diff --git a/en/OpenHarmony-Overview.md b/en/OpenHarmony-Overview.md index 594fb355e417b047d93b1de9d413540a2c839190..a8dbb1b636a19fe6a2b7e6dee741b56dac0e6289 100644 --- a/en/OpenHarmony-Overview.md +++ b/en/OpenHarmony-Overview.md @@ -127,7 +127,7 @@ The following table describes the subsystems of OpenHarmony. For details about t | 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:
- Local application data management for lightweight preference databases and relational databases
- 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 | +| Compiler and 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 | diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md index a627e1116a792c5d4fc885ae01aa6ccb172b7b1d..73bbd2d608562535e3272c1a659bcebbd39b125a 100644 --- a/en/application-dev/Readme-EN.md +++ b/en/application-dev/Readme-EN.md @@ -17,7 +17,6 @@ - Application Package Structure - [Application Package Structure in Stage Model)](quick-start/application-package-structure-stage.md) - [Application Package Structure in FA Model](quick-start/application-package-structure-fa.md) - - [HAR File Structure](quick-start/har-structure.md) - Multi-HAP Mechanism - [Multi-HAP Design Objectives](quick-start/multi-hap-objective.md) - [Multi-HAP Build View](quick-start/multi-hap-build-view.md) @@ -49,7 +48,7 @@ - Development - [Application Models](application-models/Readme-EN.md) - [UI Development](ui/Readme-EN.md) - - [Common Event and Notification](notification/Readme-EN.md) + - [Notification](notification/Readme-EN.md) - [Window Manager](windowmanager/Readme-EN.md) - [WebGL](webgl/Readme-EN.md) - [Media](media/Readme-EN.md) @@ -57,7 +56,7 @@ - [Connectivity](connectivity/Readme-EN.md) - [Data Management](database/Readme-EN.md) - [File Management](file-management/Readme-EN.md) - - [Telephony](telephony/Readme-EN.md) + - [Telephony Service](telephony/Readme-EN.md) - [Task Management](task-management/Readme-EN.md) - [Device Management](device/Readme-EN.md) - [Device Usage Statistics](device-usage-statistics/Readme-EN.md) diff --git a/en/application-dev/application-dev-guide-for-gitee.md b/en/application-dev/application-dev-guide-for-gitee.md index 96e956f86e1528c5946c094b204c83e6e7d96222..ca206e65fd11a48631e950f26c1c9b656f298e13 100644 --- a/en/application-dev/application-dev-guide-for-gitee.md +++ b/en/application-dev/application-dev-guide-for-gitee.md @@ -24,13 +24,13 @@ First thing first, familiarize yourself with the two cornerstone frameworks in O All applications should be developed on top of these frameworks. Then, equip yourself for developing the key features, with the following guidelines: -- [Common Event and Notification](notification/Readme-EN.md) +- [Notification](notification/Readme-EN.md) - [Window Manager](windowmanager/Readme-EN.md) - [WebGL](webgl/Readme-EN.md) - [Media](media/Readme-EN.md) - [Security](security/Readme-EN.md) - [Connectivity](connectivity/Readme-EN.md) -- [Telephony](telephony/Readme-EN.md) +- [Telephony Service](telephony/Readme-EN.md) - [Data Management](database/Readme-EN.md) - [Task Management](task-management/Readme-EN.md) - [Device Management](device/Readme-EN.md) @@ -40,6 +40,7 @@ Then, equip yourself for developing the key features, with the following guideli - [Application Test](application-test/Readme-EN.md) - [IDL Specifications and User Guide](IDL/idl-guidelines.md) - [Using Native APIs in Application Projects](napi/Readme-EN.md) +- [File Management](file-management/medialibrary-overview.md) ### Tools diff --git a/en/application-dev/application-dev-guide.md b/en/application-dev/application-dev-guide.md index 650eaf0b956e544bd19e8892b0c6946a6839beb5..c7b49ac56b0638e8c4ba9908582683f9c4c46d21 100644 --- a/en/application-dev/application-dev-guide.md +++ b/en/application-dev/application-dev-guide.md @@ -24,13 +24,13 @@ First thing first, familiarize yourself with the two cornerstone frameworks in O All applications should be developed on top of these frameworks. Then, equip yourself for developing the key features, with the following guidelines: -- [Common Event and Notification](notification/notification-overview.md) +- [Notification](notification/notification-overview.md) - [Window Manager](windowmanager/window-overview.md) - [WebGL](webgl/webgl-overview.md) - [Media](media/audio-overview.md) - [Security](security/userauth-overview.md) - [Connectivity](connectivity/ipc-rpc-overview.md) -- [Telephony](telephony/telephony-overview.md) +- [Telephony Service](telephony/telephony-overview.md) - [Data Management](database/database-mdds-overview.md) - [Task Management](task-management/background-task-overview.md) - [Device](device/usb-overview.md) @@ -40,6 +40,7 @@ Then, equip yourself for developing the key features, with the following guideli - [Application Test](application-test/arkxtest-guidelines.md) - [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md) - [Using Native APIs in Application Projects](napi/napi-guidelines.md) +- [File Management](file-management/medialibrary-overview.md) ### Tools diff --git a/en/application-dev/application-models/Readme-EN.md b/en/application-dev/application-models/Readme-EN.md index 6b35052ce4b7729fa566f845c9d1d367e23582f6..2c1505fc1c12e57a96f22fcda7faf92ba9ea7418 100644 --- a/en/application-dev/application-models/Readme-EN.md +++ b/en/application-dev/application-models/Readme-EN.md @@ -17,11 +17,11 @@ - ExtensionAbility Component - [ExtensionAbility Component Overview](extensionability-overview.md) - [ServiceExtensionAbility](serviceextensionability.md) - - [DataShareExtensionAbility (System Applications Only)](datashareextensionability.md) + - [DataShareExtensionAbility (for System Applications Only)](datashareextensionability.md) - [FormExtensionAbility (Widget)](widget-development-stage.md) - - [StaticSubscriberExtensionAbility](static-subscriber-extension-ability.md) - [AccessibilityExtensionAbility](accessibilityextensionability.md) - [EnterpriseAdminExtensionAbility](enterprise-extensionAbility.md) + - [InputMethodExtensionAbility](inputmethodextentionability.md) - [WindowExtensionAbility](windowextensionability.md) - [AbilityStage Component Container](abilitystage.md) - [Context](application-context-stage.md) @@ -35,16 +35,19 @@ - [Component Startup Rules](component-startup-rules.md) - Inter-Device Application Component Interaction (Continuation) - [Continuation Overview](inter-device-interaction-hop-overview.md) - - [Cross-Device Migration (System Applications Only)](hop-cross-device-migration.md) - - [Multi-device Collaboration (System Applications Only)](hop-multi-device-collaboration.md) + - [Cross-Device Migration (for System Applications Only)](hop-cross-device-migration.md) + - [Multi-device Collaboration (for System Applications Only)](hop-multi-device-collaboration.md) - [Subscribing to System Environment Variable Changes](subscribe-system-environment-variable-changes.md) - IPC - [Process Model](process-model-stage.md) - Common Events - [Introduction to Common Events](common-event-overview.md) - - [Subscribing to Common Events](common-event-subscription.md) - - [Publishing Common Events](common-event-publish.md) + - Common Event Subscription + - [Common Event Subscription Overview](common-event-subscription-overview.md) + - [Subscribing to Common Events in Dynamic Mode](common-event-subscription.md) + - [Subscribing to Common Events in Static Mode (for System Applications Only)](common-event-static-subscription.md) - [Unsubscribing from Common Events](common-event-unsubscription.md) + - [Publishing Common Events](common-event-publish.md) - [Background Services](background-services.md) - Inter-Thread Communication - [Thread Model](thread-model-stage.md) @@ -68,7 +71,7 @@ - [Creating a PageAbility](create-pageability.md) - [Starting a Local PageAbility](start-local-pageability.md) - [Stopping a PageAbility](stop-pageability.md) - - [Starting a Remote PageAbility (System Applications Only)](start-remote-pageability.md) + - [Starting a Remote PageAbility (for System Applications Only)](start-remote-pageability.md) - [Starting a Specified Page](start-page.md) - [Window Properties](window-properties.md) - [Requesting Permissions](request-permissions.md) diff --git a/en/application-dev/application-models/common-event-overview.md b/en/application-dev/application-models/common-event-overview.md index 0d3788b41b516d0af9619d320ceeefc3f52c74c5..d54fcf4786f0e22077cda0e6aae2d211bb2d0e90 100644 --- a/en/application-dev/application-models/common-event-overview.md +++ b/en/application-dev/application-models/common-event-overview.md @@ -15,11 +15,11 @@ Common events are classified into system common events and custom common events. Common events are also classified into unordered, ordered, and sticky common events. -- Unordered common events: CES forwards common events based on the subscription sequence, regardless of whether subscribers receive the events. +- Unordered common events: common events that CES forwards based on the subscription sequence, regardless of whether subscribers receive the events. -- Ordered common event: CES forwards common events to the next subscriber only after receiving a reply from the previous subscriber. +- Ordered common events: common events that CES forwards based on the subscriber priority. CES forwards common events to the subscriber with lower priority only after receiving a reply from the previous subscriber with higher priority. -- Sticky common event: a public event that can be sent to a subscriber before they initiate a subscription. Only system applications or system services can send sticky common event, and they must request the **ohos.permission.COMMONEVENT_STICKY** permission. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file). +- Sticky common events: common events that can be sent to a subscriber before they initiate a subscription. Only system applications and system services can send sticky common events, and they must request the **ohos.permission.COMMONEVENT_STICKY** permission. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file). Each application can subscribe to common events as required. After your application subscribes to a common event, the system sends it to your application every time the event is published. Such an event may be published by the system, other applications, or your own application. diff --git a/en/application-dev/application-models/common-event-static-subscription.md b/en/application-dev/application-models/common-event-static-subscription.md new file mode 100644 index 0000000000000000000000000000000000000000..85852f5712df84107c6593160d276ed33557baf9 --- /dev/null +++ b/en/application-dev/application-models/common-event-static-subscription.md @@ -0,0 +1,105 @@ +# Subscribing to Common Events in Static Mode (for System Applications Only) + +## When to Use + +A static subscriber is started once it receives a target event published by the system or application. At the same time, the **onReceiveEvent** callback is triggered, in which you can implement the service logic. For example, if an application needs to execute some initialization tasks during device power-on, the application can subscribe to the power-on event in static mode. After receiving the power-on event, the application is started to execute the initialization tasks. Subscribing to a common event in static mode is achieved by configuring a declaration file and implementing a class that inherits from **StaticSubscriberExtensionAbility**. Note that this subscribing mode has negative impact on system power consumption. Therefore, exercise caution when using this mode. + +## How to Develop + +1. Declaring a Static Subscriber + + To declare a static subscriber, create an ExtensionAbility, which is derived from the **StaticSubscriberExtensionAbility** class, in the project. The sample code is as follows: + + ```ts + import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility' + + export default class StaticSubscriber extends StaticSubscriberExtensionAbility { + onReceiveEvent(event) { + console.log('onReceiveEvent, event:' + event.event); + } + } + ``` + + You can implement service logic in the **onReceiveEvent** callback. + + + +2. Project Configuration for a Static Subscriber + + After writing the static subscriber code, configure the subscriber in the **module.json5** file. The configuration format is as follows: + + ```ts + { + "module": { + ...... + "extensionAbilities": [ + { + "name": "StaticSubscriber", + "srcEntrance": "./ets/StaticSubscriber/StaticSubscriber.ts", + "description": "$string:StaticSubscriber_desc", + "icon": "$media:icon", + "label": "$string:StaticSubscriber_label", + "type": "staticSubscriber", + "visible": true, + "metadata": [ + { + "name": "ohos.extension.staticSubscriber", + "resource": "$profile:subscribe" + } + ] + } + ] + ...... + } + } + ``` + + Pay attention to the following fields in the JSON file: + + - **srcEntrance**: entry file path of the ExtensionAbility, that is, the file path of the static subscriber declared in Step 2. + + - **type**: ExtensionAbility type. For a static subscriber, set this field to **staticSubscriber**. + + - **metadata**: level-2 configuration file information of the ExtensionAbility. The configuration information varies according to the ExtensionAbility type. Therefore, you must use different config files to indicate the specific configuration. + - **name**: name of the ExtensionAbility. For a static subscriber, declare the name as **ohos.extension.staticSubscriber** for successful identification. + - **resource**: path that stores the ExtensionAbility configuration, which is customizable. In this example, the path is **resources/base/profile/subscribe.json**. + + A level-2 configuration file pointed to by **metadata** must be in the following format: + + ```ts + { + "commonEvents": [ + { + "name": "xxx", + "permission": "xxx", + "events":[ + "xxx" + ] + } + ] + } + ``` + + If the level-2 configuration file is not declared in this format, the file cannot be identified. The fields are described as follows: + + - **name**: name of the ExtensionAbility, which must be the same as the name of **extensionAbility** declared in **module.json5**. + + - **permission**: permission required for the publisher. If a publisher without the required permission attempts to publish an event, the event is regarded as invalid and will not be published. + + - **events**: list of target events to subscribe to. + +3. Device System Configuration + + In the device system configuration file **/system/etc/app/install_list_capability.json**, add the bundle name of the static subscriber. + + ```json + { + "install_list": [ + { + "bundleName": "ohos.extension.staticSubscriber", + "allowCommonEvent": ["usual.event.A", "usual.event.B"], + } + ] + } + ``` + diff --git a/en/application-dev/application-models/common-event-subscription-overview.md b/en/application-dev/application-models/common-event-subscription-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..20064af92d3df2e6f7ab7d62c4f71f911848057a --- /dev/null +++ b/en/application-dev/application-models/common-event-subscription-overview.md @@ -0,0 +1,7 @@ +# Common Event Subscription Overview + +​The common event service provides two subscription modes: dynamic and static. The biggest difference between these two modes is that dynamic subscription requires the application to be running, while static subscription does not. + +- In dynamic subscription mode, a subscriber subscribes to common events by calling an API during the running period. For details, see [Subscribing to Common Events in Dynamic Mode](common-event-subscription.md). + +- In static subscription mode, a subscriber subscribes to common events by configuring a declaration file and implementing a class that inherits from StaticSubscriberExtensionAbility. For details, see [Subscribing to Common Events in Static Mode](common-event-static-subscription.md). diff --git a/en/application-dev/application-models/common-event-subscription.md b/en/application-dev/application-models/common-event-subscription.md index ce61e40458a7cbd5c9ec226138535da93d3766b1..6cdc52ef9b798e48a911892f965db8fbf2aaa67f 100644 --- a/en/application-dev/application-models/common-event-subscription.md +++ b/en/application-dev/application-models/common-event-subscription.md @@ -1,9 +1,9 @@ -# Subscribing to Common Events +# Subscribing to Common Events in Dynamic Mode ## When to Use -You can create a subscriber object to subscribe to a common event so as to obtain the parameters passed in the event. Certain system common events [require specific permissions](../security/accesstoken-guidelines.md) to subscribe to. For details, see [Required Permissions](../reference/apis/js-apis-commonEventManager.md#support). +In dynamic subscription mode, an application subscribes to a common event when it is running. If the subscribed event is published during the running period, the subscriber application will receive the event, together with the parameters passed in the event. For example, if an application expects to be notified of low battery so that it can reduce power consumption accordingly when running, then the application can subscribe to the low-battery event. Upon receiving the event, the application can close some unnecessary tasks to reduce power consumption. Certain system common events [require specific permissions](../security/accesstoken-guidelines.md) to subscribe to. For details, see [Required Permissions](../reference/apis/js-apis-commonEventManager.md#support). ## Available APIs diff --git a/en/application-dev/application-models/common-event-unsubscription.md b/en/application-dev/application-models/common-event-unsubscription.md index c87017ef08c05e8a22097c4bd2a05f52fc758134..1a44675d61947325a8c1a8790ff5f53626e43f57 100644 --- a/en/application-dev/application-models/common-event-unsubscription.md +++ b/en/application-dev/application-models/common-event-unsubscription.md @@ -1,9 +1,9 @@ -# Unsubscribing from Common Events +# Unsubscribing from Common Events in Dynamic Mode ## When to Use -You can call [unsubscribe()](../reference/apis/js-apis-commonEventManager.md#commoneventmanagerunsubscribe) to unsubscribe from a common event that is no longer required. +You can call [unsubscribe()](../reference/apis/js-apis-commonEventManager.md#commoneventmanagerunsubscribe) to unsubscribe from a common event that is no longer required in dynamic mode. ## Available APIs @@ -21,12 +21,12 @@ You can call [unsubscribe()](../reference/apis/js-apis-commonEventManager.md#com import commonEventManager from '@ohos.commonEventManager'; ``` -2. Subscribe to an event by following the procedure described in [Subscribing to Common Events](common-event-subscription.md). +2. Subscribe to an event by following the procedure described in [Subscribing to Common Events in Dynamic Mode](common-event-subscription.md). 3. Call **unsubscribe** in **CommonEvent** to unsubscribe from the common event. ```ts - // The subscriber object iscreated during event subscription. + // The subscriber object is created during event subscription. if (subscriber !== null) { commonEventManager.unsubscribe(subscriber, (err) => { if (err) { diff --git a/en/application-dev/application-models/datashareextensionability.md b/en/application-dev/application-models/datashareextensionability.md index 1f968abfa743d7fb917fb7db3e0e41342e41c848..f671848f890277af92fc23869c5db0d57b02a316 100644 --- a/en/application-dev/application-models/datashareextensionability.md +++ b/en/application-dev/application-models/datashareextensionability.md @@ -1,4 +1,4 @@ -# DataShareExtensionAbility (System Applications Only) +# DataShareExtensionAbility (for System Applications Only) DataShareExtensionAbility provides the data sharing capability. System applications can implement a DataShareExtensionAbility or access an existing DataShareExtensionAbility in the system. Third-party applications can only access an existing DataShareExtensionAbility. For details, see [DataShare Development](../database/database-datashare-guidelines.md). diff --git a/en/application-dev/application-models/enterprise-extensionAbility.md b/en/application-dev/application-models/enterprise-extensionAbility.md index 514e254f77981977c7c425a4ea2ddbebbcff9ca8..3750b2298ba5321194d827edde4ad7c526b467f7 100644 --- a/en/application-dev/application-models/enterprise-extensionAbility.md +++ b/en/application-dev/application-models/enterprise-extensionAbility.md @@ -1,54 +1,54 @@ # EnterpriseAdminExtensionAbility Development -## Introduction +## Introduction to EnterpriseAdminExtensionAbility -**EnterpriseAdminExtensionAbility** is essential to a mobile device management (MDM) application. When developing an MDM application for an enterprise, you must inherit the **EnterpriseAdminExtensionAbility** class and have the MDM service logic implemented in an **EnterpriseAdminExtensionAbility** instance. The **EnterpriseAdminExtensionAbility** class provides callbacks for the enable, disable, install, and uninstall events of a device administrator application, implementing notification of system administrator status changes. +EnterpriseAdminExtensionAbility is a mandatory component for Mobile Device Management (MDM) applications. When developing MDM applications for enterprises, you need to inherit EnterpriseAdminExtensionAbility and implement MDM service logic in the EnterpriseAdminExtensionAbility instance. EnterpriseAdminExtensionAbility implements notifications of system management status changes and defines the callbacks for when a device administrator application is enabled or disabled or an application is installed or uninstalled. ## Constraints -- ***Function constraints*** +- **Function constraints** - The APIs provided can be used only by device administrator applications. + EnterpriseAdminExtensionAbility is applicable only to enterprise administrator applications. -## Scenarios: Listening for the Enable, Disable, Install, and Uninstall Events of a Device Administrator Application +## Observing Activation/Deactivation of a Device Administrator Application and Installation/Removal of an Application ### Overview -**onAdminEnabled**: called when the enterprise administrator or employee deploys an MDM application and enables the DeviceAdmin permission for the application. The MDM application can set the initialization policy in the **onAdminEnabled** callback. +**onAdminEnabled**: When an enterprise administrator or employee deploys an MDM application and activates the device administrator application, this callback is invoked to notify the MDM application that the DeviceAdmin permission is activated. The initialization policy of the MDM application can set in **onAdminEnabled**. -**onAdminDisabled**: called when the system or employee disables the DeviceAdmin permission to notify the enterprise administrator that the device is no longer managed. +**onAdminDisabled**: When the device administrator application is deactivated, the callback is invoked to notify the MDM application that the DeviceAdmin permission is deactivated. -**onBundleAdded**: called to notify the enterprise administrator that the specified MDM application is installed on the device. In enterprise application administration settings, after the enterprise administrator subscribes to application installation and uninstallation events, the MDM application reports the events through the callbacks. +**onBundleAdded**: The enterprise administrator can subscribe to application installation and uninstallation events. When an application is installed on an enterprise device, the MDM application reports the event in this callback to notify the enterprise administrator. -**onBundleRemoved**: called to notify the enterprise administrator that the specified MDM application is uninstalled on the device. +**onBundleRemoved**: When an application is removed from an enterprise device, the MDM application reports the event in this callback to notify the enterprise administrator. ### Available APIs -| Class | API | Description | +| Class | API | Description | | :------------------------------ | ----------------------------------------- | ---------------------------- | -| EnterpriseAdminExtensionAbility | onAdminDisabled(): void | Called when the device administrator application is enabled.| -| EnterpriseAdminExtensionAbility | onBundleAdded(bundleName: string): void | Called when the MDM application is installed. | -| EnterpriseAdminExtensionAbility | onAdminEnabled(): void | Called when the device administrator application is disabled. | -| EnterpriseAdminExtensionAbility | onBundleRemoved(bundleName: string): void | Called when the MDM application is uninstalled. | +| EnterpriseAdminExtensionAbility | onAdminDisabled(): void | Called when a device administrator application is deactivated.| +| EnterpriseAdminExtensionAbility | onBundleAdded(bundleName: string): void | Called when an application is installed on a device. | +| EnterpriseAdminExtensionAbility | onAdminEnabled(): void | Called when a device administrator application is activated. | +| EnterpriseAdminExtensionAbility | onBundleRemoved(bundleName: string): void | Called when an application is removed from a device. | ### How to Develop -To implement **EnterpriseAdminExtensionAbility**, enable the device administrator application and create an **ExtensionAbility** instance from the code directory of the device administrator application. The procedure is as follows: +To implement EnterpriseAdminExtensionAbility, you need to activate the device administrator application and create **ExtensionAbility** in the code directory of the device administrator application. The procedure is as follows: 1. In the **ets** directory of the target module, right-click and choose **New > Directory** to create a directory named **EnterpriseExtAbility**. -2. Right-click the **EnterpriseExtAbility** directory and choose **New > TypeScript File** to create a file named **EnterpriseExtAbility.ts**. -3. Open the **EnterpriseExtAbility.ts** file and import the **EnterpriseAdminExtensionAbility** module. Customize a class that inherits from **EnterpriseAdminExtensionAbility** and add the required callbacks, such as **onAdminEnabled()** and **onAdminDisabled()**, through which the enterprise administrator can receive notification when the device administrator application is enabled or disabled. +2. Right-click the **EnterpriseExtAbility** directory, and choose **New > TypeScript File** to create a file named **EnterpriseExtAbility.ts**. +3. Open the **EnterpriseExtAbility.ts** file and import the **EnterpriseAdminExtensionAbility** module. Inherit the **EnterpriseAdminExtensionAbility** module to the custom class and add application notification callbacks, such as **onAdminEnabled()** and **onAdminDisabled()**. When the device administrator application is activated or deactivated, the device administrator can receive notifications. ```ts import EnterpriseAdminExtensionAbility from '@ohos.enterprise.EnterpriseAdminExtensionAbility'; - + export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { - + onAdminEnabled() { console.info("onAdminEnabled"); } - + onAdminDisabled() { console.info("onAdminDisabled"); } @@ -56,14 +56,14 @@ To implement **EnterpriseAdminExtensionAbility**, enable the device administrato onBundleAdded(bundleName: string) { console.info("EnterpriseAdminAbility onBundleAdded bundleName:" + bundleName) } - + onBundleRemoved(bundleName: string) { console.info("EnterpriseAdminAbility onBundleRemoved bundleName" + bundleName) } }; ``` -4. Register **ServiceExtensionAbility** in the [module.json5](../quick-start/module-configuration-file.md) file of the target module. Among the parameters, set **type** to **enterpriseAdmin** and **srcEntrance** to the code path of the current ExtensionAbility. +4. Register **ServiceExtensionAbility** in the [**module.json5**](../quick-start/module-configuration-file.md) file corresponding to the project module. Set **type** to **enterpriseAdmin** and **srcEntrance** to the path of the ExtensionAbility code. ```ts "extensionAbilities": [ @@ -78,7 +78,7 @@ To implement **EnterpriseAdminExtensionAbility**, enable the device administrato ## Example -Use the **subscribeManagedEvent** and **unsubscribeManagedEvent** APIs in the **@ohos.enterprise.adminManager** module to subscribe to and unsubscribe from the application installation and uninstallation event, respectively. After the subscription is successful, the MDM application notifies the enterprise administrator when it is installed or uninstalled on the device. +Use **subscribeManagedEvent()** and **unsubscribeManagedEvent()** in the **@ohos.enterprise.adminManager** module to subscribe to application installation and removal events. When an application is installed or removed, the MDM application is notified of the event. Then, the MDM application reports the event in the callback to notify the enterprise administrator. ```ts @State managedEvents: Array = [0,1] @@ -108,4 +108,3 @@ Use the **subscribeManagedEvent** and **unsubscribeManagedEvent** APIs in the ** } ``` - diff --git a/en/application-dev/application-models/hop-cross-device-migration.md b/en/application-dev/application-models/hop-cross-device-migration.md index a482ae26ced4987d0b0c02382ac132c42ea932c0..d90a10995f0aeba773179fc7807ab25711b4594c 100644 --- a/en/application-dev/application-models/hop-cross-device-migration.md +++ b/en/application-dev/application-models/hop-cross-device-migration.md @@ -1,4 +1,4 @@ -# Cross-Device Migration (System Applications Only)] +# Cross-Device Migration (for System Applications Only)] ## When to Use diff --git a/en/application-dev/application-models/hop-multi-device-collaboration.md b/en/application-dev/application-models/hop-multi-device-collaboration.md index 49ef26a7a11ca28273a92786eac230f5801d05cd..f5d82af32da86796d81dc1bebed1d6ff804f2532 100644 --- a/en/application-dev/application-models/hop-multi-device-collaboration.md +++ b/en/application-dev/application-models/hop-multi-device-collaboration.md @@ -1,4 +1,4 @@ -# Multi-device Collaboration (System Applications Only) +# Multi-device Collaboration (for System Applications Only) ## When to Use @@ -305,7 +305,7 @@ A system application can connect to a service on another device by calling [conn ## Using Cross-Device Ability Call -The basic principle of cross-device ability call is the same as that of intra-device ability call. For details, see [Using Ability Call to Implement UIAbility Interaction (System Applications Only)](uiability-intra-device-interaction.md#using-ability-call-to-implement-uiability-interaction-system-applications-only). +The basic principle of cross-device ability call is the same as that of intra-device ability call. For details, see [Using Ability Call to Implement UIAbility Interaction (for System Applications Only)](uiability-intra-device-interaction.md#using-ability-call-to-implement-uiability-interaction-for-system-applications-only). The following describes how to implement multi-device collaboration through cross-device ability call. @@ -319,10 +319,10 @@ The following describes how to implement multi-device collaboration through cros | startAbilityByCall(want: Want): Promise<Caller>; | Starts a UIAbility in the foreground or background and obtains the caller object for communicating with the UIAbility.| | on(method: string, callback: CalleeCallBack): void | Callback invoked when the callee ability registers a method.| | off(method: string): void | Callback invoked when the callee ability deregisters a method.| -| call(method: string, data: rpc.Sequenceable): Promise<void> | Sends agreed sequenceable data to the callee ability.| -| callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessageParcel> | Sends agreed sequenceable data to the callee ability and obtains the agreed sequenceable data returned by the callee ability.| +| call(method: string, data: rpc.Parcelable): Promise<void> | Sends agreed parcelable data to the callee ability.| +| callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequence>| Sends agreed parcelable data to the callee ability and obtains the agreed parcelable data returned by the callee ability.| | release(): void | Releases the caller object.| -| on(type: "release", callback: OnReleaseCallback): void | Callback invoked when the caller object is released.| +| on(type: "release", callback: OnReleaseCallback): void | Callback invoked when the caller object is released.| ### How to Develop @@ -348,16 +348,15 @@ The following describes how to implement multi-device collaboration through cros For the callee ability, implement the callback to receive data and the methods to marshal and unmarshal data. When data needs to be received, use **on()** to register a listener. When data does not need to be received, use **off()** to deregister the listener. 1. Configure the launch type of the UIAbility. + Set **launchType** of the callee ability to **singleton** in the **module.json5** file. - Set **launchType** of the callee ability to **singleton** in the **module.json5** file. + | JSON Field| Description| + | -------- | -------- | + | "launchType"| Ability launch type. Set this parameter to **singleton**.| - | JSON Field| Description| - | -------- | -------- | - | "launchType"| Ability launch type. Set this parameter to **singleton**.| + An example of the UIAbility configuration is as follows: - An example of the UIAbility configuration is as follows: - - + ```json "abilities":[{ "name": ".CalleeAbility", @@ -369,19 +368,18 @@ The following describes how to implement multi-device collaboration through cros "visible": true }] ``` - 2. Import the **UIAbility** module. ```ts import Ability from '@ohos.app.ability.UIAbility'; ``` - - 3. Define the agreed sequenceable data. - - The data formats sent and received by the caller and callee abilities must be consistent. In the following example, the data formats are number and string. - + 3. Define the agreed parcelable data. + + The data formats sent and received by the caller and callee abilities must be consistent. In the following example, the data formats are number and string. + + ```ts - export default class MySequenceable { + export default class MyParcelable { num: number = 0; str: string = ""; @@ -390,71 +388,69 @@ The following describes how to implement multi-device collaboration through cros this.str = string; } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); return true; } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); return true; } } ``` - 4. Implement **Callee.on** and **Callee.off**. - - In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate()** of the ability and deregistered in **onDestroy()**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. - - ```ts - const TAG: string = '[CalleeAbility]'; - const MSG_SEND_METHOD: string = 'CallSendMsg'; - - function sendMsgCallback(data) { - console.info('CalleeSortFunc called'); - - // Obtain the sequenceable data sent by the caller ability. - let receivedData = new MySequenceable(0, ''); - data.readSequenceable(receivedData); - console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`); - - // Process the data. - // Return the sequenceable data result to the caller ability. - return new MySequenceable(receivedData.num + 1, `send ${receivedData.str} succeed`); - } - - export default class CalleeAbility extends Ability { - onCreate(want, launchParam) { - try { - this.callee.on(MSG_SEND_METHOD, sendMsgCallback); - } catch (error) { - console.info(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`); - } - } + + In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate()** of the ability and deregistered in **onDestroy()**. After receiving parcelable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. - onDestroy() { - try { - this.callee.off(MSG_SEND_METHOD); - } catch (error) { - console.error(TAG, `${MSG_SEND_METHOD} unregister failed with error ${JSON.stringify(error)}`); - } - } - } - ``` - + ```ts + const TAG: string = '[CalleeAbility]'; + const MSG_SEND_METHOD: string = 'CallSendMsg'; + + function sendMsgCallback(data) { + console.info('CalleeSortFunc called'); + + // Obtain the parcelable data sent by the caller ability. + let receivedData = new MyParcelable(0, ''); + data.readParcelable(receivedData); + console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`); + + // Process the data. + // Return the parcelable data result to the caller ability. + return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`); + } + + export default class CalleeAbility extends Ability { + onCreate(want, launchParam) { + try { + this.callee.on(MSG_SEND_METHOD, sendMsgCallback); + } catch (error) { + console.info(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`); + } + } + + onDestroy() { + try { + this.callee.off(MSG_SEND_METHOD); + } catch (error) { + console.error(TAG, `${MSG_SEND_METHOD} unregister failed with error ${JSON.stringify(error)}`); + } + } + } + ``` + 4. Obtain the caller object and access the callee ability. 1. Import the **UIAbility** module. ```ts import Ability from '@ohos.app.ability.UIAbility'; ``` - 2. Obtain the caller object. - + The **context** attribute of the ability implements **startAbilityByCall** to obtain the caller object for communication. The following example uses **this.context** to obtain the **context** attribute of the ability, uses **startAbilityByCall** to start the callee ability, obtain the caller object, and register the **onRelease** listener of the caller ability. You need to implement processing based on service requirements. - + ```ts async onButtonGetRemoteCaller() { @@ -483,14 +479,14 @@ The following describes how to implement multi-device collaboration through cros For details about how to implement **getRemoteDeviceId()**, see [Starting UIAbility and ServiceExtensionAbility Across Devices (No Data Returned)](#starting-uiability-and-serviceextensionability-across-devices-no-data-returned). -5. Sends agreed sequenceable data to the callee ability. - 1. The sequenceable data can be sent to the callee ability with or without a return value. The method and sequenceable data must be consistent with those of the callee ability. The following example describes how to send data to the callee ability. +5. Sends agreed parcelable data to the callee ability. + 1. The parcelable data can be sent to the callee ability with or without a return value. The method and parcelable data must be consistent with those of the callee ability. The following example describes how to send data to the callee ability. ```ts const MSG_SEND_METHOD: string = 'CallSendMsg'; async onButtonCall() { try { - let msg = new MySequenceable(1, 'origin_Msg'); + let msg = new MyParcelable(1, 'origin_Msg'); await this.caller.call(MSG_SEND_METHOD, msg); } catch (error) { console.info(`caller call failed with ${error}`); @@ -505,12 +501,12 @@ The following describes how to implement multi-device collaboration through cros backMsg: string = ''; async onButtonCallWithResult(originMsg, backMsg) { try { - let msg = new MySequenceable(1, originMsg); + let msg = new MyParcelable(1, originMsg); const data = await this.caller.callWithResult(MSG_SEND_METHOD, msg); console.info('caller callWithResult succeed'); - let result = new MySequenceable(0, ''); - data.readSequenceable(result); + let result = new MyParcelable(0, ''); + data.readParcelable(result); backMsg(result.str); console.info(`caller result is [${result.num}, ${result.str}]`); } catch (error) { @@ -521,8 +517,8 @@ The following describes how to implement multi-device collaboration through cros 6. Release the caller object. - When the caller object is no longer required, use **release()** to release it. - + When the caller object is no longer required, use **release()** to release it. + ```ts releaseCall() { try { diff --git a/en/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md b/en/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md index 8d6bbf4eb7d09f66e1d6499c83c3b711e7209572..9fdc03477c0552f523a0ee9c40c6fa5b8d7c4363 100644 --- a/en/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md +++ b/en/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md @@ -12,10 +12,10 @@ You can also use [UIAbilityContext.setMissionIcon()](../reference/apis/js-apis-i This document describes the following operations: -- [Setting a Mission Snapshot Icon (System Applications Only)](#setting-a-mission-snapshot-icon-system-applications-only) +- [Setting a Mission Snapshot Icon (for System Applications Only)](#setting-a-mission-snapshot-icon-for-system-applications-only) - [Setting a Mission Snapshot Name](#setting-a-mission-snapshot-name) -## Setting a Mission Snapshot Icon (System Applications Only) +## Setting a Mission Snapshot Icon (for System Applications Only) Call [UIAbilityContext.setMissionIcon()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionicon) to set the icon of a mission snapshot. The icon is an object of the [PixelMap](../reference/apis/js-apis-image.md#pixelmap7) type. For details about how to obtain the context, see [Obtaining the Context of UIAbility](uiability-usage.md#obtaining-the-context-of-uiability). ```ts diff --git a/en/application-dev/application-models/serviceextensionability.md b/en/application-dev/application-models/serviceextensionability.md index edccb0b736c9ad81f5ae316e7310b6cc35ae34e0..9ff7a0ae5d6df7574da19565c81411236dba3dda 100644 --- a/en/application-dev/application-models/serviceextensionability.md +++ b/en/application-dev/application-models/serviceextensionability.md @@ -18,9 +18,9 @@ Each type of ExtensionAbility has its own context. ServiceExtensionAbility has [ This topic describes how to use ServiceExtensionAbility in the following scenarios: -- [Implementing a Background Service (System Applications Only)](#implementing-a-background-service-system-applications-only) +- [Implementing a Background Service (for System Applications Only)](#implementing-a-background-service-for-system-applications-only) -- [Starting a Background Service (System Applications Only)](#starting-a-background-service-system-applications-only) +- [Starting a Background Service (for System Applications Only)](#starting-a-background-service-for-system-applications-only) - [Connecting to a Background Service](#connecting-to-a-background-service) @@ -33,7 +33,7 @@ This topic describes how to use ServiceExtensionAbility in the following scenari > - Third-party applications can connect to ServiceExtensionAbility provided by the system only when they gain focus in the foreground. -## Implementing a Background Service (System Applications Only) +## Implementing a Background Service (for System Applications Only) [ServiceExtensionAbility](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md) provides the callbacks **onCreate()**, **onRequest()**, **onConnect()**, **onDisconnect()**, and **onDestory()**. Override them as required. The following figure shows the lifecycle of ServiceExtensionAbility. @@ -164,7 +164,7 @@ To implement a background service, manually create a ServiceExtensionAbility com ``` -## Starting a Background Service (System Applications Only) +## Starting a Background Service (for System Applications Only) A system application uses the [startServiceExtensionAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstartserviceextensionability) method to start a background service. The [onRequest()](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md#serviceextensionabilityonrequest) callback is invoked, and the **Want** object passed by the caller is received through the callback. After the background service is started, its lifecycle is independent of that of the client. In other words, even if the client is destroyed, the background service can still run. Therefore, the background service must be stopped by calling [terminateSelf()](../reference/apis/js-apis-inner-application-serviceExtensionContext.md#serviceextensioncontextterminateself) when its work is complete. Alternatively, another component can call [stopServiceExtensionAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstopserviceextensionability) to stop the background service. diff --git a/en/application-dev/application-models/start-remote-pageability.md b/en/application-dev/application-models/start-remote-pageability.md index 7d270a68058448025def436e71ace635b4a1297c..36ee305b49698c1f6e6cf216174f77212f1d53e4 100644 --- a/en/application-dev/application-models/start-remote-pageability.md +++ b/en/application-dev/application-models/start-remote-pageability.md @@ -1,4 +1,4 @@ -# Starting a Remote PageAbility (System Applications Only) +# Starting a Remote PageAbility (for System Applications Only) The **startAbility()** method in the **featureAbility** class is used to start a remote PageAbility. diff --git a/en/application-dev/application-models/static-subscriber-extension-ability.md b/en/application-dev/application-models/static-subscriber-extension-ability.md deleted file mode 100644 index ae6d9a80b7ab6c693d06e7bfe8bfb11b4db94ab8..0000000000000000000000000000000000000000 --- a/en/application-dev/application-models/static-subscriber-extension-ability.md +++ /dev/null @@ -1,107 +0,0 @@ -# StaticSubscriberExtensionAbility Development - -## Scenario Description - -​The common event service provides two subscription modes: dynamic and static. In dynamic subscription mode, a subscriber calls an API during the running period to subscribe to common events. For details, see [Subscribing to Common Events](common-event-subscription.md). In static subscription mode, no common event subscription API is called. A common event is subscribed by configuring a declaration file and implementing a class that inherits from **StaticSubscriberExtensionAbility**. A static subscriber is started once it receives a target event (for example, a power-on event) published by the system or application. At the same time, the **onReceiveEvent** callback is triggered, in which you can implement the service logic. **The static subscriber APIs are system APIs and can be used only by system applications that have passed the system-level power consumption review.** - - - -## How to Develop - -1. Prerequisites - - The application must meet the following requirements: - - The application is a system application. - - The application is developed using the full SDK. - - The application's power consumption has passed the system-level power consumption review. If you want to use static subscription in the debugging phase, add the bundle name of your application to the system configuration file **/etc/static_subscriber_config.json**. - - - -2. Declaring a Static Subscriber - - To declare a static subscriber, create an ExtensionAbility, which is derived from the **StaticSubscriberExtensionAbility** class, in the project. The sample code is as follows: - - ```ts - import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility' - - export default class StaticSubscriber extends StaticSubscriberExtensionAbility { - onReceiveEvent(event) { - console.log('onReceiveEvent, event:' + event.event); - } - } - ``` - - You can implement service logic in the **onReceiveEvent** callback. - - - -3. Project Configuration for a Static Subscriber - - After writing the static subscriber code, configure the subscriber in the **module.json5** file. The configuration format is as follows: - - ```ts - { - "module": { - ...... - "extensionAbilities": [ - { - "name": "StaticSubscriber", - "srcEntrance": "./ets/StaticSubscriber/StaticSubscriber.ts", - "description": "$string:StaticSubscriber_desc", - "icon": "$media:icon", - "label": "$string:StaticSubscriber_label", - "type": "staticSubscriber", - "visible": true, - "metadata": [ - { - "name": "ohos.extension.staticSubscriber", - "resource": "$profile:subscribe" - } - ] - } - ] - ...... - } - } - ``` - - Pay attention to the following fields in the JSON file: - - **srcEntrance**: entry file path of the ExtensionAbility, that is, the file path of the static subscriber declared in Step 2. - - **type**: ExtensionAbility type. For a static subscriber, set this field to **staticSubscriber**. - - **metadata**: level-2 configuration file information of the ExtensionAbility. The configuration information varies according to the ExtensionAbility type. Therefore, you must use different config files to indicate the specific configuration. The **metadata** field contains two keywords: **name** and **resource**. The **name** field indicates the ExtensionAbility type name. For a static subscriber, declare the name as **ohos.extension.staticSubscriber** for successful identification. The **resource** field indicates the path that stores the ExtensionAbility configuration, which is customizable. In this example, the path is **resources/base/profile/subscribe.json**. - - A level-2 configuration file pointed to by **metadata** must be in the following format: - - ```ts - { - "commonEvents": [ - { - "name": "xxx", - "permission": "xxx", - "events":[ - "xxx" - ] - } - ] - } - ``` - - If the level-2 configuration file is not declared in this format, the file cannot be identified. The fields are described as follows: - - **name**: name of the ExtensionAbility, which must be the same as the name of **extensionAbility** declared in **module.json5**. - - **permission**: permission required by the publisher. If a publisher without the required permission attempts to publish an event, the event is regarded as invalid and will not be published. - - **events**: list of subscribed target events - - - -## Samples - -For details about how to develop StaticSubscriberExtensionAbility, see [StaticSubscriber (ArkTS, API version 9, Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/StaticSubscriber). diff --git a/en/application-dev/application-models/uiability-intra-device-interaction.md b/en/application-dev/application-models/uiability-intra-device-interaction.md index 5dc8769e902c6f5eb8c3dfe3241b1287841414c5..25f509e9032a3670664937307fe4691b6a09bc28 100644 --- a/en/application-dev/application-models/uiability-intra-device-interaction.md +++ b/en/application-dev/application-models/uiability-intra-device-interaction.md @@ -15,11 +15,11 @@ This topic describes the UIAbility interaction modes in the following scenarios. - [Starting UIAbility of Another Application and Obtaining the Return Result](#starting-uiability-of-another-application-and-obtaining-the-return-result) -- [Starting UIAbility with Window Mode Specified (System Applications Only)](#starting-uiability-with-window-mode-specified-system-applications-only) +- [Starting UIAbility with Window Mode Specified (for System Applications Only)](#starting-uiability-with-window-mode-specified-for-system-applications-only) - [Starting a Specified Page of UIAbility](#starting-a-specified-page-of-uiability) -- [Using Ability Call to Implement UIAbility Interaction (System Applications Only)](#using-ability-call-to-implement-uiability-interaction-system-applications-only) +- [Using Ability Call to Implement UIAbility Interaction (for System Applications Only)](#using-ability-call-to-implement-uiability-interaction-for-system-applications-only) ## Starting UIAbility in the Same Application @@ -308,7 +308,7 @@ If you want to obtain the return result when using implicit Want to start the UI }) ``` -## Starting UIAbility with Window Mode Specified (System Applications Only) +## Starting UIAbility with Window Mode Specified (for System Applications Only) By specifying the window mode when starting the UIAbility of an application, the application can be displayed in different window modes, which can be full-screen, floating window, or split-screen. @@ -472,7 +472,7 @@ In summary, when a UIAbility instance of application A has been created and the > When the [launch type of the callee UIAbility](uiability-launch-type.md) is set to **standard**, a new instance is created each time the callee UIAbility is started. In this case, the [onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant) callback will not be invoked. -## Using Ability Call to Implement UIAbility Interaction (System Applications Only) +## Using Ability Call to Implement UIAbility Interaction (for System Applications Only) Ability call is an extension of the UIAbility capability. It enables the UIAbility to be invoked by and communicate with external systems. The UIAbility invoked can be either started in the foreground or created and run in the background. You can use the ability call to implement data sharing between two UIAbility instances (caller ability and callee ability) through IPC. @@ -488,7 +488,7 @@ Ability call is usually used in the following scenarios: - Starting the callee ability in the background - **Table 1** Terms used in the ability call +**Table 1** Terms used in the ability call | **Term**| Description| | -------- | -------- | @@ -519,15 +519,15 @@ The following figure shows the ability call process. The following table describes the main APIs used for the ability call. For details, see [AbilityContext](../reference/apis/js-apis-app-ability-uiAbility.md#caller). - **Table 2** Ability call APIs +**Table 2** Ability call APIs | API| Description| | -------- | -------- | | startAbilityByCall(want: Want): Promise<Caller> | Starts a UIAbility in the foreground (through the **want** configuration) or background (default) and obtains the caller object for communication with the UIAbility. For details, see [AbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstartabilitybycall) or [ServiceExtensionContext](../reference/apis/js-apis-inner-application-serviceExtensionContext.md#serviceextensioncontextstartabilitybycall).| | on(method: string, callback: CalleeCallBack): void | Callback invoked when the callee ability registers a method.| | off(method: string): void | Callback invoked when the callee ability deregisters a method.| -| call(method: string, data: rpc.Sequenceable): Promise<void> | Sends agreed sequenceable data to the callee ability.| -| callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessageParcel> | Sends agreed sequenceable data to the callee ability and obtains the agreed sequenceable data returned by the callee ability.| +| call(method: string, data: rpc.Parcelable): Promise<void> | Sends agreed parcelable data to the callee ability.| +| callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequence> | Sends agreed parcelable data to the callee ability and obtains the agreed parcelable data returned by the callee ability.| | release(): void | Releases the caller object.| | on(type: "release", callback: OnReleaseCallback): void | Callback invoked when the caller object is released.| @@ -571,13 +571,13 @@ For the callee ability, implement the callback to receive data and the methods t import Ability from '@ohos.app.ability.UIAbility'; ``` -3. Define the agreed sequenceable data. +3. Define the agreed parcelable data. The data formats sent and received by the caller and callee abilities must be consistent. In the following example, the data formats are number and string. ```ts - export default class MySequenceable { + export default class MyParcelable { num: number = 0 str: string = "" @@ -586,15 +586,15 @@ For the callee ability, implement the callback to receive data and the methods t this.str = string } - marshalling(messageParcel) { - messageParcel.writeInt(this.num) - messageParcel.writeString(this.str) + marshalling(messageSequence) { + messageSequence.writeInt(this.num) + messageSequence.writeString(this.str) return true } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt() - this.str = messageParcel.readString() + unmarshalling(messageSequence) { + this.num = messageSequence.readInt() + this.str = messageSequence.readString() return true } } @@ -602,7 +602,7 @@ For the callee ability, implement the callback to receive data and the methods t 4. Implement **Callee.on** and **Callee.off**. - The time to register a listener for the callee ability depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code is as follows: + The time to register a listener for the callee ability depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving parcelable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code is as follows: ```ts const TAG: string = '[CalleeAbility]'; const MSG_SEND_METHOD: string = 'CallSendMsg'; @@ -610,14 +610,14 @@ For the callee ability, implement the callback to receive data and the methods t function sendMsgCallback(data) { console.info('CalleeSortFunc called'); - // Obtain the sequenceable data sent by the caller ability. - let receivedData = new MySequenceable(0, ''); - data.readSequenceable(receivedData); + // Obtain the parcelable data sent by the caller ability. + let receivedData = new MyParcelable(0, ''); + data.readParcelable(receivedData); console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`); // Process the data. - // Return the sequenceable data result to the caller ability. - return new MySequenceable(receivedData.num + 1, `send ${receivedData.str} succeed`); + // Return the parcelable data result to the caller ability. + return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`); } export default class CalleeAbility extends Ability { diff --git a/en/application-dev/application-models/windowextensionability.md b/en/application-dev/application-models/windowextensionability.md index cf2ce01947412e479d29516601c45aebc2b55b17..069897ad02435070ac470f5d2d3d528c76b417e8 100644 --- a/en/application-dev/application-models/windowextensionability.md +++ b/en/application-dev/application-models/windowextensionability.md @@ -14,7 +14,7 @@ the context is [WindowExtensionContext](../reference/apis/js-apis-inner-applicat > -## Setting an Embedded Ability (System Applications Only) +## Setting an Embedded Ability (for System Applications Only) The **WindowExtensionAbility** class provides **onConnect()**, **onDisconnect()**, and **onWindowReady()** lifecycle callbacks, which can be overridden. @@ -78,7 +78,7 @@ To implement an embedded application, manually create a WindowExtensionAbility i ``` -## Starting an Embedded Ability (System Applications Only) +## Starting an Embedded Ability (for System Applications Only) System applications can load the created WindowExtensionAbility through the AbilityComponent. diff --git a/en/application-dev/connectivity/http-request.md b/en/application-dev/connectivity/http-request.md index da1a7e1c517f284037a41a88e2167b6d1d2406aa..a266e285245c932534873440fc777fd86ccd480d 100644 --- a/en/application-dev/connectivity/http-request.md +++ b/en/application-dev/connectivity/http-request.md @@ -1,6 +1,6 @@ # HTTP Data Request -## Use Cases +## When to Use An application can initiate a data request over HTTP. Common HTTP methods include **GET**, **POST**, **OPTIONS**, **HEAD**, **PUT**, **DELETE**, **TRACE**, and **CONNECT**. @@ -14,40 +14,49 @@ For details about how to apply for permissions, see [Access Control Development] The following table provides only a simple description of the related APIs. For details, see [API Reference](../reference/apis/js-apis-http.md). -| API | Description | -| ----------------------------------------- | --------------------------------------------------------- | -| createHttp() | Creates an HTTP request. | -| request() | Initiates an HTTP request to a given URL. | -| destroy() | Destroys an HTTP request. | +| API | Description | +| ----------------------------------------- | ----------------------------------- | +| createHttp() | Creates an HTTP request. | +| request() | Initiates an HTTP request to a given URL. | +| request2()10+ | Initiates an HTTP network request based on the URL and returns a streaming response.| +| destroy() | Destroys an HTTP request. | | on(type: 'headersReceive') | Registers an observer for HTTP Response Header events. | -| off(type: 'headersReceive') | Unregisters the observer for HTTP Response Header events. | +| off(type: 'headersReceive') | Unregisters the observer for HTTP Response Header events.| +| once\('headersReceive'\)8+ | Registers a one-time observer for HTTP Response Header events.| +| on\('dataReceive'\)10+ | Registers an observer for events indicating receiving of HTTP streaming responses. | +| off\('dataReceive'\)10+ | Unregisters the observer for events indicating receiving of HTTP streaming responses. | +| on\('dataEnd'\)10+ | Registers an observer for events indicating completion of receiving HTTP streaming responses. | +| off\('dataEnd'\)10+ | Unregisters the observer for events indicating completion of receiving HTTP streaming responses.| +| on\('dataProgress'\)10+ | Registers an observer for events indicating progress of receiving HTTP streaming responses. | +| off\('dataProgress'\)10+ | Unregisters the observer for events indicating progress of receiving HTTP streaming responses.| ## How to Develop -1. Import the required HTTP module. -2. Create an **HttpRequest** object. -3. (Optional) Listen for HTTP Response Header events. -4. Initiate an HTTP request to a given URL. -5. (Optional) Process the HTTP Response Header event and the return result of the HTTP request. +1. Import the **http** namespace from **@ohos.net.http.d.ts**. +2. Call **createHttp()** to create an **HttpRequest** object. +3. Call **httpRequest.on()** to subscribe to HTTP response header events. This API returns a response earlier than the request. You can subscribe to HTTP response header events based on service requirements. +4. Call **httpRequest.request()** to initiate a network request. You need to pass in the URL and optional parameters of the HTTP request. +5. Parse the returned result based on service requirements. +6. Call **off()** to unsubscribe from HTTP response header events. +7. Call **httpRequest.destroy()** to release resources after the request is processed. ```js +// Import the http namespace. import http from '@ohos.net.http'; -// Each HttpRequest corresponds to an HttpRequestTask object and cannot be reused. +// Each httpRequest corresponds to an HTTP request task 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+ +// This API is used to listen for the HTTP Response Header event, which is returned earlier than the result of the HTTP request. It is up to you whether to listen for HTTP Response Header events. +// 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 in extraData 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' }, @@ -55,21 +64,33 @@ httpRequest.request( extraData: { "data": "data to send", }, - connectTimeout: 60000, // Optional. The default value is 60000, in ms. + expectDataType: http.HttpDataType.STRING, // Optional. This field specifies the type of the return data. + usingCache: true, // Optional. The default value is true. + priority: 1, // Optional. The default value is 1. + connectTimeout: 60000 // Optional. The default value is 60000, in ms. readTimeout: 60000, // Optional. The default value is 60000, in ms. + usingProtocol: http.HttpProtocol.HTTP1_1, // Optional. The default protocol type is automatically specified by the system. + usingProxy: false, // Optional. By default, network proxy is not used. This field is supported since API 10. }, (err, data) => { if (!err) { - // data.result contains the HTTP response. Parse the response based on service requirements. - console.info('Result:' + data.result); - console.info('code:' + data.responseCode); - // data.header contains the HTTP response header. Parse the content based on service requirements. + // data.result carries the HTTP response. Parse the response based on service requirements. + console.info('Result:' + JSON.stringify(data.result)); + console.info('code:' + JSON.stringify(data.responseCode)); + // data.header carries the HTTP response header. Parse the content based on service requirements. console.info('header:' + JSON.stringify(data.header)); - console.info('cookies:' + data.cookies); // 8+ + console.info('cookies:' + JSON.stringify(data.cookies)); // 8+ } else { console.info('error:' + JSON.stringify(err)); - // Call the destroy() method to destroy the request if it is no longer needed. + // Unsubscribe from HTTP Response Header events. + httpRequest.off('headersReceive'); + // Call the destroy() method to release resources after HttpRequest is complete. httpRequest.destroy(); } } ); ``` + +## Samples +The following sample is provided to help you better understand how to develop the HTTP data request feature: +- [`HTTP`: Data Request (ArkTS) (API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/Connectivity/Http) +- [HTTP Communication (ArkTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/SmartChatEtsOH) diff --git a/en/application-dev/connectivity/socket-connection.md b/en/application-dev/connectivity/socket-connection.md index 96c802d565d0e58201b627d18be1e59093919a07..b0c6fcd63d49a6cf9b77662d8340cadc8f82735d 100644 --- a/en/application-dev/connectivity/socket-connection.md +++ b/en/application-dev/connectivity/socket-connection.md @@ -49,6 +49,7 @@ TLS Socket connection functions are mainly provided by the **tls_socket** module | API| Description| | -------- | -------- | +| constructTLSSocketInstance() | Creates a **TLSSocket** object.| | bind() | Binds the IP address and port number.| | close(type: 'error') | Closes a Socket connection.| | connect() | Sets up a connection to the specified IP address and port number.| @@ -189,7 +190,7 @@ TLS Socket connection process on the client: let tlsTwoWay = socket.constructTLSSocketInstance(); // Subscribe to TLS Socket connection events. - tcp.on('message', value => { + tlsTwoWay.on('message', value => { console.log("on message") let buffer = value.message let dataView = new DataView(buffer) @@ -199,10 +200,10 @@ TLS Socket connection process on the client: } console.log("on connect received:" + str) }); - tcp.on('connect', () => { + tlsTwoWay.on('connect', () => { console.log("on connect") }); - tcp.on('close', () => { + tlsTwoWay.on('close', () => { console.log("on close") }); @@ -245,23 +246,23 @@ TLS Socket connection process on the client: console.log(data); }); - // Enable the TLS Socket connection to be automatically closed after use. Then, disable listening for TLS Socket connection events. - tls.close((err) => { + // Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events. + tlsTwoWay.close((err) => { if (err) { console.log("close callback error = " + err); } else { console.log("close success"); } - tls.off('message'); - tls.off('connect'); - tls.off('close'); + tlsTwoWay.off('message'); + tlsTwoWay.off('connect'); + tlsTwoWay.off('close'); }); // Create a TLS Socket connection (for one-way authentication). let tlsOneWay = socket.constructTLSSocketInstance(); // One way authentication // Subscribe to TLS Socket connection events. - tcp.on('message', value => { + tlsTwoWay.on('message', value => { console.log("on message") let buffer = value.message let dataView = new DataView(buffer) @@ -271,10 +272,10 @@ TLS Socket connection process on the client: } console.log("on connect received:" + str) }); - tcp.on('connect', () => { + tlsTwoWay.on('connect', () => { console.log("on connect") }); - tcp.on('close', () => { + tlsTwoWay.on('close', () => { console.log("on close") }); @@ -306,16 +307,16 @@ TLS Socket connection process on the client: console.log(data); }); - // Enable the TLS Socket connection to be automatically closed after use. Then, disable listening for TLS Socket connection events. - tls.close((err) => { + // Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events. + tlsTwoWay.close((err) => { if (err) { console.log("close callback error = " + err); } else { console.log("close success"); } - tls.off('message'); - tls.off('connect'); - tls.off('close'); + tlsTwoWay.off('message'); + tlsTwoWay.off('connect'); + tlsTwoWay.off('close'); }); ``` diff --git a/en/application-dev/database/database-datashare-guidelines.md b/en/application-dev/database/database-datashare-guidelines.md index 1f25dccf2a36f3bbedb5728291e8e11b3292476e..580811158051b5b6d5d2137f4b14654a46e891b9 100644 --- a/en/application-dev/database/database-datashare-guidelines.md +++ b/en/application-dev/database/database-datashare-guidelines.md @@ -34,7 +34,7 @@ There are two roles in **DataShare**: - Data provider: adds, deletes, modifies, and queries data, opens files, and shares data. - Data consumer: accesses the data provided by the provider using **DataShareHelper**. -### Data Provider Application Development (Only for System Applications) +### Data Provider Application Development (for System Applications Only) [DataShareExtensionAbility](../reference/apis/js-apis-application-dataShareExtensionAbility.md) provides the following APIs. You can override these APIs as required. diff --git a/en/application-dev/device/pointerstyle-guidelines.md b/en/application-dev/device/pointerstyle-guidelines.md index cecab92b282e2da7a3bb966bcedeefa84768f22e..bcc09093eed4440a0c5e62c5d4cfe37a3f954c87 100644 --- a/en/application-dev/device/pointerstyle-guidelines.md +++ b/en/application-dev/device/pointerstyle-guidelines.md @@ -15,11 +15,11 @@ import pointer from '@ohos.multimodalInput.pointer'; The following table lists the common APIs for mouse pointer management. For details about the APIs, see [ohos.multimodalInput.pointer](../reference/apis/js-apis-pointer.md). | Instance | API | Description | -| ------- | ------------------------------------------------------------ | --------------------------------------------------------------- | -| pointer | function isPointerVisible(callback: AsyncCallback\): void; | Checks the visible status of the mouse pointer. | -| pointer | function setPointerVisible(visible: boolean, callback: AsyncCallback\): void; | Sets the visible status of the mouse pointer. This setting takes effect for the mouse pointer globally. | +| ------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| pointer | function isPointerVisible(callback: AsyncCallback\): void; | Checks the visible status of the mouse pointer. | +| pointer | function setPointerVisible(visible: boolean, callback: AsyncCallback\): void; | Sets the visible status of the mouse pointer. This setting takes effect for the mouse pointer globally.| | pointer | function setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback\): void; | Sets the mouse pointer style. This setting takes effect for the mouse pointer style of a specified window. | -| pointer | function getPointerStyle(windowId: number, callback: AsyncCallback\): void; | Obtains the mouse pointer style. | +| pointer | function getPointerStyle(windowId: number, callback: AsyncCallback\): void; | Obtains the mouse pointer style. | ## Hiding the Mouse Pointer @@ -77,43 +77,48 @@ When designing a color picker, you can have the mouse pointer switched to the co 5. Set the mouse pointer to the default style. ```js +import pointer from '@ohos.multimodalInput.pointer'; import window from '@ohos.window'; // 1. Enable the color pickup function. // 2. Obtain the window ID. -window.getTopWindow((error, windowClass) => { - windowClass.getProperties((error, data) => { - var windowId = data.id; - if (windowId < 0) { - console.log(`Invalid windowId`); - return; - } - try { - // 3. Set the mouse pointer to the color picker style. - pointer.setPointerStyle(windowId, pointer.PointerStyle.COLOR_SUCKER).then(() => { - console.log(`Successfully set mouse pointer style`); - }); - } catch (error) { - console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(message)}`); - } - }); +window.getLastWindow(this.context, (error, windowClass) => { + if (error.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); + return; + } + var windowId = windowClass.getWindowProperties().id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + // 3. Set the mouse pointer to the color picker style. + pointer.setPointerStyle(windowId, pointer.PointerStyle.COLOR_SUCKER).then(() => { + console.log(`Successfully set mouse pointer style`); + }); + } catch (error) { + console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(`message`)}`); + } }); // 4. End color pickup. -window.getTopWindow((error, windowClass) => { - windowClass.getProperties((error, data) => { - var windowId = data.id; - if (windowId < 0) { - console.log(`Invalid windowId`); - return; - } - try { - // 5. Set the mouse pointer to the default style. - pointer.setPointerStyle(windowId, pointer.PointerStyle.DEFAULT).then(() => { - console.log(`Successfully set mouse pointer style`); - }); - } catch (error) { - console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(message)}`); - } - }); +window.getLastWindow(this.context, (error, windowClass) => { + if (error.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); + return; + } + var windowId = windowClass.getWindowProperties().id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + // 5. Set the mouse pointer to the default style. + pointer.setPointerStyle(windowId, pointer.PointerStyle.DEFAULT).then(() => { + console.log(`Successfully set mouse pointer style`); + }); + } catch (error) { + console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(`message`)}`); + } }); ``` diff --git a/en/application-dev/dfx/hiappevent-guidelines.md b/en/application-dev/dfx/hiappevent-guidelines.md index 9991e10c731d9130a7c1f52154e18ac19bce336d..640b9185ee236dbe0fb5dfe3808b14322a401a23 100644 --- a/en/application-dev/dfx/hiappevent-guidelines.md +++ b/en/application-dev/dfx/hiappevent-guidelines.md @@ -45,7 +45,7 @@ The following table provides only a brief description of related APIs. For detai The following example illustrates how to log and subscribe to button click events of users. -1. Create an eTS application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **ets** > **entryability** > **EntryAbility.ts**, and double-click **EntryAbility.ts**. Then, add an event watcher to subscribe to button click events. The complete sample code is as follows: +1. Create an ArkTS application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **ets** > **entryability** > **EntryAbility.ts**, and double-click **EntryAbility.ts**. Then, add an event watcher to subscribe to button click events. The complete sample code is as follows: ```js import hilog from '@ohos.hilog'; diff --git a/en/application-dev/faqs/faqs-device-management.md b/en/application-dev/faqs/faqs-device-management.md index dd836eb11abfbee3979f5a604eb5aa734d0d9112..ea71edd6c9940437e197be35e60a6638c73ae88d 100644 --- a/en/application-dev/faqs/faqs-device-management.md +++ b/en/application-dev/faqs/faqs-device-management.md @@ -2,23 +2,21 @@ ## How do I obtain the DPI of a device? -Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9 - -Import the **\@ohos.display** module and call the **getDefaultDisplay** API. +Applicable to: OpenHarmony 3.2 Beta5, stage model of API version 9 -Example: +Import the **@ohos.display** module and call the **getDefaultDisplaySync** API. +**Example** ``` import display from '@ohos.display'; -display.getDefaultDisplay((err, data) => { - if (err.code) { - console.error('Test Failed to obtain the default display object. Code: ' + JSON.stringify(err)); - return; - } - console.info('Test Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); - console.info('Test densityDPI:' + JSON.stringify(data.densityDPI)); -}); +let displayClass = null; +try { + displayClass = display.getDefaultDisplaySync(); + console.info('Test densityDPI:' + JSON.stringify(data.densityDPI)); +} catch (exception) { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); +} ``` ## How do I obtain the type of the device where the application is running? diff --git a/en/application-dev/media/Readme-EN.md b/en/application-dev/media/Readme-EN.md index 94f8605a284976058c8df8537a5ae9aa4a624740..f6902595cadbea27765ebf1812544821b3c68a09 100755 --- a/en/application-dev/media/Readme-EN.md +++ b/en/application-dev/media/Readme-EN.md @@ -12,10 +12,10 @@ - [Audio Routing and Device Management Development](audio-routing-manager.md) - [AVPlayer Development (Recommended)](avplayer-playback.md) - [AVRecorder Development (Recommended)](avrecorder.md) - - [Audio Playback Development (To Be Deprecated)](audio-playback.md) - - [Audio Recording Development (To Be Deprecated)](audio-recorder.md) - - [Video Playback Development (To Be Deprecated)](video-playback.md) - - [Video Recording Development (To Be Deprecated)](video-recorder.md) + - [Audio Playback Development (To Be Deprecated Soon)](audio-playback.md) + - [Audio Recording Development (To Be Deprecated Soon)](audio-recorder.md) + - [Video Playback Development (To Be Deprecated Soon)](video-playback.md) + - [Video Recording Development (To Be Deprecated Soon)](video-recorder.md) - AVSession - [AVSession Overview](avsession-overview.md) diff --git a/en/application-dev/media/avplayer-playback.md b/en/application-dev/media/avplayer-playback.md index 324dd43e6f73d46e5f0d264ae81ba36802ee6021..9a7d9ffa10e2de83e676adbd2c5af7f9b3ba35af 100644 --- a/en/application-dev/media/avplayer-playback.md +++ b/en/application-dev/media/avplayer-playback.md @@ -292,13 +292,13 @@ export class AVPlayerDemo { async avPlayerDemo() { // Create an AVPlayer instance. this.avPlayer = await media.createAVPlayer() - let fdPath = 'fd://' - let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements. - // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" command. - let path = pathDir + '/H264_AAC.mp4' - let file = await fs.open(path) - fdPath = fdPath + '' + file.fd - this.avPlayer.url = fdPath + let fileDescriptor = undefined + // Use getRawFileDescriptor of the resource management module to obtain the media assets in the application, and use the fdSrc attribute of the AVPlayer to initialize the media assets. + // For details on the fd/offset/length parameter, see the Media API. The globalThis.abilityContext parameter is a system environment variable and is saved as a global variable on the main page during the system boost. + await globalThis.abilityContext.resourceManager.getRawFileDescriptor('H264_AAC.mp4').then((value) => { + fileDescriptor = {fd: value.fd, offset: value.offset, length: value.length} + }) + this.avPlayer.fdSrc = fileDescriptor } } ``` diff --git a/en/application-dev/media/opensles-capture.md b/en/application-dev/media/opensles-capture.md index 4e1775e178db20e01f15ee7a9b8f685a5c47b07b..3c33b37076ac14d98b550ba7b1a7e36bfe1cb048 100644 --- a/en/application-dev/media/opensles-capture.md +++ b/en/application-dev/media/opensles-capture.md @@ -53,10 +53,10 @@ To use OpenSL ES to develop the audio recording function in OpenHarmony, perform // Configure the parameters based on the audio file format. SLDataFormat_PCM format_pcm = { - SL_DATAFORMAT_PCM, - OHOS::AudioStandard::AudioChannel::MONO, - OHOS::AudioStandard::AudioSamplingRate::SAMPLE_RATE_44100, - OHOS::AudioStandard::AudioSampleFormat::SAMPLE_S16LE, + SL_DATAFORMAT_PCM, // Input audio format. + 1, // Mono channel. + SL_SAMPLINGRATE_44_1, // Sampling rate, 44100 Hz. + SL_PCMSAMPLEFORMAT_FIXED_16, // Audio sampling format, a signed 16-bit integer in little-endian format. 0, 0, 0 diff --git a/en/application-dev/notification/Readme-EN.md b/en/application-dev/notification/Readme-EN.md index bf85581053f30d6aa56e0218c51339ef6ee3f268..55070f9e38666be2c6cd5cf87b3d3680df0293ba 100644 --- a/en/application-dev/notification/Readme-EN.md +++ b/en/application-dev/notification/Readme-EN.md @@ -1,7 +1,7 @@ # Notification - [Notification Overview](notification-overview.md) -- [Notification Subscription (Open Only to System Applications)](notification-subscription.md) +- [Notification Subscription (for System Applications)](notification-subscription.md) - [Enabling Notification](notification-enable.md) - Publishing a Notification - [Publishing a Basic Notification](text-notification.md) diff --git a/en/application-dev/notification/notification-subscription.md b/en/application-dev/notification/notification-subscription.md index c62b65a25c4d80b37610449e6309e05ef259893f..95fe77de7feead97208082c12519523588cd6521 100644 --- a/en/application-dev/notification/notification-subscription.md +++ b/en/application-dev/notification/notification-subscription.md @@ -1,4 +1,4 @@ -# Notification Subscription (Open Only to System Applications) +# Notification Subscription (for System Applications Only) To receive notifications, an application must subscribe to notifications first. The notification subsystem provides two types of subscription APIs, allowing applications to subscribe to notifications from all applications or notifications from a specific application. diff --git a/en/application-dev/notification/text-notification.md b/en/application-dev/notification/text-notification.md index a9d9bdaaaccc731f0e7cec7e3f7a7e74a3aa41d6..7901a78a4c547ca02caae191b551d27f6cae3e3a 100644 --- a/en/application-dev/notification/text-notification.md +++ b/en/application-dev/notification/text-notification.md @@ -127,10 +127,10 @@ The following table describes the APIs for notification publishing. You specify Below is an example of the multi-line notification. ![en-us_image_0000001417062446](figures/en-us_image_0000001417062446.png) - - In addition to the parameters in the normal text notification, the picture-attached text notification provides the **picture**, **briefText**, and **expandedTitle** parameters. The value of **picture** is a pixel map that does not exceed 2 MB. + - In addition to the parameters in the normal text notification, the picture-attached text notification provides the **picture**, **briefText**, and **expandedTitle** parameters. The value of **picture** is a [PixelMap](../reference/apis/js-apis-image.md#pixelmap7) object that does not exceed 2 MB. ```ts - let notificationPicture: PixelMap = undefined; // Obtain the pixel map information. + let imagePixelMap: PixelMap = undefined; // Obtain the PixelMap information. let notificationRequest: notificationManager.NotificationRequest = { id: 1, content: { @@ -141,7 +141,7 @@ The following table describes the APIs for notification publishing. You specify additionalText: 'test_additionalText', briefText: 'test_briefText', expandedTitle: 'test_expandedTitle', - picture: notificationPicture + picture: imagePixelMap } } } diff --git a/en/application-dev/quick-start/Readme-EN.md b/en/application-dev/quick-start/Readme-EN.md index 439bbdcb9d9455a36c75ceb8ba39e728d1aecebd..91136d49f0db6aa18ecc86447894b922f9c263ff 100644 --- a/en/application-dev/quick-start/Readme-EN.md +++ b/en/application-dev/quick-start/Readme-EN.md @@ -1,4 +1,5 @@ # Quick Start + - Getting Started - [Before You Start](start-overview.md) - [Getting Started with ArkTS in Stage Model](start-with-ets-stage.md) @@ -10,7 +11,6 @@ - Application Package Structure - [Application Package Structure in Stage Model](application-package-structure-stage.md) - [Application Package Structure in FA Model](application-package-structure-fa.md) - - [HAR File Structure](har-structure.md) - Multi-HAP Mechanism - [Multi-HAP Design Objectives](multi-hap-objective.md) - [Multi-HAP Build View](multi-hap-build-view.md) @@ -18,6 +18,16 @@ - [Multi-HAP Usage Rules](multi-hap-rules.md) - [Multi-HAP Operation Mechanism and Data Communication Modes](multi-hap-principles.md) - [Application Installation and Uninstallation Process](application-package-install-uninstall.md) + - [Application Package Update Process](application-package-update.md) + - Shared Package + - [Shared Package Overview](shared-guide.md) + - [HAR](har-package.md) + - HSP + - [In-Application HSP Development](in-app-hsp.md) + - [Inter-Application HSP Development (for System Applications Only)](cross-app-hsp.md) + - Quick Fix + - [Quick Fix Overview](quickfix-principles.md) + - [CLI-based Quick Fix Development](quickfix-debug.md) - Application Configuration Files in Stage Model - [Application Configuration File Overview (Stage Model)](application-configuration-file-overview-stage.md) - [app.json5 Configuration File](app-configuration-file.md) diff --git a/en/application-dev/quick-start/application-package-structure-stage.md b/en/application-dev/quick-start/application-package-structure-stage.md index b9bd91d798c6a57c06c74cebb38bf558c8fa011d..cb6dc3b12ef12ff249d8afaa9871f901babd9412 100644 --- a/en/application-dev/quick-start/application-package-structure-stage.md +++ b/en/application-dev/quick-start/application-package-structure-stage.md @@ -1,17 +1,17 @@ # Application Package Structure in Stage Model -To develop an application based on the [stage model](application-configuration-file-overview-stage.md), it is essential to understand the structure of the application package created after the application is built and packaged. +To develop an application based on the [stage model](application-configuration-file-overview-stage.md), it will be helpful if you have a basic understanding of the structure of the application package created after the application is built and packaged, as well as the related basic concepts. -- In development, an application contains one or more modules. You can [create modules](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/ohos-adding-deleting-module-0000001218760594-V3) in the application project in [DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio/). As a basic functional unit of an OpenHarmony application/service, a module contains source code, resource files, third-party libraries, and application/service configuration files, and can be built and run independently. Modules can be classified as Ability or Library. A module of the Ability type is built into a Harmony Ability Package (HAP) file in .hap format, and a module of the Library type is built into a [Harmony Ability Resources (HAR) file](har-structure.md) in .tgz format. +- In development, an application contains one or more modules. You can [create modules](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/ohos-adding-deleting-module-0000001218760594-V3) in the application project in [DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio/). As a basic functional unit of an OpenHarmony application/service, a module contains source code, resource files, third-party libraries, and application/service configuration files, and can be built and run independently. Modules can be classified as Ability or Library. A module of the Ability type is built into a Harmony Ability Package (HAP) file, and a module of the Library type is built into a [Harmony Archive (HAR)](har-package.md) file or a [Harmony Shared Package (HSP)](shared-guide.md). A module can contain one or more [UIAbility](../application-models/uiability-overview.md) components, as shown in the figure below. - **Figure 1** Relationship between modules and UIAbility components + **Figure 1** Relationship between modules and UIAbility components ![ability-and-module](figures/ability-and-module.png) - Unless otherwise specified, the modules described in this document refer to the modules of the Ability type. + Unless otherwise specified, the modules described in this document refer to the modules of the Ability type. - As aforementioned, you can build an application into one or more HAP files. The HAP file is the basic unit for installing an application. It provides code, resources, third-party libraries, and a configuration file. HAP files can be classified as Entry or Feature. - HAP of the entry type: main module of the application, whose **type** field is set to **"entry"** in the [module.json5](module-configuration-file.md) file. In an application, each type of device supports only one HAP of the entry type, which is typically used to implement the application's entry screen, entry icon, or headline feature. @@ -27,6 +27,6 @@ To develop an application based on the [stage model](application-configuration-f - The **module.json** file is the configuration file indispensable in a HAP file. It consists of **module.json5** and **app.json5** in the project configuration. While DevEco Studio provides default configuration, you must modify the configuration as needed. For details about the configuration fields, see [Application Configuration Files in Stage Model](application-configuration-file-overview-stage.md). - The **pack.info** file describes the HAP attributes in the bundle, for example, **bundleName** and **versionCode** in **app** and **name**, **type**, and **abilities** in **module**. The file is automatically generated when DevEco Studio generates the bundle. - **Figure 2** Application package structure in stage model - - ![app-pack-stage](figures/app-pack-stage.png) \ No newline at end of file + **Figure 2** Application package structure in stage model + + ![app-pack-stage](figures/app-pack-stage.png) diff --git a/en/application-dev/quick-start/application-package-update.md b/en/application-dev/quick-start/application-package-update.md new file mode 100644 index 0000000000000000000000000000000000000000..0137bc47e7ad78345da1128cf423e445d8456f97 --- /dev/null +++ b/en/application-dev/quick-start/application-package-update.md @@ -0,0 +1,5 @@ +# Application Package Update Process +The OpenHarmony bundle manager service allows application packages to be updated under the following scenarios: + +1. In the application market: The application market notifies the user of an available update, and the user can install the update by following the onscreen instructions. +2. In the application: When the application for which an update is available starts up, the application market notifies the user of the update, and the user can install the update by following the onscreen instructions. diff --git a/en/application-dev/quick-start/cross-app-hsp.md b/en/application-dev/quick-start/cross-app-hsp.md new file mode 100644 index 0000000000000000000000000000000000000000..15345c966babd31b925d29160325eaf66e5b1140 --- /dev/null +++ b/en/application-dev/quick-start/cross-app-hsp.md @@ -0,0 +1,224 @@ +# Inter-Application HSP Development + +An inter-application Harmony Shared Package (HSP) is a file used for code and resource sharing between the host application and other applications. +The host application of an inter-application HSP is a special form of application, which consists of only one HSP. Instead of running independently on a device, the host application runs by being referenced by dependencies of common application modules. When a common application is running, it can invoke capabilities provided by the inter-application HSP dynamically as needed. + +## Precautions +1. The code of an inter-application HSP runs in the application process. When invoking the code, implement an exception capture and fault tolerance mechanism to avoid stability issues caused by malfunctioning of the inter-application HSP. +2. An application can depend on multiple inter-application HSP files at the same time. +3. The inter-application HSP may slow down the startup of the application that depends on it. To avoid significant increase in the startup delay, limit the number of inter-application HSP dependencies within 16. +4. Third-party developers can only use the system-provided inter-application HSP files. + +## Inter-Application HSP Usage +An inter-application HSP works by combining the following parts: + +[HAR](har-package.md): contains only objects and methods to be exported and therefore comes in a small size. By integrating the HAR into your application project, you can call the objects and methods therein to implement features. + +HSP: contains the actual implementation code, including the JS/TS code, C++ libraries, resources, and configuration files. It is either released to the application market or integrated into the system version. + +### Integrating the HAR in an Inter-Application HSP +Define the interfaces to be exported in the **index.d.ets** file in the HAR, which is the entry to the declaration file exported by the inter-application HSP. The path of the **index.d.ets** file is as follows: +``` +src +├── main +| └── module.json5 +├── index.d.ets +└── package.json +``` +Below is an example of the **index.d.ets** file content: +```ts +@Component +export declare struct UIComponent { + build():void; +} + +export declare function hello(): string; + +export declare function foo1(): string; + +export declare function foo2(): string; + +export declare function nativeHello(): string; +``` +In the example, **UIComponent** is an ArkUI component, **hello()**, **foo1()**, and **foo2()** are TS methods, and **nativeHello()** is an native method. Specific implementation is as follows: +#### ArkUI Components +The following is an implementation example of ArkUI components in the HSP: +```ts +// lib/src/main/ets/ui/MyUIComponent.ets +@Component +export struct UIComponent { + @State message: string = 'Hello World' + build() { + Column() { + Text(this.message) + .fontSize(32) + .padding(8) + .fontColor(0xffffff) + .backgroundColor(0x0000ff) + }.padding(8).width('100%') + } +} +``` + +#### **TS Methods** +The following is an implementation example of TS methods in the HSP: +```ts +export function hello(name: string): string { + return "hello + " + name; +} + +export function foo1() { + return "foo1"; +} + +export function foo2() { + return "foo2"; +} +``` +#### **Native Methods** +The following is an implementation example of native methods in the HSP: +```C++ +#include "napi/native_api.h" +#include +#include +#include + +const std::string libname = "liba"; +const std::string version = "v10001"; + +static napi_value Hello(napi_env env, napi_callback_info info) { + napi_value ret; + std::string msg = libname + ":native hello, " + version; + napi_create_string_utf8(env, msg.c_str(), msg.length(), &ret); + return ret; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) { + napi_property_descriptor desc[] = { + {"nativeHello", nullptr, Hello, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "liba", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterLibaModule(void) { + napi_module_register(&demoModule); +} +``` +### Using the Capabilities Exported from the HAR +To start with, [configure dependency](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-development-npm-package-0000001222578434#section89674298391) on the HAR. The dependency information will then be generated in the **module.json** file of the corresponding module, as shown in the following: +```json +"dependencies": [ + { + "bundleName": "com.share.liba", + "moduleName": "liba", + "versionCode": 10001 + } +] +``` +In the preceding information, **bundleName**, **moduleName**, and **versionCode** indicate the bundle name, module name, and version number of the inter-application HSP, respectively. +#### Referencing ArkUI Components in the HAR +After configuring the dependency on the HAR, you can reference ArkUI components exported from the HAR by using **import**. The sample code is as follows: +``` ts +import { UIComponent } from 'liba' + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + build() { + Row() { + // Reference the ArkUI component in the HAR. + UIComponent() + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} +``` + +#### Referencing TS Classes and Methods in the HAR +To reference the TS classes and methods exported from the HAR, use **import** as follows: +``` ts +import { foo1 } from 'liba' +import { foo2 } from 'liba' + +@Component +struct Index { + build() { + Row() { + Column() { + Button('Button') + .onClick(()=>{ + // Reference the TS methods in the HAR. + foo1(); + foo2(); + }) + } + .width('100%') + } + .height('100%') + } +} +``` +#### Referencing Native Methods in the HAR +To reference the native methods exported from the HAR, use **import** as follows: +``` ts +import { nativeHello } from 'liba' + +@Component +struct Index { + build() { + Row() { + Column() { + Button('Button') + .onClick(()=>{ + // Reference the native method in the HAR. + nativeHello(); + }) + } + .width('100%') + } + .height('100%') + } +} +``` + +## Inter-Application HSP Distribution +Inter-application HSPs are not completely integrated into an application. They are distributed by being preset in the system version or installed with an application on the device. To be specific: +1. Some frequently-used inter-application HSPs are preset in the system version. +2. When a user downloads an application from the application market, if the application market detects that the application depends on one or more inter-application HSPs and any of these HSPs are not installed on the target device, it will download the application as well as the missing HSPs for the user. In this way, the application can use the features shared through the HSPs properly. + +### Inter-Application HSP Debugging Mode +You can debug an inter-application HSP after it is distributed to a device. If the aforementioned distribution methods are not applicable, you can distribute the HSP by running **bm** commands. The procedure is as follows: + +> **NOTE** +> +> Do not reverse steps 2 and 3. Otherwise, your application will fail to be installed due to a lack of the required inter-application HSP. For more information about the **bm** commands, see [Bundle Management](../../readme/bundle-management.md). + +1. Obtain the inter-application HSP installation package. +2. Run the following **bm** command to install the inter-application HSP. +``` +bm install -s sharebundle.hsp +``` +3. Run the following **bm** command to install the HAP file of your application. +``` +bm install -p feature.hap +``` +4. Start your application and start debugging. diff --git a/en/application-dev/quick-start/figures/in-app-hsp-har.png b/en/application-dev/quick-start/figures/in-app-hsp-har.png new file mode 100644 index 0000000000000000000000000000000000000000..b4473deed92ed251cff11bee403c32cdd39556d8 Binary files /dev/null and b/en/application-dev/quick-start/figures/in-app-hsp-har.png differ diff --git a/en/application-dev/quick-start/figures/quick-fix-debug.png b/en/application-dev/quick-start/figures/quick-fix-debug.png new file mode 100644 index 0000000000000000000000000000000000000000..4e7084f30e2d2b26be811c8b8a6c9ec34a005c9e Binary files /dev/null and b/en/application-dev/quick-start/figures/quick-fix-debug.png differ diff --git a/en/application-dev/quick-start/figures/quick-fix-devel_release.png b/en/application-dev/quick-start/figures/quick-fix-devel_release.png new file mode 100644 index 0000000000000000000000000000000000000000..34b701fafe5d319da6b552c5d86305151e8e28b3 Binary files /dev/null and b/en/application-dev/quick-start/figures/quick-fix-devel_release.png differ diff --git a/en/application-dev/quick-start/figures/quick_fix_bundle_struct.png b/en/application-dev/quick-start/figures/quick_fix_bundle_struct.png new file mode 100644 index 0000000000000000000000000000000000000000..730414e3ba2fccbb58a27f83ce1afc572544f366 Binary files /dev/null and b/en/application-dev/quick-start/figures/quick_fix_bundle_struct.png differ diff --git a/en/application-dev/quick-start/figures/quick_fix_gen_abc.png b/en/application-dev/quick-start/figures/quick_fix_gen_abc.png new file mode 100644 index 0000000000000000000000000000000000000000..3e549ec79cad4a76a55ccab4dbb769b756d9936a Binary files /dev/null and b/en/application-dev/quick-start/figures/quick_fix_gen_abc.png differ diff --git a/en/application-dev/quick-start/figures/quick_fix_gen_so.png b/en/application-dev/quick-start/figures/quick_fix_gen_so.png new file mode 100644 index 0000000000000000000000000000000000000000..31717ca38c7e64983b9b3c95672fe966decf6945 Binary files /dev/null and b/en/application-dev/quick-start/figures/quick_fix_gen_so.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 index 87289c7776cb3dc33b73abc25cb3ef2da06e6eca..c5b0788516215c4ccd7a53fd0482afa4221b9644 100644 --- a/en/application-dev/quick-start/full-sdk-switch-guide.md +++ b/en/application-dev/quick-start/full-sdk-switch-guide.md @@ -16,7 +16,7 @@ Manually download the system-specific full SDK package from the mirror. For deta ## Checking the Local SDK Location -In this example, an eTS project is used. For a JS project, replace **ets** with **js**. +In this example, an ArkTS 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. diff --git a/en/application-dev/quick-start/har-package.md b/en/application-dev/quick-start/har-package.md new file mode 100644 index 0000000000000000000000000000000000000000..71cc22a71f970d6fe9e7d3638b36da0e16b9d8de --- /dev/null +++ b/en/application-dev/quick-start/har-package.md @@ -0,0 +1,172 @@ +# HAR +A Harmony Archive (HAR) is a static shared package that can contain code, C++ libraries, resources, and configuration files. It enables modules and projects to share code related to ArkUI components, resources, and more. Unlike a Harmony Ability Package (HAP), a HAR cannot be independently installed on a device. Instead, it can be referenced only as the dependency of an application module. + +## Creating a HAR Module +You can kickstart your HAR module development with the module template of the **Library** type in DevEco Studio. By default, obfuscation is disabled for the HAR module. To enable this feature, set **artifactType** in the **build-profile.json5** file of the HAR module to **obfuscation** as follows: + +```json +{ + "apiType": "stageMode", + "buildOption": { + "artifactType": "obfuscation" + } +} +``` +The value options of **artifactType** are as follows, and the default value is **original**: +- **original**: Code is not obfuscated. +- **obfuscation**: Code is obfuscated using Uglify. + +When obfuscation is enabled, DevEco Studio compiles, obfuscates, and compresses code during HAR building, thereby protecting your code assets. + +> **NOTE** +> +> If **artifactType** is set to **obfuscation**, **apiType** must be set to **stageMode**, because obfuscation is available only in the stage model. + +## Precautions for HAR Development +- The HAR does not support the declaration of **abilities** and **extensionAbilities** in its configuration file. +- The HAR does not support the declaration of pages in its configuration file. +- The HAR does not support **worker** configuration under **buildOption** in the **build-profile.json5** file. +- The HAR of the FA model and that of the stage model cannot be referenced by each other. +- The HAR of the stage model cannot reference content in the **AppScope** folder. This is because the content in the **AppScope** folder is not packaged into the HAR during compilation and building. + +## Exporting ArkUI Components, APIs, and Resources of the HAR +The **index.ets** file acts as the entry of the HAR export declaration file and is where the HAR exports APIs. This file is automatically generated by DevEco Studio by default. You can specify another file as the entry declaration file in the **main** field in the **package.json** file of the module. The code snippet is as follows: +```json +{ + "main": "index.ets" +} +``` +### Exporting ArkUI Components +Use **export** to export the ArkUI components. The code snippet is as follows: +```js +// library/src/main/ets/components/MainPage/MainPage.ets +@Component +export struct MainPage { + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} +``` +In the **index.ets** file, declare the APIs that the HAR exposes to external systems. The code snippet is as follows: +```js +// library/index.ets +export { MainPage } from './src/main/ets/components/MainPage/MainPage' +``` +### Exporting TS Classes and Methods +Use **export** to export TS classes and methods. Multiple TS classes and methods can be exported at the same time. The code snippet is as follows: +```js +// library/src/main/ts/test.ets +export class Log { + static info(msg) { + console.info(msg); + } +} + +export function func() { + return "har func"; +} + +export function func2() { + return "har func2"; +} +``` +In the **index.ets** file, declare the APIs that the HAR exposes to external systems. The code snippet is as follows: +```js +// library/index.ets +export { Log } from './src/main/ts/test' +export { func } from './src/main/ts/test' +export { func2 } from './src/main/ts/test' +``` +### Resources +Resources are packed into the HAR when it is being compiled and packaged. During compilation and building of a HAP, DevEco Studio collects resource files from the HAP module and its dependent modules. If the resource files of different modules have the same name, DevEco Studio overwrites the resource files based on the following priorities (in descending order): +- AppScope (supported only by the stage model of API version 9) +- Modules in the HAP file +- If resource conflicts occur between dependent HAR modules, they are overwritten based on the dependency sequence. (The module that is higher in the dependency sequence list has higher priority.) + +## Referencing ArkUI Components, APIs, and Resources in the HAR +To start with, [configure dependency](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-development-npm-package-0000001222578434#section89674298391) on the HAR. + +### Reference ArkUI Components in the HAR + +After configuring the dependency on the HAR, you can reference ArkUI components exported from the HAR by using **import**. The sample code is as follows: +```js +// entry/src/main/ets/pages/index.ets +import { MainPage } from "@ohos/library" + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + build() { + Row() { + // Reference the ArkUI component in the HAR. + MainPage() + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} +``` +### Referencing TS Classes and Methods in the HAR +To reference the TS classes and methods exported from the HAR, use **import** as follows: +```js +// entry/src/main/ets/pages/index.ets +import { Log } from "@ohos/library" +import { func } from "@ohos/library" + +@Entry +@Component +struct Index { + build() { + Row() { + Column() { + Button('Button') + .onClick(()=>{ + // Reference TS classes and methods in the HAR. + Log.info("har msg"); + func(); + }) + } + .width('100%') + } + .height('100%') + } +} +``` +### Referencing Resources in the HAR +Use **$r** to reference resources in the HAR. For example, add the **name: hello_har** string (defined in the **string.json** file) and **icon_har.png** image to the **src/main/resources** directory of the HAR module, and then reference the string and image in the entry module. The code snippet is as follows: +```js +// entry/src/main/ets/pages/index.ets +@Entry +@Component +struct Index { + build() { + Row() { + Column() { + // Reference the string in the HAR. + Text($r("app.string.hello_har")) + .fontSize(50) + .fontWeight(FontWeight.Bold) + // Reference the image in the HAR. + Image($r("app.media.icon_har")) + } + .width('100%') + } + .height('100%') + } +} +``` diff --git a/en/application-dev/quick-start/har-structure.md b/en/application-dev/quick-start/har-structure.md deleted file mode 100644 index 1d479b504a48752fdcb4ff033e81103efa134da2..0000000000000000000000000000000000000000 --- a/en/application-dev/quick-start/har-structure.md +++ /dev/null @@ -1,10 +0,0 @@ -# HAR File Structure - - -The OpenHarmony Archive (HAR) file enables code to be shared among multiple modules or projects. Unlike a Harmony Ability Package (HAP) file, a HAR file cannot be independently installed on a device. Instead, it can only be referenced as the dependency of an application module. - - -A HAR file is the build product of a [module](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/ohos-adding-deleting-module-0000001218760594-V3) of the Library type in a DevEco Studio project. - - -As a static shared package in OpenHarmony, the [HAR file](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-development-npm-package-0000001222578434) can contain the source code, C++ libraries, resource files, and the **module.json** file (in stage model) or **config.json** file (in FA model). diff --git a/en/application-dev/quick-start/in-app-hsp.md b/en/application-dev/quick-start/in-app-hsp.md new file mode 100644 index 0000000000000000000000000000000000000000..05380e9c6f3f3e631c56955128318d394a97f774 --- /dev/null +++ b/en/application-dev/quick-start/in-app-hsp.md @@ -0,0 +1,153 @@ +# In-Application HSP Development + +An in-application Harmony Shared Package (HSP) is a file used for code and resource sharing within an application (called the host application) and can only be invoked by a HAP or HSP of the same application. +The in-application HSP is released with the Application Package (App Pack) of the host application and has the same bundle name and lifecycle as the host application. + +## Developing an In-Application HSP + +You can kickstart your HSP development with the HSP template in DevEco Studio. In this example, an HSP module named **library** is created. The basic project directory structure is as follows: +``` +library +├── src +│ └── main +│ ├── ets +│ │ ├── pages +│ │ └── index.ets +│ ├── resources +│ └── module.json5 +└── package.json +``` +In the **module.json5** file, set **type** to **shared** for the HSP. +```json +{ + "type": "shared" +} +``` + +The HSP provides capabilities for external systems by exporting APIs in the entry file. Specify the entry file in **main** in the **package.json** file. For example: +```json +{ + "main": "./src/main/ets/index.ets" +} +``` + +### Exporting TS Classes and Methods +Use **export** to export TS classes and methods. The sample code is as follows: +```ts +// library/src/main/ets/utils/test.ts +export class Log { + static info(msg) { + console.info(msg); + } +} + +export function add(a: number, b: number) { + return a + b; +} + +export function minus(a: number, b: number) { + return a - b; +} +``` +In the entry file **index.ets**, declare the APIs to be exposed. +```ts +// library/src/main/ets/index.ets +export { Log, add, minus } from './utils/test' +``` + +### Exporting ArkUI Components +Use **export** to export ArkUI components. The sample code is as follows: +```ts +// library/src/main/ets/components/MyTitleBar.ets +@Component +export struct MyTitleBar { + build() { + Row() { + Text($r('app.string.library_title')) + .fontColor($r('app.color.white')) + .fontSize(25) + .margin({left:15}) + } + .width('100%') + .height(50) + .padding({left:15}) + .backgroundColor('#0D9FFB') + } +} +``` +In the entry file **index.ets**, declare the APIs to be exposed. +```ts +// library/src/main/ets/index.ets +export { MyTitleBar } from './components/MyTitleBar' +``` +#### About Using Resources in the HSP +To reference resources in the **resources** directory of the current HSP module, use **$r** or **$rawfile**. +If a relative path is used, the resources in the HSP caller are referenced instead. For example, +if **Image("common/example.png")** is used in the HSP module, the **\** component will reference the resource **entry/src/main/ets/common/example.png** in the HSP caller (which is **entry** in this example). + +### Exporting Native Methods +The HSP can contain .so files compiled in C++. The HSP indirectly exports the native method in the .so file. In this example, the **multi** method in the **libnative.so** file is exported. +```ts +// ibrary/src/main/ets/utils/nativeTest.ts +import native from "libnative.so" + +export function nativeMulti(a: number, b: number) { + return native.multi(a, b); +} +``` + +In the entry file **index.ets**, declare the APIs to be exposed. +```ts +// library/src/main/ets/index.ets +export { nativeMulti } from './utils/nativeTest' +``` + +## Using the In-Application HSP +To use APIs in the HSP, first configure the dependency on the HSP in the **package.json** file of the module that needs to call the APIs (called the invoking module). If the HSP and the invoking module are in the same project, the APIs can be referenced locally. The sample code is as follows: +```json +// entry/src/main/module.json5 +"dependencies": { + "library": "file:../library" +} +``` +You can now call the external APIs of the HSP in the same way as calling the APIs in the HAR. +In this example, the external APIs are the following ones exported from **library**: +```ts +// library/src/main/ets/index.ets +export { Log, add, minus } from './utils/test' +export { MyTitleBar } from './components/MyTitleBar' +export { nativeMulti } from './utils/nativeTest' +``` +The APIs can be used as follows in the code of the invoking module: +```ts +// entry/src/main/ets/pages/index.ets +import { Log, add, MyTitleBar, nativeMulti } from "library" + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + build() { + Row() { + Column() { + MyTitleBar() + Text(this.message) + .fontSize(30) + .fontWeight(FontWeight.Bold) + Button('add(1, 2)') + .onClick(()=>{ + Log.info("add button click!"); + this.message = "result: " + add(1, 2); + }) + Button('nativeMulti(3, 4)') + .onClick(()=>{ + Log.info("nativeMulti button click!"); + this.message = "result: " + nativeMulti(3, 4); + }) + } + .width('100%') + } + .height('100%') + } +} +``` diff --git a/en/application-dev/quick-start/module-configuration-file.md b/en/application-dev/quick-start/module-configuration-file.md index 67361fccfd749495e2f5825d5ccac6efe1505ed9..8fca81167d6d016376877602de947c4c9cc83bd1 100644 --- a/en/application-dev/quick-start/module-configuration-file.md +++ b/en/application-dev/quick-start/module-configuration-file.md @@ -72,7 +72,7 @@ As shown above, the **module.json5** file contains several tags. | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | | name | Name of the module. The value is a string with a maximum of 31 bytes and must be unique in the entire application. Chinese characters are not allowed.| String| No| -| type | Type of the module. The value can be **entry** or **feature**.
- **entry**: main module of the application.
- **feature**: dynamic feature module of the application.| String| No| +| type | Type of the module. The options are as follows:
- **entry**: main module of the application.
- **feature**: dynamic feature module of the application.
- **har**: static shared module.
- **shared**: dynamic shared module.| String| No| | srcEntry | Code path corresponding to the module. The value is a string with a maximum of 127 bytes.| String| Yes (initial value: left empty)| | description | Description of the module. The value is a string with a maximum of 255 bytes or a string resource index.| String| Yes (initial value: left empty)| | process | Process name of the current module. The value is a string with a maximum of 31 bytes. If **process** is configured under **HAP**, all UIAbility, DataShareExtensionAbility, and ServiceExtensionAbility components of the application run in the specified process.
**NOTE**
This tag applies only to system applications and does not take effect for third-party applications.| String| Yes (initial value: value of **bundleName** under **app** in the **app.json5** file)| @@ -150,7 +150,7 @@ Define the **main_pages.json** file under **resources/base/profile** in the deve The **metadata** tag represents the custom metadata of the HAP file. The tag value is an array and contains three subtags: **name**, **value**, and **resource**. - **Table 3** metadata +**Table 3** metadata | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | @@ -210,9 +210,10 @@ Touching this icon will direct the user to the application details screen in **S To hide an application icon from the home screen, you must configure the **AllowAppDesktopIconHide** privilege. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md). + **Setting the application icon to be displayed on the home screen**: -Set **icon**, **label**, and **skills** under **abilities** in the **module.json5** file. In addition, the **skills** configuration must contain **ohos.want.action.home **and **entity.system.home**. +Set **icon**, **label**, and **skills** under **abilities** in the **module.json5** file. In addition, make sure the **skills** configuration contains **ohos.want.action.home** and **entity.system.home**. ``` { @@ -284,7 +285,7 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json | removeMissionAfterTerminate | Whether to remove the relevant task from the task list after the UIAbility component is destroyed.
- **true**: Remove the relevant task from the task list after the UIAbility component is destroyed.
- **false**: Do not remove the relevant task from the task list after the UIAbility component is destroyed.| Boolean| Yes (initial value: **false**)| | orientation | Orientation of the UIAbility component when it is started. The options are as follows:
- **unspecified**: automatically determined by the system.
- **landscape**: landscape mode.
- **portrait**: portrait mode.
- **landscape_inverted**: inverted landscape mode.
- **portrait_inverted**: inverted portrait mode.
- **auto_rotation**: determined by the sensor.
- **auto_rotation_landscape**: determined by the sensor in the horizontal direction, including landscape and inverted landscape modes.
- **auto_rotation_portrait**: determined by the sensor in the vertical direction, including portrait and inverted portrait modes.
- **auto_rotation_restricted**: determined by the sensor when the sensor switch is enabled.
- **auto_rotation_landscape_restricted**: determined by the sensor in the horizontal direction, including landscape and inverted landscape modes, when the sensor switch is enabled.
- **auto_rotation_portrait_restricted**: determined by the sensor in the vertical direction, including portrait and inverted portrait modes, when the sensor switch is enabled.
- **locked**: auto rotation disabled.| String| Yes (initial value: **"unspecified"**)| | supportWindowMode | Window mode supported by the UIAbility component. The options are as follows:
- **fullscreen**: full-screen mode.
- **split**: split-screen mode.
- **floating**: floating window mode.| String array| Yes (initial value:
["fullscreen", "split", "floating"])| -| priority | Priority of the UIAbility component. This attribute applies only to system applications and does not take effect for third-party applications. In the case of [implicit query](../application-models/explicit-implicit-want-mappings.md), UIAbility components with a higher priority are at the higher place of the returned list. The value is an integer ranging from 0 to 10. The greater the value, the higher the priority.| Number| Yes (initial value: **0**)| +| priority | Priority of the UIAbility component. In the case of [implicit query](../application-models/explicit-implicit-want-mappings.md), UIAbility components with a higher priority are at the higher place of the returned list. The value is an integer ranging from 0 to 10. The greater the value, the higher the priority.
**NOTE**
This tag applies only to system applications and does not take effect for third-party applications.| Number| Yes (initial value: **0**)| | maxWindowRatio | Maximum aspect ratio supported by the UIAbility component. The minimum value is 0.| Number| Yes (initial value: maximum aspect ratio supported by the platform)| | minWindowRatio | Minimum aspect ratio supported by the UIAbility component. The minimum value is 0.| Number| Yes (initial value: minimum aspect ratio supported by the platform)| | maxWindowWidth | Maximum window width supported by the UIAbility component, in vp. The minimum value is 0, and the value cannot be less than the value of **minWindowWidth** or greater than the maximum window width allowed by the platform. For details about the window size, see [Constraints](../windowmanager/window-overview.md#constraints).| Number| Yes (initial value: maximum window width supported by the platform)| @@ -396,22 +397,22 @@ Example of the **skills** structure: } ``` -**Enhance implicit query** +**Enhanced implicit query** URI-level prefix matching is supported. -When only **scheme** or a combination of **scheme** and **host** or **scheme**, **host**, and **port** are configured in the configuration file, the configuration is successful if the URI prefixed with the configuration file is passed in. +When only **scheme** or a combination of **scheme** and **host** or **scheme**, **host**, and **port** are configured in the configuration file, the configuration is successful if a URI prefixed with the configuration file is passed in. * The query enhancement involves the following APIs: [@ohos.bundle.bundleManager](../reference/apis/js-apis-bundleManager.md#bundlemanagerqueryabilityinfo)
- 1. function queryAbilityInfo(want: Want, abilityFlags: number, callback: AsyncCallback>): void;
- 2. function queryAbilityInfo(want: Want, abilityFlags: number, userId: number, callback: AsyncCallback>): void;
- 3. function queryAbilityInfo(want: Want, abilityFlags: number, userId?: number): Promise>; + 1. function queryAbilityInfo(want: Want, abilityFlags: number, callback: AsyncCallback>): void;
+ 2. function queryAbilityInfo(want: Want, abilityFlags: number, userId: number, callback: AsyncCallback>): void;
+ 3. function queryAbilityInfo(want: Want, abilityFlags: number, userId?: number): Promise>; * Configuration requirements
abilities -> skills -> uris object
Configuration 1: only **scheme = 'http'**
- Configuration 2: only **(scheme = 'http' ) + ( host = 'example.com')**
- Configuration 3: only **(scheme = 'http' ) + ( host = 'example.com' ) + ( port = '8080')**
+ Configuration 2: only **(scheme = 'http') + (host = 'example.com')**
+ Configuration 3: only **(scheme = 'http') + (host = 'example.com') + (port = '8080')** * Prefix match
If the value of **uri** under [want](../application-models/want-overview.md) is obtained by calling the **queryAbilityInfo** API: 1. uri = 'https://': No matches
@@ -429,8 +430,6 @@ When only **scheme** or a combination of **scheme** and **host** or **scheme**, 13. uri = 'http://example.com:9180/path': Matches configuration 1 and configuration 2
14. uri = 'http://example.com:8080/path': Matches configuration 1, configuration 2, and configuration 3
- - ## extensionAbilities The **extensionAbilities** tag represents the configuration of extensionAbilities, which is valid only for the current extensionAbility. @@ -446,8 +445,8 @@ The **extensionAbilities** tag represents the configuration of extensionAbilitie | label | Name of the ExtensionAbility component displayed to users. The value is a string resource index.
**NOTE**
If **ExtensionAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| No| | type | Type of the ExtensionAbility component. The options are as follows:
- **form**: ExtensionAbility of a widget.
- **workScheduler**: ExtensionAbility of a Work Scheduler task.
- **inputMethod**: ExtensionAbility of an input method.
- **service**: service component running in the background.
- **accessibility**: ExtensionAbility of an accessibility feature.
- **dataShare**: ExtensionAbility for data sharing.
- **fileShare**: ExtensionAbility for file sharing.
- **staticSubscriber**: ExtensionAbility for static broadcast.
- **wallpaper**: ExtensionAbility of the wallpaper.
- **backup**: ExtensionAbility for data backup.
- **window**: ExtensionAbility of a window. This type of ExtensionAbility creates a window during startup for which you can develop the GUI. The window is then combined with other application windows through **abilityComponent**.
- **thumbnail**: ExtensionAbility for obtaining file thumbnails. You can provide thumbnails for files of customized file types.
- **preview**: ExtensionAbility for preview. This type of ExtensionAbility can parse the file and display it in a window. You can combine the window with other application windows.
- **print**: ExtensionAbility for the print framework.
**NOTE**
The **service** and **dataShare** types apply only to system applications and do not take effect for third-party applications.| String| No| | permissions | Permissions required for another application to access the ExtensionAbility component.
The value is generally in the reverse domain name notation and contains a maximum of 255 bytes. It is an array of permission names predefined by the system or customized. The name of a customized permission must be the same as the **name** value of a permission defined in the **defPermissions** attribute.| String array| Yes (initial value: left empty)| -| uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.
**NOTE**
This attribute is mandatory when **type** of the ExtensionAbility component is set to **dataShare**.| String| Yes (initial value: left empty)| -|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.
Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.
**NOTE**
The **skills** attribute with the entry capability can be configured for the feature-type package of an OpenHarmony application,
but not for an OpenHarmony service.| Array| Yes (initial value: left empty)| +| uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.
**NOTE**
This attribute is mandatory when the type of the **ExtensionAbility** component is set to **dataShare**. | String| Yes (initial value: left empty)| +|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.
Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.
**NOTE**
The **skills** attribute with the entry capability can be configured for the feature-type package of an OpenHarmony application, but not for an OpenHarmony service. | Array| Yes (initial value: left empty)| | [metadata](#metadata)| Metadata of the ExtensionAbility component.| Object| Yes (initial value: left empty)| | exported | Whether the ExtensionAbility component can be called by other applications.
- **true**: The ExtensionAbility component can be called by other applications.
- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)| @@ -488,11 +487,12 @@ Example of the **extensionAbilities** structure: ## requestPermissions -The **requestPermissions** tage represents a set of permissions that the application needs to request from the system for running correctly. +The **requestPermissions** tag represents a set of permissions that the application needs to request from the system for running correctly. > **NOTE** > -> The permission settings configured in the **requestPermissions** tag apply to the entire application. +> - The permission settings configured in the **requestPermissions** tag apply to the entire application. +> - If your application needs to subscribe to an event published by itself and the permissions required for accessing the application are set in the **permissions** tag under **extensionAbilities**, then the application must register the related permissions in the **requestPermissions** tag to receive the event. **Table 8** requestPermissions @@ -540,7 +540,7 @@ The **shortcut** information is identified in **metadata**, where: | shortcutId | ID of the shortcut. The value is a string with a maximum of 63 bytes.| String| No| | label | Label of the shortcut, that is, the text description displayed for the shortcut. The value can be a string or a resource index to the label, with a maximum of 255 bytes.| String| Yes (initial value: left empty)| | icon | Icon of the shortcut. The value is an icon resource index.| String| Yes (initial value: left empty)| -| [wants](../application-models/want-overview.md) | Wants to which the shortcut points. Each want consists of the **bundleName** and **abilityName** sub-attributes.
**bundleName**: target bundle name of the shortcut. The value is a string.
**abilityName**: target component name of the shortcut. The value is a string.| Object| Yes (initial value: left empty)| +| [wants](../application-models/want-overview.md) | Wants to which the shortcut points. Each want consists of the **bundleName** and **abilityName** sub-attributes.
- **bundleName**: target bundle name of the shortcut. The value is a string.
- **abilityName**: target component name of the shortcut. The value is a string.| Object| Yes (initial value: left empty)| 1. Configure the **shortcuts_config.json** file in **/resource/base/profile/**. @@ -699,7 +699,7 @@ Configure **metadata** in the **module** tag in the **module.json5** file. The **testRunner** tag represents the supported test runner. - **Table 14** testRunner +**Table 14** testRunner | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | diff --git a/en/application-dev/quick-start/module-structure.md b/en/application-dev/quick-start/module-structure.md index e4aee36db107109fcaa7e6d068cbc907009c69d4..352a993d5042116105ef5c50ae9138df51c622c9 100644 --- a/en/application-dev/quick-start/module-structure.md +++ b/en/application-dev/quick-start/module-structure.md @@ -21,7 +21,7 @@ The **module** tag contains the HAP configuration. | reqPermissions | Permissions that the application requests from the system when it is running.| Object array| Yes (initial value: left empty)| | colorMode | Color mode of the application. The options are as follows:
- **dark**: Resources applicable for the dark mode are used.
- **light**: Resources applicable for the light mode are used.
- **auto**: Resources are used based on the color mode of the system.| String| Yes (initial value: **auto**)| | distroFilter | Distribution rules of the application. This attribute defines the rules for distributing HAP files based on different device specifications, so that precise matching can be performed when the application market distributes applications. Distribution rules cover three factors: API version, screen shape, and screen resolution. During distribution, a unique HAP is determined based on the mapping between **deviceType** and these three factors.| Object| Yes (initial value: left empty) Set this attribute when an application has multiple entry modules.| -|commonEvents | Information about the common event static subscriber, which must contain the subscriber name, required permissions, and list of the subscribed common events. When a subscribed event is sent, the static subscriber is started. Unlike the common dynamic subscriber, the static subscriber does not need to actively call the common event subscription API in the service code, and may not be started when the common event is released. In constrast, the dynamic subscriber actively calls the common event subscription API and therefore requires the application to stay active.| Object array| Yes (initial value: left empty)| +|commonEvents | Information about the common event static subscriber, which must contain the subscriber name, required permissions, and list of the common events subscribed to. When a subscribed event is sent, the static subscriber is started. Unlike the dynamic subscriber, the static subscriber does not need to proactively call the common event subscription API in the service code, and may not be running when the common event is published.| Object array| Yes (initial value: left empty)| | entryTheme | Keyword of an OpenHarmony internal theme. Set it to the resource index of the name.| String| Yes (initial value: left empty)| |testRunner | Test runner configuration.| Object| Yes (initial value: left empty)| @@ -190,12 +190,73 @@ Example of the metadata attribute: ## Internal Structure of the abilities Attribute +**By default, application icons cannot be hidden from the home screen in OpenHarmony.** + +The OpenHarmony system imposes a strict rule on the presence of application icons. If no icon is configured in the HAP file of an application, the system creates a default icon for the application and displays it on the home screen.
+Touching this icon will direct the user to the application details screen in **Settings**. +To hide an application icon from the home screen, you must configure the **AllowAppDesktopIconHide** privilege. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md). + + +**Setting the application icon to be displayed on the home screen**:
Set **icon**, **label**, and **skills** under **abilities** in the **config.json** file. In addition, make sure the **skills** configuration contains **ohos.want.action.home** and **entity.system.home**. +``` +{ + "module":{ + + ... + + "abilities": [{ + "icon": "$media:icon", + "label": "Login", + "skills": [{ + "actions": ["ohos.want.action.home"], + "entities": ["entity.system.home"], + "uris": [] + }] + }], + + ... + + } +} +``` + +**Querying an application icon:** +* The HAP file contains Page ability configuration. + * The application icon is set under **abilities** in the **config.json** file. + * The application does not have the privilege to hide its icon from the home screen. + * The returned home screen icon is the icon configured for the ability. + * The returned home screen label is the label configured for the ability. If no label is configured, the bundle name is returned. + * The returned component name is the component name of the ability. + * When the user touches the home screen icon, the home screen of the ability is displayed. + * The application has the privilege to hide its icon from the home screen. + * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen. + * The application icon is not set under **abilities** in the **config.json** file. + * The application does not have the privilege to hide its icon from the home screen. + * The returned home screen icon is the default icon. + *The returned home screen label is the bundle name of the application. + * The returned component name is the component name displayed on the application details screen (this component is built in the system). + * Touching the home screen icon will direct the user to the application details screen. + * The application has the privilege to hide its icon from the home screen. + * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen. +* The HAP file does not contain Page ability configuration. + * The application does not have the privilege to hide its icon from the home screen. + * The returned home screen icon is the default icon. + *The returned home screen label is the bundle name of the application. + * The returned component name is the component name displayed on the application details screen (this component is built in the system). + * Touching the home screen icon will direct the user to the application details screen. + * The application has the privilege to hide its icon from the home screen. + * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen. + +> **NOTE** +> +> The icon and label displayed on the application details page may be different from those displayed on the home screen. For non-Page abilities, they are the entry icon and label set under **abilities**, if any. + **Table 8** Internal structure of the abilities attribute | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | | process | Name of the process running the application or ability. If the **process** attribute is configured in the **deviceConfig** tag, all abilities of the application run in this process. You can set the **process** attribute for a specific ability in the **abilities** attribute, so that the ability can run in the particular process. If this attribute is set to the name of the process running other applications, all these applications can run in the same process, provided they have the same unified user ID and the same signature. The value can contain a maximum of 31 bytes.| String| Yes (initial value: left empty)| -| name | Ability name. The value can be a reverse domain name, in the format of "*bundleName*.*className*", for example, **"com.example.myapplication.EntryAbility"**. Alternatively, the value can start with a period (.) followed by the class name, for example, **".EntryAbility"**.
The ability name must be unique in an application. Note: If you use DevEco Studio to create the project, an ability named **EntryAbility** will be created by default, and its configuration will be saved to the **config.json** file. The value of this attribute can be customized if you use other IDEs. The value can contain a maximum of 127 bytes.| String| No| +| name | Ability name. The value can be a reverse domain name, in the format of "*bundleName*.*className*", for example, **"com.example.myapplication.EntryAbility"**. Alternatively, the value can start with a period (.) followed by the class name, for example, **".EntryAbility"**.
The ability name must be unique in an application. Note: If you use DevEco Studio to create the project, an ability named **EntryAbility** will be created by default, and its configuration will be saved to the **config.json** file. If you use other IDEs, the value of this attribute can be customized. The value can contain a maximum of 127 bytes.| String| No| | description | Description of the ability. The value can be a string or a resource index to descriptions in multiple languages. The value can contain a maximum of 255 bytes.| String| Yes (initial value: left empty)| | icon | Index to the ability icon file. Example value: **$media:ability_icon**. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the icon of the ability is also used as the icon of the application. If multiple abilities address this condition, the icon of the first candidate ability is used as the application icon.
Note: The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels.| String| Yes (initial value: left empty)| | label | Ability name displayed to users. The value can be a name string or a resource index to names in multiple languages. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the label of the ability is also used as the label of the application. If multiple abilities address this condition, the label of the first candidate ability is used as the application label.
Note: The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels. The value can be a reference to a string defined in a resource file or a string enclosed in brackets ({}). The value can contain a maximum of 255 characters.| String| Yes (initial value: left empty)| @@ -212,13 +273,13 @@ Example of the metadata attribute: | grantPermission | Whether permissions can be granted for any data in the ability.| Boolean| Yes (initial value: left empty)| | readPermission | Permission required for reading data in the ability. This attribute applies only to the ability using the Data template. The value is a string with a maximum of 255 bytes. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String| Yes (initial value: left empty)| | writePermission | Permission required for writing data to the ability. This attribute applies only to the ability using the Data template. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)| -| configChanges | System configurations that the ability concerns. Upon any changes on the concerned configurations, the **onConfigurationUpdated** callback will be invoked to notify the ability. The options are as follows:
**mcc**: indicates that the mobile country code (MCC) of the IMSI is changed. Typical scenario: A SIM card is detected, and the MCC is updated.
**mnc**: indicates that the mobile network code (MNC) of the IMSI is changed. Typical scenario: A SIM card is detected, and the MNC is updated.
**locale**: indicates that the locale is changed. Typical scenario: The user selectes a new language for the text display of the device.
**layout**: indicates that the screen layout is changed. Typical scenario: Currently, different display forms are all in the active state.
**fontSize**: indicates that font size is changed. Typical scenario: A new global font size is set.
**orientation**: indicates that the screen orientation is changed. Typical scenario: The user rotates the device.
**density**: indicates that the display density is changed. Typical scenario: The user may specify different display ratios, or different display forms are active at the same time.
**size**: indicates that the size of the display window is changed.
**smallestSize**: indicates that the length of the shorter side of the display window is changed.
**colorMode**: indicates that the color mode is changed.| String array| Yes (initial value: left empty)| +| configChanges | System configurations that the ability concerns. Upon any changes on the concerned configurations, the **onConfigurationUpdated** callback will be invoked to notify the ability. The options are as follows:
**mcc**: indicates that the mobile country code (MCC) of the IMSI is changed. Typical scenario: A SIM card is detected, and the MCC is updated.
**mnc**: indicates that the mobile network code (MNC) of the IMSI is changed. Typical scenario: A SIM card is detected, and the MNC is updated.
**locale**: indicates that the locale is changed. Typical scenario: The user selects a new language for the text display of the device.
**layout**: indicates that the screen layout is changed. Typical scenario: Currently, different display forms are all in the active state.
**fontSize**: indicates that font size is changed. Typical scenario: A new global font size is set.
**orientation**: indicates that the screen orientation is changed. Typical scenario: The user rotates the device.
**density**: indicates that the display density is changed. Typical scenario: The user may specify different display ratios, or different display forms are active at the same time.
**size**: indicates that the size of the display window is changed.
**smallestSize**: indicates that the length of the shorter side of the display window is changed.
**colorMode**: indicates that the color mode is changed.| String array| Yes (initial value: left empty)| | mission | Task stack of the ability. This attribute applies only to the ability using the Page template. By default, all abilities in an application belong to the same task stack.| String| Yes (initial value: bundle name of the application)| | targetAbility | Target ability that this ability alias points to. This attribute applies only to the ability using the Page template. If the **targetAbility** attribute is set, only **name**, **icon**, **label**, **visible**, **permissions**, and **skills** take effect in the current ability (ability alias). Other attributes use the values of the **targetAbility** attribute. The target ability must belong to the same application as the alias and must be declared in **config.json** ahead of the alias.| String| Yes (initial value: left empty, indicating that the current ability is not an alias)| | formsEnabled | Whether the ability can provide widgets. This attribute applies only to the ability using the Page template.
**true**: This ability can provide widgets.
**false**: This ability cannot provide widgets.| Boolean| Yes (initial value: **false**)| | forms | Information about the widgets used by the ability. This attribute is valid only when **formsEnabled** is set to **true**.| Object array| Yes (initial value: left empty)| | srcLanguage | Programming language of the ability, which you can specify when creating the project.| String| Yes (initial value: **"js"**)| -| srcPath | JS code path corresponding to the ability. The value can contain maximum of 127 bytes.| String| No| +| srcPath | JS code path corresponding to the ability. The value can contain a maximum of 127 bytes.| String| No| | uriPermission | Application data that the ability can access. This attribute consists of the **mode** and **path** sub-attributes. This attribute is valid only for the capability of the type provider.| Object| Yes (initial value: left empty)| | startWindowIcon | Index to the icon file of the ability startup page. This attribute applies only to the ability using the Page template. Example: **$media:icon**.| String| Yes (initial value: left empty)| | startWindowBackground | Index to the background color resource file of the ability startup page. This attribute applies only to the ability using the Page template. Example: **$color:red**.| String| Yes (initial value: left empty)| @@ -351,9 +412,42 @@ Example of the **skills** attribute structure: ] ``` -## reqPermissions Attributes - -**Table 12** reqPermissions attributes +**Enhanced implicit query** + +URI-level prefix matching is supported. + +When only **scheme** or a combination of **scheme** and **host** or **scheme**, **host**, and **port** are configured in the configuration file, the configuration is successful if a URI prefixed with the configuration file is passed in. + + * The query enhancement involves the following APIs:
+ [@ohos.bundle.bundleManager](../reference/apis/js-apis-bundleManager.md#bundlemanagerqueryabilityinfo)
+ 1. function queryAbilityInfo(want: Want, abilityFlags: number, callback: AsyncCallback>): void;
+ 2. function queryAbilityInfo(want: Want, abilityFlags: number, userId: number, callback: AsyncCallback>): void;
+ 3. function queryAbilityInfo(want: Want, abilityFlags: number, userId?: number): Promise>; + * Configuration requirements
+ abilities -> skills -> uris object
+ Configuration 1: only **scheme = 'http'** + Configuration 2: only **(scheme = 'http') + (host = 'www.example.com')** + Configuration 3: only **(scheme = 'http') + (host = 'www.example.com') + (port = '8080')** + * Prefix match
+ If the value of **uri** under [want](../application-models/want-overview.md) is obtained by calling the **queryAbilityInfo** API:
+ 1. uri = 'https://': No matches
+ 2. uri = 'http://': Matches configuration 1
+ 3. uri = 'https://www.example.com': No matches
+ 4. uri = 'https://www.exa.com': No matches
+ 5. uri = 'http://www.exa.com': Matches configuration 1
+ 6. uri = 'http://www.example.com': Matches configuration 1 and configuration 2
+ 7. uri = 'https://www.example.com:8080': No matches
+ 8. uri = 'http://www.exampleaa.com:8080': Matches configuration 1
+ 9. uri = 'http://www.example.com:9180': Matches configuration 1 and configuration 2
+ 10. uri = 'http://www.example.com:8080': Matches configuration 1, configuration 2, and configuration 3
+ 11. uri = 'https://www.example.com:9180/query/student/name' : No matches
+ 12. uri = 'http://www.exampleap.com:8080/query/student/name': Matches configuration 1
+ 13. uri = 'http://www.example.com:9180/query/student/name': Matches configuration 1 and configuration 2
+ 14. uri = 'http://www.example.com:8080/query/student/name': Matches configuration 1, configuration 2, and configuration 3
+ +## Internal Structure of the reqPermissions Attribute + +**Table 12** Internal structure of the reqPermissions attribute | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | @@ -687,7 +781,7 @@ Example of the **commonEvents** attribute structure: | -------- | -------- | -------- | -------- | | name | Name of a permission. The value can contain a maximum of 255 bytes.| String| No| | grantMode | Permission grant mode. The options are as follows:
- **system_grant**: The permission is automatically granted by the system after the application is installed.
- **user_grant**: The permission is dynamically requested when needed and must be granted by the user.| String| Yes (initial value: **"system_grant"**)| -| availableLevel | Permission type. The options are as follows:
- **system_core**: system core permission.
- **system_basic**: basic system permission.
- **normal**: normal permission, which can be requsted by all applications.| String| Yes (initial value: **"normal"**)| +| availableLevel | Permission type. The options are as follows:
- **system_core**: system core permission.
- **system_basic**: basic system permission.
- **normal**: normal permission, which can be requested by all applications.| String| Yes (initial value: **"normal"**)| | provisionEnable | Whether the permission can be requested in provision mode, including high-level permissions. The value **true** means that the permission can be requested in provision mode.| Boolean| Yes (initial value: **true**)| | distributedSceneEnabled | Whether the permission can be used in distributed scenarios.| Boolean| Yes (initial value: **false**)| | label | Brief description of the permission. The value is a resource index to the description.| String| Yes (initial value: left empty)| diff --git a/en/application-dev/quick-start/quickfix-debug.md b/en/application-dev/quick-start/quickfix-debug.md new file mode 100644 index 0000000000000000000000000000000000000000..b7cdf872c72198e796be1f1b65e635cb52ce04e6 --- /dev/null +++ b/en/application-dev/quick-start/quickfix-debug.md @@ -0,0 +1,92 @@ +# CLI-based Quick Fix Development + +You can use the command-line tool to develop a quick fix file, an expeditious approach to resolve application bugs. In this document, an application with the bundle name of **com.ohos.quickfix** in version 1000000 is used as an example to describe how to develop a quick fix file with the command-line tool. + +## Writing the patch.json File + +Write a **patch.json** file that meets your project requirements and place it in any directory of the project. (Configuring the **patch.json** file is not supported in DevEco Studio.) Create a **patch.json** file on the local computer. Below is an example of the file content: +```json +{ + "app" : { + "bundleName" : "com.ohos.quickfix", + "versionCode": 1000000, // Application version + "versionName" : "1.0.0.1", + "patchVersionCode": 1000000, // Patch version + "patchVersionName" : "1.0.0.1" + }, + "module" : { + "name" : "entry", + "type" : "patch", + "deviceTypes" : [ + "default", + "tablet" + ], + "originalModuleHash": "11223344556677889900" // SHA-256 value of the HAP file to restore + } +} +``` + +## Generating a Quick Fix File +### Quick Fix for TS Code +* After modifying the TS code file in DevEco Studio and build it into a HAP file, you can find the corresponding .abc file in the project directory, for example, **build\default\cache\default\LegacyCompileETS\jsbundle\temporary\pages\index.abc**. + +### Quick Fix for C++ Code + +* In DevEco Studio, build the original C++ code into a .so file. Fix bugs in the code and rebuild the code into a new .so file. You can find this .so file in the project directory, for example, **build\default\intermediates\libs\default\arm64-v8a\libentry.so**. +* Locate the **diff.exe** tool in the **toolchains** folder in the local OpenHarmony SDK path. Use this tool to generate a quick fix .so file based on the old and new .so files. The command is as follows: +```shell +$ diff.exe -s Example.z.so -d Example.z.so -p Example.z.so.diff +``` +The command contains the following options: +- -**s**: path to the old .so file +- -**d**: path to the new .so file +- -**p**: path of the generated differential file + +## Generating a Quick Fix File in .hqf Format + +With the preceding **patch.json**, .abc, and .so files, run the following command to generate an .hqf file using the **app_packing_tool.jar** tool in the **toolchains** folder in the local OpenHarmony SDK path: +```shell +$ java -jar app_packing_tool.jar --mode hqf --json-path patch.json --lib-path libs --ets-patch patchs --out-path entry-default-unsigned.hqf --force true +``` + +The command contains the following options. +| Option|Description | Remarks| +| --- | --- |---| +| mode |Mode. | Mandatory| +| json-path|Path to the **patch.json** file.|Mandatory| +| lib-path|Path to the quick fix .so file. For details about the path, see [Structure of the Quick Fix Package](quickfix-principles.md#structure-of-the-quick-fix-package).|Optional| +| ets-path|Path to the quick fix .abc file.|Optional| + +## Signing the Quick Fix File + +Use the [hapsigner](../security/hapsigntool-guidelines.md) tool to sign the **entry-default-unsigned.hqf** file, in the same way you sign a HAP file. To be specific, run the following command to use **hap-sign-tool.jar** in the **toolchains** folder in the local OpenHarmony SDK path: + +```shell +$ java -jar hap-sign-tool.jar sign-app -keyAlias "OpenHarmony Application Release" -signAlg "SHA256withECDSA" -mode "localSign" -appCertFile "OpenHarmonyApplication.pem" -profileFile "ohos_provision_release.p7b" -inFile "entry-default-unsigned.hqf" -keystoreFile "OpenHarmony.p12" -outFile "entry-signed-release.hqf" -keyPwd "123456" -keystorePwd "123456" +``` + +## Installing the Quick Fix File + +Push the **entry-signed-release.hqf** file to the device. +```shell +hdc.exe file send .\entry-signed-release.hqf /data/ +``` + +Run the following command to install the quick fix file as a patch: +```shell +$ bm quickfix -a -f /data/entry-signed-release.hqf +``` + +The complete commands are as follows: +``` +$ bm quickfix -h +usage: bm quickfix +options list: +-h, --help list available commands +-q, --query indicates query quickfix, used with -b or --bundle-name +-b, --bundle-name query quickfix status and information by a specified bundle name +-a, --apply indicates apply quickfix, used with -f or --file-path +-f, --file-path apply a quickfix file by a specified path +-f, --file-path ... apply some quickfix files of one bundle +-f, --file-path apply quickfix files by direction, under which are quickfix files +``` diff --git a/en/application-dev/quick-start/quickfix-principles.md b/en/application-dev/quick-start/quickfix-principles.md new file mode 100644 index 0000000000000000000000000000000000000000..4c0a1f684cfc1ff71c5ad9a2594ae8823e178e82 --- /dev/null +++ b/en/application-dev/quick-start/quickfix-principles.md @@ -0,0 +1,105 @@ +# Quick Fix Overview + +Quick fix is a technical means provided by the OpenHarmony system for developers to fix application bugs in a manner that is far faster than application upgrades. Compared with the full application upgrade, the quick fix provides a better user experience by being smaller and faster. It allows users to fix application bugs quickly, without restarting their application. + +## Rules for Using Quick Fix + +* The quick fix only works for TypeScript (TS) and C++ code of applications, that is, .abc files (created after TS code compilation) and .so files (created after C++ code compilation). It does not work for resource files. +* No new .abc and .so files are allowed. +* Before deploying a quick fix package, make sure the corresponding application has been installed. Otherwise, the deployment will fail. +* The bundle name and application version number configured in the quick fix package must be the same as those of the installed application. Otherwise, the deployment will fail. +* Make sure the version of the quick fix package to deploy is later than that of the one previously deployed. Otherwise, the deployment will fail. +* The signature information of the quick fix package must be the same as that of the application to be fixed. Otherwise, the deployment will fail. +* Installing an application update will delete quick fix package. + +## Structure of the Quick Fix Package + +![Quick Fix Package Structure](figures/quick_fix_bundle_struct.png) +
The preceding figure shows the structure of the quick fix package released by an OpenHarmony application. +* As shown in the figure, the quick fix package comes in two formats: + * .appqf (Application Quick Fix) +
There is a one-to-one mapping between the .appqf file and App Pack of an application. For details, see [Application Package Structure in Stage Model](application-package-structure-stage). + * The .appqf file is used to release OpenHarmony applications to the application market and cannot be directly installed on devices. + * An .appqf file consists of one or more .hqf (Harmony Ability Package Quick Fix) files, which are extracted from the .appqf file by the application market and then distributed to specific devices. + * The .appqf file must contain the developer's signature information before being released to the application market. For details about how to sign the file, see [hapsigner Overview](../security/hapsigntool-overview.md). + * .hqf (Harmony Ability Package Quick Fix) +
The .hqf file is a quick fix to bugs in a HAP file. It can be installed on devices. An .hqf file contains .abc and .so files. The .abc files provide the quick fix, and the .so files provide package configuration information as well as the quick fix. + * .abc file: modified TS code in the application, which is a bytecode file created after the build. + * **libs** directory: a collection of .so.diff files, which are differential files of the .so library files, organized by system CPU architecture, such as arm and x86. + * **patch.json**: +
This file is used to describe the version information of the .hqf file and is filled in by developers. The details are as follows: + ```json + { + "app" : { + "bundleName" : "com.ohos.quickfix", + "versionCode" : 1000000, + "versionName" : "1.0.0", + "patchVersionCode" : 1000000, + "patchVersionName" : "1.0.0" + }, + "module" : { + "name" : "entry", + "type" : "patch", + "deviceTypes" : [ + "default", + "tablet" + ], + "originalModuleHash" : "11223344556677889900" + } + } + ``` + The following describes the parameters: + | Parameter|Type |Description |Initial Value Allowed| + | --- | --- | --- | --- | + |bundleName | string | Bundle name of the application. | No| + |versionCode | int |Version of the application. | No | + |versionName |string |Version name of the application.| No for the patch| + |patchVersionCode |int |Version of the patch. | No| + |patchVersionName |string |Version name of the patch.| No for the patch| + |name |string |Module name of the application, which is used to restore the module.| No| + |type | string|Type of the patch. The value can only be **patch**.| No| + |deviceTypes |array |Device types supported by the patch.| No| + |originalModuleHash| string |Hash value of the bundle corresponding to the original module name.| No| + +## Quick Fix to .abc Files Created After TS Code Compilation + +![.abc File Quick Fix](figures/quick_fix_gen_abc.png) + +The preceding figure shows the process of creating an .abc file quick fix using the TS compiler. +* An application build creates .abc and .map files. The .abc file is a bytecode file created after TS code compilation. It is used when the application is running. The .map file is an intermediate file created when the TS code is compiled using the TS compiler. It stores information such as functions and classes in the code. +* After bugs in the application are fixed, the application code is compiled again. During the compilation, the difference between the source and the target is obtained based on the preceding .map file and the current TS code, and an .abc file for quick fix is generated based on the difference. This .abc file will be placed in the .hqf file. + +## Quick Fix to .so Files Created After C++ Code Compilation + +![.so File Quickly Fix](figures/quick_fix_gen_so.png) + +The preceding figure shows the process of creating a .so file quick fix using the differential tool. +* The C++ source code of the original application is built into a .so file by using a compiler. The .so file is used when the application is running. +* After bugs in the application are fixed, the C++ code is compiled again into a .so file. With the two .so files before and after bug fixes, the differential tool generates a .so file for quick fix. This .so file will also be placed in the .hqf file. + +## Quick Fix Release and Deployment Process + +![Quick Fix File Release](figures/quick-fix-devel_release.png) + +As shown above, the modules involved in the release process are as follows: +* DevEco Studio: an integrated development environment for developing code projects. It can be used to create a quick fix file based on the original application code and the code after bug fixes, and sign the created quick repair file for release to the application market. +* Application market server: place where you release the quick fix file. It verifies the signature, scans for risks, unpacks and resigns the file, and then distributes the file to the client. +* Application market client: tool that receives the quick fix file from the application market server and triggers installation. +* Bundle manager service: system service used to manage the installation and uninstallation of application packages and quick fix files on the device. +* Quick fix engine: system service used to manage switching to quick fix code on the device. If the target application is running, the quick fix engine instructs it to switch to the quick fix file upon completion of the quick fix file deployment. +* File system: location where the application package and quick repair file are deployed on the device. + +In the end-to-end release and deployment process of the quick repair file: +1. DevEco Studio is used to create a quick fix file through building and packaging based on the original application source code and the source code after bug fixes, and sign the created quick fix file. +2. The signed quick repair file is released to the application market, which then distributes the file after verifying the signature, scanning for risks, and unpacking and resigning the file. +3. When the on-device application market client detects that a new quick fix file is available on the application market server, it downloads the file, and then installs and deploys the file through the bundle manager service in the system. +4. After the quick fix file is deployed, the quick fix engine triggers the application to switch to the quick fix file, ensuring that the user can instantly use the functions where bugs are fixed. + +## Quick Fix File Debugging Process + +![Quick Fix File Debugging](figures/quick-fix-debug.png) + +* As the quick fix capability is not yet available in DevEco Studio, for the time being, you can use the provided command-line tool to develop a quick fix file. The procedure is as follows: +1. With the original application source code and the source code after bug fixes, use the command-line tool to build and create quick fix files in .hpf format. Sign the .hpf files before installing them on the device. As aforementioned, the .appqf file cannot be installed on the device. +2. Install and deploy the .hqf files on the device using the command-line tool. +3. After the .hqf files are deployed, a callback is called to instruct the quick fix engine to trigger the application to switch to the quick fix file, ensuring that the user can instantly use the functions where bugs are fixed. diff --git a/en/application-dev/quick-start/shared-guide.md b/en/application-dev/quick-start/shared-guide.md new file mode 100644 index 0000000000000000000000000000000000000000..b73ad743a97d97b1ba9fc286c68e3b25d6f053d4 --- /dev/null +++ b/en/application-dev/quick-start/shared-guide.md @@ -0,0 +1,20 @@ +# Shared Package Overview + +OpenHarmony provides two types of shared packages: [Harmony Achive (HAR)](har-package.md) static shared package and Harmony Shared Package (HSP) dynamic shared package. + +Both the HAR and HSP are used to share code and resources and can contain code, C++ libraries, resources, and configuration files. The biggest differences between them are as follows: The code and resources in the HAR are compiled with the invoking module, and if there are multiple invoking modules, the build product contains multiple copies of the same code and resources; the code and resources in the HSP can be compiled independently, and the build product contains only one copy of the code and resources. + +**Figure 1** HAR and HSP in the App Pack + +![in-app-hsp-har](figures/in-app-hsp-har.png) + +The HSP is designed to solve the following issues with the HAR: +- When multiple HAPs reference the same HAR, the size of the App Pack swells. +- When multiple HAPs reference the same HAR, some state variables in the HAR cannot be shared. + +Restrictions on the HSP: +- The HSP and its invoking modules must be in the stage model. +- The HSP and its invoking modules must use the **esmodule **compilation mode. +- The HSP does not support the declaration of **abilities** and **extensionAbilities** in its configuration file. + +The HSP can be classified as [in-application HSP](in-app-hsp.md) or [inter-application HSP](cross-app-hsp.md), depending on the configuration files and usage methods. diff --git a/en/application-dev/quick-start/stage-structure.md b/en/application-dev/quick-start/stage-structure.md deleted file mode 100644 index ff66e3d405738a44f0c645593ffb0dbfb5beca97..0000000000000000000000000000000000000000 --- a/en/application-dev/quick-start/stage-structure.md +++ /dev/null @@ -1,25 +0,0 @@ -# Application Configuration File Overview (Stage Model) - - -Each application project must have configuration files in its code directory. These configuration files provide basic application information for build tools, operating systems, and application markets. - - -In the code directory of an application project developed in stage model, there are two types of configuration files: one **app.json5** file and one or more **module.json5** files. - - -The [app.json5](app-configuration-file.md) file contains the following contents: - - -- Application-wide configuration, including the bundle name, developer, and version number. - -- Device-specific configuration. - - -The [module.json5](module-configuration-file.md) file contains the following contents: - - -- Basic module configuration, such as the name, type, description, and supported device types of the module. - -- Information about the [application components](../application-models/stage-model-development-overview.md), including the descriptions of the UIAbility and ExtensionAbility components. - -- Information about the permissions required during application running. diff --git a/en/application-dev/quick-start/start-with-ets-fa.md b/en/application-dev/quick-start/start-with-ets-fa.md index 23709abc5c2ba7e9b14ef9f396e9731a9f94e136..c806eebac3e5f266cd0ba6859ef7eb75727af243 100644 --- a/en/application-dev/quick-start/start-with-ets-fa.md +++ b/en/application-dev/quick-start/start-with-ets-fa.md @@ -20,7 +20,7 @@ > **NOTE** > - > If you are using DevEco Studio V3.0 Beta3 or later, you can use the [low-code development](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652) mode apart from the traditional coding approach. + > If you are using DevEco Studio V3.0 Beta3 or later, you can use the low-code development mode apart from the traditional coding approach. > > On the low-code development pages, you can design your application UI in an efficient, intuitive manner, with a wide array of UI editing features. > @@ -34,7 +34,7 @@ ![en-us_image_0000001384652328](figures/en-us_image_0000001384652328.png) - **entry**: OpenHarmony project module, which can be built into an OpenHarmony Ability Package ([HAP](../../glossary.md#hap)). - - **src > main > ets**: a collection of eTS source code. + - **src > main > ets**: a collection of ArkTS source code. - **src > main > ets > MainAbility**: entry to your application/service. - **src > main > ets > MainAbility > pages**: pages contained in **MainAbility**. - **src > main > ets > MainAbility > pages > index.ets**: the first page in the **pages** list, also referred to as the entry to the application. diff --git a/en/application-dev/quick-start/start-with-ets-stage.md b/en/application-dev/quick-start/start-with-ets-stage.md index d9527e8fe83bf0173e688296c5cab2e8aff651b8..eece0ad295ee138ccf353345a78fc1eca7cf3715 100644 --- a/en/application-dev/quick-start/start-with-ets-stage.md +++ b/en/application-dev/quick-start/start-with-ets-stage.md @@ -20,7 +20,7 @@ > **NOTE** > - > You can use the [low-code development](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652) mode apart from the traditional coding approach. + > You can use the low-code development mode apart from the traditional coding approach. > > On the low-code development pages, you can design your application UI in an efficient, intuitive manner, with a wide array of UI editing features. > @@ -34,7 +34,7 @@ ![en-us_image_0000001364054489](figures/en-us_image_0000001364054489.png) - **entry**: OpenHarmony project module, which can be built into an OpenHarmony Ability Package ([HAP](../../glossary.md#hap)). - - **src > main > ets**: a collection of eTS source code. + - **src > main > ets**: a collection of ArkTS source code. - **src > main > ets > entryability**: entry to your application/service. - **src > main > ets > pages**: pages included in your application/service. - **src > main > resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. For details about resource files, see [Resource Categories and Access](resource-categories-and-access.md#resource-categories). diff --git a/en/application-dev/quick-start/start-with-js-fa.md b/en/application-dev/quick-start/start-with-js-fa.md index 7e1123d97f8af188bbb97849551cd6a499042a9f..15af85cd0dfadab9573d38e3d95e3671448550de 100644 --- a/en/application-dev/quick-start/start-with-js-fa.md +++ b/en/application-dev/quick-start/start-with-js-fa.md @@ -18,7 +18,7 @@ > **NOTE** > - > If you are using DevEco Studio V2.2 Beta1 or later, you can use the [low-code development](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652) mode apart from the traditional coding approach. + > If you are using DevEco Studio V2.2 Beta1 or later, you can use the low-code development mode apart from the traditional coding approach. > > On the low-code development pages, you can design your application UI in an efficient, intuitive manner, with a wide array of UI editing features. > diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 3c8f9de264e357fcf595ec2b3f82ec6842f55b50..6346094a14fbcea248a6bb9865155c2901e4f847 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -187,19 +187,19 @@ - [WebGL](js-apis-webgl.md) - [WebGL2](js-apis-webgl2.md) -- Media +- Multimedia - [@ohos.multimedia.audio (Audio Management)](js-apis-audio.md) - [@ohos.multimedia.avsession (AVSession Management)](js-apis-avsession.md) - [@ohos.multimedia.camera (Camera Management)](js-apis-camera.md) - [@ohos.multimedia.image (Image Processing)](js-apis-image.md) - [@ohos.multimedia.media (Media)](js-apis-media.md) -- Resource Management +- Resource Manager - [@ohos.i18n (Internationalization)](js-apis-i18n.md) - [@ohos.intl (Internationalization)](js-apis-intl.md) - [@ohos.resourceManager (Resource Manager)](js-apis-resource-manager.md) -- Background Tasks +- Background Task - [@ohos.distributedMissionManager (Distributed Mission Management)](js-apis-distributedMissionManager.md) - [@ohos.reminderAgentManager (Reminder Agent Management)](js-apis-reminderAgentManager.md) - [@ohos.resourceschedule.backgroundTaskManager (Background Task Management)](js-apis-resourceschedule-backgroundTaskManager.md) @@ -208,7 +208,7 @@ - [@ohos.WorkSchedulerExtensionAbility (Work Scheduler Callbacks)](js-apis-WorkSchedulerExtensionAbility.md) - application - [WorkSchedulerExtensionContext](js-apis-inner-application-WorkSchedulerExtensionContext.md) - + - Security - [@ohos.abilityAccessCtrl (Ability Access Control)](js-apis-abilityAccessCtrl.md) - [@ohos.privacyManager (Privacy Management)](js-apis-privacyManager.md) @@ -217,7 +217,6 @@ - [@ohos.security.huks (HUKS)](js-apis-huks.md) - [@ohos.userIAM.faceAuth (Facial Authentication)](js-apis-useriam-faceauth.md) - [@ohos.userIAM.userAuth (User Authentication)](js-apis-useriam-userauth.md) - - [@system.cipher (Cipher Algorithm)](js-apis-system-cipher.md) - security - [PermissionRequestResult](js-apis-permissionrequestresult.md) @@ -238,15 +237,16 @@ - [@ohos.file.environment (Directory Environment Capability)](js-apis-file-environment.md) - [@ohos.file.fileAccess (User File Access and Management)](js-apis-fileAccess.md) - [@ohos.file.fileExtensionInfo (User File Extension Information)](js-apis-fileExtensionInfo.md) + - [@ohos.file.fileUri (File URI)](js-apis-file-fileUri.md) - [@ohos.file.fs (File Management)](js-apis-file-fs.md) - [@ohos.file.hash (File Hash Processing)](js-apis-file-hash.md) - - [@ohos.file.picker (Picker)](js-apis-file-picker.md) + - [@ohos.file.picker (File Picker)](js-apis-file-picker.md) - [@ohos.file.securityLabel (Data Label)](js-apis-file-securityLabel.md) - [@ohos.file.statvfs (File System Space Statistics)](js-apis-file-statvfs.md) - [@ohos.file.storageStatistics (Application Storage Statistics)](js-apis-file-storage-statistics.md) - [@ohos.file.volumeManager (Volume Management)](js-apis-file-volumemanager.md) - [@ohos.filemanagement.userFileManager (User Data Management)](js-apis-userFileManager.md) - - [@ohos.multimedia.medialibrary (Media Library Management)](js-apis-medialibrary.md) + - [@ohos.fileShare (File Sharing)](js-apis-fileShare.md) - Telephony Service - [@ohos.contact (Contacts)](js-apis-contact.md) @@ -276,8 +276,8 @@ - [@ohos.rpc (RPC)](js-apis-rpc.md) - [@ohos.wifiManager (WLAN)](js-apis-wifiManager.md) - [@ohos.wifiManagerExt (WLAN Extension)](js-apis-wifiManagerExt.md) - - [@ohos.wifi (To Be Deprecated)](js-apis-wifi.md) - - [@ohos.wifiext (To Be Deprecated)](js-apis-wifiext.md) + - [@ohos.wifi (To Be Deprecated Soon)](js-apis-wifi.md) + - [@ohos.wifiext (To Be Deprecated Soon)](js-apis-wifiext.md) - tag - [nfctech (Standard NFC Technologies)](js-apis-nfctech.md) - [tagSession (Standard NFC Tag Session)](js-apis-tagSession.md) @@ -318,6 +318,7 @@ - [@ohos.batteryInfo (Battery Information)](js-apis-battery-info.md) - [@ohos.batteryStatistics (Battery Statistics)](js-apis-batteryStatistics.md) - [@ohos.brightness (Screen Brightness)](js-apis-brightness.md) + - [@ohos.charger (Charging Type)](js-apis-charger.md) - [@ohos.deviceInfo (Device Information)](js-apis-device-info.md) - [@ohos.distributedHardware.deviceManager (Device Management)](js-apis-device-manager.md) - [@ohos.geoLocationManager (Geolocation Manager)](js-apis-geoLocationManager.md) @@ -349,7 +350,7 @@ - [@ohos.account.distributedAccount (Distributed Account Management)](js-apis-distributed-account.md) - [@ohos.account.osAccount (OS Account Management)](js-apis-osAccount.md) -- Custom Management +- Customization - [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md) - [@ohos.enterprise.accountManager (Account Management)](js-apis-enterprise-accountManager.md) - [@ohos.enterprise.adminManager (Enterprise Device Management)](js-apis-enterprise-adminManager.md) @@ -403,6 +404,7 @@ - [@ohos.fileio (File Management)](js-apis-fileio.md) - [@ohos.geolocation (Geolocation)](js-apis-geolocation.md) - [@ohos.hiAppEvent (Application Event Logging)](js-apis-hiappevent.md) + - [@ohos.multimedia.medialibrary (Media Library Management)](js-apis-medialibrary.md) - [@ohos.prompt (Prompt)](js-apis-prompt.md) - [@ohos.reminderAgent (Reminder Agent)](js-apis-reminderAgent.md) - [@ohos.statfs (statfs)](js-apis-statfs.md) @@ -414,6 +416,7 @@ - [@system.battery (Battery Information)](js-apis-system-battery.md) - [@system.bluetooth (Bluetooth)](js-apis-system-bluetooth.md) - [@system.brightness (Screen Brightness)](js-apis-system-brightness.md) + - [@system.cipher (Cipher Algorithm)](js-apis-system-cipher.md) - [@system.configuration (Application Configuration)](js-apis-system-configuration.md) - [@system.device (Device Information)](js-apis-system-device.md) - [@system.fetch (Data Request)](js-apis-system-fetch.md) diff --git a/en/application-dev/reference/apis/figures/Colorsucker.png b/en/application-dev/reference/apis/figures/Colorsucker.png new file mode 100644 index 0000000000000000000000000000000000000000..40e19e94e129682fdeb461cceef0f0a57c64d66d Binary files /dev/null and b/en/application-dev/reference/apis/figures/Colorsucker.png differ diff --git a/en/application-dev/reference/apis/figures/Copy.png b/en/application-dev/reference/apis/figures/Copy.png new file mode 100644 index 0000000000000000000000000000000000000000..212517131bf176661ae85c7513def022dbb50559 Binary files /dev/null and b/en/application-dev/reference/apis/figures/Copy.png differ diff --git a/en/application-dev/reference/apis/figures/Cross.png b/en/application-dev/reference/apis/figures/Cross.png new file mode 100644 index 0000000000000000000000000000000000000000..58625855d1cd96ea8a29ab9c3c201d90ac717e83 Binary files /dev/null and b/en/application-dev/reference/apis/figures/Cross.png differ diff --git a/en/application-dev/reference/apis/figures/Default.png b/en/application-dev/reference/apis/figures/Default.png new file mode 100644 index 0000000000000000000000000000000000000000..6308171fe9d612050376f6a5dfdc870e51bc92db Binary files /dev/null and b/en/application-dev/reference/apis/figures/Default.png differ diff --git a/en/application-dev/reference/apis/figures/East.png b/en/application-dev/reference/apis/figures/East.png new file mode 100644 index 0000000000000000000000000000000000000000..4942bc948a17e78c68538ccc3ae886bc0a548737 Binary files /dev/null and b/en/application-dev/reference/apis/figures/East.png differ diff --git a/en/application-dev/reference/apis/figures/Forbid.png b/en/application-dev/reference/apis/figures/Forbid.png new file mode 100644 index 0000000000000000000000000000000000000000..c5c43d4b4b8aaf6d53931586e519a583d064fec7 Binary files /dev/null and b/en/application-dev/reference/apis/figures/Forbid.png differ diff --git a/en/application-dev/reference/apis/figures/Hand_Grabbing.png b/en/application-dev/reference/apis/figures/Hand_Grabbing.png new file mode 100644 index 0000000000000000000000000000000000000000..09ab3121d15e27a975fbaa228aadb2399e4492b9 Binary files /dev/null and b/en/application-dev/reference/apis/figures/Hand_Grabbing.png differ diff --git a/en/application-dev/reference/apis/figures/Hand_Open.png b/en/application-dev/reference/apis/figures/Hand_Open.png new file mode 100644 index 0000000000000000000000000000000000000000..e1cb7a972ec2d372f0d75cbe80159c4a66e74e10 Binary files /dev/null and b/en/application-dev/reference/apis/figures/Hand_Open.png differ diff --git a/en/application-dev/reference/apis/figures/Hand_Pointing.png b/en/application-dev/reference/apis/figures/Hand_Pointing.png new file mode 100644 index 0000000000000000000000000000000000000000..f0daa0dad6154a1846fb9fe4b7f441b3ab6f8b5b Binary files /dev/null and b/en/application-dev/reference/apis/figures/Hand_Pointing.png differ diff --git a/en/application-dev/reference/apis/figures/Help.png b/en/application-dev/reference/apis/figures/Help.png new file mode 100644 index 0000000000000000000000000000000000000000..ffea2f1c072f1682ca8e837ddb947352a553917e Binary files /dev/null and b/en/application-dev/reference/apis/figures/Help.png differ diff --git a/en/application-dev/reference/apis/figures/MID_Btn_East.png b/en/application-dev/reference/apis/figures/MID_Btn_East.png new file mode 100644 index 0000000000000000000000000000000000000000..921cd4ceea8d97ffb6d4c45008d6428cda998cce Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_East.png differ diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North.png b/en/application-dev/reference/apis/figures/MID_Btn_North.png new file mode 100644 index 0000000000000000000000000000000000000000..5769575ddb435f5e8f5f8993d9edc13749376293 Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North.png differ diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North_East.png b/en/application-dev/reference/apis/figures/MID_Btn_North_East.png new file mode 100644 index 0000000000000000000000000000000000000000..3daf141241dec309c98ae10266bb153af163f3d9 Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North_East.png differ diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North_South.png b/en/application-dev/reference/apis/figures/MID_Btn_North_South.png new file mode 100644 index 0000000000000000000000000000000000000000..1f56c4cd8f1498293f5fc4a5ab2c321159fb07dd Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North_South.png differ diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North_South_West_East.png b/en/application-dev/reference/apis/figures/MID_Btn_North_South_West_East.png new file mode 100644 index 0000000000000000000000000000000000000000..b45dbde27e59121bdfc4e1752759176fb835027c Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North_South_West_East.png differ diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North_West.png b/en/application-dev/reference/apis/figures/MID_Btn_North_West.png new file mode 100644 index 0000000000000000000000000000000000000000..bde82d08f7a098106b4f4c31d55a84a989e25a8d Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North_West.png differ diff --git a/en/application-dev/reference/apis/figures/MID_Btn_South.png b/en/application-dev/reference/apis/figures/MID_Btn_South.png new file mode 100644 index 0000000000000000000000000000000000000000..e7d5afb6f8f8b1b2939b9e18bdb8b8b3d9729f4d Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_South.png differ diff --git a/en/application-dev/reference/apis/figures/MID_Btn_South_East.png b/en/application-dev/reference/apis/figures/MID_Btn_South_East.png new file mode 100644 index 0000000000000000000000000000000000000000..44284a6e04a19ca8453b46ea81db099ad84cfaa2 Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_South_East.png differ diff --git a/en/application-dev/reference/apis/figures/MID_Btn_South_West.png b/en/application-dev/reference/apis/figures/MID_Btn_South_West.png new file mode 100644 index 0000000000000000000000000000000000000000..c8632f09160c51ca573d58d3ffb1370058b880ce Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_South_West.png differ diff --git a/en/application-dev/reference/apis/figures/MID_Btn_West.png b/en/application-dev/reference/apis/figures/MID_Btn_West.png new file mode 100644 index 0000000000000000000000000000000000000000..7460bc18d63e000689755b39b8ead3c3609ee4f5 Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_West.png differ diff --git a/en/application-dev/reference/apis/figures/Move.png b/en/application-dev/reference/apis/figures/Move.png new file mode 100644 index 0000000000000000000000000000000000000000..00f64e54dca0d0731b595b4ddc9e0f7294c40c72 Binary files /dev/null and b/en/application-dev/reference/apis/figures/Move.png differ diff --git a/en/application-dev/reference/apis/figures/North.png b/en/application-dev/reference/apis/figures/North.png new file mode 100644 index 0000000000000000000000000000000000000000..b022ac2e92d4cfb07efde7f3bf4b7ada8454e594 Binary files /dev/null and b/en/application-dev/reference/apis/figures/North.png differ diff --git a/en/application-dev/reference/apis/figures/North_East.png b/en/application-dev/reference/apis/figures/North_East.png new file mode 100644 index 0000000000000000000000000000000000000000..f6134237f38cd681b319c95bf1b77017bc1524b4 Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_East.png differ diff --git a/en/application-dev/reference/apis/figures/North_East_South_West.png b/en/application-dev/reference/apis/figures/North_East_South_West.png new file mode 100644 index 0000000000000000000000000000000000000000..908886aeb3f8df976bb67b2261e8e52e7222e622 Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_East_South_West.png differ diff --git a/en/application-dev/reference/apis/figures/North_South.png b/en/application-dev/reference/apis/figures/North_South.png new file mode 100644 index 0000000000000000000000000000000000000000..b15678a6b178ca0d9b13f7c7f58d025ab7a1ce12 Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_South.png differ diff --git a/en/application-dev/reference/apis/figures/North_West.png b/en/application-dev/reference/apis/figures/North_West.png new file mode 100644 index 0000000000000000000000000000000000000000..cfbe4c8910575c12afde4b5904d79b5beda0c162 Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_West.png differ diff --git a/en/application-dev/reference/apis/figures/North_West_South_East.png b/en/application-dev/reference/apis/figures/North_West_South_East.png new file mode 100644 index 0000000000000000000000000000000000000000..09fa728fbb45082a0524c284b8906b91d7b3a6f7 Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_West_South_East.png differ diff --git a/en/application-dev/reference/apis/figures/Resize_Left_Right.png b/en/application-dev/reference/apis/figures/Resize_Left_Right.png new file mode 100644 index 0000000000000000000000000000000000000000..83e7671e3ffea65260bdb36d8b392fa78d55cd4e Binary files /dev/null and b/en/application-dev/reference/apis/figures/Resize_Left_Right.png differ diff --git a/en/application-dev/reference/apis/figures/Resize_Up_Down.png b/en/application-dev/reference/apis/figures/Resize_Up_Down.png new file mode 100644 index 0000000000000000000000000000000000000000..db8bccf89b6e5260db3875a22b5200fabd30c23c Binary files /dev/null and b/en/application-dev/reference/apis/figures/Resize_Up_Down.png differ diff --git a/en/application-dev/reference/apis/figures/Screenshot_Cross.png b/en/application-dev/reference/apis/figures/Screenshot_Cross.png new file mode 100644 index 0000000000000000000000000000000000000000..27460c082507e71082d11cd8a20eee2fc24da28d Binary files /dev/null and b/en/application-dev/reference/apis/figures/Screenshot_Cross.png differ diff --git a/en/application-dev/reference/apis/figures/Screenshot_Cursor.png b/en/application-dev/reference/apis/figures/Screenshot_Cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..71abea4ca351988a92b8a5b2b2228321df31aecc Binary files /dev/null and b/en/application-dev/reference/apis/figures/Screenshot_Cursor.png differ diff --git a/en/application-dev/reference/apis/figures/South.png b/en/application-dev/reference/apis/figures/South.png new file mode 100644 index 0000000000000000000000000000000000000000..205f5cf5f59ce8318357e168eee0d66c119c233d Binary files /dev/null and b/en/application-dev/reference/apis/figures/South.png differ diff --git a/en/application-dev/reference/apis/figures/South_East.png b/en/application-dev/reference/apis/figures/South_East.png new file mode 100644 index 0000000000000000000000000000000000000000..f4a70d2d068271bfe10e4ce724ae27e4e5ba96d9 Binary files /dev/null and b/en/application-dev/reference/apis/figures/South_East.png differ diff --git a/en/application-dev/reference/apis/figures/South_West.png b/en/application-dev/reference/apis/figures/South_West.png new file mode 100644 index 0000000000000000000000000000000000000000..2ae8e9a9fa396bb6ed0f385b7b99b66830357a40 Binary files /dev/null and b/en/application-dev/reference/apis/figures/South_West.png differ diff --git a/en/application-dev/reference/apis/figures/Text_Cursor.png b/en/application-dev/reference/apis/figures/Text_Cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..7cd8d2200bc7455e562da003069702832db4eb20 Binary files /dev/null and b/en/application-dev/reference/apis/figures/Text_Cursor.png differ diff --git a/en/application-dev/reference/apis/figures/West.png b/en/application-dev/reference/apis/figures/West.png new file mode 100644 index 0000000000000000000000000000000000000000..2cad91aca31f2e2b257c523e80e6fc2d71fa2cee Binary files /dev/null and b/en/application-dev/reference/apis/figures/West.png differ diff --git a/en/application-dev/reference/apis/figures/West_East.png b/en/application-dev/reference/apis/figures/West_East.png new file mode 100644 index 0000000000000000000000000000000000000000..6be4aa9d05f22a10cd00fa6aec36f95aee2b332d Binary files /dev/null and b/en/application-dev/reference/apis/figures/West_East.png differ diff --git a/en/application-dev/reference/apis/figures/Zoom_In.png b/en/application-dev/reference/apis/figures/Zoom_In.png new file mode 100644 index 0000000000000000000000000000000000000000..2e928ec070fcd05a44cd9b1abd041128287b0528 Binary files /dev/null and b/en/application-dev/reference/apis/figures/Zoom_In.png differ diff --git a/en/application-dev/reference/apis/figures/Zoom_Out.png b/en/application-dev/reference/apis/figures/Zoom_Out.png new file mode 100644 index 0000000000000000000000000000000000000000..d675d0e517ba436724540a39f60dfa75c256f0d0 Binary files /dev/null and b/en/application-dev/reference/apis/figures/Zoom_Out.png differ diff --git a/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md b/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md index a55ab990ef39072d83989526e66723eab794ca63..3b42c32bc9e19c19810017a2a7d7cab637619dc6 100644 --- a/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md @@ -105,3 +105,55 @@ export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbil } }; ``` + +## EnterpriseAdminExtensionAbility.onAppStart10+ + +onAppStart(bundleName: string): void + +Called when an application is started. + +**System capability**: SystemCapability.Customization.EnterpriseDeviceManager + +**System API**: This is a system API. + +**Parameters** + +| Parameter | Type | Mandatory | Description | +| ----- | ----------------------------------- | ---- | ------- | +| bundleName | string | Yes | Bundle name of the application started.| + +**Example** + +```ts +export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { + onAppStart(bundleName: string) { + console.log("started bundle name: " + bundleName); + } +}; +``` + +## EnterpriseAdminExtensionAbility.onAppStop10+ + +onAppStop(bundleName: string): void + +Called when an application is stopped. + +**System capability**: SystemCapability.Customization.EnterpriseDeviceManager + +**System API**: This is a system API. + +**Parameters** + +| Parameter | Type | Mandatory | Description | +| ----- | ----------------------------------- | ---- | ------- | +| bundleName | string | Yes | Bundle name of the application stopped.| + +**Example** + +```ts +export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { + onAppStop(bundleName: string) { + console.log("stopped bundle name: " + bundleName); + } +}; +``` diff --git a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index 54cea921d80648b17fe5384e4ea9e57336d32fc1..874518b0e5ca7692fd902f26bcf49b07719eefc5 100644 --- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -504,8 +504,8 @@ For details about the error codes, see [Application Access Control Error Codes]( | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID in list is all invalid, or the permissionName in list is all invalid. | -| 12100004 | The API is not used together with "on()". | +| 12100001 | The parameter is invalid. The tokenIDs or permissionNames in the list are all invalid. | +| 12100004 | The interface is not used together with "on". | | 12100007 | Service is abnormal. | | 12100008 | Out of memory. | @@ -532,7 +532,9 @@ verifyAccessToken(tokenID: number, permissionName: Permissions): Promise<Gran Verifies whether a permission is granted to an application. This API uses a promise to return the result. -> **NOTE**
You are advised to use [checkAccessToken](#checkaccesstoken9). +> **NOTE** +> +> You are advised to use [checkAccessToken](#checkaccesstoken9). **System capability**: SystemCapability.Security.AccessToken @@ -619,7 +621,7 @@ Requests permissions from the user in a dialog box. This API uses a promise to | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | context | Context | Yes| Ability context of the application that requests the permissions. | -| permissionList | Array<Permissions> | Yes| Permissions requested. For details about the permissions, see the [Application Permission List](../../security/permission-list.md). | +| permissionList | Array<Permissions> | Yes| Permissions requested. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).| **Return value** @@ -659,7 +661,9 @@ verifyAccessToken(tokenID: number, permissionName: string): Promise<GrantStat Verifies whether a permission is granted to an application. This API uses a promise to return the result. -> NOTE
This API is deprecated since API version 9. You are advised to use [checkAccessToken](#checkaccesstoken9). +> **NOTE** +> +> This API is no longer maintained since API version 9. You are advised to use [checkAccessToken](#checkaccesstoken9). **System capability**: SystemCapability.Security.AccessToken diff --git a/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md b/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md index d03dcb8185338c328e279df4b03849c434f1da6d..6931cfe50da06cdd9b7526344a47eae29c3c8ef8 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md @@ -4,7 +4,7 @@ The **appRecovery** module provides APIs for recovering faulty applications. > **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. In the current version, only applications with a single ability in a single process can be recovered. +> 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. In API version 9, only applications with a single ability in a process can be recovered. In API version 10, applications with multiple abilities in a process can be recovered. ## Modules to Import ```ts @@ -51,7 +51,7 @@ Enumerates the application state saving modes. This enum is used as an input par enableAppRecovery(restart?: [RestartFlag](#apprecoveryrestartflag), saveOccasion?: [SaveOccasionFlag](#apprecoverysaveoccasionflag), saveMode?: [SaveModeFlag](#apprecoverysavemodeflag)) : void; -Enables application recovery. +Enables application recovery. After this API is called, the first ability that is displayed when the application is started from the initiator can be restored. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -63,8 +63,8 @@ Enables application recovery. | saveOccasion | [SaveOccasionFlag](#apprecoverysaveoccasionflag) | No| Scenario for saving the application state. By default, the state is saved when a fault occurs.| | saveMode | [SaveModeFlag](#apprecoverysavemodeflag) | No| Application state saving mode. By default, the application state is written to the local file cache.| -**Example** - +**Example** + ```ts import appRecovery from '@ohos.app.ability.appRecovery'; import AbilityStage from '@ohos.app.ability.AbilityStage'; @@ -84,13 +84,22 @@ export default class MyAbilityStage extends AbilityStage { restartApp(): void; -Restarts the application. This API can be used together with APIs of [errorManager](js-apis-app-ability-errorManager.md). +Restarts the current process and starts the first ability that is displayed when the application is started. If the state of this ability is saved, the saved state data is passed into the **wantParam** attribute in the **want** parameter of the **OnCreate** lifecycle callback of the ability. + +In API version 10, the ability specified by [setRestartWant](#apprecoverysetrestartwant) is started. If no ability is specified, the following rules are used: + +- If the ability of the current application running in the foreground supports recovery, that ability is started. + +- If multiple abilities that support recovery is running in the foreground, only the last ability is started. + +- If no ability is running in the foreground, none of them is started. + +This API can be used together with the APIs of [errorManager](js-apis-app-ability-errorManager.md). **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**Example** -**Example** - ```ts import appRecovery from '@ohos.app.ability.appRecovery'; import errorManager from '@ohos.app.ability.errorManager'; @@ -113,7 +122,7 @@ try { saveAppState(): boolean; -Saves the application state. This API can be used together with APIs of [errorManager](js-apis-app-ability-errorManager.md). +Saves the application state. This API can be used together with the APIs of [errorManager](js-apis-app-ability-errorManager.md). **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -123,8 +132,8 @@ Saves the application state. This API can be used together with APIs of [errorMa | -------- | -------- | | boolean | Whether the application state is saved. The value **true** is returned if the application state is saved, and **false** is returned otherwise.| -**Example** - +**Example** + ```ts import appRecovery from '@ohos.app.ability.appRecovery'; import errorManager from '@ohos.app.ability.errorManager'; @@ -142,3 +151,53 @@ try { console.error('error: ${paramError.code}, ${paramError.message}'); } ``` + +## appRecovery.saveAppState10+ + +saveAppState(context?: UIAbilityContext): boolean; + +Saves the ability state, which will be used for recovery. This API can be used together with the APIs of [errorManager](js-apis-app-ability-errorManager.md). + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Whether the application state is saved. The value **true** is returned if the application state is saved, and **false** is returned otherwise.| + +**Example** + +```ts +import appRecovery from '@ohos.app.ability.appRecovery'; +onBackground() { + hilog.info(0x0000, '[demo]', '%{public}s', 'EntryAbility onBackground'); + appRecovery.saveAppState(this.context) +} +``` + +## appRecovery.setRestartWant10+ + +setRestartWant(want: Want): void; + +Sets an ability that will be recovered. The ability must be a UIAbility in the current bundle. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Example** + +```ts +import appRecovery from '@ohos.app.ability.appRecovery'; +Button ("Start to Recover Ability") + .fontSize(40) + .fontWeight(FontWeight.Bold) + .onClick(()=> { + // set restart want + let want = { + bundleName: "ohos.samples.recovery", + abilityName: "RecoveryAbility" + }; + + appRecovery.setRestartWant(want); + }) +``` diff --git a/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md b/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md index 1224636ae4c0aa4ceb8634b244cd088257b64331..3304f535b5fd5fe52562e237a9f48c60cd794067 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md @@ -290,7 +290,7 @@ Obtains the information about a given mission. This API uses an asynchronous cal | -------- | -------- | -------- | -------- | | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| | missionId | number | Yes| Mission ID.| - | callback | AsyncCallback<[MissionInfo](./js-apis-inner-application-missionInfo.md))> | Yes| Callback used to return the mission information obtained.| + | callback | AsyncCallback<[MissionInfo](./js-apis-inner-application-missionInfo.md)> | Yes| Callback used to return the mission information obtained.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md index a77fe119ca0f5de161bb0e3d65e4be15e871dcc5..b85364df96d39f3b8bd66f64910f3e15e5867ca7 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md @@ -319,7 +319,7 @@ Sends sequenceable data to the target ability. | 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.Parcelable](js-apis-rpc.md#parcelable9) | Yes| Sequenceable data. You need to customize the data.| +| data | [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Yes| Parcelable data. You need to customize the data.| **Return value** @@ -338,7 +338,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error **Example** ```ts - class MyMessageAble{ // Custom sequenceable data structure. + class MyMessageAble{ // Custom parcelable data structure. name:'' str:'' num: 1 @@ -346,15 +346,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error this.name = name; this.str = str; } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); console.log('MyMessageAble marshalling num[${this.num}] str[${this.str}]'); return true; } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); console.log('MyMessageAble unmarshalling num[${this.num}] str[${this.str}]'); return true; } @@ -369,7 +369,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error deviceId: '' }).then((obj) => { caller = obj; - let msg = new MyMessageAble('msg', 'world'); // See the definition of Sequenceable. + let msg = new MyMessageAble('msg', 'world'); // See the definition of Parcelable. caller.call(method, msg) .then(() => { console.log('Caller call() called'); @@ -387,7 +387,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ## Caller.callWithResult -callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageParcel>; +callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequence>; Sends sequenceable data to the target ability and obtains the sequenceable data returned by the target ability. @@ -398,13 +398,13 @@ Sends sequenceable data to the target ability and obtains the sequenceable 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.Parcelable](js-apis-rpc.md#parcelable9) | Yes| Sequenceable data. You need to customize the data.| +| data | [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Yes| Parcelable data. You need to customize the data.| **Return value** | Type| Description| | -------- | -------- | -| Promise<[rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated)> | Promise used to return the sequenceable data from the target ability.| +| Promise<[rpc.MessageSequence](js-apis-rpc.md#messagesequence9)> | Promise used to return the sequenceable data from the target ability.| **Error codes** @@ -425,15 +425,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error this.name = name; this.str = str; } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); console.log('MyMessageAble marshalling num[${this.num}] str[${this.str}]'); return true; } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); console.log('MyMessageAble unmarshalling num[${this.num] str[${this.str}]'); return true; } @@ -453,7 +453,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error .then((data) => { console.log('Caller callWithResult() called'); let retmsg = new MyMessageAble(0, ''); - data.readSequenceable(retmsg); + data.readParcelable(retmsg); }) .catch((callErr) => { console.log('Caller.callWithResult catch error, error.code: ${JSON.stringify(callErr.code)}, error.message: ${JSON.stringify(callErr.message)}'); @@ -712,7 +712,7 @@ Registers a caller notification callback, which is invoked when the target abili | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | method | string | Yes| Notification message string negotiated between the two abilities.| -| callback | [CalleeCallback](#calleecallback) | Yes| JS notification synchronization callback of the [rpc.MessageParcel](js-apis-rpc.md#messageparceldeprecated) type. The callback must return at least one empty [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) object. Otherwise, the function execution fails.| +| callback | [CalleeCallback](#calleecallback) | Yes| JS notification synchronization callback of the [rpc.MessageSequence](js-apis-rpc.md#messagesequence9) type. The callback must return at least one empty [rpc.Parcelable](js-apis-rpc.md#parcelable9) object. Otherwise, the function execution fails.| **Error codes** @@ -733,15 +733,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error this.name = name; this.str = str; } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); console.log('MyMessageAble marshalling num[${this.num}] str[${this.str}]'); return true; } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); console.log('MyMessageAble unmarshalling num[${this.num}] str[${this.str}]'); return true; } @@ -750,7 +750,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error function funcCallBack(pdata) { console.log('Callee funcCallBack is called ${pdata}'); let msg = new MyMessageAble('test', ''); - pdata.readSequenceable(msg); + pdata.readParcelable(msg); return new MyMessageAble('test1', 'Callee test'); } export default class MainUIAbility extends UIAbility { @@ -816,10 +816,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ## CalleeCallback -(indata: rpc.MessageParcel): rpc.Parcelable; +(indata: rpc.MessageSequence): rpc.Parcelable; **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore | Name| Readable| Writable| Type| Description| | -------- | -------- | -------- | -------- | -------- | -| (indata: [rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated)) | Yes| No| [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Prototype of the listener function registered by the callee.| +| (indata: [rpc.MessageSequence](js-apis-rpc.md#messagesequence9)) | Yes| No| [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Prototype of the listener function registered by the callee.| diff --git a/en/application-dev/reference/apis/js-apis-app-form-formInfo.md b/en/application-dev/reference/apis/js-apis-app-form-formInfo.md index 09a6ae02c63c18073836925ad9b6399e48fdd67d..ab73d920af1c1b76825049c63b5560d8e82390ac 100644 --- a/en/application-dev/reference/apis/js-apis-app-form-formInfo.md +++ b/en/application-dev/reference/apis/js-apis-app-form-formInfo.md @@ -47,7 +47,7 @@ Enumerates the widget types. | Name | Value | Description | | ----------- | ---- | ------------ | | JS | 1 | JS widget. | -| eTS | 2 | eTS widget.| +| eTS | 2 | ArkTS widget.| ## ColorMode diff --git a/en/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md index ee7ba37cdd08795b0ea33e09dc687b7ccd4712bc..0a97689f23cdf69527c61dfc8dfba28e6869badf 100644 --- a/en/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md @@ -81,7 +81,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { console.log('getRdbStore done, data : ${data}'); rdbStore = data; rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) { - console.log('executeSql done, error message : ${err}'); + console.error('executeSql done, error message : ${err}'); }); if (callback) { callback(); diff --git a/en/application-dev/reference/apis/js-apis-avsession.md b/en/application-dev/reference/apis/js-apis-avsession.md index c614dddd308d3cb727c8c1acb2ce474380b3ccc5..b89eb42bc8793b9d28f1682ab87b1ac9f157c14d 100644 --- a/en/application-dev/reference/apis/js-apis-avsession.md +++ b/en/application-dev/reference/apis/js-apis-avsession.md @@ -3741,7 +3741,7 @@ Subscribes to playlist item changes. | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------------------------------- | | type | string | Yes | Event type. The event **'queueItemsChange'** is reported when one or more items in the playlist changes.| -| callback | (items: Array<[AVQueueItem](#avqueueitem10)\>) => void | Yes | Callback used for subscription. **items** in the callback indicates the names of the items that change, and **args** indicates the parameters carried in the event. | +| callback | (items: Array<[AVQueueItem](#avqueueitem10)\>) => void | Yes | Callback used for subscription. The **items** parameter in the callback indicates the changed items in the playlist. | **Error codes** @@ -3775,7 +3775,7 @@ Subscribes to playlist name changes. | Name | Type | Mandatory| Description | | -------- | ----------------------- | ---- | ------------------------------------------------------------------------------- | | type | string | Yes | Event type. The event **'queueTitleChange'** is reported when the playlist name changes.| -| callback | (title: string) => void | Yes | Callback used for subscription. **items** in the callback indicates the name of the playlist that changes, and **args** indicates the parameters carried in the event. | +| callback | (title: string) => void | Yes | Callback used for subscription. The **title** parameter in the callback indicates the changed playlist name. | **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md index 775bc6665152c9d2870e28f677022d8734a551fe..325b32ef4780b5a884cdb2f07b0eaf73c124fcc4 100644 --- a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -161,7 +161,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba | Name | Type | Mandatory| Description | | --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| | bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. | | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. | | callback | AsyncCallback<void> | Yes | Callback used to return the result. | @@ -253,7 +253,7 @@ Requests a continuous task from the system. This API uses a promise to return th | Name | Type | Mandatory| Description | | --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| | bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. | | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. | @@ -339,7 +339,7 @@ Requests to cancel a continuous task. This API uses an asynchronous callback to | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------------------------------- | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** @@ -395,7 +395,7 @@ Requests to cancel a continuous task. This API uses a promise to return the resu | Name | Type | Mandatory | Description | | ------- | ------- | ---- | ---------------------------------------- | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-batteryStatistics.md b/en/application-dev/reference/apis/js-apis-batteryStatistics.md index 89cd4ab39ee2d9a7c7e0a4f9b03a4755b55b864f..721a432caaf67116a6df882c0e8995e76b893a7e 100644 --- a/en/application-dev/reference/apis/js-apis-batteryStatistics.md +++ b/en/application-dev/reference/apis/js-apis-batteryStatistics.md @@ -18,7 +18,7 @@ import batteryStats from '@ohos.batteryStatistics'; getBatteryStats(): Promise -Obtains the power consumption information list, using a promise to return the result. +Obtains the power consumption information list. This API uses a promise to return the result. **System API**: This is a system API. @@ -34,9 +34,9 @@ Obtains the power consumption information list, using a promise to return the re For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md). -| Code| Error Message | -| -------- | -------------- | -| 4600101 | Operation failed. Cannot connect to service.| +| Code | Error Message | +|---------|---------| +| 4600101 | Operation failed. Cannot connect to service.| **Example** @@ -64,15 +64,15 @@ Obtains the power consumption information list. This API uses an asynchronous ca | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the array of power consumption information obtained. If the operation failed, **err** is an error object.| +| callback | AsyncCallback> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the array of power consumption information obtained (that is, **Array<[BatteryStatsInfo](#batterystatsinfo)>>**). If the operation failed, **err** is an error object.| **Error codes** For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md). -| Code| Error Message | -| -------- | -------------- | -| 4600101 | Operation failed. Cannot connect to service.| +| Code | Error Message | +|---------|---------| +| 4600101 | Operation failed. Cannot connect to service.| **Example** @@ -112,9 +112,9 @@ Obtains the power consumption of an application. For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md). -| Code| Error Message | -| -------- | -------------- | -| 4600101 | Operation failed. Cannot connect to service.| +| Code | Error Message | +|---------|---------| +| 4600101 | Operation failed. Cannot connect to service.| **Example** @@ -153,9 +153,9 @@ Obtains the proportion of the power consumption of an application. For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md). -| Code| Error Message | -| -------- | -------------- | -| 4600101 | Operation failed. Cannot connect to service.| +| Code | Error Message | +|---------|---------| +| 4600101 | Operation failed. Cannot connect to service.| **Example** @@ -194,16 +194,16 @@ Obtains the power consumption of a hardware unit according to the consumption ty For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md). -| Code| Error Message | -| -------- | -------------- | -| 4600101 | Operation failed. Cannot connect to service.| +| Code | Error Message | +|---------|---------| +| 4600101 | Operation failed. Cannot connect to service.| **Example** ```js try { var value = batteryStats.getHardwareUnitPowerValue(ConsumptionType.CONSUMPTION_TYPE_SCREEN); - console.info('battery statistics percent of hardware is: ' + percent); + console.info('battery statistics value of hardware is: ' + value); } catch(err) { console.error('get battery statistics percent of hardware failed, err: ' + err); } @@ -235,15 +235,15 @@ Obtains the proportion of the power consumption of a hardware unit according to For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md). -| Code| Error Message | -| -------- | -------------- | -| 4600101 | Operation failed. Cannot connect to service.| +| Code | Error Message | +|---------|---------| +| 4600101 | Operation failed. Cannot connect to service.| **Example** ```js try { - var value = batteryStats.getHardwareUnitPowerPercent(ConsumptionType.CONSUMPTION_TYPE_SCREEN); + var percent = batteryStats.getHardwareUnitPowerPercent(ConsumptionType.CONSUMPTION_TYPE_SCREEN); console.info('battery statistics percent of hardware is: ' + percent); } catch(err) { console.error('get battery statistics percent of hardware failed, err: ' + err); diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-overlayModuleInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-overlayModuleInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..5e16b3342c0f6a196c3da5362f950eecacf4c4a5 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-overlayModuleInfo.md @@ -0,0 +1,19 @@ +# OverlayModuleInfo + +> **NOTE** +> +> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +The **OverlayModuleInfo** module provides information about a module with the overlay feature. A system application can obtain such information of the specified application through [overlay.getOverlayModuleInfoByBundleName](js-apis-overlay.md#overlaygetoverlaymoduleinfobybundlename), and a third-party application can obtain such information of the current application through [overlay.getOverlayModuleInfo](js-apis-overlay.md#overlaygetoverlaymoduleinfo). + +## OverlayModuleInfo + + **System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +| Name | Type | Readable| Writable| Description | +| --------------------- | ---------------------------------------------------| ---- | ---- | ---------------------------------------------- | +| bundleName | string | Yes | No | Bundle name of the application to which the module with the overlay feature belongs. | +| moduleName | string | Yes | No | HAP name of the module with the overlay feature. | +| targetModuleName | string | Yes | No | HAP name of the target module specified by the module with the overlay feature. | +| priority | number | Yes | No | Priority of the module with the overlay feature. | +| state | number | Yes | No | Whether the module with the overlay feature is disabled. The value **0** means that the module is disabled, and **1** means the opposite. | diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-sharedBundleInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-sharedBundleInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..ad5ee9f5503d04a49060f69b40f4883a0af0773e --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-sharedBundleInfo.md @@ -0,0 +1,33 @@ +# SharedBundleInfo + +The **SharedBundleInfo** module provides information about the shared bundle. The information can be obtained by calling [bundleManager.getSharedBundleInfo](js-apis-bundleManager.md). + +> **NOTE** +> +> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## SharedBundleInfo + +Defines the shared bundle information. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Type | Readable| Writable| Description | +| ---------------- | ------------------------------ | ---- | ---- | ---------------------- | +| name | string | Yes | No | Name of the shared bundle. | +| compatiblePolicy | bundleManager.CompatiblePolicy | Yes | No | Compatibility type of the shared bundle.| +| sharedModuleInfo | Array\ | Yes | No | Information about the shared module. | + +## SharedModuleInfo + +Defines the shared module information. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Type | Readable| Writable| Description | +| ------------- | ------ | ---- | ---- | -------------------------- | +| name | string | Yes | No | Module name of the shared bundle. | +| versionCode | number | Yes | No | Version number of the shared bundle. | +| versionName | string | Yes | No | Version description of the shared bundle.| +| description | string | Yes | No | Description of the shared bundle. | +| descriptionId | number | Yes | No | Description ID of the shared bundle. | diff --git a/en/application-dev/reference/apis/js-apis-bundleManager.md b/en/application-dev/reference/apis/js-apis-bundleManager.md index 1503f821c413923f28e11a31a77c5cd2eb07c101..a05187320802cde128cfacbd9105c23a13ea5269 100644 --- a/en/application-dev/reference/apis/js-apis-bundleManager.md +++ b/en/application-dev/reference/apis/js-apis-bundleManager.md @@ -112,6 +112,7 @@ Enumerates the types of Extension abilities. | ENTERPRISE_ADMIN | 11 | [EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md): provides APIs for processing enterprise management events, such as application installation events on devices and events indicating too many incorrect screen-lock password attempts.| | THUMBNAIL | 13 | ThumbnailExtensionAbility: provides thumbnails for files. This ability is reserved.| | PREVIEW | 14 | PreviewExtensionAbility: provides APIs for file preview so that other applications can be embedded and displayed in the current application. This ability is reserved.| +| PRINT10+ | 15 | PrintExtensionAbility: provides APIs for printing images. Printing documents is not supported yet.| | UNSPECIFIED | 255 | No type is specified. It is used together with **queryExtensionAbilityInfo** to query all types of Extension abilities.| @@ -2861,6 +2862,191 @@ try { } ``` +### bundleManager.getSharedBundleInfo10+ + +getSharedBundleInfo(bundleName: string, moduleName: string, callback: AsyncCallback\\>): void; + +Obtains the shared bundle information based on the given bundle name. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name. | +| moduleName | string | Yes | Module name. | +| callback | AsyncCallback\\> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the shared bundle information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700002 | The specified moduleName is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager'; +import hilog from '@ohos.hilog'; +let bundleName = 'com.example.myapplication'; +let moduleName = 'library'; + +try { + bundleManager.getSharedBundleInfo(bundleName, moduleName, (err, data) => { + if (err) { + hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', err.message); + } else { + hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully: %{public}s', JSON.stringify(data)); + } + }); +} catch (err) { + hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', err.message); +} +``` + +### bundleManager.getSharedBundleInfo10+ + +function getSharedBundleInfo(bundleName: string, moduleName: string): Promise\\>; + +Obtains the shared bundle information based on the given bundle name. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | -------------------------- | +| bundleName | string | Yes | Bundle name.| +| moduleName | string | Yes | Module name.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | ----------------------------------- | +| Promise\\> | Promise used to return the shared bundle information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700002 | The specified moduleName is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager'; +import hilog from '@ohos.hilog'; +let bundleName = 'com.example.myapplication'; +let moduleName = 'library'; + +try { + bundleManager.getSharedBundleInfo(bundleName, moduleName).then((data) => { + hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data)); + }).catch(err => { + hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', err.message); + }); +} catch (err) { + hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', err.message); +} +``` + +### bundleManager.getAllSharedBundleInfo10+ + +getAllSharedBundleInfo(callback: AsyncCallback\\>): void; + +Obtains the information about all shared bundles. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback\\> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is an array of the shared bundle information obtained.| + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager'; +import hilog from '@ohos.hilog'; + +try { + bundleManager.getAllSharedBundleInfo((err, data) => { + if (err) { + hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', err.message); + } else { + hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully: %{public}s', JSON.stringify(data)); + } + }); +} catch (err) { + hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', err.message); +} +``` + +### bundleManager.getAllSharedBundleInfo10+ + +function getAllSharedBundleInfo(): Promise\\>; + +Obtains the information about all shared bundles. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | ----------------------------------- | +| Promise\\> | Promise used to return an array of the shared bundle information obtained.| + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager'; +import hilog from '@ohos.hilog'; + +try { + bundleManager.getAllSharedBundleInfo().then((data) => { + hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data)); + }).catch(err => { + hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message); + }); +} catch (err) { + hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message); +} +``` + +## CompatiblePolicy + +Defines the version compatibility type of the shared library. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Value | Description | +| ---------------------- | ---- | -------------------------------- | +| BACKWARD_COMPATIBILITY | 1 | The shared library is backward compatible.| + ## ModuleType Enumerates the module types. diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index 6b6222abe96a415e28290892f8e6a215c1e98478..b6b2bddb6306e577053b5ea9e34c21acf23c9477 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -20,6 +20,10 @@ dial\(phoneNumber: string, callback: AsyncCallback\): void Initiates a call. This API uses an asynchronous callback to return the result. +>**NOTE** +> +>This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9). + **Required Permissions**: ohos.permission.PLACE_CALL **System capability**: SystemCapability.Telephony.CallManager @@ -46,6 +50,10 @@ dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback**NOTE** +> +>This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9). + **Required Permissions**: ohos.permission.PLACE_CALL **System capability**: SystemCapability.Telephony.CallManager @@ -75,6 +83,10 @@ dial\(phoneNumber: string, options?: DialOptions\): Promise Initiates a call. You can set call options as needed. This API uses a promise to return the result. +>**NOTE** +> +>This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9). + **Required Permissions**: ohos.permission.PLACE_CALL **System capability**: SystemCapability.Telephony.CallManager @@ -121,11 +133,12 @@ Initiates a call. This API uses an asynchronous callback to return the result. **Parameters** | Name | Type | Mandatory| Description | -| ----------- | ---------------------------- | ---- | --------------------------------------- | +| ----------- | ---------------------------- | ---- | -------------------------------------- | | phoneNumber | string | Yes | Phone number. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -140,8 +153,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.dialCall("138xxxxxxxx", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.dialCall("138xxxxxxxx", (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -161,12 +174,13 @@ Initiates a call. You can set call options as needed. This API uses an asynchron **Parameters** | Name | Type | Mandatory| Description | -| ----------- | ----------------------------------- | ---- | ------------------------------------ | +| ----------- | ----------------------------------- | ---- | ----------------------------------- | | phoneNumber | string | Yes | Phone number. | | options | [DialCallOptions](#dialcalloptions9)| Yes | Call options, which carry other configuration information of the call. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -186,8 +200,8 @@ call.dialCall("138xxxxxxxx", { videoState: 0, dialScene: 0, dialType: 0, -}, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -209,15 +223,16 @@ Initiates a call. You can set call options as needed. This API uses a promise to | Name | Type | Mandatory| Description | | ----------- | ----------------------------------- | ---- | -------------------------------------- | | phoneNumber | string | Yes | Phone number. | -| options | [DialCallOptions](#dialcalloptions9)| No | Call option, which indicates whether the call is a voice call or video call.| +| options | [DialCallOptions](#dialcalloptions9)| No | Call options, which carry other configuration information of the call.| **Return value** -| Type | Description | -| ---------------------- | ------------------------------------------------------------ | -| Promise<void> | Promise used to return the result. | +| Type | Description | +| ---------------------- | ---------------------------- | +| Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -232,12 +247,17 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -try { - call.dialCall('138xxxxxxxx'); - console.log(`dialCall success, promise: data->${JSON.stringify(data)}`); -} catch (error) { - console.log(`dialCall fail, promise: err->${JSON.stringify(error)}`); -} +let promise = call.dialCall("138xxxxxxxx", { + accountId: 0, + videoState: 0, + dialScene: 0, + dialType: 0, +}); +promise.then(() => { + console.log(`dialCall success.`); +}).catch((err) => { + console.error(`dialCall fail, promise: err->${JSON.stringify(err)}`); +}); ``` @@ -257,6 +277,7 @@ Launches the call screen and displays the dialed number. This API uses an asynch | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -297,6 +318,7 @@ Launches the call screen and displays the dialed number. This API uses a promise | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -450,6 +472,7 @@ Checks whether the called number is an emergency number. This API uses an asynch | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. - **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -486,6 +509,7 @@ Checks whether the called number is an emergency number based on the phone numbe | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. - **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -527,6 +551,7 @@ Checks whether the called number is an emergency number based on the phone numbe | Promise<boolean> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -566,6 +591,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. | callback | AsyncCallback<string> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -603,6 +629,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. | callback | AsyncCallback<string> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -648,6 +675,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. | Promise<string> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -690,6 +718,7 @@ The phone number must match the specified country code. For example, for a China | callback | AsyncCallback<string> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -735,6 +764,7 @@ All country codes are supported. | Promise<string> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -775,10 +805,12 @@ Mutes the ringtone while it is playing. It does not work if the ringtone has bee | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | +| 201 | Permission denied. | | 401 | Parameter error. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | @@ -788,8 +820,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.muteRinger((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.muteRinger((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -813,13 +845,12 @@ Mutes the ringtone while it is playing. It does not work if the ringtone has bee | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | | 201 | Permission denied. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | | 8300999 | Unknown error code. | @@ -827,16 +858,15 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.muteRinger(); -promise.then(data => { - console.log(`muteRinger success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.muteRinger().then(() => { + console.log(`muteRinger success.`); +}).catch((err) => { console.error(`muteRinger fail, promise: err->${JSON.stringify(err)}`); }); ``` -## call.answerCall7+ +## call.answerCall9+ answerCall\(callId: number, callback: AsyncCallback\): void @@ -856,6 +886,7 @@ Answers a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -870,13 +901,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.answerCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.answerCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` -## call.answerCall7+ +## call.answerCall9+ answerCall(callId?: number\): Promise @@ -901,6 +932,7 @@ Answers a call. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -915,10 +947,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.answerCall(1); -promise.then(data => { - console.log(`answerCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.answerCall(1).then(() => { + console.log(`answerCall success.`); +}).catch((err) => { console.error(`answerCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -943,6 +974,7 @@ Answers a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -957,13 +989,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.answerCall((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.answerCall((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` -## call.hangUpCall7+ +## call.hangUpCall9+ hangUpCall\(callId: number, callback: AsyncCallback\): void @@ -983,6 +1015,7 @@ Ends a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -997,13 +1030,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.hangUpCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.hangUpCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` -## call.hangUpCall7+ +## call.hangUpCall9+ hangUpCall\(callId?: number\): Promise @@ -1028,6 +1061,7 @@ Ends a call. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1042,10 +1076,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.hangUpCall(1); -promise.then(data => { - console.log(`hangUpCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.hangUpCall(1).then(() => { + console.log(`hangUpCall success.`); +}).catch((err) => { console.error(`hangUpCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1070,6 +1103,7 @@ Ends a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1085,13 +1119,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.hangUpCall((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.hangUpCall((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` -## call.rejectCall7+ +## call.rejectCall9+ rejectCall(callId: number, callback: AsyncCallback\): void @@ -1111,6 +1145,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1126,13 +1161,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.rejectCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.rejectCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` -## call.rejectCall7+ +## call.rejectCall9+ rejectCall\(callId: number, options: RejectMessageOptions, callback: AsyncCallback\): void @@ -1153,6 +1188,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1170,13 +1206,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r let rejectMessageOptions={ messageContent: "Unknown number blocked" } -call.rejectCall(1, rejectMessageOptions, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.rejectCall(1, rejectMessageOptions, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` -## call.rejectCall7+ +## call.rejectCall9+ rejectCall(callId?: number, options?: RejectMessageOptions\): Promise @@ -1202,6 +1238,7 @@ Rejects a call. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1219,11 +1256,10 @@ For details about the following error codes, see [Telephony Error Codes](../../r let rejectMessageOptions={ messageContent: "Unknown number blocked" } -let promise = call.rejectCall(1, rejectMessageOptions); -promise.then(data => { - console.log(`rejectCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`rejectCall fail, promise: err->${JSON.stringify(err)}`); +call.reject(1, rejectMessageOptions).then(() => { + console.log(`reject success.`); +}).catch((err) => { + console.error(`reject fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1247,6 +1283,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1261,8 +1298,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.rejectCall((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.rejectCall((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1287,6 +1324,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1304,8 +1342,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r let rejectMessageOptions={ messageContent: "Unknown number blocked" } -call.rejectCall(rejectMessageOptions, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.rejectCall(rejectMessageOptions, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1330,6 +1368,7 @@ Holds a call based on the specified call ID. This API uses an asynchronous callb | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1344,8 +1383,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.holdCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.holdCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1375,6 +1414,7 @@ Holds a call based on the specified call ID. This API uses a promise to return t | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1389,10 +1429,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.holdCall(1); -promise.then(data => { - console.log(`holdCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.holdCall(1).then(() => { + console.log(`holdCall success.`); +}).catch((err) => { console.error(`holdCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1417,6 +1456,7 @@ Unholds a call based on the specified call ID. This API uses an asynchronous cal | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1431,8 +1471,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.unHoldCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.unHoldCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1462,6 +1502,7 @@ Unholds a call based on the specified call ID. This API uses a promise to return | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1476,10 +1517,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.unHoldCall(1); -promise.then(data => { - console.log(`unHoldCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.unHoldCall(1).then(() => { + console.log(`unHoldCall success.`); +}).catch((err) => { console.error(`unHoldCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1504,6 +1544,7 @@ Switches a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1518,8 +1559,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.switchCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.switchCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1549,6 +1590,7 @@ Switches a call. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1563,10 +1605,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.switchCall(1); -promise.then(data => { - console.log(`switchCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.switchCall(1).then(() => { + console.log(`switchCall success.`); +}).catch((err) => { console.error(`switchCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1589,6 +1630,7 @@ Combines two calls into a conference call. This API uses an asynchronous callbac | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1602,8 +1644,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.combineConference(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.combineConference(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1631,6 +1673,7 @@ Combines two calls into a conference call. This API uses a promise to return the | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1644,10 +1687,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.combineConference(1); -promise.then(data => { - console.log(`combineConference success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.combineConference(1).then(() => { + console.log(`combineConference success.`); +}).catch((err) => { console.error(`combineConference fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1670,6 +1712,7 @@ Obtains the main call ID. This API uses an asynchronous callback to return the r | callback | AsyncCallback<number> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1713,6 +1756,7 @@ Obtains the main call ID. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1752,6 +1796,7 @@ Obtains the list of subcall IDs. This API uses an asynchronous callback to retur | callback | AsyncCallback\> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1794,6 +1839,7 @@ Obtains the list of subcall IDs. This API uses a promise to return the result. | Promise<Array> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1833,6 +1879,7 @@ Obtains the list of call IDs in a conference. This API uses an asynchronous call | callback | AsyncCallback<Array> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1875,6 +1922,7 @@ Obtains the list of call IDs in a conference. This API uses a promise to return | Promise<Array> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1916,6 +1964,7 @@ Obtains the call waiting status. This API uses an asynchronous callback to retur | callback | AsyncCallback<[CallWaitingStatus](#callwaitingstatus7)\> | Yes | Callback used to return the result.

- **0**: Call waiting is disabled.
- **1**: Call waiting is enabled.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1961,6 +2010,7 @@ Obtains the call waiting status. This API uses a promise to return the result. | Promise<[CallWaitingStatus](#callwaitingstatus7)> | Promise used to return the result.
- **0**: Call waiting is disabled.
- **1**: Call waiting is enabled.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2004,6 +2054,7 @@ Sets the call waiting switch. This API uses an asynchronous callback to return t | callback | AsyncCallback | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2018,8 +2069,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.setCallWaiting(0, true, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setCallWaiting(0, true, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2050,6 +2101,7 @@ Sets the call waiting switch. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2064,10 +2116,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.setCallWaiting(0, true); -promise.then(data => { - console.log(`setCallWaiting success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.setCallWaiting(0, true).then(() => { + console.log(`setCallWaiting success.`); +}).catch((err) => { console.error(`setCallWaiting fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2091,6 +2142,7 @@ Enables DTMF. This API uses an asynchronous callback to return the result. | callback | AsyncCallback | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2104,8 +2156,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.startDTMF(1, "0", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.startDTMF(1, "0", (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2134,6 +2186,7 @@ Enables DTMF. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2147,10 +2200,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.startDTMF(1, "0"); -promise.then(data => { - console.log(`startDTMF success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.startDTMF(1, "0").then(() => { + console.log(`startDTMF success.`); +}).catch((err) => { console.error(`startDTMF fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2173,6 +2225,7 @@ Stops DTMF. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2186,8 +2239,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.stopDTMF(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.stopDTMF(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2215,6 +2268,7 @@ Stops DTMF. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2228,10 +2282,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.stopDTMF(1); -promise.then(data => { - console.log(`stopDTMF success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.stopDTMF(1).then(() => { + console.log(`stopDTMF success.`); +}).catch((err) => { console.error(`stopDTMF fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2255,6 +2308,7 @@ Checks whether a call is an emergency call. This API uses an asynchronous callba | callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2294,6 +2348,7 @@ Checks whether a call is an emergency call. This API uses a promise to return th | Promise<boolean> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2332,10 +2387,11 @@ Subscribes to **callDetailsChange** events. This API uses an asynchronous callba | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------- | ---- | -------------------------- | -| type | string | Yes | Call details change during a call.| -| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | Yes | Callback used to return the result. | +| type | string | Yes | Event type. This field has a fixed value of **callDetailsChange**.| +| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2371,10 +2427,11 @@ Subscribes to **callEventChange** events. This API uses an asynchronous callback | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------ | ---- | -------------------------- | -| type | string | Yes | Call event change during a call.| +| type | string | Yes | This interface is used to monitor the change of call events during a call. The parameter has a fixed value of callEventChange.| | callback | Callback<[CallEventOptions](#calleventoptions8)> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2410,10 +2467,11 @@ Subscribes to **callDisconnectedCause** events. This API uses an asynchronous ca | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------ | ---- | -------------------------- | -| type | string | Yes | Cause of the call disconnection.| +| type | string | Yes | Event type. The field has a fixed value of **callDisconnectedCause**.| | callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2449,10 +2507,11 @@ Subscribes to **mmiCodeResult** events. This API uses an asynchronous callback t | Name | Type | Mandatory| Description | | -------- | -------------------------------------------- | ---- | --------------------- | -| type | string | Yes | Man-machine interface (MMI) code result.| +| type | string | Yes | Event type. The field has a fixed value of **mmiCodeResult**.| | callback | Callback<[MmiCodeResults](#mmicoderesults9)> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2488,10 +2547,11 @@ Unsubscribes from **callDetailsChange** events. This API uses an asynchronous ca | Name | Type | Mandatory| Description | | -------- | -------------------------------------------------------- | ---- | ---------------------------------- | -| type | string | Yes | IMS registration status changes.| +| type | string | Yes | Event type. The field has a fixed value of **callDetailsChange**.| | callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | No | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2527,10 +2587,11 @@ Unsubscribes from **callEventChange** events. This API uses an asynchronous call | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------ | ---- | ---------------------------------- | -| type | string | Yes | Unsubscription from call event changes when a call ends.| +| type | string | Yes | Event type. The field has a fixed value of **callEventChange**.| | callback | Callback<[CallEventOptions](#calleventoptions8)> | No | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2565,11 +2626,12 @@ Unsubscribes from **callDisconnectedCause** events. This API uses an asynchronou **Parameters** | Name | Type | Mandatory| Description | -| -------- | ---------------------------------------------------------- | ---- | -------------------- | -| type | 'callDisconnectedCause' | Yes | Unsubscription from the call disconnection cause when a call ends.| -| callback | Callback**<**[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. | +| -------- | ---------------------------------------------------------- | ---- | ------------------- | +| type | string | Yes | Event type. The field has a fixed value of **callDisconnectedCause**.| +| callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2603,12 +2665,13 @@ Unsubscribes from **mmiCodeResult** events. This API uses an asynchronous callba **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | -------- | ------------------------------------------------ | ---- | ----------- | -| type | 'mmiCodeResult' | Yes | MMI code result.| -| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. | +| type | string | Yes | Event type. The field has a fixed value of **mmiCodeResult**.| +| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2645,6 +2708,7 @@ Checks whether a new call is allowed. This API uses an asynchronous callback to | callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2681,6 +2745,7 @@ Checks whether a new call is allowed. This API uses a promise to return the resu | Promise<boolean> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2720,6 +2785,7 @@ Separates calls from a conference call. This API uses an asynchronous callback t | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2733,8 +2799,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.separateConference(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.separateConference(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2762,6 +2828,7 @@ Separates calls from a conference call. This API uses a promise to return the re | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2775,10 +2842,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.separateConference(1); -promise.then(data => { - console.log(`separateConference success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.separateConference(1).then(() => { + console.log(`separateConference success.`); +}).catch((err) => { console.error(`separateConference fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2804,6 +2870,7 @@ Obtains the call restriction status. This API uses an asynchronous callback to r | callback | AsyncCallback<[RestrictionStatus](#restrictionstatus8)> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2850,6 +2917,7 @@ Obtains the call restriction status. This API uses a promise to return the resul | Promise<[RestrictionStatus](#restrictionstatus8)> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2893,6 +2961,7 @@ Sets the call restriction status. This API uses an asynchronous callback to retu | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2912,8 +2981,8 @@ let callRestrictionInfo={ password: "123456", mode: 1 } -call.setCallRestriction(0, callRestrictionInfo, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setCallRestriction(0, callRestrictionInfo, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2944,6 +3013,7 @@ Sets the call restriction status. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2963,10 +3033,9 @@ let callRestrictionInfo={ password: "123456", mode: 1 } -let promise = call.setCallRestriction(0, callRestrictionInfo); -promise.then(data => { - console.log(`setCallRestriction success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.setCallRestriction(0, callRestrictionInfo).then(() => { + console.log(`setCallRestriction success.`); +}).catch((err) => { console.error(`setCallRestriction fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2992,6 +3061,7 @@ Obtains call transfer information. This API uses an asynchronous callback to ret | callback | AsyncCallback<[CallTransferResult](#calltransferresult8)> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3038,6 +3108,7 @@ Obtains call transfer information. This API uses a promise to return the result. | Promise<[CallTransferResult](#calltransferresult8)> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3081,6 +3152,7 @@ Sets call transfer information. This API uses an asynchronous callback to return | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3100,8 +3172,8 @@ let callTransferInfo={ type: 1, settingType: 1 } -call.setCallTransfer(0, callTransferInfo, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setCallTransfer(0, callTransferInfo, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3132,6 +3204,7 @@ Sets call transfer information. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3151,10 +3224,9 @@ let callTransferInfo={ type: 1, settingType: 1 } -let promise = call.setCallTransfer(0, callTransferInfo); -promise.then(data => { - console.log(`setCallTransfer success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.setCallTransfer(0, callTransferInfo).then(() => { + console.log(`setCallTransfer success.`); +}).catch((err) => { console.error(`setCallTransfer fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3178,6 +3250,7 @@ Checks whether the ringtone is playing. This API uses an asynchronous callback t | callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3217,6 +3290,7 @@ Checks whether the ringtone is playing. This API uses a promise to return the re | Promise<boolean> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3256,6 +3330,7 @@ Sets call muting. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3269,8 +3344,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.setMuted((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setMuted((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3292,6 +3367,7 @@ Sets call muting. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3305,10 +3381,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.setMuted(); -promise.then(data => { - console.log(`setMuted success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.setMuted().then(() => { + console.log(`setMuted success.`); +}).catch((err) => { console.error(`setMuted fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3330,6 +3405,7 @@ Cancels call muting. This API uses an asynchronous callback to return the result | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3343,8 +3419,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.cancelMuted((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.cancelMuted((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3366,6 +3442,7 @@ Cancels call muting. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3379,10 +3456,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.cancelMuted(); -promise.then(data => { - console.log(`cancelMuted success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.cancelMuted().then(() => { + console.log(`cancelMuted success.`); +}).catch((err) => { console.error(`cancelMuted fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3405,6 +3481,7 @@ Sets the audio device for a call. This API uses an asynchronous callback to retu | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3418,8 +3495,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.setAudioDevice(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setAudioDevice(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3443,6 +3520,7 @@ Sets the audio device for a call based on the specified options. This API uses a | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3459,8 +3537,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r let audioDeviceOptions={ bluetoothAddress: "IEEE 802-2014" } -call.setAudioDevice(1, audioDeviceOptions, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setAudioDevice(1, audioDeviceOptions, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3489,6 +3567,7 @@ Sets the audio device for a call based on the specified options. This API uses a | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3505,10 +3584,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r 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 => { +call.setAudioDevice(1, audioDeviceOptions).then(() => { + console.log(`setAudioDevice success.`); +}).catch((err) => { console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3532,6 +3610,7 @@ Joins a conference call. This API uses an asynchronous callback to return the re | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3548,8 +3627,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r let callNumberList: Array = [ "138XXXXXXXX" ]; -call.joinConference(1, callNumberList, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.joinConference(1, callNumberList, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3577,6 +3656,7 @@ Joins a conference call. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3593,10 +3673,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r let callNumberList: Array = [ "138XXXXXXXX" ]; -let promise = call.joinConference(1, callNumberList); -promise.then(data => { - console.log(`joinConference success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.joinConference(1, callNumberList).then(() => { + console.log(`joinConference success.`); +}).catch((err) => { console.error(`joinConference fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3620,6 +3699,7 @@ Updates the IMS call mode. This API uses an asynchronous callback to return the | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3633,8 +3713,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.updateImsCallMode(1, 1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.updateImsCallMode(1, 1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3662,6 +3742,7 @@ Updates the IMS call mode. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3675,10 +3756,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.updateImsCallMode(1, 1); -promise.then(data => { - console.log(`updateImsCallMode success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.updateImsCallMode(1, 1).then(() => { + console.log(`updateImsCallMode success.`); +}).catch((err) => { console.error(`updateImsCallMode fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3703,6 +3783,7 @@ Enables the IMS switch. This API uses an asynchronous callback to return the res | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3717,8 +3798,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.enableImsSwitch(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.enableImsSwitch(0, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3747,6 +3828,7 @@ Enables the IMS switch. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3761,10 +3843,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.enableImsSwitch(0); -promise.then(data => { - console.log(`enableImsSwitch success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.enableImsSwitch(0).then(() => { + console.log(`enableImsSwitch success.`); +}).catch((err) => { console.error(`enableImsSwitch fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3789,6 +3870,7 @@ Disables the IMS switch. This API uses an asynchronous callback to return the re | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3803,8 +3885,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.disableImsSwitch(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.disableImsSwitch(0, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3822,20 +3904,21 @@ Disables the IMS switch. This API uses a promise to return the result. **Parameters** -| Name| Type | Mandatory| Description | +| Name| Type | Mandatory| Description | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | **Return value** -| Type | Description | +| Type | Description | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| Promise<void> | Promise used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). -| ID| Error Message | +| ID| Error Message | | -------- | -------------------------------------------- | | 201 | Permission denied. | | 401 | Parameter error. | @@ -3847,10 +3930,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.disableImsSwitch(0); -promise.then(data => { - console.log(`disableImsSwitch success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.disableImsSwitch(0).then(() => { + console.log(`disableImsSwitch success.`); +}).catch((err) => { console.error(`disableImsSwitch fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3873,6 +3955,7 @@ Checks whether the IMS switch is enabled. This API uses an asynchronous callback | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3914,6 +3997,7 @@ Checks whether the IMS switch is enabled. This API uses a promise to return the | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md index ec4684a53f03a85706e29f6fc918371ab54d5363..4238ee5df2b8a9bf894b83d23b9fcb11ddb9325d 100644 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -31,6 +31,15 @@ Obtains a **CameraManager** instance. This API returns the result synchronously. | ----------------------------------------------- | ---------------------------- | | [CameraManager](#cameramanager) | **CameraManager** instance obtained. | +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -255,6 +264,14 @@ Creates a **CameraInput** instance with the specified **CameraDevice** object. T | ---------- | ----------------------------- | | [CameraInput](#camerainput) | **CameraInput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | + **Example** ```js @@ -291,6 +308,14 @@ Creates a **CameraInput** instance with the specified camera position and type. | ---------- | ----------------------------- | | [CameraInput](#camerainput) | **CameraInput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | + **Example** ```js @@ -327,6 +352,14 @@ Creates a **PreviewOutput** instance. This API returns the result synchronously. | ---------- | ----------------------------- | | [PreviewOutput](#previewoutput) | **PreviewOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | + **Example** ```js @@ -361,6 +394,14 @@ Creates a **PhotoOutput** instance. This API returns the result synchronously. | ---------- | ----------------------------- | | [PhotoOutput](#photooutput) | **PhotoOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | + **Example** ```js @@ -395,6 +436,14 @@ Creates a **VideoOutput** instance. This API returns the result synchronously. | ---------- | ----------------------------- | | [VideoOutput](#videooutput) | **VideoOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | + **Example** ```js @@ -428,6 +477,14 @@ Creates a **MetadataOutput** instance. This API returns the result synchronously | ---------- | ----------------------------- | | [MetadataOutput](#metadataoutput) | **MetadataOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | + **Example** ```js @@ -455,6 +512,14 @@ Creates a **CaptureSession** instance. This API returns the result synchronously | ---------- | ----------------------------- | | [CaptureSession](#capturesession) | **CaptureSession** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -630,6 +695,16 @@ Opens this camera. This API uses an asynchronous callback to return the result. | -------- | -------------------- | ---- | ------------------- | | callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400107 | Can not use camera cause of conflict. | +| 7400108 | Camera disabled cause of security reason. | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -656,6 +731,16 @@ Opens this camera. This API uses a promise to return the result. | -------------- | ----------------------- | | Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400107 | Can not use camera cause of conflict. | +| 7400108 | Camera disabled cause of security reason. | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -680,6 +765,14 @@ Closes this camera. This API uses an asynchronous callback to return the result. | -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -706,6 +799,14 @@ Closes this camera. This API uses a promise to return the result. | -------------- | ----------------------- | | Promise| Promise used to return the result.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -823,6 +924,14 @@ Starts configuration for the session. | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400105 | Session config locked. | + **Example** ```js @@ -848,6 +957,15 @@ Commits the configuration for this **CaptureSession** instance. This API uses an | -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400102 | Operation not allow. | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -874,6 +992,15 @@ Commits the configuration for this **CaptureSession** instance. This API uses a | -------------- | ------------------------ | | Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400102 | Operation not allow. | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -905,6 +1032,15 @@ Adds a [CameraInput](#camerainput) instance to the session. | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | +| 7400102 | Operation not allow. | + **Example** ```js @@ -936,6 +1072,15 @@ Removes a [CameraInput](#camerainput) instance from the session. | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | +| 7400102 | Operation not allow. | + **Example** ```js @@ -967,6 +1112,15 @@ Adds a [CameraOutput](#cameraoutput) instance to the session. | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | +| 7400102 | Operation not allow. | + **Example** ```js @@ -998,6 +1152,15 @@ Removes a [CameraOutput](#cameraoutput) instance from the session. | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | +| 7400102 | Operation not allow. | + **Example** ```js @@ -1023,6 +1186,15 @@ Starts this **CaptureSession**. This API uses an asynchronous callback to return | -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -1049,6 +1221,15 @@ Starts this **CaptureSession**. This API uses a promise to return the result. | -------------- | ------------------------ | | Promise| Promise used to return the result.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -1073,6 +1254,14 @@ Stops this **CaptureSession**. This API uses an asynchronous callback to return | -------- | -------------------- | ---- | ------------------- | | callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -1099,6 +1288,14 @@ Stops this **CaptureSession**. This API uses a promise to return the result. | -------------- | ----------------------- | | Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -1123,6 +1320,14 @@ Releases this **CaptureSession**. This API uses an asynchronous callback to retu | -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -1149,6 +1354,14 @@ Releases this **CaptureSession**. This API uses a promise to return the result. | -------------- | ------------------------ | | Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -1173,6 +1386,14 @@ Checks whether the device has flash. This API uses an asynchronous callback to r | ---------- | ----------------------------- | | boolean | Returns **true** if the device has flash; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1204,6 +1425,14 @@ Checks whether a flash mode is supported. | ---------- | ----------------------------- | | boolean | Returns **true** if the flash mode is supported; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1240,6 +1469,14 @@ Before the setting, do the following checks: | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1265,6 +1502,14 @@ Obtains the flash mode in use. | ---------- | ----------------------------- | | [FlashMode](#flashmode) | Flash mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1296,6 +1541,14 @@ Checks whether an exposure mode is supported. | ---------- | ----------------------------- | | boolean | Returns **true** if the exposure mode is supported; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1321,6 +1574,14 @@ Obtains the exposure mode in use. | ---------- | ----------------------------- | | [ExposureMode](#exposuremode) | Exposure mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1352,6 +1613,14 @@ Sets an exposure mode for the device. | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1377,6 +1646,14 @@ Obtains the metering point of the device. | ---------- | ----------------------------- | | [Point](#point) | Metering point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1410,6 +1687,14 @@ The coordinate system is based on the horizontal device direction with the devic | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1436,6 +1721,14 @@ Obtains the exposure compensation values of the device. | ---------- | ----------------------------- | | Array | An array of compensation values. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1463,6 +1756,14 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure | -------- | -------------------------------| ---- | ------------------- | | exposureBias | number | Yes | Exposure bias to set, which must be within the range obtained by running **getExposureBiasRange** interface. If the API call fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1489,6 +1790,14 @@ Obtains the exposure value in use. | ---------- | ----------------------------- | | number | Exposure value obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1520,6 +1829,14 @@ Checks whether a focus mode is supported. | ---------- | ----------------------------- | | boolean | Returns **true** if the focus mode is supported; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1553,6 +1870,14 @@ Before the setting, use **[isFocusModeSupported](#isfocusmodesupported)** to che | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1578,6 +1903,14 @@ Obtains the focus mode in use. | ---------- | ----------------------------- | | [FocusMode](#focusmode) | Focus mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1611,6 +1944,14 @@ The coordinate system is based on the horizontal device direction with the devic | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1637,6 +1978,14 @@ Obtains the focal point of the device. | ---------- | ----------------------------- | | [Point](#point) | Focal point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1662,6 +2011,14 @@ Obtains the focal length of the device. | ---------- | ----------------------------- | | number | Focal length obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1687,6 +2044,14 @@ Obtains the supported zoom ratio range. | ---------- | ----------------------------- | | Array | Callback used to return an array containing the minimum and maximum zoom ratios. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1718,6 +2083,14 @@ Sets a zoom ratio, with a maximum precision of two decimal places. | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1744,6 +2117,14 @@ Obtains the zoom ratio in use. | ---------- | ----------------------------- | | number | Zoom ratio obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1775,6 +2156,14 @@ Checks whether the specified video stabilization mode is supported. | ---------- | ----------------------------- | | boolean | Returns **true** if the video stabilization mode is supported; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1800,6 +2189,14 @@ Obtains the video stabilization mode in use. | ---------- | ----------------------------- | | VideoStabilizationMode | Video stabilization mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1831,6 +2228,14 @@ Sets a video stabilization mode for the device. | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1910,6 +2315,14 @@ Starts to output preview streams. This API uses an asynchronous callback to retu | -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -1936,6 +2349,14 @@ Starts to output preview streams. This API uses a promise to return the result. | -------------- | ----------------------- | | Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | + **Example** ```js @@ -2010,6 +2431,14 @@ Releases output resources. This API uses an asynchronous callback to return the | -------- | -------------------- | ---- | ------------------- | | callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -2036,6 +2465,14 @@ Releases output resources. This API uses a promise to return the result. | -------------- | ----------------------- | | Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -2184,6 +2621,15 @@ Captures a photo with the default shooting parameters. This API uses an asynchro | -------- | -------------------- | ---- | ------------------- | | callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400104 | Session not running. | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -2210,6 +2656,15 @@ Captures a photo with the default shooting parameters. This API uses a promise t | -------------- | ------------------------ | | Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400104 | Session not running. | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -2235,6 +2690,16 @@ Captures a photo with the specified shooting parameters. This API uses an asynch | setting | [PhotoCaptureSetting](#photocapturesetting) | Yes | Shooting settings. | | callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned. | +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | +| 7400104 | Session not running. | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -2278,6 +2743,15 @@ Captures a photo with the specified shooting parameters. This API uses a promise | -------------- | ------------------------ | | Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | +| 7400104 | Session not running. | +| 7400201 | Camera service fatal error. | **Example** @@ -2323,6 +2797,14 @@ Releases output resources. This API uses an asynchronous callback to return the | -------- | -------------------- | ---- | ------------------- | | callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -2349,6 +2831,14 @@ Releases output resources. This API uses a promise to return the result. | -------------- | ----------------------- | | Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -2493,6 +2983,15 @@ Starts video recording. This API uses an asynchronous callback to return the res | -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -2519,6 +3018,14 @@ Starts video recording. This API uses a promise to return the result. | -------------- | ----------------------- | | Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | +| 7400201 | Camera service fatal error. | **Example** @@ -2594,6 +3101,14 @@ Releases output resources. This API uses an asynchronous callback to return the | -------- | -------------------- | ---- | ------------------- | | callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -2620,6 +3135,14 @@ Releases output resources. This API uses a promise to return the result. | -------------- | ----------------------- | | Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -2717,6 +3240,15 @@ Starts to output metadata. This API uses an asynchronous callback to return the | -------- | -------------------------- | ---- | ------------------- | | callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | +| 7400201 | Camera service fatal error. | + **Example** ```js @@ -2743,6 +3275,15 @@ Starts to output metadata. This API uses a promise to return the result. | ---------------------- | ------------------------ | | Promise | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| +**Error codes** + +For details about the error codes, see [CameraErrorCode](#cameraerrorcode). + +| ID | Error Message | +| --------------- | --------------- | +| 7400103 | Session not config. | +| 7400201 | Camera service fatal error. | + **Example** ```js diff --git a/en/application-dev/reference/apis/js-apis-commonEventManager.md b/en/application-dev/reference/apis/js-apis-commonEventManager.md index 8f150f4bbf02a8c11f81beddecd2e7edf89ab431..c94524533f8795ee22ebb328ce7ecd1f2ce1ad2c 100644 --- a/en/application-dev/reference/apis/js-apis-commonEventManager.md +++ b/en/application-dev/reference/apis/js-apis-commonEventManager.md @@ -86,8 +86,8 @@ For details about the error codes, see [Event Error Codes](../errorcodes/errorco ```ts // Attributes of a common event. let options = { - code: 0, // Initial code of the common event. - data: "initial data",// Initial data of the common event. + code: 0, // Result code of the common event. + data: "initial data",// Result data of the common event. isOrdered: true // The common event is an ordered one. } @@ -186,8 +186,8 @@ For details about the error codes, see [Event Error Codes](../errorcodes/errorco ```ts // Attributes of a common event. let options = { - code: 0, // Initial code of the common event. - data: "initial data",// Initial data of the common event. + code: 0, // Result code of the common event. + data: "initial data",// Result data of the common event. } // Callback for common event publication. @@ -224,7 +224,7 @@ Creates a subscriber. This API uses an asynchronous callback to return the resul | Name | Type | Mandatory| Description | | ------------- | ------------------------------------------------------------ | ---- | -------------------------- | -| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. | +| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. | | callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Yes | Callback used to return the result.| **Example** @@ -270,7 +270,7 @@ Creates a subscriber. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | ------------- | ----------------------------------------------------- | ---- | -------------- | -| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information.| +| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information.| **Return value** | Type | Description | @@ -327,7 +327,7 @@ let subscribeInfo = { // Callback for common event subscription. function SubscribeCB(err, data) { - if (err.code) { + if (err) { console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`); } else { console.info("subscribe "); diff --git a/en/application-dev/reference/apis/js-apis-contact.md b/en/application-dev/reference/apis/js-apis-contact.md index 2778a143c65125eca650324e67a220ab60f64ead..bcc8b36fc9a93191258ed78edb68df61ccce4c28 100644 --- a/en/application-dev/reference/apis/js-apis-contact.md +++ b/en/application-dev/reference/apis/js-apis-contact.md @@ -166,6 +166,7 @@ Updates a contact based on the specified contact information. This API uses an a ```js contact.updateContact({ + id: 1, name: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] }, (err) => { @@ -200,6 +201,7 @@ Updates a contact based on the specified contact information and attributes. Thi ```js contact.updateContact({ + id: 1, name: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] }, { @@ -241,6 +243,7 @@ Updates a contact based on the specified contact information and attributes. Thi ```js let promise = contact.updateContact({ + id: 1, name: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] }, { diff --git a/en/application-dev/reference/apis/js-apis-data-relationalStore.md b/en/application-dev/reference/apis/js-apis-data-relationalStore.md index 1b9948db2d3decf6b7d21d17cb74b53450ae3865..e49fa27eb58c01d5ccfaa905159c9124f7812687 100644 --- a/en/application-dev/reference/apis/js-apis-data-relationalStore.md +++ b/en/application-dev/reference/apis/js-apis-data-relationalStore.md @@ -8,7 +8,7 @@ The **relationalStore** module provides the following functions: - [RdbStore](#rdbstore): provides APIs for managing data in an RDB store. - [Resultset](#resultset): provides APIs for accessing the result set obtained from the RDB store. -> **NOTE**
+> **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. @@ -30,7 +30,7 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul | Name | Type | Mandatory| Description | | -------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| | config | [StoreConfig](#storeconfig) | Yes | Configuration of the RDB store. | | callback | AsyncCallback<[RdbStore](#rdbstore)> | Yes | Callback invoked to return the RDB store obtained. | @@ -108,7 +108,7 @@ Obtains an RDB store. This API uses a promise to return the result. You can set | Name | Type | Mandatory| Description | | ------- | -------------------------------- | ---- | ------------------------------------------------------------ | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| | config | [StoreConfig](#storeconfig) | Yes | Configuration of the RDB store. | **Return value** @@ -188,7 +188,7 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| | name | string | Yes | Name of the RDB store to delete. | | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | @@ -249,7 +249,7 @@ Deletes an RDB store. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | ------- | ------- | ---- | ------------------------------------------------------------ | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| | name | string | Yes | Name of the RDB store to delete. | **Return value** @@ -2612,9 +2612,9 @@ Synchronizes data between devices. This API uses a promise to return the result. let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); predicates.inDevices(['12345678abcde']); let promise = store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates); -promise.then((resultSet) =>{ +promise.then((result) =>{ console.info(`Sync done.`); - for (let i = 0; i < resultSet.length; i++) { + for (let i = 0; i < result.length; i++) { console.info(`device= ${result[i][0]}, status= ${result[i][1]}`); } }).catch((err) => { @@ -2693,10 +2693,12 @@ Provides APIs to access the result set obtained by querying the RDB store. A res Obtain the **resultSet** object first. ```js +let resultSet = null; let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); predicates.equalTo("AGE", 18); let promise = store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); -promise.then((resultSet) => { +promise.then((result) => { + resultSet = result; console.info(`resultSet columnNames: ${resultSet.columnNames}`); console.info(`resultSet columnCount: ${resultSet.columnCount}`); }); @@ -2867,7 +2869,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); let promise = store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); promise.then((resultSet) => { - resultSet.(5); + resultSet.goToRow(5); resultSet.close(); }).catch((err) => { console.error(`query failed, err: ${err}`); 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 bd78aa4b4965436b5a570e69d62bbbd522b9d710..5d6b71b99b23044250b231f34630a973f0705515 100644 --- a/en/application-dev/reference/apis/js-apis-device-manager.md +++ b/en/application-dev/reference/apis/js-apis-device-manager.md @@ -96,7 +96,7 @@ Enumerates the device types. | CAR | 0x83 | Car. | | UNKNOWN_TYPE | 0 | Unknown device type.| -## AuthForm +## AuthForm10+ Enumerates the device authentication types. @@ -262,8 +262,6 @@ getTrustedDeviceListSync(): Array<DeviceInfo> Obtains all trusted devices synchronously. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Return value** @@ -296,8 +294,6 @@ getTrustedDeviceList(callback:AsyncCallback<Array<DeviceInfo>>): voi Obtains all trusted devices. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -336,8 +332,6 @@ getTrustedDeviceList(): Promise<Array<DeviceInfo>> Obtains all trusted devices. This API uses a promise to return the result. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Return value** @@ -370,8 +364,6 @@ getLocalDeviceInfoSync(): [DeviceInfo](#deviceinfo) Obtains local device information synchronously. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Return value** @@ -404,8 +396,6 @@ getLocalDeviceInfo(callback:AsyncCallback<DeviceInfo>): void Obtains local device information. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -444,8 +434,6 @@ getLocalDeviceInfo(): Promise<DeviceInfo> Obtains local device information. This API uses a promise to return the result. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Return value** @@ -478,8 +466,6 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void Starts to discover peripheral devices. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -524,8 +510,6 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void Starts to discover peripheral devices and filters discovered devices. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -580,8 +564,6 @@ stopDeviceDiscovery(subscribeId: number): void Stops device discovery. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -616,8 +598,6 @@ publishDeviceDiscovery(publishInfo: PublishInfo): void Publishes device information for discovery purposes. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -659,8 +639,6 @@ unPublishDeviceDiscovery(publishId: number): void Stops publishing device information. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -695,8 +673,6 @@ authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: Async Authenticates a device. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -757,8 +733,6 @@ unAuthenticateDevice(deviceInfo: DeviceInfo): void Deauthenticates a device. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -798,8 +772,6 @@ verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, Verifies authentication information. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -844,8 +816,6 @@ setUserOperation(operateAction: number, params: string): void; Sets a user operation. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -880,8 +850,6 @@ requestCredentialRegisterInfo(requestInfo: string, callback: AsyncCallback<{regi Obtains the registration information of the credential. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -917,8 +885,6 @@ importCredential(credentialInfo: string, callback: AsyncCallback<{resultInfo: st Imports credential information. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -970,8 +936,6 @@ deleteCredential(queryInfo: string, callback: AsyncCallback<{resultInfo: string} Deletes credential information. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1008,8 +972,6 @@ on(type: 'uiStateChange', callback: Callback<{ param: string}>): void; Subscribes to UI status changes. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1040,8 +1002,6 @@ off(type: 'uiStateChange', callback?: Callback<{ param: string}>): void; Unsubscribes from UI status changes. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1067,8 +1027,6 @@ on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChange Subscribes to changes in the device state. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1096,8 +1054,6 @@ off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChang Unsubscribes from changes in the device state. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1125,8 +1081,6 @@ on(type: 'deviceFound', callback: Callback<{ subscribeId: number, device: Dev Subscribes to device discovery events. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1154,8 +1108,6 @@ off(type: 'deviceFound', callback?: Callback<{ subscribeId: number, device: D Unsubscribes from device discovery events. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1183,8 +1135,6 @@ on(type: 'discoverFail', callback: Callback<{ subscribeId: number, reason: nu Subscribes to device discovery failures. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1212,8 +1162,6 @@ off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: Unsubscribes from device discovery failures. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1241,8 +1189,6 @@ on(type: 'publishSuccess', callback: Callback<{ publishId: number }>): voi Subscribes to device information publication success events. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1271,8 +1217,6 @@ off(type: 'publishSuccess', callback?: Callback<{ publishId: number }>): v Unsubscribes from device information publication success events. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1300,8 +1244,6 @@ on(type: 'publishFail', callback: Callback<{ publishId: number, reason: numbe Subscribes to device information publication failures. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1329,8 +1271,6 @@ off(type: 'publishFail', callback?: Callback<{ publishId: number, reason: num Unsubscribes from device information publication failures. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1358,8 +1298,6 @@ on(type: 'serviceDie', callback: () => void): void Subscribes to dead events of the **DeviceManager** service. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** @@ -1387,8 +1325,6 @@ off(type: 'serviceDie', callback?: () => void): void Unsubscribes from dead events of the **DeviceManager** service. -**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) - **System capability**: SystemCapability.DistributedHardware.DeviceManager **Parameters** diff --git a/en/application-dev/reference/apis/js-apis-enterprise-adminManager.md b/en/application-dev/reference/apis/js-apis-enterprise-adminManager.md index 05b3f1f716f675a5eb876acec6e321b9b0dc762d..a29988585ec509bbd1948e101324dbf253991873 100644 --- a/en/application-dev/reference/apis/js-apis-enterprise-adminManager.md +++ b/en/application-dev/reference/apis/js-apis-enterprise-adminManager.md @@ -953,5 +953,7 @@ Enumerates the system management events that can be subscribed to. | Name | Value | Description | | -------------------------- | ---- | ------------- | -| MANAGED_EVENT_BUNDLE_ADDED | 0 | Application installation event.| -| MANAGED_EVENT_BUNDLE_REMOVED | 1 | Application uninstallation event.| +| MANAGED_EVENT_BUNDLE_ADDED | 0 | Bundle added.| +| MANAGED_EVENT_BUNDLE_REMOVED | 1 | Bundle removed.| +| MANAGED_EVENT_APP_START | 2 | Application started.| +| MANAGED_EVENT_APP_STOP | 3 | Application stopped.| diff --git a/en/application-dev/reference/apis/js-apis-enterprise-wifiManager.md b/en/application-dev/reference/apis/js-apis-enterprise-wifiManager.md index 44ed633f182665681e3dbb844c38406113bf9ff7..4e19154377bb2b91e8f47af1b92a126f5c429cbd 100644 --- a/en/application-dev/reference/apis/js-apis-enterprise-wifiManager.md +++ b/en/application-dev/reference/apis/js-apis-enterprise-wifiManager.md @@ -86,8 +86,8 @@ For details about the error codes, see [Enterprise Device Management Error Codes | ID| Error Message | | ------- | ---------------------------------------------------------------------------- | -| 9200001 | The application is not an administrator application of the device. | -| 9200002 | The administrator application does not have permission to manage the device.| +| 9200001 | The application is not an administrator application of the device. | +| 9200002 | The administrator application does not have permission to manage the device. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-faultLogger.md b/en/application-dev/reference/apis/js-apis-faultLogger.md index ea9be4cbb8e141c716e92ded6d839651bae9bf7f..98ddcfd6e20d64d4ef664fec43637b29e207bca5 100644 --- a/en/application-dev/reference/apis/js-apis-faultLogger.md +++ b/en/application-dev/reference/apis/js-apis-faultLogger.md @@ -40,11 +40,9 @@ Defines the data structure of the fault log information. | summary | string | Yes| Summary of the fault.| | fullLog | string | Yes| Full log text.| -## faultLogger.querySelfFaultLog(deprecated) - -querySelfFaultLog(faultType: FaultType, callback: AsyncCallback<Array<FaultLogInfo>>) : void +## faultLogger.query9+ -> **NOTE**
This API is deprecated since API version 9. You are advised to use [faultLogger.query](#faultloggerquery9) instead. +query(faultType: FaultType, callback: AsyncCallback<Array<FaultLogInfo>>) : void Obtains the fault information about the current process. This API uses an asynchronous callback to return the fault information array obtained, which contains a maximum of 10 pieces of fault information. @@ -57,6 +55,14 @@ Obtains the fault information about the current process. This API uses an asynch | faultType | [FaultType](#faulttype) | Yes| Fault type.| | callback | AsyncCallback<Array<[FaultLogInfo](#faultloginfo)>> | Yes| Callback used to return the fault information array.
The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned. +**Error codes** + +For details about the error codes, see [FaultLogger Error Codes](../errorcodes/errorcode-faultlogger.md). + +| ID| Error Message| +| --- | --- | +| 10600001 | The service is not started or is faulty | + **Example** ```js @@ -79,14 +85,16 @@ function queryFaultLogCallback(error, value) { } } } -faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH, queryFaultLogCallback); +try { + faultLogger.query(faultLogger.FaultType.JS_CRASH, queryFaultLogCallback); +} catch (err) { + console.error(`code: ${err.code}, message: ${err.message}`); +} ``` -## faultLogger.querySelfFaultLog(deprecated) - -querySelfFaultLog(faultType: FaultType) : Promise<Array<FaultLogInfo>> +## faultLogger.query9+ -> **NOTE**
This API is deprecated since API version 9. You are advised to use [faultLogger.query](#faultloggerquery9-1) instead. +query(faultType: FaultType) : Promise<Array<FaultLogInfo>> Obtains the fault information about the current process. This API uses a promise to return the fault information array obtained, which contains a maximum of 10 pieces of fault information. @@ -104,32 +112,48 @@ Obtains the fault information about the current process. This API uses a promise | -------- | -------- | | Promise<Array<[FaultLogInfo](#faultloginfo)>> | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**.
The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval.| +**Error codes** + +For details about the error codes, see [FaultLogger Error Codes](../errorcodes/errorcode-faultlogger.md). + +| ID| Error Message| +| --- | --- | +| 10600001 | The service is not started or is faulty | + **Example** ```js async function getLog() { - let value = await faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH); - if (value) { - console.info("value length is " + value.length); - let len = value.length; - for (let i = 0; i < len; i++) { - console.info("log: " + i); - console.info("Log pid: " + value[i].pid); - console.info("Log uid: " + value[i].uid); - console.info("Log type: " + value[i].type); - console.info("Log timestamp: " + value[i].timestamp); - console.info("Log reason: " + value[i].reason); - console.info("Log module: " + value[i].module); - console.info("Log summary: " + value[i].summary); - console.info("Log text: " + value[i].fullLog); + try { + let value = await faultLogger.query(faultLogger.FaultType.JS_CRASH); + if (value) { + console.info("value length is " + value.length); + let len = value.length; + for (let i = 0; i < len; i++) { + console.info("log: " + i); + console.info("Log pid: " + value[i].pid); + console.info("Log uid: " + value[i].uid); + console.info("Log type: " + value[i].type); + console.info("Log timestamp: " + value[i].timestamp); + console.info("Log reason: " + value[i].reason); + console.info("Log module: " + value[i].module); + console.info("Log summary: " + value[i].summary); + console.info("Log text: " + value[i].fullLog); + } } + } catch (err) { + console.error(`code: ${err.code}, message: ${err.message}`); } } ``` -## faultLogger.query9+ +## faultLogger.querySelfFaultLog(deprecated) -query(faultType: FaultType, callback: AsyncCallback<Array<FaultLogInfo>>) : void +querySelfFaultLog(faultType: FaultType, callback: AsyncCallback<Array<FaultLogInfo>>) : void + +> **NOTE** +> +> This API is deprecated since API version 9. You are advised to use [faultLogger.query](#faultloggerquery9) instead. Obtains the fault information about the current process. This API uses an asynchronous callback to return the fault information array obtained, which contains a maximum of 10 pieces of fault information. @@ -142,14 +166,6 @@ Obtains the fault information about the current process. This API uses an asynch | faultType | [FaultType](#faulttype) | Yes| Fault type.| | callback | AsyncCallback<Array<[FaultLogInfo](#faultloginfo)>> | Yes| Callback used to return the fault information array.
The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned. -**Error codes** - -For details about the error codes, see [FaultLogger Error Codes](../errorcodes/errorcode-faultlogger.md). - -| ID| Error Message| -| --- | --- | -| 10600001 | The service is not started or is faulty | - **Example** ```js @@ -172,16 +188,16 @@ function queryFaultLogCallback(error, value) { } } } -try { - faultLogger.query(faultLogger.FaultType.JS_CRASH, queryFaultLogCallback); -} catch (err) { - console.error(`code: ${err.code}, message: ${err.message}`); -} +faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH, queryFaultLogCallback); ``` -## faultLogger.query9+ +## faultLogger.querySelfFaultLog(deprecated) -query(faultType: FaultType) : Promise<Array<FaultLogInfo>> +querySelfFaultLog(faultType: FaultType) : Promise<Array<FaultLogInfo>> + +> **NOTE** +> +> This API is deprecated since API version 9. You are advised to use [faultLogger.query](#faultloggerquery9-1) instead. Obtains the fault information about the current process. This API uses a promise to return the fault information array obtained, which contains a maximum of 10 pieces of fault information. @@ -199,37 +215,25 @@ Obtains the fault information about the current process. This API uses a promise | -------- | -------- | | Promise<Array<[FaultLogInfo](#faultloginfo)>> | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**.
The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval.| -**Error codes** - -For details about the error codes, see [FaultLogger Error Codes](../errorcodes/errorcode-faultlogger.md). - -| ID| Error Message| -| --- | --- | -| 10600001 | The service is not started or is faulty | - **Example** ```js async function getLog() { - try { - let value = await faultLogger.query(faultLogger.FaultType.JS_CRASH); - if (value) { - console.info("value length is " + value.length); - let len = value.length; - for (let i = 0; i < len; i++) { - console.info("log: " + i); - console.info("Log pid: " + value[i].pid); - console.info("Log uid: " + value[i].uid); - console.info("Log type: " + value[i].type); - console.info("Log timestamp: " + value[i].timestamp); - console.info("Log reason: " + value[i].reason); - console.info("Log module: " + value[i].module); - console.info("Log summary: " + value[i].summary); - console.info("Log text: " + value[i].fullLog); - } + let value = await faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH); + if (value) { + console.info("value length is " + value.length); + let len = value.length; + for (let i = 0; i < len; i++) { + console.info("log: " + i); + console.info("Log pid: " + value[i].pid); + console.info("Log uid: " + value[i].uid); + console.info("Log type: " + value[i].type); + console.info("Log timestamp: " + value[i].timestamp); + console.info("Log reason: " + value[i].reason); + console.info("Log module: " + value[i].module); + console.info("Log summary: " + value[i].summary); + console.info("Log text: " + value[i].fullLog); } - } catch (err) { - console.error(`code: ${err.code}, message: ${err.message}`); } } ``` diff --git a/en/application-dev/reference/apis/js-apis-file-fileUri.md b/en/application-dev/reference/apis/js-apis-file-fileUri.md new file mode 100644 index 0000000000000000000000000000000000000000..9f524c06525a1a1f6ebdd8b2fd0117a2c43b89d5 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-file-fileUri.md @@ -0,0 +1,61 @@ +# @ohos.file.fileUri (File URI) + +The **fileUri** module allows the uniform resource identifier (URI) of a file to be obtained based on the file path. With the file URI, you can use the APIs provided by [@ohos.file.fs](js-apis-file-fs.md) to operate the file. + +> **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 fileUri from "@ohos.file.fileUri"; +``` + +Before using this module, you need to obtain the path of the file in the application sandbox. The following is an example: + + ```js +import UIAbility from '@ohos.app.ability.UIAbility'; + +export default class EntryAbility extends UIAbility { + onWindowStageCreate(windowStage) { + let context = this.context; + let pathDir = context.filesDir; + } +} + ``` + +## fileUri.getUriFromPath + +getUriFromPath(path: string): string + +Obtains the URI of a file in synchronous mode. + +**System capability**: SystemCapability.FileManagement.AppFileService + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| path | string | Yes | Path of the file in the application sandbox.| + +**Return value** + +| Type | Description | +| ---------------------------- | ---------- | +| string | File URI obtained.| + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +| ID | Error Message | +| ---------------------------- | ---------- | +| 401 | The input parameter is invalid | + + +**Example** + + ```js +let filePath = pathDir + "test.txt"; +let uri = fileUri.getUriFromPath(filePath); + ``` diff --git a/en/application-dev/reference/apis/js-apis-file-fs.md b/en/application-dev/reference/apis/js-apis-file-fs.md index 306d752c6de0ec32a36b5bc024d8b88b016bcb3d..44296a0c8391d0b8005277b3e363571f01892900 100644 --- a/en/application-dev/reference/apis/js-apis-file-fs.md +++ b/en/application-dev/reference/apis/js-apis-file-fs.md @@ -16,7 +16,7 @@ import fs from '@ohos.file.fs'; ## Guidelines -Before using the APIs provided by this module to perform operations on files or directories, obtain the path of the file or directory in the application sandbox as follows: +Before using the APIs provided by this module to perform operations on files or folders, obtain the path of the file or directory in the application sandbox as follows: **Stage Model** @@ -60,14 +60,14 @@ Obtains detailed file information. This API uses a promise to return the result. **Return value** -| Type | Description | -| ---------------------------- | ---------- | -| Promise<[Stat](#stat)> | Promise used to return the file information obtained.| + | Type | Description | + | ---------------------------- | ---------- | + | Promise<[Stat](#stat)> | Promise used to return the file information obtained.| **Example** ```js - let filePath = pathDir + "test.txt"; + let filePath = pathDir + "/test.txt"; fs.stat(filePath).then((stat) => { console.info("get file info succeed, the size of file is " + stat.size); }).catch((err) => { @@ -119,9 +119,9 @@ Obtains detailed file information synchronously. **Return value** -| Type | Description | -| ------------- | ---------- | -| [Stat](#stat) | File information obtained.| + | Type | Description | + | ------------- | ---------- | + | [Stat](#stat) | File information obtained.| **Example** @@ -146,9 +146,9 @@ Checks whether a file exists. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<boolean> | Promise used to return a Boolean value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<boolean> | Promise used to return a Boolean value.| **Example** @@ -233,15 +233,15 @@ Closes a file. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| file | [File](#file)\|number | Yes | File object or FD of the file to close.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | file | [File](#file)\|number | Yes | File object or FD of the file to close.| **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Example** @@ -266,10 +266,10 @@ Closes a file. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ------------ | -| file | [File](#file)\|number | Yes | File object or FD of the file to close.| -| callback | AsyncCallback<void> | Yes | Callback invoked when the file is closed asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ------------ | + | file | [File](#file)\|number | Yes | File object or FD of the file to close.| + | callback | AsyncCallback<void> | Yes | Callback invoked when the file is closed asynchronously.| **Example** @@ -295,9 +295,9 @@ Synchronously closes a file. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| file | [File](#file)\|number | Yes | File object or FD of the file to close.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | file | [File](#file)\|number | Yes | File object or FD of the file to close.| **Example** @@ -317,23 +317,23 @@ Copies a file. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | -------------------------- | ---- | ---------------------------------------- | -| src | string\|number | Yes | Path or FD of the file to copy. | -| dest | string\|number | Yes | Destination path of the file or FD of the file created. | -| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: overwrite the file of the same name.| + | Name | Type | Mandatory | Description | + | ---- | -------------------------- | ---- | ---------------------------------------- | + | src | string\|number | Yes | Path or FD of the file to copy. | + | dest | string\|number | Yes | Destination path of the file or FD of the file created. | + | mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: overwrite the file of the same name.| **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Example** ```js - let srcPath = pathDir + "srcDir/test.txt"; - let dstPath = pathDir + "dstDir/test.txt"; + let srcPath = pathDir + "/srcDir/test.txt"; + let dstPath = pathDir + "/dstDir/test.txt"; fs.copyFile(srcPath, dstPath).then(() => { console.info("copy file succeed"); }).catch((err) => { @@ -351,18 +351,18 @@ Copies a file. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------------------------- | ---- | ---------------------------------------- | -| src | string\|number | Yes | Path or FD of the file to copy. | -| dest | string\|number | Yes | Destination path of the file or FD of the file created. | -| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: overwrite the file with the same name and truncate the part that is not overwritten.| -| callback | AsyncCallback<void> | Yes | Callback invoked when the file is copied asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | -------------------------- | ---- | ---------------------------------------- | + | src | string\|number | Yes | Path or FD of the file to copy. | + | dest | string\|number | Yes | Destination path of the file or FD of the file created. | + | mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: overwrite the file with the same name and truncate the part that is not overwritten.| + | callback | AsyncCallback<void> | Yes | Callback invoked when the file is copied asynchronously. | **Example** ```js - let srcPath = pathDir + "srcDir/test.txt"; - let dstPath = pathDir + "dstDir/test.txt"; + let srcPath = pathDir + "/srcDir/test.txt"; + let dstPath = pathDir + "/dstDir/test.txt"; fs.copyFile(srcPath, dstPath, (err) => { if (err) { console.info("copy file failed with error message: " + err.message + ", error code: " + err.code); @@ -383,17 +383,17 @@ Synchronously copies a file. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | -------------------------- | ---- | ---------------------------------------- | -| src | string\|number | Yes | Path or FD of the file to copy. | -| dest | string\|number | Yes | Destination path of the file or FD of the file created. | -| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: overwrite the file with the same name and truncate the part that is not overwritten.| + | Name | Type | Mandatory | Description | + | ---- | -------------------------- | ---- | ---------------------------------------- | + | src | string\|number | Yes | Path or FD of the file to copy. | + | dest | string\|number | Yes | Destination path of the file or FD of the file created. | + | mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: overwrite the file with the same name and truncate the part that is not overwritten.| **Example** ```js - let srcPath = pathDir + "srcDir/test.txt"; - let dstPath = pathDir + "dstDir/test.txt"; + let srcPath = pathDir + "/srcDir/test.txt"; + let dstPath = pathDir + "/dstDir/test.txt"; fs.copyFileSync(srcPath, dstPath); ``` @@ -414,14 +414,14 @@ Creates a directory. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Example** ```js - let dirPath = pathDir + '/testDir'; + let dirPath = pathDir + "/testDir"; fs.mkdir(dirPath).then(() => { console.info("Directory created"); }).catch((err) => { @@ -448,7 +448,7 @@ Creates a directory. This API uses an asynchronous callback to return the result **Example** ```js - let dirPath = pathDir + '/testDir'; + let dirPath = pathDir + "/testDir"; fs.mkdir(dirPath, (err) => { if (err) { console.info("mkdir failed with error message: " + err.message + ", error code: " + err.code); @@ -476,7 +476,7 @@ Synchronously creates a directory. **Example** ```js - let dirPath = path + '/testDir'; + let dirPath = pathDir + "/testDir"; fs.mkdirSync(dirPath); ``` @@ -498,9 +498,9 @@ Opens a file. This API uses a promise to return the result. File uniform resourc **Return value** -| Type | Description | -| --------------------- | ----------- | -| Promise<[File](#file)> | Promise used to return the file object.| + | Type | Description | + | --------------------- | ----------- | + | Promise<[File](#file)> | Promise used to return the file object.| **Example** @@ -559,9 +559,9 @@ Synchronously opens a file. File URIs are supported. **Return value** -| Type | Description | -| ------ | ----------- | -| [File](#file) | File object opened.| + | Type | Description | + | ------ | ----------- | + | [File](#file) | File object opened.| **Example** @@ -590,9 +590,9 @@ Reads data from a file. This API uses a promise to return the result. **Return value** -| Type | Description | -| ---------------------------------- | ------ | -| Promise<number> | Promise used to return the data read.| + | Type | Description | + | ---------------------------------- | ------ | + | Promise<number> | Promise used to return the data read.| **Example** @@ -602,7 +602,7 @@ Reads data from a file. This API uses a promise to return the result. let buf = new ArrayBuffer(4096); fs.read(file.fd, buf).then((readLen) => { console.info("Read file data successfully"); - console.info(String.fromCharCode.apply(null, new Uint8Array(readLen))); + console.info(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen)))); fs.closeSync(file); }).catch((err) => { console.info("read file data failed with error message: " + err.message + ", error code: " + err.code); @@ -619,12 +619,12 @@ Reads data from a file. This API uses an asynchronous callback to return the res **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | -| options | Object | No | The options are as follows:
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| -| callback | AsyncCallback<number> | Yes | Callback invoked when the data is read asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| + | callback | AsyncCallback<number> | Yes | Callback invoked when the data is read asynchronously. | **Example** @@ -637,7 +637,7 @@ Reads data from a file. This API uses an asynchronous callback to return the res console.info("mkdir failed with error message: " + err.message + ", error code: " + err.code); } else { console.info("Read file data successfully"); - console.info(String.fromCharCode.apply(null, new Uint8Array(readLen))); + console.info(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen)))); fs.closeSync(file); } }); @@ -654,17 +654,17 @@ Synchronously reads data from a file. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | -| options | Object | No | The options are as follows:
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| **Return value** -| Type | Description | -| ------ | -------- | -| number | Length of the data read.| + | Type | Description | + | ------ | -------- | + | number | Length of the data read.| **Example** @@ -693,14 +693,14 @@ Deletes a directory. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Example** ```js - let dirPath = pathDir + '/testDir'; + let dirPath = pathDir + "/testDir"; fs.rmdir(dirPath).then(() => { console.info("Directory deleted"); }).catch((err) => { @@ -727,7 +727,7 @@ Deletes a directory. This API uses an asynchronous callback to return the result **Example** ```js - let dirPath = pathDir + '/testDir'; + let dirPath = pathDir + "/testDir"; fs.rmdir(dirPath, (err) => { if (err) { console.info("rmdir failed with error message: " + err.message + ", error code: " + err.code); @@ -755,7 +755,7 @@ Synchronously deletes a directory. **Example** ```js - let dirPath = pathDir + '/testDir'; + let dirPath = pathDir + "/testDir"; fs.rmdirSync(dirPath); ``` @@ -776,9 +776,9 @@ Deletes a file. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Example** @@ -853,17 +853,17 @@ Writes data into a file. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| **Return value** -| Type | Description | -| --------------------- | -------- | -| Promise<number> | Promise used to return the length of the data written.| + | Type | Description | + | --------------------- | -------- | + | Promise<number> | Promise used to return the length of the data written.| **Example** @@ -889,12 +889,12 @@ Writes data into a file. This API uses an asynchronous callback to return the re **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| -| callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| + | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | **Example** @@ -922,17 +922,17 @@ Synchronously writes data into a file. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| **Return value** -| Type | Description | -| ------ | -------- | -| number | Length of the data written in the file.| + | Type | Description | + | ------ | -------- | + | number | Length of the data written in the file.| **Example** @@ -961,9 +961,9 @@ Truncates a file. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Example** @@ -1050,9 +1050,9 @@ Reads the text content of a file. This API uses a promise to return the result. **Return value** -| Type | Description | -| --------------------- | ---------- | -| Promise<string> | Promise used to return the content read.| + | Type | Description | + | --------------------- | ---------- | + | Promise<string> | Promise used to return the content read.| **Example** @@ -1113,9 +1113,9 @@ Synchronously reads the text of a file. **Return value** -| Type | Description | -| ------ | -------------------- | -| string | Promise used to return the content of the file read.| + | Type | Description | + | ------ | -------------------- | + | string | Promise used to return the content of the file read.| **Example** @@ -1141,9 +1141,9 @@ Obtains information about a symbolic link. This API uses a promise to return the **Return value** -| Type | Description | -| ---------------------------- | ---------- | -| Promise<[Stat](#stat)> | Promise used to return the symbolic link information obtained. For details, see **stat**.| + | Type | Description | + | ---------------------------- | ---------- | + | Promise<[Stat](#stat)> | Promise used to return the symbolic link information obtained. For details, see **stat**.| **Example** @@ -1201,9 +1201,9 @@ Obtains information about a symbolic link synchronously. **Return value** -| Type | Description | -| ------------- | ---------- | -| [Stat](#stat) | File information obtained.| + | Type | Description | + | ------------- | ---------- | + | [Stat](#stat) | File information obtained.| **Example** @@ -1216,7 +1216,7 @@ Obtains information about a symbolic link synchronously. rename(oldPath: string, newPath: string): Promise<void> -Renames a file or directory. This API uses a promise to return the result. +Renames a file or folder. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO @@ -1229,15 +1229,15 @@ Renames a file or directory. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Example** ```js let srcFile = pathDir + "/test.txt"; - let dstFile = pathDir + '/new.txt'; + let dstFile = pathDir + "/new.txt"; fs.rename(srcFile, dstFile).then(() => { console.info("File renamed"); }).catch((err) => { @@ -1249,7 +1249,7 @@ Renames a file or directory. This API uses a promise to return the result. rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): void -Renames a file or directory. This API uses an asynchronous callback to return the result. +Renames a file or folder. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO @@ -1265,7 +1265,7 @@ Renames a file or directory. This API uses an asynchronous callback to return th ```js let srcFile = pathDir + "/test.txt"; - let dstFile = pathDir + '/new.txt'; + let dstFile = pathDir + "/new.txt"; fs.rename(srcFile, dstFile, (err) => { if (err) { console.info("rename failed with error message: " + err.message + ", error code: " + err.code); @@ -1279,7 +1279,7 @@ Renames a file or directory. This API uses an asynchronous callback to return th renameSync(oldPath: string, newPath: string): void -Renames a file or directory synchronously. +Renames a file or folder synchronously. **System capability**: SystemCapability.FileManagement.File.FileIO @@ -1294,7 +1294,7 @@ Renames a file or directory synchronously. ```js let srcFile = pathDir + "/test.txt"; - let dstFile = pathDir + '/new.txt'; + let dstFile = pathDir + "/new.txt"; fs.renameSync(srcFile, dstFile); ``` @@ -1309,15 +1309,15 @@ Flushes data of a file to disk. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| fd | number | Yes | FD of the file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | FD of the file.| **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Example** @@ -1342,10 +1342,10 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | --------------- | -| fd | number | Yes | FD of the file. | -| Callback | AsyncCallback<void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | --------------- | + | fd | number | Yes | FD of the file. | + | Callback | AsyncCallback<void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| **Example** @@ -1373,9 +1373,9 @@ Flushes data of a file to disk synchronously. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| fd | number | Yes | FD of the file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | FD of the file.| **Example** @@ -1397,15 +1397,15 @@ Flushes data of a file to disk. This API uses a promise to return the result. ** **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| fd | number | Yes | FD of the file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | FD of the file.| **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Example** @@ -1431,10 +1431,10 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------- | ---- | ----------------- | -| fd | number | Yes | FD of the file. | -| callback | AsyncCallback<void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------------- | ---- | ----------------- | + | fd | number | Yes | FD of the file. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| **Example** @@ -1461,9 +1461,9 @@ Synchronizes data in a file synchronously. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| fd | number | Yes | FD of the file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | FD of the file.| **Example** @@ -1492,15 +1492,15 @@ Creates a symbolic link based on a file path. This API uses a promise to return **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Example** ```js let srcFile = pathDir + "/test.txt"; - let dstFile = pathDir + '/test'; + let dstFile = pathDir + "/test"; fs.symlink(srcFile, dstFile).then(() => { console.info("Symbolic link created"); }).catch((err) => { @@ -1528,7 +1528,7 @@ Creates a symbolic link based on a file path. This API uses an asynchronous call ```js let srcFile = pathDir + "/test.txt"; - let dstFile = pathDir + '/test'; + let dstFile = pathDir + "/test"; fs.symlink(srcFile, dstFile, (err) => { if (err) { console.info("symlink failed with error message: " + err.message + ", error code: " + err.code); @@ -1557,7 +1557,7 @@ Synchronously creates a symbolic link based on a file path. ```js let srcFile = pathDir + "/test.txt"; - let dstFile = pathDir + '/test'; + let dstFile = pathDir + "/test"; fs.symlinkSync(srcFile, dstFile); ``` @@ -1568,30 +1568,30 @@ listFile(path: string, options?: { filter?: Filter; }): Promise; -Lists all files in a directory. This API uses a promise to return the result.
This API supports recursive listing of all files (including files in subdirectories) and file filtering. +Lists all files in a folder. This API uses a promise to return the result.
This API supports recursive listing of all files (including files in subfolders) and file filtering. **System capability**: SystemCapability.FileManagement.File.FileIO **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| path | string | Yes | Path of the directory in the application sandbox.| -| options | Object | No | File filtering options.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | path | string | Yes | Path of the folder in the application sandbox.| + | options | Object | No | File filtering options.| **options parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.| -| listNum | number | No | Number of file names to list. The default value **0** means to list all files.| -| filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | recursion | boolean | No | Whether to list all files in subfolders recursively. The default value is **false**.| + | listNum | number | No | Number of file names to list. The default value **0** means to list all files.| + | filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| **Return value** -| Type | Description | -| --------------------- | ---------- | -| Promise<string[]> | Promise used to return the files names listed.| + | Type | Description | + | --------------------- | ---------- | + | Promise<string[]> | Promise used to return the files names listed.| **Example** @@ -1608,7 +1608,7 @@ Lists all files in a directory. This API uses a promise to return the result.
{ console.info("listFile succeed"); - for (let i = 0; i < filenames.size; i++) { + for (let i = 0; i < filenames.length; i++) { console.info("fileName: %s", filenames[i]); } }).catch((err) => { @@ -1623,23 +1623,23 @@ listFile(path: string, options?: { filter?: Filter; }, callback: AsyncCallback): void; -Lists all files in a directory. This API uses an asynchronous callback to return the result.
This API supports recursive listing of all files (including files in subdirectories) and file filtering. +Lists all files in a folder. This API uses an asynchronous callback to return the result.
This API supports recursive listing of all files (including files in subfolders) and file filtering. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| path | string | Yes | Path of the directory in the application sandbox.| -| options | Object | No | File filtering options.| -| callback | AsyncCallback<string[]> | Yes | Callback invoked to return the file names listed. | + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | path | string | Yes | Path of the folder in the application sandbox.| + | options | Object | No | File filtering options.| + | callback | AsyncCallback<string[]> | Yes | Callback invoked to return the file names listed. | **options parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.| -| listNum | number | No | Number of file names to list. The default value **0** means to list all files.| -| filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | recursion | boolean | No | Whether to list all files in subfolders recursively. The default value is **false**.| + | listNum | number | No | Number of file names to list. The default value **0** means to list all files.| + | filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| **Example** @@ -1659,7 +1659,7 @@ Lists all files in a directory. This API uses an asynchronous callback to return console.info("list file failed with error message: " + err.message + ", error code: " + err.code); } else { console.info("listFile succeed"); - for (let i = 0; i < filenames.size; i++) { + for (let i = 0; i < filenames.length; i++) { console.info("filename: %s", filenames[i]); } } @@ -1674,28 +1674,28 @@ listFileSync(path: string, options?: { filter?: Filter; }): string[]; -Lists all files in a directory synchronously. This API supports recursive listing of all files (including files in subdirectories) and file filtering. +Lists all files in a folder synchronously. This API supports recursive listing of all files (including files in subfolders) and file filtering. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| path | string | Yes | Path of the directory in the application sandbox.| -| options | Object | No | File filtering options.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | path | string | Yes | Path of the folder in the application sandbox.| + | options | Object | No | File filtering options.| **options parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.| -| listNum | number | No | Number of file names to list. The default value **0** means to list all files.| -| filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | recursion | boolean | No | Whether to list all files in subfolders recursively. The default value is **false**.| + | listNum | number | No | Number of file names to list. The default value **0** means to list all files.| + | filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| **Return value** -| Type | Description | -| --------------------- | ---------- | -| string[] | File names listed.| + | Type | Description | + | --------------------- | ---------- | + | string[] | File names listed.| **Example** @@ -1712,13 +1712,13 @@ Lists all files in a directory synchronously. This API supports recursive listin }; let filenames = fs.listFileSync(pathDir, options); console.info("listFile succeed"); - for (let i = 0; i < filenames.size; i++) { + for (let i = 0; i < filenames.length; i++) { console.info("filename: %s", filenames[i]); } ``` ## fs.moveFile -moveFile(src: string, dest: string, mode?: number): Promise; +moveFile(src: string, dest: string, mode?: number): Promise\; Moves a file. This API uses a promise to return the result. @@ -1726,15 +1726,17 @@ Moves a file. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| src | string | Yes | Path of the file to move in the application sandbox.| -| dest | string | Yes | Destination path of the file in the application sandbox.| -| mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | src | string | Yes | Path of the file to move in the application sandbox.| + | dest | string | Yes | Destination path of the file in the application sandbox.| + | mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| **Example** ```js + let srcPath = pathDir + "/source.txt"; + let destPath = pathDir + "/dest.txt"; fs.moveFile(srcPath, destPath, 0).then(() => { console.info("move file succeed"); }).catch((err) => { @@ -1744,7 +1746,7 @@ Moves a file. This API uses a promise to return the result. ## fs.moveFile -moveFile(src: string, dest: string, mode?: number, callback: AsyncCallback): void; +moveFile(src: string, dest: string, mode?: number, callback: AsyncCallback\): void; Moves a file. This API uses an asynchronous callback to return the result. @@ -1752,16 +1754,18 @@ Moves a file. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| src | string | Yes | Path of the file to move in the application sandbox.| -| dest | string | Yes | Destination path of the file in the application sandbox.| -| mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| -| callback | AsyncCallback<void> | Yes | Callback invoked when the file is moved. | + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | src | string | Yes | Path of the file to move in the application sandbox.| + | dest | string | Yes | Destination path of the file in the application sandbox.| + | mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| + | callback | AsyncCallback<void> | Yes | Callback invoked when the file is moved. | **Example** ```js + let srcPath = pathDir + "/source.txt"; + let destPath = pathDir + "/dest.txt"; fs.moveFile(srcPath, destPath, 0, (err) => { if (err) { console.info("move file failed with error message: " + err.message + ", error code: " + err.code); @@ -1781,15 +1785,17 @@ Moves a file synchronously. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| src | string | Yes | Path of the file to move in the application sandbox.| -| dest | string | Yes | Destination path of the file in the application sandbox.| -| mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | src | string | Yes | Path of the file to move in the application sandbox.| + | dest | string | Yes | Destination path of the file in the application sandbox.| + | mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| **Example** ```js + let srcPath = pathDir + "/source.txt"; + let destPath = pathDir + "/dest.txt"; fs.moveFileSync(srcPath, destPath, 0); console.info("move file succeed"); ``` @@ -1804,15 +1810,15 @@ Creates a temporary directory. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| **Return value** -| Type | Description | -| --------------------- | ---------- | -| Promise<string> | Promise used to return the unique directory generated.| + | Type | Description | + | --------------------- | ---------- | + | Promise<string> | Promise used to return the unique directory generated.| **Example** @@ -1835,10 +1841,10 @@ Creates a temporary directory. This API uses an asynchronous callback to return **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | ---- | --------------------------- | -| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| -| callback | AsyncCallback<string> | Yes | Callback invoked when a temporary directory is created asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | --------------------------- | ---- | --------------------------- | + | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| + | callback | AsyncCallback<string> | Yes | Callback invoked when a temporary directory is created asynchronously. | **Example** @@ -1862,21 +1868,21 @@ Synchronously creates a temporary directory. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| **Return value** -| Type | Description | -| ------ | ---------- | -| string | Unique path generated.| + | Type | Description | + | ------ | ---------- | + | string | Unique path generated.| **Example** ```js let res = fs.mkdtempSync(pathDir + "/XXXXXX"); - ``` + ``` ## fs.createStream @@ -1895,9 +1901,9 @@ Opens a file stream based on the file path. This API uses a promise to return th **Return value** -| Type | Description | -| --------------------------------- | --------- | -| Promise<[Stream](#stream)> | Promise used to return the result.| + | Type | Description | + | --------------------------------- | --------- | + | Promise<[Stream](#stream)> | Promise used to return the result.| **Example** @@ -1957,9 +1963,9 @@ Synchronously opens a stream based on the file path. **Return value** -| Type | Description | -| ------------------ | --------- | -| [Stream](#stream) | Stream opened.| + | Type | Description | + | ------------------ | --------- | + | [Stream](#stream) | Stream opened.| **Example** @@ -1979,16 +1985,16 @@ Opens a file stream based on the file descriptor. This API uses a promise to ret **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| **Return value** -| Type | Description | -| --------------------------------- | --------- | -| Promise<[Stream](#stream)> | Promise used to return the result.| + | Type | Description | + | --------------------------------- | --------- | + | Promise<[Stream](#stream)> | Promise used to return the result.| **Example** @@ -2014,11 +2020,11 @@ Opens a file stream based on the file descriptor. This API uses an asynchronous **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| -| callback | AsyncCallback<[Stream](#stream)> | Yes | Callback invoked when the stream is open asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| + | callback | AsyncCallback<[Stream](#stream)> | Yes | Callback invoked when the stream is open asynchronously. | **Example** @@ -2045,16 +2051,16 @@ Synchronously opens a stream based on the file descriptor. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| **Return value** -| Type | Description | -| ------------------ | --------- | -| [Stream](#stream) | Stream opened.| + | Type | Description | + | ------------------ | --------- | + | [Stream](#stream) | Stream opened.| **Example** @@ -2077,17 +2083,17 @@ Creates a **Watcher** object to observe file or directory changes. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ---------------------------------------- | -| path | string | Yes | Path of the file or directory to observe in the application sandbox. | -| events | number | Yes | Events to observe. Multiple events can be separated|by a bitwise OR operator (|).
- **0x1: IN_ACCESS**: A file is accessed.
- **0x2: IN_MODIFY**: The file content is modified.
- **0x4: IN_ATTRIB**: Metadata is changed.
- **0x8: IN_CLOSE_WRITE**: The file opened for writing is closed.
- **0x10: IN_CLOSE_NOWRITE**: The file or directory not opened for writing is closed.
- **0x20: IN_OPEN**: A file or directory is opened.
- **0x40: IN_MOVED_FROM**: A file in the observed directory is moved.
- **0x80: IN_MOVED_TO**: A file is moved to the observed directory.
- **0x100: IN_CREATE**: A file or directory is created in the observed directory.
- **0x200: IN_DELETE**: A file or directory is deleted form the observed directory.
- **0x400: IN_DELETE_SELF**: The observed directory is deleted. After the directory is deleted, the listening stops.
- **0x800: IN_MOVE_SELF**: The observed file or directory is moved. After the file or directory is moved, the listening continues.
- **0xfff: IN_ALL_EVENTS**: All events.| -| listener | WatchEventListener | Yes | Callback invoked when an observed event occurs. The callback will be invoked each time an observed event occurs. | + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | Yes | Path of the file or directory to observe in the application sandbox. | + | events | number | Yes | Events to observe. Multiple events can be separated by a bitwise OR operator (|).
- **0x1: IN_ACCESS**: A file is accessed.
- **0x2: IN_MODIFY**: The file content is modified.
- **0x4: IN_ATTRIB**: Metadata is changed.
- **0x8: IN_CLOSE_WRITE**: The file opened for writing is closed.
- **0x10: IN_CLOSE_NOWRITE**: The file or directory not opened for writing is closed.
- **0x20: IN_OPEN**: A file or directory is opened.
- **0x40: IN_MOVED_FROM**: A file in the observed directory is moved.
- **0x80: IN_MOVED_TO**: A file is moved to the observed directory.
- **0x100: IN_CREATE**: A file or directory is created in the observed directory.
- **0x200: IN_DELETE**: A file or directory is deleted form the observed directory.
- **0x400: IN_DELETE_SELF**: The observed directory is deleted. After the directory is deleted, the listening stops.
- **0x800: IN_MOVE_SELF**: The observed file or directory is moved. After the file or directory is moved, the listening continues.
- **0xfff: IN_ALL_EVENTS**: All events.| + | listener | WatchEventListener | Yes | Callback invoked when an observed event occurs. The callback will be invoked each time an observed event occurs. | **Return value** -| Type | Description | -| ------------------ | --------- | -| [Watcher](#watcher10) | **Watcher** object created.| + | Type | Description | + | ------------------ | --------- | + | [Watcher](#watcher10) | **Watcher** object created.| **Example** @@ -2119,10 +2125,10 @@ Called when an observed event occurs. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ---------------------------------------- | -| event | WatchEvent | Yes | Event for the callback to invoke. | - + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | event | WatchEvent | Yes | Event for the callback to invoke. | + ## WatchEvent10+ Defines the event to observe. @@ -2146,7 +2152,7 @@ Represents detailed file information. Before calling any API of the **Stat()** c ### Attributes | Name | Type | Readable | Writable | Description | -| ------ | ------ | ---- | ---- | ---------------------------------------- | +| ------ | ------ | ---- | ---- | ---------------------------------------- | | ino | number | Yes | No | File ID. Different files on the same device have different **ino**s.| | | mode | number | Yes | No | File permissions. The meaning of each bit is as follows:
- **0o400**: The owner has the read permission on a regular file or a directory entry.
- **0o200**: The owner has the permission to write a regular file or create and delete a directory entry.
- **0o100**: The owner has the permission to execute a regular file or search for the specified path in a directory.
- **0o040**: The user group has the read permission on a regular file or a directory entry.
- **0o020**: The user group has the permission to write a regular file or create and delete a directory entry.
- **0o010**: The user group has the permission to execute a regular file or search for the specified path in a directory.
- **0o004**: Other users have the permission to read a regular file or read a directory entry.
- **0o002**: Other users have the permission to write a regular file or create and delete a directory entry.
- **0o001**: Other users have the permission to execute a regular file or search for the specified path in a directory.| | uid | number | Yes | No | ID of the file owner.| @@ -2167,9 +2173,9 @@ Checks whether this file is a block special file. A block special file supports **Return value** -| Type | Description | -| ------- | ---------------- | -| boolean | Whether the file is a block special file.| + | Type | Description | + | ------- | ---------------- | + | boolean | Whether the file is a block special file.| **Example** @@ -2188,9 +2194,9 @@ Checks whether this file is a character special file. A character special file s **Return value** -| Type | Description | -| ------- | ----------------- | -| boolean | Whether the file is a character special file.| + | Type | Description | + | ------- | ----------------- | + | boolean | Whether the file is a character special file.| **Example** @@ -2210,9 +2216,9 @@ Checks whether this file is a directory. **Return value** -| Type | Description | -| ------- | ------------- | -| boolean | Whether the file is a directory.| + | Type | Description | + | ------- | ------------- | + | boolean | Whether the file is a directory.| **Example** @@ -2232,9 +2238,9 @@ Checks whether this file is a named pipe (or FIFO). Named pipes are used for int **Return value** -| Type | Description | -| ------- | --------------------- | -| boolean | Whether the file is a FIFO.| + | Type | Description | + | ------- | --------------------- | + | boolean | Whether the file is a FIFO.| **Example** @@ -2254,9 +2260,9 @@ Checks whether this file is a regular file. **Return value** -| Type | Description | -| ------- | --------------- | -| boolean | Whether the file is a regular file.| + | Type | Description | + | ------- | --------------- | + | boolean | Whether the file is a regular file.| **Example** @@ -2276,9 +2282,9 @@ Checks whether this file is a socket. **Return value** -| Type | Description | -| ------- | -------------- | -| boolean | Whether the file is a socket.| + | Type | Description | + | ------- | -------------- | + | boolean | Whether the file is a socket.| **Example** @@ -2298,9 +2304,9 @@ Checks whether this file is a symbolic link. **Return value** -| Type | Description | -| ------- | --------------- | -| boolean | Whether the file is a symbolic link.| + | Type | Description | + | ------- | --------------- | + | boolean | Whether the file is a symbolic link.| **Example** @@ -2324,9 +2330,9 @@ Closes the stream. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ------------- | -| Promise<void> | Promise used to return the stream close result.| + | Type | Description | + | ------------------- | ------------- | + | Promise<void> | Promise used to return the stream close result.| **Example** @@ -2351,9 +2357,9 @@ Closes the stream. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ------------- | -| callback | AsyncCallback<void> | Yes | Callback invoked when the stream is closed asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ------------- | + | callback | AsyncCallback<void> | Yes | Callback invoked when the stream is closed asynchronously.| **Example** @@ -2395,9 +2401,9 @@ Flushes the stream. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ------------- | -| Promise<void> | Promise used to return the stream flushing result.| + | Type | Description | + | ------------------- | ------------- | + | Promise<void> | Promise used to return the stream flushing result.| **Example** @@ -2422,9 +2428,9 @@ Flushes the stream. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | -------------- | -| callback | AsyncCallback<void> | Yes | Callback invoked when the stream is asynchronously flushed.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | -------------- | + | callback | AsyncCallback<void> | Yes | Callback invoked when the stream is asynchronously flushed.| **Example** @@ -2466,16 +2472,16 @@ Writes data into the stream. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ------------------------------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to write. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to write. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| **Return value** -| Type | Description | -| --------------------- | -------- | -| Promise<number> | Promise used to return the length of the data written.| + | Type | Description | + | --------------------- | -------- | + | Promise<number> | Promise used to return the length of the data written.| **Example** @@ -2500,11 +2506,11 @@ Writes data into the stream. This API uses an asynchronous callback to return th **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| -| callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | + | Name | Type | Mandatory| Description | + | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| + | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | **Example** @@ -2532,16 +2538,16 @@ Synchronously writes data into the stream. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ------------------------------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| **Return value** -| Type | Description | -| ------ | -------- | -| number | Length of the data written in the file.| + | Type | Description | + | ------ | -------- | + | number | Length of the data written in the file.| **Example** @@ -2561,16 +2567,16 @@ Reads data from the stream. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. By default, data is read from the current position.| + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. By default, data is read from the current position.| **Return value** -| Type | Description | -| ---------------------------------- | ------ | -| Promise<number> | Promise used to return the data read.| + | Type | Description | + | ---------------------------------- | ------ | + | Promise<number> | Promise used to return the data read.| **Example** @@ -2580,7 +2586,7 @@ Reads data from the stream. This API uses a promise to return the result. let buf = new ArrayBuffer(4096); ss.read(buf, {offset: 5, length: 5}).then((readLen) => { console.info("Read data successfully"); - console.log(String.fromCharCode.apply(null, new Uint8Array(buf))); + console.log(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen)))); }).catch((err) => { console.info("read data failed with error message: " + err.message + ", error code: " + err.code); }); @@ -2597,11 +2603,11 @@ Reads data from the stream. This API uses an asynchronous callback to return the **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.| -| callback | AsyncCallback<number> | Yes | Callback invoked when data is read asynchronously from the stream. | + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.| + | callback | AsyncCallback<number> | Yes | Callback invoked when data is read asynchronously from the stream. | **Example** @@ -2614,7 +2620,7 @@ Reads data from the stream. This API uses an asynchronous callback to return the console.info("read stream failed with error message: " + err.message + ", error code: " + err.code); } else { console.info("Read data successfully"); - console.log(String.fromCharCode.apply(null, new Uint8Array(buf))); + console.log(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen)))); } }); ``` @@ -2629,16 +2635,16 @@ Synchronously reads data from the stream. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | | options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.
| **Return value** -| Type | Description | -| ------ | -------- | -| number | Length of the data read.| + | Type | Description | + | ------ | -------- | + | number | Length of the data read.| **Example** @@ -2662,7 +2668,7 @@ Represents a **File** object opened by **open()**. ### lock -lock(exclusive?: boolean): Promise; +lock(exclusive?: boolean): Promise\; Applies an exclusive lock or a shared lock on this file in blocking mode. This API uses a promise to return the result. @@ -2670,15 +2676,15 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | **Return value** -| Type | Description | -| ---------------------------------- | ------ | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ---------------------------------- | ------ | + | Promise<void> | Promise that returns no value.| **Example** @@ -2693,7 +2699,7 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A ### lock -lock(exclusive?: boolean, callback: AsyncCallback): void; +lock(exclusive?: boolean, callback: AsyncCallback\): void; Applies an exclusive lock or a shared lock on this file in blocking mode. This API uses a promise to return the result. @@ -2701,10 +2707,10 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | -| callback | AsyncCallback<void> | Yes | Callback invoked when the file is locked. | + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the file is locked. | **Example** @@ -2729,9 +2735,9 @@ Applies an exclusive lock or a shared lock on this file in non-blocking mode. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | **Example** @@ -2760,13 +2766,13 @@ Unlocks this file synchronously. ## Watcher10+ -Provides APIs for file or directory listening. Before using the APIs of **Watcher** , call **createWatcher()** to create a **Watcher** object. +Provides APIs for observing the changes of files or folders. Before using the APIs of **Watcher** , call **createWatcher()** to create a **Watcher** object. ### start10+ start(): void -Starts file or directory listening. +Starts listening. **System API**: This is a system API. @@ -2785,7 +2791,7 @@ Starts file or directory listening. stop(): void -Stops file or directory listening. +Stops listening. **System API**: This is a system API. diff --git a/en/application-dev/reference/apis/js-apis-file-picker.md b/en/application-dev/reference/apis/js-apis-file-picker.md index 44e38fa5f4ef0b9b6af861ceb2ceeb1a8d126906..7b1b76c5e5a7d4ef0dd8601e5a525dbe10fd62a9 100644 --- a/en/application-dev/reference/apis/js-apis-file-picker.md +++ b/en/application-dev/reference/apis/js-apis-file-picker.md @@ -1,10 +1,10 @@ -# @ohos.file.picker (Picker) +# @ohos.file.picker (File 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. -**Picker** encapsulates system applications, such as **PhotoViewPicker**, **DocumentViewPicker**, and **AudioViewPicker**, and provides capabilities of selecting and saving images, videos, documents, and audio clips. The application can select the picker as required. +The File Picker encapsulates system applications, such as **PhotoViewPicker**, **DocumentViewPicker**, and **AudioViewPicker**, and provides capabilities of selecting and saving photos, documents, and audio clips. The application can select the picker as required. ## Modules to Import ```js @@ -378,7 +378,7 @@ Saves one or more documents in a **documentPicker** page. This API uses a promis | Type | Description | | ----------------------------- | :---- | -| Promise<Array<string>> | Promise used to return the URIs of the documents saved.| +| Promise<Array<string>> | Promise used to return the URIs of the documents saved.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-fileShare.md b/en/application-dev/reference/apis/js-apis-fileShare.md new file mode 100644 index 0000000000000000000000000000000000000000..b9d9fb65f7c532d3ffd43ffdb195615b4c07b1aa --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-fileShare.md @@ -0,0 +1,126 @@ +# @ohos.fileShare (File Sharing) + +The **fileShare** module provides APIs for granting the access permissions on a user file to another application by the Uniform Resource Identifier (URI). Then, the authorized application can access the file by using the APIs provided by [@ohos.file.fs](js-apis-file-fs.md). + +> **NOTE** +> +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```js +import fileShare from '@ohos.fileShare'; +``` + +## fileShare.grantUriPermission + +grantUriPermission(uri: string, bundleName: string, mode: number, callback: AsyncCallback<void>): void + +Grants permissions on a user file by the URI to an application. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.WRITE_MEDIA + +**System API**: This is a system API. + +**System capability**: SystemCapability.FileManagement.AppFileService + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| uri | string | Yes | URI of a user file.| +| bundleName | string | Yes | Bundle name of the application to be grated with the permissions.| +| mode | number | Yes | Permissions to grant. For details, see [wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags).
**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file.
**wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION**: permission to write the file.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID | Error Message | +| ---------------------------- | ---------- | +| 201 | Permission verification failed | +| 202 | The caller is not a system application | +| 401 | The input parameter is invalid | +| 143000001 | IPC error | + + +**Example** + + ```js +import wantConstant from '@ohos.app.ability.wantConstant'; + + +let uri = 'datashare:///media/image/8'; +let bundleName = 'com.demo.test'; +try { + fileShare.grantUriPermission(uri, bundleName, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION | wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION, (err) => { + if (err) { + console.error("grantUriPermission failed with error: " + err); + return; + } + console.info("grantUriPermission success!"); + }); +} catch (error) { + console.error("grantUriPermission failed with error:" + error); +} + ``` + + +## fileShare.grantUriPermission + +grantUriPermission(uri: string, bundleName: string, mode: number): Promise<void> + +Grants permissions on a user file by the URI to an application. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.WRITE_MEDIA + +**System API**: This is a system API. + +**System capability**: SystemCapability.FileManagement.AppFileService + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| uri | string | Yes | URI of a user file.| +| bundleName | string | Yes | Bundle name of the application to be grated with the permissions.| +| mode | number | Yes | Permissions to grant. For details, see [wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags).
**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file.
**wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION**: permission to write the file.| + +**Return value** + +| Type | Description | +| ---------------------------- | ---------- | +| Promise<void> | Promise that returns no value.| + + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID | Error Message | +| ---------------------------- | ---------- | +| 201 | Permission verification failed | +| 202 | The caller is not a system application | +| 401 | The input parameter is invalid | +| 143000001 | IPC error | + + +**Example** + + ```js +import wantConstant from '@ohos.app.ability.wantConstant'; + +let uri = 'datashare:///media/image/8'; +let bundleName = 'com.demo.test'; +try { + fileShare.grantUriPermission(uri, bundleName, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION | + wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION).then(function () { + console.info("grantUriPermission success!"); + }).catch(function (error) { + console.error("grantUriPermission failed with error:" + error); + }); +} catch (error) { + console.error("grantUriPermission failed with error:" + error); +} + ``` diff --git a/en/application-dev/reference/apis/js-apis-geoLocationManager.md b/en/application-dev/reference/apis/js-apis-geoLocationManager.md index 0d56943e531718578ac4d0238bb2f6770df277d7..263a1a525e0fa1dffcbd9e79703d2d359ac49dcc 100644 --- a/en/application-dev/reference/apis/js-apis-geoLocationManager.md +++ b/en/application-dev/reference/apis/js-apis-geoLocationManager.md @@ -1,6 +1,6 @@ # @ohos.geoLocationManager (Geolocation Manager) -The **geoLocationManager** module provides a wide array of location services, including GNSS positioning, network positioning, geocoding, reverse geocoding, and geofencing. +The **geoLocationManager** module provides location services such as Global Navigation Satellite System (GNSS)-based positioning, network positioning, geofencing, as well as geocoding and reverse geocoding. > **NOTE** > @@ -21,14 +21,14 @@ If your application needs to access the device location information, it must fir API versions earlier than 9: Apply for **ohos.permission.LOCATION**. -API version 9 and later: Apply for **ohos.permission.APPROXIMATELY_LOCATION**, or apply for **ohos.permission.APPROXIMATELY_LOCATION** and **ohos.permission.LOCATION**. Note that **ohos.permission.LOCATION** cannot be applied for separately. +API version 9 and later: Apply for **ohos.permission.APPROXIMATELY\_LOCATION**, or apply for **ohos.permission.APPROXIMATELY\_LOCATION** and **ohos.permission.LOCATION**. Note that **ohos.permission.LOCATION** cannot be applied for separately. | API Version| Location Permission| Permission Application Result| Location Accuracy| | -------- | -------- | -------- | -------- | -| Earlier than 9| ohos.permission.LOCATION | Successful| Location accurate to meters.| -| 9 and later| ohos.permission.LOCATION | Failed| No location obtained.| -| 9 and later| ohos.permission.APPROXIMATELY_LOCATION | Successful| Location accurate to 5 kilometers.| -| 9 and later| ohos.permission.APPROXIMATELY_LOCATION and ohos.permission.LOCATION| Successful| Location accurate to meters.| +| Earlier than 9| ohos.permission.LOCATION | Success| Location accurate to meters| +| 9 and later| ohos.permission.LOCATION | Failure| No location obtained| +| 9 and later| ohos.permission.APPROXIMATELY_LOCATION | Success| Location accurate to 5 kilometers| +| 9 and later| ohos.permission.APPROXIMATELY_LOCATION and ohos.permission.LOCATION| Success| Location accurate to meters| If your application needs to access the device location information when running in the background, it must be configured to be able to run in 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. @@ -99,7 +99,7 @@ Defines a geographic location. | addressUrl | string | Yes| No| Website URL.| | descriptions | Array<string> | Yes| No| Additional descriptions.| | descriptionsSize | number | Yes| No| Total number of additional descriptions. The value must be greater than or equal to **0**. A value smaller than **10** is recommended.| -| isFromMock | Boolean | Yes| No| Whether the geographic address is obtained from the mock reverse geocoding function.
**System API**: This is a system API.| +| isFromMock | Boolean | Yes| No| Whether the geographical name is from the mock reverse geocoding function.
**System API**: This is a system API.| ## LocationRequest @@ -229,12 +229,12 @@ Represents information of the mock reverse geocoding function. | Name| Type| Readable|Writable| Description| | -------- | -------- | -------- | -------- | -------- | | location | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes| Yes| Latitude and longitude information.| -| geoAddress | [GeoAddress](#geoaddress) | Yes| Yes|Geographic address.| +| geoAddress | [GeoAddress](#geoaddress) | Yes| Yes|Geographical name.| ## LocationMockConfig -Represents the mock location configuration. +Represents the information of the mock location function. **System capability**: SystemCapability.Location.Location.Core @@ -267,25 +267,25 @@ Sets the priority of the location request. | Name| Value| Description| | -------- | -------- | -------- | | UNSET | 0x200 | Priority unspecified.
If this option is used, [LocationRequestPriority](#locationrequestpriority) is invalid.| -| ACCURACY | 0x201 | Location accuracy preferred.
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.| -| LOW_POWER | 0x202 | Power efficiency preferred.
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.| +| ACCURACY | 0x201 | Location 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.| +| LOW_POWER | 0x202 | Power efficiency.
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.| | FIRST_FIX | 0x203 | Fast location preferred. Use this option if you want to obtain a location as fast as possible.
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. It can lead to significant hardware resource consumption and power consumption.| ## LocationRequestScenario -Sets the scenario of the location request. + Sets the scenario of the location request. **System capability**: SystemCapability.Location.Location.Core | Name| Value| Description| | -------- | -------- | -------- | | UNSET | 0x300 | Scenario unspecified.
If this option is used, [LocationRequestScenario](#locationrequestscenario) is invalid.| -| NAVIGATION | 0x301 | Navigation scenario.
This option is 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, GNSS positioning is used to provide location services to ensure the optimal location accuracy of the system.
The location result is reported at a minimum interval of 1 second by default.| -| TRAJECTORY_TRACKING | 0x302 | Trajectory tracking scenario.
This option is 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.
The location result is reported at a minimum interval of 1 second by default.| -| CAR_HAILING | 0x303 | Ride hailing scenario.
This option is applicable when your application needs to obtain the current location of a user who is hailing a taxi.
The location result is reported at a minimum interval of 1 second by default.| -| DAILY_LIFE_SERVICE | 0x304 | Daily life service scenario.
This option is 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.
The location result is reported at a minimum interval of 1 second by default.| -| NO_POWER | 0x305 | Power efficiency scenario.
This option is applicable when your application does not proactively start the location service. 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.| +| NAVIGATION | 0x301 | Navigation.
This option is 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, GNSS positioning is used to provide location services to ensure the optimal location accuracy of the system.
The location result is reported at a minimum interval of 1 second by default.| +| TRAJECTORY_TRACKING | 0x302 | Trajectory tracking.
This option is 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.
The location result is reported at a minimum interval of 1 second by default.| +| CAR_HAILING | 0x303 | Ride hailing.
This option is applicable when your application needs to obtain the current location of a user who is hailing a taxi.
The location result is reported at a minimum interval of 1 second by default.| +| DAILY_LIFE_SERVICE | 0x304 | Daily life services.
This option is 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.
The location result is reported at a minimum interval of 1 second by default.| +| NO_POWER | 0x305 | Power efficiency. Your application does not proactively start the location service. 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.| ## LocationPrivacyType @@ -299,7 +299,7 @@ Defines the privacy statement type. | Name| Value| Description| | -------- | -------- | -------- | | OTHERS | 0 | Other scenarios. Reserved field.| -| STARTUP | 1 | Privacy statement displayed in the startup wizard. | +| STARTUP | 1 | Privacy statement displayed in the startup wizard. The user needs to choose whether to agree with the statement.| | CORE_LOCATION | 2 | Privacy statement displayed when enabling the location service.| @@ -323,7 +323,7 @@ on(type: 'locationChange', request: LocationRequest, callback: Callback<Locat Registers a listener for location changes with a location request initiated. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Core @@ -368,7 +368,7 @@ off(type: 'locationChange', callback?: Callback<Location>): void Unregisters the listener for location changes with the corresponding location request deleted. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Core @@ -489,7 +489,7 @@ on(type: 'cachedGnssLocationsChange', request: CachedGnssLocationsRequest, callb Registers a listener for cached GNSS location reports. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Gnss @@ -533,7 +533,7 @@ off(type: 'cachedGnssLocationsChange', callback?: Callback<Array<Location& Unregisters the listener for cached GNSS location reports. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Gnss @@ -577,7 +577,7 @@ on(type: 'satelliteStatusChange', callback: Callback<SatelliteStatusInfo>) Registers a listener for GNSS satellite status change events. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Gnss @@ -619,7 +619,7 @@ off(type: 'satelliteStatusChange', callback?: Callback<SatelliteStatusInfo> Unregisters the listener for GNSS satellite status change events. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Gnss @@ -662,7 +662,7 @@ on(type: 'nmeaMessage', callback: Callback<string>): void; Registers a listener for GNSS NMEA message change events. -**Permission required**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION +**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Gnss @@ -705,7 +705,7 @@ off(type: 'nmeaMessage', callback?: Callback<string>): void; Unregisters the listener for GNSS NMEA message change events. -**Permission required**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION +**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Gnss @@ -749,7 +749,7 @@ on(type: 'gnssFenceStatusChange', request: GeofenceRequest, want: WantAgent): vo Registers a listener for status change events of the specified geofence. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Geofence @@ -807,7 +807,7 @@ off(type: 'gnssFenceStatusChange', request: GeofenceRequest, want: WantAgent): v Unregisters the listener for status change events of the specified geofence. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Geofence @@ -840,7 +840,7 @@ For details about the following error codes, see [Location Error Codes](../error { bundleName: "com.example.myapplication", abilityName: "EntryAbility", - action: "action1" + action: "action1", } ], operationType: wantAgent.OperationType.START_ABILITY, @@ -882,7 +882,6 @@ For details about the following error codes, see [Location Error Codes](../error | ID| Error Message| | -------- | ---------------------------------------- | |3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | |3301500 | Failed to query the area information. | @@ -924,7 +923,6 @@ For details about the following error codes, see [Location Error Codes](../error | ID| Error Message| | -------- | ---------------------------------------- | |3301000 | Location service is unavailable. | -|3301100 | The location switch is off. | |3301500 | Failed to query the area information. | **Example** @@ -951,7 +949,7 @@ getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<L Obtains the current location. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Core @@ -999,7 +997,7 @@ getCurrentLocation(callback: AsyncCallback<Location>): void; Obtains the current location. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Core @@ -1045,7 +1043,7 @@ getCurrentLocation(request?: CurrentLocationRequest): Promise<Location> Obtains the current location. This API uses a promise to return the result. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Core @@ -1095,7 +1093,7 @@ getLastLocation(): Location Obtains the last location. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Core @@ -1282,7 +1280,7 @@ For details about the following error codes, see [Location Error Codes](../error getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void -Converts coordinates into geographic descriptions through reverse geocoding. This API uses an asynchronous callback to return the result. +Converts coordinates into geographic description through reverse geocoding. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Location.Location.Geocoder @@ -1326,7 +1324,7 @@ For details about the following error codes, see [Location Error Codes](../error getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array<GeoAddress>>; -Converts coordinates into geographic descriptions through reverse geocoding. This API uses a promise to return the result. +Converts coordinates into geographic description through reverse geocoding. This API uses a promise to return the result. **System capability**: SystemCapability.Location.Location.Geocoder @@ -1373,7 +1371,7 @@ For details about the following error codes, see [Location Error Codes](../error getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void -Converts geographic descriptions into coordinates through geocoding. This API uses an asynchronous callback to return the result. +Converts geographic description into coordinates through geocoding. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Location.Location.Geocoder @@ -1417,7 +1415,7 @@ For details about the following error codes, see [Location Error Codes](../error getAddressesFromLocationName(request: GeoCodeRequest): Promise<Array<GeoAddress>> -Converts geographic descriptions into coordinates through geocoding. This API uses a promise to return the result. +Converts geographic description into coordinates through geocoding. This API uses a promise to return the result. **System capability**: SystemCapability.Location.Location.Geocoder @@ -1499,7 +1497,7 @@ getCachedGnssLocationsSize(callback: AsyncCallback<number>): void; Obtains the number of cached GNSS locations. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Gnss @@ -1543,7 +1541,7 @@ getCachedGnssLocationsSize(): Promise<number>; Obtains the number of cached GNSS locations. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Gnss @@ -1585,7 +1583,7 @@ flushCachedGnssLocations(callback: AsyncCallback<void>): void; Obtains all cached GNSS locations and clears the GNSS cache queue. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Gnss @@ -1627,7 +1625,7 @@ flushCachedGnssLocations(): Promise<void>; Obtains all cached GNSS locations and clears the GNSS cache queue. -**Required permissions**: ohos.permission.APPROXIMATELY_LOCATION +**Permission required**: ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Location.Location.Gnss @@ -2007,7 +2005,7 @@ For details about the following error codes, see [Location Error Codes](../error setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>): void; -Sets information of the mock reverse geocoding function, including the mapping between a location and geographic name. If the location is contained in the configurations during reverse geocoding query, the corresponding geographic name will be returned. +Sets information of the mock reverse geocoding function, including the mapping between a location and geographical name. If the location is contained in the configurations during reverse geocoding query, the corresponding geographical name will be returned. This API can be invoked only after [geoLocationManager.enableReverseGeocodingMock](#geolocationmanagerenablereversegeocodingmock) is called. @@ -2019,7 +2017,7 @@ This API can be invoked only after [geoLocationManager.enableReverseGeocodingMoc | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | mockInfos | Array<[ReverseGeocodingMockInfo](#reversegeocodingmockinfo)> | Yes| Array of information of the mock reverse geocoding function, including a location and a geographic address.| + | mockInfos | Array<[ReverseGeocodingMockInfo](#reversegeocodingmockinfo)> | Yes| Array of information of the mock reverse geocoding function, including a location and a geographical name.| **Error codes** @@ -2069,7 +2067,7 @@ Checks whether a user agrees with the privacy statement of the location service. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | boolean | boolean | NA | Whether the user agrees with the privacy statement.| + | boolean | boolean | NA | Callback used to return the result, which indicates whether the user agrees with the privacy statement.| **Error codes** @@ -2108,7 +2106,7 @@ Sets the user confirmation status for the privacy statement of the location serv | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | [LocationPrivacyType](#locationprivacytype) | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when the location service is enabled.| - | isConfirmed | boolean | Yes| Whether the user agrees with the privacy statement.| + | isConfirmed | boolean | Yes| Callback used to return the result, which indicates whether the user agrees with the privacy statement.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-hiappevent.md b/en/application-dev/reference/apis/js-apis-hiappevent.md index 260c8c541809f723cee63a3cf7f7ce9374ff886d..e2ff3f6fa98d46577475cdaa86222b0eb3522b1f 100644 --- a/en/application-dev/reference/apis/js-apis-hiappevent.md +++ b/en/application-dev/reference/apis/js-apis-hiappevent.md @@ -1,8 +1,9 @@ # @ohos.hiAppEvent (Application Event Logging) -The HiAppEvent module provides the application event logging functions, such as writing application events to the event file and managing the event logging configuration. +The **hiAppEvent** module provides the application event logging functions, such as writing application events to the event file and managing the event logging configuration. > **NOTE** +> > - The APIs provided by this module are deprecated since API version 9. You are advised to use [`@ohos.hiviewdfx.hiAppEvent`](js-apis-hiviewdfx-hiappevent.md) instead. > - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -19,7 +20,7 @@ Before using application event logging, you need to understand the requirements **Event Name** -An event name is a string that contains a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_). +An event name is a string that contains a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (\_). **Event Type** @@ -30,9 +31,10 @@ An event type is an enumerated value of [EventType](#eventtype). An event parameter is an object in key-value pair format, where the key is the parameter name and the value is the parameter value. The requirements are as follows: - A parameter name is a string that contains a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (\_). -- The parameter value is a string, number, boolean, or array. -- When the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be truncated. -- When the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded. +- The parameter value can be of the string, number, boolean, or array type. +- If the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be discarded. +- If the parameter value is a number, the value must be within the range of **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. Otherwise, uncertain values may be generated. +- If the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded. - The maximum number of parameters is 32. If this limit is exceeded, excess parameters will be discarded. **Event Callback** diff --git a/en/application-dev/reference/apis/js-apis-hiviewdfx-hiappevent.md b/en/application-dev/reference/apis/js-apis-hiviewdfx-hiappevent.md index 2960e201db397e160dfc5cca7e1c729beebcb6a4..03cad26cfecb5295b611d48fbc9f69862895ddb0 100644 --- a/en/application-dev/reference/apis/js-apis-hiviewdfx-hiappevent.md +++ b/en/application-dev/reference/apis/js-apis-hiviewdfx-hiappevent.md @@ -1,6 +1,6 @@ # @ohos.hiviewdfx.hiAppEvent (Application Event Logging) -This module provides application event-related functions, including flushing application events to a disk, querying and clearing application events, and customizing application event logging configuration. +The **hiAppEvent** module provides application event-related functions, including flushing application events to a disk, querying and clearing application events, and customizing application event logging configuration. > **NOTE** > @@ -120,12 +120,12 @@ Defines parameters for an **AppEventInfo** object. **System capability**: SystemCapability.HiviewDFX.HiAppEvent -| Name | Type | Mandatory| Description | -| --------- | ----------------------- | ---- | ---------- | -| domain | string | Yes | Event domain.| -| name | string | Yes | Event name.| -| eventType | [EventType](#eventtype) | Yes | Event type.| -| params | object | Yes | Event parameters.| +| Name | Type | Mandatory| Description | +| --------- | ----------------------- | ---- | ------------------------------------------------------------ | +| domain | string | Yes | Event domain. Event domain name, which is a string of up to 32 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).| +| name | string | Yes | Event name. Event name, which is a string of up to 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).| +| eventType | [EventType](#eventtype) | Yes | Event type. | +| params | object | Yes | Event parameter object, which consists of a parameter name and a parameter value. The specifications are as follows:
- The parameter name is a string of up to 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).
- The parameter value can be a string, number, boolean, or array. If the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be discarded. If the parameter value is a number, the value must be within the range of **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. Otherwise, uncertain values may be generated. If the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded.
- The maximum number of parameters is 32. If this limit is exceeded, excess parameters will be discarded.| ## hiAppEvent.configure diff --git a/en/application-dev/reference/apis/js-apis-http.md b/en/application-dev/reference/apis/js-apis-http.md index f88c44972c8576f5d1800611ec058a86ed5be489..820cba210b6b8b43578733c1a2eb060177aa5995 100644 --- a/en/application-dev/reference/apis/js-apis-http.md +++ b/en/application-dev/reference/apis/js-apis-http.md @@ -1,6 +1,6 @@ # @ohos.net.http (Data Request) -The **http** 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**. +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** > @@ -13,10 +13,10 @@ The **http** module provides the HTTP data request capability. An application ca import http from '@ohos.net.http'; ``` -## Examples +## Example ```js -// Import the HTTP namespace. +// Import the http namespace. import http from '@ohos.net.http'; // Each httpRequest corresponds to an HTTP request task and cannot be reused. @@ -27,7 +27,7 @@ httpRequest.on('headersReceive', (header) => { console.info('header: ' + JSON.stringify(header)); }); httpRequest.request( - // Customize EXAMPLE_URL in extraData on your own. It is up to you whether to add parameters to the URL. + // 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. @@ -67,7 +67,7 @@ httpRequest.request( ## http.createHttp -createHttp\(\): HttpRequest +createHttp(): HttpRequest Creates an HTTP request. You can use this API to initiate or destroy an HTTP request, or enable or disable listening for HTTP Response Header events. An HttpRequest object corresponds to an HTTP request. To initiate multiple HTTP requests, you must create an **HttpRequest** object for each HTTP request. @@ -77,7 +77,7 @@ Creates an HTTP request. You can use this API to initiate or destroy an HTTP req | Type | Description | | :---------- | :----------------------------------------------------------- | -| HttpRequest | An **HttpRequest** object, which contains the **request**, **destroy**, **on**, or **off** method.| +| HttpRequest | An **HttpRequest** object, which contains the **request**, **request2**, **destroy**, **on**, or **off** method.| **Example** @@ -88,14 +88,17 @@ let httpRequest = http.createHttp(); ## HttpRequest -Defines an HTTP request task. Before invoking APIs provided by **HttpRequest**, you must call [createHttp\(\)](#httpcreatehttp) to create an **HttpRequestTask** object. +Defines an HTTP request task. Before invoking APIs provided by **HttpRequest**, you must call [createHttp()](#httpcreatehttp) to create an **HttpRequestTask** object. ### request -request\(url: string, callback: AsyncCallback\\):void +request(url: string, callback: AsyncCallback\):void Initiates an HTTP request to a given URL. This API uses an asynchronous callback to return the result. +>**NOTE** +>This API supports only transfer of data not greater than 5 MB. + **Required permissions**: ohos.permission.INTERNET **System capability**: SystemCapability.Communication.NetStack @@ -109,7 +112,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback **Error codes** -| ID | Error Message | +| Code | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -140,10 +143,13 @@ httpRequest.request("EXAMPLE_URL", (err, data) => { ### request -request\(url: string, options: HttpRequestOptions, callback: AsyncCallback\\):void +request(url: string, options: HttpRequestOptions, callback: AsyncCallback\):void Initiates an HTTP request containing specified options to a given URL. This API uses an asynchronous callback to return the result. +>**NOTE** +>This API supports only transfer of data not greater than 5 MB. + **Required permissions**: ohos.permission.INTERNET **System capability**: SystemCapability.Communication.NetStack @@ -158,7 +164,7 @@ Initiates an HTTP request containing specified options to a given URL. This API **Error codes** -| ID | Error Message | +| Code | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -223,9 +229,12 @@ httpRequest.request("EXAMPLE_URL", ### request -request\(url: string, options? : HttpRequestOptions\): Promise\ +request(url: string, options? : HttpRequestOptions): Promise\ -Initiates an HTTP request containing specified options to a given URL. This API uses a promise to return the result. +Initiates an HTTP request to a given URL. This API uses a promise to return the result. + +>**NOTE** +>This API supports only transfer of data not greater than 5 MB. **Required permissions**: ohos.permission.INTERNET @@ -246,7 +255,7 @@ Initiates an HTTP request containing specified options to a given URL. This API **Error codes** -| ID | Error Message | +| Code | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -309,7 +318,7 @@ promise.then((data) => { ### destroy -destroy\(\): void +destroy(): void Destroys an HTTP request. @@ -323,7 +332,7 @@ httpRequest.destroy(); ### request210+ -request2(url: string, callback: AsyncCallback): void +request2(url: string, callback: AsyncCallback\): void Initiates an HTTP request to a given URL. This API uses an asynchronous callback to return the result, which is a streaming response. @@ -340,7 +349,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback **Error codes** -| ID | Error Message | +| Code | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -359,7 +368,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback ```js httpRequest.request2("EXAMPLE_URL", (err) => { if (!err) { - console.info(request2 OK!); + console.info("request2 OK!"); } else { console.info("request2 ERROR : err = " + JSON.stringify(err)); } @@ -368,9 +377,9 @@ httpRequest.request2("EXAMPLE_URL", (err) => { ### request210+ -request2(url: string, options: HttpRequestOptions, callback: AsyncCallback): void +request2(url: string, options: HttpRequestOptions, callback: AsyncCallback\): void -Initiates an HTTP request containing specified options to a given URL. This API uses an asynchronous callback to return the result, which is a streaming response. +Initiates an HTTP request to a given URL. This API uses an asynchronous callback to return the result, which is a streaming response. **Required permissions**: ohos.permission.INTERNET @@ -386,7 +395,7 @@ Initiates an HTTP request containing specified options to a given URL. This API **Error codes** -| ID | Error Message | +| Code | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -437,7 +446,7 @@ httpRequest.request2("EXAMPLE_URL", connectTimeout: 60000 }, (err) => { if (!err) { - console.info(request2 OK!); + console.info("request2 OK!"); } else { console.info("request2 ERROR : err = " + JSON.stringify(err)); } @@ -445,7 +454,7 @@ httpRequest.request2("EXAMPLE_URL", ``` ### request210+ -request2\(url: string, options? : HttpRequestOptions\): Promise\ +request2(url: string, options? : HttpRequestOptions): Promise\ Initiates an HTTP request containing specified options to a given URL. This API uses a promise to return the result, which is a streaming response. @@ -468,7 +477,7 @@ Initiates an HTTP request containing specified options to a given URL. This API **Error codes** -| ID | Error Message | +| Code | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -504,7 +513,7 @@ Initiates an HTTP request containing specified options to a given URL. This API >**NOTE** > For details about the error codes, see [HTTP Error Codes](../errorcodes/errorcode-net-http.md). -> The HTTP error code mapping is in the format of 2300000 + Curl error code. For more common error codes, see: +> The HTTP error code mapping is in the format of 2300000 + Curl error code. For more common error codes, see [Curl Error Codes](https://curl.se/libcurl/c/libcurl-errors.html). **Example** @@ -518,20 +527,20 @@ let promise = httpRequest.request("EXAMPLE_URL", { } }); promise.then(() => { - console.info(request2 OK!); + console.info("request2 OK!"); }).catch((err) => { console.info("request2 ERROR : err = " + JSON.stringify(err)); }); ``` -### on\('headerReceive'\) +### on('headerReceive') -on\(type: 'headerReceive', callback: AsyncCallback\): void +on(type: 'headerReceive', callback: AsyncCallback\): void Registers an observer for HTTP Response Header events. >**NOTE** ->This API has been deprecated. You are advised to use [on\('headersReceive'\)8+](#onheadersreceive8) instead. +>This API has been deprecated. You are advised to use [on('headersReceive')8+](#onheadersreceive8) instead. **System capability**: SystemCapability.Communication.NetStack @@ -545,24 +554,20 @@ Registers an observer for HTTP Response Header events. **Example** ```js -httpRequest.on('headerReceive', (err, data) => { - if (!err) { - console.info('header: ' + JSON.stringify(data)); - } else { - console.info('error:' + JSON.stringify(err)); - } +httpRequest.on('headerReceive', (data) => { + console.info('error:' + JSON.stringify(data)); }); ``` -### off\('headerReceive'\) +### off('headerReceive') -off\(type: 'headerReceive', callback?: AsyncCallback\): void +off(type: 'headerReceive', callback?: AsyncCallback\): void Unregisters the observer for HTTP Response Header events. >**NOTE** > ->1. This API has been deprecated. You are advised to use [off\('headersReceive'\)8+](#offheadersreceive8) instead. +>1. This API has been deprecated. You are advised to use [off('headersReceive')8+](#offheadersreceive8) instead. > >2. 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. @@ -581,9 +586,9 @@ Unregisters the observer for HTTP Response Header events. httpRequest.off('headerReceive'); ``` -### on\('headersReceive'\)8+ +### on('headersReceive')8+ -on\(type: 'headersReceive', callback: Callback\): void +on(type: 'headersReceive', callback: Callback\): void Registers an observer for HTTP Response Header events. @@ -604,9 +609,9 @@ httpRequest.on('headersReceive', (header) => { }); ``` -### off\('headersReceive'\)8+ +### off('headersReceive')8+ -off\(type: 'headersReceive', callback?: Callback\): void +off(type: 'headersReceive', callback?: Callback\): void Unregisters the observer for HTTP Response Header events. @@ -628,9 +633,9 @@ Unregisters the observer for HTTP Response Header events. httpRequest.off('headersReceive'); ``` -### once\('headersReceive'\)8+ +### once('headersReceive')8+ -once\(type: 'headersReceive', callback: Callback\): void +once(type: 'headersReceive', callback: Callback\): void Registers a one-time observer for HTTP Response Header events. Once triggered, the observer will be removed. This API uses an asynchronous callback to return the result. @@ -650,9 +655,9 @@ httpRequest.once('headersReceive', (header) => { console.info('header: ' + JSON.stringify(header)); }); ``` -### on\('dataReceive'\)10+ +### on('dataReceive')10+ -on\(type: 'dataReceive', callback: Callback\\): void +on(type: 'dataReceive', callback: Callback\): void Registers an observer for events indicating receiving of HTTP streaming responses. @@ -673,9 +678,9 @@ httpRequest.on('dataReceive', (data) => { }); ``` -### off\('dataReceive'\)10+ +### off('dataReceive')10+ -off\(type: 'dataReceive', callback?: Callback\\): void +off(type: 'dataReceive', callback?: Callback\): void Unregisters the observer for events indicating receiving of HTTP streaming responses. @@ -697,9 +702,9 @@ Unregisters the observer for events indicating receiving of HTTP streaming respo httpRequest.off('dataReceive'); ``` -### on\('dataEnd'\)10+ +### on('dataEnd')10+ -on\(type: 'dataEnd', callback: Callback\\): void +on(type: 'dataEnd', callback: Callback\): void Registers an observer for events indicating completion of receiving HTTP streaming responses. @@ -720,7 +725,7 @@ httpRequest.on('dataReceive', () => { }); ``` -### off\('dataEnd'\)10+ +### off('dataEnd')10+ off(type: 'dataEnd', callback?: Callback\): void @@ -744,9 +749,9 @@ Unregisters the observer for events indicating completion of receiving HTTP stre httpRequest.off('dataEnd'); ``` -### on\('dataProgress'\)10+ +### on('dataProgress')10+ - on\(type: 'dataProgress', callback: Callback\<{ receiveSize: number, totalSize: number }\>\): void + on(type: 'dataProgress', callback: Callback\<{ receiveSize: number, totalSize: number }\>): void Registers an observer for events indicating progress of receiving HTTP streaming responses. @@ -757,19 +762,17 @@ Registers an observer for events indicating progress of receiving HTTP streaming | Name | Type | Mandatory| Description | | -------- | ----------------------- | ---- | --------------------------------- | | type | string | Yes | Event type. The value is **dataProgress**.| -| callback | AsyncCallback\<{ receiveSize: number, totalSize: number }\> | Yes | Callback used to return the result. | +| callback | AsyncCallback\<{ receiveSize: number, totalSize: number }\> | Yes | Callback used to return the result.
**receiveSize**: number of received bytes.
**totalSize**: total number of bytes to be received.| **Example** ```js httpRequest.on('dataProgress', (data) => { - if (!err) { - console.info('dataProgress:' + JSON.stringify(data)); - } + console.info('dataProgress:' + JSON.stringify(data)); }); ``` -### off\('dataProgress'\)10+ +### off('dataProgress')10+ off(type: 'dataProgress', callback?: Callback\<{ receiveSize: number, totalSize: number }\>): void @@ -836,7 +839,7 @@ 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 | The request is successful. 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. | | NOT_AUTHORITATIVE | 203 | "Non-Authoritative Information." The request is successful. | @@ -915,11 +918,11 @@ let httpResponseCache = http.createHttpResponseCache(); ## HttpResponseCache9+ -Defines an object that stores the response to an HTTP request. +Defines an object that stores the response to an HTTP request. Before invoking APIs provided by **HttpResponseCache**, you must call [createHttpResponseCache()](#httpcreatehttpresponsecache9) to create an **HttpRequestTask** object. ### flush9+ -flush(callback: AsyncCallback\): void +flush(callback: AsyncCallback\): void Flushes data in the cache to the file system so that the cached data can be accessed in the next HTTP request. This API uses an asynchronous callback to return the result. @@ -929,7 +932,7 @@ Flushes data in the cache to the file system so that the cached data can be acce | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +| callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -945,7 +948,7 @@ httpResponseCache.flush(err => { ### flush9+ -flush(): Promise\ +flush(): Promise\ Flushes data in the cache to the file system so that the cached data can be accessed in the next HTTP request. This API uses a promise to return the result. @@ -955,7 +958,7 @@ Flushes data in the cache to the file system so that the cached data can be acce | Type | Description | | --------------------------------- | ------------------------------------- | -| Promise\> | Promise used to return the result.| +| Promise\ | Promise used to return the result.| **Example** @@ -969,7 +972,7 @@ httpResponseCache.flush().then(() => { ### delete9+ -delete(callback: AsyncCallback\): void +delete(callback: AsyncCallback\): void Disables the cache and deletes the data in it. This API uses an asynchronous callback to return the result. @@ -979,7 +982,7 @@ Disables the cache and deletes the data in it. This API uses an asynchronous cal | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +| callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -994,7 +997,7 @@ httpResponseCache.delete(err => { ``` ### delete9+ -delete(): Promise\ +delete(): Promise\ Disables the cache and deletes the data in it. This API uses a promise to return the result. @@ -1004,7 +1007,7 @@ Disables the cache and deletes the data in it. This API uses a promise to return | Type | Description | | --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| +| Promise\ | Promise used to return the result.| **Example** @@ -1023,7 +1026,7 @@ Enumerates HTTP data types. **System capability**: SystemCapability.Communication.NetStack | Name| Value| Description | -| ------------------ | -- | ----------- | +| ------------------ | -- | ----------- | | STRING | 0 | String type.| | OBJECT | 1 | Object type. | | ARRAY_BUFFER | 2 | Binary array type.| diff --git a/en/application-dev/reference/apis/js-apis-inner-ability-want.md b/en/application-dev/reference/apis/js-apis-inner-ability-want.md index c71633638b2339f0457234c4d49a28330969a483..33de553183850772206e48cbd1e732d3a3b8cc4f 100644 --- a/en/application-dev/reference/apis/js-apis-inner-ability-want.md +++ b/en/application-dev/reference/apis/js-apis-inner-ability-want.md @@ -15,10 +15,10 @@ Want is a carrier for information transfer between objects (application componen | abilityName | string | No | Name of the ability. If both **bundleName** 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 | string | No | URI. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| | type | string | No | MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. | -| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantConstant.Flags).| -| action | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details, see [action](js-apis-app-ability-wantConstant.md#wantConstant.Action). For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](application-models/explicit-implicit-want-mappings.md). | -| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:
**ohos.aafwk.callerPid**: PID of the caller.
**ohos.aafwk.param.callerToken**: token of the caller.
**ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.
- **component.startup.newRules**: whether to enable the new control rule.
- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.
- **ohos.dlp.params.sandbox**: available only for DLP files. | -| entities | Array\ | No | Additional category information (such as browser and video player) of the target ability. It is a supplement to **action** in implicit Want and is used to filter ability types. For details, see [entity](js-apis-app-ability-wantConstant.md#wantConstant.Entity). | +| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantconstantflags). | +| action | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details, see [action](js-apis-app-ability-wantConstant.md#wantconstantaction). For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](application-models/explicit-implicit-want-mappings.md). | +| parameters | {[key: string]: Object} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:
- **ohos.aafwk.callerPid**: PID of the caller.
**ohos.aafwk.param.callerToken**: token of the caller.
- **ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.
- **component.startup.newRules**: whether to enable the new control rule.
- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.
- **ohos.dlp.params.sandbox**: available only for DLP files. | +| entities | Array\ | No | Additional category information (such as browser and video player) of the target ability. It is a supplement to **action** in implicit Want and is used to filter ability types. For details, see [entity](js-apis-app-ability-wantConstant.md#wantconstantentity). | | moduleName9+ | string | No | Module to which the ability belongs.| **Example** @@ -68,4 +68,5 @@ Want is a carrier for information transfer between objects (application componen - For more details and examples, see [Want](../../application-models/want-overview.md). - + + diff --git a/en/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md b/en/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md index 92450992f6d642dc1583f3147827a94622bcc96a..445443209e3ca4a670cfced56f285530144505c4 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md @@ -1,6 +1,6 @@ # AccessibilityExtensionContext (Accessibility Extension Context) -The **AccessibilityExtensionContext** module, inherited from **ExtensionContext**, provides context for **Accessibility Extension** abilities. +The **AccessibilityExtensionContext** module, inherited from **ExtensionContext**, provides context for **AccessibilityExtensionAbility**. You can use the APIs of this module to configure the concerned information, obtain root information, and inject gestures. @@ -131,7 +131,7 @@ Sets the concerned target bundle. This API uses an asynchronous callback to retu let targetNames = ['com.ohos.xyz']; try { axContext.setTargetBundleName(targetNames, (err, data) => { - if (err) { + if (err && err.code) { console.error('failed to set target bundle names, because ${JSON.stringify(err)}'); return; } @@ -214,7 +214,7 @@ For details about the error codes, see [Accessibility Error Codes](../errorcodes let focusElement; try { axContext.getFocusElement((err, data) => { - if (err) { + if (err && err.code) { console.error('failed to get focus element, because ${JSON.stringify(err)}'); return; } @@ -248,7 +248,7 @@ let focusElement; let isAccessibilityFocus = true; try { axContext.getFocusElement(isAccessibilityFocus, (err, data) => { - if (err) { + if (err && err.code) { console.error('failed to get focus element, because ${JSON.stringify(err)}'); return; } @@ -331,7 +331,7 @@ For details about the error codes, see [Accessibility Error Codes](../errorcodes let rootElement; try { axContext.getWindowRootElement((err, data) => { - if (err) { + if (err && err.code) { console.error('failed to get root element of the window, because ${JSON.stringify(err)}'); return; } @@ -373,7 +373,7 @@ let rootElement; let windowId = 10; try { axContext.getWindowRootElement(windowId, (err, data) => { - if (err) { + if (err && err.code) { console.error('failed to get root element of the window, because ${JSON.stringify(err)}'); return; } @@ -457,7 +457,7 @@ For details about the error codes, see [Accessibility Error Codes](../errorcodes let windows; try { axContext.getWindows((err, data) => { - if (err) { + if (err && err.code) { console.error('failed to get windows, because ${JSON.stringify(err)}'); return; } @@ -499,7 +499,7 @@ let windows; let displayId = 10; try { axContext.getWindows(displayId, (err, data) => { - if (err) { + if (err && err.code) { console.error('failed to get windows, because ${JSON.stringify(err)}'); return; } @@ -594,7 +594,7 @@ try { gesturePath.points.push(gesturePoint); } axContext.injectGesture(gesturePath, (err, data) => { - if (err) { + if (err && err.code) { console.error('failed to inject gesture, because ${JSON.stringify(err)}'); return; } @@ -818,7 +818,7 @@ Performs an action based on the specified action name. This API uses a promise t | Name | Type | Mandatory | Description | | ----------- | ---------------------------------------- | ---- | -------------- | -| actionName | string | Yes | Action name. | +| actionName | string | Yes | Action name. For details, see [Action](./js-apis-accessibility.md#action). | parameters | object | No | Parameter required for performing the target action. | **Return value** @@ -861,7 +861,7 @@ Performs an action based on the specified action name. This API uses an asynchro | Name | Type | Mandatory | Description | | ----------- | ---------------------------------------- | ---- | -------------- | -| actionName | string | Yes | Attribute name. | +| actionName | string | Yes | Action name. For details, see [Action](./js-apis-accessibility.md#action). | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** @@ -900,7 +900,7 @@ Performs an action based on the specified action name. This API uses an asynchro | Name | Type | Mandatory | Description | | ----------- | ---------------------------------------- | ---- | -------------- | -| actionName | string | Yes | Action name. | +| actionName | string | Yes | Action name. For details, see [Action](./js-apis-accessibility.md#action).| | parameters | object | Yes | Parameter required for performing the target action. | | callback | AsyncCallback<void> | Yes | Callback used to return the result.| diff --git a/en/application-dev/reference/apis/js-apis-installer.md b/en/application-dev/reference/apis/js-apis-installer.md index c39fa3514e9722ba2d33a7dce55378ecb875e3e6..625883cf0313cf47a28e8dae9f1cec7ff79b39b2 100644 --- a/en/application-dev/reference/apis/js-apis-installer.md +++ b/en/application-dev/reference/apis/js-apis-installer.md @@ -3,6 +3,7 @@ The **bundle.installer** module provides APIs for you to install, uninstall, and recover bundles on devices. > **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 @@ -118,6 +119,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc | 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | | 17700018 | Failed to install because the dependent module does not exist. | | 17700031 | Failed to install the HAP because the overlay check of the HAP is failed. | +| 17700036 | Failed to install because without allow app shared bundle permission. | **Example** @@ -164,7 +166,7 @@ Uninstalls a bundle. This API uses an asynchronous callback to return the result | Name | Type | Mandatory| Description | | ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | | bundleName | string | Yes | Name of the target bundle. | -| installParam | [InstallParam](#installparam) | Yes | Parameters required for the installation. | +| installParam | [InstallParam](#installparam) | Yes | Parameters required for the uninstall. | | callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is undefined; otherwise, **err** is an error object.| **Error codes** @@ -204,6 +206,119 @@ try { } ``` +## BundleInstaller.uninstall10+ + +uninstall(uninstallParam: UninstallParam, callback : AsyncCallback\) : void ; + +Uninstalls a shared bundle. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.INSTALL_BUNDLE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| uninstallParam | [UninstallParam](#uninstallparam10) | Yes | Parameters required for the uninstall. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is undefined; otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------------------------------ | +| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | +| 17700037 | The version of shared bundle is dependent on other applications. | +| 17700038 | The specified shared bundle does not exist. | + +**Example** + +```ts +import installer from '@ohos.bundle.installer'; +let uninstallParam = { + bundleName : "com.ohos.demo", +}; + +try { + installer.getBundleInstaller().then(data => { + data.uninstall(uninstallParam, err => { + if (err) { + console.error('uninstall failed:' + err.message); + } else { + console.info('uninstall successfully.'); + } + }); + }).catch(error => { + console.error('getBundleInstaller failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getBundleInstaller failed. Cause: ' + error.message); +} +``` + +## BundleInstaller.uninstall10+ + +uninstall(uninstallParam: UninstallParam) : Promise\; + +Uninstalls a shared bundle. This API uses a promise to return the result. + +**System API**: This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.INSTALL_BUNDLE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ----------------------------------- | ---- | ---------------------------- | +| uninstallParam | [UninstallParam](#uninstallparam10) | Yes | Parameters required for the uninstall.| + +**Return value** + +| Type | Description | +| ------------- | -------------------------------------- | +| Promise\ | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------------------------------ | +| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | +| 17700037 | The version of shared bundle is dependent on other applications. | +| 17700038 | The specified shared bundle does not exist. | + +**Example** + +```ts +import installer from '@ohos.bundle.installer'; +let uninstallParam = { + bundleName : "com.ohos.demo", +}; + +try { + installer.getBundleInstaller().then(data => { + data.uninstall(uninstallParam, err => { + if (err) { + console.error('uninstall failed:' + err.message); + } else { + console.info('uninstall successfully.'); + } + }); + }).catch(error => { + console.error('getBundleInstaller failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getBundleInstaller failed. Cause: ' + error.message); +} +``` + ## BundleInstaller.recover recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback<void>): void; @@ -221,7 +336,7 @@ Recovers a bundle. This API uses an asynchronous callback to return the result. | Name | Type | Mandatory| Description | | ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | | bundleName | string | Yes | Name of the target bundle. | -| installParam | [InstallParam](#installparam) | Yes | Parameters required for the installation. | +| installParam | [InstallParam](#installparam) | Yes | Parameters required for the recovering. | | callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is undefined; otherwise, **err** is an error object.| **Error codes** @@ -288,3 +403,17 @@ Defines the parameters that need to be specified for bundle installation, uninst | isKeepData | boolean | Yes | Whether to retain the data directory during bundle uninstall.| | hashParams | Array<[HashParam](#hashparam)> | Yes| Hash parameters. | | crowdtestDeadline| number | Yes |End date of crowdtesting.| +| sharedBundleDirPaths | Array\ | No|Paths of the shared bundle files.| + +## UninstallParam10+ + +Defines the parameters required for the uninstallation of a shared bundle. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + + **System API**: This is a system API and cannot be called by third-party applications. + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Name of the shared bundle. | +| versionCode | number | No | Version number of the shared bundle. If this parameter is not set, all shared bundles of the specified name are uninstalled.| diff --git a/en/application-dev/reference/apis/js-apis-intl.md b/en/application-dev/reference/apis/js-apis-intl.md index 22b2225382e82166356b37003483c7c27a1400e0..cec10d9eef5fbd50d9d81ca6a5358d57d78fdbf0 100644 --- a/en/application-dev/reference/apis/js-apis-intl.md +++ b/en/application-dev/reference/apis/js-apis-intl.md @@ -1,6 +1,7 @@ # @ohos.intl (Internationalization) - The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402. +The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402. + The [i18n](js-apis-i18n.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** diff --git a/en/application-dev/reference/apis/js-apis-measure.md b/en/application-dev/reference/apis/js-apis-measure.md index 6095a5e68ed87bc8c92fe3198e36ac4982fe70a7..3e608c26158d219fc76ace69899da778ad6ea576 100644 --- a/en/application-dev/reference/apis/js-apis-measure.md +++ b/en/application-dev/reference/apis/js-apis-measure.md @@ -58,6 +58,52 @@ struct Index { } ``` +## measure.measureTextSize10+ + +measureTextSize(options: MeasureOptions): SizeOptions + +Measures the width of the given single-line text. + +**System capability**: SystemCapability.ArkUI.ArkUI.Full + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------- | ------------------------------- | ---- | --------- | +| options | [MeasureOptions](#measureoptions) | Yes | Information about the measured text.| + +**Return value** + +| Type | Description | +| ------------ | --------- | +| SizeOptions | Layout width and height occupied by the text.
The unit is px.| + + +**Example** + +```ts +import measure from '@ohos.measure' +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + textSize : SizeOptions = measure.measureTextSize({ + textContent: "Hello word", + fontSize: '50px' + }) + build() { + Row() { + Column() { + Text("The width of 'Hello World': " + this.textSize.width) + Text("The height of 'Hello World': " + this.textSize.height) + } + .width('100%') + } + .height('100%') + } +} +``` + ## MeasureOptions Provides attributes of the measured text. @@ -67,8 +113,15 @@ Provides attributes of the measured text. | Name | Type | Mandatory| Description | | -------------- | -------------------------------------------------------------------------------------------------- | ---- | ----------------------------------------------- | | textContent | string | Yes | Content of the measured text. | -| fontSize | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | No | Font size of the measured text. If the value is of the number type, the unit fp is used.
Default value: **16fp**
**NOTE**
The value cannot be a percentage. | +| constraintWidth10+ | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | No | Layout width of the measured text.
The default unit is vp. | +| fontSize | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | No | Font size of the measured text. If the value is of the number type, the unit fp is used.
Default value: **16fp**
**NOTE**
The value cannot be a percent string. | | fontStyle | number \| [FontStyle](../arkui-ts/ts-appendix-enums.md#fontstyle) | No | Font style of the measured text.
Default value: **FontStyle.Normal** | | fontWeight | number \| string \| [FontWeight](../arkui-ts/ts-appendix-enums.md#fontweight) | No | Font width of the measured text. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is **400**. A larger value indicates a heavier font weight. The string type supports only the string of the number type, for example, **400**, **"bold"**, **"bolder"**, **"lighter"**, **"regular"**, and **"medium"**, which correspond to the enumerated values in **FontWeight**.
Default value: **FontWeight.Normal**| | fontFamily | string \| [Resource](../arkui-ts/ts-types.md#resource) | No | Font family of the measured text. Default value: **'HarmonyOS Sans'**
Only the default font is supported.| | letterSpacing | number \| string | No | Letter spacing of the measured text.| +| textAlign10+ | number \| [TextAlign](../arkui-ts/ts-appendix-enums.md#textalign) | No | Horizontal alignment mode of the measured text.
Default value: **TextAlign.Start**| +| overflow10+ | number \| [TextOverflow](../arkui-ts/ts-appendix-enums.md#textoverflow) | No | Display mode when the measured text is too long.| +| maxLines10+ | number | No | Maximum number of lines in the measured text.| +| lineHeight10+ | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | No | Line height of the measured text.| +| baselineOffset10+ | number \| string | No | Baseline offset of the measured text.
Default value: **0**| +| textCase10+ | number \| [TextCase](../arkui-ts/ts-appendix-enums.md#textcase) | No | Case of the measured text.
Default value: **TextCase.Normal**| diff --git a/en/application-dev/reference/apis/js-apis-media.md b/en/application-dev/reference/apis/js-apis-media.md index 70e5b8141e0072a84640e6f3b27f94e345e96264..a0d85f43ee33d674268067dedf450ac5c300419a 100644 --- a/en/application-dev/reference/apis/js-apis-media.md +++ b/en/application-dev/reference/apis/js-apis-media.md @@ -932,6 +932,14 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js +printfDescription(obj) { + for (let item in obj) { + let property = obj[item]; + console.info('audio key is ' + item); + console.info('audio value is ' + property); + } +} + avPlayer.getTrackDescription((error, arrList) => { if ((arrList) != null) { for (let i = 0; i < arrList.length; i++) { @@ -969,6 +977,14 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco ```js let arrayDescription; + +printfDescription(obj) { + for (let item in obj) { + let property = obj[item]; + console.info('audio key is ' + item); + console.info('audio value is ' + property); + } +} avPlayer.getTrackDescription().then((arrList) => { if (arrList != null) { arrayDescription = arrList; @@ -1558,6 +1574,8 @@ Subscribes to the audio interruption event. When multiple audio and video assets **Example** ```js +import audio from '@ohos.multimedia.audio'; + avPlayer.on('audioInterrupt', (info: audio.InterruptEvent) => { console.info('audioInterrupt success,and InterruptEvent info is:' + info) }) @@ -1759,7 +1777,7 @@ let AVRecorderConfig = { location : { latitude : 30, longitude : 130 } } -AVRecorder.prepare(AVRecorderConfig, (err) => { +avRecorder.prepare(AVRecorderConfig, (err) => { if (err == null) { console.info('prepare success'); } else { @@ -1830,7 +1848,7 @@ let AVRecorderConfig = { location : { latitude : 30, longitude : 130 } } -AVRecorder.prepare(AVRecorderConfig).then(() => { +avRecorder.prepare(AVRecorderConfig).then(() => { console.info('prepare success'); }).catch((err) => { console.info('prepare failed and catch error is ' + err.message); @@ -1871,7 +1889,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco ```js let surfaceID = null; // The surfaceID is transferred to the camera API to create a videoOutput instance. -AVRecorder.getInputSurface((err, surfaceId) => { +avRecorder.getInputSurface((err, surfaceId) => { if (err == null) { console.info('getInputSurface success'); surfaceID = surfaceId; @@ -1880,8 +1898,6 @@ AVRecorder.getInputSurface((err, surfaceId) => { } }); -// videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); - ``` ### getInputSurface9+ @@ -1917,14 +1933,12 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco ```js let surfaceID = null; // The surfaceID is transferred to the camera API to create a videoOutput instance. -AVRecorder.getInputSurface().then((surfaceId) => { +avRecorder.getInputSurface().then((surfaceId) => { console.info('getInputSurface success'); surfaceID = surfaceId; }).catch((err) => { console.info('getInputSurface failed and catch error is ' + err.message); }); - -// videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); ``` ### start9+ @@ -1956,7 +1970,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js -AVRecorder.start((err) => { +avRecorder.start((err) => { if (err == null) { console.info('start AVRecorder success'); } else { @@ -1994,7 +2008,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js -AVRecorder.start().then(() => { +avRecorder.start().then(() => { console.info('start AVRecorder success'); }).catch((err) => { console.info('start AVRecorder failed and catch error is ' + err.message); @@ -2030,7 +2044,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js -AVRecorder.pause((err) => { +avRecorder.pause((err) => { if (err == null) { console.info('pause AVRecorder success'); } else { @@ -2068,7 +2082,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js -AVRecorder.pause().then(() => { +avRecorder.pause().then(() => { console.info('pause AVRecorder success'); }).catch((err) => { console.info('pause AVRecorder failed and catch error is ' + err.message); @@ -2104,7 +2118,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js -AVRecorder.resume((err) => { +avRecorder.resume((err) => { if (err == null) { console.info('resume AVRecorder success'); } else { @@ -2142,7 +2156,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js -AVRecorder.resume().then(() => { +avRecorder.resume().then(() => { console.info('resume AVRecorder success'); }).catch((err) => { console.info('resume AVRecorder failed and catch error is ' + err.message); @@ -2180,7 +2194,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js -AVRecorder.stop((err) => { +avRecorder.stop((err) => { if (err == null) { console.info('stop AVRecorder success'); } else { @@ -2220,7 +2234,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js -AVRecorder.stop().then(() => { +avRecorder.stop().then(() => { console.info('stop AVRecorder success'); }).catch((err) => { console.info('stop AVRecorder failed and catch error is ' + err.message); @@ -2255,7 +2269,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js -AVRecorder.reset((err) => { +avRecorder.reset((err) => { if (err == null) { console.info('reset AVRecorder success'); } else { @@ -2292,7 +2306,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js -AVRecorder.reset().then(() => { +avRecorder.reset().then(() => { console.info('reset AVRecorder success'); }).catch((err) => { console.info('reset AVRecorder failed and catch error is ' + err.message); @@ -2326,7 +2340,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js -AVRecorder.release((err) => { +avRecorder.release((err) => { if (err == null) { console.info('release AVRecorder success'); } else { @@ -2362,7 +2376,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js -AVRecorder.release().then(() => { +avRecorder.release().then(() => { console.info('release AVRecorder success'); }).catch((err) => { console.info('release AVRecorder failed and catch error is ' + err.message); @@ -2387,9 +2401,8 @@ Subscribes to AVRecorder state changes. An application can subscribe to only one **Example** ```js -AVRecorder.on('stateChange', async (state, reason) => { +avRecorder.on('stateChange', async (state, reason) => { console.info('case state has changed, new state is :' + state + ',and new reason is : ' + reason); - } }); ``` @@ -2410,7 +2423,7 @@ Unsubscribes from AVRecorder state changes. **Example** ```js -AVRecorder.off('stateChange'); +avRecorder.off('stateChange'); ``` ### on('error')9+ @@ -2442,7 +2455,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js -AVRecorder.on('error', (err) => { +avRecorder.on('error', (err) => { console.info('case avRecorder.on(error) called, errMessage is ' + err.message); }); ``` @@ -2473,7 +2486,7 @@ For details about the error codes, see [Media Error Codes](../errorcodes/errorco **Example** ```js -AVRecorder.off('error'); +avRecorder.off('error'); ``` ## AVRecorderState9+ 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 d5a5f1585a5ae153694833b611861cc49325c4e7..adb1c8ee47ae8dc076f5b2c2f00b2c2ca92a2cd5 100644 --- a/en/application-dev/reference/apis/js-apis-net-connection.md +++ b/en/application-dev/reference/apis/js-apis-net-connection.md @@ -1,8 +1,8 @@ # @ohos.net.connection (Network Connection Management) -The **connection** 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. +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**
+> **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 @@ -10,6 +10,40 @@ The **connection** module provides basic network management capabilities. You ca ```js import connection from '@ohos.net.connection' ``` +## connection.createNetConnection + +createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection + +Creates a **NetConnection** object. **netSpecifier** specifies the network, and **timeout** specifies the timeout interval in ms. **timeout** is configurable only when **netSpecifier** is specified. If neither of them is present, the default network is used. + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | +| netSpecifier | [NetSpecifier](#netspecifier) | No | Network specifier. If this parameter is not set, the default network is used. | +| timeout | number | No | Timeout interval for obtaining the network specified by **netSpecifier**. This parameter is valid only when **netSpecifier** is set.| + +**Return value** + +| Type | Description | +| ------------------------------- | -------------------- | +| [NetConnection](#netconnection) | Handle of the network specified by **netSpecifier**.| + +**Example** + +```js +// Default network +let netConnection = connection.createNetConnection() + +// Cellular network +let netConnectionCellular = connection.createNetConnection({ + netCapabilities: { + bearerTypes: [connection.NetBearType.BEARER_CELLULAR] + } +}) +``` ## connection.getDefaultNet @@ -25,14 +59,22 @@ Obtains the default active data network. This API uses an asynchronous callback | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\<[NetHandle](#nethandle)> | Yes | Callback used to return the result.| +| callback | AsyncCallback\<[NetHandle](#nethandle)> | Yes | Callback used to return the result. If the default activated data network is obtained successfully, err is undefined and data is the default activated data network. Otherwise, err is an error object.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | **Example** ```js -connection.getDefaultNet(function (error, netHandle) { +connection.getDefaultNet(function (error, data) { console.log(JSON.stringify(error)) - console.log(JSON.stringify(netHandle)) + console.log(JSON.stringify(data)) }) ``` @@ -52,17 +94,25 @@ Obtains the default active data network. This API uses a promise to return the r | --------------------------------- | ------------------------------------- | | Promise\<[NetHandle](#nethandle)> | Promise used to return the result.| +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + **Example** ```js -connection.getDefaultNet().then(function (netHandle) { - console.log(JSON.stringify(netHandle)) +connection.getDefaultNet().then(function (data) { + console.log(JSON.stringify(data)) }) ``` ## connection.getDefaultNetSync9+ -getDefaultNetSync(): NetHandle; +getDefaultNetSync(): NetHandle Obtains the default active data network in synchronous mode. You can use [getNetCapabilities](#connectiongetnetcapabilities) to obtain information such as the network type and capabilities. @@ -76,59 +126,321 @@ Obtains the default active data network in synchronous mode. You can use [getNet | --------- | ---------------------------------- | | NetHandle | Handle of the default active data network.| +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + **Example** ```js let netHandle = connection.getDefaultNetSync(); ``` +## connection.getGlobalHttpProxy10+ -## connection.hasDefaultNet +getGlobalHttpProxy(callback: AsyncCallback\): void -hasDefaultNet(callback: AsyncCallback\): void +Obtains the global HTTP proxy configuration of the network. This API uses an asynchronous callback to return the result. -Checks whether the default data network is activated. This API uses an asynchronous callback to return the result. You can use [getDefaultNet](#connectiongetdefaultnet) to obtain the default data network, if any. +**System API**: This is a system API. -**Required permission**: ohos.permission.GET_NETWORK_INFO +**System capability**: SystemCapability.Communication.NetManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------------------------------------------ | ---- | ---------------- | +| callback | AsyncCallback\<[HttpProxy](#httpproxy)> | Yes | Callback used to return the result. If the global HTTP proxy configuration of the network is obtained successfully, **err** is **undefined** and **data** is the global HTTP proxy configuration. Otherwise, **err** is an error object.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**Example** + +```js +connection.getGlobalHttpProxy((error,data) => { + console.info(JSON.stringify(error)); + console.info(JSON.stringify(data)); +}) +``` + +## connection.getGlobalHttpProxy10+ + +getGlobalHttpProxy(): Promise\; + +Obtains the global HTTP proxy configuration of the network. This API uses a promise to return the result. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Return value** + +| Type | Description | +| --------------------------------- | ------------------------------------- | +| Promise\<[HttpProxy](#httpproxy)> | Promise used to return the result.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**Example** + +```js +connection.getGlobalHttpProxy().then((data) => { + console.info(JSON.stringify(data)); +}).catch(error => { + console.info(JSON.stringify(error)); +}) +``` + +## connection.setGlobalHttpProxy10+ + +setGlobalHttpProxy(httpProxy: HttpProxy, callback: AsyncCallback\): void + +Sets the global HTTP proxy configuration of the network. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL **System capability**: SystemCapability.Communication.NetManager.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------- | ---- | -------------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** indicates that the default data network is activated.| +| Name | Type | Mandatory| Description | +| --------- | ------------------------------------------------------------ | ---- | ---------------- | +| httpProxy | [HttpProxy](#httpproxy) | Yes | Global HTTP proxy configuration of the network.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the global HTTP proxy configuration of the network is set successfully, **err** is **undefined**. Otherwise, **err** is an error object.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | **Example** ```js -connection.hasDefaultNet(function (error, has) { - console.log(JSON.stringify(error)) - console.log('has: ' + has) +let exclusionStr="192.168,baidu.com" +let exclusionArray = exclusionStr.split(','); +let httpProxy = { + host: "192.168.xx.xxx", + port: 8080, + exclusionList: exclusionArray +} +connection.setGlobalHttpProxy(httpProxy, (error, data) => { + console.info(JSON.stringify(error)); + console.info(JSON.stringify(data)); +}); +``` + +## connection.setGlobalHttpProxy10+ + +setGlobalHttpProxy(httpProxy: HttpProxy): Promise\; + +Sets the global HTTP proxy configuration of the network. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------------------------------------------ | ---- | ---------------- | +| httpProxy | [HttpProxy](#httpproxy) | Yes | Global HTTP proxy configuration of the network.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | ----------------------------- | +| Promise\ | Promise that returns no value.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**Example** + +```js +let exclusionStr="192.168,baidu.com" +let exclusionArray = exclusionStr.split(','); +let httpProxy = { + host: "192.168.xx.xxx", + port: 8080, + exclusionList: exclusionArray +} +connection.setGlobalHttpProxy(httpProxy).then((error, data) => { + console.info(JSON.stringify(data)); +}).catch(error=>{ + console.info(JSON.stringify(error)); }) ``` -## connection.hasDefaultNet +## connection.getAppNet9+ -hasDefaultNet(): Promise\ +getAppNet(callback: AsyncCallback\): void -Checks whether the default data network is activated. This API uses a promise to return the result. You can use [getDefaultNet](#connectiongetdefaultnet) to obtain the default data network, if any. +Obtains information about the network bound to an application. This API uses an asynchronous callback to return the result. -**Required permission**: ohos.permission.GET_NETWORK_INFO +**System capability**: SystemCapability.Communication.NetManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------------------------------------------ | ---- | ---------------- | +| callback | AsyncCallback\<[NetHandle](#nethandle)> | Yes | Callback used to return the result. If information about the network bound to the application is successfully obtained, **err** is **undefined** and **data** is the obtained network information. Otherwise, **err** is an error object.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**Example** + +```js +connection.getAppNet(function(error, data) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(data)) +}) +``` + +## connection.getAppNet9+ + +getAppNet(): Promise\; + +Obtains information about the network bound to an application. This API uses a promise to return the result. **System capability**: SystemCapability.Communication.NetManager.Core **Return value** -| Type | Description | -| ----------------- | ----------------------------------------------- | -| Promise\ | Promise used to return the result. The value **true** indicates that the default data network is activated.| +| Type | Description | +| --------------------------------- | ------------------------------------- | +| Promise\<[NetHandle](#nethandle)> | Promise used to return the result.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**Example** + +```js +connection.getAppNet().then((data) => { + console.info(JSON.stringify(data)); +}).catch(error => { + console.info(JSON.stringify(error)); +}) +``` + +## connection.SetAppNet9+ + +setAppNet(netHandle: NetHandle, callback: AsyncCallback\): void + +Binds an application to the specified network, so that the application can access the external network only through this network. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.INTERNET + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------------------------------------------ | ---- | ---------------- | +| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the application is successfully bound to the specified network, **err** is **undefined**. Otherwise, **err** is an error object.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | **Example** ```js -connection.hasDefaultNet().then(function (has) { - console.log('has: ' + has) +connection.getDefaultNet(function (error, netHandle) { + connection.setAppNet(netHandle, (error, data) => { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(data)) + }); +}) +``` + +## connection.SetAppNet9+ + +setAppNet(netHandle: NetHandle): Promise\; + +Binds an application to the specified network, so that the application can access the external network only through this network. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.INTERNET + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------------------------------------------ | ---- | ---------------- | +| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | ----------------------------- | +| Promise\ | Promise that returns no value.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**Example** + +```js +connection.getDefaultNet().then(function (netHandle) { + connection.setAppNet(netHandle).then((error, data) => { + console.log(JSON.stringify(data)) + }).catch(error => { + console.log(JSON.stringify(error)) + }) }) ``` @@ -136,7 +448,7 @@ connection.hasDefaultNet().then(function (has) { getAllNets(callback: AsyncCallback<Array<NetHandle>>): void -Obtains the list of all active data networks. This API uses an asynchronous callback to return the result. +Obtains the list of all connected networks. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.GET_NETWORK_INFO @@ -146,23 +458,30 @@ Obtains the list of all active data networks. This API uses an asynchronous call | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| callback | AsyncCallback<Array<[NetHandle](#nethandle)>> | Yes| Callback used to return the result.| +| callback | AsyncCallback<Array<[NetHandle](#nethandle)>> | Yes| Callback used to return the result. If the list of all connected networks is obtained successfully, **err** is **undefined** and **data** is the list of activated data networks. Otherwise, **err** is an error object.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | **Example** ```js -connection.getAllNets(function (error, nets) { +connection.getAllNets(function (error, data) { console.log(JSON.stringify(error)) - console.log(JSON.stringify(nets)) + console.log(JSON.stringify(data)) }); ``` - ## connection.getAllNets getAllNets(): Promise<Array<NetHandle>> -Obtains the list of all active data networks. This API uses a promise to return the result. +Obtains the list of all connected networks. This API uses a promise to return the result. **Required permission**: ohos.permission.GET_NETWORK_INFO @@ -174,11 +493,19 @@ Obtains the list of all active data networks. This API uses a promise to return | -------- | -------- | | Promise<Array<[NetHandle](#nethandle)>> | Promise used to return the result.| +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + **Example** ```js -connection.getAllNets().then(function (nets) { - console.log(JSON.stringify(nets)) +connection.getAllNets().then(function (data) { + console.log(JSON.stringify(data)) }); ``` @@ -186,7 +513,7 @@ connection.getAllNets().then(function (nets) { getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\): void -Obtains connection properties of the network corresponding to the given network handle. This API uses an asynchronous callback to return the result. +Obtains connection properties of the network corresponding to the **netHandle**. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.GET_NETWORK_INFO @@ -197,15 +524,25 @@ Obtains connection properties of the network corresponding to the given network | Name | Type | Mandatory| Description | | --------- | ------------------------------------------------------------ | ---- | ---------------- | | netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| -| callback | AsyncCallback\<[ConnectionProperties](#connectionproperties)> | Yes | Callback used to return the result. | +| callback | AsyncCallback\<[ConnectionProperties](#connectionproperties)> | Yes | Callback used to return the result. If the connection properties of the network corresponding to the **netHandle** is obtained successfully, **err** is **undefined** and **data** is the obtained network connection information. Otherwise, **err** is an error object.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | **Example** ```js connection.getDefaultNet().then(function (netHandle) { - connection.getConnectionProperties(netHandle, function (error, info) { + connection.getConnectionProperties(netHandle, function (error, data) { console.log(JSON.stringify(error)) - console.log(JSON.stringify(info)) + console.log(JSON.stringify(data)) }) }) ``` @@ -214,7 +551,7 @@ connection.getDefaultNet().then(function (netHandle) { getConnectionProperties(netHandle: NetHandle): Promise\ -Obtains connection properties of the network corresponding to **netHandle**. This API uses a promise to return the result. +Obtains connection properties of the network corresponding to the **netHandle**. This API uses a promise to return the result. **Required permission**: ohos.permission.GET_NETWORK_INFO @@ -232,12 +569,22 @@ Obtains connection properties of the network corresponding to **netHandle**. Thi | ------------------------------------------------------- | --------------------------------- | | Promise\<[ConnectionProperties](#connectionproperties)> | Promise used to return the result.| +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + **Example** ```js connection.getDefaultNet().then(function (netHandle) { - connection.getConnectionProperties(netHandle).then(function (info) { - console.log(JSON.stringify(info)) + connection.getConnectionProperties(netHandle).then(function (data) { + console.log(JSON.stringify(data)) }) }) ``` @@ -246,7 +593,7 @@ connection.getDefaultNet().then(function (netHandle) { getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\): void -Obtains capability information of the network corresponding to **netHandle**. This API uses an asynchronous callback to return the result. +Obtains capability information of the network corresponding to the **netHandle**. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.GET_NETWORK_INFO @@ -257,15 +604,25 @@ Obtains capability information of the network corresponding to **netHandle**. Th | Name | Type | Mandatory| Description | | --------- | --------------------------------------------------- | ---- | ---------------- | | netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| -| callback | AsyncCallback\<[NetCapabilities](#netcapabilities)> | Yes | Callback used to return the result. | +| callback | AsyncCallback\<[NetCapabilities](#netcapabilities)> | Yes | Callback used to return the result. If the capability information of the network corresponding to the **netHandle** is obtained successfully, **err** is **undefined** and **data** is the obtained network capability information. Otherwise, **err** is an error object. | + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | **Example** ```js connection.getDefaultNet().then(function (netHandle) { - connection.getNetCapabilities(netHandle, function (error, info) { + connection.getNetCapabilities(netHandle, function (error, data) { console.log(JSON.stringify(error)) - console.log(JSON.stringify(info)) + console.log(JSON.stringify(data)) }) }) ``` @@ -274,7 +631,7 @@ connection.getDefaultNet().then(function (netHandle) { getNetCapabilities(netHandle: NetHandle): Promise\ -Obtains capability information of the network corresponding to **netHandle**. This API uses a promise to return the result. +Obtains capability information of the network corresponding to the **netHandle**. This API uses a promise to return the result. **Required permission**: ohos.permission.GET_NETWORK_INFO @@ -292,12 +649,22 @@ Obtains capability information of the network corresponding to **netHandle**. Th | --------------------------------------------- | --------------------------------- | | Promise\<[NetCapabilities](#netcapabilities)> | Promise used to return the result.| +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + **Example** ```js connection.getDefaultNet().then(function (netHandle) { - connection.getNetCapabilities(netHandle).then(function (info) { - console.log(JSON.stringify(info)) + connection.getNetCapabilities(netHandle).then(function (data) { + console.log(JSON.stringify(data)) }) }) ``` @@ -318,12 +685,20 @@ Checks whether the data traffic usage on the current network is metered. This AP | -------- | ----------------------- | ---- | -------------------------------------- | | callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** indicates the data traffic usage is metered.| -**Example**: +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**Example** ```js -connection.isDefaultNetMetered(function (error, has) { +connection.isDefaultNetMetered(function (error, data) { console.log(JSON.stringify(error)) - console.log('has: ' + has) + console.log('data: ' + data) }) ``` @@ -343,11 +718,216 @@ Checks whether the data traffic usage on the current network is metered. This AP | ----------------- | ----------------------------------------------- | | Promise\ | Promise used to return the result. The value **true** indicates the data traffic usage is metered.| -**Example**: +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**Example** + +```js +connection.isDefaultNetMetered().then(function (data) { + console.log('data: ' + data) +}) +``` + +## connection.hasDefaultNet + +hasDefaultNet(callback: AsyncCallback\): void + +Checks whether the default data network is activated. This API uses an asynchronous callback to return the result. You can use [getDefaultNet](#connectiongetdefaultnet) to obtain the default data network, if any. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** indicates the default data network is activated.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**Example** + +```js +connection.hasDefaultNet(function (error, data) { + console.log(JSON.stringify(error)) + console.log('data: ' + data) +}) +``` + +## connection.hasDefaultNet + +hasDefaultNet(): Promise\ + +Checks whether the default data network is activated. This API uses a promise to return the result. You can use [getDefaultNet](#connectiongetdefaultnet) to obtain the default data network, if any. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Return value** + +| Type | Description | +| ----------------- | ----------------------------------------------- | +| Promise\ | Promise used to return the result. The value **true** indicates that the default data network is activated.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**Example** ```js -connection.isDefaultNetMetered().then(function (has) { - console.log('has: ' + has) +connection.hasDefaultNet().then(function (data) { + console.log('data: ' + data) +}) +``` + +## connection.enableAirplaneMode + +enableAirplaneMode(callback: AsyncCallback\): void + +Enables the airplane mode. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------- | ---- | ------------------ | +| callback | AsyncCallback\ | Yes | Callback used to return the result. | + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**Example** + +```js +connection.enableAirplaneMode(function (error) { + console.log(JSON.stringify(error)) +}) +``` + +## connection.enableAirplaneMode + +enableAirplaneMode(): Promise\ + +Enables the airplane mode. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Return value** + +| Type | Description | +| ------------------------------------------- | ----------------------------- | +| Promise\ | Promise that returns no value.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**Example** + +```js +connection.enableAirplaneMode().then(function (error) { + console.log(JSON.stringify(error)) +}) +``` + +## connection.disableAirplaneMode + +disableAirplaneMode(callback: AsyncCallback\): void + +Disables the airplane mode. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------- | ---- | ------------------ | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the airplane mode is disabled successfully, **err** is **undefined**. Otherwise, **err** is an error object.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**Example** + +```js +connection.disableAirplaneMode(function (error) { + console.log(JSON.stringify(error)) +}) +``` + +## connection.disableAirplaneMode + +disableAirplaneMode(): Promise\ + +Disables the airplane mode. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Return value** + +| Type | Description | +| ------------------------------------------- | ----------------------------- | +| Promise\ | Promise that returns no value.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**Example** + +```js +connection.disableAirplaneMode().then(function (error) { + console.log(JSON.stringify(error)) }) ``` @@ -355,9 +935,8 @@ connection.isDefaultNetMetered().then(function (has) { reportNetConnected(netHandle: NetHandle, callback: AsyncCallback<void>): void -Reports connection of the data network. This API uses an asynchronous callback to return the result. - -If this API is called, the application considers that the network connection state (**ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED**) is inconsistent with that in the network management module. +Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. +This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET @@ -368,7 +947,17 @@ If this API is called, the application considers that the network connection sta | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| -| callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the network status is reported successfully, **err** is **undefined**. Otherwise, **err** is an error object.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | **Example** @@ -384,9 +973,8 @@ connection.getDefaultNet().then(function (netHandle) { reportNetConnected(netHandle: NetHandle): Promise<void> -Reports connection of the data network. This API uses a promise to return the result. - -If this API is called, the application considers that the network connection state (**ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED**) is inconsistent with that in the network management module. +Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. +This API uses a promise to return the result. **Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET @@ -399,11 +987,20 @@ If this API is called, the application considers that the network connection sta | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| **Return value** - | Type| Description| | -------- | -------- | | Promise<void> | Promise that returns no value.| +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + **Example** ```js @@ -414,14 +1011,12 @@ connection.getDefaultNet().then(function (netHandle) { }); ``` - ## connection.reportNetDisconnected reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback<void>): void -Reports disconnection of the data network. This API uses an asynchronous callback to return the result. - -If this API is called, the application considers that the network connection state (**ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED**) is inconsistent with that in the network management module. +Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. +This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET @@ -432,7 +1027,17 @@ If this API is called, the application considers that the network connection sta | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| -| callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the network status is reported successfully, **err** is **undefined**. Otherwise, **err** is an error object.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | **Example** @@ -444,14 +1049,12 @@ connection.getDefaultNet().then(function (netHandle) { }); ``` - ## connection.reportNetDisconnected reportNetDisconnected(netHandle: NetHandle): Promise<void> -Reports disconnection of the data network. This API uses a promise to return the result. - -If this API is called, the application considers that the network connection state (**ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED**) is inconsistent with that in the network management module. +Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. +This API uses a promise to return the result. **Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET @@ -464,11 +1067,20 @@ If this API is called, the application considers that the network connection sta | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| **Return value** - | Type| Description| | -------- | -------- | | Promise<void> | Promise that returns no value.| +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + **Example** ```js @@ -493,213 +1105,185 @@ Resolves the host name by using the default network to obtain all IP addresses. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------- | ---- | ------------------ | -| host | string | Yes | Host name to be resolved.| -| callback | AsyncCallback\> | Yes | Callback used to return the result. | - -**Example** - -```js -let host = "xxxx"; -connection.getAddressesByName(host, function (error, addresses) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(addresses)) -}) -``` - -## connection.getAddressesByName - -getAddressesByName(host: string): Promise\> - -Resolves the host name by using the default network to obtain all IP addresses. This API uses a promise to return the result. - -**Required permission**: ohos.permission.GET_NETWORK_INFO - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------ | -| host | string | Yes | Host name to be resolved.| - -**Return value** - -| Type | Description | -| ------------------------------------------- | ----------------------------- | -| Promise\> | Promise used to return the result.| - -**Example** - -```js -let host = "xxxx"; -connection.getAddressesByName(host).then(function (addresses) { - console.log(JSON.stringify(addresses)) -}) -``` - -## connection.enableAirplaneMode - -enableAirplaneMode(callback: AsyncCallback\): void - -Enables the airplane mode. This API uses an asynchronous callback to return the result. - -**System API**: This is a system API. - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------- | ---- | ------------------ | -| callback | AsyncCallback\ | Yes | Callback used to return the result. | +| host | string | Yes | Host name to resolve.| +| callback | AsyncCallback\> | Yes | Callback used to return the result. If all IP addresses are successfully obtained, **err** is **undefined**, and **data** is the list of all obtained IP addresses. Otherwise, **err** is an error object.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | **Example** ```js -connection.enableAirplaneMode(function (error) { +let host = "xxxx"; +connection.getAddressesByName(host, function (error, data) { console.log(JSON.stringify(error)) + console.log(JSON.stringify(data)) }) ``` -## connection.enableAirplaneMode +## connection.getAddressesByName -enableAirplaneMode(): Promise\ +getAddressesByName(host: string): Promise\> -Enables the airplane mode. This API uses a promise to return the result. +Resolves the host name by using the default network to obtain all IP addresses. This API uses a promise to return the result. -**System API**: This is a system API. +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Communication.NetManager.Core -**System capability**: SystemCapability.Communication.NetManager.Core +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------ | +| host | string | Yes | Host name to resolve.| **Return value** | Type | Description | | ------------------------------------------- | ----------------------------- | -| Promise\ | Promise that returns no value.| +| Promise\> | Promise used to return the result.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | **Example** ```js -connection.enableAirplaneMode().then(function (error) { - console.log(JSON.stringify(error)) +let host = "xxxx"; +connection.getAddressesByName(host).then(function (data) { + console.log(JSON.stringify(data)) }) ``` -## connection.disableAirplaneMode - -disableAirplaneMode(callback: AsyncCallback\): void - -Disables the airplane mode. This API uses an asynchronous callback to return the result. - -**System API**: This is a system API. - -**System capability**: SystemCapability.Communication.NetManager.Core +## NetConnection -**Parameters** +Represents the network connection handle. -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------- | ---- | ------------------ | -| callback | AsyncCallback\ | Yes | Callback used to return the result. | +### register -**Example** +register(callback: AsyncCallback\): void -```js -connection.disableAirplaneMode(function (error) { - console.log(JSON.stringify(error)) -}) -``` +Registers a listener for network status changes. -## connection.disableAirplaneMode +**Required permission**: ohos.permission.GET_NETWORK_INFO -disableAirplaneMode(): Promise\ +**System capability**: SystemCapability.Communication.NetManager.Core -Disables the airplane mode. This API uses a promise to return the result. +**Parameters** -**System API**: This is a system API. +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ---------- | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If a listener for network status changes is registered successfully, **err** is **undefined**. Otherwise, **err** is an error object.| -**System capability**: SystemCapability.Communication.NetManager.Core +**Error codes** -**Return value** +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | +| 2101008 | The callback is not exists. | +| 2101022 | The number of requests exceeded the maximum. | -| Type | Description | -| ------------------------------------------- | ----------------------------- | -| Promise\ | Promise that returns no value.| **Example** ```js -connection.disableAirplaneMode().then(function (error) { +netConnection.register(function (error) { console.log(JSON.stringify(error)) }) ``` -## connection.createNetConnection +### unregister -createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection +unregister(callback: AsyncCallback\): void -Obtains the handle of the network specified by **netSpecifier**. +Unregisters the listener for network status changes. **System capability**: SystemCapability.Communication.NetManager.Core **Parameters** -| Name | Type | Mandatory| Description | -| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | -| netSpecifier | [NetSpecifier](#netspecifier) | No | Network specifier. If this parameter is not set, the default network is used. | -| timeout | number | No | Timeout interval for obtaining the network specified by **netSpecifier**. This parameter is valid only when **netSpecifier** is set.| +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ---------- | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If a listener for network status changes is unregistered successfully, **err** is **undefined**. Otherwise, **err** is an error object.| -**Return value** +**Error codes** -| Type | Description | -| ------------------------------- | -------------------- | -| [NetConnection](#netconnection) | Handle of the network specified by **netSpecifier**.| +| ID| Error Message | +| ------- | ----------------------------- | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | +| 2101007 | The same callback exists. | **Example** ```js -// Default network -let netConnection = connection.createNetConnection() - -// Cellular network -let netConnectionCellular = connection.createNetConnection({ - netCapabilities: { - bearerTypes: [connection.NetBearType.BEARER_CELLULAR] - } +netConnection.unregister(function (error) { + console.log(JSON.stringify(error)) }) ``` -## NetConnection - -Represents the network connection handle. - ### on('netAvailable') on(type: 'netAvailable', callback: Callback\): void Registers a listener for **netAvailable** events. +**Model restriction**: Before you call this API, make sure that you have called **register** to add a listener and called **unregister** API to unsubscribe from status changes of the default network. + **System capability**: SystemCapability.Communication.NetManager.Core **Parameters** | Name | Type | Mandatory| Description | | -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed at **netAvailable**.
**netAvailable**: event indicating that the data network is available.| -| callback | Callback\<[NetHandle](#nethandle)> | Yes | Callback used to return the result. | +| type | string | Yes | Event type. The value is fixed to **netAvailable**.
**netAvailable**: event indicating that the data network is available.| +| callback | Callback\<[NetHandle](#nethandle)> | Yes | Callback used to return the network handle.| **Example** ```js -netConnection.on('netAvailable', function (data) { +// Create a NetConnection object. +let netCon = connection.createNetConnection() + +// Call register to register a listener. +netCon.register(function (error) { + console.log(JSON.stringify(error)) +}) + +// Subscribe to netAvailable events. Event notifications can be received only after register is called. +netCon.on('netAvailable', function (data) { console.log(JSON.stringify(data)) }) + +// Call unregister to unregister the listener. +netCon.unregister(function (error) { + console.log(JSON.stringify(error)) +}) ``` -### on('netCapabilitiesChange') +### on('netBlockStatusChange') -on(type: 'netCapabilitiesChange', callback: Callback<{ netHandle: NetHandle, netCap: NetCapabilities }>): void +on(type: 'netBlockStatusChange', callback: Callback<{ netHandle: NetHandle, blocked: boolean }>): void -Registers a listener for **netCapabilitiesChange** events. +Registers a listener for **netBlockStatusChange** events. + +**Model restriction**: Before you call this API, make sure tat you have called **register** to add a listener and called **unregister** API to unsubscribe from status changes of the default network. **System capability**: SystemCapability.Communication.NetManager.Core @@ -707,22 +1291,38 @@ Registers a listener for **netCapabilitiesChange** events. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed at **netCapabilitiesChange**.
**netCapabilitiesChange**: event indicating that network capabilities have changed.| -| callback | Callback<{ netHandle: [NetHandle](#nethandle), netCap: [NetCapabilities](#netcapabilities) }> | Yes | Callback used to return the result. | +| type | string | Yes | Event type. The value is fixed to **netBlockStatusChange**.
**netBlockStatusChange**: event indicating a change in the network blocking status.| +| callback | Callback<{ netHandle: [NetHandle](#nethandle), blocked: boolean }> | Yes | Callback used to return the network handle (**netHandle**) and network status (**blocked**).| **Example** ```js -netConnection.on('netCapabilitiesChange', function (data) { +// Create a NetConnection object. +let netCon = connection.createNetConnection() + +// Call register to register a listener. +netCon.register(function (error) { + console.log(JSON.stringify(error)) +}) + +// Subscribe to netBlockStatusChange events. Event notifications can be received only after register is called. +netCon.on('netBlockStatusChange', function (data) { console.log(JSON.stringify(data)) }) + +// Call unregister to unregister the listener. +netCon.unregister(function (error) { + console.log(JSON.stringify(error)) +}) ``` -### on('netConnectionPropertiesChange') +### on('netCapabilitiesChange') -on(type: 'netConnectionPropertiesChange', callback: Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }>): void +on(type: 'netCapabilitiesChange', callback: Callback<{ netHandle: NetHandle, netCap: NetCapabilities }>): void -Registers a listener for **netConnectionPropertiesChange** events. +Registers a listener for **netCapabilitiesChange** events. + +**Model restriction**: Before you call this API, make sure tat you have called **register** to add a listener and called **unregister** API to unsubscribe from status changes of the default network. **System capability**: SystemCapability.Communication.NetManager.Core @@ -730,22 +1330,38 @@ Registers a listener for **netConnectionPropertiesChange** events. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed at **netConnectionPropertiesChange**.
**netConnectionPropertiesChange**: event indicating that network connection properties have changed.| -| callback | Callback<{ netHandle: [NetHandle](#nethandle), connectionProperties: [ConnectionProperties](#connectionproperties) }> | Yes | Callback used to return the result. | +| type | string | Yes | Event type. The value is fixed to **netCapabilitiesChange**.
**netCapabilitiesChange**: event indicating that the network capabilities have changed.| +| callback | Callback<{ netHandle: [NetHandle](#nethandle), netCap: [NetCapabilities](#netcapabilities) }> | Yes | Callback used to return the network handle (**netHandle**) and capability information (**netCap**).| **Example** ```js -netConnection.on('netConnectionPropertiesChange', function (data) { +// Create a NetConnection object. +let netCon = connection.createNetConnection() + +// Call register to register a listener. +netCon.register(function (error) { + console.log(JSON.stringify(error)) +}) + +// Subscribe to netCapabilitiesChange events. Event notifications can be received only after register is called. +netCon.on('netCapabilitiesChange', function (data) { console.log(JSON.stringify(data)) }) + +// Call unregister to unregister the listener. +netCon.unregister(function (error) { + console.log(JSON.stringify(error)) +}) ``` -### on('netBlockStatusChange') +### on('netConnectionPropertiesChange') -on(type: 'netBlockStatusChange', callback: Callback<{ netHandle: NetHandle, blocked: boolean }>): void +on(type: 'netConnectionPropertiesChange', callback: Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }>): void -Registers a listener for **netBlockStatusChange** events. +Registers a listener for **netConnectionPropertiesChange** events. + +**Model restriction**: Before you call this API, make sure tat you have called **register** to add a listener and called **unregister** API to unsubscribe from status changes of the default network. **System capability**: SystemCapability.Communication.NetManager.Core @@ -753,15 +1369,29 @@ Registers a listener for **netBlockStatusChange** events. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed at **netBlockStatusChange**.
**netBlockStatusChange**: event indicating a change in the network blocking status.| -| callback | Callback<{ netHandle: [NetHandle](#nethandle), blocked: boolean }> | Yes | Callback used to return the result. | +| type | string | Yes | Event type. The value is fixed to **netConnectionPropertiesChange**.
**netConnectionPropertiesChange**: event indicating that network connection properties have changed.| +| callback | Callback<{ netHandle: [NetHandle](#nethandle), connectionProperties: [ConnectionProperties](#connectionproperties) }> | Yes | Callback used to return the network handle (**netHandle**) and capability information (**netCap**).| **Example** ```js -netConnection.on('netBlockStatusChange', function (data) { +// Create a NetConnection object. +let netCon = connection.createNetConnection() + +// Call register to register a listener. +netCon.register(function (error) { + console.log(JSON.stringify(error)) +}) + +// Subscribe to netConnectionPropertiesChange events. Event notifications can be received only after register is called. +netCon.on('netConnectionPropertiesChange', function (data) { console.log(JSON.stringify(data)) }) + +// Call unregister to unregister the listener. +netCon.unregister(function (error) { + console.log(JSON.stringify(error)) +}) ``` ### on('netLost') @@ -770,22 +1400,37 @@ on(type: 'netLost', callback: Callback\): void Registers a listener for **netLost** events. +**Model restriction**: Before you call this API, make sure tat you have called **register** to add a listener and called **unregister** API to unsubscribe from status changes of the default network. + **System capability**: SystemCapability.Communication.NetManager.Core **Parameters** | Name | Type | Mandatory| Description | | -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed at **netLost**.
netLost: event indicating that the network is interrupted or normally disconnected.| -| callback | Callback\<[NetHandle](#nethandle)> | Yes | Callback used to return the result. | +| type | string | Yes | Event type. The value is fixed to **netLost**.
netLost: event indicating that the network is interrupted or normally disconnected.| +| callback | Callback\<[NetHandle](#nethandle)> | Yes | Callback used to return the network handle (**netHandle**).| **Example** ```js -let netConnection1 = connection.createNetConnection() -netConnection1.on('netLost', function (data) { +// Create a NetConnection object. +let netCon = connection.createNetConnection() + +// Call register to register a listener. +netCon.register(function (error) { + console.log(JSON.stringify(error)) +}) + +// Subscribe to netLost events. Event notifications can be received only after register is called. +netCon.on('netLost', function (data) { console.log(JSON.stringify(data)) }) + +// Call unregister to unregister the listener. +netCon.unregister(function (error) { + console.log(JSON.stringify(error)) +}) ``` ### on('netUnavailable') @@ -794,65 +1439,35 @@ on(type: 'netUnavailable', callback: Callback\): void Registers a listener for **netUnavailable** events. +**Model restriction**: Before you call this API, make sure tat you have called **register** to add a listener and called **unregister** API to unsubscribe from status changes of the default network. + **System capability**: SystemCapability.Communication.NetManager.Core **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed at **netUnavailable**.
**netUnavailable**: event indicating that the network is unavailable.| -| callback | Callback\ | Yes | Callback used to return the result. | +| type | string | Yes | Event type. The value is fixed to **netUnavailable**.
**netUnavailable**: event indicating that the network is unavailable.| +| callback | Callback\ | Yes | Callback used to return the result, which is empty.| **Example** ```js -netConnection.on('netUnavailable', function (data) { - console.log(JSON.stringify(data)) -}) -``` - -### register - -register(callback: AsyncCallback\): void - -Registers a listener for network status changes. - -**Required permission**: ohos.permission.GET_NETWORK_INFO - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +// Create a NetConnection object. +let netCon = connection.createNetConnection() -**Example** - -```js -netConnection.register(function (error) { +// Call register to register a listener. +netCon.register(function (error) { console.log(JSON.stringify(error)) }) -``` - -### unregister - -unregister(callback: AsyncCallback\): void - -Unregisters the listener for network status changes. - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| -**Example** +// Subscribe to netUnavailable events. Event notifications can be received only after register is called. +netCon.on('netUnavailable', function (data) { + console.log(JSON.stringify(data)) +}) -```js -netConnection.unregister(function (error) { +// Call unregister to unregister the listener. +netCon.unregister(function (error) { console.log(JSON.stringify(error)) }) ``` @@ -861,24 +1476,22 @@ netConnection.unregister(function (error) { Defines the handle of the data network. -Before invoking NetHandle APIs, call **getNetHandle** to obtain a **NetHandle** object. +Before invoking **NetHandle** APIs, call **getNetHandle** to obtain a **NetHandle** object. **System capability**: SystemCapability.Communication.NetManager.Core -### Parameters +### Attributes -| Name| Type | Description | -| ------ | ------ | ------------------------- | -| netId | number | Network ID. The value **0** indicates no default network. Any other value must be greater than or equal to 100.| +| Name | Type | Mandatory| Description | +| ------ | ------ | --- |------------------------- | +| netId | number | Yes | Network ID. The value **0** indicates no default network. Any other value must be greater than or equal to 100.| ### bindSocket9+ -bindSocket(socketParam: TCPSocket \| UDPSocket, callback: AsyncCallback\): void; +bindSocket(socketParam: TCPSocket \| UDPSocket, callback: AsyncCallback\): void Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses an asynchronous callback to return the result. -**Required permission**: ohos.permission.GET_NETWORK_INFO - **System capability**: SystemCapability.Communication.NetManager.Core **Parameters** @@ -886,24 +1499,33 @@ Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses | Name | Type | Mandatory| Description | | ----------- | ------------------------ | ---- | -------------------------------| | socketParam | [TCPSocket](js-apis-socket.md#tcpsocket) \| [UDPSocket](js-apis-socket.md#udpsocket) | Yes| **TCPSocket** or **UDPSocket** object.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the **TCPSocket** or **UDPSocket** object is successfully bound to the current network, **err** is **undefined**. Otherwise, **err** is an error object.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | **Example** ```js import socket from "@ohos.net.socket"; -connection.getDefaultNet().then((netHandle)=>{ +connection.getDefaultNet().then((netHandle) => { var tcp = socket.constructTCPSocketInstance(); var udp = socket.constructUDPSocketInstance(); let socketType = "TCPSocket"; if (socketType == "TCPSocket") { tcp.bind({ - address: '192.168.xx.xxx', port: xxxx, family: 1 - }, err => { - if (err) { + address: '192.168.xx.xxx', port: 8080, family: 1 + }, error => { + if (error) { console.log('bind fail'); } - netHandle.bindSocket(tcp, (error, data)=>{ + netHandle.bindSocket(tcp, (error, data) => { if (error) { console.log(JSON.stringify(error)); } else { @@ -913,19 +1535,19 @@ connection.getDefaultNet().then((netHandle)=>{ }) } else { let callback = value => { - console.log(TAG + "on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); + console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); } udp.on('message', callback); udp.bind({ - address: '192.168.xx.xxx', port: xxxx, family: 1 - }, err => { - if (err) { + address: '192.168.xx.xxx', port: 8080, family: 1 + }, error => { + if (error) { console.log('bind fail'); } udp.on('message', (data) => { console.log(JSON.stringify(data)) }); - netHandle.bindSocket(udp,(error, data)=>{ + netHandle.bindSocket(udp, (error, data) => { if (error) { console.log(JSON.stringify(error)); } else { @@ -937,14 +1559,12 @@ connection.getDefaultNet().then((netHandle)=>{ }) ``` -### bindSocket +### bindSocket9+ bindSocket(socketParam: TCPSocket \| UDPSocket): Promise\; Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses a promise to return the result. -**Required permission**: ohos.permission.GET_NETWORK_INFO - **System capability**: SystemCapability.Communication.NetManager.Core **Parameters** @@ -959,56 +1579,60 @@ Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses | -------------- | ---------------------- | | Promise\ | Promise that returns no value.| +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + **Example** ```js import socket from "@ohos.net.socket"; -connection.getDefaultNet().then((netHandle)=>{ +connection.getDefaultNet().then((netHandle) => { var tcp = socket.constructTCPSocketInstance(); var udp = socket.constructUDPSocketInstance(); let socketType = "TCPSocket"; if (socketType == "TCPSocket") { tcp.bind({ - address: '192.168.xx.xxx', port: xxxx, family: 1 - }, err => { - if (err) { + address: '192.168.xx.xxx', port: 8080, family: 1 + }, error => { + if (error) { console.log('bind fail'); } - netHandle.bindSocket(tcp).then((err, data) => { - if (err) { - console.log(JSON.stringify(err)); - } else { - console.log(JSON.stringify(data)); - } + netHandle.bindSocket(tcp).then((data) => { + console.log(JSON.stringify(data)); + }).catch(error => { + console.log(JSON.stringify(error)); }) }) } else { let callback = value => { - console.log(TAG + "on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); + console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); } udp.on('message', callback); udp.bind({ - address: '192.168.xx.xxx', port: xxxx, family: 1 - }, err => { - if (err) { + address: '192.168.xx.xxx', port: 8080, family: 1 + }, error => { + if (error) { console.log('bind fail'); } udp.on('message', (data) => { console.log(JSON.stringify(data)); }) - netHandle.bindSocket(udp).then((err, data) => { - if (err) { - console.log(JSON.stringify(err)); - } else { - console.log(JSON.stringify(data)); - } + netHandle.bindSocket(udp).then((data) => { + console.log(JSON.stringify(data)); + }).catch(error => { + console.log(JSON.stringify(error)); }) }) } }) ``` - ### getAddressesByName getAddressesByName(host: string, callback: AsyncCallback\>): void @@ -1023,17 +1647,27 @@ Resolves the host name by using the corresponding network to obtain all IP addre | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------- | ---- | ------------------ | -| host | string | Yes | Host name to be resolved.| -| callback | AsyncCallback\> | Yes | Callback used to return the result. | +| host | string | Yes | Host name to resolve.| +| callback | AsyncCallback\> | Yes | Callback used to return the result. If all IP addresses are successfully obtained, **err** is **undefined**, and **data** is the list of all obtained IP addresses. Otherwise, **err** is an error object.| + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | **Example** ```js connection.getDefaultNet().then(function (netHandle) { let host = "xxxx"; - netHandle.getAddressesByName(host, function (error, addresses) { + netHandle.getAddressesByName(host, function (error, data) { console.log(JSON.stringify(error)) - console.log(JSON.stringify(addresses)) + console.log(JSON.stringify(data)) }) }) ``` @@ -1052,7 +1686,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------ | -| host | string | Yes | Host name to be resolved.| +| host | string | Yes | Host name to resolve.| **Return value** @@ -1060,13 +1694,23 @@ Resolves the host name by using the corresponding network to obtain all IP addre | ------------------------------------------- | ----------------------------- | | Promise\> | Promise used to return the result.| +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + **Example** ```js connection.getDefaultNet().then(function (netHandle) { let host = "xxxx"; - netHandle.getAddressesByName(host).then(function (addresses) { - console.log(JSON.stringify(addresses)) + netHandle.getAddressesByName(host).then(function (data) { + console.log(JSON.stringify(data)) }) }) ``` @@ -1085,17 +1729,27 @@ Resolves the host name by using the corresponding network to obtain the first IP | Name | Type | Mandatory| Description | | -------- | ----------------------------------------- | ---- | ------------------ | -| host | string | Yes | Host name to be resolved.| -| callback | AsyncCallback\<[NetAddress](#netaddress)> | Yes | Callback used to return the result. | +| host | string | Yes | Host name to resolve.| +| callback | AsyncCallback\<[NetAddress](#netaddress)> | Yes | Callback used to return the result. If the first IP address is obtained successfully, **err** is **undefined**, and **data** is the first obtained IP address. Otherwise, **err** is an error object. | + +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | **Example** ```js connection.getDefaultNet().then(function (netHandle) { let host = "xxxx"; - netHandle.getAddressByName(host, function (error, address) { + netHandle.getAddressByName(host, function (error, data) { console.log(JSON.stringify(error)) - console.log(JSON.stringify(address)) + console.log(JSON.stringify(data)) }) }) ``` @@ -1114,7 +1768,7 @@ Resolves the host name by using the corresponding network to obtain the first IP | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------ | -| host | string | Yes | Host name to be resolved.| +| host | string | Yes | Host name to resolve.| **Return value** @@ -1122,66 +1776,88 @@ Resolves the host name by using the corresponding network to obtain the first IP | ----------------------------------- | ------------------------------- | | Promise\<[NetAddress](#netaddress)> | Promise used to return the result.| +**Error codes** + +| ID| Error Message | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 2100001 | Invalid parameter value. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + **Example** ```js connection.getDefaultNet().then(function (netHandle) { let host = "xxxx"; - netHandle.getAddressByName(host).then(function (address) { - console.log(JSON.stringify(address)) + netHandle.getAddressByName(host).then(function (data) { + console.log(JSON.stringify(data)) }) }) ``` -## NetSpecifier +## NetCap -Provides an instance that bears data network capabilities. +Defines the network capability. **System capability**: SystemCapability.Communication.NetManager.Core -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| netCapabilities | [NetCapabilities](#netcapabilities) | Yes | Network transmission capabilities and bearer types of the data network. | -| bearerPrivateIdentifier | string | No | Network identifier. The identifier of a Wi-Fi network is **wifi**, and that of a cellular network is **slot0** (corresponding to SIM card 1).| +| Name | Value | Description | +| ------------------------ | ---- | ---------------------- | +| NET_CAPABILITY_MMS | 0 | The network can connect to the carrier's Multimedia Messaging Service Center (MMSC) to send and receive multimedia messages.| +| NET_CAPABILITY_NOT_METERED | 11 | The network traffic is not metered.| +| NET_CAPABILITY_INTERNET | 12 | The network has the Internet access capability, which is set by the network provider.| +| NET_CAPABILITY_NOT_VPN | 15 | The network does not use a virtual private network (VPN).| +| NET_CAPABILITY_VALIDATED | 16 | The Internet access capability of the network is successfully verified by the connection management module.| -## NetCapabilities +## NetBearType -Defines the network capability set. +Enumerates network types. **System capability**: SystemCapability.Communication.NetManager.Core -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| linkUpBandwidthKbps | number | No | Uplink (from the device to the network) bandwidth.| -| linkDownBandwidthKbps | number | No | Downlink (from the network to the device) bandwidth.| -| networkCap | Array<[NetCap](#netcap)> | No | Network capability. | -| bearerTypes | Array<[NetBearType](#netbeartype)> | Yes | Network type. | +| Name | Value | Description | +| --------------- | ---- | ----------- | +| BEARER_CELLULAR | 0 | Cellular network. | +| BEARER_WIFI | 1 | Wi-Fi network.| +| BEARER_ETHERNET | 3 | Ethernet network.| -## NetCap +## HttpProxy10+ -Defines the network capability. +Defines the global HTTP proxy configuration of the network. **System capability**: SystemCapability.Communication.NetManager.Core -| Name | Value | Description | -| ------------------------ | ---- | ---------------------- | -| NET_CAPABILITY_MMS | 0 | The network can connect to the carrier's Multimedia Messaging Service Center (MMSC) to send and receive multimedia messages.| -| NET_CAPABILITY_NOT_METERED | 11 | The network traffic is not metered.| -| NET_CAPABILITY_INTERNET | 12 | The network can connect to the Internet.| -| NET_CAPABILITY_NOT_VPN | 15 | The network does not use a Virtual Private Network (VPN).| -| NET_CAPABILITY_VALIDATED | 16 | The network is available. | +| Name | Type | Mandatory| Description | +| ------ | ------ | --- |------------------------- | +| host | string | No | Host name of the proxy server.| +| port | number | No | Host port.| +| exclusionList | Array | No | List of hosts that do not use the proxy server.| -## NetBearType +## NetSpecifier -Defines the network type. +Provides an instance that bears data network capabilities. **System capability**: SystemCapability.Communication.NetManager.Core -| Name | Value | Description | -| --------------- | ---- | ----------- | -| BEARER_CELLULAR | 0 | Cellular network | -| BEARER_WIFI | 1 | Wi-Fi network| -| BEARER_ETHERNET | 3 | Ethernet network| +| Name | Type | Mandatory | Description | +| ----------------------- | ----------------------------------- | ---- | ------------------------------------------------------------ | +| netCapabilities | [NetCapabilities](#netcapabilities) | Yes | Network transmission capabilities and bearer types of the data network. | +| bearerPrivateIdentifier | string | No | Network identifier. The identifier of a Wi-Fi network is **wifi**, and that of a cellular network is **slot0** (corresponding to SIM card 1).| + +## NetCapabilities + +Defines the network capability set. + +**System capability**: SystemCapability.Communication.NetManager.Core + +| Name | Type | Mandatory| Description | +| --------------------- | ---------------------------------- | --- | ------------------------ | +| linkUpBandwidthKbps | number | No| Uplink (from the device to the network) bandwidth. | +| linkDownBandwidthKbps | number | No| Downlink (from the network to the device) bandwidth. | +| networkCap | Array\<[NetCap](#netcap)> | No| Network capability. | +| bearerTypes | Array\<[NetBearType](#netbeartype)> | Yes| Network type. | ## ConnectionProperties @@ -1189,48 +1865,48 @@ Defines the network connection properties. **System capability**: SystemCapability.Communication.NetManager.Core -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| interfaceName | string | Yes | NIC card name. | -| domains | string | Yes | Domain. The default value is **""**.| -| linkAddresses | Array\<[LinkAddress](#linkaddress)> | Yes | Link information. | -| routes | Array\<[RouteInfo](#routeinfo)> | Yes | Route information. | -| dnses | Array\<[NetAddress](#netaddress)>; | Yes | Network address. For details, see [NetAddress](#netaddress).| -| mtu | number | Yes | Maximum transmission unit (MTU). | +| Name | Type | Mandatory| Description | +| ------------- | ---------------------------------- | ----|---------------- | +| interfaceName | string | Yes|Network interface card (NIC) name. | +| domains | string | Yes|Domain. The default value is **""**.| +| linkAddresses | Array\<[LinkAddress](#linkaddress)> | Yes|Link information. | +| routes | Array\<[RouteInfo](#routeinfo)> | Yes|Route information. | +| dnses | Array\<[NetAddress](#netaddress)> | Yes|Network address. For details, see [NetAddress](#netaddress).| +| mtu | number | Yes|Maximum transmission unit (MTU). | -## LinkAddress +## RouteInfo -Network link information. +Defines network route information. **System capability**: SystemCapability.Communication.NetManager.Core -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| address | [NetAddress](#netaddress) | Yes | Link address. | -| prefixLength | number | Yes | Length of the link address prefix.| +| Name | Type | Mandatory|Description | +| -------------- | --------------------------- | --- |---------------- | +| interface | string | Yes|NIC name. | +| destination | [LinkAddress](#linkaddress) | Yes|Destination address. | +| gateway | [NetAddress](#netaddress) | Yes|Gateway address. | +| hasGateway | boolean | Yes|Whether a gateway is present. | +| isDefaultRoute | boolean | Yes|Whether the route is the default route.| -## RouteInfo +## LinkAddress -Network route information. +Defines network link information. **System capability**: SystemCapability.Communication.NetManager.Core -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| interface | string | Yes | NIC card name. | -| destination | [LinkAddress](#linkaddress) | Yes | Destination IP address. | -| gateway | [NetAddress](#netaddress) | Yes | Gateway address. | -| hasGateway | boolean | Yes | Whether a gateway is present. | -| isDefaultRoute | boolean | Yes | Whether the route is the default route.| +| Name | Type | Mandatory|Description | +| ------------ | ----------------------- |---- |-------------------- | +| address | [NetAddress](#netaddress) | Yes| Link address. | +| prefixLength | number | Yes|Length of the link address prefix.| ## NetAddress -Defines the network address. +Defines a network address. **System capability**: SystemCapability.Communication.NetManager.Core -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| address | string | Yes | Network address. | -| family | number | Yes | Address family identifier. The value is **1** for IPv4 and **2** for IPv6. The default value is **1**.| -| port | number | No | Port number. The value ranges from **0** to **65535**. | +| Name | Type | Mandatory| Description | +| ------- | ------ | -- |------------------------------ | +| address | string | Yes|Network address. | +| family | number | No|Address family identifier. The value is **1** for IPv4 and **2** for IPv6. The default value is **1**.| +| port | number | No|Port number. The value ranges from **0** to **65535**. | diff --git a/en/application-dev/reference/apis/js-apis-net-ethernet.md b/en/application-dev/reference/apis/js-apis-net-ethernet.md index 3445952a9c818fad947373508accb50322e8cf59..d86e3904ec9c8789a645fde87492da5f5cd0c250 100644 --- a/en/application-dev/reference/apis/js-apis-net-ethernet.md +++ b/en/application-dev/reference/apis/js-apis-net-ethernet.md @@ -114,9 +114,9 @@ ethernet.setIfaceConfig("eth0", { dnsServers: "1.1.1.1", domain: "2.2.2.2" }).then(() => { - console.log("setIfaceConfig promiss ok "); + console.log("setIfaceConfig promise ok "); }).catch(error => { - console.log("setIfaceConfig promiss error = " + JSON.stringify(error)); + console.log("setIfaceConfig promise error = " + JSON.stringify(error)); }); ``` @@ -207,15 +207,15 @@ Obtains the configuration of a network interface. This API uses a promise to ret ```js ethernet.getIfaceConfig("eth0").then((data) => { - console.log("getIfaceConfig promiss mode = " + JSON.stringify(data.mode)); - console.log("getIfaceConfig promiss ipAddr = " + JSON.stringify(data.ipAddr)); - console.log("getIfaceConfig promiss route = " + JSON.stringify(data.route)); - console.log("getIfaceConfig promiss gateway = " + JSON.stringify(data.gateway)); - console.log("getIfaceConfig promiss netMask = " + JSON.stringify(data.netMask)); - console.log("getIfaceConfig promiss dnsServers = " + JSON.stringify(data.dnsServers)); - console.log("getIfaceConfig promiss domain = " + JSON.stringify(data.domain)); + console.log("getIfaceConfig promise mode = " + JSON.stringify(data.mode)); + console.log("getIfaceConfig promise ipAddr = " + JSON.stringify(data.ipAddr)); + console.log("getIfaceConfig promise route = " + JSON.stringify(data.route)); + console.log("getIfaceConfig promise gateway = " + JSON.stringify(data.gateway)); + console.log("getIfaceConfig promise netMask = " + JSON.stringify(data.netMask)); + console.log("getIfaceConfig promise dnsServers = " + JSON.stringify(data.dnsServers)); + console.log("getIfaceConfig promise domain = " + JSON.stringify(data.domain)); }).catch(error => { - console.log("getIfaceConfig promiss error = " + JSON.stringify(error)); + console.log("getIfaceConfig promise error = " + JSON.stringify(error)); }); ``` @@ -300,9 +300,9 @@ Checks whether a network interface is active. This API uses a promise to return ```js ethernet.isIfaceActive("eth0").then((data) => { - console.log("isIfaceActive promiss = " + JSON.stringify(data)); + console.log("isIfaceActive promise = " + JSON.stringify(data)); }).catch(error => { - console.log("isIfaceActive promiss error = " + JSON.stringify(error)); + console.log("isIfaceActive promise error = " + JSON.stringify(error)); }); ``` @@ -377,12 +377,12 @@ Obtains the list of all active network interfaces. This API uses a promise to re ```js ethernet.getAllActiveIfaces().then((data) => { - console.log("getAllActiveIfaces promiss data.length = " + JSON.stringify(data.length)); + console.log("getAllActiveIfaces promise data.length = " + JSON.stringify(data.length)); for (let i = 0; i < data.length; i++) { - console.log("getAllActiveIfaces promiss = " + JSON.stringify(data[i])); + console.log("getAllActiveIfaces promise = " + JSON.stringify(data[i])); } }).catch(error => { - console.log("getAllActiveIfaces promiss error = " + JSON.stringify(error)); + console.log("getAllActiveIfaces promise error = " + JSON.stringify(error)); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-observer.md b/en/application-dev/reference/apis/js-apis-observer.md index 2d56d02d2ec4e0f2117266569cb5bfd905f1b338..3c46e47479de6cacc6a0a2613f0aa422aad9aff8 100644 --- a/en/application-dev/reference/apis/js-apis-observer.md +++ b/en/application-dev/reference/apis/js-apis-observer.md @@ -10,7 +10,7 @@ The **observer** module provides event subscription management functions. You ca ## Modules to Import ``` -import observer from '@ohos.telephony.observer' +import observer from '@ohos.telephony.observer'; ``` ## observer.on('networkStateChange') @@ -31,7 +31,6 @@ Registers an observer for network status change events. This API uses an asynchr | callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | Yes | Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#networkstate).| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -45,7 +44,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('networkStateChange', data =>{ +observer.on('networkStateChange', data => { console.log("on networkStateChange, data:" + JSON.stringify(data)); }); ``` @@ -70,7 +69,6 @@ Registers an observer for network status change events of the SIM card in the sp | callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | Yes | Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#networkstate).| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -84,7 +82,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('networkStateChange', {slotId: 0}, data =>{ +observer.on('networkStateChange', {slotId: 0}, data => { console.log("on networkStateChange, data:" + JSON.stringify(data)); }); ``` @@ -145,7 +143,6 @@ Registers an observer for signal status change events. This API uses an asynchro | callback | Callback\> | Yes | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -159,7 +156,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('signalInfoChange', data =>{ +observer.on('signalInfoChange', data => { console.log("on signalInfoChange, data:" + JSON.stringify(data)); }); ``` @@ -182,7 +179,6 @@ Registers an observer for signal status change events of the SIM card in the spe | callback | Callback\> | Yes | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -196,7 +192,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('signalInfoChange', {slotId: 0}, data =>{ +observer.on('signalInfoChange', {slotId: 0}, data => { console.log("on signalInfoChange, data:" + JSON.stringify(data)); }); ``` @@ -222,7 +218,6 @@ Unregisters the observer for signal status change events. This API uses an async | callback | Callback\> | No | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -244,6 +239,125 @@ observer.off('signalInfoChange', callback); observer.off('signalInfoChange'); ``` +## observer.on('cellInfoChange')8+ + +on\(type: \'cellInfoChange\', callback: Callback\): void; + +Registers an observer for cell information change events. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------------- | ---- |------------------------------------------------------------| +| type | string | Yes | Cell information change event. This field has a fixed value of **cellInfoChange**. | +| callback | Callback\<[CellInformation](js-apis-radio.md#cellinformation8)\> | Yes | Callback used to return the result.| + +**Error codes** + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +observer.on('cellInfoChange', data => { + console.log("on cellInfoChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.on('cellInfoChange')8+ + +on\(type: \'cellInfoChange\', options: { slotId: number }, callback: Callback\): 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. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ |--------------------------------------------------| ---- |------------------------------------------------------------| +| type | string | Yes | Cell information change event. This field has a fixed value of **cellInfoChange**. | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| callback | Callback\<[CellInformation](js-apis-radio.md#cellinformation8)\> | Yes | Callback used to return the result.| + +**Error codes** + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +observer.on('cellInfoChange', {slotId: 0}, data => { + console.log("on cellInfoChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.off('cellInfoChange')8+ + +off\(type: \'cellInfoChange\', callback?: Callback\): void; + +Unregisters the observer for cell information change events. This API uses an asynchronous callback to return the result. + +>**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 API**: This is a system API. + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Cell information change event. This field has a fixed value of **cellInfoChange**. | +| callback | Callback\<[CellInformation](js-apis-radio.md#cellinformation8)\> | No | Callback used to return the result.| + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let callback = data => { + console.log("on cellInfoChange, data:" + JSON.stringify(data)); +} +observer.on('cellInfoChange', callback); +// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +observer.off('cellInfoChange', callback); +observer.off('cellInfoChange'); +``` ## observer.on('callStateChange') @@ -261,7 +375,6 @@ Registers an observer for call status change events. This API uses an asynchrono | callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | Yes | Callback function. For details, see [CallState](js-apis-call.md#callstate) in call.
**number**: phone number.| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -274,7 +387,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('callStateChange', value =>{ +observer.on('callStateChange', value => { console.log("on callStateChange, state:" + value.state + ", number:" + value.number); }); ``` @@ -297,7 +410,6 @@ Registers an observer for call status change events. This API uses an asynchrono | callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | Yes | Callback function. For details, see [CallState](js-apis-call.md#callstate) in call.
**number**: phone number.| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -310,7 +422,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('callStateChange', {slotId: 0}, value =>{ +observer.on('callStateChange', {slotId: 0}, value => { console.log("on callStateChange, state:" + value.state + ", number:" + value.number); }); ``` @@ -336,7 +448,6 @@ Unregisters the observer for call status change events. This API uses an asynchr | callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | No | Callback function. For details, see [CallState](js-apis-call.md#callstate) in call.
**number**: phone number.| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -375,7 +486,6 @@ Registers an observer for connection status change events of the cellular data l | 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).| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -388,7 +498,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('cellularDataConnectionStateChange', value =>{ +observer.on('cellularDataConnectionStateChange', value => { console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); }); ``` @@ -411,7 +521,6 @@ Registers an observer for connection status change events of the cellular data l | 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).| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -424,7 +533,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('cellularDataConnectionStateChange', {slotId: 0}, value =>{ +observer.on('cellularDataConnectionStateChange', {slotId: 0}, value => { console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); }); ``` @@ -450,7 +559,6 @@ Unregisters the observer for connection status change events of the cellular dat | 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).| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -489,7 +597,6 @@ Registers an observer for the uplink and downlink data flow status change events | callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | Yes | Callback used to return the result. For details, see [DataFlowType](js-apis-telephony-data.md#dataflowtype).| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -502,7 +609,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('cellularDataFlowChange', data =>{ +observer.on('cellularDataFlowChange', data => { console.log("on networkStateChange, data:" + JSON.stringify(data)); }); ``` @@ -525,7 +632,6 @@ Registers an observer for the uplink and downlink data flow status change events | callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | Yes | Callback used to return the result. For details, see [DataFlowType](js-apis-telephony-data.md#dataflowtype).| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -538,7 +644,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('cellularDataFlowChange', {slotId: 0}, data =>{ +observer.on('cellularDataFlowChange', {slotId: 0}, data => { console.log("on cellularDataFlowChange, data:" + JSON.stringify(data)); }); ``` @@ -564,7 +670,6 @@ Unregisters the observer for the uplink and downlink data flow status change eve | callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | No | Callback used to return the result. For details, see [DataFlowType](js-apis-telephony-data.md#dataflowtype).| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -603,7 +708,6 @@ Registers an observer for SIM card status change events. This API uses an asynch | callback | Callback\<[SimStateData](#simstatedata7)\> | Yes | Callback used to return the result.| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -616,7 +720,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('simStateChange', data =>{ +observer.on('simStateChange', data => { console.log("on simStateChange, data:" + JSON.stringify(data)); }); ``` @@ -639,7 +743,6 @@ Registers an observer for status change events of the SIM card in the specified | callback | Callback\<[SimStateData](#simstatedata7)\> | Yes | Callback used to return the result.| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -652,7 +755,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('simStateChange', {slotId: 0}, data =>{ +observer.on('simStateChange', {slotId: 0}, data => { console.log("on simStateChange, data:" + JSON.stringify(data)); }); ``` @@ -678,7 +781,6 @@ Unregisters the observer for SIM card status change events. This API uses an asy | callback | Callback\<[SimStateData](#simstatedata7)\> | No | Callback used to return the result.| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -732,6 +834,6 @@ Enumerates SIM card types and states. | Name | Type | Mandatory| Description | | ------------------- | ----------------------------------- | ---- | -------------------------------------------------------- | -| type | [CardType](js-apis-sim.md#cardtype) | Yes | SIM card type. For details, see [CardType](js-apis-sim.md#cardtype).| -| state | [SimState](js-apis-sim.md#simstate) | Yes | SIM card status. For details, see [SimState](js-apis-sim.md#simstate).| +| type | [CardType](js-apis-sim.md#cardtype7) | Yes | SIM card type.| +| state | [SimState](js-apis-sim.md#simstate) | Yes | SIM card state.| | reason8+ | [LockReason](#lockreason8) | Yes | SIM card lock type. | diff --git a/en/application-dev/reference/apis/js-apis-osAccount.md b/en/application-dev/reference/apis/js-apis-osAccount.md index 94a4257dfcc0af730c79334f61473c4811cb3bfd..692e834592970b9a7bdf92dc84a291c0fd2135a1 100644 --- a/en/application-dev/reference/apis/js-apis-osAccount.md +++ b/en/application-dev/reference/apis/js-apis-osAccount.md @@ -326,9 +326,9 @@ Checks whether the specified constraint is enabled for an OS account. This API u | ID| Error Message | | -------- | ------------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid localId. | -| 12300003 | Account not found. | +| 12300001 | system service exception. | +| 12300002 | invalid localId or constraint. | +| 12300003 | the account indicated by localId dose not exist. | **Example**: Check whether OS account 100 is forbidden to use Wi-Fi. @@ -376,9 +376,9 @@ Checks whether the specified constraint is enabled for an OS account. This API u | ID| Error Message | | -------- | ------------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid localId. | -| 12300003 | Account not found. | +| 12300001 | system service exception. | +| 12300002 | invalid localId or constraint. | +| 12300003 | the account indicated by localId dose not exist. | **Example**: Check whether OS account 100 is forbidden to use Wi-Fi. @@ -475,23 +475,19 @@ checkOsAccountVerified(callback: AsyncCallback<boolean>): void Checks whether this OS account has been verified. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS - **System capability**: SystemCapability.Account.OsAccount **Parameters** | Name | Type | Mandatory| Description | | -------- | ---------------------------- | ---- | ------------------------------------------------------------- | -| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the OS account has been verified; the value **false** means the opposite.| +| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If true is returned, the current account has been verified. If false is returned, the current account has not been verified.| **Error codes** | ID| Error Message | | -------- | ------------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid localId. | -| 12300003 | Account not found. | +| 12300001 | system service exception. | **Example** @@ -531,9 +527,9 @@ Checks whether an OS account has been verified. This API uses an asynchronous ca | ID| Error Message | | -------- | ------------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid localId. | -| 12300003 | Account not found. | +| 12300001 | system service exception. | +| 12300002 | invalid localId. | +| 12300003 | the account indicated by localId dose not exist. | **Example** @@ -555,7 +551,7 @@ Checks whether an OS account has been verified. This API uses an asynchronous ca ### checkOsAccountVerified9+ -checkOsAccountVerified(localId?: number): Promise<boolean> +checkOsAccountVerified(localId: number): Promise<boolean> Checks whether an OS account has been verified. This API uses a promise to return the result. @@ -567,7 +563,7 @@ Checks whether an OS account has been verified. This API uses a promise to retur | Name | Type | Mandatory| Description | | ------- | ------ | ---- | --------------------------------------------------------------- | -| localId | number | No | ID of the target OS account. If this parameter is not specified, this API checks whether the current OS account has been verified.| +| localId | number | Yes | ID of the target OS account. If this parameter is not specified, this API checks whether the current OS account has been verified.| **Return value** @@ -579,9 +575,9 @@ Checks whether an OS account has been verified. This API uses a promise to retur | ID| Error Message | | -------- | ------------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid localId. | -| 12300003 | Account not found. | +| 12300001 | system service exception. | +| 12300002 | invalid localId. | +| 12300003 | the account indicated by localId dose not exist. | **Example** @@ -991,7 +987,7 @@ Obtains the ID of the OS account to which the current process belongs. This API | ID| Error Message | | -------- | ------------------- | -| 12300001 | System service exception. | +| 12300001 | system service exception. | **Example** @@ -1028,7 +1024,7 @@ Obtains the ID of the OS account to which the current process belongs. This API | ID| Error Message | | -------- | ------------------- | -| 12300001 | System service exception. | +| 12300001 | system service exception. | **Example** @@ -1064,8 +1060,8 @@ Obtains the OS account ID based on the process UID. This API uses an asynchronou | ID| Error Message | | -------- | --------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid uid. | +| 12300001 | system service exception. | +| 12300002 | invalid uid. | **Example**: Obtain the ID of the OS account whose process UID is **12345678**. @@ -1108,8 +1104,8 @@ Obtains the OS account ID based on the process UID. This API uses a promise to r | ID| Error Message | | -------- | ------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid uid. | +| 12300001 | system service exception. | +| 12300002 | invalid uid. | **Example**: Obtain the ID of the OS account whose process UID is **12345678**. @@ -1148,8 +1144,8 @@ Obtains the OS account ID based on the domain account information. This API uses | ID| Error Message | | -------- | ------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid domainInfo. | +| 12300001 | system service exception. | +| 12300002 | invalid domainInfo. | **Example** @@ -1195,8 +1191,8 @@ Obtains the OS account ID based on the domain account information. This API uses | ID| Error Message | | -------- | ------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid domainInfo. | +| 12300001 | system service exception. | +| 12300002 | invalid domainInfo. | **Example** @@ -1474,7 +1470,7 @@ Obtains information about all activated OS accounts. This API uses an asynchrono | ID| Error Message | | -------- | ------------- | -| 12300001 | System service exception. | +| 12300001 | system service exception. | **Example** @@ -1511,7 +1507,7 @@ Obtains information about all activated OS accounts. This API uses a promise to | ID| Error Message | | -------- | ------------- | -| 12300001 | System service exception. | +| 12300001 | system service exception. | **Example** @@ -2233,9 +2229,9 @@ Obtains the OS account ID based on the serial number (SN). This API uses an asyn | ID| Error Message | | -------- | ------------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid serialNumber. | -| 12300003 | Account not found. | +| 12300001 | system service exception. | +| 12300002 | invalid serialNumber. | +| 12300003 | the account indicated by serialNumber dose not exist. | **Example**: Obtain the ID of the OS account whose SN is 12345. @@ -2276,9 +2272,9 @@ Obtains the OS account ID based on the SN. This API uses a promise to return the | ID| Error Message | | -------- | ------------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid serialNumber. | -| 12300003 | Account not found. | +| 12300001 | system service exception. | +| 12300002 | invalid serialNumber. | +| 12300003 | the account indicated by serialNumber dose not exist. | **Example**: Obtain the ID of the OS account whose SN is 12345. @@ -2315,9 +2311,9 @@ Obtains the SN of an OS account based on the account ID. This API uses an asynch | ID| Error Message | | -------- | ------------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid localId. | -| 12300003 | Account not found. | +| 12300001 | system service exception. | +| 12300002 | invalid localId. | +| 12300003 | the account indicated by localId dose not exist. | **Example**: Obtain the SN of the OS account 100. @@ -2358,9 +2354,9 @@ Obtains the SN of an OS account based on the account ID. This API uses a promise | ID| Error Message | | -------- | ------------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid localId. | -| 12300003 | Account not found. | +| 12300001 | system service exception. | +| 12300002 | invalid localId. | +| 12300003 | the account indicated by localId dose not exist. | **Example**: Obtain the SN of the OS account 100. @@ -2483,8 +2479,8 @@ Obtains the bundle ID based on the UID. This API uses an asynchronous callback t | ID| Error Message | | -------- | ------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid uid. | +| 12300001 | system service exception. | +| 12300002 | invalid uid. | **Example** @@ -2526,8 +2522,8 @@ Obtains the bundle ID based on the UID. This API uses a promise to return the re | ID| Error Message | | -------- | ------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid uid. | +| 12300001 | system service exception. | +| 12300002 | invalid uid. | **Example** @@ -2644,9 +2640,9 @@ Obtains the constraint source information of an OS account. This API uses an asy | ID| Error Message | | -------- | ------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid localId or constraint. | -| 12300003 | Account not found. | +| 12300001 | system service exception. | +| 12300002 | invalid name or constraint. | +| 12300003 | the account indicated by localId dose not exist. | **Example** @@ -2691,9 +2687,9 @@ Obtains the constraint source information of an OS account. This API uses a prom | ID| Error Message | | -------- | ------------- | -| 12300001 | System service exception. | -| 12300002 | Invalid localId or constraint. | -| 12300003 | Account not found. | +| 12300001 | system service exception. | +| 12300002 | invalid name or constraint. | +| 12300003 | the account indicated by localId dose not exist. | **Example** @@ -4433,15 +4429,26 @@ Authenticates a domain account. **Example** ```js let plugin = { - auth: (domainInfo, credential, callback) => { + auth: (domainAccountInfo, credential, callback) => { // mock authentication - callback.onResult(0, {}); - } + // notify authentication result + callback.onResult(0, { + token: new Uint8Array([0]), + remainTimes: 5, + freezingTime: 0 + }); + }, + authWithPopup: (domainAccountInfo, callback) => {}, + authWithToken: (domainAccountInfo, callback) => {}, + getAccountInfo: (domain, accountName, callback) => {}, + getAuthStatusInfo: (domainAccountInfo, callback) => {}, + bindAccount: (domainAccountInfo, localId, callback) => {}, + unbindAccount: (domainAccountInfo, callback) => {} } account_osAccount.DomainAccountManager.registerPlugin(plugin); let userAuth = new account_osAccount.UserAuth(); let challenge = new Uint8Array([0]); - let authType = account_osAccount.AuthType.PIN; + let authType = account_osAccount.AuthType.DOMAIN; let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; try { userAuth.auth(challenge, authType, authTrustLevel, { @@ -4455,6 +4462,235 @@ Authenticates a domain account. } ``` +### authWithPopup10+ + +authWithPopup(domainAccountInfo: DomainAccountInfo, callback: IUserAuthCallback): void + +Authenticates a domain account in a pop-up window. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------------- | ---- | --------------- | +| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information.| +| callback | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback invoked to return the authentication result.| + +**Example** + ```js + let plugin = { + auth: (domainAccountInfo, credential, callback) => {}, + authWithPopup: (domainAccountInfo, callback) => { + // mock authentication + // notify authentication result + callback.onResult(0, { + token: new Uint8Array([0]), + remainTimes: 5, + freezingTime: 0 + }); + }, + authWithToken: (domainAccountInfo, callback) => {}, + getAccountInfo: (domain, accountName, callback) => {}, + getAuthStatusInfo: (domainAccountInfo, callback) => {}, + bindAccount: (domainAccountInfo, localId, callback) => {}, + unbindAccount: (domainAccountInfo, callback) => {} + } + account_osAccount.DomainAccountManager.registerPlugin(plugin) + ``` + +### authWithToken10+ + +authWithToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback: IUserAuthCallback): void + +Authenticates a domain account by the authorization token. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------------- | ---- | --------------- | +| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information.| +| token | Uint8Array | Yes | Authorization token generated when the PIN or biometric authentication is successful.| +| callback | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback invoked to return the authentication result.| + +**Example** + ```js + let plugin = { + auth: (domainAccountInfo, credential, callback) => {}, + authWithPopup: (domainAccountInfo, callback) => {}, + authWithToken: (domainAccountInfo, callback) => { + // mock authentication + // notify authentication result + callback.onResult(0, { + token: new Uint8Array([0]), + remainTimes: 5, + freezingTime: 0 + }); + }, + getAccountInfo: (domain, accountName, callback) => {}, + getAuthStatusInfo: (domainAccountInfo, callback) => {}, + bindAccount: (domainAccountInfo, localId, callback) => {}, + unbindAccount: (domainAccountInfo, callback) => {} + } + account_osAccount.DomainAccountManager.registerPlugin(plugin) + ``` + +### getAccountInfo10+ + +getAccountInfo(domain: string, accountName: string, callback: AsyncCallback<DomainAccountInfo>): void + +Obtains information about a domain account. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------------- | ---- | --------------- | +| domain | string | Yes | Domain to which the account belongs.| +| accountName | string | Yes | Name of the account.| +| callback | AsyncCallback<[DomainAccountInfo](#domainaccountinfo8)> | Yes | Callback invoked to return the result.| + +**Example** + ```js + let plugin = { + auth: (domainAccountInfo, credential, callback) => {}, + authWithPopup: (domainAccountInfo, callback) => {}, + authWithToken: (domainAccountInfo, callback) => {}, + getAccountInfo: (domain, accountName, callback) => { + // mock getting account information + // notify result + callback({ + code: 0 + }, { + domain: domain, + accountName: accountName, + accountId: "xxxx" + }) + }, + getAuthStatusInfo: (domainAccountInfo, callback) => {}, + bindAccount: (domainAccountInfo, localId, callback) => {}, + unbindAccount: (domainAccountInfo, callback) => {} + } + account_osAccount.DomainAccountManager.registerPlugin(plugin) + ``` + +### getAuthStatusInfo10+ + +getAuthStatusInfo(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback<AuthStatusInfo>): void + +Obtains the authentication status of a domain account. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------------- | ---- | --------------- | +| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information.| +| callback | AsyncCallback<[AuthStatusInfo](#authstatusinfo10)> | Yes | Callback invoked to return the result.| + +**Example** + ```js + let plugin = { + auth: (domainAccountInfo, credential, callback) => {}, + authWithPopup: (domainAccountInfo, callback) => {}, + authWithToken: (domainAccountInfo, callback) => {}, + getAccountInfo: (domain, accountName, callback) => {}, + getAuthStatusInfo: (domainAccountInfo, callback) => { + callback({ + code: 0 + }, { + remainTimes: 5, + freezingTime: 0 + }) + }, + bindAccount: (domainAccountInfo, localId, callback) => {}, + unbindAccount: (domainAccountInfo, callback) => {} + } + account_osAccount.DomainAccountManager.registerPlugin(plugin) + ``` + +### bindAccount10+ + +bindAccount(domainAccountInfo: DomainAccountInfo, localId: number, callback: AsyncCallback<void>): void + +Binds a domain account. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------------- | ---- | --------------- | +| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result.| + +**Example** + ```js + let plugin = { + auth: (domainAccountInfo, credential, callback) => {}, + authWithPopup: (domainAccountInfo, callback) => {}, + authWithToken: (domainAccountInfo, callback) => {}, + getAccountInfo: (domain, accountName, callback) => {}, + getAuthStatusInfo: (domainAccountInfo, callback) => {}, + bindAccount: (domainAccountInfo, localId, callback) => { + // mock unbinding operation + // notify binding result + callback({code: 0}) + }, + unbindAccount: (domainAccountInfo, callback) => {} + } + account_osAccount.DomainAccountManager.registerPlugin(plugin) + ``` + +### unbindAccount10+ + +unbindAccount(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback<void>): void + +Unbinds a domain account. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Account.OsAccount + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------------- | ---- | --------------- | +| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result.| + +**Example** + ```js + let plugin = { + auth: (domainAccountInfo, credential, callback) => {}, + authWithPopup: (domainAccountInfo, callback) => {}, + authWithToken: (domainAccountInfo, callback) => {}, + getAccountInfo: (domain, accountName, callback) => {}, + getAuthStatusInfo: (domainAccountInfo, callback) => {}, + bindAccount: (domainAccountInfo, localId, callback) => {}, + unbindAccount: (domainAccountInfo, callback) => { + // mock unbinding operation + // notify unbinding result + callback({code: 0}) + } + } + account_osAccount.DomainAccountManager.registerPlugin(plugin) + ``` + ## DomainAccountManager 9+ Provides APIs for domain account management. @@ -4480,15 +4716,18 @@ Registers a domain plug-in. | ID| Error Message | | -------- | --------------------------- | -| 12300201 | The domain plugin has been registered. | +| 12300201 | the domain plugin has been registered. | **Example** ```js let plugin = { - auth: (domainInfo, credential, callback) => { - // mock authentication - callback.onResult(0, {}); - } + auth: (domainAccountInfo, credential, callback) => {}, + authWithPopup: (domainAccountInfo, callback) => {}, + authWithToken: (domainAccountInfo, callback) => {}, + getAccountInfo: (domain, accountName, callback) => {}, + getAuthStatusInfo: (domainAccountInfo, callback) => {}, + bindAccount: (domainAccountInfo, localId, callback) => {}, + unbindAccount: (domainAccountInfo, callback) => {} } try { account_osAccount.DomainAccountManager.registerPlugin(plugin); @@ -4520,6 +4759,252 @@ Unregisters this domain plug-in. } ``` +### auth10+ + +auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUserAuthCallback): void + +Authenticates a domain account. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Account.OsAccount + +**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------------- | ---- | --------------- | +| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information.| +| credential | Uint8Array | Yes | Credentials of the domain account.| +| callback | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback invoked to return the authentication result.| + +**Error codes** + +| ID| Error Message | +| -------- | --------------------------- | +| 12300001 | system service exception. | +| 12300002 | invalid domainAccountInfo or credential. | +| 12300003 | domain account does not exist. | +| 12300013 | network exception. | +| 12300101 | authentication failed. | +| 12300109 | authentication is canceled. | +| 12300110 | authentication is locked. | +| 12300111 | authentication timeout. | +| 12300112 | authentication service is busy. | +| 12300113 | authentication service does not exist. | +| 12300114 | authentication service exception. | + +**Example** + ```js + let domainAccountInfo = { + domain: "CHINA", + accountName: "zhangsan" + } + let credential = new Uint8Array([0]) + try { + account_osAccount.DomainAccountManager.auth(domainAccountInfo, credential, { + onResult: (resultCode, authResult) => { + console.log('auth resultCode = ' + resultCode); + console.log('auth authResult = ' + JSON.stringify(authResult)); + } + }); + } catch (err) { + console.log('auth exception = ' + JSON.stringify(err)); + } + ``` + +### authWithPopup10+ + +authWithPopup(callback: IUserAuthCallback): void + +Authenticates this domain account in a pop-up window. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Account.OsAccount + +**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------------- | ---- | --------------- | +| callback | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback invoked to return the authentication result.| + +**Error codes** + +| ID| Error Message | +| -------- | --------------------------- | +| 12300001 | system service exception. | +| 12300003 | no domain account is bound. | +| 12300013 | network exception. | +| 12300101 | authentication failed. | +| 12300109 | authentication is canceled. | +| 12300110 | authentication is locked. | +| 12300111 | authentication timeout. | +| 12300112 | authentication service is busy. | +| 12300113 | authentication service does not exist. | +| 12300114 | authentication service exception. | + +**Example** + ```js + try { + account_osAccount.DomainAccountManager.authWithPopup({ + onResult: (resultCode, authResult) => { + console.log('auth resultCode = ' + resultCode); + console.log('auth authResult = ' + JSON.stringify(authResult)); + } + }) + } catch (err) { + console.log('auth exception = ' + JSON.stringify(err)); + } + ``` + +### authWithPopup10+ + +authWithPopup(localId: number, callback: IUserAuthCallback): void + +Authenticates a domain account in a pop-up window. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Account.OsAccount + +**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------------- | ---- | --------------- | +| localId | number | Yes | Local ID of the OS account bound to the domain account.| +| callback | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback invoked to return the authentication result.| + +**Error codes** + +| ID| Error Message | +| -------- | --------------------------- | +| 12300001 | system service exception. | +| 12300002 | invalid localId. | +| 12300003 | no domain account is bound. | +| 12300013 | network exception. | +| 12300101 | authentication failed. | +| 12300109 | authentication is canceled. | +| 12300110 | authentication is locked. | +| 12300111 | authentication timeout. | +| 12300112 | authentication service is busy. | +| 12300113 | authentication service does not exist. | +| 12300114 | authentication service exception. | + +**Example** + ```js + try { + account_osAccount.DomainAccountManager.authWithPopup(100, { + onResult: (resultCode, authResult) => { + console.log('authWithPopup resultCode = ' + resultCode); + console.log('authWithPopup authResult = ' + JSON.stringify(authResult)); + } + }) + } catch (err) { + console.log('authWithPopup exception = ' + JSON.stringify(err)); + } + ``` + +### hasAccount10+ + +hasAccount(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback<boolean>): void + +Checks whether a domain account exists. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Account.OsAccount + +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------------- | ---- | --------------- | +| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information.| +| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result.| + +**Error codes** + +| ID| Error Message | +| -------- | --------------------------- | +| 12300001 | system service exception. | +| 12300002 | invalid domainAccountInfo. | +| 12300013 | network exception. | + +**Example** + ```js + let domainAccountInfo = { + domain: "CHINA", + accountName: "zhangsan" + } + try { + account_osAccount.DomainAccountManager.hasAccount(domainAccountInfo, (err, result) => { + if (err) { + console.log("call hasAccount failed, error: " + JSON.stringify(err)); + } else { + console.log("hasAccount result: " + result); + } + }); + } catch (err) { + console.log('hasAccount exception = ' + JSON.stringify(err)); + } + ``` + +### hasAccount10+ + +hasAccount(domainAccountInfo: DomainAccountInfo): Promise<boolean> + +Checks whether a domain account exists. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Account.OsAccount + +**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------------- | ---- | --------------- | +| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information.| + +**Return value** + +| Type | Description | +| :------------------------ | ----------------------- | +| Promise<boolean> | Promise used to return the result.| + +**Error codes** + +| ID| Error Message | +| -------- | --------------------------- | +| 12300001 | system service exception. | +| 12300002 | invalid domainAccountInfo. | +| 12300013 | network exception. | + +**Example** + ```js + let domainAccountInfo = { + domain: "CHINA", + accountName: "zhangsan" + } + try { + account_osAccount.DomainAccountManager.hasAccount(domainAccountInfo).then((result) => { + console.log("hasAccount result: " + result); + }).catch((err) => { + console.log("call hasAccount failed, error: " + JSON.stringify(err)); + }); + } catch (err) { + console.log('hasAccount exception = ' + JSON.stringify(err)); + } + ``` + ## UserIdentityManager8+ Provides APIs for user identity management (IDM). @@ -5254,7 +5739,7 @@ Defines the executor property. | ------------ | ---------------------------------------- | ----- | ----------------- | | result | number | Yes | Result. | | authSubType | [AuthSubType](#authsubtype8) | Yes | Authentication credential subtype.| -| remainTimes | number | No | Remaining time. | +| remainTimes | number | No | Number of remaining authentication times. | | freezingTime | number | No | Freezing time. | ## AuthResult8+ @@ -5268,7 +5753,7 @@ Defines the authentication result information. | Name | Type | Mandatory | Description | | ------------ | ----------- | ----- | ----------------- | | token | Uint8Array | No | Authentication token. | -| remainTimes | number | No | Remaining time. | +| remainTimes | number | No | Number of remaining authentication times. | | freezingTime | number | No | Freezing time. | ## CredentialInfo8+ @@ -5351,7 +5836,7 @@ Enumerates the authentication credential types. | PIN | 1 | PIN authentication.| | FACE | 2 | Facial authentication.| | FINGERPRINT10+ | 4 | Fingerprint authentication.| -| DOMAIN10+ | 1024 | Domain authentication.| +| DOMAIN9+ | 1024 | Domain authentication.| ## AuthSubType8+ @@ -5368,7 +5853,7 @@ Enumerates the authentication credential subtypes. | PIN_MIXED | 10002 | Custom mixed credentials.| | FACE_2D | 20000 | 2D face credential. | | FACE_3D | 20001 | 3D face credential. | -| DOMAIN_MIXED10+ | 10240001 | Mixed domain authentication credentials. | +| DOMAIN_MIXED9+ | 10240001 | Mixed domain authentication credentials. | ## AuthTrustLevel8+ @@ -5490,6 +5975,7 @@ Defines the domain account information. | ----------- | ------ | ---- | ---------- | | domain | string | Yes | Domain name. | | accountName | string | Yes | Domain account name.| +| accountId10+ | string | No | Domain account ID.| ## Constraints @@ -5586,3 +6072,16 @@ Enumerates the constraint sources. | CONSTRAINT_TYPE_BASE | 1 | Constraint from system settings. | | CONSTRAINT_TYPE_DEVICE_OWNER | 2 | Constraint from the device owners' settings. | | CONSTRAINT_TYPE_PROFILE_OWNER | 3 | Constraint from the profile owners' settings. | + +## AuthStatusInfo10+ + +Presents the authentication status information. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Account.OsAccount + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ---------- | +| remainTimes | number | Yes | Number of remaining authentication times. | +| freezingTime | number | Yes | Freezing time.| diff --git a/en/application-dev/reference/apis/js-apis-overlay.md b/en/application-dev/reference/apis/js-apis-overlay.md new file mode 100644 index 0000000000000000000000000000000000000000..61181d1767aeb33951b983163b376478cf3d1f36 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-overlay.md @@ -0,0 +1,693 @@ +# @ohos.bundle.overlay (overlay) + +The **overlay** module provides APIs for installing a [module with the overlay feature](#module-with-the-overlay-feature), querying the [module information](js-apis-bundleManager-overlayModuleInfo.md), and disabling and enabling the module. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> The APIs provided by this module are system APIs. + +## Modules to Import + +``` ts +import overlay from '@ohos.bundle.overlay' +``` + +## overlay.setOverlayEnabled + +setOverlayEnabled(moduleName:string, isEnabled: boolean): Promise\; + +Enables or disables a module with the overlay feature in the current application. This API uses a promise to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| moduleName | string | Yes | HAP name of the module with the overlay feature. | +| isEnabled | boolean | Yes | Whether to enable the module with the overlay feature. The value **true** means to enable the module, and **false** means to disable the module.| + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\ | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700002 | The specified moduleName is not existed. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var moduleName = "feature"; +var isEnabled = false; + +try { + overlay.setOverlayEnabled(moduleName, isEnabled) + .then(() => { + console.info('setOverlayEnabled success'); + }).catch((error) => { + console.info('setOverlayEnabled failed due to error code: ' + err.code + ' ' + 'message:' + err.message); + }); +} catch (error) { + console.info('setOverlayEnabled failed due to error code: ' + err.code + ' ' + 'message:' + err.message); +} +``` + +## overlay.setOverlayEnabled + +setOverlayEnabled(moduleName:string, isEnabled: boolean, callback: AsyncCallback\): void; + +Enables or disables a module with the overlay feature in the current application. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| moduleName | string | Yes | HAP name of the module with the overlay feature. | +| isEnabled | boolean | Yes | Whether to enable the module with the overlay feature. The value **true** means to enable the module, and **false** means to disable the module.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700002 | The specified moduleName is not existed. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var moduleName = "feature"; +var isEnabled = false; + +try { + overlay.setOverlayEnabled(moduleName, isEnabled, (error, data) => { + if (error) { + console.info('setOverlayEnabled failed due to error code: ' + err.code + ' ' + 'message:' + err.message); + return; + } + console.info('setOverlayEnabled success'); + }); +} catch (error) { + console.info('setOverlayEnabled failed due to error code: ' + err.code + ' ' + 'message:' + err.message); +} +``` + +## overlay.setOverlayEnabledByBundleName + +setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: boolean): Promise\; + +Enables or disables a module with the overlay feature in another application. This API uses a promise to return the result. If the operation is successful, the processing result is returned; otherwise, an error message is returned. + +**Required permissions**: ohos.permission.CHANGE_OVERLAY_ENABLED_STATE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**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 the application. | +| moduleName | string | Yes | HAP name of the module with the overlay feature. | +| isEnabled | boolean | Yes | Whether to enable the module with the overlay feature. The value **true** means to enable the module, and **false** means to disable the module.| + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\ | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700002 | The specified moduleName is not existed. | +| 17700032 | The specified bundleName does not contain any overlay module. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var bundleName = "com.example.myapplication_xxxxx"; +var moduleName = "feature" +var isEnabled = false; + +try { + overlay.setOverlayEnabledByBundleName(bundleName, moduleName, isEnabled) + .then((data) => { + console.info('setOverlayEnabledByBundleName successfully'); + }).catch((error) => { + console.info('setOverlayEnabledByBundleName failed due to error code: ' + err.code + ' ' + 'message:' + err.message); + }); +} catch (error) { + console.info('setOverlayEnabledByBundleName failed due to error code: ' + err.code + ' ' + 'message:' + err.message); +} +``` + +## overlay.setOverlayEnabledByBundleName + +setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: boolean, callback: AsyncCallback\): void; + +Enables or disables a module with the overlay feature in another application. This API uses an asynchronous callback to return the result. If the operation is successful, the processing result is returned; otherwise, an error message is returned. + +**Required permissions**: ohos.permission.CHANGE_OVERLAY_ENABLED_STATE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**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 the application. | +| moduleName | string | Yes | HAP name of the module with the overlay feature. | +| isEnabled | boolean | Yes | Whether to enable the module with the overlay feature. The value **true** means to enable the module, and **false** means to disable the module.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the processing result obtained; otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700002 | The specified moduleName is not existed. | +| 17700032 | The specified bundleName does not contain any overlay module. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var bundleName = "com.example.myapplication_xxxxx"; +var moduleName = "feature" +var isEnabled = false; + +try { + overlay.setOverlayEnabledByBundleName(bundleName, moduleName, isEnabled, (error, data) => { + if (error) { + console.info('setOverlayEnabledByBundleName failed due to error code: ' + err.code + ' ' + 'message:' + err.message); + return; + } + console.info('setOverlayEnabledByBundleName successfully'); + }); +} catch (error) { + console.info('setOverlayEnabledByBundleName failed due to error code: ' + err.code + ' ' + 'message:' + err.message); +} +``` + +## overlay.getOverlayModuleInfo + +getOverlayModuleInfo(moduleName: string): Promise\; + +Obtains the information about a module with the overlay feature in the current application. This API uses a promise to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | ------------------------------------------ | +| moduleName | string | Yes | HAP name of the module with the overlay feature. | + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\ | Promise used to return the result, which is an **OverlayModuleInfo** object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700002 | The specified moduleName is not existed. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var moduleName = "feature" + +(async() => { + try { + let overlayModuleInfo = await overlay.getOverlayModuleInfo(moduleName); + console.log('overlayModuleInfo is ' + JSON.stringify(overlayModuleInfo)); + } catch(err) { + console.log('getOverlayModuleInfo failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + } +})(); +``` + +## overlay.getOverlayModuleInfo + +getOverlayModuleInfo(moduleName: string, callback: AsyncCallback\): void; + +Obtains the information about a module with the overlay feature in the current application. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| moduleName | string | Yes | HAP name of the module with the overlay feature. | +| callback | AsyncCallback\ | Yes | Callback used to return the result, which is an **OverlayModuleInfo** object. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700002 | The specified moduleName is not existed. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var moduleName = "feature" +try { + overlay.getOverlayModuleInfo(moduleName, (error, data) => { + if (error) { + console.log('getOverlayModuleInfo failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + return; + } + console.log('overlayModuleInfo is ' + JSON.stringify(data)); + }); +} catch (error) { + console.log('getOverlayModuleInfo failed due to error code : ' + err.code + ' ' + 'message :' + err.message); +} +``` + +## overlay.getTargetOverlayModuleInfos + +getTargetOverlayModuleInfos(targetModuleName: string): Promise\>; + +Obtains the information about modules with the overlay feature in the current application based on the target module name. This API uses a promise to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| targetModuleName | string | Yes | HAP name of the target module, which is **targetModuleName** specified by modules with the overlay feature. | + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\> | Promise used to return the result, which is an array of **OverlayModuleInfo** objects.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700002 | The specified moduleName is not existed. | +| 17700034 | The specified moduleName is overlay module. | + +**Example** + +```ts +var targetModuleName = "feature" + +(async() => { + try { + let overlayModuleInfos = await overlay.getTargetOverlayModuleInfos(targetModuleName); + console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos)); + } catch(err) { + console.log('getTargetOverlayModuleInfos failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + } +})(); +``` + +## overlay.getTargetOverlayModuleInfos + +getTargetOverlayModuleInfos(targetModuleName: string, callback: AsyncCallback\>): void; + +Obtains the information about modules with the overlay feature in the current application based on the target module name. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| targetModuleName | string | Yes | HAP name of the target module specified by modules with the overlay feature. | +| callback | AsyncCallback\> | Yes | Callback used to return the result, which is an array of **OverlayModuleInfo** objects. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700002 | The specified moduleName is not existed. | +| 17700034 | The specified moduleName is overlay module. | + +**Example** + +```ts +var targetModuleName = "feature" +try { + overlay.getTargetOverlayModuleInfos(targetModuleName, (error, data) => { + if (error) { + console.log('getTargetOverlayModuleInfos failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + return; + } + console.log('overlayModuleInfo is ' + JSON.stringify(data)); + }); +} catch (error) { + console.log('getTargetOverlayModuleInfos failed due to error code : ' + err.code + ' ' + 'message :' + err.message); +} +``` + +## overlay.getOverlayModuleInfoByBundleName + +getOverlayModuleInfoByBundleName(bundleName: string, moduleName?: string): Promise\>; + +Obtains the information about a module with the overlay feature in another application. This API uses a promise to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**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 the application. | +| moduleName | string | No | HAP name of the module with the overlay feature. If this parameter is not specified, the API obtains the information of all modules with the overlay feature in that application. | + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\> | Promise used to return the result, which is an array of **OverlayModuleInfo** objects.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found | +| 17700002 | The specified moduleName is not existed. | +| 17700032 | The specified bundleName does not contain any overlay module. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var bundleName = "com.example.myapplication_xxxxx"; +var moduleName = "feature" + +(async() => { + try { + let overlayModuleInfos = await overlay.getOverlayModuleInfoByBundleName(bundleName, moduleName); + console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos)); + } catch(err) { + console.log('getTargetOverlayModuleInfos failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + } +})(); +``` + +## overlay.getOverlayModuleInfoByBundleName + +getOverlayModuleInfoByBundleName(bundleName: string, moduleName: string, callback: AsyncCallback\>): void; + +Obtains the information about a module with the overlay feature in another application. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**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 the application. | +| moduleName | string | Yes | HAP name of the module with the overlay feature. If this parameter is not specified, the API obtains the information of all modules with the overlay feature in that application. | +| callback | AsyncCallback\> | Yes | Callback used to return the result, which is an array of **OverlayModuleInfo** objects. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found | +| 17700002 | The specified moduleName is not existed. | +| 17700032 | The specified bundleName does not contain any overlay module. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var bundleName = "com.example.myapplication_xxxxx"; +var moduleName = "feature" + +try { + overlay.getOverlayModuleInfoByBundleName(bundleName, moduleName, (error, data) => { + if (error) { + console.log('getOverlayModuleInfoByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + return; + } + console.log('overlayModuleInfo is ' + JSON.stringify(data)); + }); +} catch (error) { + console.log('getOverlayModuleInfoByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); +} +``` + +## overlay.getOverlayModuleInfoByBundleName + +getOverlayModuleInfoByBundleName(bundleName: string, callback: AsyncCallback\>): void; + +Obtains the information about all modules with the overlay feature in another application. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**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 the application. | +| callback | AsyncCallback\> | Yes | Callback used to return the result, which is an array of **OverlayModuleInfo** objects. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found | +| 17700002 | The specified moduleName is not existed. | +| 17700032 | The specified bundleName does not contain any overlay module. | +| 17700033 | The specified moduleName is not overlay module. | + +**Example** + +```ts +var bundleName = "com.example.myapplication_xxxxx"; + +try { + overlay.getOverlayModuleInfoByBundleName(bundleName, (error, data) => { + if (error) { + console.log('getOverlayModuleInfoByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + return; + } + console.log('overlayModuleInfo is ' + JSON.stringify(data)); + }); +} catch (error) { + console.log('getOverlayModuleInfoByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); +} +``` + +## overlay.getTargetOverlayModuleInfosByBundleName + +getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName?: string): Promise\>; + +Obtains the information about modules with the overlay feature in another application based on the target module name. This API uses a promise to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| targetBundleName | string | Yes | Bundle name of the application. | +| moduleName | string | No | HAP name of the target module, which is **targetModuleName** specified by modules with the overlay feature. If this parameter is not specified, the API obtains the information associated with all modules in that application. | + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\> | Promise used to return the result, which is an array of **OverlayModuleInfo** objects.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found | +| 17700002 | The specified moduleName is not existed. | +| 17700034 | The specified moduleName is overlay module. | +| 17700035 | The specified bundleName is overlay bundle. | + +**Example** + +```ts +var targetBundleName = "com.example.myapplication_xxxxx"; +var moduleName = "feature" + +(async() => { + try { + let overlayModuleInfos = await overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, moduleName); + console.log('overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos)); + } catch(err) { + console.log('getTargetOverlayModuleInfosByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + } +})(); +``` + +## overlay.getTargetOverlayModuleInfosByBundleName + +getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName: string, callback: AsyncCallback\>): void; + +Obtains the information about modules with the overlay feature in another application based on the target module name. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| targetBundleName | string | Yes | Bundle name of the application. | +| moduleName | string | No | HAP name of the target module, which is **targetModuleName** specified by modules with the overlay feature. If this parameter is not specified, the API obtains the information associated with all modules in that application. | +| callback | AsyncCallback\> | Yes | Callback used to return the result, which is an array of **OverlayModuleInfo** objects. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found | +| 17700002 | The specified moduleName is not existed. | +| 17700034 | The specified moduleName is overlay module. | +| 17700035 | The specified bundleName is overlay bundle. | + +**Example** + +```ts +var targetBundleName = "com.example.myapplication_xxxxx"; +var moduleName = "feature" + +try { + overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, moduleName, (error, data) => { + if (error) { + console.log('getTargetOverlayModuleInfosByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + return; + } + console.log('overlayModuleInfo is ' + JSON.stringify(data)); + }); +} catch (error) { + console.log('getTargetOverlayModuleInfosByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); +} +``` + +## overlay.getTargetOverlayModuleInfosByBundleName + +getTargetOverlayModuleInfosByBundleName(targetBundleName: string, callback: AsyncCallback\>): void; + +Obtains the information about all modules with the overlay feature in another application. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned; otherwise, an error message is returned. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Overlay + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| targetBundleName | string | Yes | Bundle name of the application. | +| callback | AsyncCallback\> | Yes | Callback used to return the result, which is an array of **OverlayModuleInfo** objects. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700001 | The specified bundleName is not found | +| 17700002 | The specified moduleName is not existed. | +| 17700034 | The specified moduleName is overlay module. | +| 17700035 | The specified bundleName is overlay bundle. | + +**Example** + +```ts +var targetBundleName = "com.example.myapplication_xxxxx"; + +try { + overlay.getTargetOverlayModuleInfosByBundleName(targetBundleName, (error, data) => { + if (error) { + console.log('getTargetOverlayModuleInfosByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); + return; + } + console.log('overlayModuleInfo is ' + JSON.stringify(data)); + }); +} catch (error) { + console.log('getTargetOverlayModuleInfosByBundleName failed due to error code : ' + err.code + ' ' + 'message :' + err.message); +} +``` + +## Module with the Overlay Feature + +**Concept** +A module with the overlay feature generally provides additional resource files for modules without the overlay feature on the device, so that the target modules can use these resource files at runtime to display different colors, labels, themes, and the like. The overlay feature applies only to the stage model. + +**How do I identify a module with the overlay feature?** +If the **module.json5** file of a module contains the **targetModuleName** and **targetPriority fields** during project creation on DevEco Studio, the module is identified as a module with the overlay feature in the installation phase. diff --git a/en/application-dev/reference/apis/js-apis-pointer.md b/en/application-dev/reference/apis/js-apis-pointer.md index 8ed463d9a5bbbeb6ca8e12212e256e6a4ae3fbec..49ed81e115de6345453c93441b68cda2a132021b 100644 --- a/en/application-dev/reference/apis/js-apis-pointer.md +++ b/en/application-dev/reference/apis/js-apis-pointer.md @@ -2,7 +2,8 @@ The **pointer** module provides APIs related to pointer attribute management. -> **NOTE**
+> **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 @@ -237,6 +238,8 @@ Obtains the mouse movement speed. This API uses a promise to return the result. **System capability**: SystemCapability.MultimodalInput.Input.Pointer +**System API**: This is a system API. + **Return value** | Name | Description | @@ -263,8 +266,6 @@ Obtains the mouse pointer style. This API uses an asynchronous callback to retur **System capability**: SystemCapability.MultimodalInput.Input.Pointer -**System API**: This is a system API. - **Parameters** | Name | Type | Mandatory | Description | @@ -277,21 +278,23 @@ Obtains the mouse pointer style. This API uses an asynchronous callback to retur ```js import window from '@ohos.window'; -window.getTopWindow((error, win) => { - win.getWindowProperties((error, properties) => { - let windowId = properties.id; - if (windowId < 0) { - console.log(`Invalid windowId`); - return; - } - try { - pointer.getPointerStyle(windowId, (error, style) => { - console.log(`Get pointer style success, style: ${JSON.stringify(style)}`); - }); - } catch (error) { - console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); - } - }); +window.getLastWindow(this.context, (error, win) => { + if (error.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); + return; + } + let windowId = win.getWindowProperties().id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.getPointerStyle(windowId, (error, style) => { + console.log(`Get pointer style success, style: ${JSON.stringify(style)}`); + }); + } catch (error) { + console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + } }); ``` @@ -320,21 +323,23 @@ Obtains the mouse pointer style. This API uses a promise to return the result. ```js import window from '@ohos.window'; -window.getTopWindow((error, win) => { - win.getWindowProperties((error, properties) => { - let windowId = properties.id; - if (windowId < 0) { - console.log(`Invalid windowId`); - return; - } - try { - pointer.getPointerStyle(windowId).then((style) => { - console.log(`Get pointer style success, style: ${JSON.stringify(style)}`); - }); - } catch (error) { - console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); - } - }); +window.getLastWindow(this.context, (error, win) => { + if (error.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); + return; + } + let windowId = win.getWindowProperties().id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.getPointerStyle(windowId).then((style) => { + console.log(`Get pointer style success, style: ${JSON.stringify(style)}`); + }); + } catch (error) { + console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + } }); ``` @@ -359,21 +364,23 @@ Sets the mouse pointer style. This API uses an asynchronous callback to return t ```js import window from '@ohos.window'; -window.getTopWindow((error, win) => { - win.getWindowProperties((error, properties) => { - let windowId = properties.id; - if (windowId < 0) { - console.log(`Invalid windowId`); - return; - } - try { - pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, error => { - console.log(`Set pointer style success`); - }); - } catch (error) { - console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); - } - }); +window.getLastWindow(this.context, (error, win) => { + if (error.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); + return; + } + let windowId = win.getWindowProperties().id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, error => { + console.log(`Set pointer style success`); + }); + } catch (error) { + console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + } }); ``` ## pointer.setPointerStyle9+ @@ -397,21 +404,23 @@ Sets the mouse pointer style. This API uses a promise to return the result. ```js import window from '@ohos.window'; -window.getTopWindow((error, win) => { - win.getWindowProperties((error, properties) => { - let windowId = properties.id; - if (windowId < 0) { - console.log(`Invalid windowId`); - return; - } - try { - pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => { - console.log(`Set pointer style success`); - }); - } catch (error) { - console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); - } - }); +window.getLastWindow(this.context, (error, win) => { + if (error.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); + return; + } + let windowId = win.getWindowProperties().id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => { + console.log(`Set pointer style success`); + }); + } catch (error) { + console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + } }); ``` ## PointerStyle9+ @@ -420,44 +429,44 @@ Enumerates mouse pointer styles. **System capability**: SystemCapability.MultimodalInput.Input.Pointer -| Name | Value | Description | -| -------------------------------- | ---- | ------ | -| DEFAULT | 0 | Default | -| EAST | 1 | East arrow | -| WEST | 2 | West arrow | -| SOUTH | 3 | South arrow | -| NORTH | 4 | North arrow | -| WEST_EAST | 5 | West-east arrow | -| NORTH_SOUTH | 6 | North-south arrow | -| NORTH_EAST | 7 | North-east arrow | -| NORTH_WEST | 8 | North-west arrow | -| SOUTH_EAST | 9 | South-east arrow | -| SOUTH_WEST | 10 | South-west arrow | -| NORTH_EAST_SOUTH_WEST | 11 | North-east and south-west adjustment| -| NORTH_WEST_SOUTH_EAST | 12 | North-west and south-east adjustment| -| CROSS | 13 | Cross (accurate selection) | -| CURSOR_COPY | 14 | Copy cursor | -| CURSOR_FORBID | 15 | Forbid cursor | -| COLOR_SUCKER | 16 | Sucker | -| HAND_GRABBING | 17 | Grabbing hand | -| HAND_OPEN | 18 | Opening hand | -| HAND_POINTING | 19 | Hand-shaped pointer | -| HELP | 20 | Help | -| MOVE | 21 | Move | -| RESIZE_LEFT_RIGHT | 22 | Left and right resizing| -| RESIZE_UP_DOWN | 23 | Up and down resizing| -| SCREENSHOT_CHOOSE | 24 | Screenshot crosshair| -| SCREENSHOT_CURSOR | 25 | Screenshot cursor | -| TEXT_CURSOR | 26 | Text cursor | -| ZOOM_IN | 27 | Zoom in | -| ZOOM_OUT | 28 | Zoom out | -| MIDDLE_BTN_EAST | 29 | Scrolling east | -| MIDDLE_BTN_WEST | 30 | Scrolling west | -| MIDDLE_BTN_SOUTH | 31 | Scrolling south | -| MIDDLE_BTN_NORTH | 32 | Scrolling north | -| MIDDLE_BTN_NORTH_SOUTH | 33 | Scrolling north-south | -| MIDDLE_BTN_NORTH_EAST | 34 | Scrolling north-east | -| MIDDLE_BTN_NORTH_WEST | 35 | Scrolling north-west | -| MIDDLE_BTN_SOUTH_EAST | 36 | Scrolling south-east | -| MIDDLE_BTN_SOUTH_WEST | 37 | Scrolling south-west | -| MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 38 | Moving as a cone in four directions| +| Name | Value | Description |Legend| +| -------------------------------- | ---- | ------ |------ | +| DEFAULT | 0 | Default |![Default.png](./figures/Default.png)| +| EAST | 1 | East arrow |![East.png](./figures/East.png)| +| WEST | 2 | West arrow |![West.png](./figures/West.png)| +| SOUTH | 3 | South arrow |![South.png](./figures/South.png)| +| NORTH | 4 | North arrow |![North.png](./figures/North.png)| +| WEST_EAST | 5 | West-east arrow |![West_East.png](./figures/West_East.png)| +| NORTH_SOUTH | 6 | North-south arrow |![North_South.png](./figures/North_South.png)| +| NORTH_EAST | 7 | North-east arrow |![North_East.png](./figures/North_East.png)| +| NORTH_WEST | 8 | North-west arrow |![North_West.png](./figures/North_West.png)| +| SOUTH_EAST | 9 | South-east arrow |![South_East.png](./figures/South_East.png)| +| SOUTH_WEST | 10 | South-west arrow |![South_West.png](./figures/South_West.png)| +| NORTH_EAST_SOUTH_WEST | 11 | North-east and south-west adjustment|![North_East_South_West.png](./figures/North_East_South_West.png)| +| NORTH_WEST_SOUTH_EAST | 12 | North-west and south-east adjustment|![North_West_South_East.png](./figures/North_West_South_East.png)| +| CROSS | 13 | Cross (accurate selection) |![Cross.png](./figures/Cross.png)| +| CURSOR_COPY | 14 | Copy cursor |![Copy.png](./figures/Copy.png)| +| CURSOR_FORBID | 15 | Forbid cursor |![Forbid.png](./figures/Forbid.png)| +| COLOR_SUCKER | 16 | Sucker |![Colorsucker.png](./figures/Colorsucker.png)| +| HAND_GRABBING | 17 | Grabbing hand |![Hand_Grabbing.png](./figures/Hand_Grabbing.png)| +| HAND_OPEN | 18 | Opening hand |![Hand_Open.png](./figures/Hand_Open.png)| +| HAND_POINTING | 19 | Hand-shaped pointer |![Hand_Poniting.png](./figures/Hand_Pointing.png)| +| HELP | 20 | Help |![Help.png](./figures/Help.png)| +| MOVE | 21 | Move |![Move.png](./figures/Move.png)| +| RESIZE_LEFT_RIGHT | 22 | Left and right resizing|![Resize_Left_Right.png](./figures/Resize_Left_Right.png)| +| RESIZE_UP_DOWN | 23 | Up and down resizing|![Resize_Up_Down.png](./figures/Resize_Up_Down.png)| +| SCREENSHOT_CHOOSE | 24 | Screenshot crosshair|![Screenshot_Cross.png](./figures/Screenshot_Cross.png)| +| SCREENSHOT_CURSOR | 25 | Screenshot cursor |![Screenshot_Cursor.png](./figures/Screenshot_Cursor.png)| +| TEXT_CURSOR | 26 | Text cursor |![Text_Cursor.png](./figures/Text_Cursor.png)| +| ZOOM_IN | 27 | Zoom in |![Zoom_In.png](./figures/Zoom_In.png)| +| ZOOM_OUT | 28 | Zoom out |![Zoom_Out.png](./figures/Zoom_Out.png)| +| MIDDLE_BTN_EAST | 29 | Scrolling east |![MID_Btn_East.png](./figures/MID_Btn_East.png)| +| MIDDLE_BTN_WEST | 30 | Scrolling west |![MID_Btn_West.png](./figures/MID_Btn_West.png)| +| MIDDLE_BTN_SOUTH | 31 | Scrolling south | ![MID_Btn_South.png](./figures/MID_Btn_South.png) | +| MIDDLE_BTN_NORTH | 32 | Scrolling north |![MID_Btn_North.png](./figures/MID_Btn_North.png)| +| MIDDLE_BTN_NORTH_SOUTH | 33 | Scrolling north-south |![MID_Btn_North_South.png](./figures/MID_Btn_North_South.png)| +| MIDDLE_BTN_NORTH_EAST | 34 | Scrolling north-east |![MID_Btn_North_East.png](./figures/MID_Btn_North_East.png)| +| MIDDLE_BTN_NORTH_WEST | 35 | Scrolling north-west |![MID_Btn_North_West.png](./figures/MID_Btn_North_West.png)| +| MIDDLE_BTN_SOUTH_EAST | 36 | Scrolling south-east |![MID_Btn_South_East.png](./figures/MID_Btn_South_East.png)| +| MIDDLE_BTN_SOUTH_WEST | 37 | Scrolling south-west |![MID_Btn_South_West.png](./figures/MID_Btn_South_West.png)| +| MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 38 | Moving as a cone in four directions|![MID_Btn_North_South_West_East.png](./figures/MID_Btn_North_South_West_East.png)| diff --git a/en/application-dev/reference/apis/js-apis-radio.md b/en/application-dev/reference/apis/js-apis-radio.md index 1df1b8d7dd61ca1c5a92b65c1557aed3697a36e0..448ccd3dc7d40a17edfdb7b0862cefe3a2377f9e 100644 --- a/en/application-dev/reference/apis/js-apis-radio.md +++ b/en/application-dev/reference/apis/js-apis-radio.md @@ -394,7 +394,6 @@ Obtains the ID of the slot in which the primary card is located. This API uses a | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **Example** @@ -427,7 +426,6 @@ Obtains the ID of the slot in which the primary card is located. This API uses a | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-request.md b/en/application-dev/reference/apis/js-apis-request.md index ec609543eb2287801cf7fc0d51a0bce4ede8b837..1108ca63710590b35d05af8129f9ff278e9d6cc9 100644 --- a/en/application-dev/reference/apis/js-apis-request.md +++ b/en/application-dev/reference/apis/js-apis-request.md @@ -16,24 +16,6 @@ import request from '@ohos.request'; ## Constraints - -HTTPS is supported by default in the FA model. To support HTTP, add **network** to the **config.json** file and set the **cleartextTraffic** attribute to **true**. - -```js -var config = { - "deviceConfig": { - "default": { - "network": { - "cleartextTraffic": true - } - //... - } - } -} -``` - -The **cleartextTraffic** attribute is not involved during application development in the stage model. - The download server must support the HTTP HEAD method so that the size of the data to download can be obtained through **Content-length**. Otherwise, the download task fails. If this is the case, you can check the failure cause through [on('fail')7+](#onfail7). Only HTTP requests are supported. HTTPS requests are not supported. @@ -105,24 +87,24 @@ Uploads files. This API uses a promise to return the result. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.| -| config | [UploadConfig](#uploadconfig) | Yes| Upload configurations.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.| + | config | [UploadConfig](#uploadconfig) | Yes| Upload configurations.| **Return value** -| Type| Description| -| -------- | -------- | -| Promise<[UploadTask](#uploadtask)> | Promise used to return the **UploadTask** object.| + | Type| Description| + | -------- | -------- | + | Promise<[UploadTask](#uploadtask)> | Promise used to return the **UploadTask** object.| **Error codes** For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md). -| ID| Error Message| -| -------- | -------- | -| 13400002 | Bad file path. | + | ID| Error Message| + | -------- | -------- | + | 13400002 | Bad file path. | **Example** @@ -159,18 +141,18 @@ Uploads files. This API uses an asynchronous callback to return the result. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.| -| config | [UploadConfig](#uploadconfig) | Yes| Upload configurations.| -| callback | AsyncCallback<[UploadTask](#uploadtask)> | Yes| Callback used to return the **UploadTask** object.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.| + | config | [UploadConfig](#uploadconfig) | Yes| Upload configurations.| + | callback | AsyncCallback<[UploadTask](#uploadtask)> | Yes| Callback used to return the **UploadTask** object.| **Error codes** For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md). -| ID| Error Message| -| -------- | -------- | -| 13400002 | Bad file path. | + | ID| Error Message| + | -------- | -------- | + | 13400002 | Bad file path. | **Example** @@ -214,15 +196,15 @@ Uploads files. This API uses a promise to return the result. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| config | [UploadConfig](#uploadconfig) | Yes| Upload configurations.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | config | [UploadConfig](#uploadconfig) | Yes| Upload configurations.| **Return value** -| Type| Description| -| -------- | -------- | -| Promise<[UploadTask](#uploadtask)> | Promise used to return the **UploadTask** object.| + | Type| Description| + | -------- | -------- | + | Promise<[UploadTask](#uploadtask)> | Promise used to return the **UploadTask** object.| **Example** @@ -261,10 +243,10 @@ Uploads files. This API uses an asynchronous callback to return the result. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| config | [UploadConfig](#uploadconfig) | Yes| Upload configurations.| -| callback | AsyncCallback<[UploadTask](#uploadtask)> | Yes| Callback used to return the **UploadTask** object.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | config | [UploadConfig](#uploadconfig) | Yes| Upload configurations.| + | callback | AsyncCallback<[UploadTask](#uploadtask)> | Yes| Callback used to return the **UploadTask** object.| **Example** @@ -304,10 +286,10 @@ Subscribes to an upload event. This API uses an asynchronous callback to return **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (upload progress).| -| callback | function | Yes| Callback for the upload progress event.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (upload progress).| + | callback | function | Yes| Callback for the upload progress event.| Parameters of the callback function @@ -338,10 +320,10 @@ Subscribes to an upload event. This API uses an asynchronous callback to return **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Type of the event to subscribe to. The value is **'headerReceive'** (response header).| -| callback | function | Yes| Callback for the HTTP Response Header event.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to subscribe to. The value is **'headerReceive'** (response header).| + | callback | function | Yes| Callback for the HTTP Response Header event.| Parameters of the callback function @@ -371,10 +353,10 @@ Subscribes to an upload event. This API uses an asynchronous callback to return **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.| -| callback | Callback<Array<TaskState>> | Yes| Callback used to return the result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.| + | callback | Callback<Array<TaskState>> | Yes| Callback used to return the result.| Parameters of the callback function @@ -413,10 +395,10 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).| -| callback | function | No| Callback for the upload progress event.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).| + | callback | function | No| Callback for the upload progress event.| Parameters of the callback function @@ -447,10 +429,10 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Type of the event to unsubscribe from. The value is **'headerReceive'** (response header).| -| callback | function | No| Callback for the HTTP Response Header event.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to unsubscribe from. The value is **'headerReceive'** (response header).| + | callback | function | No| Callback for the HTTP Response Header event.| Parameters of the callback function @@ -479,10 +461,10 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.| -| callback | Callback<Array<TaskState>> | No| Callback used to return the result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.| + | callback | Callback<Array<TaskState>> | No| Callback used to return the result.| Parameters of the callback function @@ -519,9 +501,9 @@ Deletes this upload task. This API uses a promise to return the result. **Return value** -| Type| Description| -| -------- | -------- | -| Promise<boolean> | Promise used to return the task removal result. It returns **true** if the operation is successful and returns **false** otherwise.| + | Type| Description| + | -------- | -------- | + | Promise<boolean> | Promise used to return the task removal result. It returns **true** if the operation is successful and returns **false** otherwise.| **Example** @@ -550,9 +532,9 @@ Deletes this upload task. This API uses an asynchronous callback to return the r **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes| Callback used to return the result.| **Example** @@ -587,9 +569,9 @@ Removes this upload task. This API uses a promise to return the result. **Return value** -| Type| Description| -| -------- | -------- | -| Promise<boolean> | Promise used to return the task removal result. It returns **true** if the operation is successful and returns **false** otherwise.| + | Type| Description| + | -------- | -------- | + | Promise<boolean> | Promise used to return the task removal result. It returns **true** if the operation is successful and returns **false** otherwise.| **Example** @@ -622,9 +604,9 @@ Removes this upload task. This API uses an asynchronous callback to return the r **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes| Callback used to return the result.| **Example** @@ -705,25 +687,25 @@ Downloads files. This API uses a promise to return the result. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.| -| config | [DownloadConfig](#downloadconfig) | Yes| Download configurations.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.| + | config | [DownloadConfig](#downloadconfig) | Yes| Download configurations.| **Return value** -| Type| Description| -| -------- | -------- | -| Promise<[DownloadTask](#downloadtask)> | Promise used to return the result.| + | Type| Description| + | -------- | -------- | + | Promise<[DownloadTask](#downloadtask)> | Promise used to return the result.| **Error codes** For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md). -| ID| Error Message| -| -------- | -------- | -| 13400001 | File operation error. | -| 13400002 | Bad file path. | -| 13400003 | Task manager service error. | + | ID| Error Message| + | -------- | -------- | + | 13400001 | File operation error. | + | 13400002 | Bad file path. | + | 13400003 | Task manager service error. | **Example** @@ -753,20 +735,20 @@ Downloads files. This API uses an asynchronous callback to return the result. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.| -| config | [DownloadConfig](#downloadconfig) | Yes| Download configurations.| -| callback | AsyncCallback<[DownloadTask](#downloadtask)> | Yes| Callback used to return the result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | context | [BaseContext](js-apis-inner-application-baseContext.md) | Yes| Application-based context.| + | config | [DownloadConfig](#downloadconfig) | Yes| Download configurations.| + | callback | AsyncCallback<[DownloadTask](#downloadtask)> | Yes| Callback used to return the result.| **Error codes** For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md). -| ID| Error Message| -| -------- | -------- | -| 13400001 | File operation error. | -| 13400002 | Bad file path. | -| 13400003 | Task manager service error. | + | ID| Error Message| + | -------- | -------- | + | 13400001 | File operation error. | + | 13400002 | Bad file path. | + | 13400003 | Task manager service error. | **Example** @@ -804,15 +786,15 @@ Downloads files. This API uses a promise to return the result. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| config | [DownloadConfig](#downloadconfig) | Yes| Download configurations.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | config | [DownloadConfig](#downloadconfig) | Yes| Download configurations.| **Return value** -| Type| Description| -| -------- | -------- | -| Promise<[DownloadTask](#downloadtask)> | Promise used to return the result.| + | Type| Description| + | -------- | -------- | + | Promise<[DownloadTask](#downloadtask)> | Promise used to return the result.| **Example** @@ -844,10 +826,10 @@ Downloads files. This API uses an asynchronous callback to return the result. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| config | [DownloadConfig](#downloadconfig) | Yes| Download configurations.| -| callback | AsyncCallback<[DownloadTask](#downloadtask)> | Yes| Callback used to return the result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | config | [DownloadConfig](#downloadconfig) | Yes| Download configurations.| + | callback | AsyncCallback<[DownloadTask](#downloadtask)> | Yes| Callback used to return the result.| **Example** @@ -880,10 +862,10 @@ Subscribes to a download event. This API uses an asynchronous callback to return **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).| -| callback | function | Yes| Callback for the download progress event.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).| + | callback | function | Yes| Callback for the download progress event.| Parameters of the callback function @@ -914,10 +896,10 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (download progress).| -| callback | function | No| Callback for the download progress event.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (download progress).| + | callback | function | No| Callback for the download progress event.| Parameters of the callback function @@ -948,10 +930,10 @@ Subscribes to a download event. This API uses an asynchronous callback to return **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Type of the event to subscribe to.
- **'complete'**: download task completion event.
- **'pause'**: download task pause event.
- **'remove'**: download task removal event.| -| callback | function | Yes| Callback used to return the result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to subscribe to.
- **'complete'**: download task completion event.
- **'pause'**: download task pause event.
- **'remove'**: download task removal event.| + | callback | function | Yes| Callback used to return the result.| **Example** @@ -975,10 +957,10 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Type of the event to unsubscribe from.
- **'complete'**: download task completion event.
- **'pause'**: download task pause event.
- **'remove'**: download task removal event.| -| callback | function | No| Callback used to return the result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to unsubscribe from.
- **'complete'**: download task completion event.
- **'pause'**: download task pause event.
- **'remove'**: download task removal event.| + | callback | function | No| Callback used to return the result.| **Example** @@ -1002,10 +984,10 @@ Subscribes to the download task failure event. This API uses an asynchronous cal **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Type of the event to subscribe to. The value is **'fail'** (download failure).| -| callback | function | Yes| Callback for the download task failure event.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to subscribe to. The value is **'fail'** (download failure).| + | callback | function | Yes| Callback for the download task failure event.| Parameters of the callback function @@ -1035,10 +1017,10 @@ Unsubscribes from the download task failure event. This API uses an asynchronous **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Type of the event to unsubscribe from. The value is **'fail'** (download failure).| -| callback | function | No| Callback for the download task failure event.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to unsubscribe from. The value is **'fail'** (download failure).| + | callback | function | No| Callback for the download task failure event.| Parameters of the callback function @@ -1067,9 +1049,9 @@ Removes this download task. This API uses a promise to return the result. **Return value** -| Type| Description| -| -------- | -------- | -| Promise<boolean> | Promise used to return the task removal result.| + | Type| Description| + | -------- | -------- | + | Promise<boolean> | Promise used to return the task removal result.| **Example** @@ -1098,9 +1080,9 @@ Deletes this download task. This API uses an asynchronous callback to return the **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | Yes| Callback used to return the task deletion result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes| Callback used to return the task deletion result.| **Example** @@ -1131,9 +1113,9 @@ Obtains the information about this download task. This API uses a promise to ret **Return value** -| Type| Description| -| -------- | -------- | -| Promise<[DownloadInfo](#downloadinfo7)> | Promise used to return the download task information.| + | Type| Description| + | -------- | -------- | + | Promise<[DownloadInfo](#downloadinfo7)> | Promise used to return the download task information.| **Example** @@ -1158,9 +1140,9 @@ Obtains the information about this download task. This API uses an asynchronous **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | Yes| Callback used to return the download task information.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | Yes| Callback used to return the download task information.| **Example** @@ -1187,9 +1169,9 @@ Obtains the **MimeType** of this download task. This API uses a promise to retur **Return value** -| Type| Description| -| -------- | -------- | -| Promise<string> | Promise used to return the **MimeType** of the download task.| + | Type| Description| + | -------- | -------- | + | Promise<string> | Promise used to return the **MimeType** of the download task.| **Example** @@ -1214,9 +1196,9 @@ Obtains the **MimeType** of this download task. This API uses an asynchronous ca **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<string> | Yes| Callback used to return the **MimeType** of the download task.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<string> | Yes| Callback used to return the **MimeType** of the download task.| **Example** @@ -1243,9 +1225,9 @@ Pauses this download task. This API uses a promise to return the result. **Return value** -| Type| Description| -| -------- | -------- | -| Promise<boolean> | Promise used to return the download task pause result.| + | Type| Description| + | -------- | -------- | + | Promise<boolean> | Promise used to return the download task pause result.| **Example** @@ -1274,9 +1256,9 @@ Pauses this download task. This API uses an asynchronous callback to return the **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes| Callback used to return the result.| **Example** @@ -1307,9 +1289,9 @@ Resumes this download task. This API uses a promise to return the result. **Return value** -| Type| Description| -| -------- | -------- | -| Promise<boolean> | Promise used to return the result.| + | Type| Description| + | -------- | -------- | + | Promise<boolean> | Promise used to return the result.| **Example** @@ -1339,9 +1321,9 @@ Resumes this download task. This API uses an asynchronous callback to return the **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes| Callback used to return the result.| **Example** @@ -1377,9 +1359,9 @@ Removes this download task. This API uses a promise to return the result. **Return value** -| Type| Description| -| -------- | -------- | -| Promise<boolean> | Promise used to return the task removal result.| + | Type| Description| + | -------- | -------- | + | Promise<boolean> | Promise used to return the task removal result.| **Example** @@ -1412,9 +1394,9 @@ Removes this download task. This API uses an asynchronous callback to return the **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | Yes| Callback used to return the task removal result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes| Callback used to return the task removal result.| **Example** @@ -1449,9 +1431,9 @@ Queries this download task. This API uses a promise to return the result. **Return value** -| Type| Description| -| -------- | -------- | -| Promise<[DownloadInfo](#downloadinfo7)> | Promise used to return the download task information.| + | Type| Description| + | -------- | -------- | + | Promise<[DownloadInfo](#downloadinfo7)> | Promise used to return the download task information.| **Example** @@ -1480,9 +1462,9 @@ Queries this download task. This API uses an asynchronous callback to return the **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | Yes| Callback used to return the download task information.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | Yes| Callback used to return the download task information.| **Example** @@ -1513,9 +1495,9 @@ Queries the **MimeType** of this download task. This API uses a promise to retur **Return value** -| Type| Description| -| -------- | -------- | -| Promise<string> | Promise used to return the **MimeType** of the download task.| + | Type| Description| + | -------- | -------- | + | Promise<string> | Promise used to return the **MimeType** of the download task.| **Example** @@ -1544,9 +1526,9 @@ Queries the **MimeType** of this download task. This API uses an asynchronous ca **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<string> | Yes| Callback used to return the **MimeType** of the download task.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<string> | Yes| Callback used to return the **MimeType** of the download task.| **Example** @@ -1577,9 +1559,9 @@ Pauses this download task. This API uses a promise to return the result. **Return value** -| Type| Description| -| -------- | -------- | -| Promise<void> | Promise used to return the download task pause result.| + | Type| Description| + | -------- | -------- | + | Promise<void> | Promise used to return the download task pause result.| **Example** @@ -1612,9 +1594,9 @@ Pauses this download task. This API uses an asynchronous callback to return the **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<void> | Yes| Callback used to return the result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -1649,9 +1631,9 @@ Resumes this download task. This API uses a promise to return the result. **Return value** -| Type| Description| -| -------- | -------- | -| Promise<void> | Promise used to return the result.| + | Type| Description| + | -------- | -------- | + | Promise<void> | Promise used to return the result.| **Example** @@ -1685,9 +1667,9 @@ Resumes this download task. This API uses an asynchronous callback to return the **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<void> | Yes| Callback used to return the result.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md b/en/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md index bec171f5b45400827b3e76e79226b1b4210569d2..cf918a571c7121bdb5b9c5f51cb7a93ce782968d 100644 --- a/en/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md +++ b/en/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md @@ -233,7 +233,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba | Name | Type | Mandatory | Description | | --------- | ---------------------------------- | ---- | ---------------------------------------- | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| | bgMode | [BackgroundMode](#backgroundmode) | Yes | Background mode requested. | | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. | | callback | AsyncCallback<void> | Yes | Callback used to return the result. | @@ -311,7 +311,7 @@ Requests a continuous task from the system. This API uses a promise to return th | Name | Type | Mandatory | Description | | --------- | ---------------------------------- | ---- | ---------------------------------------- | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| | bgMode | [BackgroundMode](#backgroundmode) | Yes | Background mode requested. | | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. | @@ -388,7 +388,7 @@ Requests to cancel a continuous task. This API uses an asynchronous callback to | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------------------------------- | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** @@ -444,7 +444,7 @@ Requests to cancel a continuous task. This API uses a promise to return the resu | Name | Type | Mandatory | Description | | ------- | ------- | ---- | ---------------------------------------- | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-rpc.md b/en/application-dev/reference/apis/js-apis-rpc.md index c806d10c6963add3231f68a1a790d68c31d4b3a5..3b12ce374b7adcebeb45323fe3eda08efb0c9245 100644 --- a/en/application-dev/reference/apis/js-apis-rpc.md +++ b/en/application-dev/reference/apis/js-apis-rpc.md @@ -20,22 +20,22 @@ The APIs of this module return exceptions since API version 9. The following tab **System capability**: SystemCapability.Communication.IPC.Core -| Name | Value | Description | -| ------------------------------------- | ------- | --------------------------------------------- | -| CHECK_PARAM_ERROR | 401 | Parameter check failed. | -| OS_MMAP_ERROR | 1900001 | Failed to call mmap. | -| OS_IOCTL_ERROR | 1900002 | Failed to call **ioctl** with the shared memory file descriptor.| -| WRITE_TO_ASHMEM_ERROR | 1900003 | Failed to write data to the shared memory. | -| READ_FROM_ASHMEM_ERROR | 1900004 | Failed to read data from the shared memory. | -| ONLY_PROXY_OBJECT_PERMITTED_ERROR | 1900005 | This operation is allowed only on the proxy object. | -| ONLY_REMOTE_OBJECT_PERMITTED_ERROR | 1900006 | This operation is allowed only on the remote object. | -| COMMUNICATION_ERROR | 1900007 | Failed to communicate with the remote object over IPC. | -| PROXY_OR_REMOTE_OBJECT_INVALID_ERROR | 1900008 | Invalid proxy or remote object. | -| WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR | 1900009 | Failed to write data to MessageSequence. | -| READ_DATA_FROM_MESSAGE_SEQUENCE_ERROR | 1900010 | Failed to read data from MessageSequence. | -| PARCEL_MEMORY_ALLOC_ERROR | 1900011 | Failed to allocate memory during serialization. | -| CALL_JS_METHOD_ERROR | 1900012 | Failed to invoke the JS callback. | -| OS_DUP_ERROR | 1900013 | Failed to call dup. | + | Name | Value | Description | + | ------------------------------------- | ------- | --------------------------------------------- | + | CHECK_PARAM_ERROR | 401 | Parameter check failed. | + | OS_MMAP_ERROR | 1900001 | Failed to call mmap. | + | OS_IOCTL_ERROR | 1900002 | Failed to call **ioctl** with the shared memory file descriptor.| + | WRITE_TO_ASHMEM_ERROR | 1900003 | Failed to write data to the shared memory. | + | READ_FROM_ASHMEM_ERROR | 1900004 | Failed to read data from the shared memory. | + | ONLY_PROXY_OBJECT_PERMITTED_ERROR | 1900005 | This operation is allowed only on the proxy object. | + | ONLY_REMOTE_OBJECT_PERMITTED_ERROR | 1900006 | This operation is allowed only on the remote object. | + | COMMUNICATION_ERROR | 1900007 | Failed to communicate with the remote object over IPC. | + | PROXY_OR_REMOTE_OBJECT_INVALID_ERROR | 1900008 | Invalid proxy or remote object. | + | WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR | 1900009 | Failed to write data to MessageSequence. | + | READ_DATA_FROM_MESSAGE_SEQUENCE_ERROR | 1900010 | Failed to read data from MessageSequence. | + | PARCEL_MEMORY_ALLOC_ERROR | 1900011 | Failed to allocate memory during serialization. | + | CALL_JS_METHOD_ERROR | 1900012 | Failed to invoke the JS callback. | + | OS_DUP_ERROR | 1900013 | Failed to call dup. | ## MessageSequence9+ @@ -54,9 +54,9 @@ During RPC or IPC, the sender can use the **write()** method provided by **Messa **Return value** -| Type | Description | -| --------------- | ------------------------------- | -| MessageSequence | **MessageSequence** object created.| + | Type | Description | + | --------------- | ------------------------------- | + | MessageSequence | **MessageSequence** object created.| **Example** @@ -90,18 +90,18 @@ Serializes a remote object and writes it to this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------------------------------- | ---- | ----------------------------------------- | -| object | [IRemoteObject](#iremoteobject) | Yes | Remote object to serialize and write to the **MessageSequence** object.| + | Name| Type | Mandatory| Description | + | ------ | ------------------------------- | ---- | ----------------------------------------- | + | object | [IRemoteObject](#iremoteobject) | Yes | Remote object to serialize and write to the **MessageSequence** object.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| -------- | ------- | -| 1900008 | proxy or remote object is invalid | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | -------- | ------- | + | 1900008 | proxy or remote object is invalid | + | 1900009 | write data to message sequence failed | **Example** @@ -131,18 +131,18 @@ Reads the remote object from **MessageSequence**. You can use this API to deseri **Return value** -| Type | Description | -| ------------------------------- | ------------------ | -| [IRemoteObject](#iremoteobject) | Remote object obtained.| + | Type | Description | + | ------------------------------- | ------------------ | + | [IRemoteObject](#iremoteobject) | Remote object obtained.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900008 | proxy or remote object is invalid | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900008 | proxy or remote object is invalid | + | 1900010 | read data from message sequence failed | **Example** @@ -173,17 +173,17 @@ Writes an interface token to this **MessageSequence** object. The remote object **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------ | -| token | string | Yes | Interface token to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------ | + | token | string | Yes | Interface token to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900009 | write data to message sequence failed | **Example** @@ -207,17 +207,17 @@ Reads the interface token from this **MessageSequence** object. The interface to **Return value** -| Type | Description | -| ------ | ------------------------ | -| string | Interface token obtained.| + | Type | Description | + | ------ | ------------------------ | + | string | Interface token obtained.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | ----- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | ----- | + | 1900010 | read data from message sequence failed | **Example** @@ -246,9 +246,9 @@ Obtains the data size of this **MessageSequence** object. **Return value** -| Type | Description | -| ------ | ----------------------------------------------- | -| number | Size of the **MessageSequence** object obtained, in bytes.| + | Type | Description | + | ------ | ----------------------------------------------- | + | number | Size of the **MessageSequence** object obtained, in bytes.| **Example** @@ -268,9 +268,9 @@ Obtains the capacity of this **MessageSequence** object. **Return value** -| Type | Description| -| ------ | ----- | -| number | **MessageSequence** capacity obtained, in bytes.| + | Type | Description| + | ------ | ----- | + | number | **MessageSequence** capacity obtained, in bytes.| **Example** @@ -290,9 +290,9 @@ Sets the size of the data contained in this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description| -| ------ | ------ | ---- | ------ | -| size | number | Yes | Data size to set, in bytes.| + | Name| Type | Mandatory| Description| + | ------ | ------ | ---- | ------ | + | size | number | Yes | Data size to set, in bytes.| **Example** @@ -317,17 +317,17 @@ Sets the storage capacity of this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | --------------------------------------------- | -| size | number | Yes | Storage capacity of the **MessageSequence** object to set, in bytes.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | --------------------------------------------- | + | size | number | Yes | Storage capacity of the **MessageSequence** object to set, in bytes.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| -------- | ------ | -| 1900011 | parcel memory alloc failed | + | ID| Error Message| + | -------- | ------ | + | 1900011 | parcel memory alloc failed | **Example** @@ -352,9 +352,9 @@ Obtains the writable capacity (in bytes) of this **MessageSequence** object. **Return value** -| Type| Description| -| ------ | ------ | -| number | Writable capacity of the **MessageSequence** instance, in bytes.| + | Type| Description| + | ------ | ------ | + | number | Writable capacity of the **MessageSequence** instance, in bytes.| **Example** @@ -378,9 +378,9 @@ Obtains the readable capacity of this **MessageSequence** object. **Return value** -| Type| Description| -| ------ | ------- | -| number | Readable capacity of the **MessageSequence** instance, in bytes.| + | Type| Description| + | ------ | ------- | + | number | Readable capacity of the **MessageSequence** instance, in bytes.| **Example** @@ -404,9 +404,9 @@ Obtains the read position of this **MessageSequence** object. **Return value** -| Type| Description| -| ------ | ------ | -| number | Read position obtained.| + | Type| Description| + | ------ | ------ | + | number | Read position obtained.| **Example** @@ -426,9 +426,9 @@ Obtains the write position of this **MessageSequence** object. **Return value** -| Type| Description| -| ------ | ----- | -| number | Write position obtained.| + | Type| Description| + | ------ | ----- | + | number | Write position obtained.| **Example** @@ -449,9 +449,9 @@ Moves the read pointer to the specified position. **Parameters** -| Name| Type| Mandatory| Description| -| ------ | ------ | ---- | ------- | -| pos | number | Yes | Position from which data is to read.| + | Name| Type| Mandatory| Description| + | ------ | ------ | ---- | ------- | + | pos | number | Yes | Position from which data is to read.| **Example** @@ -481,9 +481,9 @@ Moves the write pointer to the specified position. **Parameters** -| Name| Type| Mandatory| Description| -| ------ | ------ | ---- | ----- | -| pos | number | Yes | Position from which data is to write.| + | Name| Type| Mandatory| Description| + | ------ | ------ | ---- | ----- | + | pos | number | Yes | Position from which data is to write.| **Example** @@ -511,17 +511,17 @@ Writes a byte value to this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description| -| ----- | ------ | ---- | ----- | -| val | number | Yes| Byte value to write.| + | Name| Type | Mandatory| Description| + | ----- | ------ | ---- | ----- | + | val | number | Yes| Byte value to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| -------- | ------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | -------- | ------- | + | 1900009 | write data to message sequence failed | **Example** @@ -545,17 +545,17 @@ Reads the byte value from this **MessageSequence** object. **Return value** -| Type | Description| -| ------ | ----- | -| number | Byte value read.| + | Type | Description| + | ------ | ----- | + | number | Byte value read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -586,17 +586,17 @@ Writes a short integer to this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description| -| ------ | ------ | --- | --- | -| val | number | Yes| Short integer to write.| + | Name| Type | Mandatory| Description| + | ------ | ------ | --- | --- | + | val | number | Yes| Short integer to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | ------ | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | ------ | + | 1900009 | write data to message sequence failed | **Example** @@ -620,17 +620,17 @@ Reads the short integer from this **MessageSequence** object. **Return value** -| Type | Description | -| ------ | -------------- | -| number | Short integer read.| + | Type | Description | + | ------ | -------------- | + | number | Short integer read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -661,17 +661,17 @@ Writes an integer to this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------- | -| val | number | Yes | Integer to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------- | + | val | number | Yes | Integer to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| -------- | ------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | -------- | ------- | + | 1900009 | write data to message sequence failed | **Example** @@ -695,17 +695,17 @@ Reads the integer from this **MessageSequence** object. **Return value** -| Type | Description | -| ------ | ------------ | -| number | Integer read.| + | Type | Description | + | ------ | ------------ | + | number | Integer read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | ------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | ------- | + | 1900010 | read data from message sequence failed | **Example** @@ -736,17 +736,17 @@ Writes a long integer to this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------- | -| val | number | Yes | Long integer to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------- | + | val | number | Yes | Long integer to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | ------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | ------- | + | 1900009 | write data to message sequence failed | **Example** @@ -770,17 +770,17 @@ Reads the long integer from this **MessageSequence** object. **Return value** -| Type | Description | -| ------ | -------------- | -| number | Long integer read.| + | Type | Description | + | ------ | -------------- | + | number | Long integer read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -811,17 +811,17 @@ Writes a floating-point number to this **MessageSequence** object. **Parameters** -| Name| Type| Mandatory| Description| -| ----- | ---- | ---- | ----- | -| val | number | Yes| Floating-point number to write.| + | Name| Type| Mandatory| Description| + | ----- | ---- | ---- | ----- | + | val | number | Yes| Floating-point number to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | ------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | ------- | + | 1900009 | write data to message sequence failed | **Example** @@ -845,17 +845,17 @@ Reads the floating-pointer number from this **MessageSequence** object. **Return value** -| Type | Description | -| ------ | ------------ | -| number | Floating-point number read.| + | Type | Description | + | ------ | ------------ | + | number | Floating-point number read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -886,17 +886,17 @@ Writes a double-precision floating-point number to this **MessageSequence** obje **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------------- | -| val | number | Yes | Double-precision floating-point number to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------------- | + | val | number | Yes | Double-precision floating-point number to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900009 | write data to message sequence failed | **Example** @@ -920,17 +920,17 @@ Reads the double-precision floating-point number from this **MessageSequence** o **Return value** -| Type | Description | -| ------ | ------------------ | -| number | Double-precision floating-point number read.| + | Type | Description | + | ------ | ------------------ | + | number | Double-precision floating-point number read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -961,17 +961,17 @@ Writes a Boolean value to this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------- | ---- | ---------------- | -| val | boolean | Yes | Boolean value to write.| + | Name| Type | Mandatory| Description | + | ------ | ------- | ---- | ---------------- | + | val | boolean | Yes | Boolean value to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | ------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | ------- | + | 1900009 | write data to message sequence failed | **Example** @@ -995,17 +995,17 @@ Reads the Boolean value from this **MessageSequence** object. **Return value** -| Type | Description | -| ------- | -------------------- | -| boolean | Boolean value read.| + | Type | Description | + | ------- | -------------------- | + | boolean | Boolean value read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| -------- | ------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | -------- | ------- | + | 1900010 | read data from message sequence failed | **Example** @@ -1036,17 +1036,17 @@ Writes a character to this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------------------- | -| val | number | Yes | Single character to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | -------------------- | + | val | number | Yes | Single character to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900009 | write data to message sequence failed | **Example** @@ -1070,17 +1070,17 @@ Reads the character from this **MessageSequence** object. **Return value** -| Type | Description| -| ------ | ---- | -| number | Character read.| + | Type | Description| + | ------ | ---- | + | number | Character read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------ | --------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------ | --------- | + | 1900010 | read data from message sequence failed | **Example** @@ -1111,17 +1111,17 @@ Writes a string to this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ----------------------------------------- | -| val | string | Yes | String to write. The length of the string must be less than 40960 bytes.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ----------------------------------------- | + | val | string | Yes | String to write. The length of the string must be less than 40960 bytes.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900009 | write data to message sequence failed | **Example** @@ -1145,17 +1145,17 @@ Reads the string from this **MessageSequence** object. **Return value** -| Type | Description | -| ------ | -------------- | -| string | String read.| + | Type | Description | + | ------ | -------------- | + | string | String read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -1186,17 +1186,17 @@ Writes a **Parcelable** object to this **MessageSequence** object. **Parameters** -| Name| Type| Mandatory| Description| -| ------ | --------- | ---- | ------ | -| val | Parcelable | Yes | **Parcelable** object to write.| + | Name| Type| Mandatory| Description| + | ------ | --------- | ---- | ------ | + | val | Parcelable | Yes | **Parcelable** object to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900009 | write data to message sequence failed | **Example** @@ -1239,18 +1239,18 @@ Reads a **Parcelable** object from this **MessageSequence** object to the specif **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------------------------- | ---- | ----------------------------------------- | -| dataIn | Parcelable | Yes | **Parcelable** object to read.| + | Name| Type | Mandatory| Description | + | ------ | ------------------------- | ---- | ----------------------------------------- | + | dataIn | Parcelable | Yes | **Parcelable** object to read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| -------- | ------- | -| 1900010 | read data from message sequence failed | -| 1900012 | call js callback function failed | + | ID| Error Message| + | -------- | ------- | + | 1900010 | read data from message sequence failed | + | 1900012 | call js callback function failed | **Example** @@ -1295,17 +1295,17 @@ Writes a byte array to this **MessageSequence** object. **Parameters** -| Name | Type | Mandatory| Description | -| --------- | -------- | ---- | ------------------ | -| byteArray | number[] | Yes | Byte array to write.| + | Name | Type | Mandatory| Description | + | --------- | -------- | ---- | ------------------ | + | byteArray | number[] | Yes | Byte array to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900009 | write data to message sequence failed | **Example** @@ -1330,17 +1330,17 @@ Reads a byte array from this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | ------------------ | -| dataIn | number[] | Yes | Byte array to read.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | ------------------ | + | dataIn | number[] | Yes | Byte array to read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -1372,17 +1372,17 @@ Reads the byte array from this **MessageSequence** object. **Return value** -| Type | Description | -| -------- | -------------- | -| number[] | Byte array read.| + | Type | Description | + | -------- | -------------- | + | number[] | Byte array read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| -------- | ------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | -------- | ------- | + | 1900010 | read data from message sequence failed | **Example** @@ -1414,17 +1414,17 @@ Writes a short array to this **MessageSequence** object. **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | -------- | ---- | -------------------- | -| shortArray | number[] | Yes | Short array to write.| + | Name | Type | Mandatory| Description | + | ---------- | -------- | ---- | -------------------- | + | shortArray | number[] | Yes | Short array to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ----- | ----- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ----- | ----- | + | 1900009 | write data to message sequence failed | **Example** @@ -1448,17 +1448,17 @@ Reads a short array from this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | -------------------- | -| dataIn | number[] | Yes | Short array to read.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | -------------------- | + | dataIn | number[] | Yes | Short array to read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------ | ------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------ | ------- | + | 1900010 | read data from message sequence failed | **Example** @@ -1489,17 +1489,17 @@ Reads the short array from this **MessageSequence** object. **Return value** -| Type | Description | -| -------- | ---------------- | -| number[] | Short array read.| + | Type | Description | + | -------- | ---------------- | + | number[] | Short array read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| -------- | ------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | -------- | ------- | + | 1900010 | read data from message sequence failed | **Example** @@ -1530,17 +1530,17 @@ Writes an integer array to this **MessageSequence** object. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------- | ---- | ------------------ | -| intArray | number[] | Yes | Integer array to write.| + | Name | Type | Mandatory| Description | + | -------- | -------- | ---- | ------------------ | + | intArray | number[] | Yes | Integer array to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ----- | --------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ----- | --------- | + | 1900009 | write data to message sequence failed | **Example** @@ -1564,17 +1564,17 @@ Reads an integer array from this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | ------------------ | -| dataIn | number[] | Yes | Integer array to read.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | ------------------ | + | dataIn | number[] | Yes | Integer array to read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -1605,17 +1605,17 @@ Reads the integer array from this **MessageSequence** object. **Return value** -| Type | Description | -| -------- | -------------- | -| number[] | Integer array read.| + | Type | Description | + | -------- | -------------- | + | number[] | Integer array read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ----- | ------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ----- | ------- | + | 1900010 | read data from message sequence failed | **Example** @@ -1646,17 +1646,17 @@ Writes a long array to this **MessageSequence** object. **Parameters** -| Name | Type | Mandatory| Description | -| --------- | -------- | ---- | -------------------- | -| longArray | number[] | Yes | Long array to write.| + | Name | Type | Mandatory| Description | + | --------- | -------- | ---- | -------------------- | + | longArray | number[] | Yes | Long array to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | ----- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | ----- | + | 1900009 | write data to message sequence failed | **Example** @@ -1680,17 +1680,17 @@ Reads a long array from this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | -------------------- | -| dataIn | number[] | Yes | Long array to read.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | -------------------- | + | dataIn | number[] | Yes | Long array to read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | ------ | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | ------ | + | 1900010 | read data from message sequence failed | **Example** @@ -1721,17 +1721,17 @@ Reads the long array from this **MessageSequence** object. **Return value** -| Type | Description | -| -------- | ---------------- | -| number[] | Long array read.| + | Type | Description | + | -------- | ---------------- | + | number[] | Long array read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -1762,17 +1762,17 @@ Writes a floating-point array to this **MessageSequence** object. **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | -------- | ---- | ----------------------------------------------------------------------------------------------------------------------- | -| floatArray | number[] | Yes | Floating-point array to write. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.| + | Name | Type | Mandatory| Description | + | ---------- | -------- | ---- | ----------------------------------------------------------------------------------------------------------------------- | + | floatArray | number[] | Yes | Floating-point array to write. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900009 | write data to message sequence failed | **Example** @@ -1796,17 +1796,17 @@ Reads a floating-point array from this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | ----------------------------------------------------------------------------------------------------------------------- | -| dataIn | number[] | Yes | Floating-point array to read. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | ----------------------------------------------------------------------------------------------------------------------- | + | dataIn | number[] | Yes | Floating-point array to read. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -1837,17 +1837,17 @@ Reads the floating-point array from this **MessageSequence** object. **Return value** -| Type | Description | -| -------- | -------------- | -| number[] | Floating-point array read.| + | Type | Description | + | -------- | -------------- | + | number[] | Floating-point array read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -1878,17 +1878,17 @@ Writes a double-precision floating-point array to this **MessageSequence** objec **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | -------- | ---- | ------------------------ | -| doubleArray | number[] | Yes | Double-precision floating-point array to write.| + | Name | Type | Mandatory| Description | + | ----------- | -------- | ---- | ------------------------ | + | doubleArray | number[] | Yes | Double-precision floating-point array to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900009 | write data to message sequence failed | **Example** @@ -1912,17 +1912,17 @@ Reads a double-precision floating-point array from this **MessageSequence** obje **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | ------------------------ | -| dataIn | number[] | Yes | Double-precision floating-point array to read.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | ------------------------ | + | dataIn | number[] | Yes | Double-precision floating-point array to read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -1953,17 +1953,17 @@ Reads the double-precision floating-point array from this **MessageSequence** ob **Return value** -| Type | Description | -| -------- | -------------------- | -| number[] | Double-precision floating-point array read.| + | Type | Description | + | -------- | -------------------- | + | number[] | Double-precision floating-point array read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -1994,17 +1994,17 @@ Writes a Boolean array to this **MessageSequence** object. **Parameters** -| Name | Type | Mandatory| Description | -| ------------ | --------- | ---- | ------------------ | -| booleanArray | boolean[] | Yes | Boolean array to write.| + | Name | Type | Mandatory| Description | + | ------------ | --------- | ---- | ------------------ | + | booleanArray | boolean[] | Yes | Boolean array to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900009 | write data to message sequence failed | **Example** @@ -2028,17 +2028,17 @@ Reads a Boolean array from this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | --------- | ---- | ------------------ | -| dataIn | boolean[] | Yes | Boolean array to read.| + | Name| Type | Mandatory| Description | + | ------ | --------- | ---- | ------------------ | + | dataIn | boolean[] | Yes | Boolean array to read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -2069,17 +2069,17 @@ Reads the Boolean array from this **MessageSequence** object. **Return value** -| Type | Description | -| --------- | -------------- | -| boolean[] | Boolean array read.| + | Type | Description | + | --------- | -------------- | + | boolean[] | Boolean array read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -2110,17 +2110,17 @@ Writes a character array to this **MessageSequence** object. **Parameters** -| Name | Type | Mandatory| Description | -| --------- | -------- | ---- | ---------------------- | -| charArray | number[] | Yes | Character array to write.| + | Name | Type | Mandatory| Description | + | --------- | -------- | ---- | ---------------------- | + | charArray | number[] | Yes | Character array to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| -------- | ------ | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | -------- | ------ | + | 1900009 | write data to message sequence failed | **Example** @@ -2144,17 +2144,17 @@ Reads a character array from this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | ---------------------- | -| dataIn | number[] | Yes | Character array to read.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | ---------------------- | + | dataIn | number[] | Yes | Character array to read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -2185,17 +2185,17 @@ Reads the character array from this **MessageSequence** object. **Return value** -| Type | Description | -| -------- | ------------------ | -| number[] | Character array read.| + | Type | Description | + | -------- | ------------------ | + | number[] | Character array read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -2227,17 +2227,17 @@ Writes a string array to this **MessageSequence** object. **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | -------- | ---- | ------------------------------------------------------- | -| stringArray | string[] | Yes | String array to write. The length of a single element in the array must be less than 40960 bytes.| + | Name | Type | Mandatory| Description | + | ----------- | -------- | ---- | ------------------------------------------------------- | + | stringArray | string[] | Yes | String array to write. The length of a single element in the array must be less than 40960 bytes.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900009 | write data to message sequence failed | **Example** @@ -2261,17 +2261,17 @@ Reads a string array from this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | -------------------- | -| dataIn | string[] | Yes | String array to read.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | -------------------- | + | dataIn | string[] | Yes | String array to read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -2302,17 +2302,17 @@ Reads the string array from this **MessageSequence** object. **Return value** -| Type | Description | -| -------- | ---------------- | -| string[] | String array read.| + | Type | Description | + | -------- | ---------------- | + | string[] | String array read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -2345,9 +2345,9 @@ Writes information to this **MessageSequence** object indicating that no excepti For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900009 | write data to message sequence failed | **Example** @@ -2387,9 +2387,9 @@ Reads the exception information from this **MessageSequence** object. For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -2417,7 +2417,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode FA.connectAbility(want, connect); ``` -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. ```ts let option = new rpc.MessageOption(); @@ -2459,17 +2459,17 @@ Writes a **Parcelable** array to this **MessageSequence** object. **Parameters** -| Name | Type | Mandatory| Description | -| --------------- | ------------ | ---- | -------------------------- | -| parcelableArray | Parcelable[] | Yes | **Parcelable** array to write.| + | Name | Type | Mandatory| Description | + | --------------- | ------------ | ---- | -------------------------- | + | parcelableArray | Parcelable[] | Yes | **Parcelable** array to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900009 | write data to message sequence failed | **Example** @@ -2515,18 +2515,18 @@ Reads a **Parcelable** array from this **MessageSequence** object. **Parameters** -| Name | Type | Mandatory| Description | -| --------------- | ------------ | ---- | -------------------------- | -| parcelableArray | Parcelable[] | Yes | **Parcelable** array to read.| + | Name | Type | Mandatory| Description | + | --------------- | ------------ | ---- | -------------------------- | + | parcelableArray | Parcelable[] | Yes | **Parcelable** array to read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | -| 1900012 | call js callback function failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | + | 1900012 | call js callback function failed | **Example** @@ -2576,17 +2576,17 @@ Writes an array of **IRemoteObject** objects to this **MessageSequence** object. **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | --------------- | ---- | ---------------------------------------------- | -| objectArray | IRemoteObject[] | Yes | Array of **IRemoteObject** objects to write.| + | Name | Type | Mandatory| Description | + | ----------- | --------------- | ---- | ---------------------------------------------- | + | objectArray | IRemoteObject[] | Yes | Array of **IRemoteObject** objects to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | ------- | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | ------- | + | 1900009 | write data to message sequence failed | **Example** @@ -2623,17 +2623,17 @@ Reads an array of **IRemoteObject** objects from this **MessageSequence** object **Parameters** -| Name | Type | Mandatory| Description | -| ------- | --------------- | ---- | ---------------------------------------------- | -| objects | IRemoteObject[] | Yes | **IRemoteObject** array to read.| + | Name | Type | Mandatory| Description | + | ------- | --------------- | ---- | ---------------------------------------------- | + | objects | IRemoteObject[] | Yes | **IRemoteObject** array to read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -2676,17 +2676,17 @@ Reads the **IRemoteObject** object array from this **MessageSequence** object. **Return value** -| Type | Description | -| --------------- | --------------------------- | -| IRemoteObject[] | **IRemoteObject** object array read.| + | Type | Description | + | --------------- | --------------------------- | + | IRemoteObject[] | **IRemoteObject** object array read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -2724,9 +2724,9 @@ Closes a file descriptor. This API is a static method. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------------------- | -| fd | number | Yes | File descriptor to close.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | -------------------- | + | fd | number | Yes | File descriptor to close.| **Example** @@ -2752,23 +2752,23 @@ Duplicates a file descriptor. This API is a static method. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------ | -| fd | number | Yes | File descriptor to duplicate.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------------ | + | fd | number | Yes | File descriptor to duplicate.| **Return value** -| Type | Description | -| ------ | -------------------- | -| number | New file descriptor.| + | Type | Description | + | ------ | -------------------- | + | number | New file descriptor.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | ------- | -| 1900013 | call os dup function failed | + | ID| Error Message| + | ------- | ------- | + | 1900013 | call os dup function failed | **Example** @@ -2794,9 +2794,9 @@ Checks whether this **MessageSequence** object contains file descriptors. **Return value** -| Type | Description | -| ------- | -------------------------------------------------------------------- | -| boolean | Returns **true** if the **MessageSequence** object contains file descriptors; returns **false** otherwise.| + | Type | Description | + | ------- | -------------------------------------------------------------------- | + | boolean | Returns **true** if the **MessageSequence** object contains file descriptors; returns **false** otherwise.| **Example** @@ -2832,17 +2832,17 @@ Writes a file descriptor to this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------ | -| fd | number | Yes | File descriptor to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------ | + | fd | number | Yes | File descriptor to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| -------- | ------ | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | -------- | ------ | + | 1900009 | write data to message sequence failed | **Example** @@ -2869,17 +2869,17 @@ Reads the file descriptor from this **MessageSequence** object. **Return value** -| Type | Description | -| ------ | ---------------- | -| number | File descriptor read.| + | Type | Description | + | ------ | ---------------- | + | number | File descriptor read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -2912,17 +2912,17 @@ Writes an anonymous shared object to this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------------------- | -| ashmem | Ashmem | Yes | Anonymous shared object to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------------------------- | + | ashmem | Ashmem | Yes | Anonymous shared object to write.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | ------- | -| 1900003 | write to ashmem failed | + | ID| Error Message| + | ------- | ------- | + | 1900003 | write to ashmem failed | **Example** @@ -2954,17 +2954,17 @@ Reads the anonymous shared object from this **MessageSequence** object. **Return value** -| Type | Description | -| ------ | ------------------ | -| Ashmem | Anonymous share object read.| + | Type | Description | + | ------ | ------------------ | + | Ashmem | Anonymous share object read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900004 | read from ashmem failed | + | ID| Error Message| + | ------- | -------- | + | 1900004 | read from ashmem failed | **Example** @@ -3002,9 +3002,9 @@ Obtains the maximum amount of raw data that can be held by this **MessageSequenc **Return value** -| Type | Description | -| ------ | ------------------------------------------------------------ | -| number | 128 MB, which is the maximum amount of raw data that can be held by this **MessageSequence** object.| + | Type | Description | + | ------ | ------------------------------------------------------------ | + | number | 128 MB, which is the maximum amount of raw data that can be held by this **MessageSequence** object.| **Example** @@ -3024,18 +3024,18 @@ Writes raw data to this **MessageSequence** object. **Parameters** -| Name | Type | Mandatory| Description | -| ------- | -------- | ---- | ---------------------------------- | -| rawData | number[] | Yes | Raw data to write. | -| size | number | Yes | Size of the raw data, in bytes.| + | Name | Type | Mandatory| Description | + | ------- | -------- | ---- | ---------------------------------- | + | rawData | number[] | Yes | Raw data to write. | + | size | number | Yes | Size of the raw data, in bytes.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | ------ | -| 1900009 | write data to message sequence failed | + | ID| Error Message| + | ------- | ------ | + | 1900009 | write data to message sequence failed | **Example** @@ -3060,23 +3060,23 @@ Reads raw data from this **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------ | -| size | number | Yes | Size of the raw data to read.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------------ | + | size | number | Yes | Size of the raw data to read.| **Return value** -| Type | Description | -| -------- | ------------------------------ | -| number[] | Raw data read, in bytes.| + | Type | Description | + | -------- | ------------------------------ | + | number[] | Raw data read, in bytes.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900010 | read data from message sequence failed | + | ID| Error Message| + | ------- | -------- | + | 1900010 | read data from message sequence failed | **Example** @@ -3116,9 +3116,9 @@ Creates a **MessageParcel** object. This method is a static method. **Return value** -| Type | Description | -| ------------- | ----------------------------- | -| MessageParcel | **MessageParcel** object created.| + | Type | Description | + | ------------- | ----------------------------- | + | MessageParcel | **MessageParcel** object created.| **Example** @@ -3152,15 +3152,15 @@ Serializes a remote object and writes it to this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------------------------------- | ---- | --------------------------------------- | -| object | [IRemoteObject](#iremoteobject) | Yes | Remote object to serialize and write to the **MessageParcel** object.| + | Name| Type | Mandatory| Description | + | ------ | ------------------------------- | ---- | --------------------------------------- | + | object | [IRemoteObject](#iremoteobject) | Yes | Remote object to serialize and write to the **MessageParcel** object.| **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** @@ -3199,9 +3199,9 @@ Reads the remote object from this **MessageParcel** object. You can use this met **Return value** -| Type | Description | -| ------------------------------- | ------------------ | -| [IRemoteObject](#iremoteobject) | Remote object obtained.| + | Type | Description | + | ------------------------------- | ------------------ | + | [IRemoteObject](#iremoteobject) | Remote object obtained.| **Example** @@ -3241,15 +3241,15 @@ Writes an interface token to this **MessageParcel** object. The remote object ca **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------ | -| token | string | Yes | Interface token to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------ | + | token | string | Yes | Interface token to write.| **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** @@ -3270,9 +3270,9 @@ Reads the interface token from this **MessageParcel** object. The interface toke **Return value** -| Type | Description | -| ------ | ------------------------ | -| string | Interface token obtained.| + | Type | Description | + | ------ | ------------------------ | + | string | Interface token obtained.| **Example** @@ -3296,9 +3296,9 @@ Obtains the data size of this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | --------------------------------------------- | -| number | Size of the **MessageParcel** object obtained, in bytes.| + | Type | Description | + | ------ | --------------------------------------------- | + | number | Size of the **MessageParcel** object obtained, in bytes.| **Example** @@ -3318,9 +3318,9 @@ Obtains the capacity of this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | --------------------------------------------- | -| number | **MessageParcel** capacity obtained, in bytes.| + | Type | Description | + | ------ | --------------------------------------------- | + | number | **MessageParcel** capacity obtained, in bytes.| **Example** @@ -3340,15 +3340,15 @@ Sets the size of data contained in this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------------------------- | -| size | number | Yes | Data size to set, in bytes.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------------------------------- | + | size | number | Yes | Data size to set, in bytes.| **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** @@ -3368,15 +3368,15 @@ Sets the storage capacity of this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------------------------- | -| size | number | Yes | Storage capacity to set, in bytes.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------------------------------- | + | size | number | Yes | Storage capacity to set, in bytes.| **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** @@ -3396,9 +3396,9 @@ Obtains the writable capacity of this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | --------------------------------------------------- | -| number | **MessageParcel** writable capacity obtained, in bytes.| + | Type | Description | + | ------ | --------------------------------------------------- | + | number | **MessageParcel** writable capacity obtained, in bytes.| **Example** @@ -3422,9 +3422,9 @@ Obtains the readable capacity of this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | --------------------------------------------------- | -| number | **MessageParcel** object readable capacity, in bytes.| + | Type | Description | + | ------ | --------------------------------------------------- | + | number | **MessageParcel** object readable capacity, in bytes.| **Example** @@ -3448,9 +3448,9 @@ Obtains the read position of this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | --------------------------------------- | -| number | Current read position of the **MessageParcel** object.| + | Type | Description | + | ------ | --------------------------------------- | + | number | Current read position of the **MessageParcel** object.| **Example** @@ -3470,9 +3470,9 @@ Obtains the write position of this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | --------------------------------------- | -| number | Current write position of the **MessageParcel** object.| + | Type | Description | + | ------ | --------------------------------------- | + | number | Current write position of the **MessageParcel** object.| **Example** @@ -3493,15 +3493,15 @@ Moves the read pointer to the specified position. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------ | -| pos | number | Yes | Position from which data is to read.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------------ | + | pos | number | Yes | Position from which data is to read.| **Return value** -| Type | Description | -| ------- | ------------------------------------------------- | -| boolean | Returns **true** if the read position changes; returns **false** otherwise.| + | Type | Description | + | ------- | ------------------------------------------------- | + | boolean | Returns **true** if the read position changes; returns **false** otherwise.| **Example** @@ -3526,15 +3526,15 @@ Moves the write pointer to the specified position. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------ | -| pos | number | Yes | Position from which data is to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------------ | + | pos | number | Yes | Position from which data is to write.| **Return value** -| Type | Description | -| ------- | --------------------------------------------- | -| boolean | Returns **true** if the write position changes; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------------------- | + | boolean | Returns **true** if the write position changes; returns **false** otherwise.| **Example** @@ -3557,15 +3557,15 @@ Writes a Byte value to this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------- | -| val | number | Yes | Byte value to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------- | + | val | number | Yes | Byte value to write.| **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** @@ -3585,9 +3585,9 @@ Reads the Byte value from this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | ------------ | -| number | Byte value read.| + | Type | Description | + | ------ | ------------ | + | number | Byte value read.| **Example** @@ -3609,15 +3609,15 @@ Writes a Short int value to this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------ | -| val | number | Yes | Short int value to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------ | + | val | number | Yes | Short int value to write.| **Return value** -| Type | Description | -| ------- | ----------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | ----------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -3637,9 +3637,9 @@ Reads the Short int value from this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | -------------- | -| number | Short int value read.| + | Type | Description | + | ------ | -------------- | + | number | Short int value read.| **Example** @@ -3661,15 +3661,15 @@ Writes an Int value to this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------- | -| val | number | Yes | Int value to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------- | + | val | number | Yes | Int value to write.| **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** @@ -3689,9 +3689,9 @@ Reads the Int value from this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | ------------ | -| number | Int value read.| + | Type | Description | + | ------ | ------------ | + | number | Int value read.| **Example** @@ -3713,15 +3713,15 @@ Writes a Long int value to this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------- | -| val | number | Yes | Long int value to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------- | + | val | number | Yes | Long int value to write.| **Return value** -| Type | Description | -| ------- | --------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -3741,9 +3741,9 @@ Reads the Long int value from this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | -------------- | -| number | Long int value read.| + | Type | Description | + | ------ | -------------- | + | number | Long int value read.| **Example** @@ -3765,15 +3765,15 @@ Writes a Float value to this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------- | -| val | number | Yes | Float value to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------- | + | val | number | Yes | Float value to write.| **Return value** -| Type | Description | -| ------- | --------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -3793,9 +3793,9 @@ Reads the Float value from this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | ------------ | -| number | Float value read.| + | Type | Description | + | ------ | ------------ | + | number | Float value read.| **Example** @@ -3817,15 +3817,15 @@ Writes a Double value to this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------------- | -| val | number | Yes | Double value to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------------- | + | val | number | Yes | Double value to write.| **Return value** -| Type | Description | -| ------- | --------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -3845,9 +3845,9 @@ Reads the Double value from this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | ------------------ | -| number | Double value read.| + | Type | Description | + | ------ | ------------------ | + | number | Double value read.| **Example** @@ -3869,15 +3869,15 @@ Writes a Boolean value to this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------- | ---- | ---------------- | -| val | boolean | Yes | Boolean value to write.| + | Name| Type | Mandatory| Description | + | ------ | ------- | ---- | ---------------- | + | val | boolean | Yes | Boolean value to write.| **Return value** -| Type | Description | -| ------- | --------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -3897,9 +3897,9 @@ Reads the Boolean value from this **MessageParcel** object. **Return value** -| Type | Description | -| ------- | -------------------- | -| boolean | Boolean value read.| + | Type | Description | + | ------- | -------------------- | + | boolean | Boolean value read.| **Example** @@ -3921,15 +3921,15 @@ Writes a Char value to this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------------------- | -| val | number | Yes | Char value to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | -------------------- | + | val | number | Yes | Char value to write.| **Return value** -| Type | Description | -| ------- | ----------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | ----------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -3949,9 +3949,9 @@ Reads the Char value from this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | ---------------- | -| number | Char value read.| + | Type | Description | + | ------ | ---------------- | + | number | Char value read.| **Example** @@ -3973,15 +3973,15 @@ Writes a string to this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ----------------------------------------- | -| val | string | Yes | String to write. The length of the string must be less than 40960 bytes.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ----------------------------------------- | + | val | string | Yes | String to write. The length of the string must be less than 40960 bytes.| **Return value** -| Type | Description | -| ------- | --------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -4001,9 +4001,9 @@ Reads the string from this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | -------------- | -| string | String read.| + | Type | Description | + | ------ | -------------- | + | string | String read.| **Example** @@ -4025,15 +4025,15 @@ Writes a sequenceable object to this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ----------------------------- | ---- | -------------------- | -| val | [Sequenceable](#sequenceable) | Yes | Sequenceable object to write.| + | Name| Type | Mandatory| Description | + | ------ | ----------------------------- | ---- | -------------------- | + | val | [Sequenceable](#sequenceable) | Yes | Sequenceable object to write.| **Return value** -| Type | Description | -| ------- | --------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -4072,15 +4072,15 @@ Reads member variables from this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ----------------------------- | ---- | --------------------------------------- | -| dataIn | [Sequenceable](#sequenceabledeprecated) | Yes | Object that reads member variables from the **MessageParcel** object.| + | Name| Type | Mandatory| Description | + | ------ | ----------------------------- | ---- | --------------------------------------- | + | dataIn | [Sequenceable](#sequenceabledeprecated) | Yes | Object that reads member variables from the **MessageParcel** object.| **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** @@ -4122,15 +4122,15 @@ Writes a byte array to this **MessageParcel** object. **Parameters** -| Name | Type | Mandatory| Description | -| --------- | -------- | ---- | ------------------ | -| byteArray | number[] | Yes | Byte array to write.| + | Name | Type | Mandatory| Description | + | --------- | -------- | ---- | ------------------ | + | byteArray | number[] | Yes | Byte array to write.| **Return value** -| Type | Description | -| ------- | --------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -4151,9 +4151,9 @@ Reads a byte array from this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | ------------------ | -| dataIn | number[] | Yes | Byte array to read.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | ------------------ | + | dataIn | number[] | Yes | Byte array to read.| **Example** @@ -4176,9 +4176,9 @@ Reads the byte array from this **MessageParcel** object. **Return value** -| Type | Description | -| -------- | -------------- | -| number[] | Byte array read.| + | Type | Description | + | -------- | -------------- | + | number[] | Byte array read.| **Example** @@ -4201,15 +4201,15 @@ Writes a short array to this **MessageParcel** object. **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | -------- | ---- | -------------------- | -| shortArray | number[] | Yes | Short array to write.| + | Name | Type | Mandatory| Description | + | ---------- | -------- | ---- | -------------------- | + | shortArray | number[] | Yes | Short array to write.| **Return value** -| Type | Description | -| ------- | ----------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | ----------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -4229,9 +4229,9 @@ Reads a short array from this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | -------------------- | -| dataIn | number[] | Yes | Short array to read.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | -------------------- | + | dataIn | number[] | Yes | Short array to read.| **Example** @@ -4253,9 +4253,9 @@ Reads the short array from this **MessageParcel** object. **Return value** -| Type | Description | -| -------- | ---------------- | -| number[] | Short array read.| + | Type | Description | + | -------- | ---------------- | + | number[] | Short array read.| **Example** @@ -4277,15 +4277,15 @@ Writes an integer array to this **MessageParcel** object. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------- | ---- | ------------------ | -| intArray | number[] | Yes | Integer array to write.| + | Name | Type | Mandatory| Description | + | -------- | -------- | ---- | ------------------ | + | intArray | number[] | Yes | Integer array to write.| **Return value** -| Type | Description | -| ------- | ----------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | ----------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -4305,9 +4305,9 @@ Reads an integer array from this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | ------------------ | -| dataIn | number[] | Yes | Integer array to read.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | ------------------ | + | dataIn | number[] | Yes | Integer array to read.| **Example** @@ -4329,9 +4329,9 @@ Reads the integer array from this **MessageParcel** object. **Return value** -| Type | Description | -| -------- | -------------- | -| number[] | Integer array read.| + | Type | Description | + | -------- | -------------- | + | number[] | Integer array read.| **Example** @@ -4353,15 +4353,15 @@ Writes a long array to this **MessageParcel** object. **Parameters** -| Name | Type | Mandatory| Description | -| --------- | -------- | ---- | -------------------- | -| longArray | number[] | Yes | Long array to write.| + | Name | Type | Mandatory| Description | + | --------- | -------- | ---- | -------------------- | + | longArray | number[] | Yes | Long array to write.| **Return value** -| Type | Description | -| ------- | ----------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | ----------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -4381,9 +4381,9 @@ Reads a long array from this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | -------------------- | -| dataIn | number[] | Yes | Long array to read.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | -------------------- | + | dataIn | number[] | Yes | Long array to read.| **Example** @@ -4405,9 +4405,9 @@ Reads the long array from this **MessageParcel** object. **Return value** -| Type | Description | -| -------- | ---------------- | -| number[] | Long array read.| + | Type | Description | + | -------- | ---------------- | + | number[] | Long array read.| **Example** @@ -4429,15 +4429,15 @@ Writes a FloatArray to this **MessageParcel** object. **Parameters** -| Name| Type| Mandatory| Description| -| ---------- | -------- | ---- | --- | -| floatArray | number[] | Yes | Floating-point array to write. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.| + | Name| Type| Mandatory| Description| + | ---------- | -------- | ---- | --- | + | floatArray | number[] | Yes | Floating-point array to write. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.| **Return value** -| Type | Description | -| ------- | ----------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | ----------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -4457,9 +4457,9 @@ Reads a FloatArray from this **MessageParcel** object. **Parameters** -| Name| Type| Mandatory| Description| -| ------ | -------- | ---- | ------ | -| dataIn | number[] | Yes | Floating-point array to read. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.| + | Name| Type| Mandatory| Description| + | ------ | -------- | ---- | ------ | + | dataIn | number[] | Yes | Floating-point array to read. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.| **Example** @@ -4481,9 +4481,9 @@ Reads the FloatArray from this **MessageParcel** object. **Return value** -| Type | Description | -| -------- | -------------- | -| number[] | FloatArray read.| + | Type | Description | + | -------- | -------------- | + | number[] | FloatArray read.| **Example** @@ -4505,15 +4505,15 @@ Writes a DoubleArray to this **MessageParcel** object. **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | -------- | ---- | ------------------------ | -| doubleArray | number[] | Yes | DoubleArray to write.| + | Name | Type | Mandatory| Description | + | ----------- | -------- | ---- | ------------------------ | + | doubleArray | number[] | Yes | DoubleArray to write.| **Return value** -| Type | Description | -| ------- | ----------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | ----------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -4533,9 +4533,9 @@ Reads a DoubleArray from this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | ------------------------ | -| dataIn | number[] | Yes | DoubleArray to read.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | ------------------------ | + | dataIn | number[] | Yes | DoubleArray to read.| **Example** @@ -4557,9 +4557,9 @@ Reads the DoubleArray from this **MessageParcel** object. **Return value** -| Type | Description | -| -------- | -------------------- | -| number[] | DoubleArray read.| + | Type | Description | + | -------- | -------------------- | + | number[] | DoubleArray read.| **Example** @@ -4581,15 +4581,15 @@ Writes a Boolean array to this **MessageParcel** object. **Parameters** -| Name | Type | Mandatory| Description | -| ------------ | --------- | ---- | ------------------ | -| booleanArray | boolean[] | Yes | Boolean array to write.| + | Name | Type | Mandatory| Description | + | ------------ | --------- | ---- | ------------------ | + | booleanArray | boolean[] | Yes | Boolean array to write.| **Return value** -| Type | Description | -| ------- | --------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -4609,9 +4609,9 @@ Reads a Boolean array from this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | --------- | ---- | ------------------ | -| dataIn | boolean[] | Yes | Boolean array to read.| + | Name| Type | Mandatory| Description | + | ------ | --------- | ---- | ------------------ | + | dataIn | boolean[] | Yes | Boolean array to read.| **Example** @@ -4633,9 +4633,9 @@ Reads the Boolean array from this **MessageParcel** object. **Return value** -| Type | Description | -| --------- | -------------- | -| boolean[] | Boolean array read.| + | Type | Description | + | --------- | -------------- | + | boolean[] | Boolean array read.| **Example** @@ -4657,15 +4657,15 @@ Writes a character array to this **MessageParcel** object. **Parameters** -| Name | Type | Mandatory| Description | -| --------- | -------- | ---- | ---------------------- | -| charArray | number[] | Yes | Character array to write.| + | Name | Type | Mandatory| Description | + | --------- | -------- | ---- | ---------------------- | + | charArray | number[] | Yes | Character array to write.| **Return value** -| Type | Description | -| ------- | --------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -4685,9 +4685,9 @@ Reads a character array from this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | ---------------------- | -| dataIn | number[] | Yes | Character array to read.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | ---------------------- | + | dataIn | number[] | Yes | Character array to read.| **Example** @@ -4709,9 +4709,9 @@ Reads the character array from this **MessageParcel** object. **Return value** -| Type | Description | -| -------- | ------------------ | -| number[] | Character array read.| + | Type | Description | + | -------- | ------------------ | + | number[] | Character array read.| **Example** @@ -4733,15 +4733,15 @@ Writes a string array to this **MessageParcel** object. **Parameters** -| Name | Type | Mandatory| Description| -| ----------- | -------- | ---- | ---------------- | -| stringArray | string[] | Yes | String array to write. The length of a single element in the array must be less than 40960 bytes.| + | Name | Type | Mandatory| Description| + | ----------- | -------- | ---- | ---------------- | + | stringArray | string[] | Yes | String array to write. The length of a single element in the array must be less than 40960 bytes.| **Return value** -| Type | Description| -| ------- | --------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description| + | ------- | --------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -4761,9 +4761,9 @@ Reads a string array from this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | -------------------- | -| dataIn | string[] | Yes | String array to read.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | -------------------- | + | dataIn | string[] | Yes | String array to read.| **Example** @@ -4785,9 +4785,9 @@ Reads the string array from this **MessageParcel** object. **Return value** -| Type | Description | -| -------- | ---------------- | -| string[] | String array read.| + | Type | Description | + | -------- | ---------------- | + | string[] | String array read.| **Example** @@ -4850,7 +4850,7 @@ Reads the exception information from this **MessageParcel** object. **System capability**: SystemCapability.Communication.IPC.Core **Example** - + Obtain the service. ```ts @@ -4875,7 +4875,7 @@ Reads the exception information from this **MessageParcel** object. FA.connectAbility(want, connect); ``` -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. ```ts let option = new rpc.MessageOption(); @@ -4912,15 +4912,15 @@ Writes a sequenceable array to this **MessageParcel** object. **Parameters** -| Name | Type | Mandatory| Description | -| ----------------- | -------------- | ---- | -------------------------- | -| sequenceableArray | Sequenceable[] | Yes | Sequenceable array to write.| + | Name | Type | Mandatory| Description | + | ----------------- | -------------- | ---- | -------------------------- | + | sequenceableArray | Sequenceable[] | Yes | Sequenceable array to write.| **Return value** -| Type | Description | -| ------- | --------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -4962,9 +4962,9 @@ Reads a sequenceable array from this **MessageParcel** object. **Parameters** -| Name | Type | Mandatory| Description | -| ----------------- | -------------- | ---- | -------------------------- | -| sequenceableArray | Sequenceable[] | Yes | Sequenceable array to read.| + | Name | Type | Mandatory| Description | + | ----------------- | -------------- | ---- | -------------------------- | + | sequenceableArray | Sequenceable[] | Yes | Sequenceable array to read.| **Example** @@ -5008,15 +5008,15 @@ Writes an array of **IRemoteObject** objects to this **MessageParcel** object. **Parameters** -| Name | Type | Mandatory| Description| -| ----------- | --------------- | ---- | ----- | -| objectArray | IRemoteObject[] | Yes | Array of **IRemoteObject** objects to write.| + | Name | Type | Mandatory| Description| + | ----------- | --------------- | ---- | ----- | + | objectArray | IRemoteObject[] | Yes | Array of **IRemoteObject** objects to write.| **Return value** -| Type | Description | -| ------- | -------------------------------------------------------------------------------------------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | -------------------------------------------------------------------------------------------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -5060,9 +5060,9 @@ Reads an **IRemoteObject** array from this **MessageParcel** object. **Parameters** -| Name | Type | Mandatory| Description| -| ------- | --------------- | ---- | --------- | -| objects | IRemoteObject[] | Yes | **IRemoteObject** array to read.| + | Name | Type | Mandatory| Description| + | ------- | --------------- | ---- | --------- | + | objects | IRemoteObject[] | Yes | **IRemoteObject** array to read.| **Example** @@ -5107,9 +5107,9 @@ Reads the **IRemoteObject** array from this **MessageParcel** object. **Return value** -| Type| Description| -| --------------- | -------- | -| IRemoteObject[] | **IRemoteObject** object array obtained.| + | Type| Description| + | --------------- | -------- | + | IRemoteObject[] | **IRemoteObject** object array obtained.| **Example** @@ -5155,9 +5155,9 @@ Closes a file descriptor. This API is a static method. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------------------- | -| fd | number | Yes | File descriptor to close.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | -------------------- | + | fd | number | Yes | File descriptor to close.| **Example** @@ -5178,15 +5178,15 @@ Duplicates a file descriptor. This API is a static method. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------ | -| fd | number | Yes | File descriptor to duplicate.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------------ | + | fd | number | Yes | File descriptor to duplicate.| **Return value** -| Type | Description | -| ------ | -------------------- | -| number | New file descriptor.| + | Type | Description | + | ------ | -------------------- | + | number | New file descriptor.| **Example** @@ -5207,9 +5207,9 @@ Checks whether this **MessageParcel** object contains file descriptors. **Return value** -| Type | Description | -| ------- | ------------------------------------------------------------------ | -| boolean |Returns **true** if the **MessageParcel** object contains file descriptors; returns **false** otherwise.| + | Type | Description | + | ------- | ------------------------------------------------------------------ | + | boolean |Returns **true** if the **MessageParcel** object contains file descriptors; returns **false** otherwise.| **Example** @@ -5235,15 +5235,15 @@ Writes a file descriptor to this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------ | -| fd | number | Yes | File descriptor to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------ | + | fd | number | Yes | File descriptor to write.| **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** @@ -5266,9 +5266,9 @@ Reads the file descriptor from this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | ---------------- | -| number | File descriptor read.| + | Type | Description | + | ------ | ---------------- | + | number | File descriptor read.| **Example** @@ -5292,15 +5292,15 @@ Writes an anonymous shared object to this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ----------------------------------- | -| ashmem | Ashmem | Yes | Anonymous shared object to write.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ----------------------------------- | + | ashmem | Ashmem | Yes | Anonymous shared object to write.| **Return value** -| Type | Description | -| ------- | -------------------------------------------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | -------------------------------------------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -5321,9 +5321,9 @@ Reads the anonymous shared object from this **MessageParcel** object. **Return value** -| Type | Description | -| ------ | ------------------ | -| Ashmem | Anonymous share object obtained.| + | Type | Description | + | ------ | ------------------ | + | Ashmem | Anonymous share object obtained.| **Example** @@ -5346,9 +5346,9 @@ Obtains the maximum amount of raw data that can be held by this **MessageParcel* **Return value** -| Type | Description | -| ------ | ---------------------------------------------------------- | -| number | 128 MB, which is the maximum amount of raw data that can be held by this **MessageParcel** object.| + | Type | Description | + | ------ | ---------------------------------------------------------- | + | number | 128 MB, which is the maximum amount of raw data that can be held by this **MessageParcel** object.| **Example** @@ -5368,16 +5368,16 @@ Writes raw data to this **MessageParcel** object. **Parameters** -| Name | Type | Mandatory| Description | -| ------- | -------- | ---- | ---------------------------------- | -| rawData | number[] | Yes | Raw data to write. | -| size | number | Yes | Size of the raw data, in bytes.| + | Name | Type | Mandatory| Description | + | ------- | -------- | ---- | ---------------------------------- | + | rawData | number[] | Yes | Raw data to write. | + | size | number | Yes | Size of the raw data, in bytes.| **Return value** -| Type | Description | -| ------- | ----------------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | ----------------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -5398,15 +5398,15 @@ Reads raw data from this **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------ | -| size | number | Yes | Size of the raw data to read.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------------ | + | size | number | Yes | Size of the raw data to read.| **Return value** -| Type | Description | -| -------- | ------------------------------ | -| number[] | Raw data obtained, in bytes.| + | Type | Description | + | -------- | ------------------------------ | + | number[] | Raw data obtained, in bytes.| **Example** @@ -5433,15 +5433,15 @@ Marshals this **Parcelable** object into a **MessageSequence** object. **Parameters** -| Name | Type | Mandatory| Description | -| ------- | --------------- | ---- | ------------------------------------------- | -| dataOut | MessageSequence | Yes | **MessageSequence** object to which the **Parcelable** object is to be marshaled.| + | Name | Type | Mandatory| Description | + | ------- | --------------- | ---- | ------------------------------------------- | + | dataOut | MessageSequence | Yes | **MessageSequence** object to which the **Parcelable** object is to be marshaled.| **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** ```ts @@ -5482,15 +5482,15 @@ Unmarshals this **Parcelable** object from a **MessageSequence** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | --------------- | ---- | ----------------------------------------------- | -| dataIn | MessageSequence | Yes | **MessageSequence** object from which the **Parcelable** object is to be unmarshaled.| + | Name| Type | Mandatory| Description | + | ------ | --------------- | ---- | ----------------------------------------------- | + | dataIn | MessageSequence | Yes | **MessageSequence** object from which the **Parcelable** object is to be unmarshaled.| **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** @@ -5538,15 +5538,15 @@ Marshals the sequenceable object into a **MessageParcel** object. **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------------------------------- | ---- | ----------------------------------------- | -| dataOut | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object to which the sequenceable object is to be marshaled.| + | Name | Type | Mandatory| Description | + | ------- | ------------------------------- | ---- | ----------------------------------------- | + | dataOut | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object to which the sequenceable object is to be marshaled.| **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** ```ts @@ -5587,15 +5587,15 @@ Unmarshals this sequenceable object from a **MessageParcel** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------------------------------- | ---- | --------------------------------------------- | -| dataIn | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object in which the sequenceable object is to be unmarshaled.| + | Name| Type | Mandatory| Description | + | ------ | ------------------------------- | ---- | --------------------------------------------- | + | dataIn | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object in which the sequenceable object is to be unmarshaled.| **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** @@ -5641,9 +5641,9 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl **Return value** -| Type | Description| -| ---- | ----- | -| [IRemoteObject](#iremoteobject) | Returns the **RemoteObject** if it is the caller; returns the [IRemoteObject](#iremoteobject), the holder of this **RemoteProxy** object, if the caller is a [RemoteProxy](#remoteproxy) object.| + | Type | Description| + | ---- | ----- | + | [IRemoteObject](#iremoteobject) | Returns the **RemoteObject** if it is the caller; returns the [IRemoteObject](#iremoteobject), the holder of this **RemoteProxy** object, if the caller is a [RemoteProxy](#remoteproxy) object.| **Example** @@ -5653,7 +5653,7 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl return this; } } - let remoteObject = new TestAbility().asObject(); + let remoteObject = new TestAbility("testObject").asObject(); ``` **Example** @@ -5681,9 +5681,9 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl }; FA.connectAbility(want, connect); ``` - -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **asObject()** of the proxy object is called to obtain the proxy or remote object. - + + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **asObject()** of the proxy object is called to obtain the proxy or remote object. + ```ts class TestProxy { remote: rpc.RemoteObject; @@ -5726,12 +5726,12 @@ Defines the response to the request. **System capability**: SystemCapability.Communication.IPC.Core -| Name | Type | Readable| Writable| Description | -| ------- | --------------- | ---- | ---- |-------------------------------------- | -| errCode | number | Yes | No | Error Code | -| code | number | Yes | No | Message code. | -| data | MessageSequence | Yes | No | **MessageSequence** object sent to the remote process.| -| reply | MessageSequence | Yes | No | **MessageSequence** object returned by the remote process. | + | Name | Type | Readable| Writable| Description | + | ------- | --------------- | ---- | ---- |-------------------------------------- | + | errCode | number | Yes | No | Error code. | + | code | number | Yes | No | Message code. | + | data | MessageSequence | Yes | No | **MessageSequence** object sent to the remote process.| + | reply | MessageSequence | Yes | No | **MessageSequence** object returned by the remote process. | ## SendRequestResult8+(deprecated) @@ -5741,12 +5741,12 @@ Defines the response to the request. **System capability**: SystemCapability.Communication.IPC.Core -| Name | Type | Readable| Writable| Description | -| ------- | ------------- | ---- | ---- | ----------------------------------- | -| errCode | number | Yes | No | Error Code | -| code | number | Yes | No | Message code. | -| data | MessageParcel | Yes | No | **MessageParcel** object sent to the remote process.| -| reply | MessageParcel | Yes | No | **MessageParcel** object returned by the remote process. | + | Name | Type | Readable| Writable| Description | + | ------- | ------------- | ---- | ---- | ----------------------------------- | + | errCode | number | Yes | No | Error code. | + | code | number | Yes | No | Message code. | + | data | MessageParcel | Yes | No | **MessageParcel** object sent to the remote process.| + | reply | MessageParcel | Yes | No | **MessageParcel** object returned by the remote process. | ## IRemoteObject @@ -5762,15 +5762,15 @@ Obtains the interface descriptor. **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------ | ---- | -------------------- | -| descriptor | string | Yes | Interface descriptor.| + | Name | Type | Mandatory| Description | + | ---------- | ------ | ---- | -------------------- | + | descriptor | string | Yes | Interface descriptor.| **Return value** -| Type | Description | -| ------------- | --------------------------------------------- | -| IRemoteBroker | **IRemoteBroker** object bound to the specified interface token.| + | Type | Description | + | ------------- | --------------------------------------------- | + | IRemoteBroker | **IRemoteBroker** object bound to the specified interface token.| ### queryLocalInterface(deprecated) @@ -5784,15 +5784,15 @@ Queries the interface descriptor. **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------ | ---- | -------------------- | -| descriptor | string | Yes | Interface descriptor.| + | Name | Type | Mandatory| Description | + | ---------- | ------ | ---- | -------------------- | + | descriptor | string | Yes | Interface descriptor.| **Return value** -| Type | Description | -| ------------- | --------------------------------------------- | -| IRemoteBroker | **IRemoteBroker** object bound to the specified interface token.| + | Type | Description | + | ------------- | --------------------------------------------- | + | IRemoteBroker | **IRemoteBroker** object bound to the specified interface token.| ### sendRequest(deprecated) @@ -5806,18 +5806,18 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **Parameters** -| Name | Type| Mandatory| Description | -| ------- | ------------------------------- | ---- | ---- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | -| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | Name | Type| Mandatory| Description | + | ------- | ------------------------------- | ---- | ---- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | + | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | **Return value** -| Type | Description | -| ------- | --------------------------------------------- | -| boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------------------- | + | boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.| ### sendRequest8+(deprecated) @@ -5832,18 +5832,18 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | -| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | Name | Type | Mandatory| Description | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | + | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | **Return value** -| Type | Description | -| -------------------------------- | --------------------------------------------- | -| Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| + | Type | Description | + | -------------------------------- | --------------------------------------------- | + | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| ### sendMessageRequest9+ @@ -5856,18 +5856,18 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | -| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | Name | Type | Mandatory| Description | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | + | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | **Return value** -| Type | Description | -| ---------------------------- | ----------------------------------------- | -| Promise<RequestResult> | Promise used to return the **requestResult** object.| + | Type | Description | + | ---------------------------- | ----------------------------------------- | + | Promise<RequestResult> | Promise used to return the **requestResult** object.| ### sendMessageRequest9+ @@ -5880,13 +5880,13 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | -| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | -| callback | AsyncCallback<RequestResult> | Yes | Callback for receiving the sending result. | + | Name | Type | Mandatory| Description | + | -------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | + | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | callback | AsyncCallback<RequestResult> | Yes | Callback for receiving the sending result. | ### sendRequest8+(deprecated) @@ -5900,13 +5900,13 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | -| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | -| callback | AsyncCallback<SendRequestResult> | Yes | Callback for receiving the sending result. | + | Name | Type | Mandatory| Description | + | -------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | + | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | callback | AsyncCallback<SendRequestResult> | Yes | Callback for receiving the sending result. | ### registerDeathRecipient9+ @@ -5918,18 +5918,18 @@ Registers a callback for receiving death notifications of the remote object. The **Parameters** -| Name | Type | Mandatory| Description | -| --------- | --------------------------------- | ---- | -------------- | -| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to register.| -| flags | number | Yes | Flag of the death notification.| + | Name | Type | Mandatory| Description | + | --------- | --------------------------------- | ---- | -------------- | + | recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to register.| + | flags | number | Yes | Flag of the death notification.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900008 | proxy or remote object is invalid | + | ID| Error Message| + | ------- | -------- | + | 1900008 | proxy or remote object is invalid | ### addDeathrecipient(deprecated) @@ -5943,16 +5943,16 @@ Adds a callback for receiving death notifications of the remote object. This met **Parameters** -| Name | Type | Mandatory| Description | -| --------- | --------------------------------- | ---- | -------------- | -| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to add.| -| flags | number | Yes | Flag of the death notification.| + | Name | Type | Mandatory| Description | + | --------- | --------------------------------- | ---- | -------------- | + | recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to add.| + | flags | number | Yes | Flag of the death notification.| **Return value** -| Type | Description | -| ------- | --------------------------------------------- | -| boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------------------- | + | boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.| ### unregisterDeathRecipient9+ @@ -5965,18 +5965,18 @@ Unregisters the callback used to receive death notifications of the remote objec **Parameters** -| Name | Type | Mandatory| Description | -| --------- | --------------------------------- | ---- | -------------- | -| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to unregister.| -| flags | number | Yes | Flag of the death notification.| + | Name | Type | Mandatory| Description | + | --------- | --------------------------------- | ---- | -------------- | + | recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to unregister.| + | flags | number | Yes | Flag of the death notification.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900008 | proxy or remote object is invalid | + | ID| Error Message| + | ------- | -------- | + | 1900008 | proxy or remote object is invalid | ### removeDeathRecipient(deprecated) @@ -5990,16 +5990,16 @@ Removes the callback used to receive death notifications of the remote object. **Parameters** -| Name | Type | Mandatory| Description | -| --------- | --------------------------------- | ---- | -------------- | -| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to remove.| -| flags | number | Yes | Flag of the death notification.| + | Name | Type | Mandatory| Description | + | --------- | --------------------------------- | ---- | -------------- | + | recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to remove.| + | flags | number | Yes | Flag of the death notification.| **Return value** -| Type | Description | -| ------- | --------------------------------------------- | -| boolean | Returns **true** if the callback is removed; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------------------- | + | boolean | Returns **true** if the callback is removed; returns **false** otherwise.| ### getDescriptor9+ @@ -6011,17 +6011,17 @@ Obtains the interface descriptor (which is a string) of this object. **Return value** -| Type | Description | -| ------ | ---------------- | -| string | Interface descriptor obtained.| + | Type | Description | + | ------ | ---------------- | + | string | Interface descriptor obtained.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900008 | proxy or remote object is invalid | + | ID| Error Message| + | ------- | -------- | + | 1900008 | proxy or remote object is invalid | ### getInterfaceDescriptor(deprecated) @@ -6036,9 +6036,9 @@ Obtains the interface descriptor (which is a string) of this object. **Return value** -| Type | Description | -| ------ | ---------------- | -| string | Interface descriptor obtained.| + | Type | Description | + | ------ | ---------------- | + | string | Interface descriptor obtained.| ### isObjectDead @@ -6051,9 +6051,9 @@ Checks whether this object is dead. **Return value** -| Type | Description | -| ------- | ------------------------------------------- | -| boolean | Returns **true** if the object is dead; returns **false** otherwise.| + | Type | Description | + | ------- | ------------------------------------------- | + | boolean | Returns **true** if the object is dead; returns **false** otherwise.| ## RemoteProxy @@ -6082,18 +6082,18 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | -| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | Name | Type | Mandatory| Description | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | + | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | **Return value** -| Type | Description | -| ------- | --------------------------------------------- | -| boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------------------- | + | boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.| **Example** @@ -6120,9 +6120,9 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch }; FA.connectAbility(want, connect); ``` - -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. - + + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. + ```ts let option = new rpc.MessageOption(); let data = rpc.MessageParcel.create(); @@ -6152,18 +6152,18 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | -| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | Name | Type | Mandatory| Description | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | + | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | **Return value** -| Type | Description | -| ---------------------------- | ----------------------------------------- | -| Promise<RequestResult> | Promise used to return the **requestResult** object.| + | Type | Description | + | ---------------------------- | ----------------------------------------- | + | Promise<RequestResult> | Promise used to return the **requestResult** object.| **Example** @@ -6190,8 +6190,8 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn }; FA.connectAbility(want, connect); ``` - -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. + + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. ```ts let option = new rpc.MessageOption(); @@ -6230,18 +6230,18 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | -| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | Name | Type | Mandatory| Description | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | + | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | **Return value** -| Type | Description | -| -------------------------------- | --------------------------------------------- | -| Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| + | Type | Description | + | -------------------------------- | --------------------------------------------- | + | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| **Example** @@ -6269,7 +6269,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch FA.connectAbility(want, connect); ``` -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. ```ts let option = new rpc.MessageOption(); @@ -6300,22 +6300,22 @@ The proxy object in the **onConnect** callback can be assigned a value only afte sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback<RequestResult>): void -Sends a **MessageSequence** message to the remote process in synchronous or asynchronous mode. If asynchronous mode is set in **options**, a callback will be called immediately, and the reply message is empty. The specific reply needs to be obtained from the callback on the service side. If **options** is the synchronous mode, a callback will be invoked at certain time after the response to **sendMessageRequest** is returned, and the reply contains the returned information. +Sends a **MessageSequence** message to the remote process in synchronous or asynchronous mode. If asynchronous mode is set in **options**, a callback will be called immediately, and the reply message is empty. The specific reply needs to be obtained from the callback on the service side. If synchronous mode is set in **options**, a callback will be invoked at certain time after the response to **sendMessageRequest** is returned, and the reply contains the returned information. **System capability**: SystemCapability.Communication.IPC.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | -| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | -| callback | AsyncCallback<RequestResult> | Yes | Callback for receiving the sending result. | + | Name | Type | Mandatory| Description | + | -------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | + | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | callback | AsyncCallback<RequestResult> | Yes | Callback for receiving the sending result. | **Example** - + Obtain the service. ```ts @@ -6353,7 +6353,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn FA.connectAbility(want, connect); ``` -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. ```ts let option = new rpc.MessageOption(); @@ -6381,13 +6381,13 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | -| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | -| callback | AsyncCallback<SendRequestResult> | Yes | Callback for receiving the sending result. | + | Name | Type | Mandatory| Description | + | -------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | + | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | callback | AsyncCallback<SendRequestResult> | Yes | Callback for receiving the sending result. | **Example** @@ -6428,7 +6428,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch FA.connectAbility(want, connect); ``` -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. ```ts let option = new rpc.MessageOption(); @@ -6449,23 +6449,23 @@ Obtains the **LocalInterface** object of an interface token. **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------ | ---- | ---------------------- | -| interface | string | Yes | Interface descriptor.| + | Name | Type | Mandatory| Description | + | --------- | ------ | ---- | ---------------------- | + | interface | string | Yes | Interface descriptor.| **Return value** -| Type | Description | -| ------------- | ------------------------------------------ | -| IRemoteBroker | Returns **Null** by default, which indicates a proxy interface.| + | Type | Description | + | ------------- | ------------------------------------------ | + | IRemoteBroker | Returns **Null** by default, which indicates a proxy interface.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900006 | only remote object permitted | + | ID| Error Message| + | ------- | -------- | + | 1900006 | only remote object permitted | **Example** @@ -6493,7 +6493,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode FA.connectAbility(want, connect); ``` -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **getLocalInterface()** of the proxy object is called to obtain the interface descriptor. + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **getLocalInterface()** of the proxy object is called to obtain the interface descriptor. ```ts try { @@ -6517,15 +6517,15 @@ Obtains the **LocalInterface** object of an interface token. **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------ | ---- | ---------------------- | -| interface | string | Yes | Interface descriptor.| + | Name | Type | Mandatory| Description | + | --------- | ------ | ---- | ---------------------- | + | interface | string | Yes | Interface descriptor.| **Return value** -| Type | Description | -| ------------- | ------------------------------------------ | -| IRemoteBroker | Returns **Null** by default, which indicates a proxy interface.| + | Type | Description | + | ------------- | ------------------------------------------ | + | IRemoteBroker | Returns **Null** by default, which indicates a proxy interface.| **Example** @@ -6552,8 +6552,8 @@ Obtains the **LocalInterface** object of an interface token. }; FA.connectAbility(want, connect); ``` - -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **queryLocalInterface()** of the proxy object is called to obtain the interface descriptor. + + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **queryLocalInterface()** of the proxy object is called to obtain the interface descriptor. ```ts let broker = proxy.queryLocalInterface("testObject"); @@ -6570,18 +6570,18 @@ Registers a callback for receiving death notifications of the remote object. The **Parameters** -| Name | Type | Mandatory| Description | -| --------- | --------------------------------- | ---- | -------------- | -| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to register.| -| flags | number | Yes | Flag of the death notification.| + | Name | Type | Mandatory| Description | + | --------- | --------------------------------- | ---- | -------------- | + | recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to register.| + | flags | number | Yes | Flag of the death notification.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900008 | proxy or remote object is invalid | + | ID| Error Message| + | ------- | -------- | + | 1900008 | proxy or remote object is invalid | **Example** @@ -6609,8 +6609,8 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode FA.connectAbility(want, connect); ``` -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **registerDeathRecipient()** of the proxy object is called to register a callback for receiving the death notification of the remote object. - + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **registerDeathRecipient()** of the proxy object is called to register a callback for receiving the death notification of the remote object. + ```ts class MyDeathRecipient { onRemoteDied() { @@ -6638,16 +6638,16 @@ Adds a callback for receiving the death notifications of the remote object, incl **Parameters** -| Name | Type | Mandatory| Description | -| --------- | --------------------------------- | ---- | --------------------------------- | -| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to add. | -| flags | number | Yes | Flag of the death notification. This parameter is reserved. It is set to **0**.| + | Name | Type | Mandatory| Description | + | --------- | --------------------------------- | ---- | --------------------------------- | + | recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to add. | + | flags | number | Yes | Flag of the death notification. This parameter is reserved. It is set to **0**.| **Return value** -| Type | Description | -| ------- | --------------------------------------------- | -| boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------------------- | + | boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.| **Example** @@ -6674,8 +6674,8 @@ Adds a callback for receiving the death notifications of the remote object, incl }; FA.connectAbility(want, connect); ``` - -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **addDeathRecippient()** of the proxy object is called to add a callback for receiving the death notification of the remove object. + + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **addDeathRecippient()** of the proxy object is called to add a callback for receiving the death notification of the remove object. ```ts class MyDeathRecipient { @@ -6697,18 +6697,18 @@ Unregisters the callback used to receive death notifications of the remote objec **Parameters** -| Name | Type | Mandatory| Description | -| --------- | --------------------------------- | ---- | -------------- | -| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to unregister.| -| flags | number | Yes | Flag of the death notification.| + | Name | Type | Mandatory| Description | + | --------- | --------------------------------- | ---- | -------------- | + | recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to unregister.| + | flags | number | Yes | Flag of the death notification.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900008 | proxy or remote object is invalid | + | ID| Error Message| + | ------- | -------- | + | 1900008 | proxy or remote object is invalid | **Example** @@ -6735,8 +6735,8 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode }; FA.connectAbility(want, connect); ``` - -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **unregisterDeathRecipient()** of the proxy object is called to unregister the callback for receiving the death notification of the remote object. + + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **unregisterDeathRecipient()** of the proxy object is called to unregister the callback for receiving the death notification of the remote object. ```ts class MyDeathRecipient { @@ -6766,16 +6766,16 @@ Removes the callback used to receive death notifications of the remote object. **Parameters** -| Name | Type | Mandatory| Description | -| --------- | --------------------------------- | ---- | --------------------------------- | -| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to remove. | -| flags | number | Yes | Flag of the death notification. This parameter is reserved. It is set to **0**.| + | Name | Type | Mandatory| Description | + | --------- | --------------------------------- | ---- | --------------------------------- | + | recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to remove. | + | flags | number | Yes | Flag of the death notification. This parameter is reserved. It is set to **0**.| **Return value** -| Type | Description | -| ------- | --------------------------------------------- | -| boolean | Returns **true** if the callback is removed; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------------------- | + | boolean | Returns **true** if the callback is removed; returns **false** otherwise.| **Example** @@ -6802,8 +6802,8 @@ Removes the callback used to receive death notifications of the remote object. }; FA.connectAbility(want, connect); ``` - -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **removeDeathRecipient()** of the proxy object is called to remove the callback used to receive the death notification of the remote object. + + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **removeDeathRecipient()** of the proxy object is called to remove the callback used to receive the death notification of the remote object. ```ts class MyDeathRecipient { @@ -6826,18 +6826,18 @@ Obtains the interface descriptor (which is a string) of this proxy object. **Return value** -| Type | Description | -| ------ | ---------------- | -| string | Interface descriptor obtained.| + | Type | Description | + | ------ | ---------------- | + | string | Interface descriptor obtained.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| -------- | ------- | -| 1900008 | proxy or remote object is invalid | -| 1900007 | communication failed | + | ID| Error Message| + | -------- | ------- | + | 1900008 | proxy or remote object is invalid | + | 1900007 | communication failed | **Example** @@ -6864,7 +6864,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode }; FA.connectAbility(want, connect); ``` -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **getDescriptor()** of the proxy object is called to obtain the interface descriptor of the object. + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **getDescriptor()** of the proxy object is called to obtain the interface descriptor of the object. ```ts try { @@ -6888,9 +6888,9 @@ Obtains the interface descriptor of this proxy object. **Return value** -| Type | Description | -| ------ | ------------------ | -| string | Interface descriptor obtained.| + | Type | Description | + | ------ | ------------------ | + | string | Interface descriptor obtained.| **Example** @@ -6917,8 +6917,8 @@ Obtains the interface descriptor of this proxy object. }; FA.connectAbility(want, connect); ``` - -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **getInterfaceDescriptor()** of the proxy object is called to obtain the interface descriptor of the current proxy object. + + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **getInterfaceDescriptor()** of the proxy object is called to obtain the interface descriptor of the current proxy object. ```ts let descriptor = proxy.getInterfaceDescriptor(); @@ -6935,9 +6935,9 @@ Checks whether the **RemoteObject** is dead. **Return value** -| Type | Description | -| ------- | --------------------------------------------------------- | -| boolean | Returns **true** if the **RemoteObject** is dead; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------------------------------- | + | boolean | Returns **true** if the **RemoteObject** is dead; returns **false** otherwise.| **Example** @@ -6965,7 +6965,7 @@ Checks whether the **RemoteObject** is dead. FA.connectAbility(want, connect); ``` -The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **isObjectDead()** of the proxy object is called to check whether this object is dead. + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **isObjectDead()** of the proxy object is called to check whether this object is dead. ```ts let isDead = proxy.isObjectDead(); @@ -6978,12 +6978,12 @@ Provides common message options (flag and wait time). Use the specified flag to **System capability**: SystemCapability.Communication.IPC.Core -| Name | Value | Description | -| ------------- | ---- | ----------------------------------------------------------- | -| TF_SYNC | 0 | Synchronous call. | -| TF_ASYNC | 1 | Asynchronous call. | -| TF_ACCEPT_FDS | 0x10 | Indication to **sendMessageRequest9+** for returning the file descriptor.| -| TF_WAIT_TIME | 8 | Default waiting time, in seconds. | + | Name | Value | Description | + | ------------- | ---- | ----------------------------------------------------------- | + | TF_SYNC | 0 | Synchronous call. | + | TF_ASYNC | 1 | Asynchronous call. | + | TF_ACCEPT_FDS | 0x10 | Indication to **sendMessageRequest9+** for returning the file descriptor.| + | TF_WAIT_TIME | 8 | Default waiting time, in seconds. | ### constructor9+ @@ -6996,9 +6996,9 @@ A constructor used to create a **MessageOption** object. **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------ | ---- | -------------------------------------- | -| syncFlags | number | No | Call flag, which can be synchronous or asynchronous. The default value is **synchronous**.| + | Name | Type | Mandatory| Description | + | --------- | ------ | ---- | -------------------------------------- | + | syncFlags | number | No | Call flag, which can be synchronous or asynchronous. The default value is **synchronous**.| **Example** @@ -7021,10 +7021,10 @@ A constructor used to create a **MessageOption** object. **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------ | ---- | --------------------------------------------- | -| syncFlags | number | No | Call flag, which can be synchronous or asynchronous. The default value is **synchronous**. | -| waitTime | number | No | Maximum wait time for an RPC call. The default value is **TF_WAIT_TIME**.| + | Name | Type | Mandatory| Description | + | --------- | ------ | ---- | --------------------------------------------- | + | syncFlags | number | No | Call flag, which can be synchronous or asynchronous. The default value is **synchronous**. | + | waitTime | number | No | Maximum wait time for an RPC call. The default value is **TF_WAIT_TIME**.| **Example** @@ -7045,9 +7045,9 @@ Checks whether **SendMessageRequest** is called synchronously or asynchronously. **Return value** -| Type | Description | -| ------- | ------------------------------------ | -| boolean | Returns **true** if **SendMessageRequest** is called synchronously; returns **false** if **SendMessageRequest** is called asynchronously.| + | Type | Description | + | ------- | ------------------------------------ | + | boolean | Returns **true** if **SendMessageRequest** is called synchronously; returns **false** if **SendMessageRequest** is called asynchronously.| **Example** @@ -7082,9 +7082,9 @@ Obtains the call flag, which can be synchronous or asynchronous. **Return value** -| Type | Description | -| ------ | ------------------------------------ | -| number | Call mode obtained.| + | Type | Description | + | ------ | ------------------------------------ | + | number | Call mode obtained.| **Example** @@ -7113,9 +7113,9 @@ Sets the call flag, which can be synchronous or asynchronous. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------ | -| flags | number | Yes | Call flag to set.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------------ | + | flags | number | Yes | Call flag to set.| **Example** @@ -7141,9 +7141,9 @@ Obtains the maximum wait time for this RPC call. **Return value** -| Type | Description | -| ------ | ----------------- | -| number | Maximum wait time obtained.| + | Type | Description | + | ------ | ----------------- | + | number | Maximum wait time obtained.| **Example** @@ -7170,9 +7170,9 @@ Sets the maximum wait time for this RPC call. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------ | ---- | --------------------- | -| waitTime | number | Yes | Maximum wait time to set.| + | Name | Type | Mandatory| Description | + | -------- | ------ | ---- | --------------------- | + | waitTime | number | Yes | Maximum wait time to set.| **Example** @@ -7201,9 +7201,9 @@ Obtains the system capability manager. This API is a static method. **Return value** -| Type | Description | -| ------------------------------- | -------------------- | -| [IRemoteObject](#iremoteobject) | System capability manager obtained.| + | Type | Description | + | ------------------------------- | -------------------- | + | [IRemoteObject](#iremoteobject) | System capability manager obtained.| **Example** @@ -7222,9 +7222,9 @@ Obtains the PID of the caller. This API is a static method, which is invoked by **Return value** -| Type | Description | -| ------ | ----------------- | -| number | PID of the caller.| + | Type | Description | + | ------ | ----------------- | + | number | PID of the caller.| **Example** @@ -7248,9 +7248,9 @@ Obtains the UID of the caller. This API is a static method, which is invoked by **Return value** -| Type | Description | -| ------ | ----------------- | -| number | UID of the caller.| + | Type | Description | + | ------ | ----------------- | + | number | UID of the caller.| **Example** @@ -7274,9 +7274,9 @@ Obtains the caller's token ID, which is used to verify the caller identity. **Return value** -| Type | Description | -| ------ | --------------------- | -| number | Token ID of the caller obtained.| + | Type | Description | + | ------ | --------------------- | + | number | Token ID of the caller obtained.| **Example** @@ -7301,9 +7301,9 @@ Obtains the ID of the device hosting the caller's process. This API is a static **Return value** -| Type | Description | -| ------ | ---------------------------- | -| string | Device ID obtained.| + | Type | Description | + | ------ | ---------------------------- | + | string | Device ID obtained.| **Example** @@ -7327,9 +7327,9 @@ Obtains the local device ID. This API is a static method. **Return value** -| Type | Description | -| ------ | ------------------ | -| string | Local device ID obtained.| + | Type | Description | + | ------ | ------------------ | + | string | Local device ID obtained.| **Example** @@ -7353,9 +7353,9 @@ Checks whether the remote process is a process of the local device. This API is **Return value** -| Type | Description | -| ------- | --------------------------------------------------------- | -| boolean | Returns **true** if the local and remote processes are on the same device; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------------------------------- | + | boolean | Returns **true** if the local and remote processes are on the same device; returns **false** otherwise.| **Example** @@ -7379,9 +7379,9 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------------------------------- | ---- | ------------------- | -| object | [IRemoteObject](#iremoteobject) | Yes | **RemoteProxy** specified. | + | Name| Type | Mandatory| Description | + | ------ | ------------------------------- | ---- | ------------------- | + | object | [IRemoteObject](#iremoteobject) | Yes | **RemoteProxy** specified. | **Example** @@ -7413,15 +7413,15 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------------------------------- | ---- | ------------------- | -| object | [IRemoteObject](#iremoteobject) | Yes | **RemoteProxy** specified. | + | Name| Type | Mandatory| Description | + | ------ | ------------------------------- | ---- | ------------------- | + | object | [IRemoteObject](#iremoteobject) | Yes | **RemoteProxy** specified. | **Return value** -| Type | Description | -| ------ | --------------------------------------------------------------------------------- | -| number | Returns **0** if the operation is successful; returns an error code if the input object is null or a **RemoteObject**, or if the operation fails.| + | Type | Description | + | ------ | --------------------------------------------------------------------------------- | + | number | Returns **0** if the operation is successful; returns an error code if the input object is null or a **RemoteObject**, or if the operation fails.| **Example** @@ -7460,9 +7460,9 @@ Changes the UID and PID of the remote user to the UID and PID of the local user. **Return value** -| Type | Description | -| ------ | ------------------------------------ | -| string | String containing the UID and PID of the remote user.| + | Type | Description | + | ------ | ------------------------------------ | + | string | String containing the UID and PID of the remote user.| **Example** @@ -7487,9 +7487,9 @@ Changes the UID and PID of the remote user to the UID and PID of the local user. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------ | ---- | ------------------------------------------------------------------ | -| identity | string | Yes | String containing the remote user UID and PID, which are returned by **resetCallingIdentity**.| + | Name | Type | Mandatory| Description | + | -------- | ------ | ---- | ------------------------------------------------------------------ | + | identity | string | Yes | String containing the remote user UID and PID, which are returned by **resetCallingIdentity**.| **Example** @@ -7520,15 +7520,15 @@ Sets the UID and PID of the remote user. This API is a static method. It is usua **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------ | ---- | ------------------------------------------------------------------ | -| identity | string | Yes | String containing the remote user UID and PID, which are returned by **resetCallingIdentity**.| + | Name | Type | Mandatory| Description | + | -------- | ------ | ---- | ------------------------------------------------------------------ | + | identity | string | Yes | String containing the remote user UID and PID, which are returned by **resetCallingIdentity**.| **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** @@ -7562,9 +7562,9 @@ A constructor used to create a **RemoteObject** object. **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------ | ---- | ------------ | -| descriptor | string | Yes | Interface descriptor.| + | Name | Type | Mandatory| Description | + | ---------- | ------ | ---- | ------------ | + | descriptor | string | Yes | Interface descriptor.| ### sendRequest(deprecated) @@ -7579,18 +7579,18 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | -| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | Name | Type | Mandatory| Description | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | + | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | **Return value** -| Type | Description | -| ------- | --------------------------------------------- | -| boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.| + | Type | Description | + | ------- | --------------------------------------------- | + | boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.| **Example** @@ -7645,18 +7645,18 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | -| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | Name | Type | Mandatory| Description | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | + | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | **Return value** -| Type | Description | -| -------------------------------- | --------------------------------------------- | -| Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| + | Type | Description | + | -------------------------------- | --------------------------------------------- | + | Promise<SendRequestResult> | Promise used to return the **sendRequestResult** object.| **Example** @@ -7715,18 +7715,18 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | -| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | Name | Type | Mandatory| Description | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | + | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | **Return value** -| Type | Description | -| ---------------------------- | --------------------------------------------- | -| Promise<RequestResult> | Promise used to return the **sendRequestResult** object.| + | Type | Description | + | ---------------------------- | --------------------------------------------- | + | Promise<RequestResult> | Promise used to return the **sendRequestResult** object.| **Example** @@ -7771,13 +7771,13 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn **Parameters** -| Name | Type | Mandatory| Description | -| ------------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | -| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | -| AsyncCallback | AsyncCallback<RequestResult> | Yes | Callback for receiving the sending result. | + | Name | Type | Mandatory| Description | + | ------------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | + | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | AsyncCallback | AsyncCallback<RequestResult> | Yes | Callback for receiving the sending result. | **Example** @@ -7821,13 +7821,13 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch **Parameters** -| Name | Type | Mandatory| Description | -| ------------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | -| code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| -| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | -| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | -| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | -| AsyncCallback | AsyncCallback<SendRequestResult> | Yes | Callback for receiving the sending result. | + | Name | Type | Mandatory| Description | + | ------------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | Yes | Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.| + | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | + | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | + | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | + | AsyncCallback | AsyncCallback<SendRequestResult> | Yes | Callback for receiving the sending result. | **Example** @@ -7885,18 +7885,18 @@ Provides a response to **sendMessageRequest()**. The server processes the reques **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------------------------------- | ---- | --------------------------------------- | -| code | number | Yes | Service request code sent by the remote end. | -| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that holds the parameters called by the client.| -| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object carrying the result. | -| option | [MessageOption](#messageoption) | Yes | Whether the operation is synchronous or asynchronous. | + | Name| Type | Mandatory| Description | + | ------ | ------------------------------- | ---- | --------------------------------------- | + | code | number | Yes | Service request code sent by the remote end. | + | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that holds the parameters called by the client.| + | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object carrying the result. | + | option | [MessageOption](#messageoption) | Yes | Whether the operation is synchronous or asynchronous. | **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** @@ -7946,19 +7946,19 @@ Provides a response to **sendMessageRequest()**. The server processes the reques **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------------------------------- | ---- | ----------------------------------------- | -| code | number | Yes | Service request code sent by the remote end. | -| data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that holds the parameters called by the client.| -| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object to which the result is written. | -| option | [MessageOption](#messageoption) | Yes | Whether the operation is synchronous or asynchronous. | + | Name| Type | Mandatory| Description | + | ------ | ------------------------------- | ---- | ----------------------------------------- | + | code | number | Yes | Service request code sent by the remote end. | + | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that holds the parameters called by the client.| + | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object to which the result is written. | + | option | [MessageOption](#messageoption) | Yes | Whether the operation is synchronous or asynchronous. | **Return value** -| Type | Description | -| ----------------- | ---------------------------------------------------------------------------------------------- | -| boolean | Returns a Boolean value if the request is processed synchronously in **onRemoteMessageRequest**. The value **true** means the operation is successful; the value **false** means the opposite.| -| Promise\ | Returns a promise object if the request is processed asynchronously in **onRemoteMessageRequest**. | + | Type | Description | + | ----------------- | ---------------------------------------------------------------------------------------------- | + | boolean | Returns a Boolean value if the request is processed synchronously in **onRemoteMessageRequest**. The value **true** means the operation is successful; the value **false** means the opposite.| + | Promise\ | Returns a promise object if the request is processed asynchronously in **onRemoteMessageRequest**. | **Example**: Overload **onRemoteMessageRequest** to process requests synchronously. @@ -8076,9 +8076,9 @@ Obtains the UID of the remote process. **System capability**: SystemCapability.Communication.IPC.Core **Return value** -| Type | Description | -| ------ | ----------------------- | -| number | UID of the remote process obtained.| + | Type | Description | + | ------ | ----------------------- | + | number | UID of the remote process obtained.| **Example** @@ -8102,9 +8102,9 @@ Obtains the PID of the remote process. **Return value** -| Type | Description | -| ------ | ----------------------- | -| number | PID of the remote process obtained.| + | Type | Description | + | ------ | ----------------------- | + | number | PID of the remote process obtained.| **Example** @@ -8128,15 +8128,15 @@ Obtains the interface descriptor. **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------ | ---- | -------------------- | -| descriptor | string | Yes | Interface descriptor.| + | Name | Type | Mandatory| Description | + | ---------- | ------ | ---- | -------------------- | + | descriptor | string | Yes | Interface descriptor.| **Return value** -| Type | Description | -| ------------- | --------------------------------------------- | -| IRemoteBroker | **IRemoteBroker** object bound to the specified interface token.| + | Type | Description | + | ------------- | --------------------------------------------- | + | IRemoteBroker | **IRemoteBroker** object bound to the specified interface token.| **Example** @@ -8182,15 +8182,15 @@ Checks whether the remote object corresponding to the specified interface token **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------ | ---- | ---------------------- | -| descriptor | string | Yes | Interface descriptor.| + | Name | Type | Mandatory| Description | + | ---------- | ------ | ---- | ---------------------- | + | descriptor | string | Yes | Interface descriptor.| **Return value** -| Type | Description | -| ------------- | ------------------------------------------------------------------ | -| IRemoteBroker | Returns the remote object if a match is found; returns **Null** otherwise.| + | Type | Description | + | ------------- | ------------------------------------------------------------------ | + | IRemoteBroker | Returns the remote object if a match is found; returns **Null** otherwise.| **Example** @@ -8228,17 +8228,17 @@ Obtains the interface descriptor of this object. The interface descriptor is a s **Return value** -| Type | Description | -| ------ | ---------------- | -| string | Interface descriptor obtained.| + | Type | Description | + | ------ | ---------------- | + | string | Interface descriptor obtained.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900008 | proxy or remote object is invalid | + | ID| Error Message| + | ------- | -------- | + | 1900008 | proxy or remote object is invalid | **Example** @@ -8263,13 +8263,13 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode } } let testRemoteObject = new TestRemoteObject("testObject"); + console.log("RpcServer: descriptor is: " + descriptor); try { let descriptor = testRemoteObject.getDescriptor(); } catch(error) { console.info("rpc get local interface fail, errorCode " + error.code); console.info("rpc get local interface fail, errorMessage " + error.message); } - console.log("RpcServer: descriptor is: " + descriptor); ``` ### getInterfaceDescriptor(deprecated) @@ -8284,9 +8284,9 @@ Obtains the interface descriptor. **Return value** -| Type | Description | -| ------ | ---------------- | -| string | Interface descriptor obtained.| + | Type | Description | + | ------ | ---------------- | + | string | Interface descriptor obtained.| **Example** @@ -8325,10 +8325,10 @@ Binds an interface descriptor to an **IRemoteBroker** object. **Parameters** -| Name | Type | Mandatory| Description | -| -------------- | ------------- | ---- | ------------------------------------- | -| localInterface | IRemoteBroker | Yes | **IRemoteBroker** object. | -| descriptor | string | Yes | Interface descriptor.| + | Name | Type | Mandatory| Description | + | -------------- | ------------- | ---- | ------------------------------------- | + | localInterface | IRemoteBroker | Yes | **IRemoteBroker** object. | + | descriptor | string | Yes | Interface descriptor.| **Example** @@ -8344,8 +8344,8 @@ Binds an interface descriptor to an **IRemoteBroker** object. try { this.modifyLocalInterface(this, descriptor); } catch(error) { - console.info(rpc attach local interface fail, errorCode " + error.code); - console.info(rpc attach local interface fail, errorMessage " + error.message); + console.info(" rpc attach local interface fail, errorCode " + error.code); + console.info(" rpc attach local interface fail, errorMessage " + error.message); } } registerDeathRecipient(recipient: MyDeathRecipient, flags: number) { @@ -8376,10 +8376,10 @@ Binds an interface descriptor to an **IRemoteBroker** object. **Parameters** -| Name | Type | Mandatory| Description | -| -------------- | ------------- | ---- | ------------------------------------- | -| localInterface | IRemoteBroker | Yes | **IRemoteBroker** object. | -| descriptor | string | Yes | Interface descriptor.| + | Name | Type | Mandatory| Description | + | -------------- | ------------- | ---- | ------------------------------------- | + | localInterface | IRemoteBroker | Yes | **IRemoteBroker** object. | + | descriptor | string | Yes | Interface descriptor.| **Example** @@ -8418,12 +8418,12 @@ Provides methods related to anonymous shared memory objects, including creating, The table below describes the protection types of the mapped memory. -| Name | Value | Description | -| ---------- | --- | ------------------ | -| PROT_EXEC | 4 | The mapped memory is executable. | -| PROT_NONE | 0 | The mapped memory is inaccessible.| -| PROT_READ | 1 | The mapped memory is readable. | -| PROT_WRITE | 2 | The mapped memory is writeable. | + | Name | Value | Description | + | ---------- | --- | ------------------ | + | PROT_EXEC | 4 | The mapped memory is executable. | + | PROT_NONE | 0 | The mapped memory is inaccessible.| + | PROT_READ | 1 | The mapped memory is readable. | + | PROT_WRITE | 2 | The mapped memory is writeable. | ### create9+ @@ -8435,16 +8435,16 @@ Creates an **Ashmem** object with the specified name and size. This API is a sta **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------------------- | -| name | string | Yes | Name of the **Ashmem** object to create. | -| size | number | Yes | Size (in bytes) of the **Ashmem** object to create.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------------------- | + | name | string | Yes | Name of the **Ashmem** object to create. | + | size | number | Yes | Size (in bytes) of the **Ashmem** object to create.| **Return value** -| Type | Description | -| ------ | ---------------------------------------------- | -| Ashmem | Returns the **Ashmem** object if it is created successfully; returns null otherwise.| + | Type | Description | + | ------ | ---------------------------------------------- | + | Ashmem | Returns the **Ashmem** object if it is created successfully; returns null otherwise.| **Example** @@ -8472,16 +8472,16 @@ Creates an **Ashmem** object with the specified name and size. This API is a sta **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------------------- | -| name | string | Yes | Name of the **Ashmem** object to create. | -| size | number | Yes | Size (in bytes) of the **Ashmem** object to create.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------------------- | + | name | string | Yes | Name of the **Ashmem** object to create. | + | size | number | Yes | Size (in bytes) of the **Ashmem** object to create.| **Return value** -| Type | Description | -| ------ | ---------------------------------------------- | -| Ashmem | Returns the **Ashmem** object if it is created successfully; returns null otherwise.| + | Type | Description | + | ------ | ---------------------------------------------- | + | Ashmem | Returns the **Ashmem** object if it is created successfully; returns null otherwise.| **Example** @@ -8501,15 +8501,15 @@ Creates an **Ashmem** object by copying the file descriptor of an existing **Ash **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------------------- | -| ashmem | Ashmem | Yes | Existing **Ashmem** object.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | -------------------- | + | ashmem | Ashmem | Yes | Existing **Ashmem** object.| **Return value** -| Type | Description | -| ------ | ---------------------- | -| Ashmem | **Ashmem** object created.| + | Type | Description | + | ------ | ---------------------- | + | Ashmem | **Ashmem** object created.| **Example** @@ -8539,15 +8539,15 @@ Creates an **Ashmem** object by copying the file descriptor of an existing **Ash **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------------------- | -| ashmem | Ashmem | Yes | Existing **Ashmem** object.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | -------------------- | + | ashmem | Ashmem | Yes | Existing **Ashmem** object.| **Return value** -| Type | Description | -| ------ | ---------------------- | -| Ashmem | **Ashmem** object created.| + | Type | Description | + | ------ | ---------------------- | + | Ashmem | **Ashmem** object created.| **Example** @@ -8598,9 +8598,9 @@ Obtains the memory size of this **Ashmem** object. **Return value** -| Type | Description | -| ------ | -------------------------- | -| number | **Ashmem** size obtained.| + | Type | Description | + | ------ | -------------------------- | + | number | **Ashmem** size obtained.| **Example** @@ -8620,17 +8620,17 @@ Creates the shared file mapping on the virtual address space of this process. Th **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------ | ---- | ------------------------------ | -| mapType | number | Yes | Protection level of the memory region to which the shared file is mapped.| + | Name | Type | Mandatory| Description | + | ------- | ------ | ---- | ------------------------------ | + | mapType | number | Yes | Protection level of the memory region to which the shared file is mapped.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | ------ | -| 1900001 | call mmap function failed | + | ID| Error Message| + | ------- | ------ | + | 1900001 | call mmap function failed | **Example** @@ -8656,15 +8656,15 @@ Creates the shared file mapping on the virtual address space of this process. Th **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------ | ---- | ------------------------------ | -| mapType | number | Yes | Protection level of the memory region to which the shared file is mapped.| + | Name | Type | Mandatory| Description | + | ------- | ------ | ---- | ------------------------------ | + | mapType | number | Yes | Protection level of the memory region to which the shared file is mapped.| **Return value** -| Type | Description | -| ------- | ----------------------------------------- | -| boolean | Returns **true** if the mapping is created; returns **false** otherwise.| + | Type | Description | + | ------- | ----------------------------------------- | + | boolean | Returns **true** if the mapping is created; returns **false** otherwise.| **Example** @@ -8686,9 +8686,9 @@ Maps the shared file to the readable and writable virtual address space of the p For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900001 | call mmap function failed | + | ID| Error Message| + | ------- | -------- | + | 1900001 | call mmap function failed | **Example** @@ -8714,9 +8714,9 @@ Maps the shared file to the readable and writable virtual address space of the p **Return value** -| Type | Description | -| ------- | ----------------------------------------- | -| boolean | Returns **true** if the mapping is created; returns **false** otherwise.| + | Type | Description | + | ------- | ----------------------------------------- | + | boolean | Returns **true** if the mapping is created; returns **false** otherwise.| **Example** @@ -8738,9 +8738,9 @@ Maps the shared file to the read-only virtual address space of the process. For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900001 | call mmap function failed | + | ID| Error Message| + | ------- | -------- | + | 1900001 | call mmap function failed | **Example** @@ -8766,9 +8766,9 @@ Maps the shared file to the read-only virtual address space of the process. **Return value** -| Type | Description | -| ------- | ----------------------------------------- | -| boolean | Returns **true** if the mapping is created; returns **false** otherwise.| + | Type | Description | + | ------- | ----------------------------------------- | + | boolean | Returns **true** if the mapping is created; returns **false** otherwise.| **Example** @@ -8788,17 +8788,17 @@ Sets the protection level of the memory region to which the shared file is mappe **Parameters** -| Name | Type | Mandatory| Description | -| -------------- | ------ | ---- | ------------------ | -| protectionType | number | Yes | Protection type to set.| + | Name | Type | Mandatory| Description | + | -------------- | ------ | ---- | ------------------ | + | protectionType | number | Yes | Protection type to set.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| -------- | ------- | -| 1900002 | call os ioctl function failed | + | ID| Error Message| + | -------- | ------- | + | 1900002 | call os ioctl function failed | **Example** @@ -8824,15 +8824,15 @@ Sets the protection level of the memory region to which the shared file is mappe **Parameters** -| Name | Type | Mandatory| Description | -| -------------- | ------ | ---- | ------------------ | -| protectionType | number | Yes | Protection type to set.| + | Name | Type | Mandatory| Description | + | -------------- | ------ | ---- | ------------------ | + | protectionType | number | Yes | Protection type to set.| **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** @@ -8852,19 +8852,19 @@ Writes data to the shared file associated with this **Ashmem** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | -------------------------------------------------- | -| buf | number[] | Yes | Data to write. | -| size | number | Yes | Size of the data to write. | -| offset | number | Yes | Start position of the data to write in the memory region associated with this **Ashmem** object.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | -------------------------------------------------- | + | buf | number[] | Yes | Data to write. | + | size | number | Yes | Size of the data to write. | + | offset | number | Yes | Start position of the data to write in the memory region associated with this **Ashmem** object.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID| Error Message| -| ------- | -------- | -| 1900003 | write to ashmem failed | + | ID| Error Message| + | ------- | -------- | + | 1900003 | write to ashmem failed | **Example** @@ -8892,17 +8892,17 @@ Writes data to the shared file associated with this **Ashmem** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | -------------------------------------------------- | -| buf | number[] | Yes | Data to write. | -| size | number | Yes | Size of the data to write. | -| offset | number | Yes | Start position of the data to write in the memory region associated with this **Ashmem** object.| + | Name| Type | Mandatory| Description | + | ------ | -------- | ---- | -------------------------------------------------- | + | buf | number[] | Yes | Data to write. | + | size | number | Yes | Size of the data to write. | + | offset | number | Yes | Start position of the data to write in the memory region associated with this **Ashmem** object.| **Return value** -| Type | Description | -| ------- | ----------------------------------------------------------------------------------------- | -| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| + | Type | Description | + | ------- | ----------------------------------------------------------------------------------------- | + | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| **Example** @@ -8925,24 +8925,24 @@ Reads data from the shared file associated with this **Ashmem** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------------------------------------------------- | -| size | number | Yes | Size of the data to read. | -| offset | number | Yes | Start position of the data to read in the memory region associated with this **Ashmem** object.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | -------------------------------------------------- | + | size | number | Yes | Size of the data to read. | + | offset | number | Yes | Start position of the data to read in the memory region associated with this **Ashmem** object.| **Return value** -| Type | Description | -| -------- | ---------------- | -| number[] | Data read.| + | Type | Description | + | -------- | ---------------- | + | number[] | Data read.| **Error codes** For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). -| ID | Error Message| -| -------- | -------- | -| 1900004 | read from ashmem failed | + | ID | Error Message| + | -------- | -------- | + | 1900004 | read from ashmem failed | **Example** @@ -8972,16 +8972,16 @@ Reads data from the shared file associated with this **Ashmem** object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------------------------------------------------- | -| size | number | Yes | Size of the data to read. | -| offset | number | Yes | Start position of the data to read in the memory region associated with this **Ashmem** object.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | -------------------------------------------------- | + | size | number | Yes | Size of the data to read. | + | offset | number | Yes | Start position of the data to read in the memory region associated with this **Ashmem** object.| **Return value** -| Type | Description | -| -------- | ---------------- | -| number[] | Data read.| + | Type | Description | + | -------- | ---------------- | + | number[] | Data read.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-socket.md b/en/application-dev/reference/apis/js-apis-socket.md index f099ece8f25d5fcb6ba4f5c753d55fa2a4f83717..27d1b5cb9a3e0fc77437ab1bdee1b81a30dcaecc 100644 --- a/en/application-dev/reference/apis/js-apis-socket.md +++ b/en/application-dev/reference/apis/js-apis-socket.md @@ -1,4 +1,6 @@ -# # @ohos.net.socket (Socket Connection) +# Socket Connection + +The **socket** module implements data transfer over TCPSocket, UDPSocket, WebSocket, and TLSSocket connections. > **NOTE** > @@ -362,7 +364,7 @@ udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback\): void -Sets other attributes of the UDPSocket connection. This API uses an asynchronous callback to return the result. +Sets other properties of the UDPSocket connection. This API uses an asynchronous callback to return the result. >**NOTE** >This API can be called only after **bind** is successfully called. @@ -416,7 +418,7 @@ udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}, err=> { setExtraOptions(options: UDPExtraOptions): Promise\ -Sets other attributes of the UDPSocket connection. This API uses a promise to return the result. +Sets other properties of the UDPSocket connection. This API uses a promise to return the result. >**NOTE** >This API can be called only after **bind** is successfully called. @@ -520,7 +522,7 @@ let callback = value =>{ console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); } udp.on('message', callback); -// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. udp.off('message', callback); udp.off('message'); ``` @@ -580,14 +582,14 @@ let callback1 = () =>{ console.log("on listening, success"); } udp.on('listening', callback1); -// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. udp.off('listening', callback1); udp.off('listening'); let callback2 = () =>{ console.log("on close, success"); } udp.on('close', callback2); -// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. udp.off('close', callback2); udp.off('close'); ``` @@ -644,7 +646,7 @@ let callback = err =>{ console.log("on error, err:" + JSON.stringify(err)); } udp.on('error', callback); -// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. udp.off('error', callback); udp.off('error'); ``` @@ -1424,7 +1426,7 @@ let callback = value =>{ console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); } tcp.on('message', callback); -// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. tcp.off('message', callback); tcp.off('message'); ``` @@ -1484,14 +1486,14 @@ let callback1 = () =>{ console.log("on connect success"); } tcp.on('connect', callback1); -// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. tcp.off('connect', callback1); tcp.off('connect'); let callback2 = () =>{ console.log("on close success"); } tcp.on('close', callback2); -// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. tcp.off('close', callback2); tcp.off('close'); ``` @@ -1548,7 +1550,7 @@ let callback = err =>{ console.log("on error, err:" + JSON.stringify(err)); } tcp.on('error', callback); -// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. tcp.off('error', callback); tcp.off('error'); ``` diff --git a/en/application-dev/reference/apis/js-apis-stationary.md b/en/application-dev/reference/apis/js-apis-stationary.md index e065e9478c631af8cc3cfe125ac71f29e2b9dadb..bd7c29020ed3d0b65501421c4b9547423986fdf9 100644 --- a/en/application-dev/reference/apis/js-apis-stationary.md +++ b/en/application-dev/reference/apis/js-apis-stationary.md @@ -70,7 +70,7 @@ Subscribes to the device status. **Parameters** -| Parameter Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | -------------------- | -------------------------------------------------- | ---- | ---------------------------- | | activity | [ActivityType](#activitytype) | Yes | Device status type. | | event | [ActivityEvent](#activityevent) | Yes | Event type. | @@ -96,7 +96,7 @@ Obtains the device status. **Parameters** -| Parameter Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | -------------------- | -------------------------------------------------- | ---- | ---------------------------- | | activity | [ActivityType](#activitytype) | Yes | Device status type. | | callback | Callback<[ActivityResponse](#activityresponse)\> | Yes | Callback used to receive reported data. | @@ -119,7 +119,7 @@ Unsubscribes from the device status. **Parameters** -| Parameter Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | -------------------- | -------------------------------------------------- | ---- | ---------------------------- | | activity | [ActivityType](#activitytype) | Yes | Device status type. | | event | [ActivityEvent](#activityevent) | Yes | Event type. | diff --git a/en/application-dev/reference/apis/js-apis-system-battery.md b/en/application-dev/reference/apis/js-apis-system-battery.md index d673a500027654075ff330c916cd22add25abaf6..efeb9caec59a04362b80c6f3502dc5a34b8e7f34 100644 --- a/en/application-dev/reference/apis/js-apis-system-battery.md +++ b/en/application-dev/reference/apis/js-apis-system-battery.md @@ -46,6 +46,8 @@ battery.getStatus({ Object that contains the API calling result. +**System capability**: SystemCapability.PowerManager.BatteryManager.Core + | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | | success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.| @@ -56,7 +58,9 @@ Object that contains the API calling result. Defines a response that returns the charging status and remaining power of the device. -| Name| Type| Description| -| -------- | -------- | -------- | -| charging | boolean | Whether the battery is being charged.| -| level | number | Current battery level, which ranges from **0.00** to **1.00**.| +**System capability**: SystemCapability.PowerManager.BatteryManager.Core + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| charging | boolean | Yes| No| Whether the battery is being charged.| +| level | number | Yes| No| Current battery level, which ranges from **0.00** to **1.00**.| diff --git a/en/application-dev/reference/apis/js-apis-system-brightness.md b/en/application-dev/reference/apis/js-apis-system-brightness.md index 939e7d7021bc8f93ad7359004de58f525feeee05..3cc0779edf610eb39cda868abc84d353c6b05dc6 100644 --- a/en/application-dev/reference/apis/js-apis-system-brightness.md +++ b/en/application-dev/reference/apis/js-apis-system-brightness.md @@ -45,7 +45,7 @@ Obtains the current screen brightness. ## brightness.setValue -etValue(options?: SetBrightnessOptions): void +setValue(options?: SetBrightnessOptions): void Sets the screen brightness. @@ -74,7 +74,7 @@ Sets the screen brightness. ## brightness.getMode -getMode(options?: GetBrightnessModeOptions: void +getMode(options?: GetBrightnessModeOptions): void Obtains the screen brightness adjustment mode. @@ -161,67 +161,81 @@ Sets whether to always keep the screen on. Call this API in **onShow()**. Defines the options for obtaining the screen brightness. +**System capability**: SystemCapability.PowerManager.DisplayPowerManager + | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | success | (data: [BrightnessResponse](#brightnessresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponse) type.| | fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when API call is complete. | +| complete | () => void | No | Called when the API call is complete. | ## SetBrightnessOptions Defines the options for setting the screen brightness. +**System capability**: SystemCapability.PowerManager.DisplayPowerManager + | Name | Type | Mandatory| Description | | -------- | ------------------------------------ | ---- | ------------------------------------------------------------ | | value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.
- If the value is less than or equal to **0**, value **1** will be used.
- If the value is greater than **255**, value **255** will be used.
- If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.| -| success | () => void | No | Called when API call is successful. | +| success | () => void | No | Callback upon a successful API call. | | fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when API call is complete. | +| complete | () => void | No | Called when the API call is complete. | ## BrightnessResponse Defines a response that returns the screen brightness. -| Parameter| Type | Description| -| -------- | -------- | -------- | -| value | number | Screen brightness. The value ranges from 1 to 255.| +**System capability**: SystemCapability.PowerManager.DisplayPowerManager + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| value | number | Yes| No| Screen brightness. The value ranges from **1** to **255**.| ## GetBrightnessModeOptions Defines the options for obtaining the screen brightness mode. +**System capability**: SystemCapability.PowerManager.DisplayPowerManager + | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponse) type.| | fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when API call is complete. | +| complete | () => void | No | Called when the API call is complete. | ## SetBrightnessModeOptions Defines the options for setting the screen brightness mode. +**System capability**: SystemCapability.PowerManager.DisplayPowerManager + | Name | Type | Mandatory| Description | | -------- | ------------------------------------ | ---- | ------------------------------------------------------ | | mode | number | Yes | The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.| -| success | () => void | No | Called when API call is successful. | +| success | () => void | No | Callback upon a successful API call. | | fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.| -| complete | () => void | No | Called when API call is complete. | +| complete | () => void | No | Called when the API call is complete. | ## BrightnessModeResponse Defines a response that returns the screen brightness mode. -| Name| Type | Description| -| -------- | -------- | -------- | -| mode | number | The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.| +**System capability**: SystemCapability.PowerManager.DisplayPowerManager + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| mode | number | Yes| No| The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.| ## SetKeepScreenOnOptions Defines the options for setting the screen to be steady on. +**System capability**: SystemCapability.PowerManager.DisplayPowerManager + | Name | Type | Mandatory| Description | | ------------ | ------------------------------------ | ---- | ------------------------------------------------------ | | keepScreenOn | boolean | Yes | The value **true** means to keep the screen steady on, and the value **false** indicates the opposite. | -| success | () => void | No | Called when API call is successful. | +| success | () => void | No | Callback upon a successful API call. | | fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.| -| complete | () => void | No | Called when API call is complete. | +| complete | () => void | No | Called when the API call is complete. | diff --git a/en/application-dev/reference/apis/js-apis-system-capability.md b/en/application-dev/reference/apis/js-apis-system-capability.md index 7949bae9880af5a8e428e62440595a4a6e990da7..e32c909193a5090737c37c70864c32573ec127b5 100644 --- a/en/application-dev/reference/apis/js-apis-system-capability.md +++ b/en/application-dev/reference/apis/js-apis-system-capability.md @@ -16,7 +16,7 @@ import systemcapability from '@ohos.systemCapability' ## systemcapability.querySystemCapabilities -querySystemCapabilities(callback: AsyncCallback): void; +querySystemCapabilities(callback: AsyncCallback<string>): void; Queries system capabilities. This API uses an asynchronous callback to return the result. @@ -51,7 +51,7 @@ querySystemCapabilities(): Promise<string> Queries system capabilities. This API uses a promise to return the result. -**System capability**: SystemCapability.Startup.SystemInfo +**System capability**: SystemCapability.Developtools.Syscap **Return value** @@ -76,4 +76,5 @@ try { > **NOTE** -> - The system capabilities returned by the preceding APIs are in the form of an encoded numeric string. +> +> The system capabilities returned by the preceding APIs are in the form of an encoded numeric string. diff --git a/en/application-dev/reference/apis/js-apis-system-device.md b/en/application-dev/reference/apis/js-apis-system-device.md index 18c6c703d5e033c216fb47594fa8116fc581dfc6..ea1eadb9ab116dc938190e3356e1c4c73d5ce821 100644 --- a/en/application-dev/reference/apis/js-apis-system-device.md +++ b/en/application-dev/reference/apis/js-apis-system-device.md @@ -16,7 +16,7 @@ import device from '@system.device'; ## device.getInfo -getInfo(Object): void +getInfo(options?: GetDeviceOptions): void Obtains the device information. @@ -30,11 +30,25 @@ Obtains the device information. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| success | Function | No| Called when API call is successful.| -| fail | Function | No| Called when API call has failed.| -| complete | Function | No| Called when API call is complete.| +| options | [GetDeviceOptions](#getdeviceoptions) | No| Parameters for obtaining the device information.| -**Return value of success()** +## GetDeviceOptions + +Defines the parameters for obtaining the device information. + +**System capability**: SystemCapability.Startup.SystemInfo + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| success | (data: DeviceResponse)=> void| No| Called when API call is successful. **data** indicates the returned device information. For details, see [DeviceResponse](#deviceresponse).| +| fail | (data: any,code:number)=> void| No| Called when API call has failed. **code** indicates the error code returned upon a failure.
**code:200**: Certain information could not be obtained.| +| complete | () => void| No| Called when API call is complete.| + +## DeviceResponse + +Provides the device information. + +**System capability**: SystemCapability.Startup.SystemInfo | Name| Type| Description| | -------- | -------- | -------- | @@ -49,14 +63,9 @@ Obtains the device information. | screenDensity4+ | number | Screen density.| | screenShape4+ | string | Screen shape. The options are as follows:
- **rect**: rectangular screen
- **circle**: round screen| | apiVersion4+ | number | API version.| -| releaseType4+ | string | Release type. The value includes both the release type and the API version, for example, Beta1.
Available release types are as follows:
- **Canary**: For the same API version, different canary releases are compatible with each other, but not compatible with those of the **beta** and **release** type.
- **Beta**: For the same API version, different beta releases are compatible with each other, but not compatible with those of the **release** type.
- **Release**: Releases of this type are compatible with the latest five API versions.| +| releaseType4+ | string | Release type. The value includes both the release type and the API version, for example, Beta1.
Available release types are as follows:
- **Canary**: Releases of this type are compatible with each other under the same API version, but not with those of the **beta** and **release** type.
- **Beta**: Releases of this type are compatible with each other under the same API version, but not with those of the **release** type.
- **Release**: Releases of this type are compatible with the latest five API versions.| | deviceType4+ | string | Device type.| -**Return value of fail()** - -| Error Code| Description| -| -------- | -------- | -| 200 | Certain information cannot be obtained.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-system-fetch.md b/en/application-dev/reference/apis/js-apis-system-fetch.md index 6829c569a3471855c403a6bfad5e80bdd18afecc..6144d903c19116e693841e5f4a55840aac43e68b 100644 --- a/en/application-dev/reference/apis/js-apis-system-fetch.md +++ b/en/application-dev/reference/apis/js-apis-system-fetch.md @@ -1,9 +1,8 @@ # @system.fetch (Data Request) > **NOTE** -> > - The APIs of this module are no longer maintained since API version 6. You are advised to use [`@ohos.net.http`](js-apis-http.md) instead. -> +> > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -15,7 +14,7 @@ import fetch from '@system.fetch'; ``` -## fetch.fetch +## fetch.fetch3+ fetch(Object): void @@ -31,9 +30,9 @@ Obtains data through a network. | header | Object | No| Request header.| | method | string | No| Request method. The default value is **GET**. The value can be **OPTIONS**, **GET**, **HEAD**, **POST**, **PUT**, **DELETE **or **TRACE**.| | responseType | string | No| Response type. The return type can be text or JSON. By default, the return type is determined based on **Content-Type** in the header returned by the server. For details, see return values in the **success** callback.| -| success | Function | No| Called when data is obtained successfully. The return value is [FetchResponse](#fetchresponse). | -| fail | Function | No| Called when data failed to be obtained.| -| complete | Function | No| Called when the execution is complete.| +| success | Function | No| Called when the API call is successful. The return value is defined by [FetchResponse](#fetchresponse).| +| fail | Function | No| Called when API call has failed.| +| complete | Function | No| Called when the API call is complete.| **Table 1** Mapping between data and Content-Type @@ -46,11 +45,11 @@ Obtains data through a network. ## FetchResponse -| Name| Type| Description| -| -------- | -------- | -------- | -| code | number | Server status code.| -| data | string \| Object | The type of the returned data is determined by **responseType**. For details, see the mapping between **responseType** and **data** in **success** callback.| -| headers | Object | All headers in the response from the server.| +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| code | number | Yes| No| Server status code.| +| data | string \| Object | Yes| No| The type of the returned data is determined by **responseType**. For details, see the mapping between **responseType** and **data** in **success** callback.| +| headers | Object | Yes| No| All headers in the response from the server.| **Table 2** Mapping between responseType and data in success callback @@ -85,7 +84,7 @@ export default { ``` -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE** > HTTPS is supported by default. To support HTTP, you need to add **"network"** to the **config.json** file, and set the attribute **"cleartextTraffic"** to **true**. That is: > > ``` diff --git a/en/application-dev/reference/apis/js-apis-system-location.md b/en/application-dev/reference/apis/js-apis-system-location.md index 7d03495284b4a0a805d1b90b0c46eaf1997200e9..4e141ca023493913251eb87e4007df06af3db283 100644 --- a/en/application-dev/reference/apis/js-apis-system-location.md +++ b/en/application-dev/reference/apis/js-apis-system-location.md @@ -21,44 +21,22 @@ ohos.permission.LOCATION ## geolocation.getLocation(deprecated) -getLocation(Object): void +getLocation(options?: GetLocationOption): void Obtains the geographic location. > **NOTE** > This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation). +**Required permissions**: ohos.permission.LOCATION + **System capability**: SystemCapability.Location.Location.Lite **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| timeout | number | No| Timeout duration, in ms. The default value is **30000**.
The timeout duration is necessary in case the request to obtain the geographic location is rejected for the lack of the required permission, weak positioning signal, or incorrect location settings. After the timeout duration expires, the fail function will be called.
The value is a 32-digit positive integer. If the specified value is less than or equal to **0**, the default value will be used.| -| coordType | string | No| Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**.| -| success | Function | No| Called when API call is successful.| -| fail | Function | No| Called when API call has failed.| -| complete | Function | No| Called when API call is complete.| - -**Return value of success()** - -| Name| Type| Description| -| -------- | -------- | -------- | -| longitude | number | Longitude.| -| latitude | number | Latitude.| -| altitude | number | Altitude.| -| accuracy | number | Location accuracy.| -| time | number | Time when the location is obtained.| - -**Return value of fail()** - -| Error Code| Description| -| -------- | -------- | -| 601 | Failed to obtain the required permission because the user rejected the request.| -| 602 | Permission not declared.| -| 800 | Operation times out due to a poor network condition or GNSS unavailability.| -| 801 | System location disabled.| -| 802 | API called again while the previous execution result is not returned yet.| +| options | [GetLocationOption](#getlocationoptiondeprecated) | No| Options of a single location request.| **Example** @@ -70,7 +48,7 @@ export default { console.log('success get location data. latitude:' + data.latitude); }, fail: function(data, code) { - console.log('fail to get location. code:' + code + ', data:' + data); + console.log('fail to get location. code:' + code + ', data:' + data); } }); } @@ -80,12 +58,12 @@ export default { ## geolocation.getLocationType(deprecated) -getLocationType(Object): void +getLocationType(options?: GetLocationTypeOption): void Obtains the supported location types. > **NOTE** -> This API is deprecated since API version 9. The location subsystem supports only two location types: GPS positioning and network positioning. No APIs will be provided to query the supported location types. +> This API is deprecated since API version 9. The location subsystem supports only two location types: GNSS positioning and network positioning. No APIs will be provided to query the supported location types. **System capability**: SystemCapability.Location.Location.Lite @@ -93,15 +71,7 @@ Obtains the supported location types. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| success | Function | No| Called when API call is successful.| -| fail | Function | No| Called when API call has failed.| -| complete | Function | No| Called when API call is complete.| - -**Return value of success()** - -| Name| Type| Description| -| -------- | -------- | -------- | -| types | Array<string> | Available location types, ['gps', 'network']| +| options | [GetLocationTypeOption](#getlocationtypeoptiondeprecated) | No| Callback used to return the result.| **Example** @@ -123,40 +93,22 @@ export default { ## geolocation.subscribe(deprecated) -subscribe(Object): void +subscribe(options: SubscribeLocationOption): void Listens to the geographic location. If this method is called multiple times, the last call takes effect. > **NOTE** > This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('locationChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationchange). +**Required permissions**: ohos.permission.LOCATION + **System capability**: SystemCapability.Location.Location.Lite **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| coordType | string | No| Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**.| -| success | Function | Yes| Called when the geographic location changes.| -| fail | Function | No| Called when API call has failed.| - -**Return value of success()** - -| Name| Type| Description| -| -------- | -------- | -------- | -| longitude | number | Longitude.| -| latitude | number | Latitude.| -| altitude | number | Altitude.| -| accuracy | number | Location accuracy.| -| time | number | Time when the location is obtained.| - -**Return value of fail()** - -| Error Code| Description| -| -------- | -------- | -| 601 | Failed to obtain the required permission because the user rejected the request.| -| 602 | Permission not declared.| -| 801 | System location disabled.| +| options | [SubscribeLocationOption](#subscribelocationoptiondeprecated) | Yes| Options for continuous location.| **Example** @@ -185,6 +137,8 @@ Cancels listening to the geographic location. > **NOTE** > This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('locationChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationchange). +**Required permissions**: ohos.permission.LOCATION + **System capability**: SystemCapability.Location.Location.Lite **Example** @@ -192,7 +146,7 @@ Cancels listening to the geographic location. ``` export default { unsubscribe() { - geolocation.unsubscribe(); + geolocation.unsubscribe(); } } ``` @@ -224,3 +178,102 @@ export default { }, } ``` + +## GetLocationOption(deprecated) + +Defines the options of a single location request. + +> **NOTE** +> This API is deprecated since API version 9. You are advised to use [geoLocationManager.CurrentLocationRequest](js-apis-geoLocationManager.md#CurrentLocationRequest). + +**Required permissions**: ohos.permission.LOCATION + +**System capability**: SystemCapability.Location.Location.Lite + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| timeout | number | No| Timeout duration, in ms. The default value is **30000**.
The timeout duration is necessary in case the request to obtain the geographic location is rejected for the lack of the required permission, weak positioning signal, or incorrect location settings. After the timeout duration expires, the fail function will be called.
The value is a 32-digit positive integer. If the specified value is less than or equal to **0**, the default value will be used.| +| coordType | string | No| Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**.| +| success | (data: [GeolocationResponse](#geolocationresponsedeprecated)) => void | No| Called when API call is successful.| +| fail | (data: string, code: number) => void | No| Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.| +| complete | () => void | No| Called when API call is complete.| + +**Return value of fail()** + +| Error Code| Description| +| -------- | -------- | +| 601 | Failed to obtain the required permission because the user rejected the request.| +| 602 | Permission not declared.| +| 800 | Operation times out due to a poor network condition or GNSS unavailability.| +| 801 | System location disabled.| +| 802 | API called again while the previous execution result is not returned yet.| + +## GeolocationResponse(deprecated) + +Defines the location information, including the longitude, latitude, and location precision. + +> **NOTE** +> This API is deprecated since API version 9. You are advised to use [geoLocationManager.Location](js-apis-geoLocationManager.md#location). + +**System capability**: SystemCapability.Location.Location.Lite + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| longitude | number | Yes| No| Longitude.| +| latitude | number | Yes| No| Latitude.| +| altitude | number | Yes| No| Altitude.| +| accuracy | number | Yes| No| Location accuracy.| +| time | number | Yes| No| Time when the location is obtained.| + +## GetLocationTypeOption(deprecated) + +Defines the location type option, which holds the callback function used to return the query result. + +> **NOTE** +> This API is deprecated since API version 9. + +**System capability**: SystemCapability.Location.Location.Lite + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| success | (data: [GetLocationTypeResponse](#getlocationtyperesponsedeprecated)) => void | No| Called when API call is successful.| +| fail | (data: string, code: number) => void | No| Called when API call has failed.| +| complete | () => void | No| Called when API call is complete.| + +## GetLocationTypeResponse(deprecated) + +Defines the list of location types supported by the current device + +> **NOTE** +> This API is deprecated since API version 9. + +**System capability**: SystemCapability.Location.Location.Lite + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| types | Array<string> | Yes| No| Available location types, ['gps', 'network']| + +## SubscribeLocationOption(deprecated) + +Defines the options for continuous location. + +> **NOTE** +> This API is deprecated since API version 9. You are advised to use [geoLocationManager.CurrentLocationRequest](js-apis-geoLocationManager.md#locationrequest). + +**Required permissions**: ohos.permission.LOCATION + +**System capability**: SystemCapability.Location.Location.Lite + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| coordType | string | No| Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**.| +| success | (data: [GeolocationResponse](#geolocationresponsedeprecated)) => void | Yes| Called when the geographic location changes.| +| fail | (data: string, code: number) => void | No| Called when API call has failed.| + +**Return value of fail()** + +| Error Code| Description| +| -------- | -------- | +| 601 | Failed to obtain the required permission because the user rejected the request.| +| 602 | Permission not declared.| +| 801 | System location disabled.| diff --git a/en/application-dev/reference/apis/js-apis-system-network.md b/en/application-dev/reference/apis/js-apis-system-network.md index e012487feefe73e79738c570e4e2ebda9ad23919..5fe6e782edc352c4d49377b4e8d9a4343d8435a6 100644 --- a/en/application-dev/reference/apis/js-apis-system-network.md +++ b/en/application-dev/reference/apis/js-apis-system-network.md @@ -1,8 +1,8 @@ # @system.network (Network State) > **NOTE** -> -> - The APIs of this module are no longer maintained since API version 7. It is recommended that you use [`@ohos.telephony.observer`](js-apis-observer.md) instead. +> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.telephony.observer`](js-apis-observer.md). +> > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -31,17 +31,17 @@ Obtains the network type. **Parameters** -| Name | Type | Mandatory | Description | +| Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| success | Function | No | Called when the execution is successful. The return value is [NetworkResponse](#networkresponse). | -| fail | Function | No | Called when the operation fails. | -| complete | Function | No | Called when the execution is complete | +| success | Function | No| Called when the API call is successful. The return value is defined by [NetworkResponse](#networkresponse).| +| fail | Function | No| Called when API call has failed.| +| complete | Function | No| Called when the API call is complete.| -Return value of the **fail** callback: +One of the following error codes will be returned if the API call has failed. -| Error Code | Description | +| Error Code| Description| | -------- | -------- | -| 602 | The current permission is not declared. | +| 602 | The current permission is not declared.| **Example** @@ -71,17 +71,17 @@ Listens to the network connection state. If this method is called multiple times **Parameters** -| Name | Type | Mandatory | Description | +| Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| success | Function | No | Called when the network connection state changes | -| fail | Function | No | Called when the multimedia volume fails to be obtained. | +| success | Function | No| Called when the network state changes. The return value is defined by [NetworkResponse](#networkresponse).| +| fail | Function | No| Called when API call has failed.| -Return value of the **fail** callback: +One of the following error codes will be returned if the API call has failed. -| Error Code | Description | +| Error Code| Description| | -------- | -------- | -| 602 | The current permission is not declared. | -| 200 | The subscription fails. | +| 602 | The current permission is not declared.| +| 200 | Subscription failed.| **Example** @@ -119,9 +119,12 @@ export default { } ``` + ## NetworkResponse -| Parameter | Type | Description | -| -------- | -------- | -------- | -| metered | boolean | Whether the billing is based on the data volume. | -| type | string | Network type. The value can be **2G**, **3G**, **4G**, **5G**, **WiFi**, or **none**. | \ No newline at end of file +**System capability**: SystemCapability.Communication.NetManager.Core + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| metered | boolean | No|Whether to charge by traffic.| +| type | string | Yes|Network type. The value can be **2G**, **3G**, **4G**, **5G**, **WiFi**, or **none**.| diff --git a/en/application-dev/reference/apis/js-apis-uitest.md b/en/application-dev/reference/apis/js-apis-uitest.md index d738e7b69170bc84f17286594cfd98b3ff908249..d1f1ba4db59b314b345b3f0efc9ec58d6a5fb913 100644 --- a/en/application-dev/reference/apis/js-apis-uitest.md +++ b/en/application-dev/reference/apis/js-apis-uitest.md @@ -1,4 +1,4 @@ -# @ohos.uitest (UiTest) +# @ohos.UiTest The **UiTest** module provides APIs that you can use to simulate UI actions during testing, such as clicks, double-clicks, long-clicks, and swipes. @@ -20,7 +20,7 @@ This module provides the following functions: ## Modules to Import ```js -import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.uitest'; +import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix, UiDirection, MouseButton} from '@ohos.UiTest'; ``` ## MatchPattern @@ -61,8 +61,8 @@ Provides the coordinates of a point. | Name| Type | Readable| Writable| Description | | ---- | ------ | ---- | ---- | ---------------- | -| X | number | Yes | No | X-coordinate of a point.| -| Y | number | Yes | No | Y-coordinate of a point.| +| x | number | Yes | No | X-coordinate of a point.| +| y | number | Yes | No | Y-coordinate of a point.| ## Rect9+ @@ -79,10 +79,10 @@ Provides bounds information of a component. ## WindowMode9+ -**System capability**: SystemCapability.Test.UiTest - Enumerates the window modes. +**System capability**: SystemCapability.Test.UiTest + | Name | Value | Description | | ---------- | ---- | ---------- | | FULLSCREEN | 0 | Full-screen mode.| @@ -92,10 +92,10 @@ Enumerates the window modes. ## DisplayRotation9+ -**System capability**: SystemCapability.Test.UiTest - Describes the display rotation of the device. +**System capability**: SystemCapability.Test.UiTest + | Name | Value | Description | | ------------ | ---- | ---------------------------------------- | | ROTATION_0 | 0 | The device display is not rotated and is in its original vertical orientation. | @@ -116,6 +116,31 @@ Provides the flag attributes of this window. | focused | boolean | Yes | No | Whether the window is in focused state. | | actived | boolean | Yes | No | Whether the window is interacting with the user.| +## UiDirection10+ + +Describes the direction of a UI operation such as fling. + +**System capability**: SystemCapability.Test.UiTest + +| Name | Value | Description | +| ----- | ---- | ------ | +| LEFT | 0 | Leftward.| +| RIGHT | 1 | Rightward.| +| UP | 2 | Upward.| +| DOWN | 3 | Downward.| + +## MouseButton10+ + +Describes the injected simulated mouse button. + +**System capability**: SystemCapability.Test.UiTest + +| Name | Value | Description | +| ------------------- | ---- | ------------ | +| MOUSE_BUTTON_LEFT | 0 | Left button on the mouse. | +| MOUSE_BUTTON_RIGHT | 1 | Right button on the mouse. | +| MOUSE_BUTTON_MIDDLE | 2 | Middle button on the mouse.| + ## On9+ Since API version 9, the UiTest framework provides a wide range of UI component feature description APIs in the **On** class to filter and match components. @@ -420,7 +445,7 @@ let on = ON.checkable(true); // Use the static constructor ON to create an On ob isBefore(on: On): On -Specifies the attributes of the component before which the target component is located. +Specifies that the target component is located before the given attribute component. **System capability**: SystemCapability.Test.UiTest @@ -428,7 +453,7 @@ Specifies the attributes of the component before which the target component is l | Name| Type | Mandatory| Description | | ------ | ---------- | ---- | -------------------- | -| on | [On](#on9) | Yes | Attributes of the component before which the target component is located.| +| on | [On](#on9) | Yes | Information about the attribute component.| **Return value** @@ -439,14 +464,14 @@ Specifies the attributes of the component before which the target component is l **Example** ```js -let on = ON.isBefore(ON.text('123')); // Use the static constructor ON to create an On object and specify the attributes of the component before which the target component is located. +let on = ON.isBefore(ON.text('123')); // Create an On object using the static constructor ON, specifying that the target component is located before the given attribute component. ``` ### isAfter9+ isAfter(on: On): On -Specifies the attributes of the component after which the target component is located. +Specifies that the target component is located after the given attribute component. **System capability**: SystemCapability.Test.UiTest @@ -454,7 +479,7 @@ Specifies the attributes of the component after which the target component is lo | Name| Type | Mandatory| Description | | ------ | ---------- | ---- | -------------------- | -| on | [On](#on9) | Yes | Attributes of the component after which the target component is located.| +| on | [On](#on9) | Yes | Information about the attribute component.| **Return value** @@ -465,7 +490,59 @@ Specifies the attributes of the component after which the target component is lo **Example** ```js -let on = ON.isAfter(ON.text('123')); // Use the static constructor ON to create an On object and specify the attributes of the component after which the target component is located. +let on = ON.isAfter(ON.text('123')); // Create an On object using the static constructor ON, specifying that the target component is located after the given attribute component. +``` + +### within10+ + +within(on: On): On + +Specifies that the target component is located within the given attribute component. + +**System capability**: SystemCapability.Test.UiTest + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ---------- | ---- | -------------------- | +| on | [On](#on9) | Yes | Information about the attribute component.| + +**Return value** + +| Type | Description | +| ---------- | -------------------------------------------------- | +| [On](#on9) | **On** object.| + +**Example** + +```js +let on = ON.within(ON.type('List')); // Create an On object using the static constructor ON, specifying that the target component is located within the given attribute component. +``` + +### inWindow10+ + +inWindow(bundleName: string): On; + +Specifies that the target component is within the given application window. + +**System capability**: SystemCapability.Test.UiTest + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ---------------- | +| bundleName | string | Yes | Bundle name of the application window.| + +**Return value** + +| Type | Description | +| ---------- | ---------------------------------------------- | +| [On](#on9) | **On** object.| + +**Example** + +```js +let on = ON.inWindow(ON.inWindow('com.uitestScene.acts')); // Create an On object using the static constructor ON, specifying that the target component is within the given application window. ``` ## Component9+ @@ -1816,7 +1893,7 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ```js async function demo() { let driver = Driver.create(); - await driver.screenCap('/local/tmp/1.png'); + await driver.screenCap('/data/storage/el2/base/cache/1.png'); } ``` @@ -2078,7 +2155,7 @@ Simulates a fling operation on the screen. | from | [Point](#point9) | Yes | Coordinates of the point where the finger touches the screen. | | to | [Point](#point9) | Yes | Coordinates of the point where the finger leaves the screen. | | stepLen | number | Yes | Fling step length, in pixels. | -| speed | number | Yes | Scroll speed, in pixel/s. The value ranges from 200 to 15000. If the set value is not in the range, the default value 600 is used.| +| speed | number | Yes | Fling speed, in pixel/s. The value ranges from 200 to 40000. If the set value is not in the range, the default value 600 is used.| **Error codes** @@ -2093,7 +2170,7 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ```js async function demo() { let driver = Driver.create(); - await driver.fling({X: 500, Y: 480},{X: 450, Y: 480},5,600); + await driver.fling({x: 500, y: 480},{x: 450, y: 480},5,600); } ``` @@ -2132,16 +2209,186 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc async function demo() { let driver = Driver.create(); let pointers = PointerMatrix.create(2,3); - pointers.setPoint(0,0,{X:230,Y:480}); - pointers.setPoint(0,1,{X:250,Y:380}); - pointers.setPoint(0,2,{X:270,Y:280}); - pointers.setPoint(1,0,{X:230,Y:680}); - pointers.setPoint(1,1,{X:240,Y:580}); - pointers.setPoint(1,2,{X:250,Y:480}); + pointers.setPoint(0,0,{x:230,y:480}); + pointers.setPoint(0,1,{x:250,y:380}); + pointers.setPoint(0,2,{x:270,y:280}); + pointers.setPoint(1,0,{x:230,y:680}); + pointers.setPoint(1,1,{x:240,y:580}); + pointers.setPoint(1,2,{x:250,y:480}); await driver.injectMultiPointerAction(pointers); } ``` +### fling10+ + +fling(direction: UiDirection, speed: number): Promise; + +Simulates a fling operation on the screen, in the specified direction and speed. + +**System capability**: SystemCapability.Test.UiTest + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ----------------------------- | ---- | ------------------------------------------------------------ | +| direction | [UiDirection](#uidirection10) | Yes | Direction of the fling operation. | +| speed | number | Yes | Fling speed, in pixel/s. The value ranges from 200 to 40000. If the set value is not in the range, the default value 600 is used.| + +**Error codes** + +For details about the error codes, see [UiTest Error Codes](../errorcodes/errorcode-uitest.md). + +| ID| Error Message | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + +**Example** + +```js +async function demo() { + let driver = Driver.create(); + await driver.fling(UiDirection.DOWN, 10000); +} +``` + +### screenCapture10+ + +screenCapture(savePath: string, rect?: Rect): Promise; + +Captures the specified area of the current screen and saves the captured screenshot as a PNG image to the specified path. + +**System capability**: SystemCapability.Test.UiTest + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------- | ---- | ---------------------- | +| savePath | string | Yes | File save path. | +| rect | [Rect](#rect9) | No | Area of the screen to capture. The default value is the entire screen.| + +**Return value** + +| Type | Description | +| ----------------- | -------------------------------------- | +| Promise\ | Promise used to return the operation result. The value **true** means that the operation is successful.| + +**Error codes** + +For details about the error codes, see [UiTest Error Codes](../errorcodes/errorcode-uitest.md). + +| ID| Error Message | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + +**Example** + +```js +async function demo() { + let driver = Driver.create(); + await driver.screenCapture('/data/storage/el2/base/cache/1.png', {left: 0, top: 0, right: 100, bottom: 100}); +} +``` + +### mouseClick10+ + +mouseClick(p: Point, btnId: MouseButton, key1?: number, key2?: number): Promise; + +Injects a mouse click at the specified coordinates, with the optional key or key combination. For example, if the value of **key1** is **2072**, the **Ctrl** button is pressed with the mouse click. + +**System capability**: SystemCapability.Test.UiTest + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ----------------------------- | ---- | ------------------- | +| p | [Point](#point9) | Yes | Coordinates of the mouse click. | +| btnId | [MouseButton](#mousebutton10) | Yes | Mouse button pressesd. | +| key1 | number | Yes | The first key value.| +| key2 | number | No | The second key value.| + +**Error codes** + +For details about the error codes, see [UiTest Error Codes](../errorcodes/errorcode-uitest.md). + +| ID| Error Message | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + +**Example** + +```js +async function demo() { + let driver = Driver.create(); + await driver.mouseClick({x:248, y:194}, MouseButton.MOUSE_BUTTON_LEFT, 2072); +} +``` + +### mouseScroll10+ + +mouseScroll(p: Point, down: boolean, d: number, key1?: number, key2?: number): Promise; + +Injects a mouse scroll action at the specified coordinates, with the optional key or key combination. For example, if the value of **key1** is **2072**, the **Ctrl** button is pressed with mouse scrolling. + +**System capability**: SystemCapability.Test.UiTest + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ---------------- | ---- | --------------------------------------------------- | +| p | [Point](#point9) | Yes | Coordinates of the mouse click. | +| down | boolean | Yes | Whether the scroll wheel slides downward. | +| d | number | Yes | Number of grids by which the scroll wheel slides. Sliding by one grid means a 120-pixel offset of the target point.| +| key1 | number | Yes | The first key value. | +| key2 | number | No | The second key value. | + +**Error codes** + +For details about the error codes, see [UiTest Error Codes](../errorcodes/errorcode-uitest.md). + +| ID| Error Message | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + +**Example** + +```js +async function demo() { + let driver = Driver.create(); + await driver.mouseScroll({x:360, y:640}, true, 30, 2072) +} +``` + +### mouseMoveTo10+ + +mouseMoveTo(p: Point): Promise; + +Moves the cursor to the target point. + +**System capability**: SystemCapability.Test.UiTest + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ---------------- | ---- | -------------- | +| p | [Point](#point9) | Yes | Coordinates of the target point.| + +**Error codes** + +For details about the error codes, see [UiTest Error Codes](../errorcodes/errorcode-uitest.md). + +| ID| Error Message | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + +**Example** + +```js +async function demo() { + let driver = Driver.create(); + await driver.mouseMoveTo({x:100, y:100}) +} +``` + ## PointerMatrix9+ Implements a **PointerMatrix** object that stores coordinates and behaviors of each action of each finger in a multi-touch operation. @@ -2196,12 +2443,12 @@ Sets the coordinates for the action corresponding to the specified finger and st ```js async function demo() { let pointers = PointerMatrix.create(2,3); - pointers.setPoint(0,0,{X:230,Y:480}); - pointers.setPoint(0,1,{X:250,Y:380}); - pointers.setPoint(0,2,{X:270,Y:280}); - pointers.setPoint(1,0,{X:230,Y:680}); - pointers.setPoint(1,1,{X:240,Y:580}); - pointers.setPoint(1,2,{X:250,Y:480}); + pointers.setPoint(0,0,{x:230,y:480}); + pointers.setPoint(0,1,{x:250,y:380}); + pointers.setPoint(0,2,{x:270,y:280}); + pointers.setPoint(1,0,{x:230,y:680}); + pointers.setPoint(1,1,{x:240,y:580}); + pointers.setPoint(1,2,{x:250,y:480}); } ``` @@ -2919,7 +3166,7 @@ let by = BY.selected(true); // Use the static constructor BY to create a By obje isBefore(by: By): By -Specifies the attributes of the component before which the target component is located. +Specifies that the target component is located before the given attribute component. This API is deprecated since API version 9. You are advised to use [isBefore9+](#isbefore9). @@ -2929,7 +3176,7 @@ This API is deprecated since API version 9. You are advised to use [isBefore(deprecated) isAfter(by: By): By -Specifies the attributes of the component after which the target component is located. +Specifies the target component is located after the given attribute component. This API is deprecated since API version 9. You are advised to use [isAfter9+](#isafter9). @@ -2957,7 +3204,7 @@ This API is deprecated since API version 9. You are advised to use [isAfter | Name| Type | Mandatory| Description | | ------ | ------------------- | ---- | ---------------- | -| by | [By](#bydeprecated) | Yes | Attributes of the component before which the target component is located.| +| by | [By](#bydeprecated) | Yes | Information about the attribute component.| **Return value** @@ -2968,7 +3215,7 @@ This API is deprecated since API version 9. You are advised to use [isAfter **Example** ```js -let by = BY.isAfter(BY.text('123')); // Use the static constructor BY to create a By object and specify the attributes of the component after which the target component is located. +let by = BY.isAfter(BY.text('123')); // Use the static constructor BY to create a By object, specifying that the target component is located after the given attribute component. ``` ## UiComponent(deprecated) @@ -3673,6 +3920,6 @@ This API is deprecated since API version 9. You are advised to use [screenCap **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 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 @@ -2034,7 +2036,7 @@ Enumerates update states. | WAITING_INSTALL | 30 | Waiting for installation. | | UPDATING | 31 | Updating. | | WAITING_APPLY | 40 | Waiting for applying the update. | -| APPLYING | 21 | Applying the update. | +| APPLYING | 41 | Applying the update. | | UPGRADE_SUCCESS | 50 | Update succeeded.| | UPGRADE_FAIL | 51 | Update failed.| @@ -2056,7 +2058,7 @@ Enumerates event IDs. | Name | Value | Description | | ---------------------- | ---------- | ------ | -| EVENT_TASK_BASE | 0x01000000 | Task event. | +| EVENT_TASK_BASE | EventClassify.TASK | Task event. | | EVENT_TASK_RECEIVE | 0x01000001 | Task received. | | EVENT_TASK_CANCEL | 0x01000010 | Task cancelled. | | EVENT_DOWNLOAD_WAIT | 0x01000011 | Waiting for download. | diff --git a/en/application-dev/reference/apis/js-apis-usb-deprecated.md b/en/application-dev/reference/apis/js-apis-usb-deprecated.md index 9e7fe19db49c7863967ba386f63dfdeeef4b12cc..f5c4bc2d05b1ac5e085f573c1730882afc38a03c 100644 --- a/en/application-dev/reference/apis/js-apis-usb-deprecated.md +++ b/en/application-dev/reference/apis/js-apis-usb-deprecated.md @@ -1,11 +1,12 @@ -# @ohos.usb (USB Management) +# @ohos.usb (USB) The **usb** module provides USB device management functions, including USB device list query, bulk data transfer, control transfer, and permission control. -> **NOTE** +> **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 is deprecated since API version 9. You are advised to use [`@ohos.usbManager`](js-apis-usbManager.md) instead. +> +> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [`@ohos.usbManager`](js-apis-usbManager.md). ## Modules to Import @@ -25,13 +26,13 @@ Obtains the USB device list. | Type | Description | | ---------------------------------------------------- | ------- | -| Array<Readonly<[USBDevice](#usbdevice)>> | Device information list.| +| Array<Readonly<[USBDevice](#usbdevice)>> | USB device list.| **Example** ```js let devicesList = usb.getDevices(); -console.log(`devicesList = ${JSON.stringify(devicesList)}`); +console.log(`devicesList = ${devicesList}`); // devicesList is a list of USB devices. // A simple example of devicesList is provided as follows: [ @@ -110,7 +111,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ```js let devicepipe= usb.connectDevice(device); -console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); +console.log(`devicepipe = ${devicepipe}`); ``` ## usb.hasRight @@ -131,7 +132,7 @@ Checks whether the application has the permission to access the device. | Type| Description| | -------- | -------- | -| boolean | The value **true** indicates that the application has the permission to access the device, and the value **false** indicates the opposite.| +| boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise.| **Example** @@ -145,7 +146,7 @@ console.log(bool); requestRight(deviceName: string): Promise<boolean> -Requests the temporary permission for the application to access the USB device. This API uses a promise to return the result. +Requests the temporary permission for the application to access a USB device. This API uses a promise to return the result. **System capability**: SystemCapability.USB.USBManager @@ -159,14 +160,14 @@ Requests the temporary permission for the application to access the USB device. | Type| Description| | -------- | -------- | -| Promise<boolean> | Promise used to return the result. The value **true** indicates that the temporary device access permissions are granted, and the value **false** indicates the opposite.| +| Promise<boolean> | Promise used to return the result. The value **true** indicates that the temporary device access permissions are granted; and the value **false** indicates the opposite.| **Example** ```js let devicesName="1-1"; usb.requestRight(devicesName).then((ret) => { - console.log(`requestRight = ${JSON.stringify(ret)}`); + console.log(`requestRight = ${ret}`); }); ``` @@ -192,7 +193,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi | Type| Description| | -------- | -------- | -| number | The value **0** indicates that the USB interface is successfully claimed, and an error code indicates the opposite.| +| number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise.| **Example** @@ -222,7 +223,7 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c | Type| Description| | -------- | -------- | -| number | The value **0** indicates that the USB interface is successfully released, and an error code indicates the opposite.| +| number | Returns **0** if the USB interface is successfully released; returns an error code otherwise.| **Example** @@ -252,7 +253,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi | Type| Description| | -------- | -------- | -| number | The value **0** indicates that the USB configuration is successfully set, and an error code indicates the opposite.| +| number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise.| **Example** @@ -282,7 +283,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi | Type| Description| | -------- | -------- | -| number | The value **0** indicates that the USB interface is successfully set, and an error code indicates the opposite.| +| number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.| **Example** @@ -311,7 +312,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi | Type| Description| | -------- | -------- | -| Uint8Array | The return value is the raw USB descriptor if the operation is successful, or **undefined** if the operation has failed.| +| Uint8Array | Returns the raw USB descriptor if the operation is successful; returns **undefined** otherwise.| **Example** @@ -339,7 +340,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi | Type | Description | | ------ | -------------------- | -| number | The return value is the file descriptor of the USB device if the operation is successful, or **-1** if the operation has failed.| +| number | Returns the file descriptor of the USB device if the operation is successful; returns **-1** otherwise.| **Example** @@ -374,8 +375,9 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **Example** ```js -usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { - console.log(`controlTransfer = ${JSON.stringify(ret)}`); +let param = new usb.USBControlParams(); +usb.controlTransfer(devicepipe, param).then((ret) => { + console.log(`controlTransfer = ${ret}`); }) ``` @@ -411,7 +413,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi // Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device. // Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer. usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { - console.log(`bulkTransfer = ${JSON.stringify(ret)}`); + console.log(`bulkTransfer = ${ret}`); }); ``` @@ -435,7 +437,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi | Type| Description| | -------- | -------- | -| number | The value **0** indicates that the USB device pipe is closed successfully, and an error code indicates the opposite.| +| number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise.| **Example** @@ -498,7 +500,7 @@ Converts the USB function list in the numeric mask format to a string in Device **Example** ```js -let funcs = ACM | ECM; +let funcs = usb.ACM | usb.ECM; let ret = usb.usbFunctionsToString(funcs); ``` @@ -527,7 +529,7 @@ Sets the current USB function list in Device mode. **Example** ```js -let funcs = HDC; +let funcs = usb.HDC; let ret = usb.setCurrentFunctions(funcs); ``` @@ -630,7 +632,12 @@ Sets the role types supported by a specified port, which can be **powerRole** (f **Example** ```js -let ret = usb.getSupportedModes(0); +let portId = 1; +usb.setPortRoles(portId, usb.PowerRoleType.SOURCE, usb.DataRoleType.HOST).then(() => { + console.info('usb setPortRoles successfully.'); +}).catch(err => { + console.error('usb setPortRoles failed: ' + err.code + ' message: ' + err.message); +}); ``` ## USBEndpoint @@ -639,16 +646,16 @@ Represents the USB endpoint from which data is sent or received. You can obtain **System capability**: SystemCapability.USB.USBManager -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| address | number | Yes | Endpoint address. | -| attributes | number | Yes | Endpoint attributes. | -| interval | number | Yes | Endpoint interval. | -| maxPacketSize | number | Yes | Maximum size of data packets on the endpoint. | -| direction | [USBRequestDirection](#usbrequestdirection) | Yes | Endpoint direction. | -| number | number | Yes | Endpoint number. | -| type | number | Yes | Endpoint type. | -| interfaceId | number | Yes | Unique ID of the interface to which the endpoint belongs.| +| Name | Type | Mandatory | Description | +| ------------- | ------------------------------------------- | ------------- |------------ | +| address | number | Yes |Endpoint address. | +| attributes | number | Yes |Endpoint attributes. | +| interval | number | Yes |Endpoint interval. | +| maxPacketSize | number | Yes |Maximum size of data packets on the endpoint. | +| direction | [USBRequestDirection](#usbrequestdirection) | Yes |Endpoint direction. | +| number | number | Yes |Endpoint number. | +| type | number | Yes |Endpoint type. | +| interfaceId | number | Yes |Unique ID of the interface to which the endpoint belongs.| ## USBInterface @@ -656,15 +663,15 @@ Represents a USB interface. One [USBConfig](#usbconfig) can contain multiple **U **System capability**: SystemCapability.USB.USBManager -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| id | number | Yes | Unique ID of the USB interface. | -| protocol | number | Yes | Interface protocol. | -| clazz | number | Yes | Device type. | -| subClass | number | Yes | Device subclass. | -| alternateSetting | number | Yes | Settings for alternating between descriptors of the same USB interface.| -| name | string | Yes | Interface name. | -| endpoints | Array<[USBEndpoint](#usbendpoint)> | Yes | Endpoints that belong to the USB interface. | +| Name | Type | Mandatory |Description | +| ---------------- | ---------------------------------------- | ------------- |--------------------- | +| id | number | Yes |Unique ID of the USB interface. | +| protocol | number | Yes |Interface protocol. | +| clazz | number | Yes |Device type. | +| subClass | number | Yes |Device subclass. | +| alternateSetting | number | Yes |Settings for alternating between descriptors of the same USB interface.| +| name | string | Yes |Interface name. | +| endpoints | Array<[USBEndpoint](#usbendpoint)> | Yes |Endpoints that belong to the USB interface. | ## USBConfig @@ -672,15 +679,15 @@ Represents the USB configuration. One [USBDevice](#usbdevice) can contain multip **System capability**: SystemCapability.USB.USBManager -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| id | number | Yes | Unique ID of the USB configuration. | -| attributes | number | Yes | Configuration attributes. | -| maxPower | number | Yes | Maximum power consumption, in mA. | -| name | string | Yes | Configuration name, which can be left empty. | -| isRemoteWakeup | boolean | Yes | Support for remote wakeup.| -| isSelfPowered | boolean | Yes | Support for independent power supplies.| -| interfaces | Array <[USBInterface](#usbinterface)> | Yes | Supported interface attributes. | +| Name | Type | Mandatory |Description | +| -------------- | ------------------------------------------------ | --------------- |----------- | +| id | number | Yes |Unique ID of the USB configuration. | +| attributes | number | Yes |Configuration attributes. | +| maxPower | number | Yes |Maximum power consumption, in mA. | +| name | string | Yes |Configuration name, which can be left empty. | +| isRemoteWakeup | boolean | Yes |Support for remote wakeup.| +| isSelfPowered | boolean | Yes |Support for independent power supplies.| +| interfaces | Array <[USBInterface](#usbinterface)> | Yes |Supported interface attributes. | ## USBDevice @@ -688,21 +695,21 @@ Represents the USB device information. **System capability**: SystemCapability.USB.USBManager -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| busNum | number | Yes | Bus address. | -| devAddress | number | Yes | Device address. | -| serial | string | Yes | Sequence number. | -| name | string | Yes | Device name. | -| manufacturerName | string | Yes | Device manufacturer. | -| productName | string | Yes | Product name. | -| version | string | Yes | Version number. | -| vendorId | number | Yes | Vendor ID. | -| productId | number | Yes | Product ID. | -| clazz | number | Yes | Device class. | -| subClass | number | Yes | Device subclass. | -| protocol | number | Yes | Device protocol code. | -| configs | Array<[USBConfig](#usbconfig)> | Yes | Device configuration descriptor information.| +| Name | Type | Mandatory |Description | +| ---------------- | ------------------------------------ | ---------- |---------- | +| busNum | number | Yes |Bus address. | +| devAddress | number | Yes |Device address. | +| serial | string | Yes |Sequence number. | +| name | string | Yes |Device name. | +| manufacturerName | string | Yes |Device manufacturer. | +| productName | string | Yes |Product name. | +| version | string | Yes |Version. | +| vendorId | number | Yes |Vendor ID. | +| productId | number | Yes |Product ID. | +| clazz | number | Yes |Device class. | +| subClass | number | Yes |Device subclass. | +| protocol | number | Yes |Device protocol code. | +| configs | Array<[USBConfig](#usbconfig)> | Yes |Device configuration descriptor information.| ## USBDevicePipe @@ -710,10 +717,10 @@ Represents a USB device pipe, which is used to determine a USB device. **System capability**: SystemCapability.USB.USBManager -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| busNum | number | Yes | Bus address.| -| devAddress | number | Yes | Device address.| +| Name | Type | Mandatory |Description | +| ---------- | ------ | ----- |----- | +| busNum | number | Yes |Bus address.| +| devAddress | number | Yes |Device address.| ## USBControlParams @@ -721,14 +728,14 @@ Represents control transfer parameters. **System capability**: SystemCapability.USB.USBManager -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| request | number | Yes | Request type. | -| target | [USBRequestTargetType](#usbrequesttargettype) | Yes | Request target type. | -| reqType | [USBControlRequestType](#usbcontrolrequesttype) | Yes | Control request type. | -| value | number | Yes | Request parameter value. | -| index | number | Yes | Index of the request parameter value.| -| data | Uint8Array | Yes | Buffer for writing or reading data. | +| Name | Type | Mandatory|Description | +| ------- | ----------------------------------------------- | ---------------- |---------------- | +| request | number | Yes |Request type. | +| target | [USBRequestTargetType](#usbrequesttargettype) | Yes |Request target type. | +| reqType | [USBControlRequestType](#usbcontrolrequesttype) | Yes |Control request type. | +| value | number | Yes |Request parameter value. | +| index | number | Yes |Index of the request parameter value.| +| data | Uint8Array | Yes |Buffer for writing or reading data. | ## USBPort9+ @@ -738,11 +745,11 @@ Represents a USB port. **System capability**: SystemCapability.USB.USBManager -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| id | number | Yes | Unique identifier of a USB port. | -| supportedModes | [PortModeType](#portmodetype9) | Yes | Numeric mask combination for the supported mode list.| -| status | [USBPortStatus](#usbportstatus9) | Yes | USB port role. | +| Name | Type | Mandatory|Description | +| -------------- | -------------------------------- | -------------- |----------------------------------- | +| id | number | Yes |Unique identifier of a USB port. | +| supportedModes | [PortModeType](#portmodetype9) | Yes |Numeric mask combination for the supported mode list.| +| status | [USBPortStatus](#usbportstatus9) | Yes |USB port role. | ## USBPortStatus9+ @@ -752,11 +759,11 @@ Enumerates USB port roles. **System capability**: SystemCapability.USB.USBManager -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| currentMode | number | Yes | Current USB mode. | -| currentPowerRole | number | Yes | Current power role. | -| currentDataRole | number | Yes | Current data role. | +| Name | Type| Mandatory|Description | +| ---------------- | -------- | ----------- |---------------------- | +| currentMode | number | Yes |Current USB mode. | +| currentPowerRole | number | Yes |Current power role. | +| currentDataRole | number | Yes |Current data role.| ## USBRequestTargetType @@ -841,7 +848,7 @@ Enumerates power role types. | Name | Value | Description | | ------ | ---- | ---------- | -| NONE | 0 | None. | +| NONE | 0 | None | | SOURCE | 1 | External power supply.| | SINK | 2 | Internal power supply.| @@ -855,6 +862,6 @@ Enumerates data role types. | Name | Value | Description | | ------ | ---- | ------------ | -| NONE | 0 | None. | +| NONE | 0 | None | | HOST | 1 | USB host.| | DEVICE | 2 | USB device.| diff --git a/en/application-dev/reference/apis/js-apis-usb.md b/en/application-dev/reference/apis/js-apis-usb.md index 521fef517823a160e22a17b752fdc62443eeba7a..49bb9b53a08027852baa2614975e6ec9f53d90e9 100644 --- a/en/application-dev/reference/apis/js-apis-usb.md +++ b/en/application-dev/reference/apis/js-apis-usb.md @@ -1,9 +1,12 @@ -# @ohos.usbV9 (USB Management) +# @ohos.usbV9 (USB) The **usb** module provides USB device management functions, including USB device list query, bulk data transfer, control transfer, and permission control on the host side as well as port management, and function switch and query on the device side. -> **NOTE**
+> **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 no longer maintained since API version 9. You are advised to use [`@ohos.usbManager`](js-apis-usbManager.md). ## Modules to Import @@ -29,7 +32,7 @@ Obtains the list of USB devices connected to the host. If no device is connected ```js let devicesList = usb.getDevices(); -console.log(`devicesList = ${JSON.stringify(devicesList)}`); +console.log(`devicesList = ${devicesList}`); // devicesList is a list of USB devices. // A simple example of devicesList is provided as follows: [ @@ -86,7 +89,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`); connectDevice(device: USBDevice): Readonly<USBDevicePipe> -Connects to a USB device based on the device list obtained by using **getDevices()**. +Connects to the USB device based on the device information returned by **getDevices()**. Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and device information, and then call [usb.requestRight](#usbrequestright) to request the device access permission. @@ -118,13 +121,12 @@ For details about the error codes, see [USB Error Codes](../errorcodes/errorcode let devicesList = usb.getDevices(); if (devicesList.length == 0) { console.log(`device list is empty`); - return; } let device = devicesList[0]; usb.requestRight(device.name); let devicepipe = usb.connectDevice(device); -console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); +console.log(`devicepipe = ${devicepipe}`); ``` ## usb.hasRight @@ -133,7 +135,7 @@ hasRight(deviceName: string): boolean Checks whether the application has the permission to access the device. -The value **true** is returned if the device access permission is available; the value **false** is returned otherwise. +Checks whether the user, for example, the application or system, has the device access permissions. The value **true** is returned if the user has the device access permissions; the value **false** is returned otherwise. **System capability**: SystemCapability.USB.USBManager @@ -182,7 +184,7 @@ Requests the temporary permission for the application to access a USB device. Th ```js let devicesName="1-1"; usb.requestRight(devicesName).then((ret) => { - console.log(`requestRight = ${JSON.stringify(ret)}`); + console.log(`requestRight = ${ret}`); }); ``` @@ -210,7 +212,7 @@ Removes the permission for the application to access a USB device. ```js let devicesName="1-1"; -if (usb.removeRight(devicesName) { +if usb.removeRight(devicesName) { console.log(`Succeed in removing right`); } ``` @@ -245,7 +247,7 @@ Adds the permission for the application to access a USB device. ```js let devicesName = "1-1"; let bundleName = "com.example.hello"; -if (usb.addRight(bundleName, devicesName) { +if usb.addRight(bundleName, devicesName) { console.log(`Succeed in adding right`); } ``` @@ -454,8 +456,9 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **Example** ```js -usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { - console.log(`controlTransfer = ${JSON.stringify(ret)}`); +let param = new usb.USBControlParams(); +usb.controlTransfer(devicepipe, param).then((ret) => { + console.log(`controlTransfer = ${ret}`); }) ``` @@ -491,7 +494,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi // Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device. // Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer. usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { - console.log(`bulkTransfer = ${JSON.stringify(ret)}`); + console.log(`bulkTransfer = ${ret}`); }); ``` @@ -578,7 +581,7 @@ Converts the USB function list in the numeric mask format to a string in Device **Example** ```js -let funcs = ACM | ECM; +let funcs = usb.ACM | usb.ECM; let ret = usb.usbFunctionsToString(funcs); ``` @@ -600,14 +603,14 @@ Sets the current USB function list in Device mode. **Return value** -| Type | Description | -| ------------------ | ------------------------------------------------------------ | +| Type | Description | +| --------------- | ------------- | | Promise\ | Promise used to return the result.| **Example** ```js -let funcs = HDC; +let funcs = usb.HDC; usb.setCurrentFunctions(funcs).then(() => { console.info('usb setCurrentFunctions successfully.'); }).catch(err => { @@ -707,15 +710,15 @@ Sets the role types supported by a specified port, which can be **powerRole** (f **Return value** -| Type | Description | -| ------------------ | ------------------------------------------------------------ | -| Promise\ | Promise used to return the result. | +| Type | Description | +| --------------- | ------------- | +| Promise\ | Promise used to return the result.| **Example** ```js let portId = 1; -usb.usb.setPortRoles(portId, usb.PowerRoleType.SOURCE, usb.DataRoleType.HOST).then(() => { +usb.setPortRoles(portId, usb.PowerRoleType.SOURCE, usb.DataRoleType.HOST).then(() => { console.info('usb setPortRoles successfully.'); }).catch(err => { console.error('usb setPortRoles failed: ' + err.code + ' message: ' + err.message); @@ -730,14 +733,14 @@ Represents the USB endpoint from which data is sent or received. You can obtain | Name | Type | Mandatory |Description | | ------------- | ------------------------------------------- | ------------- |------------- | -| address | number | Yes | Endpoint address. | -| attributes | number | Yes | Endpoint attributes. | -| interval | number | Yes | Endpoint interval. | -| maxPacketSize | number | Yes | Maximum size of data packets on the endpoint. | -| direction | [USBRequestDirection](#usbrequestdirection) | Yes | Endpoint direction. | -| number | number | Yes | Endpoint number. | -| type | number | Yes | Endpoint type. | -| interfaceId | number | Yes | Unique ID of the interface to which the endpoint belongs.| +| address | number | Yes|Endpoint address. | +| attributes | number | Yes|Endpoint attributes. | +| interval | number | Yes|Endpoint interval. | +| maxPacketSize | number | Yes|Maximum size of data packets on the endpoint. | +| direction | [USBRequestDirection](#usbrequestdirection) | Yes|Endpoint direction. | +| number | number | Yes|Endpoint number. | +| type | number | Yes|Endpoint type. | +| interfaceId | number | Yes|Unique ID of the interface to which the endpoint belongs.| ## USBInterface @@ -747,13 +750,13 @@ Represents a USB interface. One [USBConfig](#usbconfig) can contain multiple **U | Name | Type | Mandatory |Description | | ---------------- | ---------------------------------------- | ------------- |--------------------- | -| id | number | Yes | Unique ID of the USB interface. | -| protocol | number | Yes | Interface protocol. | -| clazz | number | Yes | Device type. | -| subClass | number | Yes | Device subclass. | -| alternateSetting | number | Yes | Settings for alternating between descriptors of the same USB interface.| -| name | string | Yes | Interface name. | -| endpoints | Array<[USBEndpoint](#usbendpoint)> | Yes | Endpoints that belong to the USB interface. | +| id | number | Yes|Unique ID of the USB interface. | +| protocol | number | Yes|Interface protocol. | +| clazz | number | Yes|Device type. | +| subClass | number | Yes|Device subclass. | +| alternateSetting | number | Yes|Settings for alternating between descriptors of the same USB interface.| +| name | string | Yes|Interface name. | +| endpoints | Array<[USBEndpoint](#usbendpoint)> | Yes|Endpoints that belong to the USB interface. | ## USBConfig @@ -763,13 +766,13 @@ Represents the USB configuration. One [USBDevice](#usbdevice) can contain multip | Name | Type | Mandatory |Description | | -------------- | ------------------------------------------------ | --------------- |--------------- | -| id | number | Yes | Unique ID of the USB configuration. | -| attributes | number | Yes | Configuration attributes. | -| maxPower | number | Yes | Maximum power consumption, in mA. | -| name | string | Yes | Configuration name, which can be left empty. | -| isRemoteWakeup | boolean | Yes | Support for remote wakeup.| -| isSelfPowered | boolean | Yes | Support for independent power supplies.| -| interfaces | Array <[USBInterface](#usbinterface)> | Yes | Supported interface attributes. | +| id | number | Yes|Unique ID of the USB configuration. | +| attributes | number | Yes|Configuration attributes. | +| maxPower | number | Yes|Maximum power consumption, in mA. | +| name | string | Yes|Configuration name, which can be left empty. | +| isRemoteWakeup | boolean | Yes|Support for remote wakeup.| +| isSelfPowered | boolean | Yes| Support for independent power supplies.| +| interfaces | Array <[USBInterface](#usbinterface)> | Yes|Supported interface attributes. | ## USBDevice @@ -779,19 +782,19 @@ Represents the USB device information. | Name | Type | Mandatory |Description | | ---------------- | ------------------------------------ | ---------- |---------- | -| busNum | number | Yes | Bus address. | -| devAddress | number | Yes | Device address. | -| serial | string | Yes | Sequence number. | -| name | string | Yes | Device name. | -| manufacturerName | string | Yes | Device manufacturer. | -| productName | string | Yes | Product name. | -| version | string | Yes | Version number. | -| vendorId | number | Yes | Vendor ID. | -| productId | number | Yes | Product ID. | -| clazz | number | Yes | Device class. | -| subClass | number | Yes | Device subclass. | -| protocol | number | Yes | Device protocol code. | -| configs | Array<[USBConfig](#usbconfig)> | Yes | Device configuration descriptor information.| +| busNum | number | Yes|Bus address. | +| devAddress | number | Yes|Device address. | +| serial | string | Yes|Sequence number. | +| name | string | Yes|Device name. | +| manufacturerName | string | Yes| Device manufacturer. | +| productName | string | Yes|Product name. | +| version | string | Yes|Version number. | +| vendorId | number | Yes|Vendor ID. | +| productId | number | Yes|Product ID. | +| clazz | number | Yes|Device class. | +| subClass | number | Yes|Device subclass. | +| protocol | number | Yes|Device protocol code. | +| configs | Array<[USBConfig](#usbconfig)> | Yes|Device configuration descriptor information.| ## USBDevicePipe @@ -812,12 +815,12 @@ Represents control transfer parameters. | Name | Type | Mandatory |Description | | ------- | ----------------------------------------------- | ---------------- |---------------- | -| request | number | Yes | Request type. | -| target | [USBRequestTargetType](#usbrequesttargettype) | Yes | Request target type. | -| reqType | [USBControlRequestType](#usbcontrolrequesttype) | Yes | Control request type. | -| value | number | Yes | Request parameter value. | -| index | number | Yes | Index of the request parameter value.| -| data | Uint8Array | Yes | Buffer for writing or reading data. | +| request | number | Yes |Request type. | +| target | [USBRequestTargetType](#usbrequesttargettype) | Yes |Request target type. | +| reqType | [USBControlRequestType](#usbcontrolrequesttype) | Yes |Control request type. | +| value | number | Yes |Request parameter value. | +| index | number | Yes |Index of the request parameter value.| +| data | Uint8Array | Yes |Buffer for writing or reading data. | ## USBPort @@ -829,9 +832,9 @@ Represents a USB port. | Name | Type | Mandatory |Description | | -------------- | ------------------------------- | ------------------- |------------------------ | -| id | number | Yes | Unique identifier of a USB port. | -| supportedModes | [PortModeType](#portmodetype) | Yes | Numeric mask combination for the supported mode list.| -| status | [USBPortStatus](#usbportstatus) | Yes | USB port role. | +| id | number | Yes |Unique identifier of a USB port. | +| supportedModes | [PortModeType](#portmodetype) | Yes |Numeric mask combination for the supported mode list.| +| status | [USBPortStatus](#usbportstatus) | Yes |USB port role. | ## USBPortStatus @@ -843,9 +846,9 @@ Enumerates USB port roles. | Name | Type| Mandatory |Description | | ---------------- | -------- | ---------------- |---------------------- | -| currentMode | number | Yes | Current USB mode. | -| currentPowerRole | number | Yes | Current power role. | -| currentDataRole | number | Yes | Current data role.| +| currentMode | number | Yes|Current USB mode. | +| currentPowerRole | number | Yes |Current power role. | +| currentDataRole | number | Yes |Current data role.| ## USBRequestTargetType @@ -853,12 +856,12 @@ Enumerates request target types. **System capability**: SystemCapability.USB.USBManager -| Name | Value | Description | -| ---------------------------- | ----- | ----------- | -| USB_REQUEST_TARGET_DEVICE | 0 | Device | -| USB_REQUEST_TARGET_INTERFACE | 1 | Interface | -| USB_REQUEST_TARGET_ENDPOINT | 2 | Endpoint | -| USB_REQUEST_TARGET_OTHER | 3 | Other | +| Name | Value | Description | +| ---------------------------- | ---- | ------ | +| USB_REQUEST_TARGET_DEVICE | 0 | Device| +| USB_REQUEST_TARGET_INTERFACE | 1 | Interface| +| USB_REQUEST_TARGET_ENDPOINT | 2 | Endpoint| +| USB_REQUEST_TARGET_OTHER | 3 | Other| ## USBControlRequestType diff --git a/en/application-dev/reference/apis/js-apis-usbManager.md b/en/application-dev/reference/apis/js-apis-usbManager.md index c75ebdeb327ca53b0d355515937046ab897a22fc..211a623cce941537d2d24f8ee3764608721bf6fe 100644 --- a/en/application-dev/reference/apis/js-apis-usbManager.md +++ b/en/application-dev/reference/apis/js-apis-usbManager.md @@ -1,4 +1,4 @@ -# @ohos.usbManager (USB Management) +# @ohos.usbManager (USB Manager) The **usbManager** module provides USB device management functions, including USB device list query, bulk data transfer, control transfer, and permission control on the host side as well as port management, and function switch and query on the device side. @@ -30,7 +30,7 @@ Obtains the list of USB devices connected to the host. If no device is connected ```js let devicesList = usb.getDevices(); -console.log(`devicesList = ${JSON.stringify(devicesList)}`); +console.log(`devicesList = ${devicesList}`); // devicesList is a list of USB devices. // A simple example of devicesList is provided as follows: [ @@ -119,13 +119,12 @@ For details about the error codes, see [USB Error Codes](../errorcodes/errorcode let devicesList = usb.getDevices(); if (devicesList.length == 0) { console.log(`device list is empty`); - return; } let device = devicesList[0]; usb.requestRight(device.name); let devicepipe = usb.connectDevice(device); -console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); +console.log(`devicepipe = ${devicepipe}`); ``` ## usb.hasRight @@ -155,7 +154,7 @@ Checks whether the user, for example, the application or system, has the device ```js let devicesName="1-1"; let bool = usb.hasRight(devicesName); -console.log(bool); +console.log(`${bool}`); ``` ## usb.requestRight @@ -183,7 +182,7 @@ Requests the temporary permission for the application to access a USB device. Th ```js let devicesName="1-1"; usb.requestRight(devicesName).then((ret) => { - console.log(`requestRight = ${JSON.stringify(ret)}`); + console.log(`requestRight = ${ret}`); }); ``` @@ -211,7 +210,7 @@ Removes the permission for the application to access a USB device. ```js let devicesName="1-1"; -if (usb.removeRight(devicesName) { +if usb.removeRight(devicesName) { console.log(`Succeed in removing right`); } ``` @@ -246,7 +245,7 @@ Adds the permission for the application to access a USB device. ```js let devicesName = "1-1"; let bundleName = "com.example.hello"; -if (usb.addRight(bundleName, devicesName) { +if usb.addRight(bundleName, devicesName) { console.log(`Succeed in adding right`); } ``` @@ -455,8 +454,9 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **Example** ```js -usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { - console.log(`controlTransfer = ${JSON.stringify(ret)}`); +let param = new usb.USBControlParams(); +usb.controlTransfer(devicepipe, param).then((ret) => { + console.log(`controlTransfer = ${ret}`); }) ``` @@ -492,7 +492,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi // Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device. // Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer. usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { - console.log(`bulkTransfer = ${JSON.stringify(ret)}`); + console.log(`bulkTransfer = ${ret}`); }); ``` @@ -579,7 +579,7 @@ Converts the USB function list in the numeric mask format to a string in Device **Example** ```js -let funcs = ACM | ECM; +let funcs = usb.ACM | usb.ECM; let ret = usb.usbFunctionsToString(funcs); ``` @@ -608,7 +608,7 @@ Sets the current USB function list in Device mode. **Example** ```js -let funcs = HDC; +let funcs = usb.HDC; usb.setCurrentFunctions(funcs).then(() => { console.info('usb setCurrentFunctions successfully.'); }).catch(err => { @@ -716,7 +716,7 @@ Sets the role types supported by a specified port, which can be **powerRole** (f ```js let portId = 1; -usb.usb.setPortRoles(portId, usb.PowerRoleType.SOURCE, usb.DataRoleType.HOST).then(() => { +usb.setPortRoles(portId, usb.PowerRoleType.SOURCE, usb.DataRoleType.HOST).then(() => { console.info('usb setPortRoles successfully.'); }).catch(err => { console.error('usb setPortRoles failed: ' + err.code + ' message: ' + err.message); diff --git a/en/application-dev/reference/apis/js-apis-webSocket.md b/en/application-dev/reference/apis/js-apis-webSocket.md index 6319fda995850708da44bec6c7d00dc158193516..bd7a55c09324684d80e787174483fcc8aefd884e 100644 --- a/en/application-dev/reference/apis/js-apis-webSocket.md +++ b/en/application-dev/reference/apis/js-apis-webSocket.md @@ -64,7 +64,7 @@ ws.connect(defaultIpAddress, (err, value) => { ## webSocket.createWebSocket -createWebSocket\(\): WebSocket +createWebSocket(): WebSocket Creates a WebSocket connection. You can use this API to create or close a WebSocket connection, send data over it, or enable or disable listening for the **open**, **close**, **message**, and **error** events. @@ -89,7 +89,7 @@ Defines a **WebSocket** object. Before invoking WebSocket APIs, you need to call ### connect -connect\(url: string, callback: AsyncCallback\): void +connect(url: string, callback: AsyncCallback\): void Initiates a WebSocket request to establish a WebSocket connection to a given URL. This API uses an asynchronous callback to return the result. @@ -128,7 +128,7 @@ ws.connect(url, (err, value) => { ### connect -connect\(url: string, options: WebSocketRequestOptions, callback: AsyncCallback\): void +connect(url: string, options: WebSocketRequestOptions, callback: AsyncCallback\): void Initiates a WebSocket request carrying specified options to establish a WebSocket connection to a given URL. This API uses an asynchronous callback to return the result. @@ -173,7 +173,7 @@ ws.connect(url, { ### connect -connect\(url: string, options?: WebSocketRequestOptions\): Promise +connect(url: string, options?: WebSocketRequestOptions): Promise\ Initiates a WebSocket request carrying specified options to establish a WebSocket connection to a given URL. This API uses a promise to return the result. @@ -217,7 +217,7 @@ promise.then((value) => { ### send -send\(data: string | ArrayBuffer, callback: AsyncCallback\): void +send(data: string | ArrayBuffer, callback: AsyncCallback\): void Sends data through a WebSocket connection. This API uses an asynchronous callback to return the result. @@ -229,7 +229,7 @@ Sends data through a WebSocket connection. This API uses an asynchronous callbac | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | ------------ | -| data | string \| ArrayBuffer 8+ | Yes | Data to send.| +| data | string \| ArrayBuffer | Yes | Data to send.
Only the string type is supported for API version 6 or earlier. Both the string and ArrayBuffer types are supported for API version 8 or later.| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Error codes** @@ -258,7 +258,7 @@ ws.connect(url, (err, value) => { ### send -send\(data: string | ArrayBuffer\): Promise +send(data: string | ArrayBuffer): Promise\ Sends data through a WebSocket connection. This API uses a promise to return the result. @@ -270,7 +270,7 @@ Sends data through a WebSocket connection. This API uses a promise to return the | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------ | -| data | string \| ArrayBuffer 8+ | Yes | Data to send.| +| data | string \| ArrayBuffer | Yes | Data to send.
Only the string type is supported for API version 6 or earlier. Both the string and ArrayBuffer types are supported for API version 8 or later.| **Return value** @@ -303,7 +303,7 @@ ws.connect(url, (err, value) => { ### close -close\(callback: AsyncCallback\): void +close(callback: AsyncCallback\): void Closes a WebSocket connection. This API uses an asynchronous callback to return the result. @@ -341,7 +341,7 @@ ws.close((err, value) => { ### close -close\(options: WebSocketCloseOptions, callback: AsyncCallback\): void +close(options: WebSocketCloseOptions, callback: AsyncCallback\): void Closes a WebSocket connection carrying specified options such as **code** and **reason**. This API uses an asynchronous callback to return the result. @@ -383,7 +383,7 @@ ws.close({ ### close -close\(options?: WebSocketCloseOptions\): Promise +close(options?: WebSocketCloseOptions): Promise\ Closes a WebSocket connection carrying specified options such as **code** and **reason**. This API uses a promise to return the result. @@ -427,9 +427,9 @@ promise.then((value) => { ``` -### on\('open'\) +### on('open') -on\(type: 'open', callback: AsyncCallback\): void +on(type: 'open', callback: AsyncCallback\): void Enables listening for the **open** events of a WebSocket connection. This API uses an asynchronous callback to return the result. @@ -453,9 +453,9 @@ ws.on('open', (err, value) => { ``` -### off\('open'\) +### off('open') -off\(type: 'open', callback?: AsyncCallback\): void +off(type: 'open', callback?: AsyncCallback\): void Disables listening for the **open** events of a WebSocket connection. This API uses an asynchronous callback to return the result. @@ -484,14 +484,14 @@ ws.off('open', callback1); ``` -### on\('message'\) +### on('message') -on\(type: 'message', callback: AsyncCallback\): void +on(type: 'message', callback: AsyncCallback\): void Enables listening for the **message** events of a WebSocket connection. This API uses an asynchronous callback to return the result. The maximum length of each message is 4 KB. If the length exceeds 4 KB, the message is automatically fragmented. >**NOTE** ->The data in **AsyncCallback** can be in the format of string\(API 6\) or ArrayBuffer\(API 8\). +>The data in **AsyncCallback** can be in the format of string (API version 6) or ArrayBuffer (API version 8). **System capability**: SystemCapability.Communication.NetStack @@ -512,14 +512,14 @@ ws.on('message', (err, value) => { ``` -### off\('message'\) +### off('message') -off\(type: 'message', callback?: AsyncCallback\): void +off(type: 'message', callback?: AsyncCallback\): void Disables listening for the **message** events of a WebSocket connection. This API uses an asynchronous callback to return the result. The maximum length of each message is 4 KB. If the length exceeds 4 KB, the message is automatically fragmented. >**NOTE** ->The data in **AsyncCallback** can be in the format of string\(API 6\) or ArrayBuffer\(API 8\). +>The data in **AsyncCallback** can be in the format of string (API version 6) or ArrayBuffer (API version 8). >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 @@ -539,9 +539,9 @@ ws.off('message'); ``` -### on\('close'\) +### on('close') -on\(type: 'close', callback: AsyncCallback<\{ code: number, reason: string \}\>\): void +on(type: 'close', callback: AsyncCallback\<{ code: number, reason: string }\>): void Enables listening for the **close** events of a WebSocket connection. This API uses an asynchronous callback to return the result. @@ -552,7 +552,7 @@ Enables listening for the **close** events of a WebSocket connection. This API u | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------- | ---- | ------------------------------ | | type | string | Yes | Event type.
**close**: event indicating that a WebSocket connection has been closed.| -| callback | AsyncCallback<{ code: number, reason: string }> | Yes | Callback used to return the result. | +| callback | AsyncCallback\<{ code: number, reason: string }\> | Yes | Callback used to return the result.
**close** indicates the close error code and **reason** indicates the error code description.| **Example** @@ -564,9 +564,9 @@ ws.on('close', (err, value) => { ``` -### off\('close'\) +### off('close') -off\(type: 'close', callback?: AsyncCallback<\{ code: number, reason: string \}\>\): void +off(type: 'close', callback?: AsyncCallback\<{ code: number, reason: string }\>): void Disables listening for the **close** events of a WebSocket connection. This API uses an asynchronous callback to return the result. @@ -580,7 +580,7 @@ Disables listening for the **close** events of a WebSocket connection. This API | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------- | ---- | ------------------------------ | | type | string | Yes | Event type.
**close**: event indicating that a WebSocket connection has been closed.| -| callback | AsyncCallback<{ code: number, reason: string }> | No | Callback used to return the result. | +| callback | AsyncCallback\<{ code: number, reason: string }\> | No | Callback used to return the result.
**close** indicates the close error code and **reason** indicates the error code description.| **Example** @@ -590,9 +590,9 @@ ws.off('close'); ``` -### on\('error'\) +### on('error') -on\(type: 'error', callback: ErrorCallback\): void +on(type: 'error', callback: ErrorCallback): void Enables listening for the **error** events of a WebSocket connection. This API uses an asynchronous callback to return the result. @@ -615,9 +615,9 @@ ws.on('error', (err) => { ``` -### off\('error'\) +### off('error') -off\(type: 'error', callback?: ErrorCallback\): void +off(type: 'error', callback?: ErrorCallback): void Disables listening for the **error** events of a WebSocket connection. This API uses an asynchronous callback to return the result. diff --git a/en/application-dev/reference/apis/js-apis-webview.md b/en/application-dev/reference/apis/js-apis-webview.md index d20a81f9e2b278fc2095fdd32203cfc3761c4f06..16e1356b88974ab8e4e7fcd4b76a021928847018 100644 --- a/en/application-dev/reference/apis/js-apis-webview.md +++ b/en/application-dev/reference/apis/js-apis-webview.md @@ -1739,9 +1739,9 @@ var output = document.querySelector('.output'); window.addEventListener('message', function (event) { if (event.data == '__init_port__') { if (event.ports[0] != null) { - h5Port = event.ports[0]; // 1. Save the port number sent from the eTS side. + h5Port = event.ports[0]; // 1. Save the port number sent from the ArkTS side. h5Port.onmessage = function (event) { - // 2. Receive the message sent from the eTS side. + // 2. Receive the message sent from the ArkTS side. var msg = 'Got message from ets:'; var result = event.data; if (typeof(result) == "string") { @@ -1763,7 +1763,7 @@ window.addEventListener('message', function (event) { } }) -// 3. Use h5Port to send messages to the eTS side. +// 3. Use h5Port to send messages to the ArkTS side. function PostMsgToEts(data) { if (h5Port) { h5Port.postMessage(data); diff --git a/en/application-dev/reference/apis/js-apis-wifiManager.md b/en/application-dev/reference/apis/js-apis-wifiManager.md index c4b50a6993017a534e846fc2edb761ae0f74e12d..dc9beb94d7fcc13d6c82e805bf8855d537e907bd 100644 --- a/en/application-dev/reference/apis/js-apis-wifiManager.md +++ b/en/application-dev/reference/apis/js-apis-wifiManager.md @@ -127,7 +127,7 @@ Obtains the scan result. This API uses a promise to return the result. | **Type**| **Description**| | -------- | -------- | - | Promise< Array<[WifiScanInfo](#wifiscaninfo)> > | Promise used to return the detected hotspots.| + | Promise< Array<[WifiScanInfo](#wifiscaninfo)> > | Promise used to return the hotspots detected.| **Error codes** @@ -409,6 +409,8 @@ Represents EAP configuration information. | caCertAliases | string | Yes| No| CA certificate alias.| | caPath | string | Yes| No| CA certificate path.| | clientCertAliases | string | Yes| No| Client certificate alias.| +| certEntry | Uint8Array | Yes| Yes| CA certificate content.| +| certPassword | string | Yes| Yes| CA certificate password.| | altSubjectMatch | string | Yes| No| A string to match the alternate subject.| | domainSuffixMatch | string | Yes| No| A string to match the domain suffix.| | realm | string | Yes| No| Realm for the passpoint credential.| diff --git a/en/application-dev/reference/apis/js-apis-wifiManagerExt.md b/en/application-dev/reference/apis/js-apis-wifiManagerExt.md index 852b58547ddaf7b5c6eac648016d400ed13f35f9..4d9f1c83dd5fb5739f63520ce52c132c514d0fa7 100644 --- a/en/application-dev/reference/apis/js-apis-wifiManagerExt.md +++ b/en/application-dev/reference/apis/js-apis-wifiManagerExt.md @@ -2,8 +2,9 @@ This **wifiext** module provides WLAN extension interfaces for non-universal products. > **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 described in this document are used only for non-universal products, such as routers. +> +> - 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 described in this document are used only for non-universal products, such as routers. ## Modules to Import @@ -12,9 +13,9 @@ The APIs described in this document are used only for non-universal products, su import wifiManagerExt from '@ohos.wifiManagerExt'; ``` -## wifiext.enableHotspot +## wifiext.enableHotspot9+ -enableHotspot(): boolean; +enableHotspot(): void; Enables the WLAN hotspot. @@ -27,12 +28,12 @@ Enables the WLAN hotspot. For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md). | **Type**| **Description**| - | -------- | -------- | +| -------- | -------- | | 2701000 | Operation failed.| -## wifiext.disableHotspot +## wifiext.disableHotspot9+ -disableHotspot(): boolean; +disableHotspot(): void; Disables the WLAN hotspot. @@ -45,14 +46,14 @@ Disables the WLAN hotspot. For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md). | **Type**| **Description**| - | -------- | -------- | +| -------- | -------- | | 2701000 | Operation failed.| -## wifiext.getSupportedPowerModel +## wifiext.getSupportedPowerMode9+ -getSupportedPowerModel(): Promise<Array<PowerModel>> +getSupportedPowerMode(): Promise<Array<PowerMode>> -Obtains the supported power models. This API uses a promise to return the result. +Obtains the supported power modes. This API uses a promise to return the result. **Required permissions**: ohos.permission.GET_WIFI_INFO @@ -60,21 +61,21 @@ Obtains the supported power models. This API uses a promise to return the result **Return value** - | Type| Description| - | -------- | -------- | - | Promise<Array<[PowerModel](#powermodel)>> | Promise used to return the power models obtained.| +| Type| Description| +| -------- | -------- | +| Promise<Array<[PowerMode](#powermode)>> | Promise used to return the power modes obtained.| **Error codes** For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md). | **Type**| **Description**| - | -------- | -------- | +| -------- | -------- | | 2701000 | Operation failed.| -## PowerModel +## PowerMode -Enumerates the power models. +Enumerates the power modes. **System capability**: SystemCapability.Communication.WiFi.AP.Extension @@ -85,11 +86,11 @@ Enumerates the power models. | THROUGH_WALL | 2 | Through_wall| -## wifiext.getSupportedPowerModel +## wifiext.getSupportedPowerMode9+ -getSupportedPowerModel(callback: AsyncCallback<Array<PowerModel>>): void +getSupportedPowerMode(callback: AsyncCallback<Array<PowerMode>>): void -Obtains the supported power models. This API uses an asynchronous callback to return the result. +Obtains the supported power modes. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.GET_WIFI_INFO @@ -97,23 +98,23 @@ Obtains the supported power models. This API uses an asynchronous callback to re **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<Array<[PowerModel](#powermodel)>> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power models obtained. If **err** is not **0**, an error has occurred.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<Array<[PowerMode](#powermode)>> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power modes obtained. If **err** is not **0**, an error has occurred.| **Error codes** For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md). | **Type**| **Description**| - | -------- | -------- | +| -------- | -------- | | 2701000 | Operation failed.| -## wifiext.getPowerModel +## wifiext.getPowerMode9+ -getPowerModel(): Promise<PowerModel> +getPowerMode(): Promise<PowerMode> -Obtains the power model. This API uses a promise to return the result. +Obtains the power mode. This API uses a promise to return the result. **Required permissions**: ohos.permission.GET_WIFI_INFO @@ -121,23 +122,23 @@ Obtains the power model. This API uses a promise to return the result. **Return value** - | Type| Description| - | -------- | -------- | - | Promise<[PowerModel](#powermodel)> | Promise used to return the power models obtained.| +| Type| Description| +| -------- | -------- | +| Promise<[PowerMode](#powermode)> | Promise used to return the power modes obtained.| **Error codes** For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md). | **Type**| **Description**| - | -------- | -------- | +| -------- | -------- | | 2701000 | Operation failed.| -## wifiext.getPowerModel +## wifiext.getPowerMode9+ -getPowerModel(callback: AsyncCallback<PowerModel>): void +getPowerMode(callback: AsyncCallback<PowerMode>): void -Obtains the power model. This API uses an asynchronous callback to return the result. +Obtains the power mode. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.GET_WIFI_INFO @@ -145,23 +146,23 @@ Obtains the power model. This API uses an asynchronous callback to return the re **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[PowerModel](#powermodel)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power model obtained. If **err** is not **0**, an error has occurred.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[PowerMode](#powermode)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power mode obtained. If **err** is not **0**, an error has occurred.| **Error codes** For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md). | **Type**| **Description**| - | -------- | -------- | +| -------- | -------- | | 2701000 | Operation failed.| -## wifiext.setPowerModel +## wifiext.setPowerMode9+ -setPowerModel(model: PowerModel) : boolean; +setPowerMode(model: PowerMode) : boolean; - Sets the power model. + Sets the power mode. **Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT @@ -169,14 +170,14 @@ setPowerModel(model: PowerModel) : boolean; **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | model | [PowerModel](#powermodel) | Yes| Power model to set.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| model | [PowerMode](#powermode) | Yes| Power mode to set.| **Error codes** For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md). | **Type**| **Description**| - | -------- | -------- | +| -------- | -------- | | 2701000 | Operation failed.| diff --git a/en/application-dev/reference/arkui-js/Readme-EN.md b/en/application-dev/reference/arkui-js/Readme-EN.md index c46abd3bd91d1acbf99bb15152d3f55f636483eb..16bd3fa15567cd54cb38f7f8835c53c5133b168b 100644 --- a/en/application-dev/reference/arkui-js/Readme-EN.md +++ b/en/application-dev/reference/arkui-js/Readme-EN.md @@ -1,104 +1,102 @@ # JavaScript-compatible Web-like Development Paradigm -- 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) - - -- Custom Components - - [Basic Usage](js-components-custom-basic-usage.md) - - [props](js-components-custom-props.md) - - [Style Inheritance](js-components-custom-style.md) - - [slot](js-components-custom-slot.md) - - [Lifecycle Definition](js-components-custom-lifecycle.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) +- Custom Components + - [Basic Usage](js-components-custom-basic-usage.md) + - [props](js-components-custom-props.md) + - [Style Inheritance](js-components-custom-style.md) + - [slot](js-components-custom-slot.md) + - [Lifecycle Definition](js-components-custom-lifecycle.md) - [Dynamic Component Creation](js-components-create-elements.md) - [Data Type Attributes](js-appendix-types.md) 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 e5b7dbf697f485fe49ab8a83eb849457d5c66ea1..ee7d77b8d909a85c416073c74551511de4f5a11c 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,6 +1,7 @@ # picker-view > **NOTE** +> > This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. The **\** component provides the view that shows an embedded scrollable selector on the screen. diff --git a/en/application-dev/reference/arkui-js/js-components-basic-search.md b/en/application-dev/reference/arkui-js/js-components-basic-search.md index adf32950c2889e99e88d67e28da1b6bfb110f4ee..085a50ad4662a61c7aa4e247e6acffa0be30983b 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-search.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-search.md @@ -1,6 +1,7 @@ # search > **NOTE** +> > This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. The **\** component provides an input area for users to search. diff --git a/en/application-dev/reference/arkui-js/js-components-basic-select.md b/en/application-dev/reference/arkui-js/js-components-basic-select.md index e6721685c78744ca4453b50562b59fab220dd767..488a8d1b02e0c4a5a41ca1504fac248b248a7bc4 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-select.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-select.md @@ -1,11 +1,10 @@ # select -The **** component provides a drop-down list that allows users to select among multiple options. - > **NOTE** > > This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. +The **** component provides a drop-down list that allows users to select among multiple options. ## Child Components diff --git a/en/application-dev/reference/arkui-js/js-components-basic-web.md b/en/application-dev/reference/arkui-js/js-components-basic-web.md index 0342d75b5b9183f396ab4fec35c212de5ea9617d..5ce69b6b9762e1afdd3a28fe8895c082f474311c 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-web.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-web.md @@ -1,9 +1,11 @@ # web -The **\** component displays web page content. + >**NOTE** > >This component is supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version. +The **\** component displays web page content. + ## Required Permissions ohos.permission.INTERNET, required only for accessing online web pages. diff --git a/en/application-dev/reference/arkui-js/js-components-common-animation.md b/en/application-dev/reference/arkui-js/js-components-common-animation.md index 72969d608a86f4ce8fdf8ad2eb95431e18b93528..572ff5f9aa30d9eb25d8eca25af56511e71b084b 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-animation.md +++ b/en/application-dev/reference/arkui-js/js-components-common-animation.md @@ -1,11 +1,11 @@ # Animation Styles -Components support dynamic rotation, translation, and scaling effects. These effects can be set in the **style** attribute or CSS files. - > **NOTE** > > The initial APIs of this component are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +Components support dynamic rotation, translation, and scaling effects. These effects can be set in the **style** attribute or CSS files. + | Name | Type | Description | | ------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | transform-origin | string6+ \| \ \| \ string6+ \| \ \| \ | Origin position of the transformed element. The unit can be px or a percentage (relative to the animation target component). If only one value is specified, the other one is **50%**. The available values for the first string are **left**, **center**, and **right**. The available values for the second string are **top**, **center**, and **bottom**.
Example:
transform-origin: 200px 30%
transform-origin: 100px topt
ransform-origin: center center
Default value: **center center** | diff --git a/en/application-dev/reference/arkui-js/js-components-common-atomic-layout.md b/en/application-dev/reference/arkui-js/js-components-common-atomic-layout.md index ab5c6fb8454469cffb018585cd5f8577bc7f1031..97a704e70013bf65de41999d371c03153761aef3 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-atomic-layout.md +++ b/en/application-dev/reference/arkui-js/js-components-common-atomic-layout.md @@ -1,11 +1,10 @@ # Atomic Layout -The atomic layout implements adaptive layout for screens of different sizes and types. Designers can use the atomic layout to define adaptive rules for elements on UIs of different forms. Developers can use the atomic layout to implement the adaptive UI features matching the design effect for a variety of screens. - > **NOTE** > > This component is supported since API version 5. Updates will be marked with a superscript to indicate their earliest API version. +The atomic layout implements adaptive layout for screens of different sizes and types. Designers can use the atomic layout to define adaptive rules for elements on UIs of different forms. Developers can use the atomic layout to implement the adaptive UI features matching the design effect for a variety of screens. ## Hiding Components diff --git a/en/application-dev/reference/arkui-js/js-components-container-stepper-item.md b/en/application-dev/reference/arkui-js/js-components-container-stepper-item.md index c667c410dc89e77f6ec2e1f0a3bcf9ece2597dc6..c67150bc473949b57c052f6b7e74bb20d3a9e2cc 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-stepper-item.md +++ b/en/application-dev/reference/arkui-js/js-components-container-stepper-item.md @@ -1,10 +1,11 @@ # stepper-item -The **\** component displays a step in the step navigator. This component is the child component of **\**. - > **NOTE** > This component is supported since API version 5. Updates will be marked with a superscript to indicate their earliest API version. +The **\** component displays a step in the step navigator. This component is the child component of **\**. + + ## Required Permissions None diff --git a/en/application-dev/reference/arkui-js/js-components-container-tab-content.md b/en/application-dev/reference/arkui-js/js-components-container-tab-content.md index 09dd135cffdeba9254544bc14f662637aef3c847..aed456e555fc8206ebecf81600a48dc0857c6d16 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-tab-content.md +++ b/en/application-dev/reference/arkui-js/js-components-container-tab-content.md @@ -1,11 +1,10 @@ # tab-content -**** is a child component of **[](js-components-container-tabs.md)** and is used to provide the area for displaying the tab content. By default, its height is such that all the remaining space of the **** component is filled. The child components are arranged horizontally. When **** is used as a child element in a container, its length along the main axis must be specified. Otherwise, it cannot be displayed. - > **NOTE** > > This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. +**** is a child component of **[](js-components-container-tabs.md)** and is used to provide the area for displaying the tab content. By default, its height is such that all the remaining space of the **** component is filled. The child components are arranged horizontally. When **** is used as a child element in a container, its length along the main axis must be specified. Otherwise, it cannot be displayed. **\** does not support page scrolling. If page scrolling is required, consider nesting a list. ## Required Permissions @@ -21,7 +20,7 @@ Supported In addition to the [universal attributes](../arkui-js/js-components-common-attributes.md), the following attributes are supported. -| Name | Type| Mandatory| Description| +| Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | scrollable | boolean | No| Whether the tabs can be switched by swiping left or right. The default value is **true**. If this attribute is set to **false**, tab switching is implemented only through the association with **tab-bar**.| diff --git a/en/application-dev/reference/arkui-js/js-components-custom-style.md b/en/application-dev/reference/arkui-js/js-components-custom-style.md index ba8644e3e347e700b523ea0c7f2ab02159faeca7..635c07cc1abe37bf7aa99888cf4efbe77429e02a 100644 --- a/en/application-dev/reference/arkui-js/js-components-custom-style.md +++ b/en/application-dev/reference/arkui-js/js-components-custom-style.md @@ -1,6 +1,6 @@ # Style Inheritance -> **NOTE**
+> **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. diff --git a/en/application-dev/reference/arkui-js/js-components-svg-circle.md b/en/application-dev/reference/arkui-js/js-components-svg-circle.md index 66e793fe790ccc471f91e271b8ae92163d507ac3..3b486978b5123f47660cc130a5d63d39184b1359 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-circle.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-circle.md @@ -1,11 +1,11 @@ # circle -The **\** component is used to draw circles. > **NOTE** > > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +The **\** component is used to draw circles. ## Required Permissions diff --git a/en/application-dev/reference/arkui-js/js-components-svg-ellipse.md b/en/application-dev/reference/arkui-js/js-components-svg-ellipse.md index 1d790bb7cf468e75dc8cd070e01fd42beddf1574..f678409ea72539da10ed2d3a44b80a269d516846 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-ellipse.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-ellipse.md @@ -1,11 +1,11 @@ # ellipse -The **\** component is used to draw oval shapes. > **NOTE** > > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +The **\** component is used to draw oval shapes. ## Required Permissions diff --git a/en/application-dev/reference/arkui-js/js-components-svg-line.md b/en/application-dev/reference/arkui-js/js-components-svg-line.md index f181199036a0d71e2e26e8a66cc3b9d05527ec04..9215e1dc367fa488d45e1e78d62fc4530c70c882 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-line.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-line.md @@ -1,11 +1,11 @@ # line -The **\** component is used to draw a line. > **NOTE** > > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +The **\** component is used to draw a line. ## Required Permissions diff --git a/en/application-dev/reference/arkui-js/js-components-svg-path.md b/en/application-dev/reference/arkui-js/js-components-svg-path.md index a1e114c49db8f8d608a4137b91fcd50fba9c5453..0cec8074e4892ec1ebc84ff6e90e1dcfcb732f44 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-path.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-path.md @@ -1,10 +1,11 @@ # path -The **\** component is used to draw a path. > **NOTE** -> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +The **\** component is used to draw a path. ## Required Permissions diff --git a/en/application-dev/reference/arkui-js/js-components-svg-polygon.md b/en/application-dev/reference/arkui-js/js-components-svg-polygon.md index d747dc84673e72fa6e262509ee77469a3ee6515a..8395e4d4d2cc8462b61231be3f64f9e708787f09 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-polygon.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-polygon.md @@ -1,12 +1,13 @@ # polygon -The **\** component is used to draw a polygon. - > **NOTE** > > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +The **\** component is used to draw a polygon. + + ## Required Permissions None @@ -19,7 +20,7 @@ The following are supported: [\](js-components-svg-animate.md), [\** component is used to draw a polyline. > **NOTE** > > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +The **\** component is used to draw a polyline. ## Required Permissions @@ -19,7 +19,7 @@ The following are supported: [\](js-components-svg-animate.md), [\** component is used to draw rectangles and rounded rectangles. > **NOTE** > > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +The **\** component is used to draw rectangles and rounded rectangles. ## Required Permissions @@ -19,7 +19,7 @@ The following are supported: [\](js-components-svg-animate.md), [\** component is used to display a piece of textual information. - > **NOTE** > @@ -13,6 +11,8 @@ The **\** component is used to display a piece of textual information. > > - Only the default font **sans-serif** is supported. +The **\** component is used to display a piece of textual information. + ## Required Permissions None diff --git a/en/application-dev/reference/arkui-ts/Readme-EN.md b/en/application-dev/reference/arkui-ts/Readme-EN.md index 0c3a6be8dfa6ab66042b70d72fe1daf365aa05b9..9b2c8d0277f79df9dc0cc3e59aece289076af677 100644 --- a/en/application-dev/reference/arkui-ts/Readme-EN.md +++ b/en/application-dev/reference/arkui-ts/Readme-EN.md @@ -54,6 +54,7 @@ - [SwipeGesture](ts-basic-gestures-swipegesture.md) - [Combined Gestures](ts-combined-gestures.md) - Basic Components + - [AlphabetIndexer](ts-container-alphabet-indexer.md) - [Blank](ts-basic-components-blank.md) - [Button](ts-basic-components-button.md) - [Checkbox](ts-basic-components-checkbox.md) @@ -100,7 +101,6 @@ - [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) diff --git a/en/application-dev/reference/arkui-ts/figures/richText.png b/en/application-dev/reference/arkui-ts/figures/richText.png index 65826de750d037a394178b66805a9d1ffdad374e..d7ae9f6dfaa45c77143700a24addf29371c7cc38 100644 Binary files a/en/application-dev/reference/arkui-ts/figures/richText.png and b/en/application-dev/reference/arkui-ts/figures/richText.png differ diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-navigation.md b/en/application-dev/reference/arkui-ts/ts-basic-components-navigation.md index 0365224d576125c9af95fc0cf2531e963c5ff6b7..17787ccda78c576429fe1db1b81b3b5c879cba79 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-navigation.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-navigation.md @@ -25,18 +25,18 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name | Type | Description | | -------------- | ---------------------------------------- | ---------------------------------------- | -| title | string \| [CustomBuilder](ts-types.md#custombuilder8)8+ \| [NavigationCommonTitle](#navigationcommontitle)9+ \| [NavigationCustomTitle](#navigationcustomtitle)9+ | Page title. | +| title | [ResourceStr](ts-types.md#resourcestr)10+ \| [CustomBuilder](ts-types.md#custombuilder8)8+ \| [NavigationCommonTitle](#navigationcommontitle)9+ \| [NavigationCustomTitle](#navigationcustomtitle)9+ | Page title. | | subTitledeprecated | string | Subtitle of the page. This attribute is deprecated since API version 9. You are advised to use **title** instead. | | menus | Array<[NavigationMenuItem](#navigationmenuitem)> \| [CustomBuilder](ts-types.md#custombuilder8)8+ | Menu items in the upper right corner of the page. When the value type is Array\<[NavigationMenuItem](#navigationmenuitem)>, the menu shows a maximum of three icons in portrait mode and a maximum of five icons in landscape mode, plus excess icons (if any) under the automatically generated **More** icon. | | titleMode | [NavigationTitleMode](#navigationtitlemode) | Display mode of the page title bar.
Default value: **NavigationTitleMode.Free**| | toolBar | [object](#object) \| [CustomBuilder](ts-types.md#custombuilder8)8+ | Content of the toolbar.
**items**: items on the toolbar. | | hideToolBar | boolean | Whether to hide the toolbar.
Default value: **false**
**true**: Hide the toolbar.
**false**: Display the toolbar.| | hideTitleBar | boolean | Whether to hide the title bar.
Default value: **false**
**true**: Hide the title bar.
**false**: Display the title bar.| -| hideBackButton | boolean | Whether to hide the Back key.
Default value: **false**
**true**: Hide the Back key.
**false**: Display the Back key.| +| hideBackButton | boolean | Whether to hide the Back button.
Default value: **false**
**true**: Hide the Back button.
**false**: Display the Back button.|The Back button in the title bar of the **\** component cannot be hidden.| | navBarWidth9+ | [Length](ts-types.md#length) | Width of the navigation bar.
Default value: **200vp**| | navBarPosition9+ | [NavBarPosition](#navbarposition) | Position of the navigation bar.
Default value: **NavBarPosition.Start**| | mode9+ | [NavigationMode](#navigationmode) | Display mode of the navigation bar.
Default value: **NavigationMode.Auto**| -| backButtonIcon9+ | string \| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource) | Back icon on the navigation bar.| +| backButtonIcon9+ | string \| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource) | Back button icon on the navigation bar. The Back button in the title bar of the **\** component cannot be hidden.| | hideNavBar9+ | boolean | Whether to hide the navigation bar. This attribute is valid only when **mode** is set to **NavigationMode.Split**.| @@ -91,7 +91,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | ---- | ---------------------------------------- | | Stack | The navigation bar and content area are displayed independently of each other, which are equivalent to two pages.| | Split | The navigation bar and content area are displayed in different columns.| -| Auto | When the window width is greater than or equal to 520 vp, Split mode is used. Otherwise, Stack mode is used.| +| Auto | When the window width is greater than or equal to 520 vp, Split mode is used. Otherwise, the Stack mode is used.| ## TitleHeight @@ -103,7 +103,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the > **NOTE** > -> The scrollable component can only be **\**. +> Among the scrollable components, only **\** is supported. ## Events diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-radio.md b/en/application-dev/reference/arkui-ts/ts-basic-components-radio.md index 94bdbe86681322c5f0b0e4dedf31d6e037447d5b..3213884ab2337bdf548db9b685a64cdd5aa2815b 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-radio.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-radio.md @@ -32,6 +32,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name| Type| Description| | -------- | -------- | -------- | | checked | boolean | Whether the radio button is selected.
Default value: **false**
Since API version 9, this API is supported in ArkTS widgets.| +| radioStyle10+ | [RadioStyle](#radiostyle) | Style of the radio button in selected or deselected state.
Since API version 10, this API is supported in ArkTS widgets.| ## Events @@ -41,6 +42,13 @@ In addition to the [universal events](ts-universal-events-click.md), the followi | -------- | -------- | | onChange(callback: (isChecked: boolean) => void) | Triggered when the selected state of the radio button changes.
- If **isChecked** is **true**, the radio button is selected.
- If **isChecked** is **false**, the radio button is not selected.
Since API version 9, this API is supported in ArkTS widgets.| +## RadioStyle + +| Name | Type | Mandatory| Default Value | Description | +| ---------------------- | ------------------------------------------ | ---- | ------- | ---------------------- | +| checkedBackgroundColor | [ResourceColor](ts-types.md#resourcecolor) | No | #007DFF | Color of the background when the radio button is selected. | +| uncheckedBorderColor | [ResourceColor](ts-types.md#resourcecolor) | No | #182431 | Color of the border when the radio button is deselected. | +| indicatorColor | [ResourceColor](ts-types.md#resourcecolor) | No | #FFFFFF | Color of the indicator when the radio button is selected.| ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-richtext.md b/en/application-dev/reference/arkui-ts/ts-basic-components-richtext.md index 39321308ca3063bc5da81e5ec94d353b02684cd1..fb316a779bf73f0efcb6c7208960b7a6b10c871c 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-richtext.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-richtext.md @@ -31,6 +31,10 @@ RichText(content:string) | onStart(callback: () => void) | Triggered when web page loading starts. | | onComplete(callback: () => void) | Triggered when web page loading is completed.| +## Attributes + +Among the [universal attributes](ts-universal-attributes-size.md), only the **width**, **height**, **size**, and **layoutWeight** attributes are supported. + ## Supported Tags | Name| Description| Example| @@ -39,13 +43,13 @@ RichText(content:string) | \

\

| Defines a paragraph.| \

This is a paragraph\

| | \
| Inserts a newline character.| \

This is a paragraph\
This is a new paragraph\

| | \ | Defines the font style for the text contained within it, including the font face, size, and color.| \This is in red\ | -| \
| Defines a thematic break (such as a shift of topic) on an HTML page and creates a horizontal line.| \

This is a paragraph\

\
\

This is a paragraph\

| +| \
| Defines a thematic break (such as a shift of topic) on an HTML page and creates a horizontal line.| \

This is text\

\
\

This is text\

| | \\ | Defines an image.| \\ | | \
\
| Defines a generic container that is generally used to group block-level elements. It allows you to apply CSS styles to multiple elements at the same time.| \
\

This is the heading in a div element\

\
| | \\ | Displays text in italic style.| \This is in italic style\| | \\ | Defines text that should be styled differently or have a non-textual annotation, such as misspelt words or a proper name in Chinese text. It is recommended that you avoid using the \ tag where it could be confused with a hyperlink.| \

\This is an underlined paragraph\\

| | \ | Used to embed CSS within an HTML document.| \ | -| style | Defines the inline style of an element and is placed inside the tag. Use quotation marks (') to separate the styling text and use semicolons (;) to separate styles, for example, **style='width: 500px;height: 500px;border: 1px solid;margin: 0 auto;'**.| \

This is a heading\

\

This is a paragraph\

| +| style | Defines the inline style of an element and is placed inside the tag. Use quotation marks (') to separate the styling text and use semicolons (;) to separate styles, for example, **style='width: 500px;height: 500px;border: 1px solid;margin: 0 auto;'**.| \

This is a heading\

\

This is text\

| | \ | Embeds or references a client-side script, such as JavaScript.| \ | ## Example @@ -66,7 +70,7 @@ struct RichTextExample { '
' + '

Font size: 35px; line height: 45px

' + '

' + - '

This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.

'; + '

This is text. This is text. This is text. This is text. This is text. This is text. This is text. This is text. This is text.

'; build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, @@ -78,6 +82,29 @@ struct RichTextExample { .onComplete(() => { console.info('RichText onComplete'); }) + .width(500) + .height(400) + .backgroundColor(0XBDDB69) + RichText('layoutWeight(1)') + .onStart(() => { + console.info('RichText onStart'); + }) + .onComplete(() => { + console.info('RichText onComplete'); + }) + .size({ width: '100%', height: 110 }) + .backgroundColor(0X92D6CC) + .layoutWeight(1) + RichText('layoutWeight(2)') + .onStart(() => { + console.info('RichText onStart'); + }) + .onComplete(() => { + console.info('RichText onComplete'); + }) + .size({ width: '100%', height: 110 }) + .backgroundColor(0X92C48D) + .layoutWeight(2) } } } diff --git a/en/application-dev/reference/arkui-ts/ts-components-summary.md b/en/application-dev/reference/arkui-ts/ts-components-summary.md index 3e5b4706f279043c2d77839cdc7da587faaec3dc..19bc1f97eec987ec2e7b97f4507b3e8fc107f29d 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-summary.md +++ b/en/application-dev/reference/arkui-ts/ts-components-summary.md @@ -293,7 +293,7 @@ A component that is used to display widgets. - [Menu](ts-basic-components-menu.md) - A component that is used to present a vertical list of items to the user. Preferentially used on computers. + A component that is used to present a vertical list of items to the user. - [MenuItem](ts-basic-components-menuitem.md) A component that is used to represent an item in a menu. diff --git a/en/application-dev/reference/arkui-ts/ts-container-badge.md b/en/application-dev/reference/arkui-ts/ts-container-badge.md index 83529bd0aee34fc253b3d8f46da5fe2cce6b98cc..1984ff242a64a9e8360e6ef2064e84211bd6d0d5 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-badge.md +++ b/en/application-dev/reference/arkui-ts/ts-container-badge.md @@ -57,12 +57,15 @@ Since API version 9, this API is supported in ArkTS widgets. Since API version 9, this API is supported in ArkTS widgets. -| Name | Type | Mandatory| Default Value | Description | -| ---------- | ------------------------------------------ | ---- | ----------- | ------------------------------------------- | -| color | [ResourceColor](ts-types.md#resourcecolor) | No | Color.White | Font color. | -| fontSize | number \| string | No | 10 | Font size, in vp. | -| badgeSize | number \| string | No | 16 | Badge size, in vp. This parameter cannot be set in percentage. If it is set to an invalid value, the default value is used.| -| badgeColor | [ResourceColor](ts-types.md#resourcecolor) | No | Color.Red | Badge color. | +| Name | Type | Mandatory| Default Value | Description | +| ------------------------- | ------------------------------------------------------------ | ---- | ----------------- | ------------------------------------------------------------ | +| color | [ResourceColor](ts-types.md#resourcecolor) | No | Color.White | Font color. | +| fontSize | number \| string | No | 10 | Font size, in vp. | +| badgeSize | number \| string | No | 16 | Badge size, in vp. This parameter cannot be set in percentage. If it is set to an invalid value, the default value is used.| +| badgeColor | [ResourceColor](ts-types.md#resourcecolor) | No | Color.Red | Badge color. | +| fontWeight10+ | number \|[FontWeight](ts-appendix-enums.md#fontweight) \| string | No | FontWeight.Normal | Font weight of the text. | +| borderColor10+ | [ResourceColor](ts-types.md#resourcecolor) | No | Color.Red | Border color of the background. | +| borderWidth10+ | [Length](ts-types.md#length) | No | 1.0vp | Border width of the background. | ## Example 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 0b0831d7479bb1f720d25a36712a7ad3a50c8db9..02e9c2172db36df28211c3d987d68a32b147a147 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-refresh.md +++ b/en/application-dev/reference/arkui-ts/ts-container-refresh.md @@ -5,6 +5,8 @@ > **NOTE** > > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. +> +> When setting a custom component, make sure its height does not exceed 64 vp. ## Child Components @@ -12,15 +14,16 @@ This component supports only one child component. ## APIs -Refresh\(value: \{ refreshing: boolean, offset?: number | string , friction?: number | string \}\) +Refresh\(value: \{ refreshing: boolean, offset?: number | string , friction?: number | string, builder?: Custombuilder\}\) **Parameters** | Name| Value Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | refreshing | boolean | Yes| Whether the current component is being refreshed.
This parameter supports [$$](../../quick-start/arkts-restrictions-and-extensions.md#two-way-binding-of-variables) for two-way binding of variables.| -| offset | string \| number | No| Distance to the top of the parent component from the **** component that comes to rest after a successful pull-down gesture.
Default value: **16**, in vp| +| offset | string \| number | No| Distance from the pull-down starting point to the top of the component.
Default value: **16**, in vp
**NOTE**
The value cannot be a percentage or a negative number.| | friction | number \| string | No| Coefficient of friction, which indicates the **** component's sensitivity to the pull-down gesture. The value ranges from 0 to 100.
Default value: **62**
- **0** indicates that the **\** component is not sensitive to the pull-down gesture.
- **100** indicates that the **\** component is highly sensitive to the pull-down gesture.
- A larger value indicates a more sensitive response of the **\** component to the pull-down gesture.| +| builder | [CustomBuilder](ts-types.md#custombuilder8)10+ | No| Component with the custom refresh style set for the pull-down gesture.| @@ -32,7 +35,7 @@ Refresh\(value: \{ refreshing: boolean, offset?: number | string , friction?: n | onStateChange(callback: (state: [RefreshStatus](#refreshstatus)) => void)| Triggered when the refresh status changes.
- **state**: refresh status.| | onRefreshing(callback: () => void)| Triggered when the component enters the refresh state.| -## RefreshStatus enums +## RefreshStatus | Name| Description| | -------- | -------- | diff --git a/en/application-dev/reference/arkui-ts/ts-container-scroll.md b/en/application-dev/reference/arkui-ts/ts-container-scroll.md index b8b88e630b72e4499498f066beadc8cd197f8059..14ed577d91fb25d1a797573dd045a7e2f7c86555 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-scroll.md +++ b/en/application-dev/reference/arkui-ts/ts-container-scroll.md @@ -61,7 +61,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ## Scroller -Implements a controller for a scrollable container component. You can bind this component to a container component and use it to control the scrolling of that component. Currently, this controller can be bound to the **\**, **\** and **\** components. One controller can control only one container component. +Implements a controller for a scrollable container component. You can bind this component to a container component and use it to control the scrolling of that component. One controller can control only one container component. The supported container components are **\**, **\**, **\**, **\**, and **\**. ### Objects to Import @@ -82,8 +82,8 @@ Scrolls to the specified position. | Name | Type | Mandatory| Description | | --------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| xOffset | Length | Yes | Horizontal scrolling offset. | -| yOffset | Length | Yes | Vertical scrolling offset. | +| xOffset | number | string | Yes | Horizontal scrolling offset. | +| yOffset | number | string | Yes | Vertical scrolling offset. | | animation | {
duration: number,
curve: [Curve](ts-appendix-enums.md#curve)
} | No | Animation configuration, which includes the following:
- **duration**: scrolling duration.
- **curve**: scrolling curve.| @@ -92,7 +92,7 @@ Scrolls to the specified position. scrollEdge(value: Edge): void -Scrolls to the edge of the container. +Scrolls to the edge of the container, regardless of the scroll axis direction. **Edge.Top** and **Edge.Start** produce the same effect, and **Edge.Bottom** and **Edge.End** produce the same effect. **Parameters** @@ -112,7 +112,7 @@ Scrolls to the next or previous page. | Name | Type | Mandatory | Description | | --------- | ------- | ---- | ------------------------------ | | next | boolean | Yes | Whether to turn to the next page. The value **true** means to scroll to the next page, and **false** means to scroll to the previous page.| -| direction(deprecated) | [Axis](ts-appendix-enums.md#axis) | No | Scrolling direction: horizontal or vertical.
This API is deprecated since API version 9. | +| direction(deprecated) | [Axis](ts-appendix-enums.md#axis) | No | Scrolling direction: horizontal or vertical.
This API is deprecated since API version 9. | ### currentOffset @@ -158,7 +158,7 @@ Scrolls by the specified amount. > **NOTE** > -> Only the **\** component is supported. +> Only the **\**, **\**, **\**, and **\** components are supported. **Parameters** diff --git a/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md b/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md index e8f57f0aebcdf81b7f4a5227b76e8795d79543fb..6dc3c53496053d90595a0fab3010759250e9acb9 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md +++ b/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md @@ -41,6 +41,7 @@ SideBarContainer( type?: SideBarContainerType ) | maxSideBarWidth | number \| Length9+ | Maximum width of the sidebar.
Default value: **280**, in vp| | autoHide9+ | boolean | Whether to automatically hide the sidebar when it is dragged to be smaller than the minimum width.
Default value: **true**| | sideBarPosition9+ | SideBarPosition | Position of the sidebar.
Default value: **SideBarPosition.Start**| +| divider10+ | [DividerStyle](#dividerstyle10) \| null | Divider style.
- **DividerStyle** (default): The divider is displayed.
- **null**: The divider is not displayed.| ## ButtonStyle @@ -59,6 +60,15 @@ SideBarContainer( type?: SideBarContainerType ) | Start | The sidebar is on the left side of the container.| | End | The sidebar is on the right side of the container.| +## DividerStyle10+ + +| Name | Type | Mandatory| Description | +| ----------- | ------------- | ---- | ---------------------------------------- | +| strokeWidth | [Length](ts-types.md#length) | Yes | Stroke width of the divider.
Default value: **1**, in vp | +| color | [ResourceColor](ts-types.md#resourcecolor) | No | Color of the divider.
Default value: **#000000, 3%** | +| startMargin | [Length](ts-types.md#length) | No | Distance between the divider and the top of the sidebar.
Default value: **0**| +| endMargin | [Length](ts-types.md#length) | No | Distance between the divider and the bottom of the sidebar.
Default value: **0**| + ## Events | Name| Description| diff --git a/en/application-dev/reference/arkui-ts/ts-container-stack.md b/en/application-dev/reference/arkui-ts/ts-container-stack.md index 1170de852ec2fd8c3361d4bd19a4cb5fc1f44231..766e63854217ff91b3ed49748d60b72ff490fee8 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-stack.md +++ b/en/application-dev/reference/arkui-ts/ts-container-stack.md @@ -30,7 +30,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name | Type | Description | | ------------ | ------------------------------------------- | ------------------------------ | -| alignContent | [Alignment](ts-appendix-enums.md#alignment) | Alignment of child components in the container.| +| alignContent | [Alignment](ts-appendix-enums.md#alignment) | Alignment of child components in the container.
Default value: **Alignment.Center**
Since API version 9, this API is supported in ArkTS widgets.| ## Example 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 849218cf45e69fd423b020dd8dd26381933c1fe3..2f224afc0377281c20ee36a638b5862a39096106 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-swiper.md +++ b/en/application-dev/reference/arkui-ts/ts-container-swiper.md @@ -30,7 +30,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name | Type | Description | | --------------------------- | ---------------------------------------- | ---------------------------------------- | | index | number | Index of the child component currently displayed in the container.
Default value: **0** | -| autoPlay | boolean | Whether to enable automatic playback for child component switching. If this attribute is **true**, the navigation dots indicator does not take effect.
Default value: **false** | +| autoPlay | boolean | Whether to enable automatic playback for child component switching.
Default value: **false** | | interval | number | Interval for automatic playback, in ms.
Default value: **3000** | | indicator | boolean | Whether to enable the navigation dots indicator.
Default value: **true** | | loop | boolean | Whether to enable loop playback.
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.
Default value: **true**| diff --git a/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md b/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md index d874d686fd63a1e00b2892ec5d24a7e069786e02..6b6a994a6f4e5ea976e96c87a366c501479383c4 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md +++ b/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md @@ -29,6 +29,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the > **NOTE** > - The **\** component does not support setting of the common width attribute. By default, its width is the same as that of the parent **\** component. > - The **\** component does not support setting of the common height attribute. Its height is determined by the height of the parent **\** component and the **\** component. +> - **\** does not support page scrolling. If page scrolling is required, consider nesting a list. ## SubTabBarStyle9+ diff --git a/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md b/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md index 2aef524442b5684e2a509565e642033f50f6cd06..56ebc03a81c7873468f9164e8b7ab90e8de70571 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md @@ -11,7 +11,7 @@ A custom dialog box is a dialog box you customize by using APIs of the **CustomD ## APIs -CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, autoCancel?: boolean, alignment?: DialogAlignment, offset?: Offset, customStyle?: boolean, gridCount?: number, maskColor?: ResourceColor, openAnimation?: AnimateParam, closeAniamtion?: AnimateParam}) +CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, autoCancel?: boolean, alignment?: DialogAlignment, offset?: Offset, customStyle?: boolean, gridCount?: number, maskColor?: ResourceColor, openAnimation?: AnimateParam, closeAniamtion?: AnimateParam, showInSubWindow?: boolean}) **Parameters** @@ -26,8 +26,9 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, aut | customStyle | boolean | No | Whether to use a custom style for the dialog box.
Default value: **false**, which means that the dialog box automatically adapts its width to the grid system and its height to the child components; the maximum height is 90% of the container height; the rounded corner is 24 vp. | | gridCount8+ | number | No | Number of [grid columns](../../ui/ui-ts-layout-grid-container-new.md) occupied by the dialog box.
The default value is 4, and the maximum value is the maximum number of columns supported by the system. If this parameter is set to an invalid value, the default value is used.| | maskColor10+ | [ResourceColor](ts-types.md#resourcecolor) | No | Custom mask color.
Default value: **0x33000000** | -| openAnimation10+ | [AnimateParam](ts-explicit-animation.md#animateparam) | No | Parameters for defining the open animation of the dialog box. | +| openAnimation10+ | [AnimateParam](ts-explicit-animation.md#animateparam) | No | Parameters for defining the open animation of the dialog box.
**NOTE**
If **iterations** is set to an odd number and **playMode** is set to **Reverse**, the dialog box will not be displayed when the animation ends. | | closeAniamtion10+| [AnimateParam](ts-explicit-animation.md#animateparam) | No | Parameters for defining the close animation of the dialog box. | +| showInSubWindow10+| boolean | No | Whether to display a dialog box in a subwindow.
Default value: **false**, indicating that the dialog box is not displayed in the subwindow
**NOTE**
A dialog box whose **showInSubWindow** attribute is **true** cannot trigger the display of another dialog box whose **showInSubWindow** attribute is also **true**. | ## CustomDialogController diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md index 0f946ddb498c50fa7ace4c25c04a79eb8bc47fe1..3427774435b853cc8f3589c8dfc0e7c4c54572c2 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md @@ -11,7 +11,7 @@ Transformation attributes allow you to rotate, translate, scale, or transform a | Name | Type | Description | | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| rotate | {
x?: number,
y?: number,
z?: number,
angle?: number \| string,
centerX?: number \| string,
centerY?: number \| string
} | Rotation axis. A positive angle indicates a clockwise rotation, and a negative angle indicates a counterclockwise rotation. The default value is **0**. **centerX** and **centerY** are used to set the rotation center point.
Default value:
{
x: 0,
y: 0,
z: 0,
angle: 0,
centerX: '50%',
centerY: '50%'
}
Since API version 9, this API is supported in ArkTS widgets.| +| rotate | {
x?: number,
y?: number,
z?: number,
angle: number \| string,
centerX?: number \| string,
centerY?: number \| string
} | Rotation axis. A positive angle indicates a clockwise rotation, and a negative angle indicates a counterclockwise rotation. The default value is **0**. **centerX** and **centerY** are used to set the rotation center point.
Default value:
{
x: 0,
y: 0,
z: 0,
angle: 0,
centerX: '50%',
centerY: '50%'
}
Since API version 9, this API is supported in ArkTS widgets.| | translate | {
x?: number \| string,
y?: number \| string,
z? : number \| string
} | Translation distance along the x-, y-, and z-axis. The translation direction is determined by the positive and negative values. The value cannot be a percentage.
Default value:
{
x: 0,
y: 0,
z: 0
}
Since API version 9, this API is supported in ArkTS widgets.| | scale | {
x?: number,
y?: number,
z?: number,
centerX?: number \| string,
centerY?: number \| string
} | Scale ratio along the x-, y-, and z-axis. The default value is **1**. **centerX** and **centerY** are used to set the scale center point.
Default value:
{
x: 1,
y: 1,
z: 1,
centerX:'50%',
centerY:'50%'
}
Since API version 9, this API is supported in ArkTS widgets.| | transform | [Matrix4Transit](../apis/js-apis-matrix4.md) | Transformation matrix of the component. | diff --git a/en/application-dev/reference/errorcodes/Readme-EN.md b/en/application-dev/reference/errorcodes/Readme-EN.md index 52dd31e184ddcb24483061430f9b7fafab3e3702..6af20aafd50cecbcc2a3a3ad51553d542cf428ae 100644 --- a/en/application-dev/reference/errorcodes/Readme-EN.md +++ b/en/application-dev/reference/errorcodes/Readme-EN.md @@ -20,14 +20,14 @@ - [colorSpaceManager Error Codes](errorcode-colorspace-manager.md) - [Display Error Codes](errorcode-display.md) - [Window Error Codes](errorcode-window.md) -- Media +- Multimedia - [Audio Error Codes](errorcode-audio.md) - [Media Error Codes](errorcode-media.md) - [AVSession Management Error Codes](errorcode-avsession.md) -- Resource Management +- Resource Manager - [I18N Error Codes](errorcode-i18n.md) - [Resource Manager Error Codes](errorcode-resource-manager.md) -- Resource Scheduling +- Background Task - [backgroundTaskManager Error Codes](errorcode-backgroundTaskMgr.md) - [DeviceUsageStatistics Error Codes](errorcode-DeviceUsageStatistics.md) - [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) @@ -87,9 +87,9 @@ - [System Parameter Error Codes](errorcode-system-parameterV9.md) - [USB Error Codes](errorcode-usb.md) - [Update Error Codes](errorcode-update.md) -- Customization Management +- Customization - [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) -- Utils +- Language Base Class Library - [Utils Error Codes](errorcode-utils.md) - Test - [UiTest Error Codes](errorcode-uitest.md) diff --git a/en/application-dev/reference/errorcodes/errorcode-bundle.md b/en/application-dev/reference/errorcodes/errorcode-bundle.md index fa35bc1da83d75945453b3e04452748ac0f5cb42..0787c1a76568ac0baf10306de38b8d97d6ada58e 100644 --- a/en/application-dev/reference/errorcodes/errorcode-bundle.md +++ b/en/application-dev/reference/errorcodes/errorcode-bundle.md @@ -16,7 +16,6 @@ When a query API is called, the bundle name passed in does not exist. 2. The corresponding bundle is not installed. **Solution** - 1. Check whether the spelling of the bundle name is correct. 2. Check whether the corresponding bundle is installed. @@ -125,7 +124,6 @@ When an API of the **distributedBundle** module is called, the device ID passed 2. The device ID does not exist. **Solution** - 1. Check whether the device ID is correct. 2. Check whether the device ID exists. @@ -140,13 +138,11 @@ Failed to install the HAP because the HAP fails to be parsed. When the **install** API of the **installer** module is called, the HAP passed in fails to be parsed. **Possible Causes** - 1. The HAP is not in ZIP format. 2. The configuration file in the HAP is not in JSON format. 3. Necessary fields are missing in the configuration file. **Solution** - 1. Check whether the HAP is in ZIP format. 2. Check whether the configuration file is in [JSON format](../../quick-start/application-configuration-file-overview-stage.md). 3. Check whether an error message is displayed when DevEco Studio compiles the HAP. If necessary fields are missing, an error message will be displayed. @@ -170,7 +166,7 @@ Calling the **install** API of the **installer** module to install the bundle fa **Solution** 1. Check whether the HAP is signed. -2. Ensure that the signature certificate of the HAP is applied for from the application market. +2. Ensure that the signing certificate of the HAP is applied for from the application market. 3. Check whether the same certificate is used for signing multiple HAPs. 4. Check whether the certificate used for signing the upgrade HAP is the same as the certificate used for signing the installed HAP. @@ -248,6 +244,24 @@ The version number is earlier than the version in use. Ensure that the version of the bundle to install is not earlier than the version in use. +## 17700018 Bundle Installation Failure Because the Dependent Module Does Not Exist + +**Error Message** + +Failed to install because the dependent module does not exist. + +**Description** + +The dependent module does not exist during the HAP or HPS installation. + +**Possible Causes** + +The dependent module is not installed. + +**Solution** + +Install the dependent modules first. + ## 17700020 Failure to Uninstall Preinstalled Applications **Error Message** @@ -259,6 +273,7 @@ The preinstalled app cannot be uninstalled. Calling the **uninstall** API of the **installer** module to uninstall a preinstalled application fails. **Possible Causes** + 1. You might want to uninstall a non-preinstalled application but passed the bundle name of a preinstalled app. 2. The preinstalled application cannot be uninstalled. @@ -331,6 +346,7 @@ Failed to get the profile because there is no profile in the HAP. When an API for querying the profile is called, the configuration file does not exist **Possible Causes** + 1. The metadata name passed in the API does not exist in the configuration file. 2. The content of the configuration file is not in JSON format. @@ -444,7 +460,7 @@ The application is a system application and the **AllowAppDataNotCleared** field **Solution** 1. Check whether the application is a system application. You can run the [bm commands](../../../readme/bundle-management.md#bm-commands) to query the application information and check whether the value of **isSystemApp** is **true**. -2. Check whether the **AllowAppDataNotCleared field** is configured for the application. You can run the [bm commands](../../../readme/bundle-management.md#bm-commands) to query the application information and check whether the value of **userDataClearable** is **true**. +2. Check whether the **AllowAppDataNotCleared** field is configured for the application. You can run the [bm commands](../../../readme/bundle-management.md#bm-commands) to query the application information and check whether the value of **userDataClearable** is **true**. ## 17700031 HAP Installation Fails Due to Overlay Feature Verification Failure @@ -468,4 +484,128 @@ The target application and the to-be-installed application with the overlay feat 3. Ensure that the target application is not an application with the overlay feature. 4. Ensure that the target module is not a module with the overlay feature. +## 17700032 Application Does Not Contain a Module with the Overlay Feature + +**Error Message** + +The specified bundle does not contain any overlay module. + +**Description** + +An API is called to obtain the **overlayModuleInfo** object of another application, but that application does not contain a module with the overlay feature. + +**Possible Causes** + +The specified application does not contain a module with the overlay feature. + +**Solution** + +Check whether the application contains a module with the overlay feature. + +## 17700033 Module Is Not Configured with the Overlay Feature + +**Error Message** + +The specified module is not overlay module. + +**Description** + +An API is called to obtain the **overlayModuleInfo** object of a module, but the module is not configured with the overlay feature. + +**Possible Causes** + +The specified module is not a module with the overlay feature. + +**Solution** + +Check whether the module is configured with the overlay feature. + +## 17700034 Module Is Configured with the Overlay Feature + +**Error Message** + +The specified module is overlay module. + +**Description** + +An API is called to obtain the **overlayModuleInfo** object based on the target module name, but that module is configured with the overlay feature. + +**Possible Causes** + +The specified module is configured with the overlay feature. + +**Solution** + +Check whether the specified module is configured with the overlay feature. + +## 17700035 Application Contains Only Modules with the Overlay Feature + +**Error Message** + +The specified bundle is overlay bundle. + +**Description** + +An API is called to obtain the **overlayModuleInfo** object based on the target module name of another application, but that application contains only modules with the overlay feature. + +**Possible Causes** + +The specified application contains only modules with the overlay feature. + +**Solution** + +Check whether the application contains only modules with the overlay feature. + +## 17700036 Failure in Installing the Shared Library Because of No AllowAppShareLibrary Privilege + +**Error Message** + +Failed to install because without allow app shared bundle permission. + +**Description** + +The shared library is not configured with the **AllowAppShareLibrary** privilege, resulting in security and privacy risks. As a result, the installation fails. + +**Possible Causes** + +The shared library does not request the **AllowAppShareLibrary** privilege before being released. + +**Solution** + +Configure the **AllowAppShareLibrary** privilege for the shared library, re-sign the library, and release it. + +## 17700037 Failure in Uninstalling the Shared Library Due to Dependency + +**Error Message** + +The version of shared bundle is dependent on other applications. + +**Description** + +Other applications depend on the shared library, causing the uninstallation to fail. + +**Possible Causes** +1. The version specified during the uninstallation is the latest version of the shared library, and the shared library is depended on by other applications. +2. No version is not specified during the uninstallation, meaning that all versions of the shared library will be uninstalled, and the shared library is depended on by other applications. + +**Solution** +1. Check whether the shared library to uninstall is depended on by other applications. +2. Check whether the version of the shared library to uninstall is the latest version of the shared library. + +## 17700038 Shared Library to Uninstall Does Not Exist + +**Error Message** + +The specified shared bundle does not exist. +**Description** + +The shared library to uninstall does not exist. + +**Possible Causes** +1. The version specified during the uninstallation is different from the version of the shared library installed. +2. The shared library to uninstall is not installed. + +**Solution** +1. Check whether the shared library exists. +2. Check whether the version of the shared library is the same as that installed. diff --git a/en/application-dev/reference/errorcodes/errorcode-hiappevent.md b/en/application-dev/reference/errorcodes/errorcode-hiappevent.md index eb6d5000d0c0f82d5dddfa4f6985b1f308677b4a..46256b87f89e224891a4428c9cc429bec0781bf6 100644 --- a/en/application-dev/reference/errorcodes/errorcode-hiappevent.md +++ b/en/application-dev/reference/errorcodes/errorcode-hiappevent.md @@ -15,6 +15,7 @@ This error code is reported if the **write** API is called to perform applicatio The application event logging function is disabled. **Solution** + Invoke the **configure** API to enable the application event logging function. ```js @@ -41,6 +42,7 @@ The specified event domain name does not comply with the following rules: - The event domain name is not empty and contains a maximum of 32 characters. **Solution** + Specify a valid event domain name. ## 11101002 Invalid Event Name diff --git a/en/application-dev/reference/errorcodes/errorcode-net-socket.md b/en/application-dev/reference/errorcodes/errorcode-net-socket.md index ebd15740b694e135c394b9459c06a7f09438fc8f..d4c982d29c9b402d5f2ed5a5af0ec57537aec19a 100644 --- a/en/application-dev/reference/errorcodes/errorcode-net-socket.md +++ b/en/application-dev/reference/errorcodes/errorcode-net-socket.md @@ -1,5 +1,9 @@ # Socket Error Codes +> **NOTE** +> +> The following describes only the error codes specific to the **socket** module. For details about common error codes, see [Common Error Codes](errorcode-universal.md) file. + ## 2301001 Operation Not Allowed **Error Message** diff --git a/en/application-dev/reference/errorcodes/errorcode-telephony.md b/en/application-dev/reference/errorcodes/errorcode-telephony.md index f90efffed3589a42344d27fcbbf641872e295a96..a39655b6cfb9183f32f99aae8e70023b8d35e4f4 100644 --- a/en/application-dev/reference/errorcodes/errorcode-telephony.md +++ b/en/application-dev/reference/errorcodes/errorcode-telephony.md @@ -165,7 +165,7 @@ This error code is reported if the UT is not connected. **Cause** -The current carrier does not support sending of UT requests over a Wi-Fi network, but the mobile phone is connected to the Wi-Fi network. +The current carrier does not support sending of UT requests over a Wi-Fi network, but the device is connected to the Wi-Fi network. **Solution** diff --git a/en/application-dev/reference/native-lib/Readme-EN.md b/en/application-dev/reference/native-lib/Readme-EN.md index 4bcd443b78791b4f59eb16345bff7f4da93c30f0..9c12f39504aa2d6bc0e21dfb44b0b47aee13af4a 100644 --- a/en/application-dev/reference/native-lib/Readme-EN.md +++ b/en/application-dev/reference/native-lib/Readme-EN.md @@ -1,5 +1,4 @@ # Standard Libraries Supported by Native APIs - - [Node_API](third_party_napi/napi.md) - [libuv](third_party_libuv/libuv.md) - [Native Standard Libraries Supported by Openharmony](third_party_libc/musl.md) diff --git a/en/application-dev/reference/syscap-list.md b/en/application-dev/reference/syscap-list.md index a51200c0fdb7e0ac0ef1e68c7bb44ab7cea33a0b..7c099ac348c597c2b888ca37295bcf82c8ca0c90 100644 --- a/en/application-dev/reference/syscap-list.md +++ b/en/application-dev/reference/syscap-list.md @@ -1,6 +1,6 @@ # SystemCapability List -SysCap, short for System Capability, refers to a standalone feature in the OpenHarmony system. +SystemCapability (SysCap) is a standalone feature in the OpenHarmony system. Before using an API for development, you are advised to familiarize yourself with [SysCap](syscap.md), and then consult the following tables to see whether the SysCap set required for the API is supported by the target device type. @@ -172,14 +172,6 @@ Basic network management services | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | Yes | No | Yes | Yes | Yes | Yes | No | No | -## SystemCapability.Communication.NetManager.Extension - -Extended network management services - -| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | -| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | -| Yes | No | No | Yes | Yes | Yes | No | No | - ## SystemCapability.Communication.NetStack Basic network stack capability @@ -315,14 +307,6 @@ Input device management | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | Yes | No | No | Yes | Yes | Yes | No | No | -## SystemCapability.MultimodalInput.Input.RemoteInputDevice - -Distributed input device management - -| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | -| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | -| Yes | No | No | Yes | Yes | Yes | No | No | - ## SystemCapability.MultimodalInput.Input.InputMonitor Input event listener @@ -347,14 +331,6 @@ Input event simulator | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | Yes | No | No | Yes | Yes | Yes | No | No | -## SystemCapability.MultimodalInput.Input.InputFilter - -Input event filter - -| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | -| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | -| Yes | No | No | Yes | Yes | Yes | No | No | - ## SystemCapability.PowerManager.BatteryManager.Extension Battery manager extension capability @@ -453,7 +429,7 @@ Media audio recorder capability ## SystemCapability.Multimedia.Media.VideoPlayer -Media video player capability +Video player capability | Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | @@ -1347,7 +1323,7 @@ Contacts | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | Yes | No | Yes | Yes | Yes | No | No | No | -## SystemCapability.Applictaions.settings.Core +## SystemCapability.Applications.settings.Core API setting @@ -1658,3 +1634,35 @@ Quick fix | Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | Yes | No | Yes | Yes | Yes | Yes | No | No | + +## SystemCapability.MultimodalInput.Input.Pointer + +Pointer input enhancement + +| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| Yes | No | No | Yes | Yes | Yes | No | No | + +## SystemCapability.Communication.SecureElement + +Secure element access + +| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| No | No | No | No | No | No | No | No | + +## SystemCapability.Msdp.DeviceStatus.Stationarty + +Device status awareness + +| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| Yes | No | No | Yes | Yes | Yes | No | No | + +## SystemCapability.Base + +General type + +| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | diff --git a/en/application-dev/security/accesstoken-guidelines.md b/en/application-dev/security/accesstoken-guidelines.md index 1a1f36e2a0d334d4c2564d66d4738cd5c83dab6e..4898235299bef9f194b70f20ae20dd48303aa915 100644 --- a/en/application-dev/security/accesstoken-guidelines.md +++ b/en/application-dev/security/accesstoken-guidelines.md @@ -2,14 +2,14 @@ ## When to Use -The [Ability Privilege Level (APL)](accesstoken-overview.md#app-apls) of an application can be **normal**, **system_basic**, or **system_core**. The default APL is **normal**. The [permission types](accesstoken-overview.md#permission-types) include **system_grant** and **user_grant**. For details about the permissions for applications, see the [Application Permission List](permission-list.md). +Application permissions are used to prevent unauthorized access to sensitive data or critical functions. The [Ability Privilege Level (APL)](accesstoken-overview.md#application-apls) of an application can be **normal** (default), **system_basic**, or **system_core**. The [permission types](accesstoken-overview.md#permission-types) include **system_grant** and **user_grant**. For details about the permissions for applications, see the [Application Permission List](permission-list.md). This document describes the following operations: - [Declaring Permissions in the Configuration File](#declaring-permissions-in-the-configuration-file) - [Declaring the ACL](#declaring-the-acl) - [Requesting User Authorization](#requesting-user-authorization) -- [Pre-Authorizing user_grant Permissions](#pre-authorizing-user_grant-permissions) +- [Pre-authorizing user_grant Permissions](#pre-authorizing-user_grant-permissions) ## Declaring Permissions in the Configuration File @@ -28,7 +28,7 @@ The following table describes the fields in the configuration file. | usedScene | No | Application scenario of the permission.
This parameter is mandatory when a user_grant permission is required.| | abilities | No | Abilities that require the permission. The value is an array.
**Applicable model**: stage| | ability | No | Abilities that require the permission. The value is an array.
**Applicable model**: FA| -| when | No | Time when the permission is used.
Value:
- **inuse**: The permission applies only to a foreground application.
- **always**: The permission applies to both the foreground and background applications.| +| when | No | Time when the permission is required.
Value:
- **inuse**: The permission is required only when the application is in use.
- **always**: The permission is required no matter whether the application is in use.| ### Stage Model @@ -118,14 +118,14 @@ For example, if an application needs to access audio clips of a user and capture ## Requesting User Authorization -The permissions for accessing user privacy information or using system abilities (for example, accessing Location or Calendar information or using the camera to take photos or record videos) request user authorization. Before an application that requires a **user_grant** permission is called, a verification is performed to check whether the user has granted the permission to the application. If the user has not granted the permission, a dialog box will be displayed to request user authorization. The following figure shows an example. +User authorization is required when an application needs to access user privacy information (such as Location or Calendar information) or using system abilities (such as the camera ability to take photos or record videos). In this case, the application requires a **user_grant** permission. Before the application accesses the data or using the system ability, a verification is performed to check whether the user has granted the permission to the application. If the user has not granted the permission, a dialog box will be displayed to request user authorization. The following figure shows an example. -**Figure 1** Requesting authorization from a user +**Figure 1** Requesting user authorization ![](figures/permission-read_calendar.png) > **NOTE** > -> Each time before an API protected by a **user_grant** permission is called, **requestPermissionsFromUser()** will be called to request user authorization. After the permission is granted, the user may revoke the authorization in **Settings**. Therefore, the previously granted authorization status cannot be persistent. +> Each time before an API protected by a **user_grant** permission is called, **requestPermissionsFromUser()** will be called to request user authorization. After the permission is granted, the user may revoke the authorization in **Settings**. Therefore, the previous authorization status cannot be persistent. ### Stage Model @@ -135,7 +135,7 @@ Example: Apply for the permission for an application to access the Calendar. 2. Check whether the user has granted the permission. - Use [checkAccessToken()](../reference/apis/js-apis-abilityAccessCtrl.md#checkaccesstoken9) to check whether the user has granted the permission. If yes, the application can access the Calendar. Otherwise, request authorization from the user. + Use [checkAccessToken()](../reference/apis/js-apis-abilityAccessCtrl.md#checkaccesstoken9) to check whether the user has granted the permission. If yes, the application can access the Calendar. Otherwise, user authorization is required. ```ts import bundleManager from '@ohos.bundle.bundleManager'; @@ -301,14 +301,14 @@ reqPermissions() { }); } ``` -## Pre-Authorizing user_grant Permissions -By default, the **user_grant** permissions must be dynamically authorized by the user through a dialog box. However, if you do not want the user authorization dialog box to display for pre-installed applications, you can pre-authorize the permissions, for example, the **ohos.permission.MICROPHONE** permission, in the [**install_list_permission.json**](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json) file. The **install_list_permissions.json** file is in the **/system/etc/app/** directory on a device, and is loaded when the device starts. When the application is installed, the **user_grant** permissions in the file are granted.
The **install_list_permissions.json** file contains the following fields: +## Pre-authorizing user_grant Permissions +By default, the **user_grant** permissions must be dynamically authorized by the user through a dialog box. However, some pre-installed applications may require **user_grant** permissions, for example, the system camera application requires the **ohos.permission.MICROPHONE** permission. In this case, you can pre-authorize **user_grant** permissions for pre-installed applications in the [**install_list_permission.json**](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json) file. The **install_list_permissions.json** file is in the **/system/etc/app/** directory on a device, and is loaded when the device starts. When the application is installed, the **user_grant** permissions in the file are granted.
The **install_list_permissions.json** file contains the following fields: - **bundleName**: bundle name of the application. -- **app_signature**: fingerprint information of the application. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md#configuration-in-install_list_capabilityjson). -- **permissions**: **name** specifies the name of the **user_grant** permission to pre-authorize. **userCancellable** specifies whether the user can revoke the pre-authorization. The value **true** means the user can revoke the pre-authorization; the value **false** means the opposite. +- **app_signature**: fingerprint information of the application. For details, see **Configuration in install_list_capability.json** in the [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md). +- **permissions**: The **name** field specifies the name of the **user_grant** permission to pre-authorize. The **userCancellable** field specifies whether the user can revoke the pre-authorization. The value **true** means the user can revoke the pre-authorization; the value **false** means the opposite. -> **NOTE**
This file is available only for preinstalled applications. +> **NOTE**
The **install_list_permissions.json** file is available only for preinstalled applications. ```json [ diff --git a/en/application-dev/security/app-provision-structure.md b/en/application-dev/security/app-provision-structure.md index a772f024a4179af75e30dcf4f6bc0483ed0f86b0..c21fd0f533e72e41062a28d2c0d9f1ffdaabd9a1 100644 --- a/en/application-dev/security/app-provision-structure.md +++ b/en/application-dev/security/app-provision-structure.md @@ -1,22 +1,22 @@ # HarmonyAppProvision Configuration File -The **HarmonyAppProvision** configuration file (also called profile) is the file where you declare permission and signature information for your application. +The **HarmonyAppProvision** configuration file (also called profile) is a file where you declare permission and signature information for your application. -## Configuration File Internal Structure +## Configuration File Structure The **HarmonyAppProvision** file consists of several parts, which are described in the table below. -| Name | Description | Data Type| Mandatory | Initial Value Allowed| +| Name | Description | Data Type| Mandatory| Initial Value Allowed| | ----------- | ---------------------------------------------------------------------------------------- | -------- | -------- | -------- | -| version-code | Version number of the **HarmonyAppProvision** file format. The value is a positive integer containing 32 or less digits.| Number | Yes | No | -| version-name | Description of the version number. It is recommended that the value consist of three segments, for example, **A.B.C**. | String | Yes | No| -| uuid | Unique ID of the **HarmonyAppProvision** file. | String | Yes | No| -| type | Type of the **HarmonyAppProvision** file. The value can be **debug** (for application debugging) or **release** (for application release). The recommended value is **debug**.| String | Yes | No| -| issuer | Issuer of the **HarmonyAppProvision** file. | String | Yes | No| -| validity | Validity period of the **HarmonyAppProvision** file. For details, see [Internal Structure of the validity Object](#internal-structure-of-the-validity-object). | Object | Yes | No | -| bundle-info | Information about the application bundle and developer. For details, see [Internal Structure of the bundle-info Object](#internal-structure-of-the-bundle-info-object). | Object | Yes | No | -| acls | Information about the Access Control Lists (ACLs). For details, see [Internal Structure of the acls Object](#internal-structure-of-the-acls-object). | Object | No | Yes | -| permissions | Permissions required for your application. For details, see [Internal Structure of the permissions Object](#internal-structure-of-the-permissions-object). | Object | No | Yes | -| debug-info | Additional information for application debugging. For details, see [Internal Structure of the debug-info Object](#internal-structure-of-the-debug-info-object). | Object | No | Yes | -| app-privilege-capabilities | Privilege information required by the application bundle. For details, see the [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md). | String array| No | Yes | +| version-code | Version number of the **HarmonyAppProvision** file format. The value is a positive integer containing 32 or less digits.| Number | Yes| No | +| version-name | Description of the version number. It is recommended that the value consist of three segments, for example, **A.B.C**. | String | Yes| No| +| uuid | Unique ID of the **HarmonyAppProvision** file. | String | Yes| No| +| type | Type of the **HarmonyAppProvision** file. The value can be **debug** (for application debugging) or **release** (for application release). The recommended value is **debug**.| String | Yes| No| +| issuer | Issuer of the **HarmonyAppProvision** file. | String | Yes| No| +| validity | Validity period of the **HarmonyAppProvision** file. For details, see [Internal Structure of the validity Object](#internal-structure-of-the-validity-object). | Object | Yes| No | +| bundle-info | Information about the application bundle and developer. For details, see [Internal Structure of the bundle-info Object](#internal-structure-of-the-bundle-info-object). | Object | Yes| No | +| acls | Information about the Access Control Lists (ACLs). For details, see [Internal Structure of the acls Object](#internal-structure-of-the-acls-object). | Object | No| Yes | +| permissions | Permissions required for your application. For details, see [Internal Structure of the permissions Object](#internal-structure-of-the-permissions-object). | Object | No| Yes | +| debug-info | Additional information for application debugging. For details, see [Internal Structure of the debug-info Object](#internal-structure-of-the-debug-info-object). | Object | No| Yes | +| app-privilege-capabilities | Privilege information required by the application bundle. For details, see the [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md). | String array| No| Yes | An example of the **HarmonyAppProvision** file is as follows: ```json @@ -53,47 +53,48 @@ An example of the **HarmonyAppProvision** file is as follows: ``` - ### Internal Structure of the validity Object -| Name | Description | Data Type| Mandatory | Initial Value Allowed| +| Name | Description | Data Type| Mandatory| Initial Value Allowed| | ---------- | ------------------------------- | ------- | ------- | --------- | -| not-before | Start time of the file validity period. The value is a Unix timestamp, which is a non-negative integer.| Number | Yes | No | -| not-after | End time of the file validity period. The value is a Unix timestamp, which is a non-negative integer.| Number | Yes | No | +| not-before | Start time of the file validity period. The value is a Unix timestamp, which is a non-negative integer.| Number | Yes| No | +| not-after | End time of the file validity period. The value is a Unix timestamp, which is a non-negative integer.| Number | Yes| No | ### Internal Structure of the bundle-info Object -| Name | Description | Data Type| Mandatory | Initial Value Allowed| +**NOTE**
The value of **bundle-name** in the **bundle-info** object in the HarmonyAppProvision file must be the same as the value of **bundleName** (in **config.js**/**module.json5**) of the signed application. To prevent a HarmonyAppProvision file from being used for signatures of different applications, the system checks whether the value of **bundleName** in the HAP signature is the same as that in the HAP configuration file during application installation. If they are different, the HAP cannot be installed. + +| Name | Description | Data Type| Mandatory| Initial Value Allowed| | ------------------------ | ------------------------------- | ------- | -------- | --------- | -| developer-id | Unique ID of the developer.| String | Yes | No | -| development-certificate | Information about the [debug certificate](hapsigntool-guidelines.md).| Number | Yes if **type** is set to **debug** and no otherwise | No | -| distribution-certificate | Information about the [release certificate](hapsigntool-guidelines.md).| Number | Yes if **type** is set to **release** and no otherwise| No | -| bundle-name | Bundle name of the application.| String | Yes | No | -| apl | [Ability privilege level (APL)](accesstoken-overview.md) of your application. The value can be **normal**, **system_basic**, or **system_core**.| String | Yes | No | -| app-feature | Type of your application. The value can be **hos_system_app** (system application) or **hos_normal_app** (normal application). Only system applications are allowed to call system APIs. If a normal application calls a system API, the call cannot be successful or the application may run abnormally.| String | Yes | No | +| developer-id | Unique ID of the developer.| String | Yes| No | +| development-certificate | Information about the [debug certificate](hapsigntool-guidelines.md).| Number | Yes if **type** is set to **debug** and no otherwise | No | +| distribution-certificate | Information about the [release certificate](hapsigntool-guidelines.md).| Number | Yes if **type** is set to **release** and no otherwise| No | +| bundle-name | Bundle name of the application.| String | Yes| No | +| apl | [Ability privilege level (APL)](accesstoken-overview.md) of your application. The value can be **normal**, **system_basic**, or **system_core**.| String | Yes| No | +| app-feature | Type of your application. The value can be **hos_system_app** (system application) or **hos_normal_app** (normal application). Only system applications are allowed to call system APIs. If a normal application calls a system API, the call cannot be successful or the application may run abnormally.| String | Yes| No | ### Internal Structure of the acls Object The **acls** object contains the [ACL](accesstoken-overview.md) configured for your application. It should be noted that you still need to add the ACL information to the [**requestPermissions**](../quick-start/module-configuration-file.md#requestpermissions) attribute in the application configuration file. -| Name | Description | Data Type| Mandatory | Initial Value Allowed| +| Name | Description | Data Type| Mandatory| Initial Value Allowed| | ------------------------ | ------------------------------- | ------- | ------- | --------- | -| allowed-acls | [ACLs](../security/accesstoken-overview.md) configured for your application.| String array | No | No | +| allowed-acls | [ACLs](../security/accesstoken-overview.md) configured for your application.| String array | No| No | ### Internal Structure of the permissions Object The **permissions** object contains restricted permissions required for your application. Different from the ACLs set in the **acls** object, these permissions need user authorization during the running of your application. It should be noted that you still need to add the ACL information to the [**requestPermissions**](../quick-start/module-configuration-file.md#requestpermissions) attribute in the application configuration file. -| Name | Description | Data Type| Mandatory | Initial Value Allowed| +| Name | Description | Data Type| Mandatory| Initial Value Allowed| | ------------------------ | ------------------------------- | ------- | ------- | --------- | -| restricted-permissions | [Restricted permissions](accesstoken-overview.md) required for your application.| String array | No | No | +| restricted-permissions | [Restricted permissions](accesstoken-overview.md) required for your application.| String array | No| No | ### Internal Structure of the debug-info Object The **debug-info** object contains debugging information of your application, mainly device management and control information. -| Name | Description | Data Type| Mandatory | Initial Value Allowed| +| Name | Description | Data Type| Mandatory| Initial Value Allowed| | ------------------------ | ------------------------------- | ------- | ------- | --------- | -| device-id-type | Type of the device ID. Currently, only the udid type is supported.| String | No | No | -| device-ids | IDs of devices on which your application can be debugged.| String array | No | No | +| device-id-type | Type of the device ID. Currently, only the udid type is supported.| String | No| No | +| device-ids | IDs of devices on which your application can be debugged.| String array | No| No | ## Modifying the HarmonyAppProvision Configuration File diff --git a/en/application-dev/security/figures/permission-read_calendar.png b/en/application-dev/security/figures/permission-read_calendar.png index 8236bcf2f28531c88362f1210cf70101740394bf..a8834742141c783970b733812f3498f49eb78336 100644 Binary files a/en/application-dev/security/figures/permission-read_calendar.png and b/en/application-dev/security/figures/permission-read_calendar.png differ diff --git a/en/application-dev/security/huks-guidelines.md b/en/application-dev/security/huks-guidelines.md index 59a9bc546ad1db93e6568f1a13d0dcfc8ece4876..c23e9146f3f9e1a10206a003001339efa63f7444 100644 --- a/en/application-dev/security/huks-guidelines.md +++ b/en/application-dev/security/huks-guidelines.md @@ -7,14 +7,16 @@ The HUKS provides the capability of randomly generating keys for services. For a **How to Develop** -Use [huks.generateKeyItem(keyAlias,options,callback)](../reference/apis/js-apis-huks.md#huksgeneratekeyitem9) to generate a key. You need to pass in the key alias in **keyAlias**, key attributes in **options**, and **callback** to return the result asynchronously. For details about the APIs, see [HUKS](../reference/apis/js-apis-huks.md). +Use [huks.generateKeyItem(keyAlias,options,callback)](../reference/apis/js-apis-huks.md#huksgeneratekeyitem9) to generate a key. You need to pass in the key alias in **keyAlias**, key property set in **options**, and **callback** to return the result asynchronously. For details about the APIs, see [HUKS](../reference/apis/js-apis-huks.md). -Procedure: +**Procedure** 1. Determine the key alias. -2. Initialize the key attributes.
Use [HuksParam](../reference/apis/js-apis-huks.md#huksparam) to encapsulate key attributes and use a **HuksParam** array to assign values to the **properties** field of [HuksOptions](../reference/apis/js-apis-huks.md#huksoptions). The parameters [HuksKeyAlg](../reference/apis/js-apis-huks.md#hukskeyalg), [HuksKeySize](../reference/apis/js-apis-huks.md#hukskeysize), and [HuksKeyPurpose](../reference/apis/js-apis-huks.md#hukskeypurpose) are mandatory. +2. Initialize the key property set.
Use [HuksParam](../reference/apis/js-apis-huks.md#huksparam) to encapsulate key properties and use a **HuksParam** array to assign values to the **properties** field of [HuksOptions](../reference/apis/js-apis-huks.md#huksoptions). The parameters [HuksKeyAlg](../reference/apis/js-apis-huks.md#hukskeyalg), [HuksKeySize](../reference/apis/js-apis-huks.md#hukskeysize), and [HuksKeyPurpose](../reference/apis/js-apis-huks.md#hukskeypurpose) are mandatory. 3. Pass in the key alias and key parameter set to generate a key. + + > **NOTE** > > The key alias cannot exceed 64 bytes. @@ -28,7 +30,7 @@ Procedure: import huks from '@ohos.security.huks'; /* - * Determine the key alias and encapsulate the key attributes. + * Determine the key alias and encapsulate the key properties. */ let keyAlias = 'dh_key'; let properties = new Array(); @@ -103,11 +105,11 @@ Once a key is imported to the HUKS, its plaintext will not be exposed outside th ### Importing a Key in Plaintext -Use [huks.importKeyItem(keyAlias,options,callback)](../reference/apis/js-apis-huks.md#huksimportkeyitem9) to import a key in plaintext. You need to pass in the key alias in **keyAlias**, key material and attributes in **options**, and **callback** to return the result asynchronously. For details about the APIs, see [HUKS](../reference/apis/js-apis-huks.md). +Use [huks.importKeyItem(keyAlias,options,callback)](../reference/apis/js-apis-huks.md#huksimportkeyitem9) to import a key in plaintext. You need to pass in the key alias in **keyAlias**, key material and property set in **options**, and **callback** to return the result asynchronously. For details about the APIs, see [HUKS](../reference/apis/js-apis-huks.md). 1. Determine the key alias. -2. Encapsulate the key material and key attributes.
The key material must comply with [HUKS key material formats](./huks-appendix.md#key-material-formats). The **inData** value of [HuksOptions](../reference/apis/js-apis-huks.md#huksoptions) must be in the Uint8Array format. Encapsulate key attributes in [HuksParam](../reference/apis/js-apis-huks.md#huksparam), and use a **HuksParam** array to assign values to the **properties** field. The key attributes must contain [HuksKeyAlg](../reference/apis/js-apis-huks.md#hukskeyalg), [HuksKeySize](../reference/apis/js-apis-huks.md#hukskeysize), and [HuksKeyPurpose](../reference/apis/js-apis-huks.md#hukskeypurpose). +2. Encapsulate the key material and key property set.
The key material must comply with [HUKS key material formats](./huks-appendix.md#key-material-formats). The **inData** value of [HuksOptions](../reference/apis/js-apis-huks.md#huksoptions) must be in the Uint8Array format. Encapsulate key properties in [HuksParam](../reference/apis/js-apis-huks.md#huksparam), and use a **HuksParam** array to assign values to the **properties** field. The key properties must contain [HuksKeyAlg](../reference/apis/js-apis-huks.md#hukskeyalg), [HuksKeySize](../reference/apis/js-apis-huks.md#hukskeysize), and [HuksKeyPurpose](../reference/apis/js-apis-huks.md#hukskeypurpose). 3. Import the key. @@ -131,7 +133,7 @@ let plainTextSize32 = new Uint8Array([ let keyAlias = 'AES256Alias_sample'; /* - * Encapsulate the key attributes and key material. + * Encapsulate the key properties and key material. */ let properties = new Array(); properties[0] = { @@ -223,7 +225,7 @@ You need to use the APIs for generating a key, exporting a public key, importing | -------------------------------------- | ----------------------------| |generateKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void| Generates a key.| |exportKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void| Exports the public key of a key pair.| -|importWrappedKeyItem(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions, callback: AsyncCallback) : void|Imports an wrapped key.| +|importWrappedKeyItem(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions, callback: AsyncCallback) : void|Imports a wrapped key.| |deleteKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void|Deletes a key.| >**NOTE**
The public key plaintext material returned by **exportKeyItem()** is encapsulated in X.509 format, and the key material to be imported by **importWrappedKeyItem()** must be encapsulated in **LengthData-Data** format. Specifically, the application needs to request a Uint8Array and encapsulate the Uint8Array in the sequence listed in the following table. @@ -286,9 +288,9 @@ let inputEccPair = new Uint8Array([ ]); /* - * Encapsulate the key attributes. + * Encapsulate the key properties. */ -// Attributes for the key used for secure import. +// Property set for the key used for secure import. let properties = new Array(); properties[0] = { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, @@ -315,7 +317,7 @@ let huksOptions = { inData: inputEccPair }; -// Attribute set of the AES256 key to be imported. +// Property set of the key to be imported: AES256 let importProperties = new Array(); importProperties[0] = { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, @@ -595,7 +597,7 @@ Check whether the key exists. If yes, the key is imported successfully. import huks from '@ohos.security.huks'; /* - * Determine the key alias and encapsulate the key attributes. + * Determine the key alias and encapsulate the key properties. */ let keyAlias = 'importAlias'; let isKeyExist; @@ -635,94 +637,429 @@ To ensure data confidentiality and integrity, you may need to encrypt or decrypt **General Development Process** The HUKS operates data based on key sessions. The general process is as follows: -1. (Mandatory) Use [huks.initSession()](../reference/apis/js-apis-huks.md#huksinitsession9) to initialize a key session.
You need to pass in the key alias and key operation parameters to initialize a key session, and obtain a session handle. The key operation parameters must contain the parameters required by the cipher algorithm, including the cipher algorithm, key size, key purpose, working mode, padding mode, hash mode, IV, nonce, and AAD. If access control is set for the key, other parameters are required. For details, see [Key Access Control](#key-access-control). -2. (Optional) Use [huks.updateSession()](../reference/apis/js-apis-huks.md#huksupdatesession9) to pass in data by segment.
Perform this step only if the data exceeds 100 KB or the cipher algorithm requires operations by data segment. Otherwise, skip this step. -3. (Mandatory) Use [huks.finishSession()](../reference/apis/js-apis-huks.md#huksfinishsession9) to finalize the key session operation.
Pass in the last data segment and perform the key session operation. If an error occurs during the process or the data passed in is not required, use [huks.abortSession()](../reference/apis/js-apis-huks.md#huksabortsession9) to abort the session. +1. (Mandatory) Use [huks.initSession()](../reference/apis/js-apis-huks.md#huksinitsession9) to initialize a key session.
You need to pass in the key alias and key operation parameters to initialize a key session, and obtain the session handle. The key operation parameters must contain the parameters required by the cipher algorithm, including the cipher algorithm, key size, key purpose, working mode, padding mode, hash mode, IV, nonce, and AAD. If access control is set for the key, other parameters are required. For details, see [Key Access Control](#key-access-control). This step is mandatory. +2. (Optional) Use [huks.updateSession()](../reference/apis/js-apis-huks.md#huksupdatesession9) to pass in data by segment. Perform this step only if the data exceeds 100 KB or the cryptographic algorithm requires operations by data segment. Otherwise, skip this step. This step is optional. +3. (Mandatory) Use [huks.finishSession()](../reference/apis/js-apis-huks.md#huksfinishsession9) to finalize the key session operation.
Pass in the last data segment and perform the key session operation. If an error occurs during the process or the data passed in is not required, use [huks.abortSession()](../reference/apis/js-apis-huks.md#huksabortsession9) to abort the session. This step is mandatory. ### Encryption and Decryption ```ts /* - * Encrypt and decrypt data using an SM4 128-bit key and return the result in a callback. + * The following uses an AES 128-bit key and callback-based APIs as an example. + */ +import huks from '@ohos.security.huks'; +import promptAction from '@ohos.promptAction'; + + +let aesKeyAlias = 'test_aesKeyAlias'; +let handle; +let plainText = '123456'; +let IV = '001122334455'; +let cipherData:Uint8Array; +let plainData:Uint8Array; + +function StringToUint8Array(str) { + let arr = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +function Uint8ArrayToString(fileData) { + let dataString = ''; + for (let i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString; +} + +function GetAesGenerateProperties() { + var properties = new Array(); + var index = 0; + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }; + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 + }; + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + } + return properties; +} + +function GetAesEncryptProperties() { + var properties = new Array(); + var index = 0; + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }; + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 + }; + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT + } + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PKCS7 + } + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC + } + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_IV, + value: StringToUint8Array(IV) + } + return properties; +} + +function GetAesDecryptProperties() { + var properties = new Array(); + var index = 0; + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_ALGORITHM, + value: huks.HuksKeyAlg.HUKS_ALG_AES + }; + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 + }; + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_PURPOSE, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT + } + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_PADDING, + value: huks.HuksKeyPadding.HUKS_PADDING_PKCS7 + } + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC + } + properties[index++] = { + tag: huks.HuksTag.HUKS_TAG_IV, + value: StringToUint8Array(IV) + } + return properties; +} + +async function GenerateAesKey() { + var genProperties = GetAesGenerateProperties(); + var options = { + properties: genProperties + } + await huks.generateKeyItem(aesKeyAlias, options).then((data) => { + promptAction.showToast({ + message: "An AES key is generated.", + duration: 2500, + }) + }).catch((err)=>{ + promptAction.showToast({ + message: "Failed to generate the key. Error code: "+ err.code +" Error message: "+ err.message, + duration: 6500, + }) + }) +} + +async function EncryptData() { + var encryptProperties = GetAesEncryptProperties(); + var options = { + properties:encryptProperties, + inData: StringToUint8Array(plainText) + } + await huks.initSession(aesKeyAlias, options).then((data) => { + handle = data.handle; + }).catch((err)=>{ + promptAction.showToast({ + message: "Failed to initialize the key operation. Error code: "+ err.code +" Error message: "+ err.message, + duration: 6500, + }) + }) + await huks.finishSession(handle, options).then((data) => { + promptAction.showToast({ + message: "Data encrypted successfully. Ciphertext: " + Uint8ArrayToString(data.outData), + duration: 6500, + }) + cipherData = data.outData + }).catch((err)=>{ + promptAction.showToast({ + message: "An exception is captured in the encryption process. Error code: " + err.code +" Error message: "+ err.message, + duration: 6500, + }) + }) +} + +async function DecryptData() { + var decryptOptions = GetAesDecryptProperties() + var options = { + properties:decryptOptions, + inData: cipherData + } + await huks.initSession(aesKeyAlias, options).then((data) => { + handle = data.handle; + }).catch((err)=>{ + promptAction.showToast({ + message: "Failed to initialize the key operation. Error code: "+ err.code +" Error message: "+ err.message, + duration: 6500, + }) + }) + await huks.finishSession(handle, options).then((data) => { + promptAction.showToast({ + message: "Data is decrypted. Plaintext: " + Uint8ArrayToString(data.outData), + duration: 6500, + }) + }).catch((err)=>{ + promptAction.showToast({ + message: "An exception is captured in the decryption process. Error code: " + err.code +" Error message: "+ err.message, + duration: 6500, + }) + }) +} + +async function DeleteKey() { + let emptyOptions = { + properties:[] + } + await huks.deleteKeyItem(aesKeyAlias, emptyOptions).then((data) => { + promptAction.showToast({ + message: "Key is deleted.", + duration: 6500, + }) + }).catch((err)=>{ + promptAction.showToast({ + message: "Failed to delete the key. Error code: "+ err.code +" Error message: "+ err.message, + duration: 6500, + }) + }) +} + +@Entry +@Component +struct Index { + @State message: string = 'Hello Huks' + controller: TextInputController = new TextInputController(); + build() { + Column() { + Row() { + Text('Enter the content to be encrypted.').fontSize(20).margin({ left: 2, top: 10 }) + } + + Row() { + TextInput({placeholder: 'Encrypt 123456 by default', controller: this.controller }) + .placeholderColor(Color.Grey) + .placeholderFont({ size: 14, weight: 400 }) + .caretColor(Color.Blue) + .width(400) + .height(40) + .margin(20) + .fontSize(14) + .fontColor(Color.Black) + .type(InputType.Normal) + .onChange((value: string) => { + This.message +='Plaintext entered: ' + value + '\n' + plainText = value + }) + .margin({ top: 10 }) + } + + Row() { + Text('Encryption or decryption result') .fontSize(20).margin({ left: 2, top: 10 }) + } + + Row() { + TextInput({placeholder: 'Encryption and decryption result', controller: this.controller }) + .placeholderColor(Color.Grey) + .placeholderFont({ size: 14, weight: 400 }) + .caretColor(Color.Blue) + .width(400) + .height(40) + .margin(20) + .fontSize(14) + .fontColor(Color.Black) + .type(InputType.Normal) + .onChange((value: string) => { + This.message +='Plaintext entered: ' + value + '\n' + plainText = value + }) + .margin({ top: 10 }) + } + + Row() { + Button({ type: ButtonType.Normal, stateEffect: true }) { + Text('generateAesKey') + .fontColor(Color.White) + .fontSize(20) + } + .borderRadius(8) + .width('45%') + .height('5%') + .backgroundColor(0x317aff) + .onClick(() => { + GenerateAesKey() + }) + .margin(10) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Text('deleteAesKey') + .fontColor(Color.White) + .fontSize(20) + } + .borderRadius(8) + .width('45%') + .height('5%') + .backgroundColor(0x317aff) + .onClick(() => { + DeleteKey() + }) + .margin(10) + } + + Row() { + Button({ type: ButtonType.Normal, stateEffect: true }) { + Text('EncryptData') + .fontColor(Color.White) + .fontSize(20) + } + .borderRadius(8) + .width('45%') + .height('5%') + .backgroundColor(0x317aff) + .onClick(() => { + EncryptData() + }) + .margin(10) + + Button({ type: ButtonType.Normal, stateEffect: true }) { + Text('DecryptData') + .fontColor(Color.White) + .fontSize(20) + } + .borderRadius(8) + .width('45%') + .height('5%') + .backgroundColor(0x317aff) + .onClick(() => { + DecryptData() + }) + .margin(10) + } + } + } +} +``` + +### Key Agreement +```ts +/* + * Perform key agreement using an X25519 256-bit TEMP key and return the result in a callback. */ import huks from '@ohos.security.huks'; /* - * Determine the key alias and encapsulate the key attributes. + * Determine the key alias and encapsulate the key properties. */ -let srcKeyAlias = 'sm4_Key'; -let IV = '0000000000000000'; -let cipherInData = 'Hks_SM4_Cipher_Test_101010101010101010110_string'; -let encryptUpdateResult = new Array(); -let handle; -let updateResult = new Array(); +let srcKeyAliasFirst = "AgreeX25519KeyFirstAlias"; +let srcKeyAliasSecond = "AgreeX25519KeySecondAlias"; +let agreeX25519InData = 'AgreeX25519TestIndata'; let finishOutData; +let handle; +let exportKey; +let exportKeyFrist; +let exportKeySecond; -/* Configure the key generation parameter set and key encryption parameter set. */ +/* Configure the parameter set used for generating the key. */ let properties = new Array(); properties[0] = { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM4, + value: huks.HuksKeyAlg.HUKS_ALG_X25519, } properties[1] = { tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, } properties[2] = { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128, + value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256, } properties[3] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_NONE, } properties[4] = { tag: huks.HuksTag.HUKS_TAG_PADDING, value: huks.HuksKeyPadding.HUKS_PADDING_NONE, } -let huksOptions = { +properties[5] = { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_CBC, +} +let HuksOptions = { properties: properties, inData: new Uint8Array(new Array()) } -let propertiesEncrypt = new Array(); -propertiesEncrypt[0] = { +/* Configure parameters for the first key agreement. */ +let finishProperties = new Array(); +finishProperties[0] = { + tag: huks.HuksTag.HUKS_TAG_KEY_STORAGE_FLAG, + value: huks.HuksKeyStorageType.HUKS_STORAGE_TEMP, +} +finishProperties[1] = { + tag: huks.HuksTag.HUKS_TAG_IS_KEY_ALIAS, + value: true +} +finishProperties[2] = { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM4, + value: huks.HuksKeyAlg.HUKS_ALG_AES, } -propertiesEncrypt[1] = { +finishProperties[3] = { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, +} +finishProperties[4] = { tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, + value: + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | + huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, } -propertiesEncrypt[2] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128, +finishProperties[5] = { + tag: huks.HuksTag.HUKS_TAG_DIGEST, + value: huks.HuksKeyDigest.HUKS_DIGEST_NONE, } -propertiesEncrypt[3] = { +finishProperties[6] = { + tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, + value: StringToUint8Array(srcKeyAliasFirst+ 'final'), +} +finishProperties[7] = { tag: huks.HuksTag.HUKS_TAG_PADDING, value: huks.HuksKeyPadding.HUKS_PADDING_NONE, } -propertiesEncrypt[4] = { +finishProperties[8] = { tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, -} -propertiesEncrypt[5] = { - tag: huks.HuksTag.HUKS_TAG_IV, - value: StringToUint8Array(IV), + value: huks.HuksCipherMode.HUKS_MODE_ECB, } -let encryptOptions = { - properties: propertiesEncrypt, - inData: new Uint8Array(new Array()) +let finishOptionsFrist = { + properties: finishProperties, + inData: StringToUint8Array(agreeX25519InData) } - -/* Modify the key encryption parameter set to the decryption parameter set. */ -propertiesEncrypt.splice(1, 1, { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, -}); -let decryptOptions = { - properties: propertiesEncrypt, - inData: new Uint8Array(new Array()) +/* Configure parameters for the second key agreement. */ +let finishOptionsSecond = { + properties: finishProperties, + inData: StringToUint8Array(agreeX25519InData) } +finishOptionsSecond.properties.splice(6, 1, { + tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, + value: StringToUint8Array(srcKeyAliasSecond + 'final'), +}) function StringToUint8Array(str) { let arr = []; @@ -732,14 +1069,6 @@ function StringToUint8Array(str) { return new Uint8Array(arr); } -function Uint8ArrayToString(fileData) { - let dataString = ''; - for (let i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]); - } - return dataString; -} - function generateKeyItem(keyAlias:string, huksOptions:huks.HuksOptions, throwObject) { return new Promise((resolve, reject) => { try { @@ -890,6 +1219,44 @@ async function publicFinishFunc(handle:number, huksOptions:huks.HuksOptions) { } } +function exportKeyItem(keyAlias:string, huksOptions:huks.HuksOptions, throwObject) : Promise { + return new Promise((resolve, reject) => { + try { + huks.exportKeyItem(keyAlias, huksOptions, function (error, data) { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + } catch (error) { + throwObject.isThrow = true; + throw(error); + } + }); +} + +async function publicExportKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { + console.info(`enter callback export`); + let throwObject = {isThrow: false}; + try { + await exportKeyItem(keyAlias, huksOptions, throwObject) + .then ((data) => { + console.info(`callback: exportKeyItem success, data = ${JSON.stringify(data)}`); + exportKey = data.outData; + }) + .catch(error => { + if (throwObject.isThrow) { + throw(error); + } else { + console.error(`callback: exportKeyItem failed, code: ${error.code}, msg: ${error.message}`); + } + }); + } catch (error) { + console.error(`callback: exportKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + } +} + function deleteKeyItem(keyAlias:string, huksOptions:huks.HuksOptions, throwObject) { return new Promise((resolve, reject) => { try { @@ -927,839 +1294,62 @@ async function publicDeleteKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions } } -async function testSm4Cipher() { - /* Generate a key. */ - await publicGenKeyFunc(srcKeyAlias, huksOptions); - - /* Encrypt the key. */ - await publicInitFunc(srcKeyAlias, encryptOptions); - - encryptOptions.inData = StringToUint8Array(cipherInData); - await publicUpdateFunc(handle, encryptOptions); - encryptUpdateResult = updateResult; - - encryptOptions.inData = new Uint8Array(new Array()); - await publicFinishFunc(handle, encryptOptions); - if (finishOutData === cipherInData) { - console.info('test finish encrypt err '); - } else { - console.info('test finish encrypt success'); - } +async function testAgree() { + /* 1. Generate two keys and export them. */ + await publicGenKeyFunc(srcKeyAliasFirst, HuksOptions); + await publicGenKeyFunc(srcKeyAliasSecond, HuksOptions); - /* Decrypt the key. */ - await publicInitFunc(srcKeyAlias, decryptOptions); + await publicExportKeyFunc(srcKeyAliasFirst, HuksOptions); + exportKeyFrist = exportKey; + await publicExportKeyFunc(srcKeyAliasFirst, HuksOptions); + exportKeySecond = exportKey; - decryptOptions.inData = new Uint8Array(encryptUpdateResult); - await publicUpdateFunc(handle, decryptOptions); + /* Perform key agreement for the first. */ + await publicInitFunc(srcKeyAliasFirst, HuksOptions); + HuksOptions.inData = exportKeySecond; + await publicUpdateFunc(handle, HuksOptions); + await publicFinishFunc(handle, finishOptionsFrist); - decryptOptions.inData = new Uint8Array(new Array()); - await publicFinishFunc(handle, decryptOptions); - if (finishOutData === cipherInData) { - console.info('test finish decrypt success '); - } else { - console.info('test finish decrypt err'); - } + /* Perform key agreement for the second key. */ + await publicInitFunc(srcKeyAliasSecond, HuksOptions); + HuksOptions.inData = exportKeyFrist; + await publicUpdateFunc(handle, HuksOptions); + await publicFinishFunc(handle, finishOptionsSecond); - await publicDeleteKeyFunc(srcKeyAlias, huksOptions); + await publicDeleteKeyFunc(srcKeyAliasFirst, HuksOptions); + await publicDeleteKeyFunc(srcKeyAliasSecond, HuksOptions); } ``` -### Signing and Signature Verification +### Key Derivation ```ts /* - * Generate and verify a signature using an SM2 key and return the result in a callback. + * The following uses an HKDF256 key and promise-based APIs as an example. */ import huks from '@ohos.security.huks'; /* - * Determine the key alias and encapsulate the key attributes. + * Determine the key alias and encapsulate the key properties. */ -let generateKeyAlias = 'sm2_Key'; -let importKeyAlias = 'importKeyAlias'; -let signVerifyInData1 = 'signVerifyInDataForTestFirstText'; -let signVerifyInData2 = 'signVerifyInDataForTestSecondText'; -let signVerifyInData = [signVerifyInData1, signVerifyInData2]; +let srcKeyAlias = "hkdf_Key"; +let deriveHkdfInData = "deriveHkdfTestIndata"; let handle; -let exportKey; let finishOutData; +let HuksKeyDeriveKeySize = 32; /* Configure the parameter set used for generating the key. */ -let generateKeyProperties = new Array(); -generateKeyProperties[0] = { +let properties = new Array(); +properties[0] = { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM2, + value: huks.HuksKeyAlg.HUKS_ALG_AES, } -generateKeyProperties[1] = { +properties[1] = { tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, -} -generateKeyProperties[2] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256, + value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, } -generateKeyProperties[3] = { +properties[2] = { tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SM3, -} -let genrateKeyOptions = { - properties: generateKeyProperties, - inData: new Uint8Array(new Array()) -} - -/* Configure the parameter set used for signing. */ -let signProperties = new Array(); -signProperties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM2, -} -signProperties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN -} -signProperties[2] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SM3, -} -signProperties[3] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256, -} -let signOptions = { - properties: signProperties, - inData: new Uint8Array(new Array()) -} - -/* Configure the parameter set used for signature verification. */ -let verifyProperties = new Array(); -verifyProperties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_SM2, -} -verifyProperties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY -} -verifyProperties[2] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SM3, -} -verifyProperties[3] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256, -} -let verifyOptions = { - properties: verifyProperties, - inData: new Uint8Array(new Array()) -} - -function StringToUint8Array(str) { - let arr = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function generateKeyItem(keyAlias:string, huksOptions:huks.HuksOptions, throwObject) { - return new Promise((resolve, reject) => { - try { - huks.generateKeyItem(keyAlias, huksOptions, function (error, data) { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw(error); - } - }); -} - -async function publicGenKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { - console.info(`enter callback generateKeyItem`); - let throwObject = {isThrow: false}; - try { - await generateKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`callback: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - if (throwObject.isThrow) { - throw(error); - } else { - console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); - } - }); - } catch (error) { - console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - } -} - -function initSession(keyAlias:string, huksOptions:huks.HuksOptions, throwObject) : Promise { - return new Promise((resolve, reject) => { - try { - huks.initSession(keyAlias, huksOptions, function (error, data) { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw(error); - } - }); -} - -async function publicInitFunc(keyAlias:string, huksOptions:huks.HuksOptions) { - console.info(`enter callback doInit`); - let throwObject = {isThrow: false}; - try { - await initSession(keyAlias, huksOptions, throwObject) - .then ((data) => { - console.info(`callback: doInit success, data = ${JSON.stringify(data)}`); - handle = data.handle; - }) - .catch((error) => { - if (throwObject.isThrow) { - throw(error); - } else { - console.error(`callback: doInit failed, code: ${error.code}, msg: ${error.message}`); - } - }); - } catch (error) { - console.error(`callback: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); - } -} - -function updateSession(handle:number, huksOptions:huks.HuksOptions, throwObject) : Promise { - return new Promise((resolve, reject) => { - try { - huks.updateSession(handle, huksOptions, function (error, data) { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw(error); - } - }); -} - -async function publicUpdateFunc(handle:number, huksOptions:huks.HuksOptions) { - console.info(`enter callback doUpdate`); - let throwObject = {isThrow: false}; - try { - await updateSession(handle, huksOptions, throwObject) - .then ((data) => { - console.info(`callback: doUpdate success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - if (throwObject.isThrow) { - throw(error); - } else { - console.error(`callback: doUpdate failed, code: ${error.code}, msg: ${error.message}`); - } - }); - } catch (error) { - console.error(`callback: doUpdate input arg invalid, code: ${error.code}, msg: ${error.message}`); - } -} - -function finishSession(handle:number, huksOptions:huks.HuksOptions, throwObject) : Promise { - return new Promise((resolve, reject) => { - try { - huks.finishSession(handle, huksOptions, function (error, data) { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw(error); - } - }); -} - -async function publicFinishFunc(handle:number, huksOptions:huks.HuksOptions) { - console.info(`enter callback doFinish`); - let throwObject = {isThrow: false}; - try { - await finishSession(handle, huksOptions, throwObject) - .then ((data) => { - finishOutData = data.outData; - console.info(`callback: doFinish success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - if (throwObject.isThrow) { - throw(error); - } else { - console.error(`callback: doFinish failed, code: ${error.code}, msg: ${error.message}`); - } - }); - } catch (error) { - console.error(`callback: doFinish input arg invalid, code: ${error.code}, msg: ${error.message}`); - } -} - -function exportKeyItem(keyAlias:string, huksOptions:huks.HuksOptions, throwObject) : Promise { - return new Promise((resolve, reject) => { - try { - huks.exportKeyItem(keyAlias, huksOptions, function (error, data) { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw(error); - } - }); -} - -async function publicExportKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { - console.info(`enter callback export`); - let throwObject = {isThrow: false}; - try { - await exportKeyItem(keyAlias, huksOptions, throwObject) - .then ((data) => { - console.info(`callback: exportKeyItem success, data = ${JSON.stringify(data)}`); - exportKey = data.outData; - }) - .catch(error => { - if (throwObject.isThrow) { - throw(error); - } else { - console.error(`callback: exportKeyItem failed, code: ${error.code}, msg: ${error.message}`); - } - }); - } catch (error) { - console.error(`callback: exportKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - } -} - -function importKeyItem(keyAlias:string, huksOptions:huks.HuksOptions, throwObject) { - return new Promise((resolve, reject) => { - try { - huks.importKeyItem(keyAlias, huksOptions, function (error, data) { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw(error); - } - }); -} - -async function publicImportKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { - console.info(`enter promise importKeyItem`); - let throwObject = {isThrow: false}; - try { - await importKeyItem(keyAlias, huksOptions, throwObject) - .then ((data) => { - console.info(`callback: importKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - if (throwObject.isThrow) { - throw(error); - } else { - console.error(`callback: importKeyItem failed, code: ${error.code}, msg: ${error.message}`); - } - }); - } catch (error) { - console.error(`callback: importKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - } -} - -function deleteKeyItem(keyAlias:string, huksOptions:huks.HuksOptions, throwObject) { - return new Promise((resolve, reject) => { - try { - huks.deleteKeyItem(keyAlias, huksOptions, function (error, data) { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw(error); - } - }); -} - -async function publicDeleteKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { - console.info(`enter callback deleteKeyItem`); - let throwObject = {isThrow: false}; - try { - await deleteKeyItem(keyAlias, huksOptions, throwObject) - .then ((data) => { - console.info(`callback: deleteKeyItem key success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - if (throwObject.isThrow) { - throw(error); - } else { - console.error(`callback: deleteKeyItem failed, code: ${error.code}, msg: ${error.message}`); - } - }); - } catch (error) { - console.error(`callback: deletKeeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - } -} - -async function testSm2SignVerify() { - /* Generate a key. */ - await publicGenKeyFunc(generateKeyAlias, genrateKeyOptions); - - /* Generate a signature. */ - let signHandle; - let signFinishOutData; - await publicInitFunc(generateKeyAlias, signOptions); - - signHandle = handle; - for (var index = 0; index < signVerifyInData.length; index++) { - signOptions.inData = StringToUint8Array(signVerifyInData[index]); - await publicUpdateFunc(signHandle, signOptions); - } - signOptions.inData = new Uint8Array(new Array()); - await publicFinishFunc(signHandle, signOptions); - signFinishOutData = finishOutData; - - /* Export the key. */ - await publicExportKeyFunc(generateKeyAlias, genrateKeyOptions); - - /* Import the key. */ - verifyOptions.inData = exportKey; - await publicImportKeyFunc(importKeyAlias, verifyOptions); - - /* Verify the signature. */ - let verifyHandle; - await publicInitFunc(importKeyAlias, verifyOptions); - - verifyHandle = handle; - for (var index = 0; index < signVerifyInData.length; index++) { - verifyOptions.inData = StringToUint8Array(signVerifyInData[index]); - await publicUpdateFunc(verifyHandle, verifyOptions); - } - verifyOptions.inData = signFinishOutData; - await publicFinishFunc(verifyHandle, verifyOptions); - - await publicDeleteKeyFunc(generateKeyAlias, genrateKeyOptions); - await publicDeleteKeyFunc(importKeyAlias, genrateKeyOptions); -} -``` - -### Key Agreement -```ts -/* - * Perform key agreement using an X25519 256-bit TEMP key and return the result in a callback. - */ -import huks from '@ohos.security.huks'; - -/* - * Determine the key alias and encapsulate the key attributes. - */ -let srcKeyAliasFirst = "AgreeX25519KeyFirstAlias"; -let srcKeyAliasSecond = "AgreeX25519KeySecondAlias"; -let agreeX25519InData = 'AgreeX25519TestIndata'; -let finishOutData; -let handle; -let exportKey; -let exportKeyFrist; -let exportKeySecond; - -/* Configure the parameter set used for generating the key. */ -let properties = new Array(); -properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_X25519, -} -properties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, -} -properties[2] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256, -} -properties[3] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE, -} -properties[4] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, -} -properties[5] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, -} -let HuksOptions = { - properties: properties, - inData: new Uint8Array(new Array()) -} - -/* Configure parameters for the first key agreement. */ -let finishProperties = new Array(); -finishProperties[0] = { - tag: huks.HuksTag.HUKS_TAG_KEY_STORAGE_FLAG, - value: huks.HuksKeyStorageType.HUKS_STORAGE_TEMP, -} -finishProperties[1] = { - tag: huks.HuksTag.HUKS_TAG_IS_KEY_ALIAS, - value: true -} -finishProperties[2] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, -} -finishProperties[3] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, -} -finishProperties[4] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, -} -finishProperties[5] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE, -} -finishProperties[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, - value: StringToUint8Array(srcKeyAliasFirst+ 'final'), -} -finishProperties[7] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, -} -finishProperties[8] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB, -} -let finishOptionsFrist = { - properties: finishProperties, - inData: StringToUint8Array(agreeX25519InData) -} -/* Configure parameters for the second key agreement. */ -let finishOptionsSecond = { - properties: finishProperties, - inData: StringToUint8Array(agreeX25519InData) -} -finishOptionsSecond.properties.splice(6, 1, { - tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, - value: StringToUint8Array(srcKeyAliasSecond + 'final'), -}) - -function StringToUint8Array(str) { - let arr = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - return new Uint8Array(arr); -} - -function generateKeyItem(keyAlias:string, huksOptions:huks.HuksOptions, throwObject) { - return new Promise((resolve, reject) => { - try { - huks.generateKeyItem(keyAlias, huksOptions, function (error, data) { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw(error); - } - }); -} - -async function publicGenKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { - console.info(`enter callback generateKeyItem`); - let throwObject = {isThrow: false}; - try { - await generateKeyItem(keyAlias, huksOptions, throwObject) - .then((data) => { - console.info(`callback: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - if (throwObject.isThrow) { - throw(error); - } else { - console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); - } - }); - } catch (error) { - console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - } -} - -function initSession(keyAlias:string, huksOptions:huks.HuksOptions, throwObject) : Promise { - return new Promise((resolve, reject) => { - try { - huks.initSession(keyAlias, huksOptions, function (error, data) { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw(error); - } - }); -} - -async function publicInitFunc(keyAlias:string, huksOptions:huks.HuksOptions) { - console.info(`enter callback doInit`); - let throwObject = {isThrow: false}; - try { - await initSession(keyAlias, huksOptions, throwObject) - .then ((data) => { - console.info(`callback: doInit success, data = ${JSON.stringify(data)}`); - handle = data.handle; - }) - .catch((error) => { - if (throwObject.isThrow) { - throw(error); - } else { - console.error(`callback: doInit failed, code: ${error.code}, msg: ${error.message}`); - } - }); - } catch (error) { - console.error(`callback: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); - } -} - -function updateSession(handle:number, huksOptions:huks.HuksOptions, throwObject) : Promise { - return new Promise((resolve, reject) => { - try { - huks.updateSession(handle, huksOptions, function (error, data) { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw(error); - } - }); -} - -async function publicUpdateFunc(handle:number, huksOptions:huks.HuksOptions) { - console.info(`enter callback doUpdate`); - let throwObject = {isThrow: false}; - try { - await updateSession(handle, huksOptions, throwObject) - .then ((data) => { - console.info(`callback: doUpdate success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - if (throwObject.isThrow) { - throw(error); - } else { - console.error(`callback: doUpdate failed, code: ${error.code}, msg: ${error.message}`); - } - }); - } catch (error) { - console.error(`callback: doUpdate input arg invalid, code: ${error.code}, msg: ${error.message}`); - } -} - -function finishSession(handle:number, huksOptions:huks.HuksOptions, throwObject) : Promise { - return new Promise((resolve, reject) => { - try { - huks.finishSession(handle, huksOptions, function (error, data) { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw(error); - } - }); -} - -async function publicFinishFunc(handle:number, huksOptions:huks.HuksOptions) { - console.info(`enter callback doFinish`); - let throwObject = {isThrow: false}; - try { - await finishSession(handle, huksOptions, throwObject) - .then ((data) => { - finishOutData = data.outData; - console.info(`callback: doFinish success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - if (throwObject.isThrow) { - throw(error); - } else { - console.error(`callback: doFinish failed, code: ${error.code}, msg: ${error.message}`); - } - }); - } catch (error) { - console.error(`callback: doFinish input arg invalid, code: ${error.code}, msg: ${error.message}`); - } -} - -function exportKeyItem(keyAlias:string, huksOptions:huks.HuksOptions, throwObject) : Promise { - return new Promise((resolve, reject) => { - try { - huks.exportKeyItem(keyAlias, huksOptions, function (error, data) { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw(error); - } - }); -} - -async function publicExportKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { - console.info(`enter callback export`); - let throwObject = {isThrow: false}; - try { - await exportKeyItem(keyAlias, huksOptions, throwObject) - .then ((data) => { - console.info(`callback: exportKeyItem success, data = ${JSON.stringify(data)}`); - exportKey = data.outData; - }) - .catch(error => { - if (throwObject.isThrow) { - throw(error); - } else { - console.error(`callback: exportKeyItem failed, code: ${error.code}, msg: ${error.message}`); - } - }); - } catch (error) { - console.error(`callback: exportKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - } -} - -function deleteKeyItem(keyAlias:string, huksOptions:huks.HuksOptions, throwObject) { - return new Promise((resolve, reject) => { - try { - huks.deleteKeyItem(keyAlias, huksOptions, function (error, data) { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - } catch (error) { - throwObject.isThrow = true; - throw(error); - } - }); -} - -async function publicDeleteKeyFunc(keyAlias:string, huksOptions:huks.HuksOptions) { - console.info(`enter callback deleteKeyItem`); - let throwObject = {isThrow: false}; - try { - await deleteKeyItem(keyAlias, huksOptions, throwObject) - .then ((data) => { - console.info(`callback: deleteKeyItem key success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - if (throwObject.isThrow) { - throw(error); - } else { - console.error(`callback: deleteKeyItem failed, code: ${error.code}, msg: ${error.message}`); - } - }); - } catch (error) { - console.error(`callback: deletKeeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - } -} - -async function testAgree() { - /* 1. Generate two keys and export them. */ - await publicGenKeyFunc(srcKeyAliasFirst, HuksOptions); - await publicGenKeyFunc(srcKeyAliasSecond, HuksOptions); - - await publicExportKeyFunc(srcKeyAliasFirst, HuksOptions); - exportKeyFrist = exportKey; - await publicExportKeyFunc(srcKeyAliasFirst, HuksOptions); - exportKeySecond = exportKey; - - /* Perform key agreement for the first. */ - await publicInitFunc(srcKeyAliasFirst, HuksOptions); - HuksOptions.inData = exportKeySecond; - await publicUpdateFunc(handle, HuksOptions); - await publicFinishFunc(handle, finishOptionsFrist); - - /* Perform key agreement for the second key. */ - await publicInitFunc(srcKeyAliasSecond, HuksOptions); - HuksOptions.inData = exportKeyFrist; - await publicUpdateFunc(handle, HuksOptions); - await publicFinishFunc(handle, finishOptionsSecond); - - await publicDeleteKeyFunc(srcKeyAliasFirst, HuksOptions); - await publicDeleteKeyFunc(srcKeyAliasSecond, HuksOptions); -} -``` - -### Key Derivation -```ts -/* - * The following uses the Promise() operation of an HKDF256 key as an example. - */ -import huks from '@ohos.security.huks'; - -/* - * Determine the key alias and encapsulate the key attributes. - */ -let srcKeyAlias = "hkdf_Key"; -let deriveHkdfInData = "deriveHkdfTestIndata"; -let handle; -let finishOutData; -let HuksKeyDeriveKeySize = 32; - -/* Configure the parameter set used for generating the key. */ -let properties = new Array(); -properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, -} -properties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, -} -properties[2] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256, + value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256, } properties[3] = { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, @@ -2060,7 +1650,7 @@ The HUKS also restricts the key usage. For example, the AES keys can only be use When generating or importing a key, you can enable user identity authentication for the key use. You can specify a subset of credentials (lock screen password, fingerprint, and face) for user identity authentication. After a key is generated or imported, unauthorized key access can be prevented even if the application process is attacked. Key access control applies to security-sensitive scenarios, such as password-free login, password-free payment, and automatic password filling. -In addition to user identity authentication, the HUKS provides the following modes ([HuksAuthAccessType](../reference/apis/js-apis-huks.md#huksauthaccesstype9)) for automatically invalidating a key: +In addition to user identity authentication, the HUKS provides the following modes for automatically invalidating a key: - Invalidate the key when the screen lock password is cleared.
This mode takes effect only when a screen lock password has been set. If the screen lock password is cleared, the key becomes invalid permanently. The key will not be invalidated if the screen lock password is modified. This mode applies to user-related data protection and access based on screen lock passwords. - Invalidate the key when new biometric enrollments are added.
This mode takes effect only when at least one biometric feature (such as fingerprint) has been enrolled. The key becomes invalid permanently once a new biometric feature is enrolled. The key will not be invalidated if the biometric feature is deleted. This mode applies to scenarios, such as password-free login or payment. @@ -2074,24 +1664,23 @@ If secondary user identity authentication is enabled for a key, initialize the k **Available APIs** -When a key is generated or imported, [HuksUserAuthType](../reference/apis/js-apis-huks.md#huksuserauthtype9), [HuksAuthAccessType](../reference/apis/js-apis-huks.md#huksauthaccesstype9), and [HuksChallengeType](../reference/apis/js-apis-huks.md#hukschallengetype9) in the key attributes are mandatory. +When a key is generated or imported, [HuksUserAuthType](../reference/apis/js-apis-huks.md#huksuserauthtype9), [HuksAuthAccessType](../reference/apis/js-apis-huks.md#huksauthaccesstype9), and [HuksChallengeType](../reference/apis/js-apis-huks.md#hukschallengetype9) in the key properties are mandatory. **Table 3** User authentication types | Name | Value | Description | | ------------------------------- |---|------------------------ | | HUKS_USER_AUTH_TYPE_FINGERPRINT |0x0001 | Fingerprint authentication.
Fingerprint authentication, facial authentication, and PIN authentication can be enabled at the same time. | -| HUKS_USER_AUTH_TYPE_FACE |0x0002 | Facial authentication.
Fingerprint authentication, facial authentication, and PIN authentication can be enabled at the same time. | -| HUKS_USER_AUTH_TYPE_PIN |0x0004 | PIN authentication.
Fingerprint authentication, facial authentication, and PIN authentication can be enabled at the same time. | +| HUKS_USER_AUTH_TYPE_FACE |0x0002 | Facial authentication.
Fingerprint authentication, facial authentication, and PIN authentication can be enabled at the same time.| +| HUKS_USER_AUTH_TYPE_PIN |0x0004 | PIN authentication.
Fingerprint authentication, facial authentication, and PIN authentication can be enabled at the same time.| **Table 4** Secure access types | Name | Value | Description | | --------------------------------------- | ---- | ------------------------------------------------ | | HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD | 1 | Invalidate the key after the screen lock password is cleared. | -| HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL | 2 | Invalidate the key after a biometric enrollment is added. The user authentication types must include the biometric authentication. | +| HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL | 2 | Invalidate the key after a biometric enrollment is added. The user authentication types must include the biometric authentication.| **Table 5** Challenge types - | Name | Value | Description | | ------------------------------- | ---- | ------------------------------ | | HUKS_CHALLENGE_TYPE_NORMAL | 0 | Normal challenge, which requires an independent user authentication for each use of the key.| @@ -2103,13 +1692,15 @@ When a key is generated or imported, [HuksUserAuthType](../reference/apis/js-api > - The three challenge types are mutually exclusive. > - If the challenge type is **HUKS_CHALLENGE_TYPE_NONE**, no challenge is required. However, the key can be accessed within a specified time period (set by **HUKS_TAG_AUTH_TIMEOUT**) after a successful authentication. The maximum value of **HUKS_TAG_AUTH_TIMEOUT** is 60 seconds. -To use a key, initialize the key session and determine whether a challenge is required based on the challenge type specified when the key is generated or imported. + +To use a key, initialize the key session, and determine whether a challenge is required based on the challenge type specified when the key is generated or imported. + **Table 6** APIs for using a key | API | Description | | -------------------------------------- | ----------------------------| -|initSession(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void| Initializes a key session and obtains the challenge. | +|initSession(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void| Initializes the key session and obtains the challenge.| |updateSession(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback\) : void| Operates data by segment and passes the authentication token.| |finishSession(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback\) : void| Finalizes the key session operation. | @@ -2117,12 +1708,12 @@ To use a key, initialize the key session and determine whether a challenge is re **How to Develop** -1. Generate a key and specify user authentication attributes. +1. Generate a key and specify user authentication properties. ```ts import huks from '@ohos.security.huks'; /* - * Determine the key alias and encapsulate the key attributes. + * Determine the key alias and encapsulate the key properties. */ let keyAlias = 'dh_key_fingerprint_access'; let properties = new Array(); @@ -2218,7 +1809,7 @@ import huks from '@ohos.security.huks'; import userIAM_userAuth from '@ohos.userIAM.userAuth'; /* - * Determine the key alias and encapsulate the key attributes. + * Determine the key alias and encapsulate the key properties. */ let srcKeyAlias = 'sm4_key_fingerprint_access'; let handle; @@ -2341,7 +1932,7 @@ async function testInitAndAuthFinger() { import huks from '@ohos.security.huks'; /* - * Determine the key alias and encapsulate the key attributes. + * Determine the key alias and encapsulate the key properties. */ let srcKeyAlias = 'sm4_key_fingerprint_access'; let IV = '1234567890123456'; @@ -2487,7 +2078,7 @@ async function testSm4Cipher() { The HUKS provides attestation for the public keys of asymmetric key pairs. The HUKS can issue a certificate for the public key of an asymmetric key pair stored in the HUKS using the public key infrastructure (PKI) certificate chain technology. The certificate can prove the validity of the public key. The service can use the root CA certificate provided by the OpenHarmony to verify the key certificate issued by the HUKS level by level to ensure that the public key and private key in the certificate are from a trusted hardware device and stored in the HUKS. **How to Develop** -1. Pass in the key alias and the attribute tag of the key to be attested. +1. Pass in the key alias and the property tag of the key to be attested. 2. Call a HUKS API to generate an X.509 certificate chain, which consists of the root CA certificate, device CA certificate, device certificate, and key certificate in sequence, for the application. 3. Send the certificate chain to a trusted server. The server parses and verifies the validity of the certificate chain and whether a single certificate is revoked. @@ -2508,7 +2099,7 @@ The HUKS provides attestation for the public keys of asymmetric key pairs. The H import huks from '@ohos.security.huks'; /* - * Determine the key alias and encapsulate the key attributes. + * Determine the key alias and encapsulate the key properties. */ let keyAliasString = "key attest"; let aliasString = keyAliasString; diff --git a/en/application-dev/task-management/continuous-task-dev-guide.md b/en/application-dev/task-management/continuous-task-dev-guide.md index e48995f1fc48dd652a132b6b8f04dbaeac7a00c0..a5ba250e191fb5eaa9cb6cf1d7393b23f340ccb3 100644 --- a/en/application-dev/task-management/continuous-task-dev-guide.md +++ b/en/application-dev/task-management/continuous-task-dev-guide.md @@ -210,7 +210,7 @@ For details about the stage model, see [Stage Model Development Overview](../app } } - class MySequenceable { + class MyParcelable { num: number = 0; str: String = ""; @@ -219,23 +219,23 @@ For details about the stage model, see [Stage Model Development Overview](../app this.str = string; } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); return true; } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); return true; } } function sendMsgCallback(data) { console.info('BgTaskAbility funcCallBack is called ' + data) - let receivedData = new MySequenceable(0, "") - data.readSequenceable(receivedData) + let receivedData = new MyParcelable(0, "") + data.readParcelable(receivedData) console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`) // You can execute different methods based on the str value in the sequenceable data sent by the caller. if (receivedData.str === 'start_bgtask') { @@ -243,7 +243,7 @@ For details about the stage model, see [Stage Model Development Overview](../app } else if (receivedData.str === 'stop_bgtask') { stopContinuousTask(); } - return new MySequenceable(10, "Callee test"); + return new MyParcelable(10, "Callee test"); } export default class BgTaskAbility extends UIAbility { diff --git a/en/application-dev/telephony/telephony-call.md b/en/application-dev/telephony/telephony-call.md index bbef181efb128f47ee08fd84d5adb0fd1aa031b2..8fc44ed193a78137b73a29854e539494147b9bc2 100644 --- a/en/application-dev/telephony/telephony-call.md +++ b/en/application-dev/telephony/telephony-call.md @@ -43,7 +43,7 @@ The **observer** module provides the functions of subscribing to and unsubscribi ## How to Develop -### Making a Call by Using the **dial** API (Only for System Applications) +### Making a Call by Using the **dial** API (for System Applications Only) 1. Declare the required permission: **ohos.permission.PLACE_CALL**. This permission is of the **system\_basic** level. Before applying for the permission, ensure that the [basic principles for permission management](../security/accesstoken-overview.md#basic-principles-for-permission-management) are met. Then, declare the corresponding permission by following instructions in [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file). diff --git a/en/application-dev/ui/Readme-EN.md b/en/application-dev/ui/Readme-EN.md index afd987b1607c3a489c7d686e848e61330e4f7a1f..09b8c42877602d230810e9c299cd6a1ab8d73c41 100644 --- a/en/application-dev/ui/Readme-EN.md +++ b/en/application-dev/ui/Readme-EN.md @@ -1,7 +1,7 @@ # UI Development - [ArkUI Overview](arkui-overview.md) -- UI Development with ArkTS-based Declarative Development Paradigm +- ArkTS-based Declarative Development Paradigm - [Overview](ui-ts-overview.md) - [Declarative UI Development Guidelines](ui-ts-developing-intro.md) - Declarative UI Development Examples @@ -27,7 +27,7 @@ - [Custom Component Lifecycle Callbacks](ui-ts-custom-component-lifecycle-callbacks.md) - [Web Component Development](ui-ts-components-web.md) - [Recommendations for Improving Performance](ui-ts-performance-improvement-recommendation.md) -- UI Development with JavaScript-compatible Web-like Development Paradigm +- JavaScript-compatible Web-like Development Paradigm - [Overview](ui-js-overview.md) - Framework Overview - [File Organization](js-framework-file.md) diff --git a/en/application-dev/website.md b/en/application-dev/website.md index 321757c730d5dd0e1f59beb0d316838a3645bb3c..40a5c8bd53fb06344a61e98a421706cf9dd89038 100644 --- a/en/application-dev/website.md +++ b/en/application-dev/website.md @@ -12,7 +12,6 @@ - Application Package Structure - [Application Package Structure in Stage Model](quick-start/application-package-structure-stage.md) - [Application Package Structure in FA Model](quick-start/application-package-structure-fa.md) - - [HAR File Structure](quick-start/har-structure.md) - Multi-HAP Mechanism - [Multi-HAP Design Objectives](quick-start/multi-hap-objective.md) - [Multi-HAP Build View](quick-start/multi-hap-build-view.md) @@ -60,9 +59,10 @@ - ExtensionAbility Component - [ExtensionAbility Component Overview](application-models/extensionability-overview.md) - [ServiceExtensionAbility](application-models/serviceextensionability.md) - - [DataShareExtensionAbility (System Applications Only)](application-models/datashareextensionability.md) + - [DataShareExtensionAbility (for System Applications Only)](application-models/datashareextensionability.md) - [FormExtensionAbility (Widget)](application-models/widget-development-stage.md) - [AccessibilityExtensionAbility](application-models/accessibilityextensionability.md) + - [InputMethodExtensionAbility](application-models/inputmethodextentionability.md) - [WindowExtensionAbility](application-models/windowextensionability.md) - [AbilityStage Component Container](application-models/abilitystage.md) - [Context](application-models/application-context-stage.md) @@ -76,8 +76,8 @@ - [Component Startup Rules (Stage Model)](application-models/component-startup-rules.md) - Inter-Device Application Component Interaction (Continuation) - [Continuation Overview](application-models/inter-device-interaction-hop-overview.md) - - [Cross-Device Migration (System Applications Only)](application-models/hop-cross-device-migration.md) - - [Multi-device Collaboration (System Applications Only)](application-models/hop-multi-device-collaboration.md) + - [Cross-Device Migration (for System Applications Only)](application-models/hop-cross-device-migration.md) + - [Multi-device Collaboration (for System Applications Only)](application-models/hop-multi-device-collaboration.md) - IPC - [Process Model](application-models/process-model-stage.md) - Common Events @@ -106,7 +106,7 @@ - [Creating a PageAbility](application-models/create-pageability.md) - [Starting a Local PageAbility](application-models/start-local-pageability.md) - [Stopping a PageAbility](application-models/stop-pageability.md) - - [Starting a Remote PageAbility (System Applications Only)](application-models/start-remote-pageability.md) + - [Starting a Remote PageAbility (for System Applications Only)](application-models/start-remote-pageability.md) - [Starting a Specified Page](application-models/start-page.md) - [Window Properties](application-models/window-properties.md) - [Requesting Permissions](application-models/request-permissions.md) @@ -272,7 +272,7 @@ - [Custom Components](ui/ui-js-custom-components.md) - Notification - [Notification Overview](notification/notification-overview.md) - - [Notification Subscription (System Applications Only)](notification/notification-subscription.md) + - [Notification Subscription (for System Applications Only)](notification/notification-subscription.md) - [Enabling Notification](notification/notification-enable.md) - Publishing a Notification - [Publishing a Basic Notification](notification/text-notification.md) @@ -299,10 +299,10 @@ - [Audio Routing and Device Management Development](media/audio-routing-manager.md) - [AVPlayer Development (Recommended)](media/avplayer-playback.md) - [AVRecorder Development (Recommended)](media/avrecorder.md) - - [Audio Playback Development (To Be Deprecated)](media/audio-playback.md) - - [Audio Recording Development (To Be Deprecated)](media/audio-recorder.md) - - [Video Playback Development (To Be Deprecated)](media/video-playback.md) - - [Video Recording Development (To Be Deprecated)](media/video-recorder.md) + - [Audio Playback Development (To Be Deprecated Soon)](media/audio-playback.md) + - [Audio Recording Development (To Be Deprecated Soon)](media/audio-recorder.md) + - [Video Playback Development (To Be Deprecated Soon)](media/video-playback.md) + - [Video Recording Development (To Be Deprecated Soon)](media/video-recorder.md) - AVSession - [AVSession Overview](media/avsession-overview.md) - [AVSession Development](media/avsession-guidelines.md) @@ -347,7 +347,7 @@ - [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 - [Telephony Service Overview](telephony/telephony-overview.md) - [Call Service Development](telephony/telephony-call.md) - [SMS Service Development](telephony/telephony-sms.md) @@ -376,8 +376,8 @@ - File Access Framework - [File Access Framework Overview](file-management/file-access-framework-overview.md) - [FilePicker Guide](file-management/filepicker-guidelines.md) - - Task Management - - Background Task Management + - Background Task Management + - Background Task - [Background Task Management Overview](task-management/background-task-overview.md) - [Transient Task Development](task-management/transient-task-dev-guide.md) - [Continuous Task Development](task-management/continuous-task-dev-guide.md) @@ -387,7 +387,7 @@ - Agent-Powered Reminder - [Agent-Powered Reminder Overview](task-management/reminder-agent-overview.md) - [Agent-Powered Reminder Development](task-management/reminder-agent-development.md) - - Device + - Device Management - USB Service - [USB Service Overview](device/usb-overview.md) - [USB Service Development](device/usb-guidelines.md) @@ -879,6 +879,20 @@ - [@ohos.notification (Notification) (To Be Deprecated Soon)](reference/apis/js-apis-notification.md) - application - [EventHub](reference/apis/js-apis-inner-application-eventHub.md) + - commonEvent + - [CommonEventData](reference/apis/js-apis-inner-commonEvent-commonEventData.md) + - [CommonEventPublishData](reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md) + - [CommonEventSubscriber](reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md) + - [CommonEventSubscribeInfo](reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md) + - notification + - [NotificationActionButton](reference/apis/js-apis-inner-notification-notificationActionButton.md) + - [NotificationCommonDef](reference/apis/js-apis-inner-notification-notificationCommonDef.md) + - [NotificationContent](reference/apis/js-apis-inner-notification-notificationContent.md) + - [NotificationFlags](reference/apis/js-apis-inner-notification-notificationFlags.md) + - [NotificationRequest](reference/apis/js-apis-inner-notification-notificationRequest.md) + - [NotificationSlot](reference/apis/js-apis-inner-notification-notificationSlot.md) + - [NotificationTemplate](reference/apis/js-apis-inner-notification-notificationTemplate.md) + - [NotificationUserInput](reference/apis/js-apis-inner-notification-notificationUserInput.md) - Bundle Management - [@ohos.bundle.appControl(appControl)](reference/apis/js-apis-appControl.md) - [@ohos.bundle.bundleManager (bundleManager)](reference/apis/js-apis-bundleManager.md) @@ -922,17 +936,17 @@ - webgl - [WebGL](reference/apis/js-apis-webgl.md) - [WebGL2](reference/apis/js-apis-webgl2.md) - - Media + - Multimedia - [@ohos.multimedia.audio (Audio Management)](reference/apis/js-apis-audio.md) - [@ohos.multimedia.avsession (AVSession Management)](reference/apis/js-apis-avsession.md) - [@ohos.multimedia.camera (Camera Management)](reference/apis/js-apis-camera.md) - [@ohos.multimedia.image (Image Processing)](reference/apis/js-apis-image.md) - [@ohos.multimedia.media (Media)](reference/apis/js-apis-media.md) - - Resource Management + - Resource Manager - [@ohos.i18n (Internationalization)](reference/apis/js-apis-i18n.md) - [@ohos.intl (Internationalization)](reference/apis/js-apis-intl.md) - [@ohos.resourceManager (Resource Manager)](reference/apis/js-apis-resource-manager.md) - - Resource Scheduling + - Background Task - [@ohos.distributedMissionManager (Distributed Mission Management)](reference/apis/js-apis-distributedMissionManager.md) - [@ohos.reminderAgentManager (Reminder Agent Management)](reference/apis/js-apis-reminderAgentManager.md) - [@ohos.resourceschedule.backgroundTaskManager (Background Task Management)](reference/apis/js-apis-resourceschedule-backgroundTaskManager.md) @@ -999,8 +1013,8 @@ - [@ohos.rpc (RPC)](reference/apis/js-apis-rpc.md) - [@ohos.wifiManager (WLAN)](reference/apis/js-apis-wifiManager.md) - [@ohos.wifiManagerExt (WLAN Extension)](reference/apis/js-apis-wifiManagerExt.md) - - [@ohos.wifi (To Be Deprecated)](reference/apis/js-apis-wifi.md) - - [@ohos.wifiext (To Be Deprecated)](reference/apis/js-apis-wifiext.md) + - [@ohos.wifi (To Be Deprecated Soon)](reference/apis/js-apis-wifi.md) + - [@ohos.wifiext (To Be Deprecated Soon)](reference/apis/js-apis-wifiext.md) - tag - [nfctech (Standard NFC Technologies)](reference/apis/js-apis-nfctech.md) - [tagSession (Standard NFC Tag Session)](reference/apis/js-apis-tagSession.md) @@ -1066,7 +1080,7 @@ - [@ohos.account.appAccount (App Account Management)](reference/apis/js-apis-appAccount.md) - [@ohos.account.distributedAccount (Distributed Account Management)](reference/apis/js-apis-distributed-account.md) - [@ohos.account.osAccount (OS Account Management)](reference/apis/js-apis-osAccount.md) - - Custom Management + - Customization - [@ohos.configPolicy (Configuration Policy)](reference/apis/js-apis-configPolicy.md) - [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](reference/apis/js-apis-EnterpriseAdminExtensionAbility.md) - [@ohos.enterprise.adminManager (Enterprise Device Management)](reference/apis/js-apis-enterprise-adminManager.md) @@ -1173,14 +1187,14 @@ - [colorSpaceManager Error Codes](reference/errorcodes/errorcode-colorspace-manager.md) - [Display Error Codes](reference/errorcodes/errorcode-display.md) - [Window Error Codes](reference/errorcodes/errorcode-window.md) - - Media + - Multimedia - [Audio Error Codes](reference/errorcodes/errorcode-audio.md) - [Media Error Codes](reference/errorcodes/errorcode-media.md) - [AVSession Management Error Codes](reference/errorcodes/errorcode-avsession.md) - - Resource Management + - Resource Manager - [I18N Error Codes](reference/errorcodes/errorcode-i18n.md) - [Resource Manager Error Codes](reference/errorcodes/errorcode-resource-manager.md) - - Resource Scheduling + - Background Task - [backgroundTaskManager Error Codes](reference/errorcodes/errorcode-backgroundTaskMgr.md) - [DeviceUsageStatistics Error Codes](reference/errorcodes/errorcode-DeviceUsageStatistics.md) - [reminderAgentManager Error Codes](reference/errorcodes/errorcode-reminderAgentManager.md) @@ -1232,7 +1246,7 @@ - [System Parameter Error Codes](reference/errorcodes/errorcode-system-parameterV9.md) - [USB Error Codes](reference/errorcodes/errorcode-usb.md) - [Update Error Codes](reference/errorcodes/errorcode-update.md) - - Customization Management + - Customization - [Enterprise Device Management Error Codes](reference/errorcodes/errorcode-enterpriseDeviceManager.md) - Language Base Class Library - [Utils Error Codes](reference/errorcodes/errorcode-utils.md) diff --git a/en/device-dev/faqs/faqs-burning.md b/en/device-dev/faqs/faqs-burning.md index 09f3a076e11ad20c3a539746954c3a7221bb62fa..2390fcde0049a6d96f58ae4f25b3ab6599e6233f 100644 --- a/en/device-dev/faqs/faqs-burning.md +++ b/en/device-dev/faqs/faqs-burning.md @@ -4,44 +4,45 @@ ## Mini and Small Systems -### "Error: Opening COMxx: Access denied" Displayed When I Start Burning +### "Error: Opening COMxx: Access denied" Is Displayed When I Start Burning - **Symptom** - + After I click **Burn** and select a serial port, **Error: Opening COMxx: Access denied** is displayed. **Figure 1** Access denied error ![failed-to-open-the-serial-port](figures/failed-to-open-the-serial-port.png) -- **Possible Causes** +- **Possible Causes** + The serial port is in use. - **Solution** 1. Search for the terminal using serial-xx from the drop-down list in the **TERMINAL** panel. - + **Figure 2** Checking whether the serial port is in use - - ![en-us_image_0000001243481989](figures/en-us_image_0000001243481989.png) + ![en-us_image_0000001243481989](figures/en-us_image_0000001243481989.png) + 2. Click the dustbin icon as shown below to disable the terminal using the serial port. - + **Figure 3** Disabling the terminal using the serial port - + ![en-us_image_0000001243082093](figures/en-us_image_0000001243082093.png) 3. Click **Burn**, select the serial port, and start burning images again. - + **Figure 4** Restarting the burning task - + ![en-us_image_0000001198322224](figures/en-us_image_0000001198322224.png) ### The Image Failed To Be Burnt - **Symptom** - + The image failed to be burnt over a serial port. - **Possible Causes** @@ -87,29 +88,28 @@ > > Hi3518E V300: **device\hisilicon\hispark_aries\sdk_liteos\uboot\out\boot\u-boot-hi3518ev300.bin** - 2. Burn the U-Boot file by following the procedures for burning a U-Boot file over USB. - Select the U-Boot files of the corresponding development board for burning by referring to [Burning an Image](../quick-start/quickstart-ide-3516-burn.md). + 2. Burn the U-Boot file. + + Select the U-Boot files of the corresponding development board for burning. For details, see [Burning an Image](../quick-start/quickstart-ide-3516-burn.md). - 3. Log in to the serial port after the burning is complete. + 3. Log in to the serial port after the burning is complete. - **Figure 5** Information displayed through the serial port after the U-Boot file is burnt + **Figure 5** Information displayed through the serial port after the U-Boot file is burnt - ![en-us_image_0000001243484907](figures/en-us_image_0000001243484907.png) + ![en-us_image_0000001243484907](figures/en-us_image_0000001243484907.png) ### Windows-based PC Failed to Be Connected to the Board - **Symptom** - The file image cannot be obtained after clicking **Burn** and selecting a serial port. **Figure 6** Failed to obtain the file image due to network disconnection - + ![en-us_image_0000001198322428](figures/en-us_image_0000001198322428.png) - **Possible Causes** - The board is disconnected from the Windows-based PC. @@ -117,23 +117,55 @@ - **Solution** - 1. Check whether the network cable is properly connected. - 2. Click **Windows Firewall**. + 1. Make sure the network cable is properly connected. - **Figure 7** Setting the firewall + 2. Click **Windows Firewall**. + + **Figure 7** Setting the firewall + ![en-us_image_0000001198162584](figures/en-us_image_0000001198162584.png) 3. Click **Firewall & network protection**. On the displayed page, click **Allow an app through the firewall**. - + **Figure 8** Firewall & network protection + ![en-us_image_0000001198323146](figures/en-us_image_0000001198323146.png) 4. Select Visual Studio Code. - + **Figure 9** Selecting Visual Studio Code + ![en-us_image_0000001198003232](figures/en-us_image_0000001198003232.png) 5. Select the **Private** and **Public** network access rights for Visual Studio Code. - + **Figure 10** Allowing Visual Studio Code to access the network - ![en-us_image_0000001243084579](figures/en-us_image_0000001243084579.png) \ No newline at end of file + + ![en-us_image_0000001243084579](figures/en-us_image_0000001243084579.png) + +### The Development Board Failed to Be Identified by the Burning Tool + +- **Symptom** + + During image burning, the burning tool displays a message indicating that no device is found. + +- **Possible Causes** + + The cable between the Windows computer and the development board is not connected. (The cable required varies. In this example, the USB cable is used.) + + The driver corresponding to the cable between the Windows computer and the development board is not installed. + +- **Solution** + + 1. Make sure the cable between the Windows computer and the development board is connected. + + 2. Open Device Manager in Windows. + + 3. Open the Universal Serial Bus controllers list. + + 4. Check whether the USB device driver has been installed. If an alarm is displayed, the driver has not been installed. + + 5. Depending on the Windows environment, install the desired USB device driver, such as FT23R USB UART Driver. Then try again. + + 6. If any other issue occurs, consult the relevant FAQ entry. + diff --git a/en/device-dev/get-code/figure/customizing-bundles.png b/en/device-dev/get-code/figures/customizing-bundles.png similarity index 100% rename from en/device-dev/get-code/figure/customizing-bundles.png rename to en/device-dev/get-code/figures/customizing-bundles.png diff --git a/en/device-dev/get-code/figure/example-distribution.png b/en/device-dev/get-code/figures/example-distribution.png similarity index 100% rename from en/device-dev/get-code/figure/example-distribution.png rename to en/device-dev/get-code/figures/example-distribution.png diff --git a/en/device-dev/get-code/figure/hpm-page.png b/en/device-dev/get-code/figures/hpm-page.png similarity index 100% rename from en/device-dev/get-code/figure/hpm-page.png rename to en/device-dev/get-code/figures/hpm-page.png diff --git a/en/device-dev/get-code/figure/setting-page.png b/en/device-dev/get-code/figures/setting-page.png similarity index 100% rename from en/device-dev/get-code/figure/setting-page.png rename to en/device-dev/get-code/figures/setting-page.png diff --git a/en/device-dev/get-code/gettools-acquire.md b/en/device-dev/get-code/gettools-acquire.md index a3025ebd834424ff319aa25f3194609ead2cf1e9..6923c4ea21b71cfbeb1a788e19fde9e7096ffdd8 100644 --- a/en/device-dev/get-code/gettools-acquire.md +++ b/en/device-dev/get-code/gettools-acquire.md @@ -74,6 +74,7 @@ Before using the Docker environment, perform the following operations: > > You do not need to obtain the source code for the HPM-based Docker environment. +3. Perform subsequent operations as a user who has the root permission or has been granted the permission to use Docker. ## Standalone Docker Environment @@ -113,7 +114,7 @@ hb set ``` **Figure 1** Setting page -![](figure/setting-page.png "setting-page") +![](figures/setting-page.png "setting-page") > **NOTE**
> The mapping between the development board and the building GUI: diff --git a/en/device-dev/get-code/sourcecode-acquire.md b/en/device-dev/get-code/sourcecode-acquire.md index 6e6cf7aec20779e57b7dd0607d6ae8f16295d04b..109210ddca1b8bb0c1b99fc7c38bfd68a08e8ea1 100644 --- a/en/device-dev/get-code/sourcecode-acquire.md +++ b/en/device-dev/get-code/sourcecode-acquire.md @@ -138,7 +138,7 @@ You must install **Node.js** and HPM on your local PC. The installation procedur 4. Find your desired distribution and click it to view details. **Figure 1** HPM page - ![](figure/hpm-page.png "hpm-page") + ![](figures/hpm-page.png "hpm-page") 2. Learn more about the distribution. @@ -147,7 +147,7 @@ You must install **Node.js** and HPM on your local PC. The installation procedur 3. Click **Custom** if you want to add or delete bundles of the distribution. **Figure 2** Example distribution - ![](figure/example-distribution.png "example-distribution") + ![](figures/example-distribution.png "example-distribution") 3. Customize bundles. 1. Access the **Custom solution** page, as shown in the following figure. @@ -156,7 +156,7 @@ You must install **Node.js** and HPM on your local PC. The installation procedur 4. Click **Download**. The system generates the OpenHarmony code structure file \(for example, **my\_cust\_dist.zip**\) and saves it to your local PC. **Figure 3** Customizing bundles - ![](figure/customizing-bundles.png "customizing-bundles") + ![](figures/customizing-bundles.png "customizing-bundles") 4. Install bundles. 1. Decompress the downloaded code structure file using CMD on Windows (or shell in Linux). diff --git a/en/device-dev/porting/porting-stm32mp15xx-on-smallsystem.md b/en/device-dev/porting/porting-stm32mp15xx-on-smallsystem.md index 76820392c8015b557111e0986a82b32579c7e3e3..0bb8a5f39c772167420b88639299f066088f1457 100644 --- a/en/device-dev/porting/porting-stm32mp15xx-on-smallsystem.md +++ b/en/device-dev/porting/porting-stm32mp15xx-on-smallsystem.md @@ -443,7 +443,7 @@ To adapt `OpenHarmony` subsystems, you only need to add related subsystems and c #### Startup Subsystem Adaptation -For the startup subsystem, adapt the `bootstrap_lite`, `syspara_lite`, `appspawn_lite`, and `init_lite` components. Add the corresponding configuration items to the `vendor/bearpi/bearpi_hm_micro/config.json` file, as shown below: +For the startup subsystem, adapt the `bootstrap_lite`, `syspara_lite`, `appspawn_lite`, and `init` components. Add the corresponding configuration items to the `vendor/bearpi/bearpi_hm_micro/config.json` file, as shown below: ``` { @@ -452,7 +452,7 @@ For the startup subsystem, adapt the `bootstrap_lite`, `syspara_lite`, `appspawn { "component": "syspara_lite", "features":[] }, { "component": "bootstrap_lite", "features":[] }, { "component": "appspawn_lite", "features":[] }, - { "component": "init_lite", "features":[] } + { "component": "init", "features":[] } ] }, ``` diff --git a/en/device-dev/security/figure/consent-withdrawal-1.png b/en/device-dev/security/figures/consent-withdrawal-1.png similarity index 100% rename from en/device-dev/security/figure/consent-withdrawal-1.png rename to en/device-dev/security/figures/consent-withdrawal-1.png diff --git a/en/device-dev/security/figure/consent-withdrawal-2.png b/en/device-dev/security/figures/consent-withdrawal-2.png similarity index 100% rename from en/device-dev/security/figure/consent-withdrawal-2.png rename to en/device-dev/security/figures/consent-withdrawal-2.png diff --git a/en/device-dev/security/figure/how-an-iot-controller-and-an-iot-device-establish-a-trust-relationship.png b/en/device-dev/security/figures/how-an-iot-controller-and-an-iot-device-establish-a-trust-relationship.png similarity index 100% rename from en/device-dev/security/figure/how-an-iot-controller-and-an-iot-device-establish-a-trust-relationship.png rename to en/device-dev/security/figures/how-an-iot-controller-and-an-iot-device-establish-a-trust-relationship.png diff --git a/en/device-dev/security/figure/how-dac-works.png b/en/device-dev/security/figures/how-dac-works.png similarity index 100% rename from en/device-dev/security/figure/how-dac-works.png rename to en/device-dev/security/figures/how-dac-works.png diff --git a/en/device-dev/security/figure/huks-functions.png b/en/device-dev/security/figures/huks-functions.png similarity index 100% rename from en/device-dev/security/figure/huks-functions.png rename to en/device-dev/security/figures/huks-functions.png diff --git a/en/device-dev/security/figure/privacy-notice.png b/en/device-dev/security/figures/privacy-notice.png similarity index 100% rename from en/device-dev/security/figure/privacy-notice.png rename to en/device-dev/security/figures/privacy-notice.png diff --git a/en/device-dev/security/figure/privacy-statement-entry.png b/en/device-dev/security/figures/privacy-statement-entry.png similarity index 100% rename from en/device-dev/security/figure/privacy-statement-entry.png rename to en/device-dev/security/figures/privacy-statement-entry.png diff --git a/en/device-dev/security/figure/privacy-statement-update.png b/en/device-dev/security/figures/privacy-statement-update.png similarity index 100% rename from en/device-dev/security/figure/privacy-statement-update.png rename to en/device-dev/security/figures/privacy-statement-update.png diff --git a/en/device-dev/security/figure/privacy-statement.png b/en/device-dev/security/figures/privacy-statement.png similarity index 100% rename from en/device-dev/security/figure/privacy-statement.png rename to en/device-dev/security/figures/privacy-statement.png diff --git a/en/device-dev/security/figure/security-assurance-framework.png b/en/device-dev/security/figures/security-assurance-framework.png similarity index 100% rename from en/device-dev/security/figure/security-assurance-framework.png rename to en/device-dev/security/figures/security-assurance-framework.png diff --git a/en/device-dev/security/figure/sensitive-permission-request.png b/en/device-dev/security/figures/sensitive-permission-request.png similarity index 100% rename from en/device-dev/security/figure/sensitive-permission-request.png rename to en/device-dev/security/figures/sensitive-permission-request.png diff --git a/en/device-dev/security/security-guidelines-overall.md b/en/device-dev/security/security-guidelines-overall.md index d7d9d7009d76d0b1a12111f72ede57ce945a52c9..aa50fa7857627675431c38b16db37fb73425d9b6 100644 --- a/en/device-dev/security/security-guidelines-overall.md +++ b/en/device-dev/security/security-guidelines-overall.md @@ -9,7 +9,7 @@ This environment combines chip security and system security features with upper- **Figure 1** Security assurance -![](figure/security-assurance-framework.png) +![](figures/security-assurance-framework.png) ## Hardware Security @@ -74,7 +74,7 @@ For device with 128 KB to 128 MB of memory, the OpenHarmony lite kernel is recom **Figure 2** How DAC works -![](figure/how-dac-works.png) +![](figures/how-dac-works.png) - Capability mechanism @@ -103,7 +103,7 @@ OpenHarmony Universal KeyStore (HUKS) provides key and certificate management. F **Figure 3** HUKS functions -![](figure/huks-functions.png) +![](figures/huks-functions.png) The following algorithms are supported: @@ -145,7 +145,7 @@ To ensure secure transmit of user data between devices, a trust relationship and **Figure 4** Process of establishing a trust relationship between devices -![](figure/how-an-iot-controller-and-an-iot-device-establish-a-trust-relationship.png) +![](figures/how-an-iot-controller-and-an-iot-device-establish-a-trust-relationship.png) - IoT device interconnection security diff --git a/en/device-dev/security/security-privacy-protection.md b/en/device-dev/security/security-privacy-protection.md index 334f54d53554bd63054b2531de815f077db96e06..dc606109fc78e22d971a5e7b019e97cb589113cf 100644 --- a/en/device-dev/security/security-privacy-protection.md +++ b/en/device-dev/security/security-privacy-protection.md @@ -136,26 +136,26 @@ When collecting personal data, clearly and explicitly notify users of the data t **Figure 1** Examples of a privacy notice and a privacy statement - ![](figure/privacy-notice.png)![](figure/privacy-statement.png) + ![](figures/privacy-notice.png)![](figures/privacy-statement.png) - Personal data shall be collected for specified, explicit, and legitimate purposes and not further processed in a manner that is incompatible with those purposes. If the purposes are changed or a user withdraws their consent, you shall obtain user consent again before using the data. The figures below are examples of a privacy statement update and content withdrawal, respectively. **Figure 2** Example dialog showing a privacy statement update - ![](figure/privacy-statement-update.png) + ![](figures/privacy-statement-update.png) **Figure 3** Example dialog showing consent withdrawal - ![](figure/consent-withdrawal-1.png)![](figure/consent-withdrawal-2.png) + ![](figures/consent-withdrawal-1.png)![](figures/consent-withdrawal-2.png) - You shall provide an entry for users to view the privacy statement. For example, you can provide an entry on the **About** page of your application to view the privacy statement, as shown in the following figure. **Figure 4** Example of About page providing an entry to the privacy statement - ![](figure/privacy-statement-entry.png) + ![](figures/privacy-statement-entry.png) **Minimization in Data Collection and Use** @@ -179,7 +179,7 @@ You shall obtain consent from users and comply with applicable laws and regulati **Figure 5** Example dialog for requesting a sensitive permission - ![](figure/sensitive-permission-request.png) + ![](figures/sensitive-permission-request.png) - Users shall have the right to modify or withdraw the permissions granted to your product. When a user does not agree to a permission or data collection, the user shall be allowed to use the functions irrelevant to the permission or data collection. For example, the user can refuse to grant the camera permission to social or communication apps on Smart TVs, when using product functions irrelevant to the camera, such as voice calls. - In scenarios where personal data is recorded, users shall be provided with the functions of adding, deleting, modifying, and viewing personal data. diff --git a/en/device-dev/subsystems/Readme-EN.md b/en/device-dev/subsystems/Readme-EN.md index 580b86372075c5473c9f06a0b946a2c28f6b3d4c..3c97fc6d362ffb32a79bab32490658047cde7aad 100644 --- a/en/device-dev/subsystems/Readme-EN.md +++ b/en/device-dev/subsystems/Readme-EN.md @@ -109,3 +109,6 @@ - [bytrace](subsys-toolchain-bytrace-guide.md) - [hdc](subsys-toolchain-hdc-guide.md) - [hiperf](subsys-toolchain-hiperf.md) +- Power Management + - Display Management + - [System Brightness Customization](subsys-power-brightness-customization.md) diff --git a/en/device-dev/subsystems/figure/dfx-overview.png b/en/device-dev/subsystems/figure/dfx-overview.png new file mode 100644 index 0000000000000000000000000000000000000000..357d87edbaeaff0494573b2b7f35ba2af162ed26 Binary files /dev/null and b/en/device-dev/subsystems/figure/dfx-overview.png differ diff --git a/en/device-dev/subsystems/figure/20200721-223604(espace).gif b/en/device-dev/subsystems/figures/20200721-223604(espace).gif similarity index 100% rename from en/device-dev/subsystems/figure/20200721-223604(espace).gif rename to en/device-dev/subsystems/figures/20200721-223604(espace).gif diff --git a/en/device-dev/subsystems/figure/ABStartup_1.png b/en/device-dev/subsystems/figures/ABStartup_1.png similarity index 100% rename from en/device-dev/subsystems/figure/ABStartup_1.png rename to en/device-dev/subsystems/figures/ABStartup_1.png diff --git a/en/device-dev/subsystems/figure/ABStartup_2.png b/en/device-dev/subsystems/figures/ABStartup_2.png similarity index 100% rename from en/device-dev/subsystems/figure/ABStartup_2.png rename to en/device-dev/subsystems/figures/ABStartup_2.png diff --git a/en/device-dev/subsystems/figure/ABStartup_3.png b/en/device-dev/subsystems/figures/ABStartup_3.png similarity index 100% rename from en/device-dev/subsystems/figure/ABStartup_3.png rename to en/device-dev/subsystems/figures/ABStartup_3.png diff --git a/en/device-dev/subsystems/figure/ABStartup_4.png b/en/device-dev/subsystems/figures/ABStartup_4.png similarity index 100% rename from en/device-dev/subsystems/figure/ABStartup_4.png rename to en/device-dev/subsystems/figures/ABStartup_4.png diff --git a/en/device-dev/subsystems/figure/ABStartup_5.png b/en/device-dev/subsystems/figures/ABStartup_5.png similarity index 100% rename from en/device-dev/subsystems/figure/ABStartup_5.png rename to en/device-dev/subsystems/figures/ABStartup_5.png diff --git a/en/device-dev/subsystems/figure/ABStartup_6.png b/en/device-dev/subsystems/figures/ABStartup_6.png similarity index 100% rename from en/device-dev/subsystems/figure/ABStartup_6.png rename to en/device-dev/subsystems/figures/ABStartup_6.png diff --git a/en/device-dev/subsystems/figure/ABStartup_7.png b/en/device-dev/subsystems/figures/ABStartup_7.png similarity index 100% rename from en/device-dev/subsystems/figure/ABStartup_7.png rename to en/device-dev/subsystems/figures/ABStartup_7.png diff --git a/en/device-dev/subsystems/figure/ABStartup_8.png b/en/device-dev/subsystems/figures/ABStartup_8.png similarity index 100% rename from en/device-dev/subsystems/figure/ABStartup_8.png rename to en/device-dev/subsystems/figures/ABStartup_8.png diff --git a/en/device-dev/subsystems/figure/HUKS-CertChain.png b/en/device-dev/subsystems/figures/HUKS-CertChain.png similarity index 100% rename from en/device-dev/subsystems/figure/HUKS-CertChain.png rename to en/device-dev/subsystems/figures/HUKS-CertChain.png diff --git a/en/device-dev/subsystems/figure/HUKS-GenerateKey1.png b/en/device-dev/subsystems/figures/HUKS-GenerateKey1.png similarity index 100% rename from en/device-dev/subsystems/figure/HUKS-GenerateKey1.png rename to en/device-dev/subsystems/figures/HUKS-GenerateKey1.png diff --git a/en/device-dev/subsystems/figure/HUKS-KeyBlob.png b/en/device-dev/subsystems/figures/HUKS-KeyBlob.png similarity index 100% rename from en/device-dev/subsystems/figure/HUKS-KeyBlob.png rename to en/device-dev/subsystems/figures/HUKS-KeyBlob.png diff --git a/en/device-dev/subsystems/figure/HiTraceMeter.png b/en/device-dev/subsystems/figures/HiTraceMeter.png similarity index 100% rename from en/device-dev/subsystems/figure/HiTraceMeter.png rename to en/device-dev/subsystems/figures/HiTraceMeter.png diff --git a/en/device-dev/subsystems/figure/Hiview_module_data_interaction.png b/en/device-dev/subsystems/figures/Hiview_module_data_interaction.png similarity index 100% rename from en/device-dev/subsystems/figure/Hiview_module_data_interaction.png rename to en/device-dev/subsystems/figures/Hiview_module_data_interaction.png diff --git a/en/device-dev/subsystems/figure/Ninja_Trace.png b/en/device-dev/subsystems/figures/Ninja_Trace.png similarity index 100% rename from en/device-dev/subsystems/figure/Ninja_Trace.png rename to en/device-dev/subsystems/figures/Ninja_Trace.png diff --git a/en/device-dev/subsystems/figure/animator-effect.gif b/en/device-dev/subsystems/figures/animator-effect.gif similarity index 100% rename from en/device-dev/subsystems/figure/animator-effect.gif rename to en/device-dev/subsystems/figures/animator-effect.gif diff --git a/en/device-dev/subsystems/figure/application-startup-process.png b/en/device-dev/subsystems/figures/application-startup-process.png similarity index 100% rename from en/device-dev/subsystems/figure/application-startup-process.png rename to en/device-dev/subsystems/figures/application-startup-process.png diff --git a/en/device-dev/subsystems/figure/architecture-of-the-ability-management-framework.png b/en/device-dev/subsystems/figures/architecture-of-the-ability-management-framework.png similarity index 100% rename from en/device-dev/subsystems/figure/architecture-of-the-ability-management-framework.png rename to en/device-dev/subsystems/figures/architecture-of-the-ability-management-framework.png diff --git a/en/device-dev/subsystems/figure/architecture-of-the-bundle-management-framework.png b/en/device-dev/subsystems/figures/architecture-of-the-bundle-management-framework.png similarity index 100% rename from en/device-dev/subsystems/figure/architecture-of-the-bundle-management-framework.png rename to en/device-dev/subsystems/figures/architecture-of-the-bundle-management-framework.png diff --git a/en/device-dev/subsystems/figure/build_process.png b/en/device-dev/subsystems/figures/build_process.png similarity index 100% rename from en/device-dev/subsystems/figure/build_process.png rename to en/device-dev/subsystems/figures/build_process.png diff --git a/en/device-dev/subsystems/figure/call-chain-tracing-in-synchronous-communication.png b/en/device-dev/subsystems/figures/call-chain-tracing-in-synchronous-communication.png similarity index 100% rename from en/device-dev/subsystems/figure/call-chain-tracing-in-synchronous-communication.png rename to en/device-dev/subsystems/figures/call-chain-tracing-in-synchronous-communication.png diff --git a/en/device-dev/subsystems/figure/component-tree-structure.png b/en/device-dev/subsystems/figures/component-tree-structure.png similarity index 100% rename from en/device-dev/subsystems/figure/component-tree-structure.png rename to en/device-dev/subsystems/figures/component-tree-structure.png diff --git a/en/device-dev/subsystems/figure/context-structure-of-the-Startup-subsystem.png b/en/device-dev/subsystems/figures/context-structure-of-the-Startup-subsystem.png similarity index 100% rename from en/device-dev/subsystems/figure/context-structure-of-the-Startup-subsystem.png rename to en/device-dev/subsystems/figures/context-structure-of-the-Startup-subsystem.png diff --git a/en/device-dev/subsystems/figure/dac-definition.png b/en/device-dev/subsystems/figures/dac-definition.png similarity index 100% rename from en/device-dev/subsystems/figure/dac-definition.png rename to en/device-dev/subsystems/figures/dac-definition.png diff --git a/en/device-dev/subsystems/figure/dependency_types.png b/en/device-dev/subsystems/figures/dependency_types.png similarity index 100% rename from en/device-dev/subsystems/figure/dependency_types.png rename to en/device-dev/subsystems/figures/dependency_types.png diff --git a/en/device-dev/subsystems/figure/effect-of-adding-view-instances-to-a-viewgroup.png b/en/device-dev/subsystems/figures/effect-of-adding-view-instances-to-a-viewgroup.png similarity index 100% rename from en/device-dev/subsystems/figure/effect-of-adding-view-instances-to-a-viewgroup.png rename to en/device-dev/subsystems/figures/effect-of-adding-view-instances-to-a-viewgroup.png diff --git a/en/device-dev/subsystems/figure/effect-of-clicking-a-uibutton.gif b/en/device-dev/subsystems/figures/effect-of-clicking-a-uibutton.gif similarity index 100% rename from en/device-dev/subsystems/figure/effect-of-clicking-a-uibutton.gif rename to en/device-dev/subsystems/figures/effect-of-clicking-a-uibutton.gif diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001051782526.png b/en/device-dev/subsystems/figures/en-us_image_0000001051782526.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001051782526.png rename to en/device-dev/subsystems/figures/en-us_image_0000001051782526.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001052582522.png b/en/device-dev/subsystems/figures/en-us_image_0000001052582522.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001052582522.png rename to en/device-dev/subsystems/figures/en-us_image_0000001052582522.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001052662559.png b/en/device-dev/subsystems/figures/en-us_image_0000001052662559.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001052662559.png rename to en/device-dev/subsystems/figures/en-us_image_0000001052662559.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001052782555.png b/en/device-dev/subsystems/figures/en-us_image_0000001052782555.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001052782555.png rename to en/device-dev/subsystems/figures/en-us_image_0000001052782555.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001052942531.png b/en/device-dev/subsystems/figures/en-us_image_0000001052942531.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001052942531.png rename to en/device-dev/subsystems/figures/en-us_image_0000001052942531.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001053207924.gif b/en/device-dev/subsystems/figures/en-us_image_0000001053207924.gif similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001053207924.gif rename to en/device-dev/subsystems/figures/en-us_image_0000001053207924.gif diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001053247975.gif b/en/device-dev/subsystems/figures/en-us_image_0000001053247975.gif similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001053247975.gif rename to en/device-dev/subsystems/figures/en-us_image_0000001053247975.gif diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001054101094.png b/en/device-dev/subsystems/figures/en-us_image_0000001054101094.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001054101094.png rename to en/device-dev/subsystems/figures/en-us_image_0000001054101094.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001054421113.png b/en/device-dev/subsystems/figures/en-us_image_0000001054421113.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001054421113.png rename to en/device-dev/subsystems/figures/en-us_image_0000001054421113.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001062334618.png b/en/device-dev/subsystems/figures/en-us_image_0000001062334618.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001062334618.png rename to en/device-dev/subsystems/figures/en-us_image_0000001062334618.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001062476933.png b/en/device-dev/subsystems/figures/en-us_image_0000001062476933.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001062476933.png rename to en/device-dev/subsystems/figures/en-us_image_0000001062476933.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001062942690.png b/en/device-dev/subsystems/figures/en-us_image_0000001062942690.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001062942690.png rename to en/device-dev/subsystems/figures/en-us_image_0000001062942690.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001077724150.png b/en/device-dev/subsystems/figures/en-us_image_0000001077724150.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001077724150.png rename to en/device-dev/subsystems/figures/en-us_image_0000001077724150.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001115980740.png b/en/device-dev/subsystems/figures/en-us_image_0000001115980740.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001115980740.png rename to en/device-dev/subsystems/figures/en-us_image_0000001115980740.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001119924146.gif b/en/device-dev/subsystems/figures/en-us_image_0000001119924146.gif similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001119924146.gif rename to en/device-dev/subsystems/figures/en-us_image_0000001119924146.gif diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001151931738.jpg b/en/device-dev/subsystems/figures/en-us_image_0000001151931738.jpg similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001151931738.jpg rename to en/device-dev/subsystems/figures/en-us_image_0000001151931738.jpg diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001166643927.jpg b/en/device-dev/subsystems/figures/en-us_image_0000001166643927.jpg similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001166643927.jpg rename to en/device-dev/subsystems/figures/en-us_image_0000001166643927.jpg diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001171507146.png b/en/device-dev/subsystems/figures/en-us_image_0000001171507146.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001171507146.png rename to en/device-dev/subsystems/figures/en-us_image_0000001171507146.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001192123772.png b/en/device-dev/subsystems/figures/en-us_image_0000001192123772.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001192123772.png rename to en/device-dev/subsystems/figures/en-us_image_0000001192123772.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001200128073.png b/en/device-dev/subsystems/figures/en-us_image_0000001200128073.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001200128073.png rename to en/device-dev/subsystems/figures/en-us_image_0000001200128073.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001210683929.png b/en/device-dev/subsystems/figures/en-us_image_0000001210683929.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001210683929.png rename to en/device-dev/subsystems/figures/en-us_image_0000001210683929.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001214727595.png b/en/device-dev/subsystems/figures/en-us_image_0000001214727595.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001214727595.png rename to en/device-dev/subsystems/figures/en-us_image_0000001214727595.png diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001267088285.png b/en/device-dev/subsystems/figures/en-us_image_0000001267088285.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001267088285.png rename to en/device-dev/subsystems/figures/en-us_image_0000001267088285.png diff --git a/en/device-dev/subsystems/figure/error-information.png b/en/device-dev/subsystems/figures/error-information.png similarity index 100% rename from en/device-dev/subsystems/figure/error-information.png rename to en/device-dev/subsystems/figures/error-information.png diff --git a/en/device-dev/subsystems/figure/fig1.png b/en/device-dev/subsystems/figures/fig1.png similarity index 100% rename from en/device-dev/subsystems/figure/fig1.png rename to en/device-dev/subsystems/figures/fig1.png diff --git a/en/device-dev/subsystems/figure/image-auto-adaption-effect.png b/en/device-dev/subsystems/figures/image-auto-adaption-effect.png similarity index 100% rename from en/device-dev/subsystems/figure/image-auto-adaption-effect.png rename to en/device-dev/subsystems/figures/image-auto-adaption-effect.png diff --git a/en/device-dev/subsystems/figure/image-tile-effect.png b/en/device-dev/subsystems/figures/image-tile-effect.png similarity index 100% rename from en/device-dev/subsystems/figure/image-tile-effect.png rename to en/device-dev/subsystems/figures/image-tile-effect.png diff --git a/en/device-dev/subsystems/figure/kconfig_interface.png b/en/device-dev/subsystems/figures/kconfig_interface.png similarity index 100% rename from en/device-dev/subsystems/figure/kconfig_interface.png rename to en/device-dev/subsystems/figures/kconfig_interface.png diff --git a/en/device-dev/subsystems/figure/kconfig_save.png b/en/device-dev/subsystems/figures/kconfig_save.png similarity index 100% rename from en/device-dev/subsystems/figure/kconfig_save.png rename to en/device-dev/subsystems/figures/kconfig_save.png diff --git a/en/device-dev/subsystems/figure/kconfig_select_component.gif b/en/device-dev/subsystems/figures/kconfig_select_component.gif similarity index 100% rename from en/device-dev/subsystems/figure/kconfig_select_component.gif rename to en/device-dev/subsystems/figures/kconfig_select_component.gif diff --git a/en/device-dev/subsystems/figure/kconfig_set_parameters.gif b/en/device-dev/subsystems/figures/kconfig_set_parameters.gif similarity index 100% rename from en/device-dev/subsystems/figure/kconfig_set_parameters.gif rename to en/device-dev/subsystems/figures/kconfig_set_parameters.gif diff --git a/en/device-dev/subsystems/figure/module_addition_process.png b/en/device-dev/subsystems/figures/module_addition_process.png similarity index 100% rename from en/device-dev/subsystems/figure/module_addition_process.png rename to en/device-dev/subsystems/figures/module_addition_process.png diff --git a/en/device-dev/subsystems/figure/ohos_device_security_level.png b/en/device-dev/subsystems/figures/ohos_device_security_level.png similarity index 100% rename from en/device-dev/subsystems/figure/ohos_device_security_level.png rename to en/device-dev/subsystems/figures/ohos_device_security_level.png diff --git a/en/device-dev/subsystems/figure/ohos_system_security_architecture.png b/en/device-dev/subsystems/figures/ohos_system_security_architecture.png similarity index 100% rename from en/device-dev/subsystems/figure/ohos_system_security_architecture.png rename to en/device-dev/subsystems/figures/ohos_system_security_architecture.png diff --git a/en/device-dev/subsystems/figure/process_crash_handling.png b/en/device-dev/subsystems/figures/process_crash_handling.png similarity index 100% rename from en/device-dev/subsystems/figure/process_crash_handling.png rename to en/device-dev/subsystems/figures/process_crash_handling.png diff --git a/en/device-dev/subsystems/figure/product_subsystem_component_module_relationships.png b/en/device-dev/subsystems/figures/product_subsystem_component_module_relationships.png similarity index 100% rename from en/device-dev/subsystems/figure/product_subsystem_component_module_relationships.png rename to en/device-dev/subsystems/figures/product_subsystem_component_module_relationships.png diff --git a/en/device-dev/subsystems/figure/relationship-between-a-page-ability-and-its-ability-slices.png b/en/device-dev/subsystems/figures/relationship-between-a-page-ability-and-its-ability-slices.png similarity index 100% rename from en/device-dev/subsystems/figure/relationship-between-a-page-ability-and-its-ability-slices.png rename to en/device-dev/subsystems/figures/relationship-between-a-page-ability-and-its-ability-slices.png diff --git a/en/device-dev/subsystems/figure/scrolling-effect-in-both-horizontal-and-vertical-directions.gif b/en/device-dev/subsystems/figures/scrolling-effect-in-both-horizontal-and-vertical-directions.gif similarity index 100% rename from en/device-dev/subsystems/figure/scrolling-effect-in-both-horizontal-and-vertical-directions.gif rename to en/device-dev/subsystems/figures/scrolling-effect-in-both-horizontal-and-vertical-directions.gif diff --git a/en/device-dev/subsystems/figure/service-calling-process-(inter-device-and-inter-process-synchronous-call).png b/en/device-dev/subsystems/figures/service-calling-process-(inter-device-and-inter-process-synchronous-call).png similarity index 100% rename from en/device-dev/subsystems/figure/service-calling-process-(inter-device-and-inter-process-synchronous-call).png rename to en/device-dev/subsystems/figures/service-calling-process-(inter-device-and-inter-process-synchronous-call).png diff --git a/en/device-dev/subsystems/figure/service-calling-process.png b/en/device-dev/subsystems/figures/service-calling-process.png similarity index 100% rename from en/device-dev/subsystems/figure/service-calling-process.png rename to en/device-dev/subsystems/figures/service-calling-process.png diff --git a/en/device-dev/subsystems/figure/setting-a-2x2-grid-and-adding-four-buttons-in-a-layout.png b/en/device-dev/subsystems/figures/setting-a-2x2-grid-and-adding-four-buttons-in-a-layout.png similarity index 100% rename from en/device-dev/subsystems/figure/setting-a-2x2-grid-and-adding-four-buttons-in-a-layout.png rename to en/device-dev/subsystems/figures/setting-a-2x2-grid-and-adding-four-buttons-in-a-layout.png diff --git a/en/device-dev/subsystems/figure/startup-of-the-ability-manager-service-and-bundle-manager-service.png b/en/device-dev/subsystems/figures/startup-of-the-ability-manager-service-and-bundle-manager-service.png similarity index 100% rename from en/device-dev/subsystems/figure/startup-of-the-ability-manager-service-and-bundle-manager-service.png rename to en/device-dev/subsystems/figures/startup-of-the-ability-manager-service-and-bundle-manager-service.png diff --git a/en/device-dev/subsystems/figure/structure-of-a-signed-hap.png b/en/device-dev/subsystems/figures/structure-of-a-signed-hap.png similarity index 100% rename from en/device-dev/subsystems/figure/structure-of-a-signed-hap.png rename to en/device-dev/subsystems/figures/structure-of-a-signed-hap.png diff --git a/en/device-dev/subsystems/figure/structure-of-common-container-components.png b/en/device-dev/subsystems/figures/structure-of-common-container-components.png similarity index 100% rename from en/device-dev/subsystems/figure/structure-of-common-container-components.png rename to en/device-dev/subsystems/figures/structure-of-common-container-components.png diff --git a/en/device-dev/subsystems/figure/system-parameter-operation-primitives.png b/en/device-dev/subsystems/figures/system-parameter-operation-primitives.png similarity index 100% rename from en/device-dev/subsystems/figure/system-parameter-operation-primitives.png rename to en/device-dev/subsystems/figures/system-parameter-operation-primitives.png diff --git a/en/device-dev/subsystems/figure/time-delay-in-the-service-calling-process.png b/en/device-dev/subsystems/figures/time-delay-in-the-service-calling-process.png similarity index 100% rename from en/device-dev/subsystems/figure/time-delay-in-the-service-calling-process.png rename to en/device-dev/subsystems/figures/time-delay-in-the-service-calling-process.png diff --git a/en/device-dev/subsystems/figure/tree-structure-of-common-components.png b/en/device-dev/subsystems/figures/tree-structure-of-common-components.png similarity index 100% rename from en/device-dev/subsystems/figure/tree-structure-of-common-components.png rename to en/device-dev/subsystems/figures/tree-structure-of-common-components.png diff --git a/en/device-dev/subsystems/figure/use-cases-of-hitrace.png b/en/device-dev/subsystems/figures/use-cases-of-hitrace.png similarity index 100% rename from en/device-dev/subsystems/figure/use-cases-of-hitrace.png rename to en/device-dev/subsystems/figures/use-cases-of-hitrace.png diff --git a/en/device-dev/subsystems/subsys-ai-aiframework-devguide.md b/en/device-dev/subsystems/subsys-ai-aiframework-devguide.md index d1cca7c960f6e22ba52860f799b9fa3e2994338b..793db13e3a40f8ce542d4bafa17173b6e464f08c 100644 --- a/en/device-dev/subsystems/subsys-ai-aiframework-devguide.md +++ b/en/device-dev/subsystems/subsys-ai-aiframework-devguide.md @@ -13,7 +13,7 @@ Under this framework, AI algorithm APIs will be standardized to facilitate distr The following figure shows the AI engine framework. **Figure 1** AI engine framework - ![en-us_image_0000001200128073](figure/en-us_image_0000001200128073.png) + ![en-us_image_0000001200128073](figures/en-us_image_0000001200128073.png) ### Setting Up the Environment @@ -34,7 +34,7 @@ The following figure shows the code dependency between modules of the AI engine **Figure 2** Code dependency - ![en-us_image_0000001151931738](figure/en-us_image_0000001151931738.jpg) + ![en-us_image_0000001151931738](figures/en-us_image_0000001151931738.jpg) #### Recommendation: Develop plug-ins and SDKs in the directories specified by the AI engine. diff --git a/en/device-dev/subsystems/subsys-application-framework-guide.md b/en/device-dev/subsystems/subsys-application-framework-guide.md index 508677cb988fad38d7858583010b70e51b65dd3b..3d2bea63d2f55410aff3cdc69d271c43ed68f942 100644 --- a/en/device-dev/subsystems/subsys-application-framework-guide.md +++ b/en/device-dev/subsystems/subsys-application-framework-guide.md @@ -683,15 +683,15 @@ The packing tool is generally integrated into the development tool or IDE, and y - Example HAP File Structure - Development view - ![](figure/en-us_image_0000001062942690.png) + ![](figures/en-us_image_0000001062942690.png) - Compilation view - ![](figure/en-us_image_0000001062334618.png) + ![](figures/en-us_image_0000001062334618.png) - Run the following commands to pack a HAP file using the packing tool. - ![](figure/en-us_image_0000001062476933.png) + ![](figures/en-us_image_0000001062476933.png) ``` $ java -jar hmos_app_packing_tool.jar --mode hap --json-path ./config.json --assets-path ./assets/ --ability-so-path ./libentry.so --index-path ./resources.index --out-path out/entry.hap --force true diff --git a/en/device-dev/subsystems/subsys-application-framework-overview.md b/en/device-dev/subsystems/subsys-application-framework-overview.md index 601e65a26fddc9a4a01cec37297a0157a388eab1..4c3aacae9354e3595f5a30544a0c5efdd917ebca 100644 --- a/en/device-dev/subsystems/subsys-application-framework-overview.md +++ b/en/device-dev/subsystems/subsys-application-framework-overview.md @@ -11,7 +11,7 @@ This section describes some basic concepts for you to better understand the Open The ability management framework manages running status of OpenHarmony applications. **Figure 1** Architecture of the ability management framework -![](figure/architecture-of-the-ability-management-framework.png "architecture-of-the-ability-management-framework") +![](figures/architecture-of-the-ability-management-framework.png "architecture-of-the-ability-management-framework") - **Ability** is the minimum unit for the system to schedule applications. It is a component that can implement an independent functionality. An application can contain one or more **Ability** instances. There are two types of templates that you can use to create an **Ability** instance: Page and Service. - An **Ability using the Page template** \(Page ability for short\) provides a UI for interacting with users. @@ -23,14 +23,14 @@ The ability management framework manages running status of OpenHarmony applicati - An **AbilitySlice** represents a single screen and its control logic. It is specific to Page abilities. A Page ability may contain one ability slice or multiple ability slices that provide highly relevant capabilities. **Figure 2** Relationship between a Page ability and its ability slices - ![](figure/relationship-between-a-page-ability-and-its-ability-slices.png "relationship-between-a-page-ability-and-its-ability-slices") + ![](figures/relationship-between-a-page-ability-and-its-ability-slices.png "relationship-between-a-page-ability-and-its-ability-slices") - **Lifecycle** is a general term for all states of an ability, including **INITIAL**, **INACTIVE**, **ACTIVE**, and **BACKGROUND**. **Figure 3** Lifecycle state transition of a Page ability - ![](figure/fig1.png) + ![](figures/fig1.png) - **OnStart\(\)** @@ -88,7 +88,7 @@ The ability management framework manages running status of OpenHarmony applicati The bundle management framework is provided by OpenHarmony for you to manage application bundles. **Figure 4** Architecture of the bundle management framework -![](figure/architecture-of-the-bundle-management-framework.png "architecture-of-the-bundle-management-framework") +![](figures/architecture-of-the-bundle-management-framework.png "architecture-of-the-bundle-management-framework") - **BundleKit** includes external APIs provided by the Bundle Manager Service, including the APIs for application installation and uninstallation, bundle information query, and bundle state change listeners. - The **bundle scanning sub-module** parses pre-installed or installed bundles on the local device and extracts information from them for the bundle management module to manage and make the information persistent for storage. @@ -104,12 +104,12 @@ The bundle management framework is provided by OpenHarmony for you to manage app The Ability Manager Service and Bundle Manager Service are the core modules of the ability management framework and bundle management framework, respectively. The two system-level services are registered and discovered by using the system service framework SAMgr, and they are used by manage abilities and bundles for other processes. The Ability Manager Service and Bundle Manager Service are provided as open APIs in the AbilityKit and BundleKit. **Figure 5** Startup of the Ability Manager Service and Bundle Manager Service -![](figure/startup-of-the-ability-manager-service-and-bundle-manager-service.png "startup-of-the-ability-manager-service-and-bundle-manager-service") +![](figures/startup-of-the-ability-manager-service-and-bundle-manager-service.png "startup-of-the-ability-manager-service-and-bundle-manager-service") OpenHarmony applications can be installed and started after the two services are started. **Figure 6** Application startup process -![](figure/application-startup-process.png "application-startup-process") +![](figures/application-startup-process.png "application-startup-process") The home screen is the first OpenHarmony application started by the Ability Manager Service. After the home screen is started, the user can touch any installed OpenHarmony application on the home screen to start the particular application. The figure above shows the interaction process of starting an installed application from the home screen. diff --git a/en/device-dev/subsystems/subsys-boot-faqs.md b/en/device-dev/subsystems/subsys-boot-faqs.md index f4e3eb59371a2cf083f9169c2ae42795eaa0f808..974cf6b9925f360d227d19ba9a70b00dc5ad87e3 100644 --- a/en/device-dev/subsystems/subsys-boot-faqs.md +++ b/en/device-dev/subsystems/subsys-boot-faqs.md @@ -7,7 +7,7 @@ During system startup, the error message "\[Init\] InitReadCfg, parse failed! please check file /etc/init.cfg format." is displayed, and the startup is interrupted, as shown in the following figure. **Figure 1** Error information -![](figure/error-information.png "error-information") +![](figures/error-information.png "error-information") **Cause** diff --git a/en/device-dev/subsystems/subsys-boot-init-deviceInfo.md b/en/device-dev/subsystems/subsys-boot-init-deviceInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..fd2c79d06f047628a118cdc137a4acbdfefa67ca --- /dev/null +++ b/en/device-dev/subsystems/subsys-boot-init-deviceInfo.md @@ -0,0 +1,158 @@ +# DeviceInfo Adaptation + +## DeviceInfo parameters and mapping APIs + +| Parameter| API| Description| +|----------|------- |------| +| const.product.devicetype | const char\* GetDeviceType(void) | Obtains the device type.| +| const.product.manufacturer | const char\* GetManufacture(void) | Obtains the device manufacturer.| +| const.product.brand | const char\* GetBrand(void) | Obtains the device brand.| +| const.product.name | const char\* GetMarketName(void) | Obtains the device marketing name.| +| const.build.product | const char\* GetProductSeries(void) | Obtains the device series name.| +| const.product.model | const char\* GetProductModel(void) | Obtains the device authentication model.| +| const.software.model | const char\* GetSoftwareModel(void) | Obtains the device software model.| +| const.product.hardwareversion | const char\* GetHardwareModel(void) | Obtains the device hardware model.| +| const.product.hardwareprofile | const char\* GetHardwareProfile(void) | Obtains the device hardware profile.| +| ohos.boot.sn | const char\* GetSerial(void) | Obtains the serial number (SN) of the device.| +| const.product.software.version | const char\* GetDisplayVersion(void) | Obtains the software version visible to users.| +| const.product.bootloader.version | const char\* GetBootloaderVersion(void) | Obtains the bootloader version of the device.| +| const.product.udid | int GetDevUdid(char \*udid, int size) | Obtains the UDID of the device through **DeviceInfo** or through calculation if the attempt to obtain the UDID through **DeviceInfo** fails.| +| | const char *AclGetSerial(void); | Obtains the SN of the device (with ACL check).| +| | int AclGetDevUdid(char *udid, int size); | Obtains the UDID of the device (with ACL check).| + +## DeviceInfo Source + +### Adaptation of OHOS Fixed-value Parameters + +- OHOS fixed-value parameters: + + ``` + const.ohos.version.security_patch + const.ohos.releasetype + const.ohos.apiversion + const.ohos.fullname + ``` + +- Description of adaptation: + + OHOS fixed-value parameters are filled by the OHOS and do not need to be adapted by vendors. Currently, these parameters are defined in the **/base/startup/init/services/etc/param/ohos_const/ohos.para** file. + +### Adaptation of Vendor Fixed-value Parameters + +- Vendor fixed-value parameters: + + ``` + const.product.devicetype + const.product.manufacturer + const.product.brand + const.product.name + const.build.product + const.product.model + const.software.model + const.product.hardwareversion + const.product.hardwareprofile + const.product.software.version + const.product.bootloader.version + const.build.characteristics + ... ... + + ``` + + +- Description of adaptation: + + Adapt parameters in the **vendor** directory based on actual requirements. + + (1) Take RK3568 as an example for standard-system devices. Adapt parameters in the **/vendor/hihope/rk3568/etc/para/hardware_rk3568.para** file and install the file to the specified directory. + + ``` + ohos_prebuilt_etc("para_for_chip_prod") { + source = "./para/hardware_rk3568.para" + install_images = [ chip_prod_base_dir ] + relative_install_dir = "para" + part_name = "product_rk3568" + } + ``` + + (2) For mini- and small-system devices, adapt parameters in the respective **hals/utils/sys_param/vendor.para** file. For example: + + ``` + const.product.manufacturer=Talkweb + + const.product.brand=Talkweb + + const.product.name=Niobe + + const.build.product=Niobe + + const.product.model=Niobe407 + + const.software.model="2.0.0" + + const.product.hardwareversion="1.0.0" + + const.product.hardwareprofile="RAM:192K,ROM:1M,ETH:true" + ... ... + ``` + +### Adaptation of Vendor Dynamic-value Parameters + +- Currently, three ways are provided to obtain vendor dynamic-value parameters: cmdline, macro definition, and **BUILD.gn** definition. + + 1. cmdline: Values that are read from cmdline include **ohos.boot.hardware**, **ohos.boot.bootslots**, and **ohos.boot.sn**. The way to obtain **ohos.boot.sn** differs according to the system type as follows: + + (1) For standard-system devices: **ohos.boot.sn** is read from cmdline (generated by U-Boot). If the SN is obtained, the value is directly read; if the file path is obtained, the value is read from the file. If the preceding attempt fails, the value is read from the default SN files; that is, **/sys/block/mmcblk0/device/cid** and **/proc/bootdevice/cid**. + + (2) For mini- and small-system devices: These devices may come with their own special algorithms. Therefore, **HalGetSerial()** can be used to obtain the SN from the **hal_sys_param.c** file in the **hals/utils/sys_param** directory. + + 2. Macro definition: Obtain parameter values by compiling macro definitions. Currently, this mode is available only for mini- and small-system devices. For example: + + ``` + defines = [ + "INCREMENTAL_VERSION=\"${ohos_version}\"", + "BUILD_TYPE=\"${ohos_build_type}\"", + "BUILD_USER=\"${ohos_build_user}\"", + "BUILD_TIME=\"${ohos_build_time}\"", + "BUILD_HOST=\"${ohos_build_host}\"", + "BUILD_ROOTHASH=\"${ohos_build_roothash}\"", + ] + ``` + + 3. **BUILD.gn** definition: Obtain parameter values from the **/base/startup/init/services/etc/BUILD.gn** file. For example: + + ``` + if (target_cpu == "arm64") { + extra_paras += [ "const.product.cpu.abilist=arm64-v8a" ] + } + if (build_variant == "user") { + extra_paras += [ + "const.secure=1", + "const.debuggable=0", + ] + } else if (build_variant == "root") { + extra_paras += [ + "const.secure=0", + "const.debuggable=1", + ] + } + if (device_type != "default") { + extra_paras += [ + "const.product.devicetype=${device_type}", + "const.build.characteristics=${device_type}", + ] + } + module_install_dir = "etc/param" + } + ``` +#### Notes + + (1) For small-system devices, add the compilation of **vendor.para** to the **hals/utils/sys_param/BUILD.gn** file. + + ``` + copy("vendor.para") { + sources = [ "./vendor.para" ] + outputs = [ "$root_out_dir/vendor/etc/param/vendor.para" ] + } + ``` + + (2) For mini-system devices, a file system is not available and therefore, the **hal_sys_param.c** and **vendor.para** files are converted into header files and are compiled to the system during compilation. diff --git a/en/device-dev/subsystems/subsys-boot-init-jobs.md b/en/device-dev/subsystems/subsys-boot-init-jobs.md index 0a9bc5be6ee4270204bc0899dc825fce38a1617e..bd8ab114595085b855a2b60f6d84f17d74c4936d 100644 --- a/en/device-dev/subsystems/subsys-boot-init-jobs.md +++ b/en/device-dev/subsystems/subsys-boot-init-jobs.md @@ -5,7 +5,7 @@ A job is a set of commands in the **.cfg** file of the init module. A maximum of ### Basic Concepts A job can be configured in the **init.cfg** file or the custom **.cfg** file of the module. The parser of the init process aggregates commands of the jobs with the same name into one job. For jobs with the same name, the init process only ensures that the commands in the **init.cfg** file are executed in preference. It does not guarantee the execution sequence of commands in other **.cfg** files. -- Common job +- Basic job A job executed in a fixed phase during init process startup, for example, pre-init, init, or post-init. - pre-init: pre-initialization phase. Key services on which other services depend, such as ueventd, watchdog, and hilogd, are started in this phase. The mounting of data partitions is also done in this phase. @@ -20,7 +20,21 @@ A job can be configured in the **init.cfg** file or the custom **.cfg** file of A job triggered based on specific conditions. You can add conditions to a job so that the job is executed when the conditions are met. - A condition is a combination of system parameter values and supports operations such as **&&** and **||**, for example, **"condition": "sys.usb.config = none && sys.usb.configfs = 0"**. When defining commands for a job, you can add attributes in the format of **param:xxx** to form different commands. + A condition is a combination of system parameter values. It supports operations such as **&&** and **||** as well as matching of any parameter values by using the wildcard character (*). + + Generally, you can configure a condition in the format shown below: + + ``` + "condition": "sys.usb.config = none && sys.usb.configfs = 0" + ``` + + If you need to enable parameter checking in the boot phase, configure the condition as follows: + + ``` + "condition": "boot && const.debuggable=1" + ``` + + When defining commands for a job, you can add attributes in the format of **param:xxx** to form different commands. ### Constraints With the system parameter module, the standard system is able to support basic, conditional, and custom jobs. The small system supports only basic jobs. @@ -29,881 +43,80 @@ With the system parameter module, the standard system is able to support basic, ### Use Cases A job is a command set, where you can manage the commands to be executed. A maximum of 4096 commands can be added to a command set. During the init startup process, the execution of jobs helps ensure normal running of services. -### Parameters +### Parameter Description **Table 1** Command set description - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Command - - - Format and Example - - - Description - - - Supported System Type - -
- mkdir - - mkdir target folder [mode] [owner] [group]
Example:
mkdir /storage/myDirectory
mkdir /storage/myDirectory 0755 root root -
- Creates a folder. mkdir and the target folder must be separated by only one space. Folders cannot be created recursively. - - Small and standard systems -
- chmod - - chmod permission target
Example:
chmod 0600 /storage/myFile.txt
chmod 0750 /storage/myDir -
- Modifies the permission, which must be in the 0xxx format. chmod, permission, and target must be separated by only one space. - - Small and standard systems -
- chown - - chown uid gid target
Example:
chown 900 800 /storage/myDir
chown 100 100 /storage/myFile.txt -
- Modifies the owner group. chown, uid, gid, and target must be separated by only one space. - - Small and standard systems -
- mount - - mount fileSystemType src dst flags data
Example:
mount vfat /dev/mmcblk0 /sdc rw,umask=000
mount jffs2 /dev/mtdblock3 /storage nosuid -
- Mounts devices. Every two parameters must be separated by only one space.
For details about flags, see the mountFlagMap[] array of the mountFlagMap function in base/startup/init/services/init/init_common_cmds.c. The data field is optional. -
- Small and standard systems -
- start - - start serviceName
Example:
start foundationstart -
- Starts services. serviceName must be contained in the services array. - - Small and standard systems -
- export - - export key value
Example:
export TEST /data/test -
- Sets environment variables. key and value respectively indicate the environment variable and its value. - - Small and standard systems -
- rm - - rm filename
Example:
rm /data/testfile -
- Deletes a file. filename indicates the absolute file path. - - Small and standard systems -
- rmdir - - rmdir dirname
Example:
rmdir /data/testdir -
- Deletes a directory. dirname indicates the absolute path of the directory. - - Small and standard systems -
- write - - write filename value
Example:
write /data/testfile 0 -
- Writes a file. filename and value respectively indicate the absolute file path and the string to write. - - Standard system -
- stop - - stop servicename
Example:
stop console -
- Stops a service. servicename indicates the name of the service to stop. - - Small and standard systems -
- copy - - copy oldfile newfile
Example:
copy /data/old /data/new -
- Copies a file. oldfile and newfile respectively indicate the old and new absolute file paths. - - Small and standard systems -
- reset - - reset servicename
Example:
reset console -
- Resets a service. servicename indicates the name of the service to reset. If the service has not been started, this command will start the service. If the service is running, the command will stop the service and then restart it. - - Small and standard systems -
- reboot - - reboot subsystem
Example:
reboot updater -
- Restarts the system. subsystem is optional. If it is not specified, the device enters the current system upon restarting. If it is specified, the device enters the corresponding subsystem upon restarting. For example, if you run reboot updater, the device enters the updater subsystem upon restarting. - - Small and standard systems -
- sleep - - sleep time
Example:
sleep 5 -
- Enters the sleep mode. time indicates the sleep time.
To avoid impact on services, exercise caution when running this command. -
- Small and standard systems -
- domainname - - domainname name
Example:
domainname localdomain -
- Sets the domain name. - - Small and standard systems -
- hostname - - hostname name
Example:
hostname localhost -
- Sets the host name. - - Small and standard systems -
- wait - - wait filepath
Example:
wait /data/testfile or wait /data/testfile 5 -
- Waits for commands. The waiting time must not exceed 5 seconds. - - Small and standard systems -
- setrlimit - - setrlimit resource curValue maxValue
Example:
setrlimit RLIMIT_CPU 10 100 -
- Sets resource usage restrictions.
For details, see the resource[] array of the DoSetrlimit function in base/startup/init/services/init/init_common_cmds.c. -
- Small and standard systems -
- exec - - exec Path of the executable file Parameters passed by the executable file
Example:
exec /system/bin/udevadm trigger -
- Runs an executable file. The command must not contain more than 10 parameters. - - Small and standard systems -
- syncexec - - syncexec Path of the executable file Parameters passed by the executable file
Example:
syncexec /system/bin/udevadm trigger -
- Runs an executable file synchronously. The **wait** function will be called to wait for the child process to end. The command must not contain more than 10 parameters. - - Standard system -
- mknode - - mknod name { b | c } Major Minor
Example:
mknod path b 0644 1 9 -
- Creates an index node corresponding to a directory entry and a special file. - - Standard system -
- makedev - - makedev major minor
Example:
makedev -v update -
- Creates a static device node, which is usually in the /dev directory. - - Standard system -
- symlink - - symlink target link_name
Example
symlink /proc/self/fd/0 /dev/stdin -
- Creates a symbolic link. - - Standard system -
- trigger - - trigger jobName
Example
trigger early-fs -
- Triggers a job. - - Standard system -
- insmod - - insmod [-f] [options]
Example
insmod xxx.ko -
- Loads a kernel module file. - - Standard system -
- setparam - - setparam paramname paramvalue
Example:
setparam sys.usb.config hdc -
- Sets system parameters. - - Standard system -
- load_persist_params - - load persist params
Example:
load_persist_params  -
- Loads persist parameters. There must be one and only one space after the load_persist_params command. - - Standard system -
- load_param - - load params
Example:
load_param /data/test.normal.para -
- Loads the parameters from a file to the memory. - - Standard system -
- load_access_token_id - - load_access_token_id  - - Writes the access token to the data/service/el0/access_token/nativetoken.json file. There is one and only one space after load_access_token_id. - - Standard system -
- ifup - - ifup NIC
Example:
ifup eth0 -
- Activates the specified NIC. - - Standard system -
- mount_fstab - - mount_fstab fstab.test
Example:
mount_fstab /vendor/etc/fstab.test -
- Mounts partitions based on the fstab file. - - Standard system -
- umount_fstab - - umount_fstab fstab.test
Example:
umount_fstab /vendor/etc/fstab.test -
- Unmounts partitions based on the fstab file. - - Standard system -
- restorecon - - restorecon file or dir
Example:
restorecon /file -
- Reloads the SELinux context. - - Standard system -
- stopAllServices - - stopAllServices [bool]
Example:
stopAllServices false
stopAllServices -
- Stops all services. - - Standard system -
- umount - - umount path
Example:
umount /vendor -
- Unmounts a mounted device. - - Standard system -
- sync - - sync  - - Writes data to the disk synchronously. There is only one and only one space after sync. - - Standard system -
- timer_start - - timer_start serviceName
Example:
timer_start console -
- Starts the service timer. - - Standard system -
- timer_stop - - timer_stop serviceName
Example:
timer_stop console -
- Stops the service timer. - - Standard system -
- init_global_key - - init_global_key path
Example:
init_global_key /data -
- Initializes the encryption key of the data partition file. - - Standard system -
- init_main_user - - init_main_user - - Encrypts the main user directory. - - Standard system -
- mkswap - - mkswap file
Example:
mkswap /swapfile1 -
- Creates a swap partition on a file or device. - - Standard system -
- swapon - - swapon file
Example:
swapon /swapfile1 -
- Activates the swap space. - - Standard system -
- mksandbox - - mksandbox fileName
Example:
mksandbox system -
- Creates a sandbox. - - Standard system -
- loadcfg - - loadcfg filePath
Example:
loadcfg /patch/fstab.cfg -
- Loads other .cfg files. The maximum size of the target file (only /patch/fstab.cfg supported currently) is 50 KB. Each line in the /patch/fstab.cfg file is a command. The command types and formats must comply with their respective requirements mentioned in this table. A maximum of 20 commands are allowed. - - Small system -
+ | Command| Format and Example| Description| + | -------- | -------- | -------- | + | mkdir | mkdir target folder [mode] [owner] [group]
Example:
mkdir /storage/myDirectory
mkdir /storage/myDirectory 0755 root root| Creates a folder. mkdir and the target folder must be separated by only one space.
System type: small system and standard system| + | chmod | chmod permission target
Example:
chmod 0600 /storage/myFile.txt
chmod 0750 /storage/myDir | Modifies the permission, which must be in the 0xxx format. chmod, permission, and target must be separated by only one space.
System type: small system and standard system| + | chown | chown uid gid target
Example:
chown 900 800 /storage/myDir
chown 100 100 /storage/myFile.txt | Modifies the owner group. chown, uid, gid, and target must be separated by only one space.
System type: small system and standard system| + | mount | mount fileSystemType src dst flags [data]
Example:
mount vfat /dev/mmcblk0 /sdc rw,umask=000
mount jffs2 /dev/mtdblock3 /storage nosuid | Mounts devices. Every two parameters must be separated by only one space. For details about flags, see the mountFlagMap[] function in base/startup/init/services/init/init\_common\_cmds.c. The data field is optional.
System type: small system and standard system| + | start | start serviceName
Example: start foundation| Starts services. serviceName must be contained in the services array.
System type: small system and standard system| + | export | export key value
Example:
export TEST /data/test| Sets environment variables. key and value respectively indicate the environment variable and its value.
System type: small system and standard system| + | rm | rm filename
Example:
rm /data/testfile| Deletes a file. filename indicates the absolute file path.
System type: small system and standard system| + | rmdir | rmdir dirname
Example:
rmdir /data/testdir| Deletes a directory. dirname indicates the absolute path of the directory.
System type: small system and standard system| + | write | write filename value
Example:
write /data/testfile 0| Writes a file. filename and value respectively indicate the absolute file path and the string to write.
System type: small system and standard system| + | stop | stop serviceName
Example:
stop console| Stops a service. servicenamei> indicates the name of the service to stop.
System type: small system and standard system| + | copy | copy oldfile newfile
Example:
copy /data/old /data/new| Copies a file. oldfile and newfile respectively indicate the old and new absolute file paths.
System type: small system and standard system| + | reset | reset serviceName
Example:
reset console| Resets a service. servicename indicates the name of the service to reset. If the service has not been started, this command will start the service. If the service is running, the command will stop the service and then restart it.
System type: small system and standard system| + | reboot | reboot [subsystem]
Example:
reboot updater| Restarts the system. subsystem is optional. If it is not specified, the device enters the current system upon restarting. If it is specified, the device enters the corresponding subsystem upon restarting. For example, if you run reboot updater, the device enters the updater subsystem upon restarting.
System type: small system and standard system| + | sleep | sleep time
Example:
sleep 5| Enters the sleep mode. time indicates the sleep time, which must not exceed 5 seconds.
To avoid impact on services, exercise caution when running this command.
System type: small system and standard system| + | domainname | domainname name
Example:
domainname localdomain| Sets the domain name.
System type: small system and standard system| + | hostname | hostname name
Example:
hostname localhost| Sets the host name.
System type: small system and standard system| + | wait | wait filepath [time]
Example:
wait /data/testfile or wait /data/testfile 5| Waits for commands. time indicates the waiting time, which must not exceed 5 seconds.
System type: small system and standard system| + | setrlimit | setrlimit resource curValue maxValue
Example:
setrlimit RLIMIT_CPU 10 100| Sets resource usage restrictions.
System type: small system and standard system| + | write | write path content
Example:
write /proc/sys/kernel/sysrq 0| Writes a file.
System type: small system and standard system| + | exec | exec Path of the executable file Parameters passed by the executable file
Example:
exec /system/bin/mkdir /data/test.txt| Runs an executable file. This command is called by the system.
System type: small system and standard system| + | syncexec | syncexec Path of the executable file Parameters passed by the executable file
Example:
syncexec /system/bin/udevadm trigger| Runs an executable file synchronously. The **wait** function will be called to wait for the child process to end. The command must not contain more than 10 parameters.
System type: standard system + | mknode |mknod name { b \| c } Major Minor
Example:
mknod path b 0644 1 9| Creates an index node corresponding to a directory entry and a special file.
System type: standard system| + | makedev | makedev major minor
Example:
makedev -v update| Creates a static device node, which is usually in the /dev directory.
System type: standard system| + | symlink | symlink target link_name
Example:
symlink /proc/self/fd/0 /dev/stdin| Creates a symbolic link.
System type: standard system| + | trigger | trigger jobName
Example:
trigger early-fs| Triggers a job.
System type: standard system| + | insmod | insmod [-f] [options]
Example:
insmod xxx.ko| Loads a kernel module file.
System type: standard system| + | setparam | setparam paramName paramValue
Example:
setparam sys.usb.config hdc| Sets system parameters.
System type: standard system| + | load_persist_params | load persist params
Example:
load_persist_params | Loads persist parameters. There must be one and only one space after the load_persist_params command.
System type: standard system| + | load_param | load params
Example:
load_param /data/test.normal.para| Loads the parameters from a file to the memory.
System type: standard system| + | load_access_token_id | load_access_token_id | Writes the access token to the data/service/el0/access_token/nativetoken.json file. There is one and only one space after load_access_token_id.
System type: standard system| + | ifup | ifup NIC
Example:
ifup eth0| Activates the specified NIC.
System type: standard system| + | mount_fstab | mount_fstab fstab.test
Example:
mount_fstab /vendor/etc/fstab.test| Mounts partitions based on the fstab file.
System type: standard system| + | umount_fstab | umount_fstab fstab.test
Example:
umount_fstab /vendor/etc/fstab.test| Unmounts partitions based on the fstab file.
System type: standard system| + | restorecon | restorecon file or dir
Example:
restorecon /file| Reloads the SELinux context.
System type: standard system| + | stopAllServices | stopAllServices [bool]
Example:
stopAllServices false or stopAllServices| Stops all services. The maximum response time is 10 ms by default.
System type: standard system| + | umount |umount path
Example:
umount /vendor| Unmounts a mounted device.
System type: standard system| + | sync | sync | Writes data to the disk synchronously. There is only one and only one space after sync.
System type: standard system| + | timer_start | timer_start serviceName
Example:
timer_start console| Starts the service timer.
System type: standard system| + | timer_stop | timer_stop serviceName
Example:
timer_stop console| Stops a service timer.
System type: standard system| + | init_global_key | init_global_key path
Example:
init_global_key /data| Initializes the encryption key of the data partition file.
System type: standard system| + | init_main_user | init_main_user| Encrypts the main user directory.
System type: standard system| + | mkswap | mkswap file
Example:
mkswap /swapfile1| Creates a swap partition on a file or device.
System type: standard system| + | swapon | swapon file
Example:
swapon /swapfile1| Activates the swap space.
System type: standard system| + | mksandbox | mksandbox fileName
Example:
mksandbox system| Creates a sandbox.
System type: standard system| + | loadcfg | loadcfg filePath
Example:
loadcfg /patch/fstab.cfg| Loads other .cfg files. The maximum size of the target file (only /patch/fstab.cfg supported currently) is 50 KB. Each line in the /patch/fstab.cfg file is a command. The command types and formats must comply with their respective requirements mentioned in this table. A maximum of 20 commands are allowed.
System type: small system| ### Available APIs Job management is a part of the init startup process. It is a process-based function that completely serves the init startup process. It does not provide any functional APIs for other modules. It works in a way similar to command group management and does not provide help for other types of management. The following describes the job management APIs. **Table 2** Description of job parsing APIs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- API - - Input Parameter - - Return Value - - Description - - Supported System Type -
- void ParseAllJobs(const cJSON *fileRoot) - - const cJSON *fileRoot - - void - - Provides the general entry for parsing jobs. - - Small and standard systems -
- static void ParseJob(const cJSON  *jobItem, Job *resJob) - - const cJSON *jobItem, Job *resJob - - void - - Checks whether a job exists and parses cmds in it. - - Small system -
- int GetCmdLinesFromJson(const cJSON *root, CmdLines **cmdLines) - - const cJSON *root, CmdLines **cmdLines - - int - - Parses cmds in the job. This API is used for the small system. It does not apply to the standard system because the trigger command and condition attribute are involved. - - Small and standard systems -
- int ParseTriggerConfig(const cJSON *fileRoot, int (*checkJobValid)(const char *jobName)) - - const cJSON *fileRoot, int (*checkJobValid)(const char *jobName) - - int - - Parses the trigger command in the job. - - Standard system -
- static int ParseTrigger_(const TriggerWorkSpace *workSpace, const cJSON *triggerItem, int (*checkJobValid)(const char *jobName)) - - const TriggerWorkSpace *workSpace, const cJSON *triggerItem, int (*checkJobValid)(const char *jobName) - - int - - Obtains the job name, condition attribute, and cmds command group. Jobs are stored in a hash table, and commands are stored in a queue structure. - - Standard system -
+| API| Function| Supported System Type| +|:--------|:-----|:------| +|void ParseAllJobs(const cJSON *fileRoot)|Provides the general entry for parsing jobs.| Small and standard systems| +|static void ParseJob(const cJSON *jobItem, Job *resJob)|Checks whether a job exists and parses cmds in it.| Small system| +|int GetCmdLinesFromJson(const cJSON *root, CmdLines **cmdLines)| Parses cmds in the job. This API is used for the small system.
It does not apply to the standard system because the trigger command and condition attribute are involved.| Small and standard systems| +|int ParseTriggerConfig(const cJSON *fileRoot,
int (*checkJobValid)(const char *jobName))|Parses the trigger command in the job.| Standard system| +|static int ParseTrigger_(const TriggerWorkSpace *workSpace,
const cJSON *triggerItem,
int (*checkJobValid)(const char *jobName))|Obtains the job name, condition attribute, and cmds command group.
Jobs are stored in a hash table, and commands are stored in a queue structure.| Standard system| **Table 3** Description of the job triggering APIs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- API - - Input Parameter - - Return Value - - Description - - Supported System Type -
- void PostTrigger(EventType type, const char *content, uint32_t contentLen) - - EventType type, const char *content, uint32_t contentLen - - void - - Verifies the validity of the job name and sends a job triggering event. - - Standard system -
- static void SendTriggerEvent(int type, const char *content, uint32_t contentLen) - - int type, const char *content, uint32_t contentLen - - void - - Performs functions such as system control and starting or stopping of services based on system parameters. - - Standard system -
- static void DoTriggerCmd(const struct CmdArgs *ctx) - - const struct CmdArgs *ctx - - void - - Executes the trigger command. - - Standard system -
- void DoTriggerExec(const char *triggerName) - - const char *triggerName - - void - - Finds a command group based on the job name and pushes the commands in the command group to the execution queue. This API is available only for the standard system. - - Standard system -
- void DoJob(const char *jobName) - - const char *jobName - - void - - Matches a job based on the job name and invokes DoCmdByIndex to execute the commands in the job. - - Small system -
- void DoCmdByIndex(int index, const char *cmdContent) - - int index, const char *cmdContent - - void - - Combines parameters and commands. - - Small and standard systems -
- -### Development Example +| API| Function| Supported System Type| +|:--------|:-----|:------| +|void PostTrigger(EventType type, const char *content, uint32_t contentLen)|Verifies the validity of the job name and sends a job triggering event.| Standard system| +|static void SendTriggerEvent(int type, const char *content, uint32_t contentLen)|Performs functions such as system control and starting or stopping of services based on system parameters.| Standard system| +|static void DoTriggerCmd(const struct CmdArgs *ctx)|Executes the trigger command.| Standard system| +|void DoTriggerExec(const char *triggerName)|Finds a command group based on the job name and pushes the commands in the command group to the execution queue.
This API is available only for the standard system.| Standard system| +|void DoJob(const char *jobName)|Matches a job based on the job name and invokes DoCmdByIndex
to execute the commands in the job.| Small system| +|void DoCmdByIndex(int index, const char *cmdContent)|Combines parameters and commands.| Small and standard systems| + +### Example The following is the template for configuring jobs in the .cfg file. You can use it to verify the job management function. ``` { diff --git a/en/device-dev/subsystems/subsys-boot-init-sysparam.md b/en/device-dev/subsystems/subsys-boot-init-sysparam.md index f3032d36d7bc5893bfaadff1b3fe6b9863021bbf..1b5541a741273c7db7551bc6441bbfb44d1532a6 100644 --- a/en/device-dev/subsystems/subsys-boot-init-sysparam.md +++ b/en/device-dev/subsystems/subsys-boot-init-sysparam.md @@ -8,7 +8,7 @@ The parameter management module, namely, sysparam, provides an easy-to-use key-v Figure 1 System parameter operation primitives -![System parameter operation primitives](figure/system-parameter-operation-primitives.png) +![System parameter operation primitives](figures/system-parameter-operation-primitives.png) **Table 1** Description of system parameter operation primitives | Operation Primitive| Description| @@ -96,7 +96,7 @@ Each subsystem defines the system parameters of its own modules, including the s **Figure 2** UGO rule structure - ![UGO rule](figure/dac-definition.png) + ![UGO rule](figures/dac-definition.png) - SELinux policy for system parameter configuration diff --git a/en/device-dev/subsystems/subsys-boot-overview.md b/en/device-dev/subsystems/subsys-boot-overview.md index 7cd6f438d0e5b29d2a541263459bf1cb281d5104..2636bc078baedad412e0e96ab6fcf022bf0328b0 100644 --- a/en/device-dev/subsystems/subsys-boot-overview.md +++ b/en/device-dev/subsystems/subsys-boot-overview.md @@ -7,7 +7,7 @@ The following figure shows the context structure of the Startup subsystem. **Figure 1** Context structure of the Startup subsystem - ![context-structure-of-the-Startup-subsystem](figure/context-structure-of-the-Startup-subsystem.png) + ![context-structure-of-the-Startup-subsystem](figures/context-structure-of-the-Startup-subsystem.png) When the system is powered on, the kernel loads and starts services and applications as follows: @@ -426,7 +426,7 @@ Currently, OpenHarmony supports booting from partitions A and B (active and stan 1. Burn the original image, and view the device information of each partition. - ![Original partition](figure/ABStartup_1.png) + ![Original partition](figures/ABStartup_1.png) Use the original image to construct images of the partitions used for partition A/B booting, and test the partition A/B booting function. - Copy the **system** and **vendor** images, and add the suffix **\_b** to them. @@ -441,16 +441,16 @@ Currently, OpenHarmony supports booting from partitions A and B (active and stan 1. Run the **cat /proc/cmdline** command. If the command output contains **bootslot=2**, the system supports partition A/B booting. - ![cmdline](figure/ABStartup_2.png) + ![cmdline](figures/ABStartup_2.png) 2. Run the **param get ohos.boot.bootslot** command. If the command output contains **2**, the **bootslot** information is successfully written to the **parameter.txt**. 3. Run the **ls -l /dev/block/by-name** command. If the command output contains **system_b** and **vendor_b**, device nodes are successfully created in partition B. - ![Device information](figure/ABStartup_3.png) + ![Device information](figures/ABStartup_3.png) 4. Run the **df -h** command to check the partitions mounted to the system. - ![Partition information](figure/ABStartup_4.png) + ![Partition information](figures/ABStartup_4.png) As shown in the figure, partition **mmcblk0p6** is mounted to the root file system (represented by a slash), and partition **mmcblk0p7** is mounted to **/vendor**. Based on the command output in step 3, **mmcblk0p6** is the **system** partition, and **mmcblk0p7** is the **vendor** partition. That is, the mounted partitions are the default partitions, that is, **system** and **vendor** partitions without suffixes. In other words, partition A is the default partition. @@ -458,21 +458,21 @@ Currently, OpenHarmony supports booting from partitions A and B (active and stan 1) Run the **partitionslot setactive 2** command to set the slot of the active partition to **2**, that is, the slot of partition B. - ![Partition slot configuration](figure/ABStartup_5.png) + ![Partition slot configuration](figures/ABStartup_5.png) 2) Run the **partitionslot getslot** command to check the configured slot. - ![View Slot](figure/ABStartup_6.png) + ![View Slot](figures/ABStartup_6.png) If **current slot** is **2**, the slot of the active partition is successfully set to **2**. 3) Upon restarting, run the **df -h** command to check the partitions mounted to the system. According to the command output, partition **mmcblk0p11** is mounted to the root file system, and partition **mmcblk0p12** is mounted to **/vendor**. - ![Mounting information](figure/ABStartup_7.png) + ![Mounting information](figures/ABStartup_7.png) 4) Run the **ls -l /dev/block/by-name** command again. - ![New device information](figure/ABStartup_8.png) + ![New device information](figures/ABStartup_8.png) **mmcblk0p11** corresponds to **system_b**, and **mmcblk0p12** corresponds to **vendor_b**. That is, the system is successfully booted from partition B. diff --git a/en/device-dev/subsystems/subsys-build-all.md b/en/device-dev/subsystems/subsys-build-all.md index 6f2970e906c0c622e0019bcd12bd9cc2944476cc..a7111d5c13621490a871197a5e55f7bcb6ff3c43 100644 --- a/en/device-dev/subsystems/subsys-build-all.md +++ b/en/device-dev/subsystems/subsys-build-all.md @@ -57,7 +57,7 @@ The Compilation and Build subsystem implements compilation and packaging through **Figure 1** Relationships between product, subsystem, component, and module -![](figure/product_subsystem_component_module_relationships.png) +![](figures/product_subsystem_component_module_relationships.png) The relationships between the product, subsystem, component, and module are as follows: @@ -73,7 +73,7 @@ A product, component, and module can be built, but a subsystem cannot. The figur **Figure 2** Build process -![Build process](figure/build_process.png) +![Build process](figures/build_process.png) 1. Run **hb set** to set the product to build. @@ -143,28 +143,28 @@ To ensure that chipset and product solutions are decoupled from OpenHarmony, you ```shell -/build # Directory for build +/build # Directory for build ├── __pycache__ -├── build_scripts/ # Python scripts for build +├── build_scripts/ # Python scripts for build ├── common/ -├── config/ # Build-related configuration +├── config/ # Build-related configuration ├── core -│ └── gn/ # BUILD.gn configuration +│ └── gn/ # BUILD.gn configuration └── build_scripts/ ├── docs gn_helpers.py* -lite/ # hb and preloader entry +lite/ # hb and preloader entry misc/ -├── ohos # Configuration of OpenHarmony build and packaging -│ ├── 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 (facilitating one-time import of each module) +├── ohos # Configuration of OpenHarmony build and packaging +│ ├── 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 (facilitating one-time import of each module) ├── ohos_system.prop ├── ohos_var.gni* ├── prebuilts_download.sh* @@ -172,10 +172,10 @@ misc/ ├── scripts/ ├── subsystem_config.json ├── subsystem_config_example.json -├── templates/ # C/C++ build templates +├── templates/ # C/C++ build templates ├── test.gni* -├── toolchain # Build toolchain configuration -├── tools # Common tools +├── toolchain # Build toolchain configuration +├── tools # Common tools ├── version.gni ├── zip.py* @@ -222,25 +222,25 @@ Then, run the build commands in command line (CLI) mode or hb mode. - The **./build.sh** command supports the following options: ```shell - -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 # Specify 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. + -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 # Specify 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. --jobs=JOBS --export-para=EXPORT_PARA - --build-only-gn # Perform GN parsing and do not run Ninja. - --ccache # (Optional) Use ccache for build. You need to install ccache locally. - --fast-rebuild # Specify whether to allow fast rebuild. The default value is False. - --log-level=LOG_LEVEL # Specify the log level used in the build process. 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. + --build-only-gn # Perform GN parsing and do not run Ninja. + --ccache # (Optional) Use ccache for build. You need to install ccache locally. + --fast-rebuild # Specify whether to allow fast rebuild. The default value is False. + --log-level=LOG_LEVEL # Specify the log level used in the build process. 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. ``` 2. Using the hb tool @@ -381,4 +381,4 @@ You can add and build a product, component, chipset solution, and module. For de - [Information Collected by the Open Source Software Notice](subsys-build-reference.md#information-collected-by-the-open-source-software-notice) - [Parameters for Accelerating Local Build](subsys-build-reference.md#parameters-for-accelerating-local-build) - [Viewing Ninja Build Information](subsys-build-reference.md#viewing-ninja-build-information) - +- [Customizing the chip_prod Image](subsys-build-reference.md#customizing-the-chip_prod-image) 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 88eb7f5a3a015cf03a57b20bf861963cf93c9e24..7a7dc70272ea5d474f5014c6fd9a410380aef235 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 @@ -40,13 +40,13 @@ Kconfig visual configuration has the following advantages: menuconfig kconfig ``` - ![Kconfig example](./figure/kconfig_interface.png) + ![Kconfig example](./figures/kconfig_interface.png) 4. Set parameters. For details about the parameters, see productdefine/common/base/base_product.json. - ![Setting parameters](./figure/kconfig_set_parameters.gif) + ![Setting parameters](./figures/kconfig_set_parameters.gif) 5. Select and configure the component. @@ -56,13 +56,13 @@ Kconfig visual configuration has the following advantages: 3. When setting `feature`, use commas (,) to separate multiple values. - ![Selecting a component](./figure/kconfig_select_component.gif) + ![Selecting a component](./figures/kconfig_select_component.gif) 6. Save the settings. Press **S** to save the settings. You can set the name of the file to generate. By default, a file named `.config` file is generated in the current directory. - ![Save settings](./figure/kconfig_save.png) + ![Save settings](./figures/kconfig_save.png) 7. Generate the OpenHarmony style configuration file. diff --git a/en/device-dev/subsystems/subsys-build-module.md b/en/device-dev/subsystems/subsys-build-module.md index 24766cba3df0dd1e179111e874ddb33819ebfa3a..bc5ec28957f446b4b4ca8b221580467083d2963f 100644 --- a/en/device-dev/subsystems/subsys-build-module.md +++ b/en/device-dev/subsystems/subsys-build-module.md @@ -369,7 +369,7 @@ The following figure shows the logic for adding a module. Generally, you need to - Add a module to a new subsystem. - ![](figure/module_addition_process.png) + ![](figures/module_addition_process.png) **Adding a Module to an Existing Component** diff --git a/en/device-dev/subsystems/subsys-build-reference.md b/en/device-dev/subsystems/subsys-build-reference.md index 0ac5679c3afa3f2530733555a26e8ad5c99dddf7..1d8d95250294bb955316441667630904e73f4611 100644 --- a/en/device-dev/subsystems/subsys-build-reference.md +++ b/en/device-dev/subsystems/subsys-build-reference.md @@ -6,7 +6,7 @@ When adding a module, you must declare its dependencies in **BUILD.gn**. **deps* **Dependency Types** -![Dependency Types](figure/dependency_types.png) +![Dependency Types](figures/dependency_types.png) The dependency between modules can be classified into **deps** (left in the figure above) and **external_deps** (right in the figure above). @@ -55,8 +55,8 @@ The dependency between modules can be classified into **deps** (left in the figu 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. + ] # 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. } ``` @@ -71,14 +71,14 @@ Sanitizer configuration example: ``` shell ohos_shared_library("example") { sanitize = { - cfi = true # Enable the CFI check. - cfi_cross_dso = true # Enable the cross-DSO CFI check. - integer_overflow = true # Enable the integer overflow check. - boundary_sanitize = true # Enable the bounds check. - ubsan = true # Enable some UBSAN options. - all_ubsan = true # Enable all UBSAN options. - debug = true # Enable the debug mode, which is disabled by default. - blocklist = "./blocklist.txt" # Path of the blocklist. + cfi = true # Enable the CFI check. + cfi_cross_dso = true # Enable the cross-DSO CFI check. + integer_overflow = true # Enable the integer overflow check. + boundary_sanitize = true # Enable the bounds check. + ubsan = true # Enable some UBSAN options. + all_ubsan = true # Enable all UBSAN options. + debug = true # Enable the debug mode, which is disabled by default. + blocklist = "./blocklist.txt" # Path of the blocklist. } ... } @@ -187,7 +187,7 @@ The **out/rk3568/.ninja_log** file records the build start time and end time (ms The four columns are start time, end time, modified timestamp (mtime), and command hash from left to right. -![Ninja_Trace](figure/Ninja_Trace.png) +![Ninja_Trace](figures/Ninja_Trace.png) You can graphically display the build time as follows: @@ -198,3 +198,69 @@ You can graphically display the build time as follows: 1. Click **Success** under **Static Check**. 2. Click **Output** in the **Output** column. The **build.trace.html** file is displayed in the **build_trace** column on the left. Click the file to open it. + +## Customizing the chip_prod Image + +### When to Use + +The different capabilities for the products in the same chip solution are placed in the **chip_prod** partition. You need to generate the **chip_prod.img** specific to the product. + +### Procedure +1. Configure the **config.json** file. + + In the **config.json** file, add **chipprod_config_path**, which specifies the path of the product definition file. + The file is named **chip_product_list.gni**, and in the **chip_product_list = ["productA", "productB", ...]** format. + + Example: + + To customize **chip_prod.img** for **MyProduct**, modify the **//vendor/Product vendor/MyProduct/config.json** as follows: + + ```shell + { + "product_name": "MyProduct", # Product name. + "version": "3.0", # config.json version, which is 3.0. + "chipprod_config_path": "", # (Optional) Path of the chipprod configuration file. + "subsystems": [ + { + "subsystem": "arkui", # Subsystem of the product. + "components": [ + { + "component": "ace_engine", + "features":[ "ace_engine_feature_enable_web = true", + "ace_engine_feature_enable_accessibility = true" ] } + ] + }, + { + ... + } + ... + More subsystems and components. + } + } + ``` + +2. Configure the module. + + If the configuration file has different product configurations, for example, to generate **chip_prod.img** for product A, you need to configure **install_images** and **module_install_dir** for module compilation. + + The following uses **ohos_prebuilt_executable** as an example: + + ```shell + ohos_prebuilt_executable("moduleXXX"){ + install_images = [ "chip_prod" ] + module_install_dir = "productA/etc/***" # The path must start with productA. + } + ``` + +3. Run the build command. +```shell +./build.sh --product-name {product_name} --build-target chip_prod_image +``` + +4. Generate the images. + If products A and B are defined (**chip_product_list = ["productA", "productB"]**) and a module is installed in the products, the following images are generated: + + ``` + images/productA/chip_prod.img + images/productB/chip_prod.img + ``` diff --git a/en/device-dev/subsystems/subsys-data-relational-database-overview.md b/en/device-dev/subsystems/subsys-data-relational-database-overview.md index e152fd38c14b2b10a465547e1359b6ce175fd099..9a86c143c01e9f5f1bf5022793eca51fbcef2959 100644 --- a/en/device-dev/subsystems/subsys-data-relational-database-overview.md +++ b/en/device-dev/subsystems/subsys-data-relational-database-overview.md @@ -25,7 +25,7 @@ The OpenHarmony RDB provides a common operation interface (**RdbStore**) for ext **Figure 1** How RDB works -![](figure/en-us_image_0000001115980740.png) +![](figures/en-us_image_0000001115980740.png) ## Default Settings - The default database logging mode is write-ahead logging (WAL). diff --git a/en/device-dev/subsystems/subsys-data-storage-overview.md b/en/device-dev/subsystems/subsys-data-storage-overview.md index fee188e448354c1a09825b2880d7a2485c69818f..be3c41e7eeffd76d53b5b54057568c3079e50930 100644 --- a/en/device-dev/subsystems/subsys-data-storage-overview.md +++ b/en/device-dev/subsystems/subsys-data-storage-overview.md @@ -22,7 +22,7 @@ When obtaining a **Preferences** instance, the application can read data from or **Figure 1** How lightweight data store works -![](figure/en-us_image_0000001192123772.png) +![](figures/en-us_image_0000001192123772.png) ## Constraints diff --git a/en/device-dev/subsystems/subsys-dfx-faultlogger.md b/en/device-dev/subsystems/subsys-dfx-faultlogger.md index 3158fc12562b130652e3ed2d164abd388b918d28..209734174320846cc68004b82dfff89447df453b 100644 --- a/en/device-dev/subsystems/subsys-dfx-faultlogger.md +++ b/en/device-dev/subsystems/subsys-dfx-faultlogger.md @@ -18,7 +18,7 @@ The following figure shows the process of handling a process crash based on the **Figure 1** Process crash handling flowchart -![process_crash_handling](figure/process_crash_handling.png) +![process_crash_handling](figures/process_crash_handling.png) 1. After the signal processor is installed, the **DFX_SignalHandler** function detects and responds to the process crash exception signal. diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md index c74833145c8213f6df04bc5a9ca29e63df9671ce..e6c0316c22cf0f0988f032218e92543c9f7b3acc 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md @@ -6,18 +6,18 @@ ### Function Introduction -If HiSysEvent logging is required for a component, you need to define a YAML file and [configure the YAML file path](#configuring-the-yaml-file-path) in the **bundle.json** file. During compilation, the OpenHarmony compilation framework will use the Python compilation script to parse and verify all the YAML files configured in the **bundle.json** file. On completion, the compilation framework will summarize the configuration information in the YAML files and convert the information into a JSON file named **hisysevent.def**. After that, the compilation framework will put the JSON file to a specified path as the basis for the system to determine whether to log system events. +If HiSysEvent logging is required for a component, you need to define a YAML file and [configure the YAML file path](#verifying-the-yaml-file) in the **bundle.json** file. During compilation, the OpenHarmony compilation framework will use the Python compilation script to parse and verify all the YAML files configured in the **bundle.json** file. On completion, the compilation framework will summarize the configuration information in the YAML files and convert the information into a JSON file named **hisysevent.def**. After that, the compilation framework will put the JSON file to a specified path as the basis for the system to determine whether to log system events. ### Basic Concepts Understanding the following concepts would be helpful for you in configuring HiSysEvent logging. -- Event domain
Represents the domain to which an event belongs. It is specified by the **domain** field in the YAML file. For details, see [domain](#example) in the example YAML file. +- Event domain
Represents the domain to which an event belongs. It is specified by the **domain** field in the YAML file. For details, see [domain](#writing-a-yaml-file) in the example YAML file. -- Event name
Indicates the events in an event domain. For details, see [EVENT\_NAMEA/EVENT\_NAMEB](#example) in the example YAML file. +- Event name
Indicates the events in an event domain. For details, see [EVENT\_NAMEA/EVENT\_NAMEB](#writing-a-yaml-file) in the example YAML file. -- Parameter
Defines the key values in an event name. For details, see [__BASE/NAME1/NAME2](#example) in the example YAML file. +- Parameter
Defines the key values in an event name. For details, see [__BASE/NAME1/NAME2](#writing-a-yaml-file) in the example YAML file. ### Constraints @@ -47,11 +47,12 @@ Constraints on the event domain, event name, and parameter | arrsize | Length of the parameter of the array type. This field is optional.
Value:
1-100| | desc | Parameter description. This field is mandatory.
Rule:
The description contains 3 to 128 characters, including a to z, A to Z, 0 to 9, and underscores (_).| +## How to Develop -## Writing a YAML File +### Writing a YAML File -### Writing Rules +**Writing Rules** - Event domain naming rules: - The name must start with a letter and can contain only uppercase letters, digits, and underscores (_). @@ -64,11 +65,11 @@ Constraints on the event domain, event name, and parameter - Parameter naming rules: - The name must start with a letter and can contain only uppercase letters, digits, and underscores (_). - - The name contains 1 to 32 characters. + - The name contains 1 to 48 characters. - The number of parameters in an event domain cannot exceed 128. -### Example +**Example** - In the example YAML file, the event domain name is **MODULEA**. The event domain contains two events named **EVENT_NAMEA** and **EVENT_NAMEB**. @@ -96,10 +97,10 @@ Constraints on the event domain, event name, and parameter ``` -## Verifying the YAML File +### Verifying the YAML File -### Configuring the YAML File Path +**Configuring the YAML File Path** In the **bundle.json** file, use the **hisysevent_config** attribute to specify the YAML file path. @@ -150,7 +151,7 @@ In the **bundle.json** file, use the **hisysevent_config** attribute to specify > The YAML file can be placed in any directory of the component project as needed. You only need to specify the path in the **bundle.json** file. -### Compiling YAML Files +**Compiling YAML Files** - Perform full compilation. - During full compilation of the system, the configurations in the YAML files of all components are summarized. After the compilation is complete, the **hisysevent.def** file will be generated in the specified directory. diff --git a/en/device-dev/subsystems/subsys-dfx-hitracechain.md b/en/device-dev/subsystems/subsys-dfx-hitracechain.md index 8e7ded998f75f6fde34134a1240486193431058d..9b9b85b66a457a0653b12f7d450f13f7aaef2a4f 100644 --- a/en/device-dev/subsystems/subsys-dfx-hitracechain.md +++ b/en/device-dev/subsystems/subsys-dfx-hitracechain.md @@ -16,24 +16,24 @@ HiTraceChain can be used for the following purposes: **Figure 1** Use cases of HiTraceChain - ![](figure/use-cases-of-hitrace.png "use-cases-of-hitrace") + ![](figures/use-cases-of-hitrace.png "use-cases-of-hitrace") ### Usage Example **Figure 2** Service calling process \(inter-device and inter-process synchronous call\) -![](figure/service-calling-process-(inter-device-and-inter-process-synchronous-call).png "service-calling-process-(inter-device-and-inter-process-synchronous-call)") +![](figures/service-calling-process-(inter-device-and-inter-process-synchronous-call).png "service-calling-process-(inter-device-and-inter-process-synchronous-call)") 1. Display the call relationship in the service process, analyze key paths and function dependency, and determine the time consumption and call frequency at each call point to detect performance bottlenecks. **Figure 3** Service calling process - ![](figure/service-calling-process.png "service-calling-process") + ![](figures/service-calling-process.png "service-calling-process") **Figure 4** Time delay in the service calling process - ![](figure/time-delay-in-the-service-calling-process.png "time-delay-in-the-service-calling-process") + ![](figures/time-delay-in-the-service-calling-process.png "time-delay-in-the-service-calling-process") 2. Add **traceid** to logs and events automatically to facilitate comprehensive analysis and quick fault location. @@ -444,7 +444,7 @@ Extended communication mechanisms can also follow this implementation. **Figure 5** Call chain tracing in synchronous communication -![](figure/call-chain-tracing-in-synchronous-communication.png "call-chain-tracing-in-synchronous-communication") +![](figures/call-chain-tracing-in-synchronous-communication.png "call-chain-tracing-in-synchronous-communication") The process is as follows: diff --git a/en/device-dev/subsystems/subsys-dfx-hitracemeter.md b/en/device-dev/subsystems/subsys-dfx-hitracemeter.md index e5e02d1479d2b744d92bceb0525c944e87742b08..e80731582852658e6a65c6fc8f8d7cb66ca746a0 100644 --- a/en/device-dev/subsystems/subsys-dfx-hitracemeter.md +++ b/en/device-dev/subsystems/subsys-dfx-hitracemeter.md @@ -12,15 +12,13 @@ The HiTraceMeter subsystem consists of three parts: - hitrace CLI tool for data collection - smartperf tool for graphical data analysis -Wherein, HiTraceMeter APIs and the hitrace CLI tool run on the device side, and the smartperf tool runs on the PC side. - -HiTraceMeter APIs are provided in C++ and JS for event logging, which aims to generate the trace data necessary for performance tracing and analysis during the development process. +Wherein, HiTraceMeter APIs and the hitrace CLI tool run on the device side, and the smartperf tool runs on the PC side. HiTraceMeter APIs are provided in C++ and JS for event logging, which aims to generate the trace data necessary for performance tracing and analysis during the development process. The hitrace CLI tool is used to collect trace data. It captures trace data flows and saves the data as a text file. The smartperf tool allows you to perform data analysis manually or use the analysis script for automated data analysis. If you want to get the data analysis done automatically, you need to supply the data file generated by the hitrace CLI tool as the input for the smartperf tool. -Traces data is classified by trace tag or trace category. Generally, one device subsystem corresponds to one tag. The tag is passed as the **Tag** parameter to event logging APIs. When you use the hitrace CLI tool to collect trace data, only the trace data specified by the **Tag** parameter is collected. Trace data of applications is fixedly labeled as **APP Tag**, and therefore, no **Tag** parameter needs to be passed to JS APIs. The following is a list of trace tags supported by HiTraceMeter. You can view the tags in [hitrace_meter.h](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/interfaces/native/innerkits/include/hitrace_meter/hitrace_meter.h). + Traces data is classified by trace tag or trace category. Generally, one device subsystem corresponds to one tag. The tag is passed as the **Tag** parameter to event logging APIs. When you use the hitrace CLI tool to collect trace data, only the trace data specified by the **Tag** parameter is collected. Trace data of applications is fixedly labeled as **APP Tag**, and therefore, no **Tag** parameter needs to be passed to JS APIs. The following is a list of trace tags supported by HiTraceMeter. You can view the tags in [hitrace_meter.h](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/interfaces/native/innerkits/include/hitrace_meter/hitrace_meter.h). ```cpp constexpr uint64_t HITRACE_TAG_NEVER = 0; // This tag is never enabled. @@ -73,24 +71,23 @@ constexpr uint64_t HITRACE_TAG_NOT_READY = (1ULL << 63); // Reserved for initial constexpr uint64_t HITRACE_TAG_VALID_MASK = ((HITRACE_TAG_LAST - 1) | HITRACE_TAG_LAST); ``` -## Implementation Principle +## Implementation Principles HiTraceMeter provides the hitrace CLI tool for capturing trace data in user mode and kernel mode, and provides C++ (innerkits) and JS (kits) APIs for event logging in user mode. Through extending kernel's ftrace functionality, HiTraceMeter can use the trace_marker node of ftrace to write the data, which is written into the user space by event logging APIs, to the kernel buffer. The following figure shows the basic HiTraceMeter architecture. -![HiTraceMeter architecture](figure/HiTraceMeter.png) - +![HiTraceMeter architecture](figures/HiTraceMeter.png) ## Constraints - The implementation of HiTraceMeter functions and APIs depends on the ftrace functionality, a framework provided by the kernel. It enables developers to add more trace functions via plug-ins. Therefore, make sure that ftrace is enabled before you use HiTraceMeter. - For most Linux kernels, ftrace is enabled by default. For details, see the ftrace documentation you may obtain. + For most Linux kernels, ftrace is enabled by default. For details, see the ftrace documentation you may obtain. - HiTraceMeter is available only for the mini system and standard system. - - + + # HiTraceMeter Development @@ -98,7 +95,6 @@ HiTraceMeter development focuses on two parts: JS/C++ event logging APIs and the - ## When to Use You may encounter unexpected issues like app freezing during app development or need to view the code's call chain during code debugging. With the APIs provided by HiTraceMeter, you'll be able to trace the application delay and call chain to identify performance problems. @@ -109,20 +105,19 @@ Only C++ APIs are now open for system developers. If you're developing a JS app, **Table 1** Sync APIs -| API | Function |Parameter Description | -| :----------------------------------------------------------- | ------------- |------------- | -| void StartTrace(uint64_t label, const std::string& value, float limit = -1); | Starts a synchronous trace.|**label**: trace category.
**value**: trace data that indicates the specific status, such as the memory size and queue length.| -| void FinishTrace(uint64_t label); | Stops a synchronous trace.|**label**: trace category.| - +| Sync trace | Function | Parameter Description | +|:---------------------------------------------------------------------------- | --------- | --------------------------------------------------------------------- | +| void StartTrace(uint64_t label, const std::string& value, float limit = -1); | Starts a synchronous trace.| **label**: trace category.
**value**: trace data that indicates the specific status, such as the memory size and queue length.| +| void FinishTrace(uint64_t label); | Stops a synchronous trace.| **label**: trace category. | **StartTrace** and **FinishTrace** must be used in pairs, and **FinishTrace** matches the latest **StartTrace**. The two APIs can be used in nested mode. The stack data structure is used for matching during trace data parsing. The **limit** parameter is used for flow control, and you are advised to use the default value. **Table 2** Async APIs -| API | Function |Parameter Description | -| ------------------------------------------------------------ | ------------- |------------- | +| Async trace | Function | Parameter Description | +| ------------------------------------------------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------- | | void StartAsyncTrace(uint64_t label, const std::string& value, int32_t taskId, float limit = -1); | Starts an asynchronous trace.| **label**: trace category.
**value**: trace data that indicates the specific status, such as the memory size and queue length.
**taskId**: ID used to indicate the association of APIs in an asynchronous trace.| -| void FinishAsyncTrace(uint64_t label, const std::string& value, int32_t taskId); | Stops an asynchronous trace.| **label**: trace category.
**value**: trace data that indicates the specific status, such as the memory size and queue length.
**taskId**: ID used to indicate the association of APIs in an asynchronous trace.| +| void FinishAsyncTrace(uint64_t label, const std::string& value, int32_t taskId); | Stops an asynchronous trace.| **label**: trace category.
**value**: trace data that indicates the specific status, such as the memory size and queue length.
**taskId**: ID used to indicate the association of APIs in an asynchronous trace.| @@ -130,160 +125,144 @@ The trace data of **StartAsyncTrace** and **FinishAsyncTrace** is matched based **Table 3** Counter APIs -| API | Function |Parameter Description | -| ------------------------------------------------------------ | --------- |--------- | -| void CountTrace(uint64_t label, const std::string& name, int64_t); | Performs a count trace.|**label**: trace category.
**name**: trace name displayed in the IDE.| - +| Counter Trace | Function | Parameter Description | +| ------------------------------------------------------------------ | ------- | -------------------------------------------------------------- | +| void CountTrace(uint64_t label, const std::string& name, int64_t); | Count trace.| **label**: trace category.
**name**: trace name displayed in the IDE.| ## How to Develop + 1. Add the build dependencies to the build configuration file **base\hiviewdfx\hitrace\cmd\BUILD.gn**. + + ``` + external_deps = [ "hitrace_native:hitrace_meter"] + ``` - ``` - external_deps = [ "hitrace_native:hitrace_meter"] - ``` 2. Add the header file dependencies. - - ```cpp - #include "hitrace_meter.h"// Header file for defining APIs - ``` - -3. When calling an API, pass the trace value as an input parameter. After the hitrace command is executed in the shell, the trace data is automatically captured. The captured data includes the function call process and the memory and time consumed during this process. You can use the data to analyze the call process to identify performance problems. - - - ```cpp - - CountTrace(label, "count number", 2000); // Integer trace - - StartTrace(label, "func1Trace", -1); // Trace start point of func1Start - - FinishTrace(label); // Trace end point of func1Trace - - StartAsyncTrace(label, "asyncTrace1", 1234); // Start point of asyncTrace1 - - FinishAsyncTrace(label, "asyncTrace2", 3456); // End point of asyncTrace2 - ``` + + ```cpp + #include "hitrace_meter.h"// Header file for defining APIs + ``` + +3. When calling an API, pass the trace value as an input parameter. The trace tags currently supported are listed in **hitrace_meter.h**. Assume that the trace tag is **OHOS** and trace data of **func1** and **func2** needs to be captured. After the hitrace command is executed in the shell, the trace data is automatically captured. The captured data includes the function call process and the memory and time consumed during this process. You can use the data to analyze the call process to identify performance problems. + + ```cpp + #include "hitrace_meter.h" // Include hitrace_meter.h + using namespace std; + + int main() + { + uint64_t label = BYTRACE_TAG_OHOS; + sleep(1); + CountTrace(label, "count number", 2000); // Integer trace + + StartTrace(label, "func1Trace", -1); // Trace start point of func1Start + sleep(1); + StartTrace(label, "func2Trace", -1); // Trace start point of func2Start + sleep(2); + FinishTrace (label); // Trace end point of func2Trace + sleep(1); + FinishTrace(label); // Trace end point of func1Trace + + StartAsyncTrace(label, "asyncTrace1", 1234); // Trace start point of asyncTrace1 + FinishAsyncTrace(label, "asyncTrace1", 1234); // Trace end point of asyncTrace1 + + return 0; + } + ``` 4. On completion of HiTraceMeter building and deployment, start a trace. After you run the application in the shell on the device, trace data will be captured automatically. - - ``` - hdc_std shell hitrace -t 10 ohos > .\myapp_demo.ftrace - ``` - - You can open the captured data by clicking **Open trace file** in the smartperf tool or dragging the data to the graphics area. For details, see [smartperf](https://toscode.gitee.com/openharmony-sig/smartperf). - -## Development Example - -You can access a full list of trace tags supported by HiTraceMeter in **hitrace_meter.h**. The following uses the **OHOS** tag as an example to illustrate how to obtain the trace data of the **func1** and **func2** functions. - -```cpp -#include "hitrace_meter.h" // Include hitrace_meter.h -using namespace std; - -int main() -{ - uint64_t label = BYTRACE_TAG_OHOS; - sleep(1); - CountTrace(label, "count number", 2000); // Integer trace - - StartTrace(label, "func1Trace", -1); // Trace start point of func1Start - sleep(1); - StartTrace(label, "func2Trace", -1); // Trace start point of func2Start - sleep(2); - FinishTrace (label); // Trace end point of func2Trace - sleep(1); - FinishTrace(label); // Trace end point of func1Trace - - return 0; - } -``` - - + + ``` + hdc_std shell hitrace -t 10 ohos > .\myapp_demo.ftrace + ``` + + You can open the captured data by clicking **Open trace file** in the smartperf tool or dragging the data to the graphics area. For details, see [smartperf](https://toscode.gitee.com/openharmony-sig/smartperf). ## Verification The following is a demo debugging process, where the **StartTrace** and **FinishTrace** APIs are used in synchronization mode. 1. Write the test code file [hitrace_example.cpp](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/cmd/example/hitrace_example.cpp) by adding the **StartTrace** and **FinishTrace** APIs to the code. - - ```cpp - int main() - { - thread t1(ThreadFunc1); - t1.join(); - - StartTrace(LABEL, "testStart"); - sleep(SLEEP_ONE_SECOND); - - StartTrace(LABEL, "funcAStart", SLEEP_ONE_SECOND); // Trace start point - FuncA(); - FinishTrace(LABEL); - sleep(SLEEP_TWO_SECOND); - - thread t2(ThreadFunc2); - t2.join(); - - StartTrace(LABEL, "funcBStart", SLEEP_TWO_SECOND); - FuncB(); - FinishTrace(LABEL);// Trace end point - sleep(SLEEP_TWO_SECOND); - - sleep(SLEEP_ONE_SECOND); - FinishTrace(LABEL); - FuncC(); - - return 0; - } - ``` + + ```cpp + int main() + { + thread t1(ThreadFunc1); + t1.join(); + + StartTrace(LABEL, "testStart"); + sleep(SLEEP_ONE_SECOND); + + StartTrace(LABEL, "funcAStart", SLEEP_ONE_SECOND); // Trace start point + FuncA(); + FinishTrace(LABEL); + sleep(SLEEP_TWO_SECOND); + + thread t2(ThreadFunc2); + t2.join(); + + StartTrace(LABEL, "funcBStart", SLEEP_TWO_SECOND); + FuncB(); + FinishTrace(LABEL);// Trace end point + sleep(SLEEP_TWO_SECOND); + + sleep(SLEEP_ONE_SECOND); + FinishTrace(LABEL); + FuncC(); + + return 0; + } + ``` 2. Modify the **base\hiviewdfx\hitrace\cmd\BUILD.gn** file, and start building. - - ``` - ohos_executable("hitrace_example") { - sources = [ "example/hitrace_example.cpp" ] - - external_deps = [ "hitrace_native:hitrace_meter" ] - - subsystem_name = "hiviewdfx" - part_name = "hitrace_native" - } - - group("hitrace_target") { - deps = [ - ":hitrace", - ":hitrace_example", - ] - } - ``` + + ``` + ohos_executable("hitrace_example") { + sources = [ "example/hitrace_example.cpp" ] + + external_deps = [ "hitrace_native:hitrace_meter" ] + + subsystem_name = "hiviewdfx" + part_name = "hitrace_native" + } + + group("hitrace_target") { + deps = [ + ":hitrace", + ":hitrace_example", + ] + } + ``` 3. Place the **hitrace_example** executable file in the **/system/bin** directory of the device, and run the following commands in sequence in the shell: - - ```shell - hitrace --trace_begin ohos - hitrace_exampe - hitrace --trace_dump - ``` - + + ```shell + hitrace --trace_begin ohos + hitrace_exampe + hitrace --trace_dump + ``` + If the expected trace value is present in the trace data, the capture of trace data is successful. For example: - - ``` - <...>-1651 (-------) [002] .... 327.194136: tracing_mark_write: S|1650|H:testAsync 111 - <...>-1650 (-------) [001] .... 332.197640: tracing_mark_write: B|1650|H:testStart - <...>-1650 (-------) [001] .... 333.198018: tracing_mark_write: B|1650|H:funcAStart - <...>-1650 (-------) [001] .... 334.198507: tracing_mark_write: E|1650| - <...>-1654 (-------) [003] .... 341.201673: tracing_mark_write: F|1650|H:testAsync 111 - <...>-1650 (-------) [001] .... 341.202168: tracing_mark_write: B|1650|H:funcBStart - <...>-1650 (-------) [001] .... 343.202557: tracing_mark_write: E|1650| - <...>-1650 (-------) [001] .... 346.203178: tracing_mark_write: E|1650| - <...>-1650 (-------) [001] .... 346.203457: tracing_mark_write: C|1650|H:count number 1 - <...>-1650 (-------) [001] .... 347.203818: tracing_mark_write: C|1650|H:count number 2 - <...>-1650 (-------) [001] .... 348.204207: tracing_mark_write: C|1650|H:count number 3 - <...>-1650 (-------) [001] .... 349.204473: tracing_mark_write: C|1650|H:count number 4 - <...>-1650 (-------) [001] .... 350.204851: tracing_mark_write: C|1650|H:count number 5 - <...>-1655 (-------) [001] .... 365.944658: tracing_mark_write: trace_event_clock_sync: realtime_ts=1502021460925 - <...>-1655 (-------) [001] .... 365.944686: tracing_mark_write: trace_event_clock_sync: parent_ts=365.944641 - ``` - - + + ``` + <...>-1651 (-------) [002] .... 327.194136: tracing_mark_write: S|1650|H:testAsync 111 + <...>-1650 (-------) [001] .... 332.197640: tracing_mark_write: B|1650|H:testStart + <...>-1650 (-------) [001] .... 333.198018: tracing_mark_write: B|1650|H:funcAStart + <...>-1650 (-------) [001] .... 334.198507: tracing_mark_write: E|1650| + <...>-1654 (-------) [003] .... 341.201673: tracing_mark_write: F|1650|H:testAsync 111 + <...>-1650 (-------) [001] .... 341.202168: tracing_mark_write: B|1650|H:funcBStart + <...>-1650 (-------) [001] .... 343.202557: tracing_mark_write: E|1650| + <...>-1650 (-------) [001] .... 346.203178: tracing_mark_write: E|1650| + <...>-1650 (-------) [001] .... 346.203457: tracing_mark_write: C|1650|H:count number 1 + <...>-1650 (-------) [001] .... 347.203818: tracing_mark_write: C|1650|H:count number 2 + <...>-1650 (-------) [001] .... 348.204207: tracing_mark_write: C|1650|H:count number 3 + <...>-1650 (-------) [001] .... 349.204473: tracing_mark_write: C|1650|H:count number 4 + <...>-1650 (-------) [001] .... 350.204851: tracing_mark_write: C|1650|H:count number 5 + <...>-1655 (-------) [001] .... 365.944658: tracing_mark_write: trace_event_clock_sync: realtime_ts=1502021460925 + <...>-1655 (-------) [001] .... 365.944686: tracing_mark_write: trace_event_clock_sync: parent_ts=365.944641 + ``` + + # Using the hitrace CLI Tool @@ -291,71 +270,82 @@ The hitrace CLI tool is an executable binary program. On an OpenHarmony-powered **Table 4** Command list -| Option | Description | -| ------------------------------ | ------------------------------------------------------------ | +| Option | Description | +| ----------------------------- | -------------------------------------------------------- | | -h, --help | Views the help Information. | -| -b *n*, --buffer_size *n* | Sets the buffer size for trace data in KB. The default value is **2048**. | -| -t *n*, --time *n* | Sets the trace uptime in seconds, which depends on the time required for analysis.| -| --trace_clock clock | Sets the type of the clock for adding a timestamp to a trace. The value can be **boot** (default), **global**, **mono**, **uptime**, or **perf**.| -| --trace_begin | Starts capturing trace data. | -| --trace_dump | Dumps trace data to the specified position. The default position is the console. | -| --trace_finish | Stops capturing trace data and dumps trace data to the specified position. The default position is the console. | -| -l, --list_categories | Lists the trace categories supported by the device. | -| --overwrite | Sets the action to take when the buffer is full. If this option is used, the latest trace data is discarded. If this option is not used, the earliest trace data is discarded (default). | -| -o *filename*, --output *filename*| Outputs trace data to the specified file. | -| -z | Compresses the trace data. | +| -b *n*, --buffer_size *n* | Sets the buffer size for trace data in KB. The default value is **2048**. | +| -t *n*, --time *n* | Sets the trace uptime in seconds, which depends on the time required for analysis. | +| --trace_clock clock | Sets the type of the clock for adding a timestamp to a trace. The value can be **boot** (default), **global**, **mono**, **uptime**, or **perf**.| +| --trace_begin | Starts capturing trace data. | +| --trace_dump | Dumps trace data to the specified position. The default position is the console. | +| --trace_finish | Stops capturing trace data and dumps trace data to the specified position. The default position is the console. | +| -l, --list_categories | Lists the trace categories supported by the device. | +| --overwrite | Sets the action to take when the buffer is full. If this option is used, the latest trace data is discarded. If this option is not used, the earliest trace data is discarded (default). | +| -o *filename*, --output *filename*| Outputs trace data to the specified file. | +| -z | Compresses the trace data. | Examples: - Query supported labels. - + ``` + hitrace -l + ``` - - Or, - + + Alternatively, run the following command: + ``` + hitrace --list_categories + ``` - - Trace ability information for 10 seconds and store the trace data in a buffer of 4 MB. - + ``` + hitrace -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace + ``` - - Set the clock type to **mono**. - + ``` + hitrace --trace_clock mono -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace + ``` - - Compress the trace data. - + ``` + hitrace -z -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace + ``` - - + + # FAQs ### Incomplete or Empty Data Captured by hitrace -#### Symptom +#### Symptom + +The data captured by running the hitrace command is incomplete or no data is captured. + +#### **Root Cause** - The data captured by running the hitrace command is incomplete or no data is captured. +The value of **-t** or **-b** buffer is too small, leading to data loss. -#### Solution +#### Solution - Check the value of the **-t** and **-b** parameters. If the value is too small, data loss will occur. You are advised to set **-t** to **60** and **-b** to **204800** to increase the trace capture time and buffer, respectively. +You can set **-t** to **60** and **-b** to **204800** to increase the trace time and buffer size. -# References +# Reference -For details about HiTraceMeter, see [hiviewdfx_hitrace: A Lightweight Distributed Tracing](https://gitee.com/openharmony/hiviewdfx_hitrace). +For details about HiTraceMeter, see [hiviewdfx_hitrace: Lightweight Distributed Tracing](https://gitee.com/openharmony/hiviewdfx_hitrace). diff --git a/en/device-dev/subsystems/subsys-dfx-hiview.md b/en/device-dev/subsystems/subsys-dfx-hiview.md index 52320be5cf9c2ef51c5e92523dcf5f1f387a41a7..7c74963914cde869cc4d6c8e11cddb0383d9c59b 100644 --- a/en/device-dev/subsystems/subsys-dfx-hiview.md +++ b/en/device-dev/subsystems/subsys-dfx-hiview.md @@ -10,7 +10,7 @@ Hiview is a module that provides toolkits for device maintenance across differen **Figure 1** Data interaction between Hiview modules -![Hiview_module_data_interaction](figure/Hiview_module_data_interaction.png) +![Hiview_module_data_interaction](figures/Hiview_module_data_interaction.png) 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. diff --git a/en/device-dev/subsystems/subsys-dfx-overview.md b/en/device-dev/subsystems/subsys-dfx-overview.md index 246375d40c696fc92a4d4a733543c0b3fd231169..b7487c10632d95533a94b29c78a340fbb808d17c 100644 --- a/en/device-dev/subsystems/subsys-dfx-overview.md +++ b/en/device-dev/subsystems/subsys-dfx-overview.md @@ -5,14 +5,16 @@ The DFX subsystem provides the following functions: - HiLog: implements the logging function. It is applicable to mini-system devices \(reference memory ≥ 128 KiB\), small-system devices \(reference memory ≥ 1 MiB\), and standard-system devices \(reference memory ≥ 128 MB\). - - HiTraceChain: implements distributed call chain tracing. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). +- HiTraceMeter: implements performance trace. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). - HiCollie: implements thread suspension detection. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). - HiSysEvent: implements system event logging. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). -- HiChecker: implements defect scanning. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). - HiDumper: exports system information. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). - FaultLogger: implements crash detection. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). - Hiview: implements device maintenance across different platforms. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). +- HiAppEvent and HiChecker are only hap developer oriented。 + +![dfx features overview](figure/dfx-overview.png) ## Basic Concepts diff --git a/en/device-dev/subsystems/subsys-graphics-animation-guide.md b/en/device-dev/subsystems/subsys-graphics-animation-guide.md index 61bc52cbe893b9ac1675b9c9bb0df9b2edbe7de8..884357ad6587d66e8bd4e04d92c98cbc888cad7a 100644 --- a/en/device-dev/subsystems/subsys-graphics-animation-guide.md +++ b/en/device-dev/subsystems/subsys-graphics-animation-guide.md @@ -181,6 +181,6 @@ A UI animator is implemented by calling the callback function you set for each t 4. Click the buttons in the lower part of the following figure to verify that the animation effects are as expected. **Figure 1** Animator effect - ![](figure/animator-effect.gif "animator-effect") + ![](figures/animator-effect.gif "animator-effect") diff --git a/en/device-dev/subsystems/subsys-graphics-common-guide.md b/en/device-dev/subsystems/subsys-graphics-common-guide.md index 72ee8265bce4e34edc5130abfebde78347cdbae9..1f550e4a939a650d3645d9fb8c19d0e93a199999 100644 --- a/en/device-dev/subsystems/subsys-graphics-common-guide.md +++ b/en/device-dev/subsystems/subsys-graphics-common-guide.md @@ -3,7 +3,7 @@ Common components inherit from the base class **UIView**. Child components cannot be added to common components, such as buttons, images, and labels. **Figure 1** Tree structure of common components -![](figure/tree-structure-of-common-components.png "tree-structure-of-common-components") +![](figures/tree-structure-of-common-components.png "tree-structure-of-common-components") **UIView** is a base class of the following components: **UIAbstractProgress**, **UIArcLabel**, **UIButton**, **UICanvas**, **UILabel**, and **UIImageView**. **UIBoxProgress** and **UICircleProgress** inherit from **UIAbstractProgress**. **UILabelButton** and **UIRepeatButton** inherit from **UIButton**. **UIImageAnimatorView** and **UITextureMapper** inherit from **UIImageView**. @@ -107,7 +107,7 @@ Common components inherit from the base class **UIView**. Child components cann 4. Verify that the button is clicked and its size increases gradually, as shown in the following figure. **Figure 2** Effect of clicking a **UIButton** - ![](figure/effect-of-clicking-a-uibutton.gif "effect-of-clicking-a-uibutton") + ![](figures/effect-of-clicking-a-uibutton.gif "effect-of-clicking-a-uibutton") ## UIImageView @@ -193,7 +193,7 @@ Common components inherit from the base class **UIView**. Child components cann 3. Verify that the **UIImageView** component is adaptive to the image. **Figure 3** Image auto-adaption effect - ![](figure/image-auto-adaption-effect.png "image-auto-adaption-effect") + ![](figures/image-auto-adaption-effect.png "image-auto-adaption-effect") ## How to Develop \(Tile Mode\) @@ -221,7 +221,7 @@ Common components inherit from the base class **UIView**. Child components cann 4. Verify that the tile mode has been enabled for the **UIImageView**. **Figure 4** Image tile effect - ![](figure/image-tile-effect.png "image-tile-effect") + ![](figures/image-tile-effect.png "image-tile-effect") ## UILabel @@ -379,7 +379,7 @@ Common components inherit from the base class **UIView**. Child components cann 4. Verify the label size and display effect, as shown in the following figure. - ![](figure/en-us_image_0000001051782526.png) + ![](figures/en-us_image_0000001051782526.png) ## How to Develop \(Background Color and Opacity\) @@ -408,7 +408,7 @@ Common components inherit from the base class **UIView**. Child components cann 4. Verify that the background color of the label is **Gray**, as shown in the following figure. - ![](figure/en-us_image_0000001052582522.png) + ![](figures/en-us_image_0000001052582522.png) ## How to Develop \(Letter Spacing\) @@ -437,7 +437,7 @@ Common components inherit from the base class **UIView**. Child components cann 4. Verify that the letter spacing is **5** pixels on the label, as shown in the following figure. - ![](figure/en-us_image_0000001052942531.png) + ![](figures/en-us_image_0000001052942531.png) ## How to Develop \(Size-Adaptive Mode\) @@ -468,7 +468,7 @@ Regarding too long text, the size of a label can be automatically adjusted based 4. Verify that the label size adapts to the text, as shown in the following figure. - ![](figure/en-us_image_0000001052782555.png) + ![](figures/en-us_image_0000001052782555.png) ## How to Develop \(Ellipsis Mode\) @@ -499,7 +499,7 @@ In ellipsis mode, an ellipsis \(...\) is displayed at the end of the label if 4. Verify that the ellipsis mode has taken effect on the label, as shown in the following figure. - ![](figure/en-us_image_0000001052662559.png) + ![](figures/en-us_image_0000001052662559.png) ## How to Develop \(Scrolling Mode\) @@ -531,6 +531,6 @@ In scrolling mode, long text is kept scrolling on a screen to bring the entire t 4. Verify that the text is scrolling on the label, as shown in the following figure. - ![](figure/20200721-223604(espace).gif) + ![](figures/20200721-223604(espace).gif) diff --git a/en/device-dev/subsystems/subsys-graphics-container-guide.md b/en/device-dev/subsystems/subsys-graphics-container-guide.md index 90fd506671fe1fcd416a8e8f79d20bb148a923d6..3599789f6a9eb6ae22fc109371bb1c12ebd33c97 100644 --- a/en/device-dev/subsystems/subsys-graphics-container-guide.md +++ b/en/device-dev/subsystems/subsys-graphics-container-guide.md @@ -3,7 +3,7 @@ Container components are capable of containing UI components and inherit from **UIViewGroup**. Components that are commonly used and need to contain child components are placed in the container class inheritance structure. For example, you need to call the **Add** function to add information such as time statistics and icons to **UIAnalogClock**. **Figure 1** Structure of common container components -![](figure/structure-of-common-container-components.png "structure-of-common-container-components") +![](figures/structure-of-common-container-components.png "structure-of-common-container-components") The **RootView**, **UIAbstractScroll**, and **UIPicker** components inherit from **UIViewGroup**, and the **UIList**, **UIScrollView**, and **UISwipeView** components inherit from **UIAbstractScroll**. @@ -14,7 +14,7 @@ The **RootView**, **UIAbstractScroll**, and **UIPicker** components inherit **UIViewGroup** is a base class for container components. For example, you can call the functions in this class to add, remove, and insert container components. Also, you can call the **Add** function to add child components for a container component. You need to set the position information for child components in a common container component. The position information is the coordinates relative to those of their parent component. The following figure shows the tree structure of components. **Figure 2** Component tree structure -![](figure/component-tree-structure.png "component-tree-structure") +![](figures/component-tree-structure.png "component-tree-structure") As shown in the figure, the container component **ViewGroup1** and the component **View1** are added to **RootView**, the component **View2** and the container component **ViewGroup2** are added to **ViewGroup1**, and then the component **View3** \(as a sibling of **View1**\) is also added to **ViewGroup1**. @@ -117,7 +117,7 @@ As shown in the figure, the container component **ViewGroup1** and the compone 4. The following figure shows the effect of adding view instances to a **ViewGroup**. **Figure 3** Effect of adding view instances to a ViewGroup - ![](figure/effect-of-adding-view-instances-to-a-viewgroup.png "effect-of-adding-view-instances-to-a-viewgroup") + ![](figures/effect-of-adding-view-instances-to-a-viewgroup.png "effect-of-adding-view-instances-to-a-viewgroup") ## UIScrollView @@ -231,5 +231,5 @@ scroll->Add(button2); ``` **Figure 4** Scrolling effect in both horizontal and vertical directions -![](figure/scrolling-effect-in-both-horizontal-and-vertical-directions.gif "scrolling-effect-in-both-horizontal-and-vertical-directions") +![](figures/scrolling-effect-in-both-horizontal-and-vertical-directions.gif "scrolling-effect-in-both-horizontal-and-vertical-directions") diff --git a/en/device-dev/subsystems/subsys-graphics-layout-guide.md b/en/device-dev/subsystems/subsys-graphics-layout-guide.md index 404af81512dcf14f7b84596a6b6a3d6dd6bbd41c..f0d19d5b29ebb68b9da78ab8b6556b20fc1c76c8 100644 --- a/en/device-dev/subsystems/subsys-graphics-layout-guide.md +++ b/en/device-dev/subsystems/subsys-graphics-layout-guide.md @@ -87,7 +87,7 @@ Layout container components consist of basic view classes. You can set the view **Figure 1** Horizontal swiping effect of **UISwipeView** - ![](figure/en-us_image_0000001053247975.gif) + ![](figures/en-us_image_0000001053247975.gif) ## Development Procedure \(Cyclic Horizontal Swiping\) @@ -121,7 +121,7 @@ Layout container components consist of basic view classes. You can set the view **Figure 2** Cyclic horizontal swiping effect of **UISwipeView** - ![](figure/en-us_image_0000001053207924.gif) + ![](figures/en-us_image_0000001053207924.gif) ## GridLayout @@ -201,6 +201,6 @@ Layout container components consist of basic view classes. You can set the view 4. Verify the layout of buttons, as shown in the following figure. **Figure 3** Setting a 2x2 grid and adding four buttons in a layout - ![](figure/setting-a-2x2-grid-and-adding-four-buttons-in-a-layout.png "setting-a-2x2-grid-and-adding-four-buttons-in-a-layout") + ![](figures/setting-a-2x2-grid-and-adding-four-buttons-in-a-layout.png "setting-a-2x2-grid-and-adding-four-buttons-in-a-layout") diff --git a/en/device-dev/subsystems/subsys-multimedia-camera-overview.md b/en/device-dev/subsystems/subsys-multimedia-camera-overview.md index b0f7fdeefa3823bbb3d199321ea2fb6412834c1b..34f8ddb97762ff4c28bc609d9505af457b329018 100644 --- a/en/device-dev/subsystems/subsys-multimedia-camera-overview.md +++ b/en/device-dev/subsystems/subsys-multimedia-camera-overview.md @@ -97,7 +97,7 @@ It is considered good practice that you understand the following concepts before **Figure 1** Sequence diagram for creating a camera - ![](figure/en-us_image_0000001054101094.png) + ![](figures/en-us_image_0000001054101094.png) 1. Taking a video/Previewing @@ -106,7 +106,7 @@ It is considered good practice that you understand the following concepts before **Figure 2** Sequence diagram for recording/previewing - ![](figure/en-us_image_0000001054421113.png) + ![](figures/en-us_image_0000001054421113.png) diff --git a/en/device-dev/subsystems/subsys-power-brightness-customization.md b/en/device-dev/subsystems/subsys-power-brightness-customization.md new file mode 100644 index 0000000000000000000000000000000000000000..75604d60d5495105a380899d0815c4cc8f2b0098 --- /dev/null +++ b/en/device-dev/subsystems/subsys-power-brightness-customization.md @@ -0,0 +1,191 @@ +# System Brightness Customization + +## Overview + +### Introduction + +By default, the system brightness of OpenHarmony ranges from **0** to **255** (**0** indicates the minimum luminance and **255** the maximum). It is applicable to the entire system and all application windows. Due to hardware restrictions, some display devices are unable to support the system brightness range. To address this issue, OpenHarmony provides the function of customizing the system brightness range. This way, you can adjust the system brightness range based on the hardware specifications of the display devices. + +### Basic Concepts + +**System brightness** +Global brightness of OpenHarmony. The customized brightness range is effective for all application windows. + +**Window brightness** +Brightness of an application window. The customized brightness range is effective only for this application window. After a brightness is specified for an application window, its brightness is not affected by the system brightness. + +### Constraints + +The [sysparam](./subsys-boot-init-sysparam.md) module of OpenHarmony provides an easy-to-use key-value pair access interface for system services to configure service functions based on their own system parameters. The customization of the system brightness range is dependent on this feature. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/Readme-EN.md). + +### How to Develop + +1. In the target directory, create a target folder by referring to the [default brightness value configuration folder](https://gitee.com/openharmony/powermgr_display_manager/tree/master/service/etc). The file format is as follows: + + ```text + etc + ├── BUILD.gn + ├── display.para + ├── display.para.dac + ``` + +2. Write the customized **display.para** file by referring to the [**display.para** file](https://gitee.com/openharmony/powermgr_display_manager/blob/master/service/etc/display.para) in the default brightness range configuration folder. Include the customized brightness thresholds, for example, **max=150**, **default=75**, and **min=50**, into the file: + + ```shell + # Brightness limits is 0-255. + const.display.brightness.min=50 + const.display.brightness.default=75 + const.display.brightness.max=150 + ``` + +3. Write the customized **display.para.dac** file by referring to the [**display.para.dac** file](https://gitee.com/openharmony/powermgr_display_manager/blob/master/service/etc/display.para.dac) in the default brightness range configuration folder, so as to grant the permission required to access the customized configuration. + + ```shell + const.display.brightness.="foundation:foundation:444" + ``` + +4. Write the customized **BUILD.gn** file by referring to the [**BUILD.gn** file](https://gitee.com/openharmony/powermgr_display_manager/blob/master/service/etc/BUILD.gn) in the default brightness range configuration folder. Then, put the **display.para** and **display.para.dac** files to the **/vendor/etc/param** directory. For example: + + ```shell + import("//base/powermgr/display_manager/displaymgr.gni") + import("//build/ohos.gni") + + ## Install display.para to /vendor/etc/param/display.para + ohos_prebuilt_etc("display.para") { + source = "display.para" + relative_install_dir = "param" + install_images = [ chipset_base_dir ] + part_name = "${displaymgr_part_name}" + subsystem_name = "powermgr" + } + + ohos_prebuilt_etc("display.para.dac") { + source = "display.para.dac" + relative_install_dir = "param" + install_images = [ chipset_base_dir ] + part_name = "${displaymgr_part_name}" + subsystem_name = "powermgr" + } + + group("param_files") { + deps = [ + ":display.para", + ":display.para.dac", + ] + } + ``` + +5. Write the customized **bundle.json** file by referring to the [**bundle.json** file](https://gitee.com/openharmony/powermgr_display_manager/blob/master/bundle.json) in the default brightness range configuration folder, so as to compile the **BUILD.gn** file. + + ```shell + "service_group": [ "//base/powermgr/display_manager/service/etc:param_files" ] + ``` + In the preceding code, **//base/powermgr/display_manager/service** indicates the directory of the created folder, and **etc** indicates the folder name. + +6. Build the customized version by referring to [Quick Start](../quick-start/Readme-EN.md). The following command uses DAYU200 as an example: + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +7. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + +1. After startup, run the following command to launch the shell command line: + + ```shell + hdc shell + ``` + +2. Run the following command to check the console output: + + ```shell + hidumper -s 3308 -a -a + ``` + +3. Check the console output for the customized system brightness thresholds. + + The default system brightness thresholds are as follows: + + ```shell + ----------------------------------DisplayPowerManagerService--------------------------------- + DISPLAY POWER MANAGER DUMP: + Display Id=0 State=2 Discount=1.000000 Brightness=102 + DeviceBrightness=102 + Support Ambient Light: FALSE + Auto Adjust Brightness: OFF + Brightness Limits: Max=255 Min=5 Default=102 + + ``` + + Assume that the system brightness thresholds are set to **Max=150 Min=50 Default=75**. The console output is as follows: + + ```shell + # cd vendor/etc/param + # ls + display.para thermal.para usb.para.dac + display.para.dac thermal.para.dac + # cat display.para + # Copyright (C) 2022 Huawei Device Co., Ltd. + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + + # Brightness limits is 0-255. + const.display.brightness.min=50 + const.display.brightness.default=75 + const.display.brightness.max=150# + # + # cd + # hidumper -s 3308 -a -a + + -------------------------------[ability]------------------------------- + + + ----------------------------------DisplayPowerManagerService--------------------------------- + DISPLAY POWER MANAGER DUMP: + Display Id=0 State=0 Discount=1.000000 Brightness=75 + DeviceBrightness=75 + Support Ambient Light: FALSE + Auto Adjust Brightness: OFF + Brightness Limits: Max=150 Min=50 Default=75 + + ``` + +4. Set the system brightness thresholds to the customized values. + +## Reference + +For details about how to write the configuration file during system brightness customization, refer to the [default brightness range configuration file](https://gitee.com/openharmony/powermgr_display_manager/tree/master/service/etc). + +Default configuration: + +```shell +# Brightness limits is 0-255. +const.display.brightness.min=5 +const.display.brightness.default=102 +const.display.brightness.max=255 +``` + +Packing directory: /system/etc/param diff --git a/en/device-dev/subsystems/subsys-security-devicesecuritylevel.md b/en/device-dev/subsystems/subsys-security-devicesecuritylevel.md index 29a6b604fe0e6a736ed7a0116a1f1c03856b0664..6753e3476d17806be72cb141a25344f04a790591 100644 --- a/en/device-dev/subsystems/subsys-security-devicesecuritylevel.md +++ b/en/device-dev/subsystems/subsys-security-devicesecuritylevel.md @@ -16,11 +16,11 @@ The Device Security Level Management (DSLM) module is introduced to manage the s The following figure shows the OpenHarmony security architecture. - ![OpenHarmony system security architecture](figure/ohos_system_security_architecture.png) + ![OpenHarmony system security architecture](figures/ohos_system_security_architecture.png) The above figure shows the typical security architecture for a single device. The architecture may vary depending on the risk level as well as the software and hardware resources of the device. The security capabilities of OpenHarmony devices are classified into five levels from SL1 to SL5, based on the industry standard security classification model and actual OpenHarmony service scenarios and device types. In the OpenHarmony ecosystem, higher security levels include all the capabilities of lower security levels by default. The figure below shows the security levels of OpenHarmony devices. - ![OpenHarmony device security levels](figure/ohos_device_security_level.png) + ![OpenHarmony device security levels](figures/ohos_device_security_level.png) - SL1: SL1 is the lowest security level of OpenHarmony devices. Usually equipped with a lightweight operating system and low-end microprocessors, such devices implement simple services and do not need to process sensitive data. SL1 devices are required to support software integrity protection and eliminate common errors. Devices that cannot meet the requirements of SL1 can only be controlled by OpenHarmony devices. They cannot control OpenHarmony devices for more complex service collaboration. diff --git a/en/device-dev/subsystems/subsys-security-huks-guide.md b/en/device-dev/subsystems/subsys-security-huks-guide.md index f88fdaa1e0907183a518790f47b29e5688d9611d..dcd6d6e0a01d1b5a3321ed3ce14893dc2382dc97 100644 --- a/en/device-dev/subsystems/subsys-security-huks-guide.md +++ b/en/device-dev/subsystems/subsys-security-huks-guide.md @@ -43,7 +43,7 @@ HUKS supports key lifecycle management, which covers the following: The following uses the key generation process as an example to describe communication between the HUKS Service and HUKS Core. Other key operations are similar. The upper-layer application invokes the HUKS Service through the key management SDK. The HUKS Service invokes the HUKS Core, which invokes the key management module to generate a key. The HUKS Core uses a work key derived from the root key to encrypt the generated key and sends the encrypted key to the HUKS Service. The HUKS Service stores the encrypted key in a file. -![](figure/HUKS-GenerateKey1.png) +![](figures/HUKS-GenerateKey1.png) ### Constraints @@ -51,13 +51,13 @@ The upper-layer application invokes the HUKS Service through the key management * The certificate chain returned by **HuksHdiAttestKey** must be in the sequence of the application certificate, device certificate, CA certificate, and root certificate, with the certificate length added before each certificate. The certificate chain and its length are assembled in the binary large object (BLOB) format. If you want to define the certificate format, the format must be the same as that parsed by the server. -![CertChain format](figure/HUKS-CertChain.png) +![CertChain format](figures/HUKS-CertChain.png) * The key returned by the API must be assembled into a **KeyBlob** based on the key storage status. For details about the APIs that must comply with this constraint, see [Available APIs](#available-apis). The **KeyBlob** stores both the key and its attributes. The figure below shows the **KeyBlob** structure. For details about how to construct a **KeyBlob**, see [hks_keyblob.c/HksBuildKeyBlob](https://gitee.com/openharmony/security_huks/blob/master/services/huks_standard/huks_engine/main/core/src/hks_keyblob.c). -![KeyBlob format](figure/HUKS-KeyBlob.png) +![KeyBlob format](figures/HUKS-KeyBlob.png) ## Development Guidelines diff --git a/en/device-dev/subsystems/subsys-security-sigverify.md b/en/device-dev/subsystems/subsys-security-sigverify.md index d2d735f7f7dd2a999a17cab786bc5b0eef6cf8a8..9ba1b9f5532b3f3ac9a9e158f9abd7df79f05c88 100644 --- a/en/device-dev/subsystems/subsys-security-sigverify.md +++ b/en/device-dev/subsystems/subsys-security-sigverify.md @@ -14,7 +14,7 @@ An unsigned HAP is in **.zip** format and consists of a file block, central di After the HAP is signed, a signature block is added between the file block and the central directory. The integrated signature block consists of a profile signature block, HAP signature block, and signature header. The following figure shows the structure of a signed HAP. **Figure 1** Structure of a signed HAP -![](figure/structure-of-a-signed-hap.png "structure-of-a-signed-hap") +![](figures/structure-of-a-signed-hap.png "structure-of-a-signed-hap") The signature verification process consists of three steps: HAP signature verification, profile signature verification, and profile content verification. diff --git a/en/device-dev/subsystems/subsys-sensor-overview.md b/en/device-dev/subsystems/subsys-sensor-overview.md index 91a8187098ba32d0c7e841f06568947ffaa26b4f..0c3ab60e0ed269efe41eb9fa6ca894053449669a 100644 --- a/en/device-dev/subsystems/subsys-sensor-overview.md +++ b/en/device-dev/subsystems/subsys-sensor-overview.md @@ -7,7 +7,7 @@ The pan-sensor service subsystem provides a lightweight sensor service framework **Figure 1** Sensor service framework - ![](figure/en-us_image_0000001077724150.png) + ![](figures/en-us_image_0000001077724150.png) - 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. diff --git a/en/device-dev/subsystems/subsys-tel-guide.md b/en/device-dev/subsystems/subsys-tel-guide.md index 9ddc0393b11c42349822e2dbd1d30d8875d848c4..eb3bc7fcc9b0e6d9c7dbca1e9fe5a0fd9152f6f7 100644 --- a/en/device-dev/subsystems/subsys-tel-guide.md +++ b/en/device-dev/subsystems/subsys-tel-guide.md @@ -379,7 +379,7 @@ The following table describes the API for reporting modem events. **Figure 1** Time sequence of API calling for an outgoing call - ![](figure/en-us_image_0000001171507146.png) + ![](figures/en-us_image_0000001171507146.png) When an application initiates an outgoing call, RIL Adapter receives a call request, and the **hril** layer invokes the **ReqDial\(\)** function. In **ReqDial\(\)**, the data passed by the Telephony Service is encapsulated as an AT command and sent to the modem. After executing the dial command, the modem reports the execution result to RIL Adapter through **OnCallReport\(\)**. @@ -458,7 +458,7 @@ The following table describes the API for reporting modem events. **Figure 2** Time sequence of API calling for an incoming call - ![](figure/en-us_image_0000001214727595.png) + ![](figures/en-us_image_0000001214727595.png) The **g\_reader** thread cyclically reads the messages reported by the modem. When the modem receives an incoming call event, it actively reports the information about the incoming call. diff --git a/en/device-dev/subsystems/subsys-tel-overview.md b/en/device-dev/subsystems/subsys-tel-overview.md index 7ee561e36b48430058d26bae3ed4157d0ded9a6e..9bbe0d655058ad473bc085d6adbf91238778ae5a 100644 --- a/en/device-dev/subsystems/subsys-tel-overview.md +++ b/en/device-dev/subsystems/subsys-tel-overview.md @@ -20,7 +20,7 @@ This document provides development guidelines related to the telephony subsystem **Figure 1** RIL Adapter architecture -![](figure/en-us_image_0000001210683929.png) +![](figures/en-us_image_0000001210683929.png) As shown in the preceding figure, RIL Adapter is logically divided into three layers: **hril\_hdf**, **hril**, and **vendorlib**. diff --git a/en/device-dev/subsystems/subsys-usbservice-overview.md b/en/device-dev/subsystems/subsys-usbservice-overview.md index 8981a02b997f2946b9cacdec98a087a4729da6eb..e4cc9c9ccd95ee4f8d72f949b778360cae860c1a 100644 --- a/en/device-dev/subsystems/subsys-usbservice-overview.md +++ b/en/device-dev/subsystems/subsys-usbservice-overview.md @@ -29,7 +29,7 @@ USB devices are classified into two types: USB host and USB device. On OpenHarmo The USB subsystem logically consists of three parts: USB API, USB Service, and USB HAL. The following figure shows how the USB service is implemented. **Figure 1** USB service architecture - ![USB service architecture](figure/en-us_image_0000001267088285.png) + ![USB service architecture](figures/en-us_image_0000001267088285.png) - USB API: provides USB APIs that implement various basic functions, for example, query of the USB device list, bulk data transfer, control transfer, and right management. diff --git a/en/readme/ai.md b/en/readme/ai.md index 83aa9a2381963c295ba1d54375c98117dff307fc..409bfb226eab0208354adaf65b6a03bda5a99c69 100644 --- a/en/readme/ai.md +++ b/en/readme/ai.md @@ -36,7 +36,7 @@ The AI subsystem is the part of OpenHarmony that provides native distributed AI * **Programming language**: C/C++ -* **Operating system**: OpenHarmony +* **Operating system**: OpenHarmony mini- and small-system * **Others**: The System Ability Manager \(Samgr\) has been started and is running properly. @@ -314,9 +314,7 @@ The AI subsystem is the part of OpenHarmony that provides native distributed AI } ``` -4. Develop a sample application. For details, see the [keyword spotting demo](https://gitee.com/openharmony/applications_sample_camera/tree/master/ai). - - Directory: //applications/sample/camera/ai/asr/keyword\_spotting +4. Develop a sample application. Call the **Create** API. diff --git a/en/readme/kernel.md b/en/readme/kernel.md index 752b237edbcd39c18862cae44cb97707846e22f8..e5067ef2bb218ecc970c5f2aaf5cdcec9b546230 100644 --- a/en/readme/kernel.md +++ b/en/readme/kernel.md @@ -219,6 +219,4 @@ Linux: [kernel\_linux\_build](https://gitee.com/openharmony/kernel_linux_build/blob/master/README.md) -[kernel\_linux\_4.19](https://gitee.com/openharmony/kernel_linux_4.19/blob/master/README) - [kernel\_linux\_5.10](https://gitee.com/openharmony/kernel_linux_5.10/blob/master/README) diff --git a/en/readme/network-management.md b/en/readme/network-management.md index 08e5ae88a87a5423efbf05bdf78a818c1ad7dc31..ac7fe63d43054c0badb2fa4d5de27dd117f31022 100644 --- a/en/readme/network-management.md +++ b/en/readme/network-management.md @@ -36,6 +36,8 @@ foundation/communication/ 4. Call **conn.register()** to subscribe to network status changes of the specified network. +5. When the network is available, the callback will be invoked to return the **netAvailable** event. + 6. Call **conn.unregister()** to unsubscribe from the network status changes if required. ``` @@ -43,9 +45,9 @@ foundation/communication/ import connection from '@ohos.net.connection' let netCap = { - // Set the network type to cellular network. + // Set the network type to CELLULAR. bearerTypes: [connection.NetBearType.BEARER_CELLULAR], - // Set the network capability to Internet. + // Set the network capability to INTERNET. networkCap: [connection.NetCap.NET_CAPABILITY_INTERNET], }; let netSpec = { @@ -55,7 +57,7 @@ foundation/communication/ let timeout = 10 * 1000; // Create a NetConnection object. let conn = connection.createNetConnection(netSpec, timeout); - // Subscribe to the netAvailable event. When the network is available, the callback will be invoked to report the event. + // Subscribe to the netAvailable event. conn.on('netAvailable', (data=> { console.log("net is available, netId is " + data.netId); })); @@ -67,16 +69,12 @@ foundation/communication/ ### Sharing a Network -1. Import the network sharing namespace from **@ohos.net.sharing**. - +1. Import the **sharing** namespace from **@ohos.net.sharing**. 2. Set the network sharing type. - 3. Start network sharing. - 4. Stop network sharing. - ``` -// Import the network sharing namespace. +// Import the connection namespace. import sharing from '@ohos.net.sharing'; // Set the network sharing type. this.sharingType = 0; // The value 0 indicates Wi-Fi, 1 indicates USB, and 2 indicates Bluetooth. @@ -92,33 +90,30 @@ sharing.stopSharing(this.sharingType,(err)=>{ ### Initiating a Network Request -1. Import the HTTP namespace from **@ohos.net.http.d.ts**. - +1. Import the **http** namespace from **@ohos.net.http.d.ts**. 2. Call **createHttp()** to create an **HttpRequest** object. - -3. Call **httpRequest.on()** to subscribe to an HTTP response header. This method returns a response earlier than the request. You can subscribe to HTTP response header events based on service requirements. - +3. Call **httpRequest.on()** to subscribe to HTTP response header events. This API returns a response earlier than the request. You can subscribe to HTTP response header events based on service requirements. 4. Call **httpRequest.request()** to initiate a network request. You need to pass in the URL and optional parameters of the HTTP request. - 5. Parse the returned result based on service requirements. - -6. Call **httpRequest.destroy()** to release resources after the request is processed. +6. Call **off()** to unsubscribe from HTTP response header events. +7. Call **httpRequest.destroy()** to release resources after the request is processed. ``` -// Import the HTTP namespace. +// Import the http namespace. import http from '@ohos.net.http'; -// Each httpRequest corresponds to an HttpRequestTask object and cannot be reused. +// Each httpRequest corresponds to an HTTP request task and cannot be reused. let httpRequest = http.createHttp(); -// Subscribe to the HTTP response header, which is returned earlier than the response to httpRequest. -httpRequest.on('headersReceive', (data) => { - console.info('header: ' + data.header); +// This API is used to listen for the HTTP Response Header event, which is returned earlier than the result of the HTTP request. It is up to you whether to listen for HTTP Response Header events. +// 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 for the httpRequest. You must specify the URL address, and set httpRequestOptions as required. You can specify the parameters for GET in extraData. + // Customize EXAMPLE_URL in extraData on your own. It is up to you whether to add parameters to the URL. "EXAMPLE_URL", { - method: 'POST', // Optional. The default value is GET. + method: http.RequestMethod.POST, // Optional. The default value is http.RequestMethod.GET. // You can add header fields based on service requirements. header: { 'Content-Type': 'application/json' @@ -127,21 +122,28 @@ httpRequest.request( extraData: { "data": "data to send", }, - connectTimeout: 60000, // This parameter is optional. The default value is 60000, that is, 60s. - readTimeout: 60000, // This parameter is optional. The default value is 60000, that is, 60s. - },(err, data) => { + expectDataType: http.HttpDataType.STRING, // Optional. This field specifies the type of the return data. + usingCache: true, // Optional. The default value is true. + priority: 1, // Optional. The default value is 1. + connectTimeout: 60000 // Optional. The default value is 60000, in ms. + readTimeout: 60000, // Optional. The default value is 60000, in ms. + usingProtocol: http.HttpProtocol.HTTP1_1, // Optional. The default protocol type is automatically specified by the system. + usingProxy: false, // Optional. By default, network proxy is not used. This field is supported since API 10. + }, (err, data) => { if (!err) { // data.result carries the HTTP response. Parse the response based on service requirements. - console.info('Result:' + data.result); - console.info('code:' + data.responseCode); + console.info('Result:' + JSON.stringify(data.result)); + console.info('code:' + JSON.stringify(data.responseCode)); // data.header carries the HTTP response header. Parse the content based on service requirements. - console.info('header:' + data.header); - console.info('header:' + data.cookies); + console.info('header:' + JSON.stringify(data.header)); + console.info('cookies:' + JSON.stringify(data.cookies)); // 8+ } else { - console.info('error:' + err); + console.info('error:' + JSON.stringify(err)); + // Unsubscribe from HTTP Response Header events. + httpRequest.off('headersReceive'); + // Call the destroy() method to release resources after HttpRequest is complete. + httpRequest.destroy(); } - // Call destroy() to release resources after HttpRequest is complete. - httpRequest.destroy(); } ); ``` @@ -150,8 +152,6 @@ httpRequest.request( **Network Management Subsystem** -[communication_netmanager_base](https://gitee.com/openharmony/communication_netmanager_base) - -[communication_netmanager_ext](https://gitee.com/openharmony/communication_netmanager_ext) - -[communication_netstack](https://gitee.com/openharmony/communication_netstack) \ No newline at end of file +[communication_netmanager_base](https://gitee.com/openharmony/communication_netmanager_base/blob/master/README_zh.md) +[communication_netmanager_ext](https://gitee.com/openharmony/communication_netmanager_ext/blob/master/README_zh.md) +[communication_netstack](https://gitee.com/openharmony/communication_netstack/blob/master/README_zh.md) diff --git a/en/release-notes/api-diff/v3.1-Release/js-apidiff-compiler-and-runtime.md b/en/release-notes/api-diff/v3.1-Release/js-apidiff-compiler-and-runtime.md index 13aebd5b337cdf7f6a39b7875350651fffc2bd19..a12696e85e9fc429d76a30fb3947d21d8b9d3b48 100644 --- a/en/release-notes/api-diff/v3.1-Release/js-apidiff-compiler-and-runtime.md +++ b/en/release-notes/api-diff/v3.1-Release/js-apidiff-compiler-and-runtime.md @@ -1,6 +1,6 @@ -# JS API Changes of the Utils Subsystem +# JS API Changes of the Compiler and Runtime Subsystem -The table below lists the APIs changes of the Utils subsystem in OpenHarmony 3.1 Release over OpenHarmony 3.0 LTS. +The table below lists the APIs changes of the compiler and runtime subsystem in OpenHarmony 3.1 Release over OpenHarmony 3.0 LTS. ## API Changes diff --git a/en/release-notes/api-diff/v3.2-beta2/js-apidiff-compiler-and-runtime.md b/en/release-notes/api-diff/v3.2-beta2/js-apidiff-compiler-and-runtime.md index e865832eebbb0b34ee233e5974a3757cb74a527e..2d8a2f24d0817d374462a298110a33cfefa7f55e 100644 --- a/en/release-notes/api-diff/v3.2-beta2/js-apidiff-compiler-and-runtime.md +++ b/en/release-notes/api-diff/v3.2-beta2/js-apidiff-compiler-and-runtime.md @@ -1,6 +1,6 @@ -# JS API Changes of the Utils Subsystem +# JS API Changes of the Compiler and Runtime Subsystem -The table below lists the APIs changes of the Utils subsystem in OpenHarmony 3.2 Beta2 over OpenHarmony 3.2 Beta1. +The table below lists the APIs changes of the compiler and runtime subsystem in OpenHarmony 3.2 Beta2 over OpenHarmony 3.2 Beta1. ## API Changes diff --git a/en/release-notes/api-diff/v3.2-beta3/Readme-EN.md b/en/release-notes/api-diff/v3.2-beta3/Readme-EN.md index caa19c0d47f00a067d0166fe1c59b04a35601899..42a3798286203c9d711723df4d1b1e8f3e1a99aa 100644 --- a/en/release-notes/api-diff/v3.2-beta3/Readme-EN.md +++ b/en/release-notes/api-diff/v3.2-beta3/Readme-EN.md @@ -10,7 +10,7 @@ This directory records the API changes in OpenHarmony 3.2 Beta3 over OpenHarmony - [Power management subsystem](js-apidiff-battery.md) - [Bundle management framework](js-apidiff-bundle.md) - [Communication subsystem](js-apidiff-communicate.md) - - [Utils subsystem](js-apidiff-compiler-and-runtime.md) + - [Compiler and runtime subsystem](js-apidiff-compiler-and-runtime.md) - [DFX subsystem](js-apidiff-dfx.md) - [Distributed data management subsystem](js-apidiff-distributed-data.md) - [Distributed hardware subsystem](js-apidiff-distributed-hardware.md) diff --git a/en/release-notes/api-diff/v3.2-beta3/js-apidiff-compiler-and-runtime.md b/en/release-notes/api-diff/v3.2-beta3/js-apidiff-compiler-and-runtime.md index 3c1957aff039872d58115413ad1b216a9ff77424..3510e655cb337008b29c8ecc66b743bf96629ac5 100644 --- a/en/release-notes/api-diff/v3.2-beta3/js-apidiff-compiler-and-runtime.md +++ b/en/release-notes/api-diff/v3.2-beta3/js-apidiff-compiler-and-runtime.md @@ -1,6 +1,6 @@ -# JS API Changes of the Utils Subsystem +# JS API Changes of the Compiler and Runtime Subsystem -The table below lists the APIs changes of the Utils subsystem in OpenHarmony 3.2 Beta3 over OpenHarmony 3.2 Beta2. +The table below lists the APIs changes of the compiler and runtime subsystem in OpenHarmony 3.2 Beta3 over OpenHarmony 3.2 Beta2. ## API Changes diff --git a/en/release-notes/api-diff/v3.2-beta4/Readme-EN.md b/en/release-notes/api-diff/v3.2-beta4/Readme-EN.md index 945501b129f35e4e2e6e5ab5ae12e2326eb97dba..e6788c41190e1a5c0d4f6a274e4dd4fb6901a727 100644 --- a/en/release-notes/api-diff/v3.2-beta4/Readme-EN.md +++ b/en/release-notes/api-diff/v3.2-beta4/Readme-EN.md @@ -9,7 +9,7 @@ - [Power management subsystem](js-apidiff-battery.md) - [Bundle management framework](js-apidiff-bundle.md) - [Communication subsystem](js-apidiff-communication.md) - - [Utils subsystem](js-apidiff-compiler-and-runtime.md) + - [Compiler and runtime subsystem](js-apidiff-compiler-and-runtime.md) - [Customization subsystem](js-apidiff-customization.md) - [DFX subsystem](js-apidiff-dfx.md) - [Distributed data management subsystem](js-apidiff-distributed-data.md) diff --git a/en/release-notes/changelogs/OpenHarmony_3.2.10.1/changelogs-url.md b/en/release-notes/changelogs/OpenHarmony_3.2.10.1/changelogs-url.md index 76b0bf08104a53dfb2d943ae3a860bfc76111dc1..c5f219a9dca53926c131a4bf36e17122e2b47cce 100644 --- a/en/release-notes/changelogs/OpenHarmony_3.2.10.1/changelogs-url.md +++ b/en/release-notes/changelogs/OpenHarmony_3.2.10.1/changelogs-url.md @@ -1,9 +1,10 @@ -# Utils Subsystem Changelog +# Common Library Subsystem Changelog -Compared with OpenHarmony 3.2 Beta4, OpenHarmony 3.2.10.1(MR) has the following API changes in the URL module of the utils subsystem. +Compared with OpenHarmony 3.2 Beta4, OpenHarmony 3.2.10.1(MR) has the following API changes in the URL module of the common library subsystem. ## cl.commonlibrary.1 URLParams Class Changes -The constructor function of the **URLParams** class in the URL module of the utils subsystem is changed. + +The constructor function of the **URLParams** class in the URL module of the common library subsystem is changed. Specifically, **constructor(init?: string[][] | Record | string | URLSearchParams)** is changed to **constructor(init?: string[][] | Record | string | URLParams)**, and the parameter type is changed from **URLSearchParams** to **URLParams**. @@ -38,7 +39,8 @@ try { } ``` ## cl.commonlibrary.2 URL Attribute Changes of URLParams Class APIs -The URL attributes of the URL module in the utils subsystem are changed. + +The URL attributes of the URL module in the common library subsystem are changed. Specifically, the **searchParams: URLSearchParams** attribute is deprecated, and the **params: URLParams** attribute is added. diff --git a/en/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-bundlemanager.md b/en/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-bundlemanager.md new file mode 100644 index 0000000000000000000000000000000000000000..94e7367fe1d8daeee5d9a943ca6d85b463e7be2a --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-bundlemanager.md @@ -0,0 +1,60 @@ +# Bundle Manager Subsystem Changelog + +## cl.bundlemanager.1 Deleted the atomicService Tag from the app.json File +The **atomicService** tag is deleted from the **app.json** file. + +**Change Impact**
+If this tag is used, an error is reported during compilation on DevEco Studio. + +**Adaptation Guide**
+Delete the **atomicService** tag from your code. + +## cl.bundlemanager.2 Added the bundleType Tag to the app.json File +The **bundleType** tag is added to the **app.json** file. + +**Change Impact**
+For an existing ability with [installationFree](../../../application-dev/quick-start/module-configuration-file.md) set to **true**, **bundleType** must be set to **atomicService** in the **app.json** file. Otherwise, the packaging fails. + +**Adaptation Guide**
+Add the [bundleType](../../../application-dev/quick-start/app-configuration-file.md) tag. This tag can be left blank. The default value is **app**. The setting of this tag and the [installationFree](../../../application-dev/quick-start/module-configuration-file.md) field in the **module.json** file must meet the following rules: +- If **bundleType** is **app**, **installationFree** must be set to **false**. +- If **bundleType** is **atomicService**, **installationFree** must be set to **true**. + +## cl.bundlemanager.3 Deleted the split Field from the ApplicationInfo Struct + +The **split** field is deleted from the [ApplicationInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/ApplicationInfo.d.ts) struct. + +**Change Impact**
+If the **split** field is used in your code, the compilation fails. + +**Key API/Component Changes**
+The **split** field is deleted from the [ApplicationInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/ApplicationInfo.d.ts) struct. + +**Adaptation Guide**
+Delete the **split** field from the **ApplicationInfo** struct of your code. The stage model always forcibly splits bundles. + +## cl.bundlemanager.4 Deleted the atomicServiceModuleType Field from the HapModuleInfo Struct + +The **atomicServiceModuleType** field is deleted from the [HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts) struct. + +**Change Impact**
+If the **atomicServiceModuleType** field is used in your code, the compilation fails. + +**Key API/Component Changes**
+The **atomicServiceModuleType** field is deleted from the [HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts) struct. + +**Adaptation Guide**
+Record the setting of the **atomicServiceModuleType** field, delete it from the [HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts) struct, and set the **moduleType** field in the [HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts) struct to the recorded value. + +## cl.bundlemanager.5 Deleted the AtomicServiceModuleType Enumerated Value + +The **atomicServiceModuleType** field is deleted from the [HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts) struct. + +**Change Impact**
+If the **atomicServiceModuleType** field is used in your code, the compilation fails. + +**Key API/Component Changes**
+The **atomicServiceModuleType** field is deleted from the [HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts) struct. + +**Adaptation Guide**
+Record the setting of the **atomicServiceModuleType** field, delete it from the [HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts) struct, and set the **moduleType** field in the [HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts) struct to the recorded value. diff --git a/en/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-screenlock.md b/en/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-screenlock.md new file mode 100644 index 0000000000000000000000000000000000000000..deeaac319aecfd4ba2824b8f23370d6fe2601adc --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-screenlock.md @@ -0,0 +1,157 @@ +# Theme Framework Subsystem – Screenlock Management Service Changelog + + +## cl.screenlock.1 Permission Change of isLocked and unlock +Changed the **isLocked** and **unlock** APIs to system APIs since API version 9. + +You need to adapt your application based on the following information. + +**Change Impact** + +The JS API needs to be adapted for applications developed based on earlier versions. Otherwise, relevant functions will be affected. + +- Involved APIs: + +```js + function isLocked(): boolean; + function unlock(callback: AsyncCallback): void; + function unlock():Promise; +``` + +- Before change: + +```js + * Checks whether the screen is currently locked. + * + * @returns Returns {@code true} if the screen is currently locked; returns {@code false} otherwise. + * @syscap SystemCapability.MiscServices.ScreenLock + * @since 9 + */ + function isLocked(): boolean; + + /** + * Unlock the screen. + * + * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. + * @syscap SystemCapability.MiscServices.ScreenLock + * @systemapi Hide this for inner system use. + * @since 9 + */ + function unlock(callback: AsyncCallback): void; + + /** + * Unlock the screen. + * + * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. + * @syscap SystemCapability.MiscServices.ScreenLock + * @systemapi Hide this for inner system use. + * @since 9 + */ + function unlock():Promise; +``` + +- After change: + +```js + * Checks whether the screen is currently locked. + * + * @returns Returns {@code true} if the screen is currently locked; returns {@code false} otherwise. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.MiscServices.ScreenLock + * @systemapi Hide this for inner system use. + * @since 9 + */ + function isLocked(): boolean; + + /** + * Unlock the screen. + * + * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. + * @syscap SystemCapability.MiscServices.ScreenLock + * @since 9 + */ + function unlock(callback: AsyncCallback): void; + + /** + * Unlock the screen. + * + * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. + * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. + * @syscap SystemCapability.MiscServices.ScreenLock + * @since 9 + */ + function unlock():Promise; +``` + + +**Adaptation Guide** + +Make sure the APIs are only invoked by system applications. + +The code snippet is as follows: + +```js + try { + let ret = screenLock.isLocked(); + console.error(`Obtain whether the screen is locked successfully , ret is: ${ret}`); + } catch (error) { + console.error(`Failed to obtain whether the screen is locked, error is : ${error.code}, ${error.message}`); + } +``` + +```js + screenlock.unlock((err, data) => { + if (err) { + console.error(`Failed to unlock the screen, because: ${err.message}`); + return; + } + console.info(`unlock the screen successfully. result: ${data}`); + }); +``` + +```js + screenlock.unlock().then((data) => { + console.info(`unlock the screen successfully. result: ${data}`); + }).catch((err) => { + console.error(`Failed to unlock the screen, because: ${err.message}`); + }); +``` + + +## cl.screenlock.2 Deprecation of isSecure +Deprecated the **isSecure** API since API version 9. + +You need to adapt your application based on the following information. + +**Change Impact** + +The API can no longer be used after being deleted. + +- Involved APIs: + +```js + function isSecure(): boolean; +``` + +- Before change: + +```js + function isSecure(): boolean; +``` + +- After change: + + The API is deleted. + + +**Adaptation Guide** + +Update the code so that the deprecated API is not used. diff --git a/en/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-wallpaper.md b/en/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-wallpaper.md new file mode 100644 index 0000000000000000000000000000000000000000..18fff418c0723c7508f6c7eacdb318b95758402b --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-wallpaper.md @@ -0,0 +1,306 @@ +# Theme Framework Subsystem – Wallpaper Management Service Changelog + + +## cl.wallpaper.1 Permission Change of getColorsSync, getMinHeightSync, getMinWidthSync, restore, and setImage +Changed the **getColorsSync**, **getMinHeightSync**, **getMinWidthSync**, restore, and **setImage** APIs to system APIs since API version 9. + +You need to adapt your application based on the following information. + +**Change Impact** + +The JS API needs to be adapted for applications developed based on earlier versions. Otherwise, relevant functions will be affected. + +- Involved APIs: + +```js + function getColorsSync(wallpaperType: WallpaperType): Array; + function getMinHeightSync(): number; + function getMinWidthSync(): number; + function restore(wallpaperType: WallpaperType, callback: AsyncCallback): void; + function restore(wallpaperType: WallpaperType): Promise; + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback): void; + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise; +``` + +- Before change: + +```js + /** + * Obtains the wallpaper colors for the wallpaper of the specified type. Returns rgbaColor type of array callback function. + * @param wallpaperType Indicates the wallpaper type. + * @returns { Array } the Array returned by the function. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function getColorsSync(wallpaperType: WallpaperType): Array; + + /** + * Obtains the minimum height of the wallpaper. in pixels. returns 0 if no wallpaper has been set. + * @returns { number } the number returned by the function. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function getMinHeightSync(): number; + + /** + * Obtains the minimum width of the wallpaper. in pixels. returns 0 if no wallpaper has been set. + * @returns { number } the number returned by the function. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function getMinWidthSync(): number; + + /** + * Removes a wallpaper of the specified type and restores the default one. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function restore(wallpaperType: WallpaperType, callback: AsyncCallback): void; + + /** + * Removes a wallpaper of the specified type and restores the default one. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function restore(wallpaperType: WallpaperType): Promise; + + /** + * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file. + * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback): void; + + /** + * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file. + * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise; +``` + +- After change: + +```js + /** + * Obtains the wallpaper colors for the wallpaper of the specified type. Returns rgbaColor type of array callback function. + * @param wallpaperType Indicates the wallpaper type. + * @returns { Array } the Array returned by the function. + * @throws {BusinessError} 401 - parameter error. + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function getColorsSync(wallpaperType: WallpaperType): Array; + + /** + * Obtains the minimum height of the wallpaper. in pixels. returns 0 if no wallpaper has been set. + * @returns { number } the number returned by the function. + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function getMinHeightSync(): number; + + /** + * Obtains the minimum width of the wallpaper. in pixels. returns 0 if no wallpaper has been set. + * @returns { number } the number returned by the function. + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function getMinWidthSync(): number; + + /** + * Removes a wallpaper of the specified type and restores the default one. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function restore(wallpaperType: WallpaperType, callback: AsyncCallback): void; + + /** + * Removes a wallpaper of the specified type and restores the default one. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function restore(wallpaperType: WallpaperType): Promise; + + /** + * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file. + * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback): void; + + /** + * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file. + * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise; +``` + + +**Adaptation Guide** + +Make sure the APIs are only invoked by system applications. + +The code snippet is as follows: + +```js + try { + let colors = wallpaper.getColorsSync(wallpaper.WallpaperType.WALLPAPER_SYSTEM); + console.log(`success to getColorsSync: ${JSON.stringify(colors)}`); + } catch (error) { + console.error(`failed to getColorsSync because: ${JSON.stringify(error)}`); + } +``` + +```js + let minHeight = wallpaper.getMinHeightSync(); +``` + +```js + let minWidth = wallpaper.getMinWidthSync(); +``` + +```js + wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error) => { + if (error) { + console.error(`failed to restore because: ${JSON.stringify(error)}`); + return; + } + console.log(`success to restore.`); + }); +``` + +```js + wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { + console.log(`success to restore.`); + }).catch((error) => { + console.error(`failed to restore because: ${JSON.stringify(error)}`); + }); +``` + +```js + // The source type is string. + let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; + wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error) => { + if (error) { + console.error(`failed to setImage because: ${JSON.stringify(error)}`); + return; + } + console.log(`success to setImage.`); + }); +``` + +```js + // The source type is string. + let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; + wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { + console.log(`success to setImage.`); + }).catch((error) => { + console.error(`failed to setImage because: ${JSON.stringify(error)}`); + }); +``` + + +## cl.wallpaper.2 Deprecation of getIdSync, getFileSync, isChangeAllowed, isUserChangeAllowed, on, off, and RgbaColor +Deprecated the **getIdSync**, **getFileSync**, **isChangeAllowed**, **isUserChangeAllowed**, **on**, **off**, and **RgbaColor** APIs since API version 9. + +You need to adapt your application based on the following information. + +**Change Impact** + +The APIs can no longer be used after being deleted. + +- Involved APIs: + +```js + function getIdSync(wallpaperType: WallpaperType): number; + function getFileSync(wallpaperType: WallpaperType): number; + function isChangeAllowed(): boolean; + function isUserChangeAllowed(): boolean; + function on(type: 'colorChange', callback: (colors: Array, wallpaperType: WallpaperType) => void): void; + function off(type: 'colorChange', callback?: (colors: Array, wallpaperType: WallpaperType) => void): void; + interface RgbaColor { + red: number; + green: number; + blue: number; + alpha: number; + } +``` + +- Before change: + +```js + function getIdSync(wallpaperType: WallpaperType): number; + function getFileSync(wallpaperType: WallpaperType): number; + function isChangeAllowed(): boolean; + function isUserChangeAllowed(): boolean; + function on(type: 'colorChange', callback: (colors: Array, wallpaperType: WallpaperType) => void): void; + function off(type: 'colorChange', callback?: (colors: Array, wallpaperType: WallpaperType) => void): void; + interface RgbaColor { + red: number; + green: number; + blue: number; + alpha: number; + } +``` + +- After change: + + The APIs are deleted. + + +**Adaptation Guide** + +Update the code so that the deprecated APIs are not used. diff --git a/en/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-ability.md b/en/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-ability.md index 39c327d863b2e322ece336edf983f053e451d398..6ebe3fe1b7988aab988b1b93cdf1664378665304 100644 --- a/en/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-ability.md +++ b/en/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-ability.md @@ -1,4 +1,4 @@ -# Ability Subsystem Changelog +# Ability Framework Changelog ## cl.ability.1 AreaMode APIs Changed Duplicate **AreaMode** APIs are deleted. @@ -106,3 +106,163 @@ let context: common.UIAbilityContext = globalThis.abilityContext; let appContext = context.getApplicationContext(); appContext.getRunningProcessInformation() ``` + + + +## cl.ability.4 WantConstant.Flags API Change + +**WantConstant.Flags** has multiple invalid flag definitions. These invalid flags are deleted. + +**Change Impact** + +JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version. + +**Key API/Component Changes** + +| Module | Class | Method/Attribute/Enum/Constant | Change Type| +| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags | FLAG_ABILITY_FORWARD_RESULT | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags | FLAG_ABILITY_CONTINUATION | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags | FLAG_NOT_OHOS_COMPONENT | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags | FLAG_ABILITY_FORM_ENABLED | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags | FLAG_AUTH_PERSISTABLE_URI_PERMISSION | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags | FLAG_AUTH_PREFIX_URI_PERMISSION | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags | FLAG_ABILITYSLICE_MULTI_DEVICE | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags | FLAG_START_FOREGROUND_ABILITY | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags | FLAG_ABILITY_CONTINUATION_REVERSIBLE | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags | FLAG_INSTALL_WITH_BACKGROUND_MODE | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags | FLAG_ABILITY_CLEAR_MISSION | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags | FLAG_ABILITY_NEW_MISSION | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Flags | FLAG_ABILITY_MISSION_TOP | Deleted | + + + +## cl.ability.5 WantConstant.Action API Change + +**WantConstant.Action** has multiple invalid action definitions. These invalid actions are deleted. + +**Change Impact** + +JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version. + +**Key API/Component Changes** + +| Module | Class | Method/Attribute/Enum/Constant | Change Type| +| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Action | ACTION_APP_ACCOUNT_AUTH | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Action | ACTION_MARKET_DOWNLOAD | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Action | ACTION_MARKET_CROWDTEST | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Action | DLP_PARAMS_SANDBOX | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Action | DLP_PARAMS_BUNDLE_NAME | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Action | DLP_PARAMS_MODULE_NAME | Deleted | +| @ohos.app.ability.wantConstant.d.ts | wantConstant.Action | DLP_PARAMS_ABILITY_NAME | Deleted | + + + +## cl.ability.6 Caller APIs Changed + +Caller APIs use the **Parcelable** and **MessageSequence** objects provided by RPC in API version 9 to replace the deprecated **Sequenceable** and **MessageParcel** object. + +**Change Impact** + +JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version. + +**Key API/Component Changes** + +| Module | Class | Method/Attribute/Enum/Constant | Change Type| +| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- | +| api/@ohos.app.ability.UIAbility.d.ts | CalleeCallback | (indata: rpc.MessageParcel): rpc.Sequenceable; | Changed to **(indata: rpc.MessageSequence): rpc.Parcelable;**. | +| api/@ohos.app.ability.UIAbility.d.ts | Caller | call(method: string, data: rpc.Sequenceable): Promise; | Changed to **call(method: string, data: rpc.Parcelable): Promise;**. | +| api/@ohos.app.ability.UIAbility.d.ts | Caller | callWithResult(method: string, data: rpc.Sequenceable): Promise; | Changed to **callWithResult(method: string, data: rpc.Parcelable): Promise;**. | + +**Adaptation Guide** + +The following illustrates how to call the caller APIs in your application. + +Code before the change: + +```ts + class MyMessageAble{ + name:"" + str:"" + num: 1 + constructor(name, str) { + this.name = name; + this.str = str; + } + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); + return true; + } + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); + return true; + } + }; + let method = 'call_Function'; + function funcCallBack(pdata) { + console.log('Callee funcCallBack is called ' + pdata); + let msg = new MyMessageAble("test", ""); + pdata.readSequenceable(msg); + return new MyMessageAble("test1", "Callee test"); + } + export default class MainUIAbility extends UIAbility { + onCreate(want, launchParam) { + console.log('Callee onCreate is called'); + try { + this.callee.on(method, funcCallBack); + } catch (error) { + console.log('Callee.on catch error, error.code: ' + JSON.stringify(error.code) + + ' error.message: ' + JSON.stringify(error.message)); + } + } + } +``` + +Code after the change: + +```ts + class MyMessageAble{ + name:"" + str:"" + num: 1 + constructor(name, str) { + this.name = name; + this.str = str; + } + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); + console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); + return true; + } + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); + console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); + return true; + } + }; + let method = 'call_Function'; + function funcCallBack(pdata) { + console.log('Callee funcCallBack is called ' + pdata); + let msg = new MyMessageAble("test", ""); + pdata.readParcelable(msg); + return new MyMessageAble("test1", "Callee test"); + } + export default class MainUIAbility extends UIAbility { + onCreate(want, launchParam) { + console.log('Callee onCreate is called'); + try { + this.callee.on(method, funcCallBack); + } catch (error) { + console.log('Callee.on catch error, error.code: ' + JSON.stringify(error.code) + + ' error.message: ' + JSON.stringify(error.message)); + } + } + } +``` diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.1.1/changelogs-window.md b/en/release-notes/changelogs/OpenHarmony_4.0.1.1/changelogs-window.md deleted file mode 100644 index 4c26515ed4be4c3d5b7ff568886d174ed65591a4..0000000000000000000000000000000000000000 --- a/en/release-notes/changelogs/OpenHarmony_4.0.1.1/changelogs-window.md +++ /dev/null @@ -1,63 +0,0 @@ -# Window Subsystem ChangeLog - -## cl.window.1 Change of Window Stage Lifecycle Listener Types - -Changed the enumerated listener types of the window stage lifecycle in version 4.0.1.1 and later. - -**Change Impacts** - -Application lifecycle listeners developed using **FOREGROUND** and **BACKGROUND** in versions earlier than 4.0.1.1 will be invalidated in version 4.0.1.1 and later. - -**Key API/Component Changes** - -## WindowStageEventType9+ - -Before change: - -| Name | Value | Description | -| ---------- | ---- | ---------- | -| FOREGROUND | 1 | The window stage is running in the foreground.| -| BACKGROUND | 4 | The window stage is running in the background.| - -After change: -| Name | Value | Description | -| ------ | ---- | ---------- | -| SHOWN | 1 | The window stage is running in the foreground.| -| HIDDEN | 4 | The window stage is running in the background.| - -**Adaptation Guide** - -When registering lifecycle listeners, change the foreground and background event types to **SHOWN** and **HIDDEN**, respectively. - -``` -import Ability from '@ohos.application.Ability'; - -class myAbility extends Ability { - onWindowStageCreate(windowStage) { - console.log('onWindowStageCreate'); - try { - windowStage.on('windowStageEvent', (stageEventType) => { - switch (stageEventType) { - case window.WindowStageEventType.SHOWN: - console.log("windowStage shown"); - break; - case window.WindowStageEventType.ACTIVE: - console.log("windowStage active"); - break; - case window.WindowStageEventType.INACTIVE: - console.log("windowStage inActive"); - break; - case window.WindowStageEventType.HIDDEN: - console.log("windowStage hidden"); - break; - default: - break; - } - } ) - } catch (exception) { - console.error('Failed to enable the listener for window stage event changes. Cause:' + - JSON.stringify(exception)); - }; - } -}; -``` diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.2.2/changelogs-global.md b/en/release-notes/changelogs/OpenHarmony_4.0.2.2/changelogs-global.md new file mode 100644 index 0000000000000000000000000000000000000000..e6e84330a176fb8e06a5a7a4dc626aba84b362ef --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_4.0.2.2/changelogs-global.md @@ -0,0 +1,57 @@ +# Globalization Subsystem Changelog + +## cl.resourceManager.1 Change in the Meaning of the Return Value for the API Used to Obtain the rawfile Descriptor + +Changed the meaning of the return value for the API used to obtain the rawfile descriptor after the non-decompression feature is added in this version. The change in the meaning of the return value, namely, **descriptor: RawFileDescriptor {fd, offset, length}**, is described as follows: + +**Before change:** + +**fd**: file descriptor for accessing the rawfile. + +**offset**: offset for accessing the rawfile. In this case, the value is **0**. + +**length**: size of the rawfile to access. + +**After change:** + +**fd**: file descriptor for accessing the HAP where the rawfile is located. + +**offset**: offset of the accessed rawfile relative to the HAP. + +**length**: size of the rawfile to access. + +**Change Impact** + +In versions earlier than 4.0.2.2, the rawfile can be accessed only through **fd**. In version 4.0.2.2 or later, the rawfile can be accessed only through **{fd, offset, and length}**. + +**Key API/Component Changes** + +| **Original API** | +| ---------------- | +| getRawFd(path: string, callback: AsyncCallback\): void | +| getRawFd(path: string): Promise\ | +| getRawFileDescriptor(path: string, callback: AsyncCallback\): void| +| getRawFileDescriptor(path: string): Promise\| +|| + +**Sample Code** + +The following is an example of calling the **getRawFd** API: +``` +try { + this.context.resourceManager.getRawFd("test.ogg", (error, value) => { + if (error != null) { + console.log(`callback getRawFd failed error code: ${error.code}, message: ${error.message}.`); + } else { + let fileDescriptor = { + fd = value.fd, + offset = value.offset, + length = value.length + } + this.avPlayer.fdSrc(fileDescriptor); // Take the audio player as an example. When calling fdSrc, pass fileDescriptor in addition to fd. + } + }); + } catch (error) { + console.error(`callback getRawFd failed, error code: ${error.code}, message: ${error.message}.`) + }; +``` diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.5.2/changelogs-ability.md b/en/release-notes/changelogs/OpenHarmony_4.0.5.2/changelogs-ability.md new file mode 100644 index 0000000000000000000000000000000000000000..229a965c8cff75c6e3a95c415b5f2449e2b10535 --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_4.0.5.2/changelogs-ability.md @@ -0,0 +1,64 @@ +# Ability Framework Changelog + +## Added the saveAppState API to cl.ability.appRecovery + +The API **saveAppState (context?: UIAbilityContext): boolean;** is added. + +**Change Impact** + +When developing an application based on OpenHarmony 4.0.5.2 or a later SDK version, you can use **saveAppState** with the ability context specified to save the state of the specified ability. + +**Key API/Component Changes** + +The **saveAppState** API is added to the **@ohos.app.ability.appRecovery.d.ts** file. + +| Module| Class| Method/Attribute/Enum/Constant| Change Type| +| -- | -- | -- | -- | +| @ohos.app.ability.appRecovery.d.ts | appRecovery | saveAppState(context?: UIAbilityContext): boolean; | Added| + +**Adaptation Guide** + +Call **saveAppState** with the UIAbility context specified to save the ability state. + +```ts +import appRecovery from '@ohos.app.ability.appRecovery'; +onBackground() { + hilog.info(0x0000, '[demo]', '%{public}s', 'EntryAbility onBackground'); + appRecovery.saveAppState(this.context) +} +``` +## Added the setRestartWant API to cl.ability.appRecovery. + +The API **setRestartWant (want: Want): void;** is added. + +**Change Impact** + +To develop an application based on OpenHarmony 4.0.5.2 or a later SDK version, you can use **setRestartWant** to set the ability to recover. + +**Key API/Component Changes** + +The **setRestartWant** API is added to the **@ohos.app.ability.appRecovery.d.ts** file. + +| Module| Class| Method/Attribute/Enum/Constant| Change Type| +| -- | -- | -- | -- | +| @ohos.app.ability.appRecovery.d.ts | appRecovery | setRestartWant(want: Want): void; | Added| + +**Adaptation Guide** + +Call **setRestartWant** to set the ability to recover. + +```ts +import appRecovery from '@ohos.app.ability.appRecovery'; +Button ("Start to Recover Ability") + .fontSize(40) + .fontWeight(FontWeight.Bold) + .onClick(()=> { + // set restart want + let want = { + bundleName: "ohos.samples.recovery", + abilityName: "RecoveryAbility" + }; + + appRecovery.setRestartWant(want); + }) +``` diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.5.3/changelog-screenlock.md b/en/release-notes/changelogs/OpenHarmony_4.0.5.3/changelog-screenlock.md new file mode 100644 index 0000000000000000000000000000000000000000..deeaac319aecfd4ba2824b8f23370d6fe2601adc --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_4.0.5.3/changelog-screenlock.md @@ -0,0 +1,157 @@ +# Theme Framework Subsystem – Screenlock Management Service Changelog + + +## cl.screenlock.1 Permission Change of isLocked and unlock +Changed the **isLocked** and **unlock** APIs to system APIs since API version 9. + +You need to adapt your application based on the following information. + +**Change Impact** + +The JS API needs to be adapted for applications developed based on earlier versions. Otherwise, relevant functions will be affected. + +- Involved APIs: + +```js + function isLocked(): boolean; + function unlock(callback: AsyncCallback): void; + function unlock():Promise; +``` + +- Before change: + +```js + * Checks whether the screen is currently locked. + * + * @returns Returns {@code true} if the screen is currently locked; returns {@code false} otherwise. + * @syscap SystemCapability.MiscServices.ScreenLock + * @since 9 + */ + function isLocked(): boolean; + + /** + * Unlock the screen. + * + * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. + * @syscap SystemCapability.MiscServices.ScreenLock + * @systemapi Hide this for inner system use. + * @since 9 + */ + function unlock(callback: AsyncCallback): void; + + /** + * Unlock the screen. + * + * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. + * @syscap SystemCapability.MiscServices.ScreenLock + * @systemapi Hide this for inner system use. + * @since 9 + */ + function unlock():Promise; +``` + +- After change: + +```js + * Checks whether the screen is currently locked. + * + * @returns Returns {@code true} if the screen is currently locked; returns {@code false} otherwise. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.MiscServices.ScreenLock + * @systemapi Hide this for inner system use. + * @since 9 + */ + function isLocked(): boolean; + + /** + * Unlock the screen. + * + * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. + * @syscap SystemCapability.MiscServices.ScreenLock + * @since 9 + */ + function unlock(callback: AsyncCallback): void; + + /** + * Unlock the screen. + * + * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. + * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. + * @syscap SystemCapability.MiscServices.ScreenLock + * @since 9 + */ + function unlock():Promise; +``` + + +**Adaptation Guide** + +Make sure the APIs are only invoked by system applications. + +The code snippet is as follows: + +```js + try { + let ret = screenLock.isLocked(); + console.error(`Obtain whether the screen is locked successfully , ret is: ${ret}`); + } catch (error) { + console.error(`Failed to obtain whether the screen is locked, error is : ${error.code}, ${error.message}`); + } +``` + +```js + screenlock.unlock((err, data) => { + if (err) { + console.error(`Failed to unlock the screen, because: ${err.message}`); + return; + } + console.info(`unlock the screen successfully. result: ${data}`); + }); +``` + +```js + screenlock.unlock().then((data) => { + console.info(`unlock the screen successfully. result: ${data}`); + }).catch((err) => { + console.error(`Failed to unlock the screen, because: ${err.message}`); + }); +``` + + +## cl.screenlock.2 Deprecation of isSecure +Deprecated the **isSecure** API since API version 9. + +You need to adapt your application based on the following information. + +**Change Impact** + +The API can no longer be used after being deleted. + +- Involved APIs: + +```js + function isSecure(): boolean; +``` + +- Before change: + +```js + function isSecure(): boolean; +``` + +- After change: + + The API is deleted. + + +**Adaptation Guide** + +Update the code so that the deprecated API is not used. diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.5.3/changelog-wallpaper.md b/en/release-notes/changelogs/OpenHarmony_4.0.5.3/changelog-wallpaper.md new file mode 100644 index 0000000000000000000000000000000000000000..18fff418c0723c7508f6c7eacdb318b95758402b --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_4.0.5.3/changelog-wallpaper.md @@ -0,0 +1,306 @@ +# Theme Framework Subsystem – Wallpaper Management Service Changelog + + +## cl.wallpaper.1 Permission Change of getColorsSync, getMinHeightSync, getMinWidthSync, restore, and setImage +Changed the **getColorsSync**, **getMinHeightSync**, **getMinWidthSync**, restore, and **setImage** APIs to system APIs since API version 9. + +You need to adapt your application based on the following information. + +**Change Impact** + +The JS API needs to be adapted for applications developed based on earlier versions. Otherwise, relevant functions will be affected. + +- Involved APIs: + +```js + function getColorsSync(wallpaperType: WallpaperType): Array; + function getMinHeightSync(): number; + function getMinWidthSync(): number; + function restore(wallpaperType: WallpaperType, callback: AsyncCallback): void; + function restore(wallpaperType: WallpaperType): Promise; + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback): void; + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise; +``` + +- Before change: + +```js + /** + * Obtains the wallpaper colors for the wallpaper of the specified type. Returns rgbaColor type of array callback function. + * @param wallpaperType Indicates the wallpaper type. + * @returns { Array } the Array returned by the function. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function getColorsSync(wallpaperType: WallpaperType): Array; + + /** + * Obtains the minimum height of the wallpaper. in pixels. returns 0 if no wallpaper has been set. + * @returns { number } the number returned by the function. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function getMinHeightSync(): number; + + /** + * Obtains the minimum width of the wallpaper. in pixels. returns 0 if no wallpaper has been set. + * @returns { number } the number returned by the function. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function getMinWidthSync(): number; + + /** + * Removes a wallpaper of the specified type and restores the default one. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function restore(wallpaperType: WallpaperType, callback: AsyncCallback): void; + + /** + * Removes a wallpaper of the specified type and restores the default one. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function restore(wallpaperType: WallpaperType): Promise; + + /** + * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file. + * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback): void; + + /** + * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file. + * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise; +``` + +- After change: + +```js + /** + * Obtains the wallpaper colors for the wallpaper of the specified type. Returns rgbaColor type of array callback function. + * @param wallpaperType Indicates the wallpaper type. + * @returns { Array } the Array returned by the function. + * @throws {BusinessError} 401 - parameter error. + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function getColorsSync(wallpaperType: WallpaperType): Array; + + /** + * Obtains the minimum height of the wallpaper. in pixels. returns 0 if no wallpaper has been set. + * @returns { number } the number returned by the function. + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function getMinHeightSync(): number; + + /** + * Obtains the minimum width of the wallpaper. in pixels. returns 0 if no wallpaper has been set. + * @returns { number } the number returned by the function. + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function getMinWidthSync(): number; + + /** + * Removes a wallpaper of the specified type and restores the default one. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function restore(wallpaperType: WallpaperType, callback: AsyncCallback): void; + + /** + * Removes a wallpaper of the specified type and restores the default one. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function restore(wallpaperType: WallpaperType): Promise; + + /** + * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file. + * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback): void; + + /** + * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file. + * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise; +``` + + +**Adaptation Guide** + +Make sure the APIs are only invoked by system applications. + +The code snippet is as follows: + +```js + try { + let colors = wallpaper.getColorsSync(wallpaper.WallpaperType.WALLPAPER_SYSTEM); + console.log(`success to getColorsSync: ${JSON.stringify(colors)}`); + } catch (error) { + console.error(`failed to getColorsSync because: ${JSON.stringify(error)}`); + } +``` + +```js + let minHeight = wallpaper.getMinHeightSync(); +``` + +```js + let minWidth = wallpaper.getMinWidthSync(); +``` + +```js + wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error) => { + if (error) { + console.error(`failed to restore because: ${JSON.stringify(error)}`); + return; + } + console.log(`success to restore.`); + }); +``` + +```js + wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { + console.log(`success to restore.`); + }).catch((error) => { + console.error(`failed to restore because: ${JSON.stringify(error)}`); + }); +``` + +```js + // The source type is string. + let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; + wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error) => { + if (error) { + console.error(`failed to setImage because: ${JSON.stringify(error)}`); + return; + } + console.log(`success to setImage.`); + }); +``` + +```js + // The source type is string. + let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; + wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { + console.log(`success to setImage.`); + }).catch((error) => { + console.error(`failed to setImage because: ${JSON.stringify(error)}`); + }); +``` + + +## cl.wallpaper.2 Deprecation of getIdSync, getFileSync, isChangeAllowed, isUserChangeAllowed, on, off, and RgbaColor +Deprecated the **getIdSync**, **getFileSync**, **isChangeAllowed**, **isUserChangeAllowed**, **on**, **off**, and **RgbaColor** APIs since API version 9. + +You need to adapt your application based on the following information. + +**Change Impact** + +The APIs can no longer be used after being deleted. + +- Involved APIs: + +```js + function getIdSync(wallpaperType: WallpaperType): number; + function getFileSync(wallpaperType: WallpaperType): number; + function isChangeAllowed(): boolean; + function isUserChangeAllowed(): boolean; + function on(type: 'colorChange', callback: (colors: Array, wallpaperType: WallpaperType) => void): void; + function off(type: 'colorChange', callback?: (colors: Array, wallpaperType: WallpaperType) => void): void; + interface RgbaColor { + red: number; + green: number; + blue: number; + alpha: number; + } +``` + +- Before change: + +```js + function getIdSync(wallpaperType: WallpaperType): number; + function getFileSync(wallpaperType: WallpaperType): number; + function isChangeAllowed(): boolean; + function isUserChangeAllowed(): boolean; + function on(type: 'colorChange', callback: (colors: Array, wallpaperType: WallpaperType) => void): void; + function off(type: 'colorChange', callback?: (colors: Array, wallpaperType: WallpaperType) => void): void; + interface RgbaColor { + red: number; + green: number; + blue: number; + alpha: number; + } +``` + +- After change: + + The APIs are deleted. + + +**Adaptation Guide** + +Update the code so that the deprecated APIs are not used. diff --git a/en/website.md b/en/website.md index 2431b867aafb1669ef739c1c3d2884fe32223596..c89534497929cd5975debbf051874a1c0c4bbca6 100644 --- a/en/website.md +++ b/en/website.md @@ -43,7 +43,7 @@ - [Power management subsystem](release-notes/api-diff/v3.2-beta4/js-apidiff-battery.md) - [Bundle management framework](release-notes/api-diff/v3.2-beta4/js-apidiff-bundle.md) - [Communication subsystem](release-notes/api-diff/v3.2-beta4/js-apidiff-communication.md) - - [Utils subsystem](release-notes/api-diff/v3.2-beta4/js-apidiff-compiler-and-runtime.md) + - [Compiler and runtime subsystem](release-notes/api-diff/v3.2-beta4/js-apidiff-compiler-and-runtime.md) - [Communication subsystem](release-notes/api-diff/v3.2-beta4/js-apidiff-customization.md) - [DFX subsystem](release-notes/api-diff/v3.2-beta4/js-apidiff-dfx.md) - [Distributed data management subsystem](release-notes/api-diff/v3.2-beta4/js-apidiff-distributed-data.md) @@ -76,7 +76,7 @@ - [Power management subsystem](release-notes/api-diff/v3.2-beta3/js-apidiff-battery.md) - [Bundle management framework](release-notes/api-diff/v3.2-beta3/js-apidiff-bundle.md) - [Communication subsystem](release-notes/api-diff/v3.2-beta3/js-apidiff-communicate.md) - - [Utils subsystem](release-notes/api-diff/v3.2-beta3/js-apidiff-compiler-and-runtime.md) + - [Compiler and runtime subsystem](release-notes/api-diff/v3.2-beta3/js-apidiff-compiler-and-runtime.md) - [DFX subsystem](release-notes/api-diff/v3.2-beta3/js-apidiff-dfx.md) - [Distributed data management subsystem](release-notes/api-diff/v3.2-beta3/js-apidiff-distributed-data.md) - [Distributed hardware subsystem](release-notes/api-diff/v3.2-beta3/js-apidiff-distributed-hardware.md) @@ -105,7 +105,7 @@ - [ArkUI development framework](release-notes/api-diff/v3.2-beta2/js-apidiff-arkui.md) - [Bundle management framework](release-notes/api-diff/v3.2-beta2/js-apidiff-bundle.md) - [Communication subsystem](release-notes/api-diff/v3.2-beta2/js-apidiff-communicate.md) - - [Utils subsystem](release-notes/api-diff/v3.2-beta2/js-apidiff-compiler-and-runtime.md) + - [Compiler and runtime subsystem](release-notes/api-diff/v3.2-beta2/js-apidiff-compiler-and-runtime.md) - [DFX subsystem](release-notes/api-diff/v3.2-beta2/js-apidiff-dfx.md) - [Distributed data management subsystem](release-notes/api-diff/v3.2-beta2/js-apidiff-distributed-data.md) - [Common event and notification subsystem](release-notes/api-diff/v3.2-beta2/js-apidiff-event-and-notification.md) @@ -159,7 +159,7 @@ - [Power management subsystem](release-notes/api-diff/v3.1-Release/js-apidiff-battery.md) - [Bundle management subsystem](release-notes/api-diff/v3.1-Release/js-apidiff-bundle.md) - [Communication subsystem](release-notes/api-diff/v3.1-Release/js-apidiff-communicate.md) - - [Multi-language Runtime subsystem](release-notes/api-diff/v3.1-Release/js-apidiff-compiler-and-runtime.md) + - [Compiler and runtime subsystem](release-notes/api-diff/v3.1-Release/js-apidiff-compiler-and-runtime.md) - [DFX subsystem](release-notes/api-diff/v3.1-Release/js-apidiff-dfx.md) - [Distributed data management subsystem](release-notes/api-diff/v3.1-Release/js-apidiff-distributed-data.md) - [Distributed hardware subsystem](release-notes/api-diff/v3.1-Release/js-apidiff-distributed-hardware.md) diff --git a/zh-cn/application-dev/IDL/idl-guidelines.md b/zh-cn/application-dev/IDL/idl-guidelines.md index 5f9989698ce60c86c3614cb7389346e84d0a9b40..c9c92172d7154c7e24d48256b1d8577aafaf4577 100644 --- a/zh-cn/application-dev/IDL/idl-guidelines.md +++ b/zh-cn/application-dev/IDL/idl-guidelines.md @@ -158,9 +158,9 @@ OpenHarmony IDL容器数据类型与Ts数据类型、C++数据类型的对应关 > **注意**:请保证使用最新版的SDK,版本老旧可能导致部分语句报错。 -若不存在,可对应版本前往[docs仓版本目录](https://gitee.com/openharmony/docs/tree/master/zh-cn/release-notes)下载SDK包,以[3.2Beta3版本](../../release-notes/OpenHarmony-v3.2-beta3.md#%E4%BB%8E%E9%95%9C%E5%83%8F%E7%AB%99%E7%82%B9%E8%8E%B7%E5%8F%96)为例,可通过镜像站点获取。 +若不存在,可对应版本前往[docs仓版本目录](../../release-notes)下载SDK包,以[3.2Beta3版本](../../release-notes/OpenHarmony-v3.2-beta3.md)为例,可通过镜像站点获取。 -关于如何替换DevEco Studio的SDK包具体操作,参考[full-SDK替换指南](../quick-start/full-sdk-switch-guide.md#full-sdk%E6%9B%BF%E6%8D%A2%E6%8C%87%E5%8D%97)中的替换方法。 +关于如何替换DevEco Studio的SDK包具体操作,参考[full-SDK替换指南](../quick-start/full-sdk-compile-guide.md)中的替换方法。 得到idl工具的可执行文件后,根据具体场景进行后续开发步骤。 @@ -176,6 +176,8 @@ OpenHarmony IDL容器数据类型与Ts数据类型、C++数据类型的对应关 interface OHOS.IIdlTestService { int TestIntTransaction([in] int data); void TestStringTransaction([in] String data); + void TestMapTransaction([in] Map data); + int TestArrayTransaction([in] String[] data); } ``` @@ -203,6 +205,8 @@ OpenHarmony IDL工具生成的Stub类是接口类的抽象实现,并且会声 ```ts import {testIntTransactionCallback} from "./i_idl_test_service"; import {testStringTransactionCallback} from "./i_idl_test_service"; +import {testMapTransactionCallback} from "./i_idl_test_service"; +import {testArrayTransactionCallback} from "./i_idl_test_service"; import IIdlTestService from "./i_idl_test_service"; import rpc from "@ohos.rpc"; @@ -211,8 +215,8 @@ export default class IdlTestServiceStub extends rpc.RemoteObject implements IIdl super(des); } - async onRemoteRequestEx(code: number, data, reply, option): Promise { - console.log("onRemoteRequestEx called, code = " + code); + async onRemoteMessageRequest(code: number, data, reply, option): Promise { + console.log("onRemoteMessageRequest called, code = " + code); switch(code) { case IdlTestServiceStub.COMMAND_TEST_INT_TRANSACTION: { let _data = data.readInt(); @@ -231,6 +235,29 @@ export default class IdlTestServiceStub extends rpc.RemoteObject implements IIdl }); return true; } + case IdlTestServiceStub.COMMAND_TEST_MAP_TRANSACTION: { + let _data = new Map(); + let _dataSize = data.readInt(); + for (let i = 0; i < _dataSize; ++i) { + let key = data.readInt(); + let value = data.readInt(); + _data.set(key, value); + } + this.testMapTransaction(_data, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case IdlTestServiceStub.COMMAND_TEST_ARRAY_TRANSACTION: { + let _data = data.readStringArray(); + this.testArrayTransaction(_data, (errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(returnValue); + } + }); + return true; + } default: { console.log("invalid request code" + code); break; @@ -241,17 +268,23 @@ export default class IdlTestServiceStub extends rpc.RemoteObject implements IIdl testIntTransaction(data: number, callback: testIntTransactionCallback): void{} testStringTransaction(data: string, callback: testStringTransactionCallback): void{} + testMapTransaction(data: Map, callback: testMapTransactionCallback): void{} + testArrayTransaction(data: string[], callback: testArrayTransactionCallback): void{} static readonly COMMAND_TEST_INT_TRANSACTION = 1; static readonly COMMAND_TEST_STRING_TRANSACTION = 2; + static readonly COMMAND_TEST_MAP_TRANSACTION = 3; + static readonly COMMAND_TEST_ARRAY_TRANSACTION = 4; } ``` -开发者需要继承.idl文件中定义的接口类并实现其中的方法。在本示例中,我们继承了IdlTestServiceStub接口类并实现了其中的testIntTransaction和testStringTransaction方法。具体的示例代码如下: +开发者需要继承.idl文件中定义的接口类并实现其中的方法。在本示例中,我们继承了IdlTestServiceStub接口类并实现了其中的testIntTransaction、testStringTransaction、testMapTransaction和testArrayTransaction方法。具体的示例代码如下: ```ts import {testIntTransactionCallback} from "./i_idl_test_service" import {testStringTransactionCallback} from "./i_idl_test_service" +import {testMapTransactionCallback} from "./i_idl_test_service"; +import {testArrayTransactionCallback} from "./i_idl_test_service"; import IdlTestServiceStub from "./idl_test_service_stub" @@ -265,6 +298,14 @@ class IdlTestImp extends IdlTestServiceStub { { callback(0); } + testMapTransaction(data: Map, callback: testMapTransactionCallback): void + { + callback(0); + } + testArrayTransaction(data: string[], callback: testArrayTransactionCallback): void + { + callback(0, 1); + } } ``` @@ -320,11 +361,28 @@ function callbackTestStringTransaction(result: number): void { } } +function callbackTestMapTransaction(result: number): void { + if (result == 0) { + console.log('case 3 success'); + } +} + +function callbackTestArrayTransaction(result: number, ret: number): void { + if (result == 0 && ret == 124) { + console.log('case 4 success'); + } +} + var onAbilityConnectDone = { onConnect:function (elementName, proxy) { let testProxy = new IdlTestServiceProxy(proxy); + let testMap = new Map(); + testMap.set(1, 1); + testMap.set(1, 2); testProxy.testIntTransaction(123, callbackTestIntTransaction); testProxy.testStringTransaction('hello', callbackTestStringTransaction); + testProxy.testMapTransaction(testMap, callbackTestMapTransaction); + testProxy.testArrayTransaction(['1','2'], callbackTestMapTransaction); }, onDisconnect:function (elementName) { console.log('onDisconnectService onDisconnect'); diff --git a/zh-cn/application-dev/application-dev-guide.md b/zh-cn/application-dev/application-dev-guide.md index 15439726df413f25a8d3612e0b10ca9868ca322c..4febc5121809eda48ffcb612229db596840f0907 100644 --- a/zh-cn/application-dev/application-dev-guide.md +++ b/zh-cn/application-dev/application-dev-guide.md @@ -60,13 +60,10 @@ API参考提供了OpenHarmony全量组件和接口的参考文档,可以帮助 内容包括: - [组件参考(基于TS扩展的声明式开发范式)](reference/arkui-ts/Readme-CN.md) - -- [组件参考(基于JS扩展的类Web开发范式)](reference/arkui-js/Readme-CN.md) - +- [组件参考(兼容JS的类Web开发范式-ArkUI.Full)](reference/arkui-js/Readme-CN.md) +- [组件参考(兼容JS的类Web开发范式-ArkUI.Lite)](reference/arkui-js-lite/Readme-CN.md) - [JS服务卡片UI组件参考](reference/js-service-widget-ui/Readme-CN.md) - - [接口参考(JS及TS API)](reference/apis/js-apis-ability-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) diff --git a/zh-cn/application-dev/application-models/Readme-CN.md b/zh-cn/application-dev/application-models/Readme-CN.md index 3c05dfc73ae46d173a51979c963d1f13fefb64e1..ec0c60b405086cd469318f2299cd638681224953 100644 --- a/zh-cn/application-dev/application-models/Readme-CN.md +++ b/zh-cn/application-dev/application-models/Readme-CN.md @@ -17,7 +17,6 @@ - ExtensionAbility组件 - [ExtensionAbility组件概述](extensionability-overview.md) - [ServiceExtensionAbility](serviceextensionability.md) - - [DataShareExtensionAbility(仅对系统应用开放)](datashareextensionability.md) - [FormExtensionAbility(服务卡片)](widget-development-stage.md) - [AccessibilityExtensionAbility](accessibilityextensionability.md) - [EnterpriseAdminExtensionAbility](enterprise-extensionAbility.md) diff --git a/zh-cn/application-dev/application-models/ability-startup-with-implicit-want.md b/zh-cn/application-dev/application-models/ability-startup-with-implicit-want.md index c8cd6dd7620c101ce7aaeba78223a29dae8835be..643b8931eee32882fd66ba9bbccb8acd075ce201 100644 --- a/zh-cn/application-dev/application-models/ability-startup-with-implicit-want.md +++ b/zh-cn/application-dev/application-models/ability-startup-with-implicit-want.md @@ -27,8 +27,7 @@ "host": "www.test.com", "port": "8080", // prefix matching - "pathStartWith": "query", - "type": "text/*" + "pathStartWith": "query" }, { "scheme": "http", @@ -57,8 +56,7 @@ function implicitStartAbility() { "action": "ohos.want.action.viewData", // entities can be omitted. "entities": ["entity.system.browsable"], - "uri": "https://www.test.com:8080/query/student", - "type": "text/plain" + "uri": "https://www.test.com:8080/query/student" } context.startAbility(wantInfo).then(() => { // ... diff --git a/zh-cn/application-dev/application-models/application-context-stage.md b/zh-cn/application-dev/application-models/application-context-stage.md index 6b034680947fff1b9218b3672a6197a7939e1c9a..b959ddaadb8146f814ef151b785c08ce61a09b22 100644 --- a/zh-cn/application-dev/application-models/application-context-stage.md +++ b/zh-cn/application-dev/application-models/application-context-stage.md @@ -19,10 +19,10 @@ ```ts import UIAbility from '@ohos.app.ability.UIAbility'; export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - let uiAbilityContext = this.context; - // ... - } + onCreate(want, launchParam) { + let uiAbilityContext = this.context; + // ... + } } ``` @@ -34,10 +34,10 @@ ```ts import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'; export default class MyService extends ServiceExtensionAbility { - onCreate(want) { - let serviceExtensionContext = this.context; - // ... - } + onCreate(want) { + let serviceExtensionContext = this.context; + // ... + } } ``` - 获取[AbilityStageContext](../reference/apis/js-apis-inner-application-abilityStageContext.md)。Module级别的Context,和基类Context相比,额外提供HapModuleInfo、Configuration等信息。 @@ -45,10 +45,10 @@ ```ts import AbilityStage from "@ohos.app.ability.AbilityStage"; export default class MyAbilityStage extends AbilityStage { - onCreate() { - let abilityStageContext = this.context; - // ... - } + onCreate() { + let abilityStageContext = this.context; + // ... + } } ``` - 获取[ApplicationContext](../reference/apis/js-apis-inner-application-applicationContext.md)。应用级别的Context。ApplicationContext在基类Context的基础上提供了订阅应用内应用组件的生命周期的变化、订阅系统内存变化和订阅应用内系统环境的变化的能力,在UIAbility、ExtensionAbility、AbilityStage中均可以获取。 @@ -56,10 +56,10 @@ ```ts import UIAbility from '@ohos.app.ability.UIAbility'; export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - let applicationContext = this.context.getApplicationContext(); - // ... - } + onCreate(want, launchParam) { + let applicationContext = this.context.getApplicationContext(); + // ... + } } ``` @@ -127,16 +127,16 @@ import UIAbility from '@ohos.app.ability.UIAbility'; export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - let cacheDir = this.context.cacheDir; - let tempDir = this.context.tempDir; - let filesDir = this.context.filesDir; - let databaseDir = this.context.databaseDir; - let bundleCodeDir = this.context.bundleCodeDir; - let distributedFilesDir = this.context.distributedFilesDir; - let preferencesDir = this.context.preferencesDir; - // ... - } + onCreate(want, launchParam) { + let cacheDir = this.context.cacheDir; + let tempDir = this.context.tempDir; + let filesDir = this.context.filesDir; + let databaseDir = this.context.databaseDir; + let bundleCodeDir = this.context.bundleCodeDir; + let distributedFilesDir = this.context.distributedFilesDir; + let preferencesDir = this.context.preferencesDir; + // ... + } } ``` @@ -146,36 +146,42 @@ export default class EntryAbility extends UIAbility { ### 获取和修改加密分区 -上一个场景中,引入了加密等级的概念,通过对[Context的area属性](../reference/apis/js-apis-inner-application-context.md)的读写来实现获取和设置当前加密分区,支持如下两种加密等级: +应用文件加密是一种保护数据安全的方法,可以使得文件在未经授权访问的情况下得到保护。在不同的场景下,应用需要不同程度的文件保护。对于私有文件,如闹铃、壁纸等,应用需要将这些文件放到设备级加密分区(EL1)中,以保证在用户输入密码前就可以被访问;对于更敏感的文件,如个人隐私信息等,应用需要将这些文件放到更高级别的加密分区(EL2)中,以保证更高的安全性。 + +在实际应用中,开发者需要根据不同场景的需求选择合适的加密分区,从而保护应用数据的安全。通过合理使用EL1和EL2加密分区,可以有效提高应用数据的安全性。 -- AreaMode.EL1:设备级加密区,设备开机后可访问的数据区。 +> **说明:** +> +> - AreaMode.EL1:设备级加密区,设备开机后可访问的数据区。 +> +> - AreaMode.EL2:用户级加密区,设备开机,首次输入密码后才能够访问的数据区。 -- AreaMode.EL2:用户级加密区,设备开机,首次输入密码后才能够访问的数据区。 +要实现获取和设置当前加密分区,可以通过读写[Context的area属性](../reference/apis/js-apis-inner-application-context.md)来实现。 ```ts import UIAbility from '@ohos.app.ability.UIAbility'; export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - // 存储普通信息前,切换到EL1设备机加密 - if (this.context.area === 1) { // 获取area - this.context.area = 0; // 修改area - } - // 存储普通信息 - - // 存储敏感信息前,切换到EL2用户级加密 - if (this.context.area === 0) { // 获取area - this.context.area = 1; // 修改area - } - // 存储敏感信息 + onCreate(want, launchParam) { + // 存储普通信息前,切换到EL1设备机加密 + if (this.context.area === 1) { // 获取area + this.context.area = 0; // 修改area + } + // 存储普通信息 + + // 存储敏感信息前,切换到EL2用户级加密 + if (this.context.area === 0) { // 获取area + this.context.area = 1; // 修改area } + // 存储敏感信息 + } } ``` ### 创建其他应用或其他Module的Context -基类Context提供创建其他应用或其他Module的Context的方法有[createBundleContext(bundleName:string)](../reference/apis/js-apis-inner-application-context.md#contextcreatebundlecontext)、[createModuleContext(moduleName:string)](../reference/apis/js-apis-inner-application-context.md#contextcreatemodulecontext)和[createModuleContext(bundleName:string, moduleName:string)](../reference/apis/js-apis-inner-application-context.md#contextcreatemodulecontext-1)接口,创建其他应用或者其他Module的Context,从而通过该Context获取相应的资源信息(例如获取其他Module的[获取应用开发路径](#获取应用开发路径)信息)。 +基类Context提供创建其他应用或其他Module的Context的方法有[createBundleContext(bundleName: string)](../reference/apis/js-apis-inner-application-context.md#contextcreatebundlecontext)、[createModuleContext(moduleName: string)](../reference/apis/js-apis-inner-application-context.md#contextcreatemodulecontext)和[createModuleContext(bundleName: string, moduleName: string)](../reference/apis/js-apis-inner-application-context.md#contextcreatemodulecontext-1)接口,创建其他应用或者其他Module的Context,从而通过该Context获取相应的资源信息(例如获取其他Module的[获取应用开发路径](#获取应用开发路径)信息)。 - 调用createBundleContext(bundleName:string)方法,创建其他应用的Context信息。 > **说明:** @@ -191,12 +197,12 @@ export default class EntryAbility extends UIAbility { import UIAbility from '@ohos.app.ability.UIAbility'; export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - let bundleName2 = "com.example.application"; - let context2 = this.context.createBundleContext(bundleName2); - let label2 = context2.applicationInfo.label; - // ... - } + onCreate(want, launchParam) { + let bundleName2 = "com.example.application"; + let context2 = this.context.createBundleContext(bundleName2); + let label2 = context2.applicationInfo.label; + // ... + } } ``` @@ -212,12 +218,12 @@ export default class EntryAbility extends UIAbility { import UIAbility from '@ohos.app.ability.UIAbility'; export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - let bundleName2 = "com.example.application"; - let moduleName2 = "module1"; - let context2 = this.context.createModuleContext(bundleName2, moduleName2); - // ... - } + onCreate(want, launchParam) { + let bundleName2 = "com.example.application"; + let moduleName2 = "module1"; + let context2 = this.context.createModuleContext(bundleName2, moduleName2); + // ... + } } ``` @@ -227,77 +233,90 @@ export default class EntryAbility extends UIAbility { import UIAbility from '@ohos.app.ability.UIAbility'; export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - let moduleName2 = "module1"; - let context2 = this.context.createModuleContext(moduleName2); - // ... - } + onCreate(want, launchParam) { + let moduleName2 = "module1"; + let context2 = this.context.createModuleContext(moduleName2); + // ... + } } ``` ### 订阅进程内UIAbility生命周期变化 -在应用内的DFX统计场景,如需要统计对应页面停留时间和访问频率等信息,可以使用订阅进程内UIAbility生命周期变化功能。 +在应用内的DFX统计场景中,如需要统计对应页面停留时间和访问频率等信息,可以使用订阅进程内UIAbility生命周期变化功能。 -[ApplicationContext](../reference/apis/js-apis-inner-application-applicationContext)提供了订阅进程内UIAbility生命周期变化的能力。在进程内UIAbility生命周期变化时,如创建、可见/不可见、获焦/失焦、销毁等,会触发进入相应的回调,其中返回的此次注册监听生命周期的ID(每次注册该ID会自增+1,当超过监听上限数量2^63-1时,返回-1),以在[UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md)中使用为例进行说明。 +通过[ApplicationContext](../reference/apis/js-apis-inner-application-applicationContext)提供的能力,可以订阅进程内UIAbility生命周期变化。当进程内的UIAbility生命周期变化时,如创建、可见/不可见、获焦/失焦、销毁等,会触发相应的回调函数。每次注册回调函数时,都会返回一个监听生命周期的ID,此ID会自增+1。当超过监听上限数量2^63-1时,会返回-1。以[UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md)中的使用为例进行说明。 ```ts import UIAbility from '@ohos.app.ability.UIAbility'; import window from '@ohos.window'; -const TAG: string = "[Example].[Entry].[EntryAbility]"; +const TAG: string = '[Example].[Entry].[EntryAbility]'; export default class EntryAbility extends UIAbility { - lifecycleId: number; - - onCreate(want, launchParam) { - let abilityLifecycleCallback = { - onAbilityCreate(uiability) { - console.info(TAG, "onAbilityCreate uiability:" + JSON.stringify(uiability)); - }, - onWindowStageCreate(uiability, windowStage) { - console.info(TAG, "onWindowStageCreate uiability:" + JSON.stringify(uiability)); - console.info(TAG, "onWindowStageCreate windowStage:" + JSON.stringify(windowStage)); - }, - onWindowStageActive(uiability, windowStage) { - console.info(TAG, "onWindowStageActive uiability:" + JSON.stringify(uiability)); - console.info(TAG, "onWindowStageActive windowStage:" + JSON.stringify(windowStage)); - }, - onWindowStageInactive(uiability, windowStage) { - console.info(TAG, "onWindowStageInactive uiability:" + JSON.stringify(uiability)); - console.info(TAG, "onWindowStageInactive windowStage:" + JSON.stringify(windowStage)); - }, - onWindowStageDestroy(uiability, windowStage) { - console.info(TAG, "onWindowStageDestroy uiability:" + JSON.stringify(uiability)); - console.info(TAG, "onWindowStageDestroy windowStage:" + JSON.stringify(windowStage)); - }, - onAbilityDestroy(uiability) { - console.info(TAG, "onAbilityDestroy uiability:" + JSON.stringify(uiability)); - }, - onAbilityForeground(uiability) { - console.info(TAG, "onAbilityForeground uiability:" + JSON.stringify(uiability)); - }, - onAbilityBackground(uiability) { - console.info(TAG, "onAbilityBackground uiability:" + JSON.stringify(uiability)); - }, - onAbilityContinue(uiability) { - console.info(TAG, "onAbilityContinue uiability:" + JSON.stringify(uiability)); - } - } - // 1. 通过context属性获取applicationContext - let applicationContext = this.context.getApplicationContext(); - // 2. 通过applicationContext注册监听应用内生命周期 - this.lifecycleId = applicationContext.on("abilityLifecycle", abilityLifecycleCallback); - console.info(TAG, "register callback number: " + JSON.stringify(this.lifecycleId)); + // 定义生命周期ID + lifecycleId: number; + + onCreate(want, launchParam) { + // 定义生命周期回调对象 + let abilityLifecycleCallback = { + // 当UIAbility创建时被调用 + onAbilityCreate(uiAbility) { + console.log(TAG, `onAbilityCreate uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + }, + // 当窗口创建时被调用 + onWindowStageCreate(uiAbility, windowStage: window.WindowStage) { + console.log(TAG, `onWindowStageCreate uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + console.log(TAG, `onWindowStageCreate windowStage: ${JSON.stringify(windowStage)}`); + }, + // 当窗口处于活动状态时被调用 + onWindowStageActive(uiAbility, windowStage: window.WindowStage) { + console.log(TAG, `onWindowStageActive uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + console.log(TAG, `onWindowStageActive windowStage: ${JSON.stringify(windowStage)}`); + }, + // 当窗口处于非活动状态时被调用 + onWindowStageInactive(uiAbility, windowStage: window.WindowStage) { + console.log(TAG, `onWindowStageInactive uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + console.log(TAG, `onWindowStageInactive windowStage: ${JSON.stringify(windowStage)}`); + }, + // 当窗口被销毁时被调用 + onWindowStageDestroy(uiAbility, windowStage: window.WindowStage) { + console.log(TAG, `onWindowStageDestroy uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + console.log(TAG, `onWindowStageDestroy windowStage: ${JSON.stringify(windowStage)}`); + }, + // 当UIAbility被销毁时被调用 + onAbilityDestroy(uiAbility) { + console.log(TAG, `onAbilityDestroy uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + }, + // 当UIAbility从后台转到前台时触发回调 + onAbilityForeground(uiAbility) { + console.log(TAG, `onAbilityForeground uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + }, + // 当UIAbility从前台转到后台时触发回调 + onAbilityBackground(uiAbility) { + console.log(TAG, `onAbilityBackground uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + }, + // 当UIAbility迁移时被调用 + onAbilityContinue(uiAbility) { + console.log(TAG, `onAbilityContinue uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`); + } } + // 获取应用上下文 + let applicationContext = this.context.getApplicationContext(); + // 注册应用内生命周期回调 + this.lifecycleId = applicationContext.on("abilityLifecycle", abilityLifecycleCallback); + console.log(TAG, `register callback number: ${this.lifecycleId}`); + } - onDestroy() { - let applicationContext = this.context.getApplicationContext(); - applicationContext.off("abilityLifecycle", this.lifecycleId, (error, data) => { - console.info(TAG, "unregister callback success, err: " + JSON.stringify(error)); - }); - } + // ... + + onDestroy() { + // 获取应用上下文 + let applicationContext = this.context.getApplicationContext(); + // 取消应用内生命周期回调 + applicationContext.off("abilityLifecycle", this.lifecycleId); + } } ``` diff --git a/zh-cn/application-dev/application-models/common-event-overview.md b/zh-cn/application-dev/application-models/common-event-overview.md index b9b1e6b174907991e4dc33abd06e7037d903e5ea..b68fdc86e1e9179da08fcaf7fdc48f8c109edc0c 100644 --- a/zh-cn/application-dev/application-models/common-event-overview.md +++ b/zh-cn/application-dev/application-models/common-event-overview.md @@ -15,15 +15,14 @@ OpenHarmony通过CES(Common Event Service,公共事件服务)为应用程 公共事件按发送方式可分为:无序公共事件、有序公共事件和粘性公共事件。 -- 无序公共事件:CES转发公共事件时,不考虑订阅者是否接收到,按订阅者订阅先后顺序转发。 +- 无序公共事件:CES转发公共事件时,不考虑订阅者是否接收到,且订阅者接收到的顺序与其订阅顺序无关。 -- 有序公共事件:CES转发公共事件时,根据订阅者设置的优先级等级,在接收到优先级较高的一个订阅者回复后,再向下一个优先级较低的订阅者转发公共事件。 +- 有序公共事件:CES转发公共事件时,根据订阅者设置的优先级等级,在接收到优先级较高的一个订阅者回复后,再向下一个优先级较低的订阅者转发公共事件。具有相同优先级的订阅者将按随机顺序收到公共事件。 -- 粘性公共事件:能够让订阅者收到在订阅前已经发送的公共事件就是粘性公共事件。普通的公共事件只能在订阅后发送才能收到,而粘性公共事件的特殊性就是可以先发送后订阅。发送粘性事件必须是系统应用或系统服务,且需要申请`ohos.permission.COMMONEVENT_STICKY`权限,配置方式请参见[访问控制授权申请](../security/accesstoken-guidelines.md#配置文件权限声明)。 +- 粘性公共事件:能够让订阅者收到在订阅前已经发送的公共事件就是粘性公共事件。普通的公共事件只能在订阅后发送才能收到,而粘性公共事件的特殊性就是可以先发送后订阅,同时也支持先订阅后发送。发送粘性事件必须是系统应用或系统服务,粘性事件发送后会一直存在系统中,且发送者需要申请`ohos.permission.COMMONEVENT_STICKY`权限,配置方式请参见[配置文件权限声明](../security/accesstoken-guidelines.md#配置文件权限声明)。 每个应用都可以按需订阅公共事件,订阅成功,当公共事件发布时,系统会将其发送给对应的应用。这些公共事件可能来自系统、其他应用和应用自身。 - - **图1** 公共事件示意图 + **图1** 公共事件示意图 ![common-event](figures/common-event.png) diff --git a/zh-cn/application-dev/application-models/extensionability-overview.md b/zh-cn/application-dev/application-models/extensionability-overview.md index 11419851ab216f182e707a023e63be02db361e94..0994ac74ce86b1dfbc860d7be232151efdf6201e 100644 --- a/zh-cn/application-dev/application-models/extensionability-overview.md +++ b/zh-cn/application-dev/application-models/extensionability-overview.md @@ -25,6 +25,13 @@ ExtensionAbility组件是基于特定场景(例如服务卡片、输入法等 - [EnterpriseAdminExtensionAbility](../reference/apis/js-apis-EnterpriseAdminExtensionAbility.md):ENTERPRISE_ADMIN类型的ExtensionAbility组件,用于提供企业管理时处理管理事件的能力,比如设备上应用安装事件、锁屏密码输入错误次数过多事件等。 +> **说明:** +> 1. OpenHarmony不支持三方应用实现ServiceExtensionAbility、DataShareExtensionAbility、StaticSubscriberExtensionAbility和WindowExtensionAbility。 +> +> 2. 如果三方开发者想要实现后台处理相关事务的功能,无法使用ServiceExtensionAbility,可以使用后台任务,具体请参见[后台任务](../task-management/background-task-overview.md)。 +> +> 3. 三方应用只能使用当前系统已定义的上述类型的ExtensionAbility。 + ## 使用指定类型的ExtensionAbility组件 @@ -48,11 +55,11 @@ ExtensionAbility组件是基于特定场景(例如服务卡片、输入法等 > **说明:** > 同一应用内的所有同类型的ExtensionAbility运行在同一独立进程(除ServiceExtensionAbility、DataShareExtensionAbility外),跟UIAbility组件不在同一进程,Stage模型的进程模型请参见[进程模型](process-model-stage.md)。 -> +> > 例如一个应用有1个UIAbility组件、1个ServiceExtensionAbility、1个DataShareExtensionAbility、2个FormExtensionAbility、1个ImeExtensionAbility。则该应用在运行时,有三个进程: -> +> > - UIAbility、ServiceExtensionAbility、DataShareExtensionAbility运行在同一个进程。 -> +> > - FormExtensionAbility运行在一个独立进程。 -> +> > - ImeExtensionAbility运行在一个独立进程。 diff --git a/zh-cn/application-dev/application-models/hop-cross-device-migration.md b/zh-cn/application-dev/application-models/hop-cross-device-migration.md index ae9eb5bd2f164f527441958c57ddb6544e02061a..cf25e93206af9f1f131d415f480c6be920d3e4f4 100644 --- a/zh-cn/application-dev/application-models/hop-cross-device-migration.md +++ b/zh-cn/application-dev/application-models/hop-cross-device-migration.md @@ -47,60 +47,38 @@ ## 开发步骤 -1. 在module.json5配置数据同步权限,示例代码如下。 - +1. 需要申请`ohos.permission.DISTRIBUTED_DATASYNC`权限,配置方式请参见[配置文件权限声明](../security/accesstoken-guidelines.md#配置文件权限声明)。 + +2. 同时需要在应用首次启动时弹窗向用户申请授权,使用方式请参见[向用户申请授权](../security/accesstoken-guidelines.md#向用户申请授权)。 + +3. 在配置文件中配置跨端迁移相关标签字段。 + + 配置应用支持迁移 + 在module.json5中配置continuable标签:true表示支持迁移,false表示不支持,默认为false。配置为false的UIAbility将被系统识别为无法迁移。 + + ```json { "module": { - "requestPermissions":[ - { - "name" : "ohos.permission.DISTRIBUTED_DATASYNC", + // ... + "abilities": [ + { + // ... + "continuable": true, } ] } } ``` -2. 在配置文件中配置跨端迁移相关标签字段。 - - 配置应用支持迁移 - 在module.json5中配置continuable标签:true表示支持迁移,false表示不支持,默认为false。配置为false的UIAbility将被系统识别为无法迁移。 - - - ```json - { - "module": { - // ... - "abilities": [ - { - // ... - "continuable": true, - } - ] - } - } - ``` - - 根据需要配置应用启动模式类型,配置详情请参照[UIAbility组件启动模式](uiability-launch-type.md)。 - -3. 申请数据同步权限,弹框示例代码。 - - ```ts - requestPermission() { - let context = this.context - let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'] - context.requestPermissionsFromUser(permissions).then((data) => { - console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)) - }).catch((error) => { - console.info("Failed to request permission from user with error: "+ JSON.stringify(error)) - }) - } - ``` + 根据需要配置应用启动模式类型,配置详情请参照[UIAbility组件启动模式](uiability-launch-type.md)。 4. 在发起端UIAbility中实现[onContinue()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncontinue)接口。 - 当应用触发迁移时,[onContinue()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncontinue)接口在发起端被调用,开发者可以在该接口中保存迁移数据,实现应用兼容性检测,决定是否支持此次迁移。 + 当应用触发迁移时,[onContinue()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncontinue)接口在发起端被调用,开发者可以在该接口中保存迁移数据,实现应用兼容性检测,决定是否支持此次迁移。 - 保存迁移数据:开发者可以将要迁移的数据通过键值对的方式保存在wantParam中。 - + - 应用兼容性检测:开发者可以通过从wantParam中获取目标应用的版本号与本应用版本号做兼容性校验。 - + - 迁移决策:开发者可以通过onContinue接口的返回值决定是否支持此次迁移,返回值信息见[接口说明](#接口说明)。 示例如下: diff --git a/zh-cn/application-dev/application-models/hop-multi-device-collaboration.md b/zh-cn/application-dev/application-models/hop-multi-device-collaboration.md index 4e8851aca08ad2ed5906db94af9fc24f25f281d6..c7d4a8c3860cbb4396a519bce9627e6c67109c78 100644 --- a/zh-cn/application-dev/application-models/hop-multi-device-collaboration.md +++ b/zh-cn/application-dev/application-models/hop-multi-device-collaboration.md @@ -47,24 +47,12 @@ ### 开发步骤 -1. 申请`ohos.permission.DISTRIBUTED_DATASYNC`权限,配置方式请参见[访问控制授权申请](../security/accesstoken-guidelines.md#配置文件权限声明)。 +1. 需要申请`ohos.permission.DISTRIBUTED_DATASYNC`权限,配置方式请参见[配置文件权限声明](../security/accesstoken-guidelines.md#配置文件权限声明)。 -2. 申请数据同步权限,弹框示例代码。 - - ```ts - requestPermission() { - let context = this.context; - let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']; - context.requestPermissionsFromUser(permissions).then((data) => { - console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)); - }).catch((error) => { - console.info("Failed to request permission from user with error: "+ JSON.stringify(error)); - }) - } - ``` +2. 同时需要在应用首次启动时弹窗向用户申请授权,使用方式请参见[向用户申请授权](../security/accesstoken-guidelines.md#向用户申请授权)。 3. 获取目标设备的设备ID。 - + ```ts import deviceManager from '@ohos.distributedHardware.deviceManager'; @@ -94,7 +82,7 @@ ``` 4. 设置目标组件参数,调用[startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)接口,启动UIAbility或ServiceExtensionAbility。 - + ```ts let want = { deviceId: getRemoteDeviceId(), @@ -129,24 +117,12 @@ ### 开发步骤 -1. 申请`ohos.permission.DISTRIBUTED_DATASYNC`权限,配置方式请参见[访问控制授权申请](../security/accesstoken-guidelines.md#配置文件权限声明)。 +1. 需要申请`ohos.permission.DISTRIBUTED_DATASYNC`权限,配置方式请参见[配置文件权限声明](../security/accesstoken-guidelines.md#配置文件权限声明)。 -2. 申请数据同步权限,弹框示例代码。 - - ```ts - requestPermission() { - let context = this.context; - let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']; - context.requestPermissionsFromUser(permissions).then((data) => { - console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)); - }).catch((error) => { - console.info("Failed to request permission from user with error: "+ JSON.stringify(error)); - }) - } - ``` +2. 同时需要在应用首次启动时弹窗向用户申请授权,使用方式请参见[向用户申请授权](../security/accesstoken-guidelines.md#向用户申请授权)。 3. 在发起端设置目标组件参数,调用startAbilityForResult()接口启动目标端UIAbility,异步回调中的data用于接收目标端UIAbility停止自身后返回给调用方UIAbility的信息。getRemoteDeviceId方法参照[通过跨设备启动uiability和serviceextensionability组件实现多端协同无返回数据](#通过跨设备启动uiability和serviceextensionability组件实现多端协同无返回数据)。 - + ```ts let want = { deviceId: getRemoteDeviceId(), @@ -163,7 +139,7 @@ ``` 4. 在目标端UIAbility任务完成后,调用terminateSelfWithResult()方法,将数据返回给发起端的UIAbility。 - + ```ts const RESULT_CODE: number = 1001; let abilityResult = { @@ -181,7 +157,7 @@ ``` 5. 发起端UIAbility接收到目标端UIAbility返回的信息,对其进行处理。 - + ```ts const RESULT_CODE: number = 1001; @@ -218,21 +194,9 @@ ### 开发步骤 -1. 申请`ohos.permission.DISTRIBUTED_DATASYNC`权限,配置方式请参见[访问控制授权申请](../security/accesstoken-guidelines.md#配置文件权限声明)。 - -2. 申请数据同步权限,弹框示例代码。 - - ```ts - requestPermission() { - let context = this.context; - let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']; - context.requestPermissionsFromUser(permissions).then((data) => { - console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)); - }).catch((error) => { - console.info("Failed to request permission from user with error: "+ JSON.stringify(error)); - }) - } - ``` +1. 需要申请`ohos.permission.DISTRIBUTED_DATASYNC`权限,配置方式请参见[配置文件权限声明](../security/accesstoken-guidelines.md#配置文件权限声明)。 + +2. 同时需要在应用首次启动时弹窗向用户申请授权,使用方式请参见[向用户申请授权](../security/accesstoken-guidelines.md#向用户申请授权)。 3. 如果已有后台服务,请直接进入下一步;如果没有,则[实现一个后台服务](serviceextensionability.md#实现一个后台服务仅对系统应用开放)。 @@ -292,7 +256,7 @@ getRemoteDeviceId方法参照[通过跨设备启动uiability和serviceextensionability组件实现多端协同无返回数据](#通过跨设备启动uiability和serviceextensionability组件实现多端协同无返回数据)。 5. 断开连接。调用disconnectServiceExtensionAbility()断开与后台服务的连接。 - + ```ts let connectionId = 1 // 在通过connectServiceExtensionAbility绑定服务时返回的Id this.context.disconnectServiceExtensionAbility(connectionId).then((data) => { @@ -327,116 +291,104 @@ ### 开发步骤 -1. 申请`ohos.permission.DISTRIBUTED_DATASYNC`权限,配置方式请参见[访问控制授权申请](../security/accesstoken-guidelines.md#配置文件权限声明)。 - -2. 申请数据同步权限,弹框示例代码。 - - ```ts - requestPermission() { - let context = this.context; - let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']; - context.requestPermissionsFromUser(permissions).then((data) => { - console.info("Succeed to request permission from user with data: "+ JSON.stringify(data)); - }).catch((error) => { - console.info("Failed to request permission from user with error: "+ JSON.stringify(error)); - }) - } - ``` +1. 需要申请`ohos.permission.DISTRIBUTED_DATASYNC`权限,配置方式请参见[配置文件权限声明](../security/accesstoken-guidelines.md#配置文件权限声明)。 + +2. 同时需要在应用首次启动时弹窗向用户申请授权,使用方式请参见[向用户申请授权](../security/accesstoken-guidelines.md#向用户申请授权)。 3. 创建被调用端UIAbility。 - 被调用端UIAbility需要实现指定方法的数据接收回调函数、数据的序列化及反序列化方法。在需要接收数据期间,通过on接口注册监听,无需接收数据时通过off接口解除监听。 + 被调用端UIAbility需要实现指定方法的数据接收回调函数、数据的序列化及反序列化方法。在需要接收数据期间,通过on接口注册监听,无需接收数据时通过off接口解除监听。 - 1. 配置UIAbility的启动模式。 - 配置module.json5,将CalleeAbility配置为单实例"singleton"。 + 1. 配置UIAbility的启动模式。 + 配置module.json5,将CalleeAbility配置为单实例"singleton"。 - | Json字段 | 字段说明 | - | -------- | -------- | - | “launchType” | Ability的启动模式,设置为"singleton"类型。 | + | Json字段 | 字段说明 | + | -------- | -------- | + | “launchType” | Ability的启动模式,设置为"singleton"类型。 | - UIAbility配置标签示例如下: + UIAbility配置标签示例如下: - - ```json - "abilities":[{ - "name": ".CalleeAbility", - "srcEntrance": "./ets/CalleeAbility/CalleeAbility.ts", - "launchType": "singleton", - "description": "$string:CalleeAbility_desc", - "icon": "$media:icon", - "label": "$string:CalleeAbility_label", - "visible": true - }] - ``` - 2. 导入UIAbility模块。 - - ```ts - import Ability from '@ohos.app.ability.UIAbility'; - ``` - 3. 定义约定的序列化数据。 - 调用端及被调用端发送接收的数据格式需协商一致,如下示例约定数据由number和string组成。 + + ```json + "abilities":[{ + "name": ".CalleeAbility", + "srcEntrance": "./ets/CalleeAbility/CalleeAbility.ts", + "launchType": "singleton", + "description": "$string:CalleeAbility_desc", + "icon": "$media:icon", + "label": "$string:CalleeAbility_label", + "visible": true + }] + ``` + 2. 导入UIAbility模块。 + + ```ts + import Ability from '@ohos.app.ability.UIAbility'; + ``` + 3. 定义约定的序列化数据。 + 调用端及被调用端发送接收的数据格式需协商一致,如下示例约定数据由number和string组成。 - - ```ts - export default class MyParcelable { - num: number = 0; - str: string = ""; - - constructor(num, string) { - this.num = num; - this.str = string; - } - - marshalling(messageSequence) { - messageSequence.writeInt(this.num); - messageSequence.writeString(this.str); - return true; - } - - unmarshalling(messageSequence) { - this.num = messageSequence.readInt(); - this.str = messageSequence.readString(); - return true; - } - } - ``` - 4. 实现Callee.on监听及Callee.off解除监听。 - 如下示例在Ability的onCreate注册MSG_SEND_METHOD监听,在onDestroy取消监听,收到序列化数据后作相应处理并返回。应用开发者根据实际业务需要做相应处理。 - ```ts - const TAG: string = '[CalleeAbility]'; - const MSG_SEND_METHOD: string = 'CallSendMsg'; - - function sendMsgCallback(data) { - console.info('CalleeSortFunc called'); - - // 获取Caller发送的序列化数据 - let receivedData = new MyParcelable(0, ''); - data.readParcelable(receivedData); - console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`); - - // 作相应处理 - // 返回序列化数据result给Caller - return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`); - } - - export default class CalleeAbility extends Ability { - onCreate(want, launchParam) { - try { - this.callee.on(MSG_SEND_METHOD, sendMsgCallback); - } catch (error) { - console.info(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`); - } - } - - onDestroy() { - try { - this.callee.off(MSG_SEND_METHOD); - } catch (error) { - console.error(TAG, `${MSG_SEND_METHOD} unregister failed with error ${JSON.stringify(error)}`); - } - } - } - ``` + ```ts + export default class MyParcelable { + num: number = 0; + str: string = ""; + + constructor(num, string) { + this.num = num; + this.str = string; + } + + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); + return true; + } + + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); + return true; + } + } + ``` + 4. 实现Callee.on监听及Callee.off解除监听。 + 如下示例在Ability的onCreate注册MSG_SEND_METHOD监听,在onDestroy取消监听,收到序列化数据后作相应处理并返回。应用开发者根据实际业务需要做相应处理。 + + ```ts + const TAG: string = '[CalleeAbility]'; + const MSG_SEND_METHOD: string = 'CallSendMsg'; + + function sendMsgCallback(data) { + console.info('CalleeSortFunc called'); + + // 获取Caller发送的序列化数据 + let receivedData = new MyParcelable(0, ''); + data.readParcelable(receivedData); + console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`); + + // 作相应处理 + // 返回序列化数据result给Caller + return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`); + } + + export default class CalleeAbility extends Ability { + onCreate(want, launchParam) { + try { + this.callee.on(MSG_SEND_METHOD, sendMsgCallback); + } catch (error) { + console.info(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`); + } + } + + onDestroy() { + try { + this.callee.off(MSG_SEND_METHOD); + } catch (error) { + console.error(TAG, `${MSG_SEND_METHOD} unregister failed with error ${JSON.stringify(error)}`); + } + } + } + ``` 4. 获取Caller接口,访问被调用端UIAbility。 1. 导入UIAbility模块。 @@ -512,8 +464,8 @@ ``` 6. 释放Caller通信接口。 - Caller不再使用后,应用开发者可以通过release接口释放Caller。 - + Caller不再使用后,应用开发者可以通过release接口释放Caller。 + ```ts releaseCall() { try { diff --git a/zh-cn/application-dev/application-models/mission-management-overview.md b/zh-cn/application-dev/application-models/mission-management-overview.md index 527a00d8dcca4221251bf2bbb9ec4e6ecc7baa75..fa7835d59990e941c5aa33ef633b265b4b54270d 100644 --- a/zh-cn/application-dev/application-models/mission-management-overview.md +++ b/zh-cn/application-dev/application-models/mission-management-overview.md @@ -30,102 +30,100 @@ 一个UIAbility实例对应一个单独的任务,因此应用调用[startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法启动一个UIAbility时,就是创建了一个任务。 - -桌面应用调用[missionManager](../reference/apis/js-apis-application-missionManager.md)的接口管理任务,需要申请`ohos.permission.MANAGE_MISSIONS`权限,配置方式请参见[访问控制授权申请](../security/accesstoken-guidelines.md#配置文件权限声明)。 - - -利用missionManager进行任务管理(监听任务变化、获取任务信息、获取任务快照、清理任务、任务加锁/解锁等),示例代码如下: - - - -```ts -import missionManager from '@ohos.app.ability.missionManager' - -let listener = { - // 任务创建 - onMissionCreated: function (mission) { - console.info("--------onMissionCreated-------") - }, - // 任务销毁 - onMissionDestroyed: function (mission) { - console.info("--------onMissionDestroyed-------") - }, - // 任务快照变化 - onMissionSnapshotChanged: function (mission) { - console.info("--------onMissionSnapshotChanged-------") - }, - // 任务被移动到前台 - onMissionMovedToFront: function (mission) { - console.info("--------onMissionMovedToFront-------") - }, - // 任务图标变化 - onMissionIconUpdated: function (mission, icon) { - console.info("--------onMissionIconUpdated-------") - }, - // 任务名称变化 - onMissionLabelUpdated: function (mission) { - console.info("--------onMissionLabelUpdated-------") - }, - // 任务实例被关闭 - onMissionClosed: function (mission) { - console.info("--------onMissionClosed-------") - } -}; - -// 1.注册任务变化通知 -let listenerId = missionManager.on('mission', listener); - -// 2.获取系统最近20个任务 -missionManager.getMissionInfos("", 20, (error, missions) => { - console.info("getMissionInfos is called, error.code = " + error.code); - console.info("size = " + missions.length); - console.info("missions = " + JSON.stringify(missions)); -}); - -// 3.获取单个任务的详细信息() -let missionId = 11; // 11只是示例,实际是从系统中获取的任务id,下面类似 -let mission = missionManager.getMissionInfo("", missionId).catch(function (err) { - console.info(err); -}); - -// 4.获取任务快照 -missionManager.getMissionSnapShot("", missionId, (error, snapshot) => { - console.info("getMissionSnapShot is called, error.code = " + error.code); - console.info("bundleName = " + snapshot.ability.bundleName); -}) - -// 5.获取低分辨任务快照 -missionManager.getLowResolutionMissionSnapShot("", missionId, (error, snapshot) => { - console.info("getLowResolutionMissionSnapShot is called, error.code = " + error.code); - console.info("bundleName = " + snapshot.ability.bundleName); -}) - -// 6.加锁/解锁任务 -missionManager.lockMission(missionId).then(() => { - console.info("lockMission is called "); -}); - -missionManager.unlockMission(missionId).then(() => { - console.info("unlockMission is called "); -}); - -// 7.把任务切到前台 -missionManager.moveMissionToFront(missionId).then(() => { - console.info("moveMissionToFront is called "); -}); - -// 8.删除单个任务 -missionManager.clearMission(missionId).then(() => { - console.info("clearMission is called "); -}); - -// 9.删除全部任务 -missionManager.clearAllMissions().catch(function (err) { - console.info(err); -}); - -// 10.解注册任务变化通知 -missionManager.off('mission', listenerId, (error) => { - console.info("unregisterMissionListener"); -}) -``` +1. 桌面应用调用[missionManager](../reference/apis/js-apis-application-missionManager.md)的接口管理任务,需要申请`ohos.permission.MANAGE_MISSIONS`权限,配置方式请参见[配置文件权限声明](../security/accesstoken-guidelines.md#配置文件权限声明)。 + +2. 利用missionManager进行任务管理(监听任务变化、获取任务信息、获取任务快照、清理任务、任务加锁/解锁等)。 + + ```ts + import missionManager from '@ohos.app.ability.missionManager' + + let listener = { + // 任务创建 + onMissionCreated: function (mission) { + console.info("--------onMissionCreated-------") + }, + // 任务销毁 + onMissionDestroyed: function (mission) { + console.info("--------onMissionDestroyed-------") + }, + // 任务快照变化 + onMissionSnapshotChanged: function (mission) { + console.info("--------onMissionSnapshotChanged-------") + }, + // 任务被移动到前台 + onMissionMovedToFront: function (mission) { + console.info("--------onMissionMovedToFront-------") + }, + // 任务图标变化 + onMissionIconUpdated: function (mission, icon) { + console.info("--------onMissionIconUpdated-------") + }, + // 任务名称变化 + onMissionLabelUpdated: function (mission) { + console.info("--------onMissionLabelUpdated-------") + }, + // 任务实例被关闭 + onMissionClosed: function (mission) { + console.info("--------onMissionClosed-------") + } + }; + + // 1.注册任务变化通知 + let listenerId = missionManager.on('mission', listener); + + // 2.获取系统最近20个任务 + missionManager.getMissionInfos("", 20, (error, missions) => { + console.info("getMissionInfos is called, error.code = " + error.code); + console.info("size = " + missions.length); + console.info("missions = " + JSON.stringify(missions)); + }); + + // 3.获取单个任务的详细信息() + let missionId = 11; // 11只是示例,实际是从系统中获取的任务id,下面类似 + let mission = missionManager.getMissionInfo("", missionId).catch(function (err) { + console.info(err); + }); + + // 4.获取任务快照 + missionManager.getMissionSnapShot("", missionId, (error, snapshot) => { + console.info("getMissionSnapShot is called, error.code = " + error.code); + console.info("bundleName = " + snapshot.ability.bundleName); + }) + + // 5.获取低分辨任务快照 + missionManager.getLowResolutionMissionSnapShot("", missionId, (error, snapshot) => { + console.info("getLowResolutionMissionSnapShot is called, error.code = " + error.code); + console.info("bundleName = " + snapshot.ability.bundleName); + }) + + // 6.加锁/解锁任务 + missionManager.lockMission(missionId).then(() => { + console.info("lockMission is called "); + }); + + missionManager.unlockMission(missionId).then(() => { + console.info("unlockMission is called "); + }); + + // 7.把任务切到前台 + missionManager.moveMissionToFront(missionId).then(() => { + console.info("moveMissionToFront is called "); + }); + + // 8.删除单个任务 + missionManager.clearMission(missionId).then(() => { + console.info("clearMission is called "); + }); + + // 9.删除全部任务 + missionManager.clearAllMissions().catch(function (err) { + console.info(err); + }); + + // 10.解注册任务变化通知 + missionManager.off('mission', listenerId, (error) => { + console.info("unregisterMissionListener"); + }) + ``` + + diff --git a/zh-cn/application-dev/application-models/request-permissions.md b/zh-cn/application-dev/application-models/request-permissions.md index f37c6ba9442f2ee813204982fef1c0a98eb77ec4..e9b8ff5b090c1c3d983b9285e4d49bffe777569e 100644 --- a/zh-cn/application-dev/application-models/request-permissions.md +++ b/zh-cn/application-dev/application-models/request-permissions.md @@ -9,37 +9,7 @@ 在config.json声明需要的权限,在module下添加"reqPermissions",并写入对应权限。 +例如申请访问日历权限: -如申请访问日历权限,需要申请`ohos.permission.READ_CALENDAR`权限,配置方式请参见[访问控制授权申请](../security/accesstoken-guidelines.md#配置文件权限声明)。 - - - 对应config.json文件的示例代码如下所示: - -```json -{ - "module": { - // ... - "reqPermissions": [ - { - "name": "ohos.permission.READ_CALENDAR" - // ... - } - ] - } -} -``` - - -通过动态弹窗向用户申请授权: - -```ts -import featureAbility from '@ohos.ability.featureAbility'; - -let context = featureAbility.getContext(); -let permissions: Array = ['ohos.permission.READ_CALENDAR'] -context.requestPermissionsFromUser(permissions, 1).then((data) => { - console.info("Succeed to request permission from user with data: " + JSON.stringify(data)) -}).catch((error) => { - console.info("Failed to request permission from user with error: " + JSON.stringify(error)) -}) -``` +1. 需要申请`ohos.permission.DISTRIBUTED_DATASYNC`权限,配置方式请参见[配置文件权限声明](../security/accesstoken-guidelines.md#配置文件权限声明)。 +2. 同时需要在应用首次启动时弹窗向用户申请授权,使用方式请参见[向用户申请授权](../security/accesstoken-guidelines.md#向用户申请授权)。 diff --git a/zh-cn/application-dev/application-models/stage-model-development-overview.md b/zh-cn/application-dev/application-models/stage-model-development-overview.md index e54ad806a83440b010e74ae49c5d3c4379537c9e..b3e6271352001f51614614411a2db30d2146b28b 100644 --- a/zh-cn/application-dev/application-models/stage-model-development-overview.md +++ b/zh-cn/application-dev/application-models/stage-model-development-overview.md @@ -10,7 +10,7 @@ - [UIAbility组件](uiability-overview.md)和[ExtensionAbility组件](extensionability-overview.md) - Stage模型提供UIAbility和ExtensionAbility两种类型的组件,这两种组件都有具体的类承载,支持面向对象的开发方式。他们是Ability抽象概念在Stage模型上的具体实现。他们是Ability管理服务调度的单元,其生命周期都是由Ability管理服务进行调度的。 + Stage模型提供UIAbility和ExtensionAbility两种类型的组件,这两种组件都有具体的类承载,支持面向对象的开发方式。 - UIAbility组件是一种包含UI界面的应用组件,主要用于和用户交互。例如,图库类应用可以在UIAbility组件中展示图片瀑布流,在用户选择某个图片后,在新的页面中展示图片的详细内容。同时用户可以通过返回键返回到瀑布流页面。UIAbility的生命周期只包含创建/销毁/前台/后台等状态,与显示相关的状态通过WindowStage的事件暴露给开发者。 diff --git a/zh-cn/application-dev/application-models/uiability-data-sync-with-ui.md b/zh-cn/application-dev/application-models/uiability-data-sync-with-ui.md index e90966c58eb9b963f88411127db3cc6890e60e76..3af7d1991cfba406a9fa988c8eb739aa8f548366 100644 --- a/zh-cn/application-dev/application-models/uiability-data-sync-with-ui.md +++ b/zh-cn/application-dev/application-models/uiability-data-sync-with-ui.md @@ -240,10 +240,6 @@ Stage模型上同名对象覆盖导致问题的场景举例说明。 struct Index { onPageShow() { let ctx = globalThis.context; // 页面中从globalThis中取出context并使用 - let permissions = ['com.example.permission'] - ctx.requestPermissionsFromUser(permissions,(result) => { - // ... - }); } // 页面展示 build() { @@ -251,7 +247,7 @@ Stage模型上同名对象覆盖导致问题的场景举例说明。 } } ``` - + 3. 在UIAbilityB文件中使用globalThis中存放了[UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md),并且命名为相同的名称。 ```ts @@ -274,10 +270,6 @@ Stage模型上同名对象覆盖导致问题的场景举例说明。 struct Index { onPageShow() { let ctx = globalThis.context; // Page中从globalThis中取出context并使用 - let permissions = ['com.example.permission'] - ctx.requestPermissionsFromUser(permissions,(result) => { - console.info('requestPermissionsFromUser result:' + JSON.stringify(result)); - }); } // 页面展示 build() { @@ -285,7 +277,7 @@ Stage模型上同名对象覆盖导致问题的场景举例说明。 } } ``` - + 5. 在UIAbilityB实例切换至后台,将UIAbilityA实例从后台切换回到前台。此时UIAbilityA的onCreate生命周期不会再次进入。 ```ts @@ -307,10 +299,6 @@ Stage模型上同名对象覆盖导致问题的场景举例说明。 struct Index { onPageShow() { let ctx = globalThis.context; // 这时候globalThis中的context是UIAbilityB的context - let permissions=['com.example.permission']; - ctx.requestPermissionsFromUser(permissions,(result) => { // 使用这个对象就会导致进程崩溃 - console.info('requestPermissionsFromUser result:' + JSON.stringify(result)); - }); } // 页面展示 build() { diff --git a/zh-cn/application-dev/application-models/uiability-overview.md b/zh-cn/application-dev/application-models/uiability-overview.md index 56022de24ac87603a5a4fa985a633f72b4d7abd7..94c2d2317cf542d016767efcd7c132a036ab77fa 100644 --- a/zh-cn/application-dev/application-models/uiability-overview.md +++ b/zh-cn/application-dev/application-models/uiability-overview.md @@ -5,10 +5,24 @@ UIAbility组件是一种包含UI界面的应用组件,主要用于和用户交互。 -UIAbility组件是系统调度的基本单元,为应用提供绘制界面的窗口。一个应用可以包含一个或多个UIAbility组件。例如,在支付应用中,可以将入口功能和收付款功能分别配置为独立的UIAbility。建议将相同的功能模块放在同一个UIAbility中,以多页面的形式呈现。 +UIAbility的设计理念: + +1. 原生支持应用组件级的[跨端迁移](hop-cross-device-migration.md)和[多端协同](hop-multi-device-collaboration.md) + +2. 支持多设备和多窗口形态 + +关于UIAbility的设计理念,请详细参考[Stage模型的设计理念。](application-model-description.md) + +UIAbility划分原则与建议: +UIAbility组件是系统调度的基本单元,为应用提供绘制界面的窗口。一个应用可以包含一个或多个UIAbility组件。例如,在支付应用中,可以将入口功能和收付款功能分别配置为独立的UIAbility。 每一个UIAbility组件实例都会在最近任务列表中显示一个对应的任务。 +对于开发者而言,可以根据具体场景选择单个还是多个UIAbility,划分建议如下: + +- 如果开发者希望在任务视图中看到一个任务,则建议使用一个UIAbility,多个页面的方式。 + +- 如果开发者希望在任务视图中看到多个任务,或者需要同时开启多个窗口,则建议使用多个UIAbility开发不同的模块功能。 ## 声明配置 diff --git a/zh-cn/application-dev/connectivity/http-request.md b/zh-cn/application-dev/connectivity/http-request.md index 8c4c663fcc800a1998168aed065fd3e568a5e329..cec44400b724fc3ca43edc77a37e63d4e9ffc0d0 100644 --- a/zh-cn/application-dev/connectivity/http-request.md +++ b/zh-cn/application-dev/connectivity/http-request.md @@ -90,6 +90,78 @@ httpRequest.request( ); ``` +## request2接口开发步骤 + +1. 从@ohos.net.http.d.ts中导入http命名空间。 +2. 调用createHttp()方法,创建一个HttpRequest对象。 +3. 调用该对象的on()方法,可以根据业务需要订阅HTTP响应头事件、HTTP流式响应数据接收事件、HTTP流式响应数据接收进度事件和HTTP流式响应数据接收完毕事件。 +4. 调用该对象的request2()方法,传入http请求的url地址和可选参数,发起网络请求。 +5. 按照实际业务需要,可以解析返回的响应码。 +6. 调用该对象的off()方法,取消订阅相应事件。 +7. 当该请求使用完毕时,调用destroy()方法主动销毁。 + +```js +// 引入包名 +import http from '@ohos.net.http' + +// 每一个httpRequest对应一个HTTP请求任务,不可复用 +let httpRequest = http.createHttp(); +// 用于订阅HTTP响应头事件 +httpRequest.on('headersReceive', (header) => { + console.info('header: ' + JSON.stringify(header)); +}); +// 用于订阅HTTP流式响应数据接收事件 +let res = ''; +httpRequest.on('dataReceive', (data) => { + res += data; + console.info('res: ' + res); +}); +// 用于订阅HTTP流式响应数据接收完毕事件 +httpRequest.on('dataEnd', () => { + console.info('No more data in response, data receive end'); +}); +// 用于订阅HTTP流式响应数据接收进度事件 +httpRequest.on('dataProgress', (data) => { + console.log("dataProgress receiveSize:" + data.receiveSize+ ", totalSize:" + data.totalSize); +}); + +httpRequest.request2( + // 填写HTTP请求的URL地址,可以带参数也可以不带参数。URL地址需要开发者自定义。请求的参数可以在extraData中指定 + "EXAMPLE_URL", + { + method: http.RequestMethod.POST, // 可选,默认为http.RequestMethod.GET + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json' + }, + // 当使用POST请求时此字段用于传递内容 + extraData: { + "data": "data to send", + }, + expectDataType: http.HttpDataType.STRING, // 可选,指定返回数据的类型 + usingCache: true, // 可选,默认为true + priority: 1, // 可选,默认为1 + connectTimeout: 60000, // 可选,默认为60000ms + readTimeout: 60000, // 可选,默认为60000ms。若传输的数据较大,需要较长的时间,建议增大该参数以保证数据传输正常终止 + usingProtocol: http.HttpProtocol.HTTP1_1, // 可选,协议类型默认值由系统自动指定 + }, (err, data) => { + console.info('error:' + JSON.stringify(err)); + console.info('ResponseCode :' + JSON.stringify(data)); + // 取消订阅HTTP响应头事件 + httpRequest.off('headersReceive'); + // 取消订阅HTTP流式响应数据接收事件 + httpRequest.off('dataReceive'); + // 取消订阅HTTP流式响应数据接收进度事件 + httpRequest.off('dataProgress'); + // 取消订阅HTTP流式响应数据接收完毕事件 + httpRequest.off('dataEnd'); + // 当该请求使用完毕时,调用destroy方法主动销毁 + httpRequest.destroy(); + } +); + +``` + ## 相关实例 针对HTTP数据请求,有以下相关实例可供参考: - [`Http:`数据请求(ArkTS)(API9))](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/Connectivity/Http) diff --git a/zh-cn/application-dev/dfx/apprecovery-guidelines.md b/zh-cn/application-dev/dfx/apprecovery-guidelines.md index 32d673bae7f18506e4062ddefe5dddac81eb8921..393083bb068e7f282675e166e24c012e2dd0e877 100644 --- a/zh-cn/application-dev/dfx/apprecovery-guidelines.md +++ b/zh-cn/application-dev/dfx/apprecovery-guidelines.md @@ -5,29 +5,48 @@ 应用在运行中不可避免会产生一些非预期的行为,如运行时抛出未处理的异常和错误,违反框架的调用/运行约束等。 系统默认对异常的处理方式为进程退出,如果应用使用过程中产生了用户数据,直接退出可能会导致用户工作中断,数据丢失。 -如果使用应用故障恢复相关接口,则可对临时数据进行保存,应用退出后会重启应用并恢复先前的状态和数据,能给用户带来更好的使用体验。 +如果应用使能了应用恢复功能,并对临时数据进行保存,应用非预期退出后的下一次启动会恢复先前的状态和数据,给用户更连贯的使用体验。这里状态包括应用的页面栈以及onSaveState接口中保存的数据。 -目前该接口仅支持单进程单Ability的Stage模型应用开发。 +API 9上的应用恢复接口支持单Ability的Stage模型应用开发。支持JsError故障时的状态保存与自动重启。 + +API 10在API 9的基础上新增支持多Ability的Stage模型应用开发。支持AppFreeze故障时的状态保存回调。支持应用被管控模式杀死后,下次启动的状态恢复。 ## 接口说明 -应用故障恢复接口由appRecovery模块提供,开发者可以通过import引入,详见[开发示例](#开发示例)。本文档描述的为API9版本的接口行为,后续接口行为变更会更新本文档。 +应用故障恢复接口由appRecovery模块提供,开发者可以通过import引入,详见[开发示例](#开发示例)。 ### 应用恢复接口功能介绍 | 接口名称 | 说明 | | ------------------------------------------------------------ | ---------------------------------------------------- | -| enableAppRecovery(restart?: RestartFlag, saveOccasion?: SaveOccasionFlag, saveMode?: SaveModeFlag) : void; | 使能应用恢复功能。| -| saveAppState(): boolean; | 主动保存当前应用中Ability的状态。 | -| restartApp(): void; | 重启当前进程,如果有已经保存的Ability状态,会在Ability的OnCreate生命周期回调的want参数中的wantParam属性传入。 | +| enableAppRecovery(restart?: RestartFlag, saveOccasion?: SaveOccasionFlag, saveMode?: SaveModeFlag) : void;9+ | 使能应用恢复功能,参数按顺序填入。该接口调用后,应用从启动器启动时第一个Ability支持恢复。| +| saveAppState(): boolean;9+ | 主动保存当前应用中支持恢复的Ability的状态。 | +| restartApp(): void;9+ | 重启当前进程,并启动由**setRestartWant**指定的Ability,如果未指定,将重新拉起处于前台且支持恢复的Ability。 | +| saveAppState(context?: UIAbilityContext): boolean;10+ | 主动保存由Context指定的Ability状态。 | +| setRestartWant(want: Want): void;10+ | 设置主动调用**restartApp**以及**RestartFlag**不为**NO_RESTART**时重启的Ability。该Ability必须在同一个包名下,且必须为**UiAbility**。 | -由于本接口为故障处理时使用,不会返回异常,需要开发者熟悉使用的场景。 +由于上述接口可能在故障处理时使用,所以不会返回异常,需要开发者熟悉使用的场景。 **enableAppRecovery:** 需要在应用初始化阶段调用,比如AbilityStage的OnCreate调用赋能。具体其各参数定义详见[参数说明](../reference/apis/js-apis-app-ability-appRecovery.md)。 -**saveAppState:** 调用后框架会回调Ability的onSaveState方法,如果在onSaveState方法中同意保存数据,则会将相关数据及Ability的页面栈持久化到应用的本地缓存。 +**saveAppState:** 调用后框架会回调**当前进程中所有支持恢复的Ability**的onSaveState方法,如果在onSaveState方法中同意保存数据,则会将相关数据及Ability的页面栈持久化到应用的本地缓存。如果需要保存指定Ability,则需要指定Ability对应的Context。 + +**setRestartWant:** 指定由appRecovery发起重启的Ability。 + +**restartApp:** 调用后框架会杀死当前应用进程,并重新拉起由**setRestartWant**指定的Ability,其中启动原因为APP_RECOVERY。API 9以及未使用**setRestartWant**指定Ability的场景,会拉起最后一个支持恢复且在前台的Ability,如果当前前台的Ability不支持恢复,则应用表现闪退。如果重启的Ability存在已经保存的状态,这些状态数据会在Ability的OnCreate生命周期回调的want参数中作为wantParam属性传入。 + +### 应用恢复状态管理示意 +从API 10起,应用恢复的场景不仅局限于异常时自动重启。所以需要理解应用何时会加载恢复的状态。 +一句话概括就是**如果应用任务的上次退出不是由用户发起的,且应用存在用于恢复的状态,应用下一次由用户拉起时的启动原因会被设为APP_RECOVERY,并清理该任务的恢复状态。** +应用恢复状态标识会在状态保存接口主动或者被动调用时设置。在该任务正常退出或者消费了该状态时清理。正常退出目前包括用户按**后退键退出**以及用户**清理最近任务**。 + +![应用恢复状态管理示意](./figures/20230315112155.png) -**restartApp:** 调用后框架会杀死当前应用进程,并重新拉起处于前台的Ability,其中启动原因为APP_RECOVERY。 +### 应用卡死的状态保存及恢复 +API 10开始支持应用卡死时的状态保存。JsError故障时,onSaveState接口在主线程进行回调。对于AppFreeze故障,主线程可能处于卡死的状态,onSaveState会在非主线程进行回调。其主要流程如下图: + +![应用卡死状态保存恢复示意](./figures/20230315112235.png) +由于卡死时的回调不在JS线程上执行,onSaveState回调中的代码建议不要使用import进来的Native动态库,禁止访问主线程创建的thread_local对象。 ### 框架故障管理流程示意 @@ -52,7 +71,7 @@ | 故障名称 | 故障监听 | 状态保存 | 自动重启 | 日志查询 | | ----------|--------- |--------- |--------- |--------- | | [JS_CRASH](../reference/apis/js-apis-faultLogger.md#faulttype) | 支持|支持|支持|支持| -| [APP_FREEZE](../reference/apis/js-apis-faultLogger.md#faulttype) | 不支持|不支持|支持|支持| +| [APP_FREEZE](../reference/apis/js-apis-faultLogger.md#faulttype) | 不支持|支持|支持|支持| | [CPP_CRASH](../reference/apis/js-apis-faultLogger.md#faulttype) | 不支持|不支持|不支持|支持| 这里状态保存指的是故障时状态保存,对于应用卡死场景,开发者可以采用定时保存状态或者在Ability切入后台后自动保存的方式最大限度的保护用户数据。 @@ -77,6 +96,18 @@ export default class MyAbilityStage extends AbilityStage { appRecovery.SaveModeFlag.SAVE_WITH_FILE); } } +``` +### 配置支持恢复的Ability +Ability的配置清单一般的名字为module.json5。 +```json +{ + "abilities": [ + { + "name": "EntryAbility", + "recoverable": true, + }] +} + ``` ### 数据保存和恢复 diff --git a/zh-cn/application-dev/dfx/figures/20230315112155.png b/zh-cn/application-dev/dfx/figures/20230315112155.png new file mode 100644 index 0000000000000000000000000000000000000000..20324a0b23f2b409c2fef8daaa74bcccd5427398 Binary files /dev/null and b/zh-cn/application-dev/dfx/figures/20230315112155.png differ diff --git a/zh-cn/application-dev/dfx/figures/20230315112235.png b/zh-cn/application-dev/dfx/figures/20230315112235.png new file mode 100644 index 0000000000000000000000000000000000000000..34cf30ce75516810536335bd9a2789517360eae3 Binary files /dev/null and b/zh-cn/application-dev/dfx/figures/20230315112235.png differ diff --git a/zh-cn/application-dev/dfx/hiappevent-guidelines.md b/zh-cn/application-dev/dfx/hiappevent-guidelines.md index c422b69f7589430d2b4e3eb12dc14d7f6f335e92..bcb7ad3d6bbe8355cc7d2b65f1e5b542db6bb533 100644 --- a/zh-cn/application-dev/dfx/hiappevent-guidelines.md +++ b/zh-cn/application-dev/dfx/hiappevent-guidelines.md @@ -45,7 +45,7 @@ HiAppEvent是在系统层面为应用开发者提供的一种事件打点机制 以实现对用户点击按钮行为的事件打点及订阅为例,说明开发步骤。 -1. 新建一个ets应用工程,编辑工程中的“entry > src > main > ets > entryability > EntryAbility.ts” 文件,在onCreate函数中添加对用户点击按钮事件的订阅,完整示例代码如下: +1. 新建一个ArkTS应用工程,编辑工程中的“entry > src > main > ets > entryability > EntryAbility.ts” 文件,在onCreate函数中添加对用户点击按钮事件的订阅,完整示例代码如下: ```js import hilog from '@ohos.hilog'; diff --git a/zh-cn/application-dev/faqs/Readme-CN.md b/zh-cn/application-dev/faqs/Readme-CN.md index 8e60a76b28e1270a53e044fbddc5b403499e03e8..e412b9478b4d9c22cfc4ceef31ef1016bcaa8c6f 100644 --- a/zh-cn/application-dev/faqs/Readme-CN.md +++ b/zh-cn/application-dev/faqs/Readme-CN.md @@ -18,5 +18,4 @@ - [Native API使用常见问题](faqs-native.md) - [三四方库使用常见问题](faqs-third-party-library.md) - [IDE使用常见问题](faqs-ide.md) -- [hdc_std命令使用常见问题](faqs-hdc-std.md) - [开发板使用常见问题](faqs-development-board.md) diff --git a/zh-cn/application-dev/faqs/faqs-device-management.md b/zh-cn/application-dev/faqs/faqs-device-management.md index 9a62835d2c4ea2a6fa098c18efce5bd89e851b9c..47a73b6ff7ddf778173d784399ddb8c85b26f6f4 100644 --- a/zh-cn/application-dev/faqs/faqs-device-management.md +++ b/zh-cn/application-dev/faqs/faqs-device-management.md @@ -2,23 +2,27 @@ ## 如何获取设备的dpi值 -适用于:OpenHarmony SDK 3.2.2.5版本,API9 Stage模型 +适用于:OpenHarmony 3.2 Beta5,API9 Stage模型 + +**问题现象** + +获取设备的dpi信息。 -导入\@ohos.display包,通过getDefaultDisplay方法获取。 +**解决措施** -示例: +导入@ohos.display包,通过getDefaultDisplaySync方法获取。 +**示例代码** ``` import display from '@ohos.display'; -display.getDefaultDisplay((err, data) => { - if (err.code) { - console.error('Test Failed to obtain the default display object. Code: ' + JSON.stringify(err)); - return; - } - console.info('Test Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); - console.info('Test densityDPI:' + JSON.stringify(data.densityDPI)); -}); +let displayClass = null; +try { + displayClass = display.getDefaultDisplaySync(); + console.info('Test densityDPI:' + JSON.stringify(data.densityDPI)); +} catch (exception) { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); +} ``` ## 如何获取当前运行设备类型 diff --git a/zh-cn/application-dev/faqs/faqs-hdc-std.md b/zh-cn/application-dev/faqs/faqs-hdc-std.md deleted file mode 100644 index 20cdb7205dd9fca003b2b3b2ea0d6bc152d60e62..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/faqs/faqs-hdc-std.md +++ /dev/null @@ -1,87 +0,0 @@ -# hdc_std命令使用常见问题 - -## 日志的常用命令 - -适用于:OpenHarmony SDK 3.2.2.5版本 - -清理日志:hdc_std shell hilog -r - -调大缓存到20M:hdc_std shell hilog -G 20M - -抓取日志:hdc_std shell hilog > log.txt - -## 日志限流怎么规避 - -适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 - -- 关闭日志限流 hdc_std shell hilog -Q pidoff - -- 关闭隐私标志 hdc_std shell hilog -p off - -- 增加日志buffer hdc_std shell hilog -G 200M - -- 关闭全局日志,只打开自己领域的日志 hdc_std shell hilog –b D –D 0xd0xxxxx - -执行完命令后重启DevEco Studio。 - -## 用IDE安装HAP到开发板上无法打开 - -适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 - -请检查sdk和开发板烧录的系统版本是否一致,推荐取同一天的sdk和系统版本。 - -## 如何通过hdc命令上传文件 - -适用于:OpenHarmony SDK 3.2.2.5版本 - -可以使用hdc_std file send上传文件。 - -## 如何让RK3568开发板不熄屏 - -适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 - -输入命令hdc_std shell "power-shell setmode 602" - -## 如何通过命令启动Ability - -适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 - -输入命令hdc_std shell aa start -a AbilityName -b bundleName -m moduleName - -## 如何修改开发板中文件目录为可读写权限 - -适用于:OpenHarmony SDK 3.2.5.6版本,API9 Stage模型 - -输入命令 hdc_std shell mount -o remount,rw / - -## 如何解决hdc_std file recv 使用报错:Unkonw file option -r - -适用于:OpenHarmony SDK 3.2.5.6版本,API9 Stage模型 - -1. 使用设备镜像或者同版本SDK中配套的hdc工具进行使用。 - -2. hdc工具指定的路径不要包含中文和空格。 - -## 如何使用命令卸载应用 - -适用于:OpenHarmony SDK 3.2.2.5版本 - -输入命令hdc_std uninstall [-k] [package_name] - -## 如何查看系统是32位还是64位 - -适用于:OpenHarmony SDK 3.2.5.5版本 - -使用命令:hdc_std shell getconf LONG_BIT - -若返回64则为64位系统,否则为32位系统。 - -## 如何查看组件树结构 - -适用于:OpenHarmony SDK 3.2.5.5版本 - -1. 使用命令hdc_std shell 进入命令行界面。 - -2. 输入 aa dump -a 找到abilityID。 - -3. aa dump -i [abilityID] -c -render 查看组件树。 diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/case.md b/zh-cn/application-dev/key-features/multi-device-app-dev/case.md index f1dc34b9e0514708dca74b4e1f67889d730d57f7..0792abdeb6ecd0c060cdba2794501436a6563105 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/case.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/case.md @@ -467,8 +467,8 @@ const globalMessageList:any[] = [ | 断点 | 窗口宽度(vp) | 栅格总列数 | 消息气泡占用的列数 | 接收场景偏移的列数 | 发送场景偏移的列数 | | -------- | -------- | -------- | -------- | -------- | -------- | -| sm | [320, 520) | 12 | 12 | 0 | 0 | -| md | [520, 840) | 12 | 8 | 0 | 4 | +| sm | [320, 600) | 12 | 12 | 0 | 0 | +| md | [600, 840) | 12 | 8 | 0 | 4 | | lg | [840, +∞) | 12 | 8 | 0 | 4 | | 默认设备 | 平板 | diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/design-delivery.md b/zh-cn/application-dev/key-features/multi-device-app-dev/design-delivery.md index 658db5e5e1a18a8a49be9f990a4badbddeb6f6d2..49f29e94a09f65410f508301464bebca900c51dc 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/design-delivery.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/design-delivery.md @@ -35,8 +35,8 @@ | 设备类型 | 屏幕宽度 | 画板尺寸(vp) | | -------- | -------- | -------- | | 超小设备 | [0, 320) | 240\*320 | -| 小设备 | [320, 520) | 360\*780 | -| 中设备 | [520, 840) | 677\*763 | +| 小设备 | [320, 600) | 360\*780 | +| 中设备 | [600, 840) | 677\*763 | | 大设备 | [840, +) | 1280\*800 | 多设备效果示意图 diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/design-interaction-event-normalization.md b/zh-cn/application-dev/key-features/multi-device-app-dev/design-interaction-event-normalization.md index 9bef5805ea054e71175ce023aba4247472f22c49..21d43d67cacb5fbaf07ea6c6f645dd416b65844f 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/design-interaction-event-normalization.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/design-interaction-event-normalization.md @@ -11,12 +11,12 @@ 用户通过点击某个元素触发功能、访问新页面、或改变自身状态。 - | **输入方式** | **交互行为** | **示意** | +| **输入方式** | **交互行为** | **示意** | | -------- | -------- | -------- | -| 触屏 | 单指单击 | ![zh-cn_image_0000001280472681](figures/zh-cn_image_0000001280472681.png) | -| 鼠标 | 左键单击 / 左键双击 | ![zh-cn_image_0000001236472600](figures/zh-cn_image_0000001236472600.png) | -| 触摸板 | 单指单击 / 单指双击 | ![zh-cn_image_0000001280232265](figures/zh-cn_image_0000001280232265.png) | -| 键盘 | 移动焦点到对象上后按下Enter键 | ![zh-cn_image_0000001280472701](figures/zh-cn_image_0000001280472701.png) | +| 触屏 | 单指单击 | ![zh-cn_image_0000001280472681](figures/zh-cn_image_0000001280472681.png) | +| 鼠标 | 左键单击 / 左键双击 | ![zh-cn_image_0000001236472600](figures/zh-cn_image_0000001236472600.png) | +| 触摸板 | 单指单击 / 单指双击 | ![zh-cn_image_0000001280232265](figures/zh-cn_image_0000001280232265.png) | +| 键盘 | 移动焦点到对象上后按下Space键 | ![zh-cn_image_0000001280472701](figures/zh-cn_image_0000001280472701.png) | 一般地,触屏手指的按下/抬起行为对应于光标的按下/抬起行为。 diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001280472701.png b/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001280472701.png index cabcaf5667a4093f188b59b9ce092abd975ab5d8..a27b306ab5457819b1a57599e2a7a95d81faf5c3 100644 Binary files a/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001280472701.png and b/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001280472701.png differ diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md b/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md index 270181beca5a233e31e91b90958b0a79174426f7..5bd5144d57b201b20310a141a8fed69ee55d6528 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md @@ -24,8 +24,8 @@ | 断点名称 | 取值范围(vp) | | -------- | -------- | | xs | [0, 320) | -| sm | [320, 520) | -| md | [520, 840) | +| sm | [320, 600) | +| md | [600, 840) | | lg | [840, +∞) | > **说明:** @@ -66,7 +66,7 @@ OpenHarmony提供了多种方法,判断应用当前处于何种断点,进而 let newBp: string = '' if (windowWidthVp < 320) { newBp = 'xs' - } else if (windowWidthVp < 520) { + } else if (windowWidthVp < 600) { newBp = 'sm' } else if (windowWidthVp < 840) { newBp = 'md' @@ -209,9 +209,9 @@ export class BreakpointSystem { } public register() { - this.smListener = mediaquery.matchMediaSync("(320vp **说明:** diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/typical-layout-scenario.md b/zh-cn/application-dev/key-features/multi-device-app-dev/typical-layout-scenario.md index 4bb565e096bb61022c3f76f9256e0ed31054ed74..b2135839a5223c43f1af530b9d371273d6d8cb31 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/typical-layout-scenario.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/typical-layout-scenario.md @@ -371,7 +371,6 @@ struct SideBarSample { @Builder itemBuilder(index: number) { Text(images[index].label) - .width('100%') .fontSize(24) .fontWeight(FontWeight.Bold) .borderRadius(5) @@ -470,6 +469,7 @@ struct Item { NavDestination() { Details({imageSrc: this.imageSrc}) }.title(this.label) + .backgroundColor('#FFFFFF') } } } @@ -491,7 +491,7 @@ struct NavigationSample { .backgroundColor('#F1F3F5') .height('100%') .width('100%') - .navBarWidth('40%') + .navBarWidth(360) .hideToolBar(true) .title('Sample') } diff --git a/zh-cn/application-dev/media/avplayer-playback.md b/zh-cn/application-dev/media/avplayer-playback.md index 950ccd19857cd5704b86d82828c522e45ddde4aa..900a193f3dd9743e5aaa0a6f9fa2b0d463a9279e 100644 --- a/zh-cn/application-dev/media/avplayer-playback.md +++ b/zh-cn/application-dev/media/avplayer-playback.md @@ -299,13 +299,13 @@ export class AVPlayerDemo { async avPlayerDemo() { // 创建avPlayer实例对象 this.avPlayer = await media.createAVPlayer() - let fdPath = 'fd://' - let pathDir = "/data/storage/el2/base/haps/entry/files" // pathDir在FA模型和Stage模型的获取方式不同,请参考开发步骤首行的说明,根据实际情况自行获取。 - // path路径的码流可通过"hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" 命令,将其推送到设备上 - let path = pathDir + '/H264_AAC.mp4' - let file = await fs.open(path) - fdPath = fdPath + '' + file.fd - this.avPlayer.url = fdPath + let fileDescriptor = undefined + // 使用资源管理模块的getRawFileDescriptor获取集成在应用中的媒体资源,并使用AVPlayer的fdSrc属性完成媒体资源初始化 + // 其中的参数fd/offset/length定义请查看媒体API文档,globalThis.abilityContext参数为系统环境变量,在系统启动时在主界面保存为全局变量 + await globalThis.abilityContext.resourceManager.getRawFileDescriptor('H264_AAC.mp4').then((value) => { + fileDescriptor = {fd: value.fd, offset: value.offset, length: value.length} + }) + this.avPlayer.fdSrc = fileDescriptor } } ``` @@ -481,10 +481,4 @@ export class AVPlayerDemo { this.avPlayer.url = fdPath } } -``` - -## 相关示例 - -针对AVPlayer播放器开发,有以下相关示例可供参考: - -待补充 \ No newline at end of file +``` \ No newline at end of file diff --git a/zh-cn/application-dev/media/opensles-capture.md b/zh-cn/application-dev/media/opensles-capture.md index 4c9a88531543ba15f882720fe83e512373496c2c..bf7120054a8431a0ccbe877a312d44dbd80f33e6 100644 --- a/zh-cn/application-dev/media/opensles-capture.md +++ b/zh-cn/application-dev/media/opensles-capture.md @@ -51,12 +51,12 @@ 3 }; - //具体参数需要根据音频文件格式进行适配 + // 具体参数需要根据音频文件格式进行适配 SLDataFormat_PCM format_pcm = { - SL_DATAFORMAT_PCM, - OHOS::AudioStandard::AudioChannel::MONO, - OHOS::AudioStandard::AudioSamplingRate::SAMPLE_RATE_44100, - OHOS::AudioStandard::AudioSampleFormat::SAMPLE_S16LE, + SL_DATAFORMAT_PCM, // 输入的音频格式 + 1, // 单声道 + SL_SAMPLINGRATE_44_1, // 采样率,44100HZ + SL_PCMSAMPLEFORMAT_FIXED_16, // 音频采样格式,小尾数,带符号的16位整数 0, 0, 0 @@ -107,7 +107,7 @@ return; } - //wavFile_ 需要设置为用户想要录音的文件描述符 + // wavFile_ 需要设置为用户想要录音的文件描述符 (*bufferQueueItf)->RegisterCallback(bufferQueueItf, BufferQueueCallback, wavFile_); ``` diff --git a/zh-cn/application-dev/napi/Readme-CN.md b/zh-cn/application-dev/napi/Readme-CN.md index 752a456fca9fed148b05885c3ce41c1ebfc1b456..7ab6c418168a4e99ca15a63c0cc17e1dcd797a10 100644 --- a/zh-cn/application-dev/napi/Readme-CN.md +++ b/zh-cn/application-dev/napi/Readme-CN.md @@ -1,6 +1,71 @@ +# Native API +Native API是OHOS SDK上提供的一组native开发接口与工具集合,方便开发者使用C或者C++语言实现应用的关键功能。Native API只覆盖了OHOS基础的一些底层能力,如libc,图形库,窗口系统,多媒体,压缩库等,并没有完全提供类似于JS API上的完整的OHOS 平台能力。在应用中使用Native API会编译成动态库打包到应用中。 + +
+ +## Native API构成介绍 + +### Native API目录结构 + +Native API在SDK包的位置为$(SDK_ROOT)/native目录,主要有以下几个部分组成 + +|目录|功能说明| +|--|--| +|build|应用中编译动态库的toolchain cmake脚本;这个目录下ohos.toolchain.cmake文件定义了给OHOS交叉编译选项| +|build-tools|放置编译构建的工具,如cmake| +|docs|Native API接口参考文档,通过doxgen从头文件中提取出来| +|llvm|支持OHOS ABI的llvm交叉编译器| +|sysroot|放置编译链接的依赖文件目录,包含头文件,动态库等| + +
+ +### Native API接口 + +|接口分类|接口功能|引入版本| +|--|--|--| +|标准C库|以musl为基础提供的标准c库接口,当前提供了1500+的接口|8| +|标准C++库|c++运行时库libc++_shared,此库在打包的时候需要打包或者静态链接到应用中|8| +|日志|打印日志到系统的hilog接口|8| +|napi|ArkUI提供的,方便应用开发接入JS应用环境的一组类Node-API,是属于Native API的一部分|8| +|XComponent|ArkUI XComponent组件中的surface与触屏事件接口,方便开发者开发高性能图形应用|8| +|libuv|ArkUI集成的三方的异步IO库|8| +|libz|zlib库,提供基本的压缩,解压接口|8| +|Drawing|系统提供的2D图形库,可以在surface进行绘制|8| +|OpenGL|系统提供的openglv3接口|8| +|Rawfile|应用资源访问接口,可以读取应用中打包的各种资源|8| +|OpenSLES|用于2D,3D音频加速的接口库|8| +|Mindspore|AI模型接口库|9| +|包管理|包服务接口,方便查询应用包信息|8| + +Native API中有一部分接口采用开源标准,详细列表见《[Native API中支持的标准库](https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/reference/native-lib/third_party_libc/musl.md/)》《[Node_API](https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/reference/native-lib/third_party_napi/napi.md/)》 + +## 使用介绍 + +
+ +### 建议使用Native API的场景 + +主要有如下一些 + +1. 应用性能敏感代码,比如游戏,物理模拟等计算密集型场景 +2. 需要复用已有的C或C++库 +3. 需要针对CPU特性进行专项定制的库,如neon加速 + +
+ +### 不建议使用Native API的场景 + +1. 写一个纯native的的OHOS应用 +2. 希望在尽可能多的OHOS设备上保持兼容的应用 + +
+ # Native API的相关指导 +- [Native API hello world]() + - 本例子引导开发者开发一个hello的Native API库,在ts界面上显示出从hello库中获取的字符串 - [Native API在应用工程中的使用指导](napi-guidelines.md) + - 介绍如何使用各种napi接口与js中的模块,接口,异步任务进行互操作 - [Drawing开发指导](drawing-guidelines.md) - [Rawfile开发指导](rawfile-guidelines.md) - [NativeWindow开发指导](native-window-guidelines.md) diff --git a/zh-cn/application-dev/notification/notification-with-wantagent.md b/zh-cn/application-dev/notification/notification-with-wantagent.md index 83208e2f85841040a5f5c0008e1d766f900d8fff..d3ea33340bf8af7a738c2655abd892d1a67b6357 100644 --- a/zh-cn/application-dev/notification/notification-with-wantagent.md +++ b/zh-cn/application-dev/notification/notification-with-wantagent.md @@ -12,9 +12,8 @@ 具体接口描述,详见[WantAgent接口文档](../reference/apis/js-apis-app-ability-wantAgent.md)。 -| | | -| -------- | -------- | | **接口名** | **描述** | +| -------- | -------- | | getWantAgent(info: WantAgentInfo, callback: AsyncCallback<WantAgent>): void | 创建WantAgent。 | | trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback<CompleteData>): void | 触发WantAgent意图。 | | cancel(agent: WantAgent, callback: AsyncCallback<void>): void | 取消WantAgent。 | diff --git a/zh-cn/application-dev/quick-start/Readme-CN.md b/zh-cn/application-dev/quick-start/Readme-CN.md index 34d3bb66aa5367e975ea54ff28d803b54953f79e..ef1c7b868f3a4be8ee86d36c2c3109f0011a314b 100755 --- a/zh-cn/application-dev/quick-start/Readme-CN.md +++ b/zh-cn/application-dev/quick-start/Readme-CN.md @@ -4,7 +4,7 @@ - [开发准备](start-overview.md) - [使用ArkTS语言开发(Stage模型)](start-with-ets-stage.md) - [使用ArkTS语言开发(FA模型)](start-with-ets-fa.md) - - [使用JS语言开发(FA模型)](start-with-js-fa.md) + - [使用JS语言开发(FA模型)](start-with-js-fa.md) - 开发基础知识 - 应用程序包基础知识 - [应用程序包概述](application-package-overview.md) @@ -25,6 +25,8 @@ - HSP - [应用内HSP开发指导](in-app-hsp.md) - [应用间HSP开发指导(仅对系统应用开放)](cross-app-hsp.md) + - 原子化服务 + - [原子化服务开发指导](atomicService.md) - 应用程序包快速修复 - [快速修复概述](quickfix-principles.md) - [快速修复调试指导](quickfix-debug.md) diff --git a/zh-cn/application-dev/quick-start/app-configuration-file.md b/zh-cn/application-dev/quick-start/app-configuration-file.md index a890fd96269336f5bd3e8b52fa3c1f2e9640bf14..12c2d3e8888a81c4b0096cdcb30c25a770449f67 100644 --- a/zh-cn/application-dev/quick-start/app-configuration-file.md +++ b/zh-cn/application-dev/quick-start/app-configuration-file.md @@ -33,6 +33,7 @@ app.json5配置文件包含以下标签。 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | -------- | -------- | -------- | | bundleName | 标识应用的Bundle名称,用于标识应用的唯一性。该标签不可缺省。标签的值命名规则 :
- 字符串以字母、数字、下划线和符号“.”组成。
- 以字母开头。
- 最小长度7个字节,最大长度127个字节。
推荐采用反域名形式命名(如com.example.demo,建议第一级为域名后缀com,第二级为厂商/个人名,第三级为应用名,也可以多级)。
其中,随系统源码编译的应用建议命名为“com.ohos.demo”形式, ohos标识OpenHarmony系统应用。 | 字符串 | 该标签不可缺省。 | +| bundleType| 标识应用的Bundle类型,用于区分应用或者原子化服务。该标签可选值为app和atomicService :
- app:当前Bundle为普通应用。
- atomicService:当前Bundle为原子化服务。| 字符串| 该标签可以缺省,缺省为app。 | | debug | 标识应用是否可调试,该标签由IDE编译构建时生成。
- true:可调试。
- false:不可调式。 | 布尔值 | 该标签可以缺省,缺省为false。 | | icon | 标识[应用的图标](../application-models/application-component-configuration-stage.md),标签值为图标资源文件的索引。 | 字符串 | 该标签不可缺省。 | | label | 标识[应用的名称](../application-models/application-component-configuration-stage.md),标签值为字符串资源的索引。 | 字符串 | 该标签不可缺省。 | diff --git a/zh-cn/application-dev/quick-start/arkts-rendering-control.md b/zh-cn/application-dev/quick-start/arkts-rendering-control.md index 4b92d08d2e95b5f44ae8e990a8c39531cde38081..1d1635674d5e913a1a4ac33c84e2a165e092df5d 100644 --- a/zh-cn/application-dev/quick-start/arkts-rendering-control.md +++ b/zh-cn/application-dev/quick-start/arkts-rendering-control.md @@ -256,7 +256,7 @@ struct MyComponent { this.data.pushData('/path/image' + this.data.totalCount() + '.png') }) }, item => item) - } + }.height('100%').width('100%') } } ``` diff --git a/zh-cn/application-dev/quick-start/arkts-restrictions-and-extensions.md b/zh-cn/application-dev/quick-start/arkts-restrictions-and-extensions.md index 946b9ced5bc14583846a28a37b1b4f81535dfc81..ae8318ee1472177ba59b6eaf8b21d8f2e5623bb4 100644 --- a/zh-cn/application-dev/quick-start/arkts-restrictions-and-extensions.md +++ b/zh-cn/application-dev/quick-start/arkts-restrictions-and-extensions.md @@ -231,3 +231,27 @@ struct Child { } } ``` + +## 自定义组件名,类名,函数名和系统组件名相同约束。 + +自定义组件名,类名,函数名不能和系统组件名相同。 + +示例: + +``` +// Rect.ets +export class Rect { + constructor(){} +} +// Index.ets +// ERROR: The module name 'Rect' can not be the same as the inner component name. +import { Rect } from './Rect'; +@Entry +@Component +struct Index { + build() { + + } +} +``` + diff --git a/zh-cn/application-dev/quick-start/atomicService.md b/zh-cn/application-dev/quick-start/atomicService.md new file mode 100644 index 0000000000000000000000000000000000000000..d99306b2a37028f0c1e3c27269f17c614cd3df36 --- /dev/null +++ b/zh-cn/application-dev/quick-start/atomicService.md @@ -0,0 +1,218 @@ +# 原子化服务 + +## 原子化服务分包预加载 + +### 使用分包 + +为了加快首次启动原子化服务时的速度,可以采用分包策略,原子化服务的代码包可以被划分为几个:一个是类型为entry的模块,包含原子化服务启动时会打开的页面代码和相关资源;其余是“分包”,包含其余的代码和资源。这样,启动原子化服务时,只需下载和安装entry模块,即可立刻启动原子化服务,大大降低原子化服务下载的时间。 + +#### 配置方法 + +原子化服务分包可以在`DevEco Studio`中创建,我们以创建一个原子化服务为例。基本的工程目录结构大致如下: + +``` +├── AppScope +| ├── resources +| └── app.json5 +├── entry +| └── src/main +| ├── ets +| ├── resources +| └── module.json5 +├── feature +| └── src/main +| ├── ets +| ├── resources +| └── module.json5 +├── library +| └── src/main +| ├── ets +| ├── resources +| └── module.json5 +├── node_modules +``` + +注意,开发者需要在[app.json5](app-configuration-file.md)中`bundleType`字段指定为`atomicService`,标识当前应用是原子化服务。`app.json5`(路径为:`AppScope/app.json5`)的内容为: + +```json +{ + "app": { + "bundleName": "com.example.hmservice", + "bundleType":"atomicService", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "targetAPIVersion": 9 + } +} +``` + +具体分包攻略,详细可参考[多hap开发](multi-hap-objective.md)。 + +#### 限制 + +1. 原子化服务中每个模块对应的配置文件[module.json5](module-configuration-file.md)中`installationFree`字段必须为`true`。 + +2. 打包原子化服务时,需遵循以下大小校验规则: + +- 原子化服务中,所有包的大小总和不能超过10M。 + +- 单个包加上其依赖的所有[共享包](in-app-hsp.md),大小不能超过2M。 + + +### 使用预加载 + +开发者可以通过配置,在原子化服务进入某个模块时,由系统自动预下载可能需要的模块,从而提升进入后续模块的速度。 + +原子化服务预加载目前只支持通过配置方式使用,暂不支持通过调用API使用。 + +#### 配置方法 + +原子化服务预加载行为在点击进入某个模块时,第一帧绘制结束之后触发,可以通过在相应模块的[module.json5](module-configuration-file.md)文件中配置`atomicService`标签下的`preloads`字段来控制,以下为entry模块的`module.json5`(路径为:`entry/src/main/module.json5`)文件内容: + +```json +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/MyAbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "atomicService": { + "preloads": [ + { + "moduleName": "feature" + } + ] + }, + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} +``` + +在完成entry模块的第一帧绘制结束后,会自动执行预加载去下载和安装模块名为feature的模块。 + +#### 限制 + +preloads列表配置的moduleName对应的[moduleType(模块类型)](../reference/apis/js-apis-bundleManager.md#moduletype)不能为entry。 + +## 原子化服务中使用动态共享包 + +[Harmony动态共享包](shared-guide.md)(Harmony Shared Package),简称HSP,其可以包含其他模块公用的代码、C++库、资源和配置文件等。 +在原子化服务中使用HSP,可以参考[应用内HSP开发指导](in-app-hsp.md)。 + +#### 配置方法 + +假设工程目录结构如下: +``` +├── AppScope +| ├── resources +| └── app.json5 +├── entry +| └── src/main +| ├── ets +| ├── entryAbility +| └── pages +| └── Index.ets +| ├── resources +| └── module.json5 +├── feature +| └── src/main +| ├── ets +| ├── resources +| └── module.json5 +├── library +| └── src/main +| ├── ets +| └── pages +| └── menu.ets +| ├── resources +| └── module.json5 +├── node_modules +``` + +若开发者想在entry模块中,添加一个按钮跳转至library模块中的menu页面(路径为:`library/src/main/ets/pages/menu.ets`),那么可以在使用方的代码(entry模块下的Index.ets,路径为:`entry/src/main/ets/MainAbility/Index.ets`)里这样使用: + +```ts +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('click to menu') + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + // 绑定点击事件 + .onClick(() => { + router.pushUrl({ + url: '@bundle:com.example.hmservice/library/ets/pages/menu' + }).then(() => { + console.log("push page success"); + }).catch(err => { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + }) + } + .width('100%') + } + .height('100%') + } +} +``` + +其中`router.pushUrl`方法的入参中`url`的内容为: +```ets +'@bundle:com.example.hmservice/library/ets/pages/menu' +``` +`url`内容的模板为: +```ets +'@bundle:包名(bundleName)/模块名(moduleName)/路径/页面所在的文件名(不加.ets后缀)' +``` \ No newline at end of file diff --git a/zh-cn/application-dev/quick-start/cross-app-hsp.md b/zh-cn/application-dev/quick-start/cross-app-hsp.md index 91a8972480dc84591d93ed4284243b342eaf7aa5..7f6107d612a6eab95d51b2b14f21eae856153b2b 100644 --- a/zh-cn/application-dev/quick-start/cross-app-hsp.md +++ b/zh-cn/application-dev/quick-start/cross-app-hsp.md @@ -7,12 +7,12 @@ 1. 应用间`HSP`的代码会运行再开发者应用的进程中,调用相关代码时,需要做好异常捕获与容错处理,防止由于应用间`HSP`功能异常导致的稳定性问题。 2. 一个应用可以同时依赖多个应用间`HSP`。 3. 应用间`HSP`会影响开发者应用自身的启动时间,依赖过多的应用间`HSP`可能会导致启动时延发生明显的劣化,建议将依赖的数目控制在16个以内。 -4. 当前三方开发者开发者只能使用系统提供的应用间`HSP`,不支持开发并发布自己的应用间`HSP`。 +4. 应用间`HSP`安装时需要对特权权限进行校验,如果想要开发应用间`HSP`,需要配置allowAppShareLibrary应用特权,具体配置方式参考[应用特权配置指南](../../device-dev/subsystems/subsys-app-privilege-config-guide.md)。 ## 应用间HSP的使用 应用间HSP会分为两部分对外发布: -一部分为[HAR](har-package.md),这部分`HAR`中不会包含具体的功能实现代码,而仅仅包含导出的对象与方法,所以体积很小。应用开发者将`HAR`集成到自身的工程中,然后就可以通过调用`HAR`中提供的对象与方法完成自身的应用功能。 +一部分为[HAR](har-package.md),`HAR`包中不会包含具体的功能实现代码,而仅仅包含导出的对象与方法,所以体积很小。应用开发者将`HAR`包集成到自身的工程中,然后就可以通过调用`HAR`包中提供的对象与方法完成自身的应用功能。 另外一部分为HSP,这部分为应用间`HSP`的具体实现,里面包含js/ts代码、C++库、资源和配置文件。这部分会上架到应用市场或者集成到系统版本中。 @@ -23,7 +23,7 @@ src ├── main | └── module.json5 ├── index.d.ets -└── package.json +└── oh-package.json5 ``` `index.d.ets`内容样例如下: ```ts @@ -117,7 +117,7 @@ extern "C" __attribute__((constructor)) void RegisterLibaModule(void) { } ``` ### 使用HAR导出的能力 -引用`HAR`前,需要先配置对`HAR`的依赖,配置方式可参考[文档](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-development-npm-package-0000001222578434#section89674298391)。`HAR`配置成功后,在配置模块的`module.json`中会生成相关依赖项信息,如下所示: +引用`HAR`前,需要先配置对`HAR`的依赖,配置方式可参考[文档](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-development-npm-package-0000001222578434#section89674298391)。`HAR`配置成功后,在配置模块的`module.json5`中会生成相关依赖项信息,如下所示: ```json "dependencies": [ { @@ -218,4 +218,4 @@ bm install -p feature.hap ``` 4. 启动开发者自身的应用,调试相关功能。 -**注意**:步骤2和步骤3不可以颠倒,否则会由于缺少必要的应用间`HSP`导致开发者的应用安装失败。更多`bm`相关指令可以参考[文档](https://gitee.com/openharmony/bundlemanager_bundle_framework#bm%E5%B7%A5%E5%85%B7%E5%91%BD%E4%BB%A4)。 \ No newline at end of file +**注意**:步骤2和步骤3不可以颠倒,否则会由于缺少必要的应用间`HSP`导致开发者的应用安装失败。更多`bm`相关指令可以参考[文档](https://gitee.com/openharmony/bundlemanager_bundle_framework#bm%E5%B7%A5%E5%85%B7%E5%91%BD%E4%BB%A4)。 diff --git a/zh-cn/application-dev/quick-start/har-package.md b/zh-cn/application-dev/quick-start/har-package.md index 88e4c47a32bf2d7fe0162c177ae638ef12ee053a..cef09be1ef5764c019c3b726bcd2dc333aea2c03 100644 --- a/zh-cn/application-dev/quick-start/har-package.md +++ b/zh-cn/application-dev/quick-start/har-package.md @@ -27,7 +27,7 @@ artifactType字段有以下两种取值,默认缺省为original。 - Stage模型的HAR,不能引用AppScope内的内容。在编译构建时APPScope中的内容不会打包到HAR中,导致HAR资源引用失败。 ## 导出HAR的ArkUI组件、接口、资源 -index.ets文件是HAR导出声明文件的入口,HAR需要导出的接口,统一在index.ets文件中导出。index.ets文件是DevEco Studio默认自动生成的,用户也可以自定义,在模块的package.json文件中的main字段配置入口声明文件,配置如下所示: +index.ets文件是HAR导出声明文件的入口,HAR需要导出的接口,统一在index.ets文件中导出。index.ets文件是DevEco Studio默认自动生成的,用户也可以自定义,在模块的oh-package.json5文件中的main字段配置入口声明文件,配置如下所示: ```json { "main": "index.ets" diff --git a/zh-cn/application-dev/quick-start/in-app-hsp.md b/zh-cn/application-dev/quick-start/in-app-hsp.md index 177700e909363128a4df4da45de0e1d7c56f36f8..0cd31484efcafe7e7512efbb6f3fc2718cee6b5e 100644 --- a/zh-cn/application-dev/quick-start/in-app-hsp.md +++ b/zh-cn/application-dev/quick-start/in-app-hsp.md @@ -15,7 +15,7 @@ library │ │ └── index.ets │ ├── resources │ └── module.json5 -└── package.json +└── oh-package.json5 ``` 模块`module.json5`中的`"type"`标识模块类型,`HSP`的`"type"`是`"shared"`。 ```json @@ -24,7 +24,7 @@ library } ``` -`HSP`通过在入口文件中导出接口,对外提供能力。入口文件在模块`package.json`的`"main"`中配置。例如: +`HSP`通过在入口文件中导出接口,对外提供能力。入口文件在模块`oh-package.json5`的`"main"`中配置。例如: ```json { "main": "./src/main/ets/index.ets" @@ -103,9 +103,9 @@ export { nativeMulti } from './utils/nativeTest' ``` ## 使用应用内HSP -要使用`HSP`中的接口,首先需要在使用方的`package.json`中配置对它的依赖。如果应用内`HSP`和使用方在同一工程下,可以直接本地引用,例如: +要使用`HSP`中的接口,首先需要在使用方的`oh-package.json5`中配置对它的依赖。如果应用内`HSP`和使用方在同一工程下,可以直接本地引用,例如: ```json -// entry/src/main/module.json5 +// entry/oh-package.json5 "dependencies": { "library": "file:../library" } diff --git a/zh-cn/application-dev/quick-start/module-configuration-file.md b/zh-cn/application-dev/quick-start/module-configuration-file.md index dbd64ee433a13647d1cf022a1c0c3984fd6afed3..0743763adda6e0a788c5fc9df8d2ac9fc79393eb 100644 --- a/zh-cn/application-dev/quick-start/module-configuration-file.md +++ b/zh-cn/application-dev/quick-start/module-configuration-file.md @@ -87,6 +87,8 @@ module.json5配置文件包含以下标签。 | [extensionAbilities](#extensionabilities标签) | 标识当前Module中ExtensionAbility的配置信息,标签值为数组类型,只对当前ExtensionAbility生效。 | 对象 | 该标签可缺省,缺省值为空。 | | [requestPermissions](#requestpermissions标签) | 标识当前应用运行时需向系统申请的权限集合。 | 对象 | 该标签可缺省,缺省值为空。 | | [testRunner](#testrunner标签) | 标识当前Module用于支持对测试框架的配置。 | 对象 | 该标签可缺省,缺省值为空。 | +| [atomicService](#atomicservice标签)| 标识当前应用是原子化服务时,有关原子化服务的相关配置。| 对象 | 该标签可缺省,缺省值为空。 | +| [dependencies](#dependencies标签)| 标识当前模块运行时依赖的共享库列表。| 对象数组 | 该标签可缺省,缺省值为空。 | ## deviceTypes标签 @@ -165,7 +167,7 @@ deviceTypes示例: "metadata": [{ "name": "module_metadata", "value": "a test demo for module metadata", - "resource": "$profile:shortcuts_config", + "resource": "$profile:shortcuts_config" }], "abilities": [{ @@ -226,7 +228,7 @@ OpenHarmony系统对无图标应用严格管控。如果HAP中没有配置启动 }] }], ... - + } } ``` @@ -457,7 +459,7 @@ extensionAbilities示例: "icon": "$media:icon", "label" : "$string:extension_name", "description": "$string:form_description", - "type": "form", + "type": "form", "permissions": ["ohos.abilitydemo.permission.PROVIDER"], "readPermission": "", "writePermission": "", @@ -471,7 +473,7 @@ extensionAbilities示例: "metadata": [ { "name": "ohos.extension.form", - "resource": "$profile:form_config", + "resource": "$profile:form_config", } ] } @@ -486,7 +488,8 @@ extensionAbilities示例: > **说明:** > -> 在requestPermissions标签中配置的权限项将在应用级别生效,即该权限适用于整个应用程序。 +> - 在requestPermissions标签中配置的权限项将在应用级别生效,即该权限适用于整个应用程序。 +> - 如果应用需要订阅自己发布的事件,而且应用在extensionAbilities标签中的permissions字段中设置了访问该应用所需要的权限,那么应用也需要在requestPermissions标签中注册相关权限才能收到该事件。 **表8** **requestPermissions标签说明** @@ -528,7 +531,7 @@ metadata中指定shortcut信息,其中: - name:指定shortcuts的名称。使用ohos.ability.shortcuts作为shortcuts信息的标识。 - resource:指定shortcuts信息的资源位置。 - + | 属性 | 含义 | 类型 | 默认值 | | -------- | -------- | -------- | -------- | | shortcutId | 标识快捷方式的ID。字符串的最大长度为63字节。 | 字符串 | 该标签不可缺省。 | @@ -538,7 +541,7 @@ metadata中指定shortcut信息,其中: 1. 在/resource/base/profile/目录下配置shortcuts_config.json配置文件。 - + ```json { "shortcuts": [ @@ -558,7 +561,7 @@ metadata中指定shortcut信息,其中: ``` 2. 在module.json5配置文件的abilities标签中,针对需要添加快捷方式的UIAbility进行配置metadata标签,使shortcut配置文件对该UIAbility生效。 - + ```json { "module": { @@ -714,3 +717,84 @@ testRunner标签示例: } } ``` + +## atomicService标签 + +此标签用于支持对原子化服务的配置。此标签仅在app.json中bundleType指定为atomicService时使能。 + +**表14** **atomicService标签说明** + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | -------- | -------- | -------- | +| preloads | 标识原子化服务中预加载列表 | 对象数组 | 可缺省,缺省值为空。 | + +atomicService标签示例: + + +```json +{ + "module": { + "atomicService": { + "preloads":[ + { + "moduleName":"feature" + } + ] + } + } +} +``` + +## preloads标签 + +此标签标识原子化服务中预加载列表。 + +**表14** **preloads标签说明** + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| -------- | -------- | -------- | -------- | +| moduleName | 标识原子化服务中,当前模块被加载时,需预加载的模块名 | 字符串 | 不可缺省。 | + +preloads标签示例: + +```json +{ + "module": { + "atomicService": { + "preloads":[ + { + "moduleName":"feature" + } + ] + } + } +} +``` + +## dependencies标签 + +此标签标识模块运行时依赖的共享库列表。 + +**表14** **dependencies标签说明** + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ----------- | ------------------------------ | -------- | ---------- | +| bundleName | 标识当前模块依赖的共享包包名。 | 字符串 | 可缺省。 | +| moduleName | 标识当前模块依赖的共享包模块名。| 字符串 | 不可缺省。 | +| versionCode | 标识当前共享包的版本号。 | 数值 | 可缺省。 | + +dependencies标签示例: + +```json +{ + "module": { + "dependencies": [ + { + "bundleName":"com.share.library", + "moduleName": "library", + "versionCode": 10001 + } + ] + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/Readme-CN.md b/zh-cn/application-dev/reference/Readme-CN.md index 88fa07c730e4774e12236232947abd162cc77a0a..6253620ea55348d7cb196bfaa0b3958e7e46a3b1 100644 --- a/zh-cn/application-dev/reference/Readme-CN.md +++ b/zh-cn/application-dev/reference/Readme-CN.md @@ -3,7 +3,8 @@ - [系统能力SystemCapability使用指南](syscap.md) - [系统能力SystemCapability列表](syscap-list.md) - [组件参考(基于ArkTS的声明式开发范式)](arkui-ts/Readme-CN.md) -- [组件参考(兼容JS的类Web开发范式)](arkui-js/Readme-CN.md) +- [组件参考(兼容JS的类Web开发范式-ArkUI.Full)](arkui-js/Readme-CN.md) +- [组件参考(兼容JS的类Web开发范式-ArkUI.Lite)](arkui-js-lite/Readme-CN.md) - [JS服务卡片UI组件参考](js-service-widget-ui/Readme-CN.md) - [接口参考(ArkTS及JS API)](apis/Readme-CN.md) - [错误码参考](errorcodes/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 0a8f7356c2b06b99a32cbf946befae8e830f1c8f..07d9d19b88f139b835a153c436013f92f3257148 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -173,6 +173,7 @@ - [@ohos.promptAction (弹窗)](js-apis-promptAction.md) - [@ohos.router (页面路由)](js-apis-router.md) - [@ohos.measure (文本计算)](js-apis-measure.md) + - [@ohos.uiAppearance(用户界面外观)](js-apis-uiappearance.md) - 图形图像 - [@ohos.animation.windowAnimationManager (窗口动画管理)](js-apis-windowAnimationManager.md) @@ -227,16 +228,15 @@ - [@ohos.data.dataShareResultSet (数据共享结果集)](js-apis-data-DataShareResultSet.md) - [@ohos.data.distributedDataObject (分布式数据对象)](js-apis-data-distributedobject.md) - [@ohos.data.distributedKVStore (分布式键值数据库)](js-apis-distributedKVStore.md) - - [@ohos.data.preferences (首选项)](js-apis-data-preferences.md) + - [@ohos.data.preferences (用户首选项)](js-apis-data-preferences.md) - [@ohos.data.relationalStore (关系型数据库)](js-apis-data-relationalStore.md) - [@ohos.data.ValuesBucket (数据集)](js-apis-data-valuesBucket.md) - - data/rdb - - [resultSet (结果集)](js-apis-data-resultset.md) - 文件管理 - [@ohos.file.environment (目录环境能力)](js-apis-file-environment.md) - [@ohos.file.fileAccess (公共文件访问与管理)](js-apis-fileAccess.md) - [@ohos.file.fileExtensionInfo (公共文件访问与管理属性信息)](js-apis-fileExtensionInfo.md) + - [@ohos.file.fileUri (文件URI)](js-apis-file-fileUri.md) - [@ohos.file.fs (文件管理)](js-apis-file-fs.md) - [@ohos.file.hash (文件哈希处理)](js-apis-file-hash.md) - [@ohos.file.picker (选择器)](js-apis-file-picker.md) @@ -245,6 +245,7 @@ - [@ohos.file.storageStatistics (应用空间统计)](js-apis-file-storage-statistics.md) - [@ohos.file.volumeManager (卷管理)](js-apis-file-volumemanager.md) - [@ohos.filemanagement.userFileManager (用户数据管理)](js-apis-userFileManager.md) + - [@ohos.fileShare (文件分享)](js-apis-fileShare.md) - 电话服务 - [@ohos.contact (联系人)](js-apis-contact.md) @@ -444,3 +445,5 @@ - [PermissionDef](js-apis-bundle-PermissionDef.md) - [remoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md) - [shortcutInfo](js-apis-bundle-ShortcutInfo.md) + - data/rdb + - [resultSet (结果集)](js-apis-data-resultset.md) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/commonEventManager-definitions.md b/zh-cn/application-dev/reference/apis/commonEventManager-definitions.md index d0a05a4bae5c1f8e1ee52287013bfdb08499984e..0cdb577fbcb8129ea13191797dd2b394450bd093 100644 --- a/zh-cn/application-dev/reference/apis/commonEventManager-definitions.md +++ b/zh-cn/application-dev/reference/apis/commonEventManager-definitions.md @@ -60,10 +60,13 @@ - 值: usual.event.THERMAL_LEVEL_CHANGED - 订阅者所需权限: 无 -## COMMON_EVENT_USER_PRESENT +## COMMON_EVENT_USER_PRESENT(deprecated) (预留事件,暂未支持)用户解锁设备的公共事件的动作。 - 值: usual.event.USER_PRESENT - 订阅者所需权限: 无 +> 说明: +> +> 从API Version 10 开始废弃。 ## COMMON_EVENT_TIME_TICK 表示系统时间更改的公共事件的动作。 @@ -888,4 +891,17 @@ Wi-Fi P2P群组信息已更改。 ## COMMON_EVENT_RADIO_STATE_CHANGE10+ 提示设备modem上下电状态变化。 - 值:usual.event.RADIO_STATE_CHANGE + +## COMMON_EVENT_SCREEN_LOCKED 10+ + +表示屏幕锁定的公共事件。 + +- 值: usual.event.SCREEN_LOCKED +- 订阅者所需权限: 无 + +## COMMON_EVENT_SCREEN_UNLOCKED10+ + +表示屏幕解锁的公共事件。 + +- 值:usual.event.SCREEN_UNLOCKED - 订阅者所需权限:无 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/figures/zh-ch_image_Average_Color.png b/zh-cn/application-dev/reference/apis/figures/zh-ch_image_Average_Color.png new file mode 100644 index 0000000000000000000000000000000000000000..db2d6dca8a84f09b59aaa1affb5caf5deb289669 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-ch_image_Average_Color.png differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-ch_image_Highest_Saturation_Color.png b/zh-cn/application-dev/reference/apis/figures/zh-ch_image_Highest_Saturation_Color.png new file mode 100644 index 0000000000000000000000000000000000000000..6bf7c7ba71bee89b092cdf9a8e6a5e786b8e389b Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-ch_image_Highest_Saturation_Color.png differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-ch_image_Largest_Proportion_Color.png b/zh-cn/application-dev/reference/apis/figures/zh-ch_image_Largest_Proportion_Color.png new file mode 100644 index 0000000000000000000000000000000000000000..93f347b1abf77970d9f84569423f0ea1673ecf9a Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-ch_image_Largest_Proportion_Color.png differ 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 65f7d28de041725febfd25cdac582e4b268476fb..8d77a5bffc1a5ccfa74c971c26f5eadf6e5e2b8d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -206,8 +206,8 @@ grantUserGrantedPermission(tokenID: number, permissionName: Permissions, permiss | 错误码ID | 错误信息 | | -------- | -------- | | 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256, or the flags value is invalid. | -| 12100002 | TokenId does not exist. | -| 12100003 | Permission does not exist. | +| 12100002 | The specified tokenID does not exist. | +| 12100003 | The specified permission does not exist. | | 12100006 | The application specified by the tokenID is not allowed to be granted with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. | | 12100007 | Service is abnormal. | @@ -317,8 +317,8 @@ revokeUserGrantedPermission(tokenID: number, permissionName: Permissions, permis | 错误码ID | 错误信息 | | -------- | -------- | | 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256, or the flags value is invalid. | -| 12100002 | TokenId does not exist. | -| 12100003 | Permission does not exist. | +| 12100002 | The specified tokenID does not exist. | +| 12100003 | The specified permission does not exist. | | 12100006 | The application specified by the tokenID is not allowed to be revoked with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. | | 12100007 | Service is abnormal. | @@ -503,7 +503,7 @@ off(type: 'permissionStateChange', tokenIDList: Array<number>, permissionL | 错误码ID | 错误信息 | | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID in list is all invalid, or the permissionName in list is all invalid. | +| 12100001 | The parameter is invalid. The tokenIDs or permissionNames in the list are all invalid. | | 12100004 | The interface is not used together with "on". | | 12100007 | Service is abnormal. | | 12100008 | Out of memory. | @@ -692,6 +692,44 @@ promise.then(data => { }); ``` +### checkAccessTokenSync10+ + +checkAccessTokenSync(tokenID: number, permissionName: Permissions): GrantStatus; + +校验应用是否被授予权限,同步返回结果。 + +**系统能力:** SystemCapability.Security.AccessToken + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------- | ---- | ------------------------------------------ | +| tokenID | number | 是 | 要校验应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)获得。 | +| permissionName | Permissions | 是 | 需要校验的权限名称,合法的权限名取值可在[系统权限定义列表](../../security/permission-list.md)中查询。 | + +**返回值:** + +| 类型 | 说明 | +| :------------ | :---------------------------------- | +| [GrantStatus](#grantstatus) | 枚举实例,返回授权状态。 | + +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. | + +**示例:** + +```js +let atManager = abilityAccessCtrl.createAtManager(); +let tokenID = 0; // 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取 +let data = atManager.checkAccessTokenSync(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); +console.log(`data->${JSON.stringify(data)}`); +``` + ### GrantStatus 表示授权状态的枚举。 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 16b2e9bef518ae6fe58c830c4373a9deaf34b81a..6822b20d3e216d1a6363874c20bdcfe17086aa59 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-accessibility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-accessibility.md @@ -18,9 +18,9 @@ import accessibility from '@ohos.accessibility'; **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 描述 | -| -------- | -------- | -| enable | 辅助应用已启用。 | +| 名称 | 描述 | +| ------- | -------- | +| enable | 辅助应用已启用。 | | disable | 辅助应用已禁用。 | | install | 辅助应用已安装。 | @@ -30,13 +30,13 @@ import accessibility from '@ohos.accessibility'; **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 描述 | -| -------- | -------- | -| audible | 表示具有听觉反馈。 | -| generic | 表示具有通用反馈。 | -| haptic | 表示具有触觉反馈。 | -| spoken | 表示具有语音反馈。 | -| visual | 表示具有视觉反馈。 | +| 名称 | 描述 | +| ---------------- | --------- | +| audible | 表示具有听觉反馈。 | +| generic | 表示具有通用反馈。 | +| haptic | 表示具有触觉反馈。 | +| spoken | 表示具有语音反馈。 | +| visual | 表示具有视觉反馈。 | | all9+ | 表示以上所有类别。 | ## AccessibilityAbilityInfo @@ -47,16 +47,16 @@ import accessibility from '@ohos.accessibility'; ### 属性 -| 名称 | 类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| id | string | 是 | 否 | ability id。 | -| name | string | 是 | 否 | ability 名。 | -| bundleName | string | 是 | 否 | Bundle名称。 | -| targetBundleNames9+ | Array<string> | 是 | 否 | 关注的目标Bundle名称。 | -| abilityTypes | Array<[AbilityType](#abilitytype)> | 是 | 否 | 辅助应用类型。 | -| capabilities | Array<[Capability](#capability)> | 是 | 否 | 辅助应用能力列表。 | -| description | string | 是 | 否 | 辅助应用描述。 | -| eventTypes | Array<[EventType](#eventtype)> | 是 | 否 | 辅助应用关注的无障碍事件列表。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------------------ | ---------------------------------------- | ---- | ---- | ---------------- | +| id | string | 是 | 否 | ability id。 | +| name | string | 是 | 否 | ability 名。 | +| bundleName | string | 是 | 否 | Bundle名称。 | +| targetBundleNames9+ | Array<string> | 是 | 否 | 关注的目标Bundle名称。 | +| abilityTypes | Array<[AbilityType](#abilitytype)> | 是 | 否 | 辅助应用类型。 | +| capabilities | Array<[Capability](#capability)> | 是 | 否 | 辅助应用能力列表。 | +| description | string | 是 | 否 | 辅助应用描述。 | +| eventTypes | Array<[EventType](#eventtype)> | 是 | 否 | 辅助应用关注的无障碍事件列表。 | ## Action @@ -64,24 +64,24 @@ import accessibility from '@ohos.accessibility'; **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 描述 | -| -------- | -------- | -| click | 表示点击操作。 | -| longClick | 表示长按操作。 | -| scrollForward | 表示向前滚动操作。 | -| scrollBackward | 表示向后滚动操作。 | -| focus | 表示获得焦点操作。 | -| clearFocus | 表示清除焦点操作。 | -| clearSelection | 表示清除选择操作。 | -| accessibilityFocus | 表示获得无障碍焦点操作。 | -| clearAccessibilityFocus | 表示清除无障碍焦点操作。 | -| cut | 表示剪切操作。 | -| copy | 表示复制操作。 | -| paste | 表示粘贴操作。 | -| select | 表示选择操作。 | -| setText | 表示设置文本操作。 | -| delete | 表示删除操作。 | -| setSelection | 表示选择操作。 | +| 名称 | 描述 | +| ----------------------- | ------------------ | +| click | 表示点击操作。 | +| longClick | 表示长按操作。 | +| scrollForward | 表示向前滚动操作;当前版本暂不支持。 | +| scrollBackward | 表示向后滚动操作;当前版本暂不支持。 | +| focus | 表示获得焦点操作;当前版本暂不支持。 | +| clearFocus | 表示清除焦点操作;当前版本暂不支持。 | +| clearSelection | 表示清除选择操作;当前版本暂不支持。 | +| accessibilityFocus | 表示获得无障碍焦点操作。 | +| clearAccessibilityFocus | 表示清除无障碍焦点操作。 | +| cut | 表示剪切操作;当前版本暂不支持。 | +| copy | 表示复制操作;当前版本暂不支持。 | +| paste | 表示粘贴操作;当前版本暂不支持。 | +| select | 表示选择操作,当前版本暂不支持。 | +| setText | 表示设置文本操作;当前版本暂不支持。 | +| delete | 表示删除操作;当前版本暂不支持。 | +| setSelection | 表示选择操作;当前版本暂不支持。 | ## Capability @@ -89,13 +89,13 @@ import accessibility from '@ohos.accessibility'; **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 描述 | -| -------- | -------- | -| retrieve | 具有检索窗口内容的能力。 | -| touchGuide | 具有触摸探索模式的能力。 | -| keyEventObserver | 具有过滤按键事件的能力。 | -| zoom | 具有控制显示放大的能力。 | -| gesture | 具有执行手势动作的能力。 | +| 名称 | 描述 | +| ---------------- | --------------------- | +| retrieve | 具有检索窗口内容的能力。 | +| touchGuide | 具有触摸探索模式的能力。 | +| keyEventObserver | 具有过滤按键事件的能力。 | +| zoom | 具有控制显示放大的能力;当前版本暂不支持。 | +| gesture | 具有执行手势动作的能力。 | ## CaptionsFontEdgeType8+ @@ -103,12 +103,12 @@ import accessibility from '@ohos.accessibility'; **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Hearing -| 名称 | 描述 | -| -------- | -------- | -| none | 无效果。 | -| raised | 凸起效果。 | -| depressed | 凹陷效果。 | -| uniform | 轮廓效果。 | +| 名称 | 描述 | +| ---------- | ----- | +| none | 无效果。 | +| raised | 凸起效果。 | +| depressed | 凹陷效果。 | +| uniform | 轮廓效果。 | | dropShadow | 阴影效果。 | ## CaptionsFontFamily8+ @@ -117,16 +117,16 @@ import accessibility from '@ohos.accessibility'; **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Hearing -| 名称 | 描述 | -| -------- | -------- | -| default | 默认字体。 | -| monospacedSerif | 等宽 Serif 字体。 | -| serif | Serif 字体。 | +| 名称 | 描述 | +| ------------------- | ----------------- | +| default | 默认字体。 | +| monospacedSerif | 等宽 Serif 字体。 | +| serif | Serif 字体。 | | monospacedSansSerif | 等宽 Sans Serif 字体。 | -| sansSerif | Sans Serif 字体。 | -| casual | 非正式字体。 | -| cursive | 手写字体。 | -| smallCapitals | 小型大写字母字体。 | +| sansSerif | Sans Serif 字体。 | +| casual | 非正式字体。 | +| cursive | 手写字体。 | +| smallCapitals | 小型大写字母字体。 | ## CaptionsStyle8+ @@ -134,14 +134,14 @@ import accessibility from '@ohos.accessibility'; **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Hearing -| 名称 | 类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | 是 | 否 | 描述字幕字体。 | -| fontScale | number | 是 | 否 | 描述字幕字体缩放系数。 | -| fontColor | number \| string | 是 | 否 | 描述字幕字体颜色。 | -| fontEdgeType | [CaptionsFontEdgeType](#captionsfontedgetype8) | 是 | 否 | 描述字幕字体边缘。 | -| backgroundColor | number \| string | 是 | 否 | 描述字幕背景颜色。 | -| windowColor | number \| string | 是 | 否 | 描述字幕窗口颜色。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------------- | ---------------------------------------- | ---- | ---- | ----------- | +| fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | 是 | 否 | 描述字幕字体。 | +| fontScale | number | 是 | 否 | 描述字幕字体缩放系数。 | +| fontColor | number \| string | 是 | 否 | 描述字幕字体颜色。 | +| fontEdgeType | [CaptionsFontEdgeType](#captionsfontedgetype8) | 是 | 否 | 描述字幕字体边缘。 | +| backgroundColor | number \| string | 是 | 否 | 描述字幕背景颜色。 | +| windowColor | number \| string | 是 | 否 | 描述字幕窗口颜色。 | ## CaptionsManager8+ @@ -151,10 +151,10 @@ import accessibility from '@ohos.accessibility'; ### 属性 -| 名称 | 类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| enabled | boolean | 是 | 否 | 表示是否启用字幕配置。 | -| style | [CaptionsStyle](#captionsstyle8) | 是 | 否 | 表示字幕风格。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------- | -------------------------------- | ---- | ---- | ----------- | +| enabled | boolean | 是 | 否 | 表示是否启用字幕配置。 | +| style | [CaptionsStyle](#captionsstyle8) | 是 | 否 | 表示字幕风格。 | ### on('enableChange') @@ -164,10 +164,10 @@ on(type: 'enableChange', callback: Callback<boolean>): void; **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| type | string | 是 | 监听的事件名,固定为‘enableChange’,即字幕配置启用状态变化事件。 | -| callback | Callback<boolean> | 是 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | --------------------------------------- | +| type | string | 是 | 监听的事件名,固定为‘enableChange’,即字幕配置启用状态变化事件。 | +| callback | Callback<boolean> | 是 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 | **示例:** @@ -190,10 +190,10 @@ on(type: 'styleChange', callback: Callback<CaptionsStyle>): void; **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| type | string | 是 | 监听的事件名,固定为‘styleChange’,即字幕风格变化事件。 | -| callback | Callback<[CaptionsStyle](#captionsstyle8)> | 是 | 回调函数,在字幕风格变化时通过此函数进行通知。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------- | +| type | string | 是 | 监听的事件名,固定为‘styleChange’,即字幕风格变化事件。 | +| callback | Callback<[CaptionsStyle](#captionsstyle8)> | 是 | 回调函数,在字幕风格变化时通过此函数进行通知。 | **示例:** @@ -218,10 +218,10 @@ off(type: 'enableChange', callback?: Callback<boolean>): void; **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| type | string | 是 | 取消监听的事件名,固定为‘enableChange’,即字幕配置启用状态变化事件。 | -| callback | Callback<boolean> | 否 | 回调函数,在字幕配置启用状态变化时将状态通过此函数进行通知。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | ---------------------------------------- | +| type | string | 是 | 取消监听的事件名,固定为‘enableChange’,即字幕配置启用状态变化事件。 | +| callback | Callback<boolean> | 否 | 回调函数,在字幕配置启用状态变化时将状态通过此函数进行通知。 | **示例:** @@ -244,10 +244,10 @@ off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void; **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| type | string | 是 | 取消监听的事件名,固定为‘styleChange’,即字幕风格变化事件。 | -| callback | Callback<[CaptionsStyle](#captionsstyle8)> | 否 | 回调函数,在字幕风格变化时通过此函数进行通知。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------ | +| type | string | 是 | 取消监听的事件名,固定为‘styleChange’,即字幕风格变化事件。 | +| callback | Callback<[CaptionsStyle](#captionsstyle8)> | 否 | 回调函数,在字幕风格变化时通过此函数进行通知。 | **示例:** @@ -272,22 +272,22 @@ try { ### 属性 -| 名称 | 类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| type | [EventType](#eventtype) | 是 | 是 | 无障碍事件类型。 | -| windowUpdateType | [WindowUpdateType](#windowupdatetype) | 是 | 是 | 窗口变化类型。 | -| bundleName | string | 是 | 是 | 目标应用名。 | -| componentType | string | 是 | 是 | 事件源组件类型,如按钮、图表。 | -| pageId | number | 是 | 是 | 事件源的页面 ID。 | -| description | string | 是 | 是 | 事件描述。 | -| triggerAction | [Action](#action) | 是 | 是 | 触发事件的 Action。 | -| textMoveUnit | [TextMoveUnit](#textmoveunit) | 是 | 是 | 文本移动粒度。 | -| contents | Array<string> | 是 | 是 | 内容列表。 | -| lastContent | string | 是 | 是 | 最新内容。 | -| beginIndex | number | 是 | 是 | 画面显示条目的开始序号。 | -| currentIndex | number | 是 | 是 | 当前条目序号。 | -| endIndex | number | 是 | 是 | 画面显示条目的结束序号。 | -| itemCount | number | 是 | 是 | 条目总数。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---------------- | ------------------------------------- | ---- | ---- | --------------------- | +| type | [EventType](#eventtype) | 是 | 是 | 无障碍事件类型。 | +| windowUpdateType | [WindowUpdateType](#windowupdatetype) | 是 | 是 | 窗口变化类型。 | +| bundleName | string | 是 | 是 | 目标应用名。 | +| componentType | string | 是 | 是 | 事件源组件类型,如按钮、图表。 | +| pageId | number | 是 | 是 | 事件源的页面 ID。 | +| description | string | 是 | 是 | 事件描述;当前版本暂不支持。 | +| triggerAction | [Action](#action) | 是 | 是 | 触发事件的 Action。 | +| textMoveUnit | [TextMoveUnit](#textmoveunit) | 是 | 是 | 文本移动粒度;当前版本暂不支持。 | +| contents | Array<string> | 是 | 是 | 内容列表。 | +| lastContent | string | 是 | 是 | 最新内容。 | +| beginIndex | number | 是 | 是 | 画面显示条目的开始序号;当前版本暂不支持。 | +| currentIndex | number | 是 | 是 | 当前条目序号;当前版本暂不支持。 | +| endIndex | number | 是 | 是 | 画面显示条目的结束序号;当前版本暂不支持。 | +| itemCount | number | 是 | 是 | 条目总数;当前版本暂不支持。 | ### constructor @@ -299,9 +299,9 @@ constructor(jsonObject) **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| jsonObject | string | 是 | 创建对象所需要的 JSON 格式字符串。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | -------------------- | +| jsonObject | string | 是 | 创建对象所需要的 JSON 格式字符串。 | **示例:** @@ -319,19 +319,19 @@ constructor(jsonObject) **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 描述 | -| -------- | -------- | -| click | 描述点击组件的事件。 | -| longClick | 描述长按组件的事件。 | -| select | 描述选择组件的事件。 | -| focus | 描述组件获得焦点的事件。 | -| textUpdate | 描述组件文本已更改的事件。 | -| hoverEnter | 描述悬停进入组件的事件。 | -| hoverExit | 描述悬停离开组件的事件。 | -| scroll | 描述滚动视图的事件。 | -| textSelectionUpdate | 描述选定文本已更改的事件。 | -| accessibilityFocus | 描述获得无障碍焦点的事件。 | -| accessibilityFocusClear | 描述清除无障碍焦点的事件。 | +| 名称 | 描述 | +| ----------------------- | ---------------------- | +| click | 描述点击组件的事件。 | +| longClick | 描述长按组件的事件。 | +| select | 描述选择组件的事件;当前版本暂不支持。 | +| focus | 描述组件获得焦点的事件;当前版本暂不支持。 | +| textUpdate | 描述组件文本已更改的事件;当前版本暂不支持。 | +| hoverEnter | 描述悬停进入组件的事件;当前版本暂不支持。 | +| hoverExit | 描述悬停离开组件的事件;当前版本暂不支持。 | +| scroll | 描述滚动视图的事件;当前版本暂不支持。 | +| textSelectionUpdate | 描述选定文本已更改的事件;当前版本暂不支持。 | +| accessibilityFocus | 描述获得无障碍焦点的事件。 | +| accessibilityFocusClear | 描述清除无障碍焦点的事件。 | ## TextMoveUnit @@ -339,12 +339,12 @@ constructor(jsonObject) **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 描述 | -| -------- | -------- | -| char | 以字符为移动粒度遍历节点文本。 | -| word | 以词为移动粒度遍历节点文本。 | -| line | 以行为移动粒度遍历节点文本。 | -| page | 以页为移动粒度遍历节点文本。 | +| 名称 | 描述 | +| --------- | --------------- | +| char | 以字符为移动粒度遍历节点文本。 | +| word | 以词为移动粒度遍历节点文本。 | +| line | 以行为移动粒度遍历节点文本。 | +| page | 以页为移动粒度遍历节点文本。 | | paragraph | 以段落为移动粒度遍历节点文本。 | ## WindowUpdateType @@ -353,13 +353,13 @@ constructor(jsonObject) **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 描述 | -| -------- | -------- | -| add | 添加窗口的窗口变化事件。 | -| remove | 一个窗口被删除的窗口变化事件。 | -| bounds | 窗口边界已更改的窗口变化事件。 | +| 名称 | 描述 | +| ------ | ------------------ | +| add | 添加窗口的窗口变化事件。 | +| remove | 一个窗口被删除的窗口变化事件。 | +| bounds | 窗口边界已更改的窗口变化事件。 | | active | 窗口变为活动或不活动的窗口变化事件。 | -| focus | 窗口焦点发生变化的窗口变化事件。 | +| focus | 窗口焦点发生变化的窗口变化事件。 | ## accessibility.getAbilityLists(deprecated) @@ -376,15 +376,15 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise<A **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | -| stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ----------------------------- | ---- | -------- | +| abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | +| stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------------------------- | --------------------- | | Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Promise对象,返回辅助应用信息列表。 | **示例:** @@ -426,11 +426,11 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: Asyn **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | -| stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | -| callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | 是 | 回调函数,返回辅助应用信息列表。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ---------------------------------------- | ---- | ---------------- | +| abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | +| stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | +| callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | 是 | 回调函数,返回辅助应用信息列表。 | **示例:** @@ -470,15 +470,15 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState) **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | -| stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ----------------------------- | ---- | -------- | +| abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | +| stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------------------------- | --------------------- | | Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Promise对象,返回辅助应用信息列表。 | **示例:** @@ -515,11 +515,11 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState, **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | -| stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | -| callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | 是 | 回调函数,返回辅助应用信息列表。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ---------------------------------------- | ---- | ---------------- | +| abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | +| stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | +| callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | 是 | 回调函数,返回辅助应用信息列表。 | **示例:** @@ -557,8 +557,8 @@ getCaptionsManager(): CaptionsManager **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------------------------ | ---------- | | [CaptionsManager](#captionsmanager8) | 无障碍字幕配置管理。 | **示例:** @@ -577,10 +577,10 @@ on(type: 'accessibilityStateChange', callback: Callback<boolean>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| type | string | 是 | 监听的事件名,固定为‘accessibilityStateChange’,即辅助应用启用状态变化事件。 | -| callback | Callback<boolean> | 是 | 回调函数,在辅助应用启用状态变化时将状态通过此函数进行通知。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | ---------------------------------------- | +| type | string | 是 | 监听的事件名,固定为‘accessibilityStateChange’,即辅助应用启用状态变化事件。 | +| callback | Callback<boolean> | 是 | 回调函数,在辅助应用启用状态变化时将状态通过此函数进行通知。 | **示例:** @@ -604,10 +604,10 @@ on(type: 'touchGuideStateChange', callback: Callback<boolean>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| type | string | 是 | 监听的事件名,固定为‘touchGuideStateChange’,即触摸浏览启用状态变化事件。 | -| callback | Callback<boolean> | 是 | 回调函数,在触摸浏览启用状态变化时将状态通过此函数进行通知。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | ---------------------------------------- | +| type | string | 是 | 监听的事件名,固定为‘touchGuideStateChange’,即触摸浏览启用状态变化事件。 | +| callback | Callback<boolean> | 是 | 回调函数,在触摸浏览启用状态变化时将状态通过此函数进行通知。 | **示例:** @@ -631,10 +631,10 @@ off(type: 'accessibilityStateChange', callback?: Callback<boolean>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| type | string | 否 | 取消监听的事件名,固定为‘accessibilityStateChange’,即辅助应用启用状态变化事件。 | -| callback | Callback<boolean> | 否 | 回调函数,在辅助应用启用状态变化时将状态通过此函数进行通知。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | ---------------------------------------- | +| type | string | 否 | 取消监听的事件名,固定为‘accessibilityStateChange’,即辅助应用启用状态变化事件。 | +| callback | Callback<boolean> | 否 | 回调函数,在辅助应用启用状态变化时将状态通过此函数进行通知。 | **示例:** @@ -658,10 +658,10 @@ off(type: 'touchGuideStateChange', callback?: Callback<boolean>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| type | string | 否 | 取消监听的事件名,固定为‘touchGuideStateChange’,即触摸浏览启用状态变化事件。 | -| callback | Callback<boolean> | 否 | 回调函数,在触摸浏览启用状态变化时将状态通过此函数进行通知。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | ---------------------------------------- | +| type | string | 否 | 取消监听的事件名,固定为‘touchGuideStateChange’,即触摸浏览启用状态变化事件。 | +| callback | Callback<boolean> | 否 | 回调函数,在触摸浏览启用状态变化时将状态通过此函数进行通知。 | **示例:** @@ -685,8 +685,8 @@ isOpenAccessibility(): Promise<boolean> **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------- | ---------------------------------------- | | Promise<boolean> | Promise对象,如果辅助功能已启用,则返回 true;否则返回 false。 | **示例:** @@ -709,9 +709,9 @@ isOpenAccessibility(callback: AsyncCallback<boolean>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | 是 | 回调函数,如果辅助功能已启用,则返回 true;否则返回 false。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ----------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调函数,如果辅助功能已启用,则返回 true;否则返回 false。 | **示例:** @@ -735,8 +735,8 @@ isOpenTouchGuide(): Promise<boolean> **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------- | ---------------------------------------- | | Promise<boolean> | Promise对象,如果触摸浏览模式已开启,则返回 true;否则返回 false。 | **示例:** @@ -759,9 +759,9 @@ isOpenTouchGuide(callback: AsyncCallback<boolean>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | 是 | 回调函数,如果触摸浏览模式已开启,则返回 true;否则返回 false。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调函数,如果触摸浏览模式已开启,则返回 true;否则返回 false。 | **示例:** @@ -790,14 +790,14 @@ sendEvent(event: EventInfo): Promise<void> **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| event | [EventInfo](#eventinfo) | 是 | 无障碍事件对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ----------------------- | ---- | -------- | +| event | [EventInfo](#eventinfo) | 是 | 无障碍事件对象。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ---------------- | | Promise<void> | 无返回结果的Promise对象。 | **示例:** @@ -830,10 +830,10 @@ sendEvent(event: EventInfo, callback: AsyncCallback<void>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| event | [EventInfo](#eventinfo) | 是 | 辅助事件对象。 | -| callback | AsyncCallback<void> | 是 | 回调函数,如果发送无障碍事件失败,则 AsyncCallback中err有数据返回。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------------------------------------- | +| event | [EventInfo](#eventinfo) | 是 | 辅助事件对象。 | +| callback | AsyncCallback<void> | 是 | 回调函数,如果发送无障碍事件失败,则 AsyncCallback中err有数据返回。 | **示例:** @@ -862,14 +862,14 @@ sendAccessibilityEvent(event: EventInfo): Promise<void> **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| event | [EventInfo](#eventinfo) | 是 | 无障碍事件对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ----------------------- | ---- | -------- | +| event | [EventInfo](#eventinfo) | 是 | 无障碍事件对象。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ---------------- | | Promise<void> | 无返回结果的Promise对象。 | **示例:** @@ -901,10 +901,10 @@ sendAccessibilityEvent(event: EventInfo, callback: AsyncCallback<void>): v **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| event | [EventInfo](#eventinfo) | 是 | 辅助事件对象。 | -| callback | AsyncCallback<void> | 是 | 回调函数,如果发送无障碍事件失败,则 AsyncCallback中err有数据返回。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------------------------------------- | +| event | [EventInfo](#eventinfo) | 是 | 辅助事件对象。 | +| callback | AsyncCallback<void> | 是 | 回调函数,如果发送无障碍事件失败,则 AsyncCallback中err有数据返回。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-appRecovery.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-appRecovery.md index a513c1d0c68d7e5386529c0ab378aee6f6cfad7f..8658417d06f5e70a9f87a3ae9555a6fa82a628fa 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-appRecovery.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-appRecovery.md @@ -4,7 +4,7 @@ appRecovery模块提供了应用在故障状态下的恢复能力。 > **说明:** > -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。当前版本仅支持单进程中单Ability的应用恢复。 +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。API9仅支持单进程中单Ability的应用恢复。API10支持进程中包含多个Ability的场景。 ## 导入模块 ```ts @@ -51,7 +51,7 @@ import appRecovery from '@ohos.app.ability.appRecovery'; enableAppRecovery(restart?: [RestartFlag](#apprecoveryrestartflag), saveOccasion?: [SaveOccasionFlag](#apprecoverysaveoccasionflag), saveMode?: [SaveModeFlag](#apprecoverysavemodeflag)) : void; -使能应用恢复功能,参数按顺序填入。 +使能应用恢复功能,参数按顺序填入。该接口调用后,应用从启动器启动时第一个Ability支持恢复。 **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -84,7 +84,14 @@ export default class MyAbilityStage extends AbilityStage { restartApp(): void; -重启当前App进程,可以配合[errorManager](js-apis-app-ability-errorManager.md)相关接口使用。 +重启当前进程,并拉起应用启动时第一个Ability,如果该Ability存在已经保存的状态,这些状态数据会在Ability的OnCreate生命周期回调的want参数中作为wantParam属性传入。 + +API10时将启动由[setRestartWant](#apprecoverysetrestartwant)指定的Ability。如果没有指定则按以下规则启动:\ +如果当前应用前台的Ability支持恢复,则重新拉起该Ability。\ +如果存在多个支持恢复的Ability处于前台,则只拉起最后一个。\ +如果没有Ability处于前台,则不拉起。 + +可以配合[errorManager](js-apis-app-ability-errorManager.md)相关接口使用。 **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -142,3 +149,53 @@ try { console.error('error: ${paramError.code}, ${paramError.message}'); } ``` + +## appRecovery.saveAppState10+ + +saveAppState(context?: UIAbilityContext): boolean; + +主动保存Ability的状态,这个状态将在下次恢复启动时使用。可以配合[errorManager](js-apis-app-ability-errorManager.md)相关接口使用 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| boolean | 保存成功与否。true:保存成功,false:保存失败。 | + +**示例:** + +```ts +import appRecovery from '@ohos.app.ability.appRecovery'; +onBackground() { + hilog.info(0x0000, '[demo]', '%{public}s', 'EntryAbility onBackground'); + appRecovery.saveAppState(this.context) +} +``` + +## appRecovery.setRestartWant10+ + +setRestartWant(want: Want): void; + +设置下次恢复主动拉起场景下的Ability。该Ability必须为当前包下的UIAbility。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**示例:** + +```ts +import appRecovery from '@ohos.app.ability.appRecovery'; +Button("启动到恢复Ability") + .fontSize(40) + .fontWeight(FontWeight.Bold) + .onClick(()=> { + // set restart want + let want = { + bundleName: "ohos.samples.recovery", + abilityName: "RecoveryAbility" + }; + + appRecovery.setRestartWant(want); + }) +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-form-formInfo.md b/zh-cn/application-dev/reference/apis/js-apis-app-form-formInfo.md index 68c813640be97cb572079e41887ea6770949ee0b..55baab89a6a4390f48466b19e1f84ee177843081 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-form-formInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-form-formInfo.md @@ -47,7 +47,7 @@ import formInfo from '@ohos.app.form.formInfo'; | 名称 | 值 | 说明 | | ----------- | ---- | ------------ | | JS | 1 | 卡片类型为JS。 | -| eTS | 2 | 卡片类型为eTS。 | +| eTS | 2 | 卡片类型为ArkTS。 | ## ColorMode 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 719437c9913dc324003a2c9e030945f8f44f8db6..576ac1cb96871d0ff6bbd4b39072da650ca08f89 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md @@ -148,7 +148,6 @@ createAccount(name: string, options?: CreateAccountOptions): Promise<void> | 12300002 | Invalid name or options. | | 12300004 | Account already exists. | | 12300007 | The number of accounts reaches the upper limit. | -| 12400003 | The number of custom data reaches the upper limit. | **示例:** @@ -248,7 +247,7 @@ createAccountImplicitly(owner: string, options: CreateAccountImplicitlyOptions, | 错误码ID | 错误信息 | | ------- | ------- | | 12300001 | System service exception. | -| 12300002 | Invalid name or options. | +| 12300002 | Invalid owner or options. | | 12300007 | The number of accounts reaches the upper limit. | | 12300010 | Account service busy. | | 12300113 | Authenticator service not found. | @@ -481,7 +480,6 @@ checkAppAccess(name: string, bundleName: string, callback: AsyncCallback<bool | 12300001 | System service exception. | | 12300002 | Invalid name or bundleName. | | 12300003 | Account not found. | -| 12400001 | Application not found. | **示例:** @@ -527,7 +525,6 @@ checkAppAccess(name: string, bundleName: string): Promise<boolean> | 12300001 | System service exception. | | 12300002 | Invalid name or bundleName. | | 12300003 | Account not found. | -| 12400001 | Application not found. | **示例:** @@ -903,7 +900,7 @@ setCustomData(name: string, key: string, value: string, callback: AsyncCallback& | 错误码ID | 错误信息| | ------- | -------| | 12300001 | System service exception. | -| 12300002 | Invalid name or key or value. | +| 12300002 | Invalid name, key or value. | | 12300003 | Account not found. | | 12400003 | The number of custom data reaches the upper limit. | @@ -950,7 +947,7 @@ setCustomData(name: string, key: string, value: string): Promise<void> | 错误码ID | 错误信息| | ------- | -------| | 12300001 | System service exception. | -| 12300002 | Invalid name or key or value. | +| 12300002 | Invalid name, key or value. | | 12300003 | Account not found. | | 12400003 | The number of custom data reaches the upper limit. | @@ -1267,7 +1264,6 @@ on(type: 'accountChange', owners: Array<string>, callback: Callback<Arr | ------- | ------- | | 12300001 | System service exception. | | 12300002 | Invalid type or owners. | -| 12300011 | Callback has been registered. | | 12400001 | Application not found. | **示例:** @@ -1304,7 +1300,6 @@ off(type: 'accountChange', callback?: Callback<Array<AppAccountInfo>> | ------- | -------| | 12300001 | System service exception. | | 12300002 | Invalid type. | -| 12300012 | Callback has not been registered. | **示例:** @@ -1347,7 +1342,7 @@ auth(name: string, owner: string, authType: string, callback: AuthCallback): voi | 错误码ID | 错误信息| | ------- | -------| | 12300001 | System service exception. | -| 12300002 | Invalid name or owner or authType. | +| 12300002 | Invalid name, owner or authType. | | 12300003 | Account not found. | | 12300010 | Account service busy. | | 12300113 | Authenticator service not found. | @@ -1410,8 +1405,8 @@ auth(name: string, owner: string, authType: string, options: {[key: string]: Obj | 错误码ID | 错误信息| | ------- | -------| | 12300001 | System service exception. | -| 12300002 | Invalid name or owner or authType. | -| 12300003 | Account not exist. | +| 12300002 | Invalid name, owner, authType or options. | +| 12300003 | Account not found. | | 12300010 | Account service busy. | | 12300113 | Authenticator service not found. | | 12300114 | Authenticator service exception. | @@ -1522,7 +1517,7 @@ getAuthToken(name: string, owner: string, authType: string): Promise<string&g | 错误码ID | 错误信息 | | ------- | ------- | | 12300001 | System service exception. | -| 12300002 | Invalid name or owner or authType. | +| 12300002 | Invalid name, owner or authType. | | 12300003 | Account not found. | | 12300107 | AuthType not found. | @@ -1562,7 +1557,7 @@ setAuthToken(name: string, authType: string, token: string, callback: AsyncCallb | 错误码ID | 错误信息| | ------- | -------| | 12300001 | System service exception. | -| 12300002 | Invalid name or authType or token. | +| 12300002 | Invalid name, authType or token. | | 12300003 | Account not found. | | 12400004 | The number of token reaches the upper limit. | @@ -1609,7 +1604,7 @@ setAuthToken(name: string, authType: string, token: string): Promise<void> | 错误码ID | 错误信息| | ------- | -------| | 12300001 | System service exception. | -| 12300002 | Invalid name or authType or token. | +| 12300002 | Invalid name, authType or token. | | 12300003 | Account not found. | | 12400004 | The number of token reaches the upper limit. | @@ -1650,7 +1645,7 @@ deleteAuthToken(name: string, owner: string, authType: string, token: string, ca | 错误码ID | 错误信息 | | ------- | ------- | | 12300001 | System service exception. | -| 12300002 | Invalid name or owner or authType or token. | +| 12300002 | Invalid name, owner, authType or token. | | 12300003 | Account not found. | | 12300107 | AuthType not found. | @@ -1698,7 +1693,7 @@ deleteAuthToken(name: string, owner: string, authType: string, token: string): P | 错误码ID | 错误信息 | | ------- | ------- | | 12300001 | System service exception. | -| 12300002 | Invalid name or owner or authType or token. | +| 12300002 | Invalid name, owner, authType or token. | | 12300003 | Account not found. | | 12300107 | AuthType not found. | @@ -1739,7 +1734,7 @@ setAuthTokenVisibility(name: string, authType: string, bundleName: string, isVis | 错误码ID | 错误信息| | ------- | -------| | 12300001 | System service exception. | -| 12300002 | Invalid name or authType or bundleName. | +| 12300002 | Invalid name, authType or bundleName. | | 12300003 | Account not found. | | 12300107 | AuthType not found. | | 12400001 | Application not found. | @@ -1789,7 +1784,7 @@ setAuthTokenVisibility(name: string, authType: string, bundleName: string, isVis | 错误码ID | 错误信息| | ------- | -------| | 12300001 | System service exception. | -| 12300002 | Invalid name or authType or bundleName. | +| 12300002 | Invalid name, authType or bundleName. | | 12300003 | Account not found. | | 12300107 | AuthType not found. | | 12400001 | Application not found. | @@ -1831,10 +1826,9 @@ checkAuthTokenVisibility(name: string, authType: string, bundleName: string, cal | 错误码ID | 错误信息| | ------- | -------| | 12300001 | System service exception. | -| 12300002 | Invalid name or authType or bundleName. | +| 12300002 | Invalid name, authType or bundleName. | | 12300003 | Account not found. | | 12300107 | AuthType not found. | -| 12400001 | Application not found. | **示例:** @@ -1879,10 +1873,9 @@ checkAuthTokenVisibility(name: string, authType: string, bundleName: string): Pr | 错误码ID | 错误信息| | ------- | -------| | 12300001 | System service exception. | -| 12300002 | Invalid name or authType or bundleName. | +| 12300002 | Invalid name, authType or bundleName. | | 12300003 | Account not found. | | 12300107 | AuthType not found. | -| 12400001 | Application not found. | **示例:** @@ -2281,7 +2274,7 @@ checkAccountLabels(name: string, owner: string, labels: Array<string>, cal | 错误码ID | 错误信息 | | ------- | ------- | | 12300001 | System service exception. | -| 12300002 | Invalid name or owner or labels. | +| 12300002 | Invalid name, owner or labels. | | 12300003 | Account not found. | | 12300010 | Account service busy. | | 12300113 | Authenticator service not found. | @@ -2331,7 +2324,7 @@ checkAccountLabels(name: string, owner: string, labels: Array<string>): Pr | 错误码ID | 错误信息 | | ------- | ------- | | 12300001 | System service exception. | -| 12300002 | Invalid name or owner or labels. | +| 12300002 | Invalid name, owner or labels. | | 12300003 | Account not found. | | 12300010 | Account service busy. | | 12300113 | Authenticator service not found. | @@ -2594,7 +2587,7 @@ verifyCredential(name: string, owner: string, options: VerifyCredentialOptions, | 错误码ID | 错误信息| | ------- | -------| | 12300001 | System service exception. | -| 12300002 | Invalid name or owner or options. | +| 12300002 | Invalid name, owner or options. | | 12300003 | Account not found. | | 12300010 | Account service busy. | | 12300113 | Authenticator service not found. | 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 d83bfe08bb64c405f5ed4e5b3de2bde89c1a4399..209e20483059e5ca06dd284e3b52818a517acb2b 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 @@ -16,9 +16,9 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens **系统能力:** SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 类型 | 可读 | 可写 | 说明 | -| --------- | -------- | ---- | ---- | ------------------------- | -| context | [AccessibilityExtensionContext](js-apis-inner-application-accessibilityExtensionContext.md) | 是 | 否 | 表示辅助扩展能力上下文。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------- | ---------------------------------------- | ---- | ---- | ------------ | +| context | [AccessibilityExtensionContext](js-apis-inner-application-accessibilityExtensionContext.md) | 是 | 否 | 表示辅助扩展能力上下文。 | ## AccessibilityEvent @@ -28,11 +28,11 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens ### 属性 -| 名称 | 类型 | 可读 | 可写 | 说明 | -| --------- | ---------------------------------------- | ---- | ---- | ---------- | -| eventType | [accessibility.EventType](js-apis-accessibility.md#EventType) \| [accessibility.WindowUpdateType](js-apis-accessibility.md#WindowUpdateType) \| [TouchGuideType](#touchguidetype) \| [GestureType](#gesturetype) \| [PageUpdateType](#pageupdatetype) | 是 | 否 | 具体事件类型。 | -| target | [AccessibilityElement](js-apis-inner-application-accessibilityExtensionContext.md#accessibilityelement9) | 是 | 否 | 发生事件的目标组件。 | -| timeStamp | number | 是 | 否 | 事件时间戳。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ | +| eventType | [accessibility.EventType](js-apis-accessibility.md#EventType) \| [accessibility.WindowUpdateType](js-apis-accessibility.md#WindowUpdateType)\| [TouchGuideType](#touchguidetype) \| [GestureType](#gesturetype) \| [PageUpdateType](#pageupdatetype) | 是 | 否 | 具体事件类型。
EventType:无障碍事件类型;
WindowUpdateType:窗口变化类型;TouchGuideType:触摸浏览事件类型;
GestureType:手势事件类型;
PageUpdateType:页面刷新类型,当前版本暂不支持。 | +| target | [AccessibilityElement](js-apis-inner-application-accessibilityExtensionContext.md#accessibilityelement9) | 是 | 否 | 发生事件的目标组件。 | +| timeStamp | number | 是 | 否 | 事件时间戳。 | ## GestureType @@ -40,8 +40,8 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 描述 | -| ------------- | ------------ | +| 名称 | 描述 | +| ------------- | ------------------- | | left | 类型为字符串,表示向左的手势。 | | leftThenRight | 类型为字符串,表示先向左再向右的手势。 | | leftThenUp | 类型为字符串,表示先向左再向上的手势。 | @@ -61,12 +61,12 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens ## PageUpdateType -页面刷新类型。 +页面刷新类型;当前版本暂不支持。 **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 描述 | -| ----------------- | --------- | +| 名称 | 描述 | +| ----------------- | ---------------- | | pageContentUpdate | 类型为字符串,表示页面内容刷新。 | | pageStateUpdate | 类型为字符串,表示页面状态刷新。 | @@ -76,8 +76,8 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 描述 | -| ---------- | ------------ | +| 名称 | 描述 | +| ---------- | ------------------- | | touchBegin | 类型为字符串,表示触摸浏览时开始触摸。 | | touchEnd | 类型为字符串,表示触摸浏览时结束触摸。 | @@ -127,7 +127,7 @@ onAccessibilityEvent(event: AccessibilityEvent): void; **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ---------------------------------------- | ---- | --------------- | | event | [AccessibilityEvent](#accessibilityevent) | 是 | 无障碍事件回调函数。无返回值。 | @@ -154,7 +154,7 @@ onKeyEvent(keyEvent: KeyEvent): boolean; **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ----------------------- | | keyEvent | [KeyEvent](js-apis-keyevent.md#KeyEvent) | 是 | 按键事件回调函数。返回true表示拦截此按键。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-arkui-drawableDescriptor.md b/zh-cn/application-dev/reference/apis/js-apis-arkui-drawableDescriptor.md new file mode 100644 index 0000000000000000000000000000000000000000..dececbfebf0b5d76bb9e57266f7a97a70a08b0f7 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-arkui-drawableDescriptor.md @@ -0,0 +1,135 @@ +# @ohos.arkui.drawableDescriptor (DrawableDescriptor) + +本模块提供获取pixelMap的能力,包括前景、背景、蒙版和分层图标。 + +> **说明:** +> +> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> 示例效果请以真机运行为准,当前IDE预览器不支持。 + +## 导入模块 + +```js +import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'; +``` + +## DrawableDescriptor.constructor +constructor() + +创建DrawableDescriptor或LayeredDrawableDescriptor对象。对象构造需要使用全球化接口[getDrawableDescriptor](js-apis-resource-manager.md##getdrawabledescriptor)或[getDrawableDescriptorByName](js-apis-resource-manager.md##getdrawabledescriptorbyname)。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +### DrawableDescriptor + +当传入资源id或name为普通图片时,生成DrawableDescriptor对象。 + +### LayeredDrawableDescriptor + +当传入资源id或name为包含前景和背景资源的json文件时,生成LayeredDrawableDescriptor对象。 + +**示例:** +```js +@Entry +@Component +struct Index { + private resManager = getContext().resourceManager + let drawable1 = resManager.getDrawableDescriptor($r('app.media.icon').id) + let drawable2 = resManager.getDrawableDescriptorByName(icon) + let layeredDrawable1 = resManager.getDrawableDescriptor($r('app.media.file').id) + let layeredDrawable1 = resManager.getDrawableDescriptor(file) + } +``` + +## DrawableDescriptor.getPixelMap +getPixelMap(): image.PixelMap; + +获取pixelMap。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**返回值:** + +| 类型 | 说明 | +| --------------------------------- | ---------------- | +| [image.PixelMap](../apis/js-apis-image.md#pixelmap7) | PixelMap | + +**示例:** + ```js + @State pixmap: PixelMap = drawable1.getPixelMap(); + ``` + +## LayeredDrawableDescriptor.getPixelMap +getPixelMap(): image.PixelMap; + +获取前景、背景和蒙版融合裁剪后的pixelMap。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**返回值:** + +| 类型 | 说明 | +| --------------------------------- | ---------------- | +| [image.PixelMap](../apis/js-apis-image.md#pixelmap7) | PixelMap | + +**示例:** + ```js + @State pixmap: PixelMap = layeredDrawable1.getPixelMap(); + ``` + +## LayeredDrawableDescriptor.getForeground +getForeground(): DrawableDescriptor; + +获取前景的DrawableDescriptor对象。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**返回值:** + +| 类型 | 说明 | +| --------------------------------- | ---------------- | +| [DrawableDescriptor](#drawabledescriptor) | DrawableDescriptor对象 | + +**示例:** + ```js + @State drawable: DrawableDescriptor = layeredDrawable1.getForeground(); + ``` + +## LayeredDrawableDescriptor.getBackground +getBackground(): DrawableDescriptor; + +获取背景的DrawableDescriptor对象。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**返回值:** + +| 类型 | 说明 | +| --------------------------------- | ---------------- | +| [DrawableDescriptor](#drawabledescriptor) | DrawableDescriptor对象 | + +**示例:** + ```js + @State drawable: DrawableDescriptor = layeredDrawable1.getBackground(); + ``` + +## LayeredDrawableDescriptor.getMask +getMask(): DrawableDescriptor; + +获取蒙版的DrawableDescriptor对象。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**返回值:** + +| 类型 | 说明 | +| --------------------------------- | ---------------- | +| [DrawableDescriptor](#drawabledescriptor) | DrawableDescriptor对象 | + +**示例:** + ```js + @State drawable: DrawableDescriptor = layeredDrawable1.getMask(); + ``` 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 11ba2ba08458236b144c32c3f7111e351d4035b9..fffcf303e943f5ec3564b80cf508d1fb40d4b9a0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -689,21 +689,19 @@ async function createTonePlayerBefore(){ | forceType | [InterruptForceType](#interruptforcetype9) | 是 | 操作是由系统执行或是由应用程序执行。 | | hintType | [InterruptHint](#interrupthint) | 是 | 中断提示。 | -## VolumeEvent8+ +## VolumeEvent9+ 音量改变时,应用接收的事件。 -**系统接口:** 该接口为系统接口 - **系统能力:** SystemCapability.Multimedia.Audio.Volume | 名称 | 类型 | 必填 | 说明 | | ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | -| updateUi | boolean | 是 | 在UI中显示音量变化。 | -| volumeGroupId9+ | number | 是 | 音量组id。可用于getGroupManager入参 | -| networkId9+ | string | 是 | 网络id。 | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | +| updateUi | boolean | 是 | 在UI中显示音量变化。 | +| volumeGroupId | number | 是 | 音量组id。可用于getGroupManager入参。
此接口为系统接口。 | +| networkId | string | 是 | 网络id。
此接口为系统接口。 | ## MicStateChangeEvent9+ @@ -1110,7 +1108,7 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l 设置指定流的音量,使用callback方式异步返回结果。 > **说明:** -> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用AudioVolumeGroupManager中的[setVolume](#setvolume9)替代。 +> 从 API version 7 开始支持,从 API version 9 开始废弃。建议使用AudioVolumeGroupManager中的[setVolume](#setvolume9)替代,替代接口能力仅对系统应用开放。 **需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY @@ -1145,7 +1143,7 @@ setVolume(volumeType: AudioVolumeType, volume: number): Promise<void> 设置指定流的音量,使用Promise方式异步返回结果。 > **说明:** -> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用AudioVolumeGroupManager中的[setVolume](#setvolume9)替代。 +> 从 API version 7 开始支持,从 API version 9 开始废弃。建议使用AudioVolumeGroupManager中的[setVolume](#setvolume9)替代,替代接口能力仅对系统应用开放。 **需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY @@ -1364,7 +1362,7 @@ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void 设置指定音量流静音,使用callback方式异步返回结果。 > **说明:** -> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用AudioVolumeGroupManager中的[mute](#mute9)替代。 +> 从 API version 7 开始支持,从 API version 9 开始废弃。建议使用AudioVolumeGroupManager中的[mute](#mute9)替代,替代接口能力仅对系统应用开放。 **系统能力:** SystemCapability.Multimedia.Audio.Volume @@ -1395,7 +1393,7 @@ mute(volumeType: AudioVolumeType, mute: boolean): Promise<void> 设置指定音量流静音,使用Promise方式异步返回结果。 > **说明:** -> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用AudioVolumeGroupManager中的[mute](#mute9)替代。 +> 从 API version 7 开始支持,从 API version 9 开始废弃。建议使用AudioVolumeGroupManager中的[mute](#mute9)替代,替代接口能力仅对系统应用开放。 **系统能力:** SystemCapability.Multimedia.Audio.Volume @@ -1550,7 +1548,7 @@ setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void 设置铃声模式,使用callback方式异步返回结果。 > **说明:** -> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用AudioVolumeGroupManager中的[setRingerMode](#setringermode9)替代。 +> 从 API version 7 开始支持,从 API version 9 开始废弃。建议使用AudioVolumeGroupManager中的[setRingerMode](#setringermode9)替代,替代接口能力仅对系统应用开放。 **需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY @@ -1584,7 +1582,8 @@ setRingerMode(mode: AudioRingMode): Promise<void> 设置铃声模式,使用Promise方式异步返回结果。 > **说明:** -> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用AudioVolumeGroupManager中的[setRingerMode](#setringermode9)替代。 +> 从 API version 7 开始支持,从 API version 9 开始废弃。建议使用AudioVolumeGroupManager中的[setRingerMode](#setringermode9)替代,替代接口能力仅对系统应用开放。 + **需要权限:** ohos.permission.ACCESS_NOTIFICATION_POLICY @@ -1974,12 +1973,12 @@ audioManager.isMicrophoneMute().then((value) => { }); ``` -### on('volumeChange')(deprecated) +### on('volumeChange')9+ on(type: 'volumeChange', callback: Callback\): void > **说明:** -> 从 API version 8 开始支持,从 API version 9 开始废弃,建议使用AudioVolumeManager中的[on](#on9)替代。 +> 建议使用AudioVolumeManager中的[on('volumeChange')](#onvolumechange9)替代。 监听系统音量变化事件。 @@ -1994,7 +1993,7 @@ on(type: 'volumeChange', callback: Callback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 事件回调类型,支持的事件为:'volumeChange'(系统音量变化事件,检测到系统音量改变时,触发该事件)。 | -| callback | Callback<[VolumeEvent](#volumeevent8)> | 是 | 回调方法。 | +| callback | Callback<[VolumeEvent](#volumeevent9)> | 是 | 回调方法。 | **示例:** @@ -2041,7 +2040,7 @@ on(type: 'deviceChange', callback: Callback): void 设备更改。音频设备连接状态变化。 > **说明:** -> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用AudioRoutingManager中的[on](#on9)替代。 +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用AudioRoutingManager中的[on('deviceChange')](#ondevicechange9)替代。 **系统能力:** SystemCapability.Multimedia.Audio.Device @@ -2070,7 +2069,7 @@ off(type: 'deviceChange', callback?: Callback): void 取消订阅音频设备连接变化事件。 > **说明:** -> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用AudioRoutingManager中的[off](#off9)替代。 +> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用AudioRoutingManager中的[off('deviceChange')](#offdevicechange9)替代。 **系统能力:** SystemCapability.Multimedia.Audio.Device @@ -2303,7 +2302,7 @@ on(type: 'volumeChange', callback: Callback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 事件回调类型,支持的事件为:'volumeChange'。 | -| callback | Callback<[VolumeEvent](#volumeevent8)> | 是 | 回调方法。 | +| callback | Callback<[VolumeEvent](#volumeevent9)> | 是 | 回调方法。 | **错误码:** @@ -3430,7 +3429,7 @@ audioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) }); ``` -### on9+ +### on('deviceChange')9+ on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback): void @@ -3465,7 +3464,7 @@ audioRoutingManager.on('deviceChange', audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (de }); ``` -### off9+ +### off('deviceChange')9+ off(type: 'deviceChange', callback?: Callback): void @@ -3899,6 +3898,125 @@ async function selectOutputDeviceByFilter(){ } ``` +### getPreferOutputDeviceForRendererInfo10+ + +getPreferOutputDeviceForRendererInfo(rendererInfo: AudioRendererInfo, callback: AsyncCallback<AudioDeviceDescriptors>): void + +根据音频信息,返回优先级最高的输出设备,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Device + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | +| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 是 | 表示渲染器信息。 | +| callback | AsyncCallback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | 是 | 回调,返回优先级最高的输出设备信息。 | + +**示例:** +```js +let rendererInfo = { + content : audio.ContentType.CONTENT_TYPE_MUSIC, + usage : audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags : 0 }; + +async function getPreferOutputDevice() { + audioRoutingManager.getPreferOutputDeviceForRendererInfo(rendererInfo, (err, desc) => { + if (err) { + console.error(`Result ERROR: ${JSON.stringify(err)}`); + } else { + console.info('device descriptor: ' + JSON.stringify(desc)); + } + }); +} +``` + +### getPreferOutputDeviceForRendererInfo9+ +getPreferOutputDeviceForRendererInfo(rendererInfo: AudioRendererInfo): Promise<AudioDeviceDescriptors> + +根据音频信息,返回优先级最高的输出设备,使用promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Device + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------------------| ------------------------------------------------------------ | ---- | ------------------------- | +| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 是 | 表示渲染器信息。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------- | --------------------------- | +| Promise<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Promise返回优先级最高的输出设备信息。 | + +**示例:** + +```js +let rendererInfo = { + content : audio.ContentType.CONTENT_TYPE_MUSIC, + usage : audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags : 0 }; + +async function getPreferOutputDevice() { + audioRoutingManager.getPreferOutputDeviceForRendererInfo(rendererInfo).then((desc) => { + console.info('device descriptor: ' + JSON.stringify(desc)); + }).catch((err) => { + console.error(`Result ERROR: ${JSON.stringify(err)}`); + }) +} +``` + +### on('preferOutputDeviceChangeForRendererInfo')10+ + +on(type: 'preferOutputDeviceChangeForRendererInfo', rendererInfo: AudioRendererInfo, callback: Callback): void + +订阅最高优先级输出设备变化事件,使用callback获取最高优先级输出设备。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| :------- | :--------------------------------------------------- | :--- | :----------------------------------------- | +| type | string | 是 | 订阅的事件的类型。支持事件:'preferOutputDeviceChangeForRendererInfo' | +| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 是 | 表示渲染器信息。 | +| callback | Callback<[AudioDeviceDescriptors](#audiodevicedescriptors)\> | 是 | 获取优先级最高的输出设备信息。 | + +**示例:** + +```js +let rendererInfo = { + content : audio.ContentType.CONTENT_TYPE_MUSIC, + usage : audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags : 0 }; + +audioRoutingManager.on('preferOutputDeviceChangeForRendererInfo', rendererInfo, (desc) => { + console.info('device descriptor: ' + JSON.stringify(desc)); +}); +``` + +### off('preferOutputDeviceChangeForRendererInfo')10+ + +off(type: 'preferOutputDeviceChangeForRendererInfo', callback?: Callback): void + +取消订阅最高优先级输出音频设备变化事件。 + +**系统能力:** SystemCapability.Multimedia.Audio.Device + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------- | ---- | ------------------------------------------ | +| type | string | 是 | 订阅的事件的类型。支持事件:'preferOutputDeviceChangeForRendererInfo' | +| callback | Callback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | 否 | 监听方法的回调函数。 | + +**示例:** + +```js +audioRoutingManager.off('preferOutputDeviceChangeForRendererInfo', () => { + console.info('Should be no callback.'); +}); +``` + ## AudioRendererChangeInfoArray9+ 数组类型,AudioRenderChangeInfo数组,只读。 @@ -4068,7 +4186,7 @@ promise.then(function (value) { | 名称 | 类型 | 必填 | 说明 | | -------------| ---------------------------------------- | ---- | -------------- | -| uid | number | 是 | 表示应用ID。
**系统能力:** SystemCapability.Multimedia.Audio.Core| +| uid | number | 否 | 表示应用ID。
**系统能力:** SystemCapability.Multimedia.Audio.Core| | rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 否 | 表示渲染器信息。
**系统能力:** SystemCapability.Multimedia.Audio.Renderer| | rendererId | number | 否 | 音频流唯一id。
**系统能力:** SystemCapability.Multimedia.Audio.Renderer| 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 1c8b02dde9ca35f07e7693d51a162ebc3de0b063..636487cc3dd633f9e8a5141ebc044c786e4441bd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @@ -22,8 +22,7 @@ enableBluetooth(): boolean 开启蓝牙。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.enableBluetooth](js-apis-bluetoothManager.md#bluetoothmanagerenablebluetooth)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.enableBluetooth](js-apis-bluetoothManager.md#bluetoothmanagerenablebluetooth)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH @@ -49,8 +48,7 @@ disableBluetooth(): boolean 关闭蓝牙。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.disableBluetooth](js-apis-bluetoothManager.md#bluetoothmanagerdisablebluetooth)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.disableBluetooth](js-apis-bluetoothManager.md#bluetoothmanagerdisablebluetooth)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH @@ -76,8 +74,7 @@ getLocalName(): string 获取蓝牙本地设备名称。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.getLocalName](js-apis-bluetoothManager.md#bluetoothmanagergetlocalname)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.getLocalName](js-apis-bluetoothManager.md#bluetoothmanagergetlocalname)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -103,8 +100,7 @@ getState(): BluetoothState 获取蓝牙开关状态。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.getState](js-apis-bluetoothManager.md#bluetoothmanagergetstate)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.getState](js-apis-bluetoothManager.md#bluetoothmanagergetstate)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -127,11 +123,10 @@ let state = bluetooth.getState(); getBtConnectionState(): ProfileConnectionState -获取蓝牙设备的Profile连接状态。 +获取蓝牙本端的Profile连接状态,例如:任意一个支持的Profile连接状态为已连接,则此接口返回状态为已连接。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.getBtConnectionState](js-apis-bluetoothManager.md#bluetoothmanagergetbtconnectionstate)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.getBtConnectionState](js-apis-bluetoothManager.md#bluetoothmanagergetbtconnectionstate)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -157,8 +152,7 @@ setLocalName(name: string): boolean 设置蓝牙本地设备名称。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.setLocalName](js-apis-bluetoothManager.md#bluetoothmanagersetlocalname)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.setLocalName](js-apis-bluetoothManager.md#bluetoothmanagersetlocalname)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH @@ -190,8 +184,7 @@ pairDevice(deviceId: string): boolean 发起蓝牙配对。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.pairDevice](js-apis-bluetoothManager.md#bluetoothmanagerpairdevice)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.pairDevice](js-apis-bluetoothManager.md#bluetoothmanagerpairdevice)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH @@ -221,11 +214,10 @@ let result = bluetooth.pairDevice("XX:XX:XX:XX:XX:XX"); getProfileConnState(profileId: ProfileId): ProfileConnectionState -获取profile的连接状态。 +依据ProfileId获取指定profile的连接状态。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.getProfileConnectionState](js-apis-bluetoothManager.md#bluetoothmanagergetprofileconnectionstate)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.getProfileConnectionState](js-apis-bluetoothManager.md#bluetoothmanagergetprofileconnectionstate)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -257,8 +249,7 @@ cancelPairedDevice(deviceId: string): boolean 删除配对的远程设备。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.cancelPairedDevice](js-apis-bluetoothManager.md#bluetoothmanagercancelpaireddevice)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.cancelPairedDevice](js-apis-bluetoothManager.md#bluetoothmanagercancelpaireddevice)替代。 **系统接口**:此接口为系统接口。 @@ -292,8 +283,7 @@ getRemoteDeviceName(deviceId: string): string 获取对端蓝牙设备的名称。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.getRemoteDeviceName](js-apis-bluetoothManager.md#bluetoothmanagergetremotedevicename)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.getRemoteDeviceName](js-apis-bluetoothManager.md#bluetoothmanagergetremotedevicename)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -325,8 +315,7 @@ getRemoteDeviceClass(deviceId: string): DeviceClass 获取对端蓝牙设备的类别。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.getRemoteDeviceClass](js-apis-bluetoothManager.md#bluetoothmanagergetremotedeviceclass)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.getRemoteDeviceClass](js-apis-bluetoothManager.md#bluetoothmanagergetremotedeviceclass)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -358,8 +347,7 @@ getPairedDevices(): Array<string> 获取蓝牙配对列表。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.getPairedDevices](js-apis-bluetoothManager.md#bluetoothmanagergetpaireddevices)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.getPairedDevices](js-apis-bluetoothManager.md#bluetoothmanagergetpaireddevices)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -385,8 +373,7 @@ setBluetoothScanMode(mode: ScanMode, duration: number): boolean 设置蓝牙扫描模式,可以被远端设备发现。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.setBluetoothScanMode](js-apis-bluetoothManager.md#bluetoothmanagersetbluetoothscanmode)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.setBluetoothScanMode](js-apis-bluetoothManager.md#bluetoothmanagersetbluetoothscanmode)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -420,8 +407,7 @@ getBluetoothScanMode(): ScanMode 获取蓝牙扫描模式。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.getBluetoothScanMode](js-apis-bluetoothManager.md#bluetoothmanagergetbluetoothscanmode)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.getBluetoothScanMode](js-apis-bluetoothManager.md#bluetoothmanagergetbluetoothscanmode)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -447,8 +433,7 @@ startBluetoothDiscovery(): boolean 开启蓝牙扫描,可以发现远端设备。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.startBluetoothDiscovery](js-apis-bluetoothManager.md#bluetoothmanagerstartbluetoothdiscovery)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.startBluetoothDiscovery](js-apis-bluetoothManager.md#bluetoothmanagerstartbluetoothdiscovery)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH 和 ohos.permission.LOCATION @@ -479,8 +464,7 @@ stopBluetoothDiscovery(): boolean 关闭蓝牙扫描。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.stopBluetoothDiscovery](js-apis-bluetoothManager.md#bluetoothmanagerstopbluetoothdiscovery)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.stopBluetoothDiscovery](js-apis-bluetoothManager.md#bluetoothmanagerstopbluetoothdiscovery)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH @@ -506,8 +490,7 @@ setDevicePairingConfirmation(device: string, accept: boolean): boolean 设置设备配对请求确认。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.setDevicePairingConfirmation](js-apis-bluetoothManager.md#bluetoothmanagersetdevicepairingconfirmation)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.setDevicePairingConfirmation](js-apis-bluetoothManager.md#bluetoothmanagersetdevicepairingconfirmation)替代。 **需要权限**:ohos.permission.MANAGE_BLUETOOTH @@ -545,8 +528,7 @@ on(type: "bluetoothDeviceFind", callback: Callback<Array<string>>): 订阅蓝牙设备发现上报事件。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.on('bluetoothDeviceFind')](js-apis-bluetoothManager.md#bluetoothmanageronbluetoothdevicefind)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.on('bluetoothDeviceFind')](js-apis-bluetoothManager.md#bluetoothmanageronbluetoothdevicefind)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -580,8 +562,7 @@ off(type: "bluetoothDeviceFind", callback?: Callback<Array<string>>) 取消订阅蓝牙设备发现上报事件。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.off('bluetoothDeviceFind')](js-apis-bluetoothManager.md#bluetoothmanageroffbluetoothdevicefind)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.off('bluetoothDeviceFind')](js-apis-bluetoothManager.md#bluetoothmanageroffbluetoothdevicefind)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -616,8 +597,7 @@ on(type: "pinRequired", callback: Callback<PinRequiredParam>): void 订阅远端蓝牙设备的配对请求事件。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.on('pinRequired')](js-apis-bluetoothManager.md#bluetoothmanageronpinrequired)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.on('pinRequired')](js-apis-bluetoothManager.md#bluetoothmanageronpinrequired)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH @@ -651,8 +631,7 @@ off(type: "pinRequired", callback?: Callback<PinRequiredParam>): void 取消订阅远端蓝牙设备的配对请求事件。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.off('pinRequired')](js-apis-bluetoothManager.md#bluetoothmanageroffpinrequired)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.off('pinRequired')](js-apis-bluetoothManager.md#bluetoothmanageroffpinrequired)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH @@ -687,8 +666,7 @@ on(type: "bondStateChange", callback: Callback<BondStateParam>): void 订阅蓝牙配对状态改变事件。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.on('bondStateChange')](js-apis-bluetoothManager.md#bluetoothmanageronbondstatechange)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.on('bondStateChange')](js-apis-bluetoothManager.md#bluetoothmanageronbondstatechange)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -722,8 +700,7 @@ off(type: "bondStateChange", callback?: Callback<BondStateParam>): void 取消订阅蓝牙配对状态改变事件。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.off('bondStateChange')](js-apis-bluetoothManager.md#bluetoothmanageroffbondstatechange)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.off('bondStateChange')](js-apis-bluetoothManager.md#bluetoothmanageroffbondstatechange)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -758,8 +735,7 @@ on(type: "stateChange", callback: Callback<BluetoothState>): void 订阅蓝牙连接状态改变事件。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.on('stateChange')](js-apis-bluetoothManager.md#bluetoothmanageronstatechange)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.on('stateChange')](js-apis-bluetoothManager.md#bluetoothmanageronstatechange)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -793,8 +769,7 @@ off(type: "stateChange", callback?: Callback<BluetoothState>): void 取消订阅蓝牙连接状态改变事件。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.off('stateChange')](js-apis-bluetoothManager.md#bluetoothmanageroffstatechange)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.off('stateChange')](js-apis-bluetoothManager.md#bluetoothmanageroffstatechange)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -829,8 +804,7 @@ sppListen(name: string, option: SppOption, callback: AsyncCallback<number> 创建一个服务端监听Socket。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.sppListen](js-apis-bluetoothManager.md#bluetoothmanagerspplisten)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.sppListen](js-apis-bluetoothManager.md#bluetoothmanagerspplisten)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -868,8 +842,7 @@ sppAccept(serverSocket: number, callback: AsyncCallback<number>): void 服务端监听socket等待客户端连接。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.sppAccept](js-apis-bluetoothManager.md#bluetoothmanagersppaccept)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.sppAccept](js-apis-bluetoothManager.md#bluetoothmanagersppaccept)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -911,8 +884,7 @@ sppConnect(device: string, option: SppOption, callback: AsyncCallback<number& 客户端向远端设备发起spp连接。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.sppConnect](js-apis-bluetoothManager.md#bluetoothmanagersppconnect)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.sppConnect](js-apis-bluetoothManager.md#bluetoothmanagersppconnect)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -951,8 +923,7 @@ sppCloseServerSocket(socket: number): void 关闭服务端监听Socket,入参socket由sppListen接口返回。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.sppCloseServerSocket](js-apis-bluetoothManager.md#bluetoothmanagersppcloseserversocket)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.sppCloseServerSocket](js-apis-bluetoothManager.md#bluetoothmanagersppcloseserversocket)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -984,8 +955,7 @@ sppCloseClientSocket(socket: number): void 关闭客户端socket,入参socket由sppAccept或sppConnect接口获取。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.sppCloseClientSocket](js-apis-bluetoothManager.md#bluetoothmanagersppcloseclientsocket)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.sppCloseClientSocket](js-apis-bluetoothManager.md#bluetoothmanagersppcloseclientsocket)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1019,8 +989,7 @@ sppWrite(clientSocket: number, data: ArrayBuffer): boolean 通过socket向远端发送数据,入参clientSocket由sppAccept或sppConnect接口获取 。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.sppWrite](js-apis-bluetoothManager.md#bluetoothmanagersppwrite)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.sppWrite](js-apis-bluetoothManager.md#bluetoothmanagersppwrite)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1066,8 +1035,7 @@ if (ret) { on(type: "sppRead", clientSocket: number, callback: Callback<ArrayBuffer>): void > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.on('sppRead')](js-apis-bluetoothManager.md#bluetoothmanageronsppread)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.on('sppRead')](js-apis-bluetoothManager.md#bluetoothmanageronsppread)替代。 订阅spp读请求事件,入参clientSocket由sppAccept或sppConnect接口获取。 @@ -1112,8 +1080,7 @@ off(type: "sppRead", clientSocket: number, callback?: Callback<ArrayBuffer> 取消订阅spp读请求事件,入参clientSocket由sppAccept或sppConnect接口获取。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.off('sppRead')](js-apis-bluetoothManager.md#bluetoothmanageroffsppread)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.off('sppRead')](js-apis-bluetoothManager.md#bluetoothmanageroffsppread)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1152,8 +1119,7 @@ getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfi 通过ProfileId,获取profile的对象实例。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.getProfileInstance](js-apis-bluetoothManager.md#bluetoothmanagergetprofileinstance)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.getProfileInstance](js-apis-bluetoothManager.md#bluetoothmanagergetprofileinstance)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1185,8 +1151,7 @@ createGattServer(): GattServer 创建一个可使用的GattServer实例。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BLE.createGattServer](js-apis-bluetoothManager.md#bluetoothmanagerblecreategattserver)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BLE.createGattServer](js-apis-bluetoothManager.md#bluetoothmanagerblecreategattserver)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1210,8 +1175,7 @@ createGattClientDevice(deviceId: string): GattClientDevice 创建一个可使用的GattClientDevice实例。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BLE.createGattClientDevice](js-apis-bluetoothManager.md#bluetoothmanagerblecreategattclientdevice)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BLE.createGattClientDevice](js-apis-bluetoothManager.md#bluetoothmanagerblecreategattclientdevice)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1241,8 +1205,7 @@ getConnectedBLEDevices(): Array<string> 获取和当前设备连接的BLE设备。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BLE.getConnectedBLEDevices](js-apis-bluetoothManager.md#bluetoothmanagerblegetconnectedbledevices)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BLE.getConnectedBLEDevices](js-apis-bluetoothManager.md#bluetoothmanagerblegetconnectedbledevices)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -1268,8 +1231,7 @@ startBLEScan(filters: Array<ScanFilter>, options?: ScanOptions): void 发起BLE扫描流程。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BLE.startBLEScan](js-apis-bluetoothManager.md#bluetoothmanagerblestartblescan)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BLE.startBLEScan](js-apis-bluetoothManager.md#bluetoothmanagerblestartblescan)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH 和 ohos.permission.MANAGE_BLUETOOTH 和 ohos.permission.LOCATION @@ -1315,8 +1277,7 @@ stopBLEScan(): void 停止BLE扫描流程。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BLE.stopBLEScan](js-apis-bluetoothManager.md#bluetoothmanagerblestopblescan)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BLE.stopBLEScan](js-apis-bluetoothManager.md#bluetoothmanagerblestopblescan)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH @@ -1340,8 +1301,7 @@ on(type: "BLEDeviceFind", callback: Callback<Array<ScanResult>>): vo 订阅BLE设备发现上报事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BLE.on('BLEDeviceFind')](js-apis-bluetoothManager.md#bluetoothmanagerbleonbledevicefind)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BLE.on('BLEDeviceFind')](js-apis-bluetoothManager.md#bluetoothmanagerbleonbledevicefind)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -1375,8 +1335,7 @@ off(type: "BLEDeviceFind", callback?: Callback<Array<ScanResult>>): 取消订阅BLE设备发现上报事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BLE.off('BLEDeviceFind')](js-apis-bluetoothManager.md#bluetoothmanagerbleoffbledevicefind)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BLE.off('BLEDeviceFind')](js-apis-bluetoothManager.md#bluetoothmanagerbleoffbledevicefind)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -1416,8 +1375,7 @@ getConnectionDevices(): Array<string> 获取已连接设备列表。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BaseProfile.getConnectionDevices](js-apis-bluetoothManager.md#getconnectiondevices)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BaseProfile.getConnectionDevices](js-apis-bluetoothManager.md#getconnectiondevices)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -1443,8 +1401,7 @@ getDeviceState(device: string): ProfileConnectionState 获取设备profile的连接状态。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BaseProfile.getDeviceState](js-apis-bluetoothManager.md#getdevicestate)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BaseProfile.getDeviceState](js-apis-bluetoothManager.md#getdevicestate)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -1481,8 +1438,7 @@ connect(device: string): boolean 发起设备的A2dp服务连接请求。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.A2dpSourceProfile.connect](js-apis-bluetoothManager.md#connect)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.A2dpSourceProfile.connect](js-apis-bluetoothManager.md#connect)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH @@ -1515,8 +1471,7 @@ disconnect(device: string): boolean 断开设备的a2dp服务连接。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.A2dpSourceProfile.disconnect](js-apis-bluetoothManager.md#disconnect)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.A2dpSourceProfile.disconnect](js-apis-bluetoothManager.md#disconnect)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH @@ -1549,8 +1504,7 @@ on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#Stat 订阅a2dp连接状态变化事件。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.A2dpSourceProfile.on('connectionStateChange')](js-apis-bluetoothManager.md#onconnectionstatechange)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.A2dpSourceProfile.on('connectionStateChange')](js-apis-bluetoothManager.md#onconnectionstatechange)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1583,8 +1537,7 @@ off(type: "connectionStateChange", callback?: Callback<[StateChangeParam](#St 取消订阅a2dp连接状态变化事件。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.A2dpSourceProfile.off('connectionStateChange')](js-apis-bluetoothManager.md#offconnectionstatechange)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.A2dpSourceProfile.off('connectionStateChange')](js-apis-bluetoothManager.md#offconnectionstatechange)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1618,8 +1571,7 @@ getPlayingState(device: string): PlayingState 获取设备的播放状态。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.A2dpSourceProfile.getPlayingState](js-apis-bluetoothManager.md#getplayingstate)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.A2dpSourceProfile.getPlayingState](js-apis-bluetoothManager.md#getplayingstate)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1655,8 +1607,7 @@ connect(device: string): boolean 连接设备的HFP服务。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.HandsFreeAudioGatewayProfile.connect](js-apis-bluetoothManager.md#connect-1)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.HandsFreeAudioGatewayProfile.connect](js-apis-bluetoothManager.md#connect-1)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH @@ -1690,8 +1641,7 @@ disconnect(device: string): boolean 断开连接设备的HFP服务。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.HandsFreeAudioGatewayProfile.disconnect](js-apis-bluetoothManager.md#disconnect-1)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.HandsFreeAudioGatewayProfile.disconnect](js-apis-bluetoothManager.md#disconnect-1)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH @@ -1725,8 +1675,7 @@ on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#Stat 订阅HFP连接状态变化事件。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.HandsFreeAudioGatewayProfile.on('connectionStateChange')](js-apis-bluetoothManager.md#onconnectionstatechange-1)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.HandsFreeAudioGatewayProfile.on('connectionStateChange')](js-apis-bluetoothManager.md#onconnectionstatechange-1)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1760,8 +1709,7 @@ off(type: "connectionStateChange", callback?: Callback<[StateChangeParam](#St 取消订阅HFP连接状态变化事件。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.HandsFreeAudioGatewayProfile.off('connectionStateChange')](js-apis-bluetoothManager.md#offconnectionstatechange-1)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.HandsFreeAudioGatewayProfile.off('connectionStateChange')](js-apis-bluetoothManager.md#offconnectionstatechange-1)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1801,8 +1749,7 @@ startAdvertising(setting: AdvertiseSetting, advData: AdvertiseData, advResponse? 开始发送BLE广播。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.startAdvertising](js-apis-bluetoothManager.md#startadvertising)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.startAdvertising](js-apis-bluetoothManager.md#startadvertising)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH @@ -1872,8 +1819,7 @@ stopAdvertising(): void 停止发送BLE广播。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.stopAdvertising](js-apis-bluetoothManager.md#stopadvertising)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.stopAdvertising](js-apis-bluetoothManager.md#stopadvertising)替代。 **需要权限**:ohos.permission.DISCOVER_BLUETOOTH @@ -1898,8 +1844,7 @@ addService(service: GattService): boolean server端添加服务。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.addService](js-apis-bluetoothManager.md#addservice)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.addService](js-apis-bluetoothManager.md#addservice)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -1961,8 +1906,7 @@ removeService(serviceUuid: string): boolean 删除已添加的服务。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.removeService](js-apis-bluetoothManager.md#removeservice)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.removeService](js-apis-bluetoothManager.md#removeservice)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -1995,8 +1939,7 @@ close(): void 关闭服务端功能,去注册server在协议栈的注册,调用该接口后[GattServer](#gattserver)实例将不能再使用。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.close](js-apis-bluetoothManager.md#close)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.close](js-apis-bluetoothManager.md#close)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2017,8 +1960,7 @@ notifyCharacteristicChanged(deviceId: string, notifyCharacteristic: NotifyCharac server端特征值发生变化时,主动通知已连接的client设备。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.notifyCharacteristicChanged](js-apis-bluetoothManager.md#notifycharacteristicchanged)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.notifyCharacteristicChanged](js-apis-bluetoothManager.md#notifycharacteristicchanged)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2066,8 +2008,7 @@ sendResponse(serverResponse: ServerResponse): boolean server端回复client端的读写请求。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.sendResponse](js-apis-bluetoothManager.md#sendresponse)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.sendResponse](js-apis-bluetoothManager.md#sendresponse)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2117,8 +2058,7 @@ on(type: "characteristicRead", callback: Callback<CharacteristicReadReq>): server端订阅特征值读请求事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.on('characteristicRead')](js-apis-bluetoothManager.md#oncharacteristicread)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.on('characteristicRead')](js-apis-bluetoothManager.md#oncharacteristicread)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2169,8 +2109,7 @@ off(type: "characteristicRead", callback?: Callback<CharacteristicReadReq> server端取消订阅特征值读请求事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.off('characteristicRead')](js-apis-bluetoothManager.md#offcharacteristicread)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.off('characteristicRead')](js-apis-bluetoothManager.md#offcharacteristicread)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2202,8 +2141,7 @@ on(type: "characteristicWrite", callback: Callback<CharacteristicWriteReq> server端订阅特征值写请求事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.on('characteristicWrite')](js-apis-bluetoothManager.md#oncharacteristicwrite)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.on('characteristicWrite')](js-apis-bluetoothManager.md#oncharacteristicwrite)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2257,8 +2195,7 @@ off(type: "characteristicWrite", callback?: Callback<CharacteristicWriteReq&g server端取消订阅特征值写请求事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.off('characteristicWrite')](js-apis-bluetoothManager.md#offcharacteristicwrite)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.off('characteristicWrite')](js-apis-bluetoothManager.md#offcharacteristicwrite)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2290,8 +2227,7 @@ on(type: "descriptorRead", callback: Callback<DescriptorReadReq>): void server端订阅描述符读请求事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.on('descriptorRead')](js-apis-bluetoothManager.md#ondescriptorread)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.on('descriptorRead')](js-apis-bluetoothManager.md#ondescriptorread)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2342,8 +2278,7 @@ off(type: "descriptorRead", callback?: Callback<DescriptorReadReq>): void server端取消订阅描述符读请求事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.off('descriptorRead')](js-apis-bluetoothManager.md#offdescriptorread)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.off('descriptorRead')](js-apis-bluetoothManager.md#offdescriptorread)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2375,8 +2310,7 @@ on(type: "descriptorWrite", callback: Callback<DescriptorWriteReq>): void server端订阅描述符写请求事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.on('descriptorWrite')](js-apis-bluetoothManager.md#ondescriptorwrite)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.on('descriptorWrite')](js-apis-bluetoothManager.md#ondescriptorwrite)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2430,8 +2364,7 @@ off(type: "descriptorWrite", callback?: Callback<DescriptorWriteReq>): voi server端取消订阅描述符写请求事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.off('descriptorWrite')](js-apis-bluetoothManager.md#offdescriptorwrite)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.off('descriptorWrite')](js-apis-bluetoothManager.md#offdescriptorwrite)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2463,8 +2396,7 @@ on(type: "connectStateChange", callback: Callback<BLEConnectChangedState>) server端订阅BLE连接状态变化事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.on('connectStateChange')](js-apis-bluetoothManager.md#onconnectstatechange)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.on('connectStateChange')](js-apis-bluetoothManager.md#onconnectstatechange)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2501,8 +2433,7 @@ off(type: "connectStateChange", callback?: Callback<BLEConnectChangedState> server端取消订阅BLE连接状态变化事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattServer.off('connectStateChange')](js-apis-bluetoothManager.md#offconnectstatechange)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattServer.off('connectStateChange')](js-apis-bluetoothManager.md#offconnectstatechange)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2539,8 +2470,7 @@ connect(): boolean client端发起连接远端蓝牙低功耗设备。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.connect](js-apis-bluetoothManager.md#connect-3)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.connect](js-apis-bluetoothManager.md#connect-3)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2567,8 +2497,7 @@ disconnect(): boolean client端断开与远端蓝牙低功耗设备的连接。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.disconnect](js-apis-bluetoothManager.md#disconnect-4)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.disconnect](js-apis-bluetoothManager.md#disconnect-4)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2595,8 +2524,7 @@ close(): boolean 关闭客户端功能,注销client在协议栈的注册,调用该接口后[GattClientDevice](#gattclientdevice)实例将不能再使用。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.close](js-apis-bluetoothManager.md#close-1)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.close](js-apis-bluetoothManager.md#close-1)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2625,8 +2553,7 @@ getServices(callback: AsyncCallback<Array<GattService>>): void client端获取蓝牙低功耗设备的所有服务,即服务发现 。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.getServices](js-apis-bluetoothManager.md#getservices)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.getServices](js-apis-bluetoothManager.md#getservices)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2671,8 +2598,7 @@ getServices(): Promise<Array<GattService>> client端获取蓝牙低功耗设备的所有服务,即服务发现。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.getServices](js-apis-bluetoothManager.md#getservices-1)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.getServices](js-apis-bluetoothManager.md#getservices-1)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2703,8 +2629,7 @@ readCharacteristicValue(characteristic: BLECharacteristic, callback: AsyncCallba client端读取蓝牙低功耗设备特定服务的特征值。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.readCharacteristicValue](js-apis-bluetoothManager.md#readcharacteristicvalue)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.readCharacteristicValue](js-apis-bluetoothManager.md#readcharacteristicvalue)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2761,8 +2686,7 @@ readCharacteristicValue(characteristic: BLECharacteristic): Promise<BLECharac client端读取蓝牙低功耗设备特定服务的特征值。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.readCharacteristicValue](js-apis-bluetoothManager.md#readcharacteristicvalue-1)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.readCharacteristicValue](js-apis-bluetoothManager.md#readcharacteristicvalue-1)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2811,8 +2735,7 @@ readDescriptorValue(descriptor: BLEDescriptor, callback: AsyncCallback<BLEDes client端读取蓝牙低功耗设备特定的特征包含的描述符。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.readDescriptorValue](js-apis-bluetoothManager.md#readdescriptorvalue)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.readDescriptorValue](js-apis-bluetoothManager.md#readdescriptorvalue)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2859,8 +2782,7 @@ readDescriptorValue(descriptor: BLEDescriptor): Promise<BLEDescriptor> client端读取蓝牙低功耗设备特定的特征包含的描述符。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.readDescriptorValue](js-apis-bluetoothManager.md#readdescriptorvalue-1)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.readDescriptorValue](js-apis-bluetoothManager.md#readdescriptorvalue-1)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2899,8 +2821,7 @@ writeCharacteristicValue(characteristic: BLECharacteristic): boolean client端向低功耗蓝牙设备写入特定的特征值。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.writeCharacteristicValue](js-apis-bluetoothManager.md#writecharacteristicvalue)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.writeCharacteristicValue](js-apis-bluetoothManager.md#writecharacteristicvalue)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2953,8 +2874,7 @@ writeDescriptorValue(descriptor: BLEDescriptor): boolean client端向低功耗蓝牙设备特定的描述符写入二进制数据。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.writeDescriptorValue](js-apis-bluetoothManager.md#writedescriptorvalue)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.writeDescriptorValue](js-apis-bluetoothManager.md#writedescriptorvalue)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2998,8 +2918,7 @@ setBLEMtuSize(mtu: number): boolean client协商远端蓝牙低功耗设备的最大传输单元(Maximum Transmission Unit, MTU),调用[connect](#connect)接口连接成功后才能使用。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.setBLEMtuSize](js-apis-bluetoothManager.md#setblemtusize)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.setBLEMtuSize](js-apis-bluetoothManager.md#setblemtusize)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -3032,8 +2951,7 @@ setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolea 向服务端发送设置通知此特征值请求。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.setNotifyCharacteristicChanged](js-apis-bluetoothManager.md#setnotifycharacteristicchanged)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.setNotifyCharacteristicChanged](js-apis-bluetoothManager.md#setnotifycharacteristicchanged)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -3079,8 +2997,7 @@ on(type: "BLECharacteristicChange", callback: Callback<BLECharacteristic>) 订阅蓝牙低功耗设备的特征值变化事件。需要先调用setNotifyCharacteristicChanged接口才能接收server端的通知。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.on('BLECharacteristicChange')](js-apis-bluetoothManager.md#onblecharacteristicchange)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.on('BLECharacteristicChange')](js-apis-bluetoothManager.md#onblecharacteristicchange)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -3117,8 +3034,7 @@ off(type: "BLECharacteristicChange", callback?: Callback<BLECharacteristic> 取消订阅蓝牙低功耗设备的特征值变化事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.off('BLECharacteristicChange')](js-apis-bluetoothManager.md#offblecharacteristicchange)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.off('BLECharacteristicChange')](js-apis-bluetoothManager.md#offblecharacteristicchange)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -3150,8 +3066,7 @@ on(type: "BLEConnectionStateChange", callback: Callback<BLEConnectChangedStat client端订阅蓝牙低功耗设备的连接状态变化事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.on('BLEConnectionStateChange')](js-apis-bluetoothManager.md#onbleconnectionstatechange)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.on('BLEConnectionStateChange')](js-apis-bluetoothManager.md#onbleconnectionstatechange)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -3187,8 +3102,7 @@ off(type: "BLEConnectionStateChange", callback?: Callback<BLEConnectChangedSt 取消订阅蓝牙低功耗设备的连接状态变化事件。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.off('BLEConnectionStateChange')](js-apis-bluetoothManager.md#offbleconnectionstatechange)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.off('BLEConnectionStateChange')](js-apis-bluetoothManager.md#offbleconnectionstatechange)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -3220,8 +3134,7 @@ getDeviceName(callback: AsyncCallback<string>): void client获取远端蓝牙低功耗设备名。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.getDeviceName](js-apis-bluetoothManager.md#getdevicename)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.getDeviceName](js-apis-bluetoothManager.md#getdevicename)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -3256,8 +3169,7 @@ getDeviceName(): Promise<string> client获取远端蓝牙低功耗设备名。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.getDeviceName](js-apis-bluetoothManager.md#getdevicename-1)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.getDeviceName](js-apis-bluetoothManager.md#getdevicename-1)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -3288,8 +3200,7 @@ getRssiValue(callback: AsyncCallback<number>): void client获取远端蓝牙低功耗设备的信号强度 (Received Signal Strength Indication, RSSI),调用[connect](#connect)接口连接成功后才能使用。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.getRssiValue](js-apis-bluetoothManager.md#getrssivalue)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.getRssiValue](js-apis-bluetoothManager.md#getrssivalue)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -3325,8 +3236,7 @@ getRssiValue(): Promise<number> client获取远端蓝牙低功耗设备的信号强度 (Received Signal Strength Indication, RSSI),调用[connect](#connect)接口连接成功后才能使用。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattClientDevice.getRssiValue](js-apis-bluetoothManager.md#getrssivalue-1)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattClientDevice.getRssiValue](js-apis-bluetoothManager.md#getrssivalue-1)替代。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -3353,8 +3263,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 枚举,扫描模式。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.ScanMode](js-apis-bluetoothManager.md#scanmode)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.ScanMode](js-apis-bluetoothManager.md#scanmode)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3372,8 +3281,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 枚举,配对状态。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BondState](js-apis-bluetoothManager.md#bondstate)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BondState](js-apis-bluetoothManager.md#bondstate)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3389,8 +3297,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述spp的配置参数。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.SppOption](js-apis-bluetoothManager.md#sppoption)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.SppOption](js-apis-bluetoothManager.md#sppoption)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3406,8 +3313,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 枚举,Spp链路类型。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.SppType](js-apis-bluetoothManager.md#spptype)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.SppType](js-apis-bluetoothManager.md#spptype)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3421,8 +3327,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述service的接口参数定义。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.GattService](js-apis-bluetoothManager.md#gattservice)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.GattService](js-apis-bluetoothManager.md#gattservice)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3439,8 +3344,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述characteristic的接口参数定义 。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BLECharacteristic](js-apis-bluetoothManager.md#blecharacteristic)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BLECharacteristic](js-apis-bluetoothManager.md#blecharacteristic)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3457,8 +3361,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述descriptor的接口参数定义 。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BLEDescriptor](js-apis-bluetoothManager.md#bledescriptor)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BLEDescriptor](js-apis-bluetoothManager.md#bledescriptor)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3475,8 +3378,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述server端特征值变化时发送的特征通知参数定义。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.NotifyCharacteristic](js-apis-bluetoothManager.md#notifycharacteristic)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.NotifyCharacteristic](js-apis-bluetoothManager.md#notifycharacteristic)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3493,8 +3395,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述server端订阅后收到的特征值读请求事件参数结构。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.CharacteristicReadRequest](js-apis-bluetoothManager.md#characteristicreadrequest)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.CharacteristicReadRequest](js-apis-bluetoothManager.md#characteristicreadrequest)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3512,8 +3413,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述server端订阅后收到的特征值写请求事件参数结构。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.CharacteristicWriteRequest](js-apis-bluetoothManager.md#characteristicwriterequest)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.CharacteristicWriteRequest](js-apis-bluetoothManager.md#characteristicwriterequest)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3532,8 +3432,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述server端订阅后收到的描述符读请求事件参数结构。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.DescriptorReadRequest](js-apis-bluetoothManager.md#descriptorreadrequest)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.DescriptorReadRequest](js-apis-bluetoothManager.md#descriptorreadrequest)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3552,8 +3451,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述server端订阅后收到的描述符写请求事件参数结构。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.DescriptorWriteRequest](js-apis-bluetoothManager.md#descriptorwriterequest)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.DescriptorWriteRequest](js-apis-bluetoothManager.md#descriptorwriterequest)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3575,8 +3473,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述server端回复client端读/写请求的响应参数结构。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.ServerResponse](js-apis-bluetoothManager.md#serverresponse)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.ServerResponse](js-apis-bluetoothManager.md#serverresponse)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3594,8 +3491,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述Gatt profile连接状态 。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BLEConnectChangedState](js-apis-bluetoothManager.md#bleconnectchangedstate)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BLEConnectChangedState](js-apis-bluetoothManager.md#bleconnectchangedstate)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3610,8 +3506,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 枚举,蓝牙设备的profile连接状态。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.ProfileConnectionState](js-apis-bluetoothManager.md#profileconnectionstate)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.ProfileConnectionState](js-apis-bluetoothManager.md#profileconnectionstate)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3628,8 +3523,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 扫描过滤参数。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.ScanFilter](js-apis-bluetoothManager.md#scanfilter)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.ScanFilter](js-apis-bluetoothManager.md#scanfilter)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3645,8 +3539,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 扫描的配置参数。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.ScanOptions](js-apis-bluetoothManager.md#scanoptions)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.ScanOptions](js-apis-bluetoothManager.md#scanoptions)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3662,8 +3555,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 枚举,扫描模式。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.ScanDuty](js-apis-bluetoothManager.md#scanduty)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.ScanDuty](js-apis-bluetoothManager.md#scanduty)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3679,8 +3571,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 枚举,硬件过滤匹配模式。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.MatchMode](js-apis-bluetoothManager.md#matchmode)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.MatchMode](js-apis-bluetoothManager.md#matchmode)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3695,8 +3586,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 扫描结果上报数据。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.ScanResult](js-apis-bluetoothManager.md#scanresult)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.ScanResult](js-apis-bluetoothManager.md#scanresult)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3712,8 +3602,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 枚举,蓝牙开关状态。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BluetoothState](js-apis-bluetoothManager.md#bluetoothstate)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BluetoothState](js-apis-bluetoothManager.md#bluetoothstate)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3733,8 +3622,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述蓝牙低功耗设备发送广播的参数。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.AdvertiseSetting](js-apis-bluetoothManager.md#advertisesetting)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.AdvertiseSetting](js-apis-bluetoothManager.md#advertisesetting)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3750,8 +3638,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述BLE广播数据包的内容。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.AdvertiseData](js-apis-bluetoothManager.md#advertisedata)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.AdvertiseData](js-apis-bluetoothManager.md#advertisedata)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3767,8 +3654,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述BLE广播数据包的内容。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.ManufactureData](js-apis-bluetoothManager.md#manufacturedata)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.ManufactureData](js-apis-bluetoothManager.md#manufacturedata)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3783,8 +3669,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述广播包中服务数据内容。 > **说明:**
-> 从API version 7开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.ServiceData](js-apis-bluetoothManager.md#servicedata)替代。 +> 从API version 7开始支持,从API version 9开始废弃。建议使用[bluetoothManager.ServiceData](js-apis-bluetoothManager.md#servicedata)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3799,8 +3684,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述配对请求参数。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.PinRequiredParam](js-apis-bluetoothManager.md#pinrequiredparam)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.PinRequiredParam](js-apis-bluetoothManager.md#pinrequiredparam)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3815,8 +3699,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述配对状态参数。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.BondStateParam](js-apis-bluetoothManager.md#bondstateparam)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.BondStateParam](js-apis-bluetoothManager.md#bondstateparam)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3831,8 +3714,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述profile状态改变参数。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.StateChangeParam](js-apis-bluetoothManager.md#statechangeparam)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.StateChangeParam](js-apis-bluetoothManager.md#statechangeparam)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3847,8 +3729,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 描述蓝牙设备的类别。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.DeviceClass](js-apis-bluetoothManager.md#deviceclass)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.DeviceClass](js-apis-bluetoothManager.md#deviceclass)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3865,8 +3746,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 枚举,蓝牙设备主要类别。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.MajorClass](js-apis-bluetoothManager.md#majorclass)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.MajorClass](js-apis-bluetoothManager.md#majorclass)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3890,8 +3770,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 枚举,主要次要蓝牙设备类别。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.MajorMinorClass](js-apis-bluetoothManager.md#majorminorclass)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.MajorMinorClass](js-apis-bluetoothManager.md#majorminorclass)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3990,8 +3869,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 枚举,蓝牙A2DP 播放状态。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.PlayingState](js-apis-bluetoothManager.md#playingstate)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.PlayingState](js-apis-bluetoothManager.md#playingstate)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -4006,8 +3884,7 @@ let rssi = gattClient.getRssiValue().then((data) => { 蓝牙profile枚举,API9新增PROFILE_HID_HOST,PROFILE_PAN_NETWORK。 > **说明:**
-> 从API version 8开始支持。 -> 从API version 9开始废弃,建议使用[bluetoothManager.ProfileId](js-apis-bluetoothManager.md#profileid)替代。 +> 从API version 8开始支持,从API version 9开始废弃。建议使用[bluetoothManager.ProfileId](js-apis-bluetoothManager.md#profileid)替代。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-bluetoothManager.md b/zh-cn/application-dev/reference/apis/js-apis-bluetoothManager.md index 1386e7f32ab296447a7930bbfe583d1ac4afb3ec..673a90540c0f1e82f1787f2a566d132192b480e5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bluetoothManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bluetoothManager.md @@ -151,7 +151,7 @@ try { getBtConnectionState(): ProfileConnectionState -获取蓝牙设备的Profile连接状态。 +获取蓝牙本端的Profile连接状态,例如:任意一个支持的Profile连接状态为已连接,则此接口返回状态为已连接。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -263,7 +263,7 @@ try { getProfileConnectionState(profileId: ProfileId): ProfileConnectionState -获取profile的连接状态。 +依据ProfileId获取指定profile的连接状态。 **需要权限**:ohos.permission.USE_BLUETOOTH @@ -2333,17 +2333,6 @@ isTetheringOn(): boolean | --------------------- | --------------------------------- | | boolean | 网络共享开启返回true,网络共享关闭返回false。 | -**错误码**: - -以下错误码的详细介绍请参见[蓝牙服务子系统错误码](../errorcodes/errorcode-bluetoothManager.md)。 - -| 错误码ID | 错误信息 | -| -------- | ---------------------------- | -|2900001 | Service stopped. | -|2900003 | Bluetooth switch is off. | -|2900004 | Profile is not supported. | -|2900099 | Operation failed. | - **示例:** ```js @@ -3258,7 +3247,7 @@ client端读取蓝牙低功耗设备特定服务的特征值。 | 错误码ID | 错误信息 | | -------- | ---------------------------- | |2900001 | Service stopped. | -|2901000 | Read forbidden。 | +|2901000 | Read forbidden. | |2900099 | Operation failed. | **示例:** @@ -3327,7 +3316,7 @@ client端读取蓝牙低功耗设备特定服务的特征值。 | 错误码ID | 错误信息 | | -------- | ---------------------------- | |2900001 | Service stopped. | -|2901000 | Read forbidden。 | +|2901000 | Read forbidden. | |2900099 | Operation failed. | **示例:** @@ -3382,7 +3371,7 @@ client端读取蓝牙低功耗设备特定的特征包含的描述符。 | 错误码ID | 错误信息 | | -------- | ---------------------------- | |2900001 | Service stopped. | -|2901000 | Read forbidden。 | +|2901000 | Read forbidden. | |2900099 | Operation failed. | **示例:** @@ -3444,7 +3433,7 @@ client端读取蓝牙低功耗设备特定的特征包含的描述符。 | 错误码ID | 错误信息 | | -------- | ---------------------------- | |2900001 | Service stopped. | -|2901000 | Read forbidden。 | +|2901000 | Read forbidden. | |2900099 | Operation failed. | **示例:** @@ -3491,7 +3480,7 @@ client端向低功耗蓝牙设备写入特定的特征值。 | 错误码ID | 错误信息 | | -------- | ---------------------------- | |2900001 | Service stopped. | -|2901001 | Write forbidden。 | +|2901001 | Write forbidden. | |2900099 | Operation failed. | **示例:** @@ -3545,7 +3534,7 @@ client端向低功耗蓝牙设备特定的描述符写入二进制数据。 | 错误码ID | 错误信息 | | -------- | ---------------------------- | |2900001 | Service stopped. | -|2901001 | Write forbidden。 | +|2901001 | Write forbidden. | |2900099 | Operation failed. | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundleManager-BundlePackInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundleManager-BundlePackInfo.md index 553c6f0911813d730d625dd20b84f172f9de0ff8..ef3853d7c5c52ba7cf2f018cdae5482690ce6f8d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundleManager-BundlePackInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundleManager-BundlePackInfo.md @@ -62,10 +62,10 @@ | ------------------ | ------------------------------------------------- | ---- | ---- | ---------------------------------- | | mainAbility | string | 是 | 否 | 应用主ability的名称。 | | apiVersion | [ApiVersion](#apiversion) | 是 | 否 | module的api版本。 | -| deviceType | Array\ | 是 | 否 | module的设备类型。 | +| deviceTypes | Array\ | 是 | 否 | module的设备类型。 | | distro | [ModuleDistroInfo](#moduledistroinfo) | 是 | 否 | module发行版信息。 | | abilities | Array\<[ModuleAbilityInfo](#moduleabilityinfo)> | 是 | 否 | module包含的ability组件信息。 | -| extensionAbilities | Array\<[ExtensionAbilities](#extensionability)> | 是 | 否 | 描述extensionAbilities的配置信息。 | +| extensionAbilities | Array\<[ExtensionAbility](#extensionability)> | 是 | 否 | 描述extensionAbilities的配置信息。 | ## ModuleDistroInfo diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md index 9ac0871230226db8437ef0c34a495b1d0cac96a2..13b7c2e15489346fc2b37edbde593dce3260d6e5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md @@ -30,4 +30,5 @@ | descriptionResource | [Resource](js-apis-resource-manager.md#resource9) | 是 | 否 | 应用程序的描述资源信息,通过ApplicationInfo 获取的resource 包含了该资源的信息的bundleName、moduleName 和 id,可以调用全球化的接口[@ohos.resourceManager.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.resourceManager.d.ts)中的getMediaContent来获取详细的资源数据信息。| | appDistributionType | string | 是 | 否 | 应用程序签名证书的分发类型,分为:app_gallery、enterprise、os_integration和crowdtesting。 | | appProvisionType | string | 是 | 否 | 应用程序签名证书文件的类型,分为debug和release两种类型。 | -| systemApp | boolean | 是 | 否 | 标识应用是否为系统应用。 | \ No newline at end of file +| systemApp | boolean | 是 | 否 | 标识应用是否为系统应用。 | +| bundleType |[BundleType](js-apis-bundleManager.md#bundletype) | 是 | 否 | 标识包的类型,取值为APP(普通应用)或者ATOMIC_SERVICE(原子化服务)。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundleManager-hapModuleInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundleManager-hapModuleInfo.md index 3496e020162075029fec44755921de0c08229412..17e56fa5e5866454864b84e4c907f23016e0ce2a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundleManager-hapModuleInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundleManager-hapModuleInfo.md @@ -25,3 +25,28 @@ HAP信息,系统应用可以通过[bundleManager.getBundleInfo](js-apis-bundle | deviceTypes | Array\ | 是 | 否 | 可以运行模块的设备类型。 | | installationFree | boolean | 是 | 否 | 模块是否支持免安装。 | | hashValue | string | 是 | 否 | 模块的Hash值。 | +| moduleType | [ModuleType](js-apis-bundleManager.md#moduletype) | 是 | 否 | 标识当前模块的类型。 | +| preloads | Array\<[PreloadItem](#preloaditem)> | 是 | 否 | 原子化服务中模块的预加载列表。| +| dependencies | Array\<[Dependency](#dependency)> | 是 | 否 | 模块运行依赖的动态共享库列表。 | + +## PreloadItem + +描述原子化服务中模块的预加载模块信息。 + + **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | -------------- | ---- | ---- | --------------------------- | +|moduleName | string | 是 | 否 | 模块运行时,由系统自动执行预加载的模块名称。| + +## Dependency + +描述模块所依赖的动态共享库信息。 + + **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----------- | ------ | ---- | ---- | ---------------------- | +| bundleName | string | 是 | 否 | 标识当前模块依赖的共享包包名。 | +| moduleName | string | 是 | 否 | 标识当前模块依赖的共享包模块名。 | +| versionCode | number | 是 | 否 | 标识当前共享包的版本号。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md b/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md index fcdb34dd85b3477a2aaa70d8cc58bdc27b890207..81792364b3b24c0fe0dfe978025b425c4721cb89 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md @@ -186,6 +186,39 @@ Ability组件信息标志,指示需要获取的Ability组件信息的内容。 | AUTO_ROTATION_PORTRAIT_RESTRICTED |11|表示受开关控制的自动竖向旋转模式。| | LOCKED |12|表示锁定模式。| +### CompatiblePolicy + +标识共享库的版本兼容类型。 + + **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core + +| 名称 | 值 | 说明 | +| ---------------------- | ---- | -------------------------------- | +| BACKWARD_COMPATIBILITY | 1 | 该字段表明共享库是向后兼容类型。 | + +### ModuleType + +标识模块类型。 + + **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core + +| 名称 | 值 | 说明 | +| ------- | ---- | -------------------- | +| ENTRY | 1 | 应用的主模块。 | +| FEATURE | 2 | 应用的动态特性模块。 | +| SHARED | 3 | 应用的动态共享库模块。 | + +### BundleType + +标识应用的类型。 + + **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core + +| 名称 | 值 | 说明 | +| -------------- | ---- | --------------- | +| APP | 0 | 该Bundle是普通应用程序。 | +| ATOMIC_SERVICE | 1 | 该Bundle是原子化服务。 | + ## 接口 ### bundleManager.getBundleInfoForSelf @@ -501,7 +534,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use | 17700004 | The specified user ID is not found. | | 17700026 | The specified bundle is disabled. | -**示例:** +**示例:** ```ts import bundleManager from '@ohos.bundle.bundleManager'; @@ -1076,7 +1109,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: numb | 错误码ID | 错误信息 | | -------- | ------------------------------------- | | 17700001 | The specified bundleName is not found. | -| 17700003 | The specified extensionAbility is not found. | +| 17700003 | The specified ability is not found. | | 17700004 | The specified userId is invalid. | | 17700026 | The specified bundle is disabled. | | 17700029 | The specified ability is disabled. | @@ -2879,7 +2912,7 @@ getSharedBundleInfo(bundleName: string, moduleName: string, callback: AsyncCall | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 表示应用程序的bundleName。 | | moduleName | string | 是 | 表示被查询的module的name。 | -| callback | AsyncCallback\<[SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取的指定共享包信息。 | +| callback | AsyncCallback\\> | 是 | 回调函数,当获取成功时,err为null,data为获取的指定共享包信息。 | **错误码:** @@ -2934,7 +2967,7 @@ function getSharedBundleInfo(bundleName: string, moduleName: string): Promise\ | Promise对象,返回指定的共享包信息。 | +| Promise\\> | Promise对象,返回指定的共享包信息。 | **错误码:** @@ -3036,46 +3069,3 @@ try { } ``` -## CompatiblePolicy - -标识共享库的版本兼容类型。 - - **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core - -| 名称 | 值 | 说明 | -| ---------------------- | ---- | -------------------------------- | -| BACKWARD_COMPATIBILITY | 1 | 该字段表明共享库是向后兼容类型。 | - -## ModuleType - -标识模块类型。 - - **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core - -| 名称 | 值 | 说明 | -| ------- | ---- | -------------------- | -| ENTRY | 1 | 应用的主模块。 | -| FEATURE | 2 | 应用的动态特性模块。 | -| SHARED | 3 | 应用的动态共享库模块。 | - -## BundleType - -标识应用的类型。 - - **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core - -| 名称 | 值 | 说明 | -| -------------- | ---- | --------------- | -| APP | 0 | 该Bundle是普通应用程序。 | -| ATOMIC_SERVICE | 1 | 该Bundle是元服务。 | - -## AtomicServiceModuleType - -标识在元服务分包时的分包类型。 - - **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core - -| 名称 | 值 | 说明 | -| ------ | ---- | --------------------------- | -| NORMAL | 0 | 元服务中的页面包。 | -| MAIN | 1 | 元服务中的落地页包. | 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 eda0fa78007b61f5b33ee46a97686738dc87d65a..6bb1c12adf9393282450eb2a6ab2603d0d614db5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-call.md +++ b/zh-cn/application-dev/reference/apis/js-apis-call.md @@ -14,15 +14,13 @@ import call from '@ohos.telephony.call'; ``` -## call.dial(deprecated) +## call.dialCall9+ -dial\(phoneNumber: string, callback: AsyncCallback\): void +dialCall\(phoneNumber: string, callback: AsyncCallback\): void 拨打电话。使用callback异步回调。 ->**说明:** -> ->从API version 6 开始支持,从API version 9 开始废弃,建议使用[dialCall](#calldialcall9)替代。 +**系统接口:** 此接口为系统接口。 **需要权限**:ohos.permission.PLACE_CALL @@ -31,28 +29,39 @@ dial\(phoneNumber: string, callback: AsyncCallback\): void **参数:** | 参数名 | 类型 | 必填 | 说明 | -| ----------- | ---------------------------- | ---- | --------------------------------------- | +| ----------- | ---------------------------- | ---- | -------------------------------------- | | phoneNumber | string | 是 | 电话号码。 | -| callback | AsyncCallback<boolean> | 是 | 回调函数,返回true为成功,false为失败。 | +| callback | AsyncCallback<void> | 是 | 以callback形式异步返回拨打电话的结果。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + +| 错误码ID | 错误信息 | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | **示例:** ```js -call.dial("138xxxxxxxx", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.dialCall("138xxxxxxxx", (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` -## call.dial(deprecated) +## call.dialCall9+ -dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback\): void +dialCall\(phoneNumber: string, options: DialCallOptions, callback: AsyncCallback\): void 拨打电话,可设置通话参数。使用callback异步回调。 ->**说明:** -> ->从API version 6 开始支持,从API version 9 开始废弃,建议使用[dialCall](#calldialcall9)替代。 +**系统接口:** 此接口为系统接口。 **需要权限**:ohos.permission.PLACE_CALL @@ -60,32 +69,46 @@ dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.dialCall("138xxxxxxxx", { + accountId: 0, + videoState: 0, + dialScene: 0, + dialType: 0, +}, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` -## call.dial(deprecated) +## call.dialCall9+ -dial\(phoneNumber: string, options?: DialOptions\): Promise +dialCall\(phoneNumber: string, options?: DialCallOptions\): Promise 拨打电话,可设置通话参数。使用Promise异步回调。 ->**说明:** -> ->从API version 6 开始支持,从API version 9 开始废弃,建议使用[dialCall](#calldialcall9)替代。 +**系统接口:** 此接口为系统接口。 **需要权限**:ohos.permission.PLACE_CALL @@ -93,38 +116,55 @@ dial\(phoneNumber: string, options?: DialOptions\): Promise **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | -------------------------------------- | -| phoneNumber | string | 是 | 电话号码。 | -| options | [DialOptions](#dialoptions) | 否 | 通话参数,选择为语音通话还是视频通话。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ----------------------------------- | ---- | -------------------------------------- | +| phoneNumber | string | 是 | 电话号码。 | +| options | [DialCallOptions](#dialcalloptions9)| 否 | 通话参数,携带呼叫的其他配置信息。 | **返回值:** -| 类型 | 说明 | -| ---------------------- | ------------------------------------------------------------ | -| Promise<boolean> | 以Promise形式返回拨打电话的结果,返回true为成功,false为失败。 | +| 类型 | 说明 | +| ---------------------- | ---------------------------- | +| Promise<void> | 以Promise形式异步返回拨号结果。| + +**错误码:** + +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + +| 错误码ID | 错误信息 | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | **示例:** ```js -let promise = call.dial("138xxxxxxxx", { - extras: false +let promise = call.dialCall("138xxxxxxxx", { + accountId: 0, + videoState: 0, + dialScene: 0, + dialType: 0, }); -promise.then(data => { - console.log(`dial success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`dial fail, promise: err->${JSON.stringify(err)}`); +promise.then(() => { + console.log(`dialCall success.`); +}).catch((err) => { + console.error(`dialCall fail, promise: err->${JSON.stringify(err)}`); }); ``` +## call.dial(deprecated) -## call.dialCall9+ - -dialCall\(phoneNumber: string, callback: AsyncCallback\): void +dial\(phoneNumber: string, callback: AsyncCallback\): void 拨打电话。使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从API version 6 开始支持,从API version 9 开始废弃。请使用[dialCall](#calldialcall9)替代,替代接口能力仅对系统应用开放。 **需要权限**:ohos.permission.PLACE_CALL @@ -137,33 +177,24 @@ dialCall\(phoneNumber: string, callback: AsyncCallback\): void | phoneNumber | string | 是 | 电话号码。 | | callback | AsyncCallback<boolean> | 是 | 回调函数,返回true为成功,false为失败。 | -**错误码:** - -| 错误码ID | 错误信息 | -| -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | - **示例:** ```js -call.dialCall("138xxxxxxxx", (err, data) => { +call.dial("138xxxxxxxx", (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` -## call.dialCall9+ +## call.dial(deprecated) -dialCall\(phoneNumber: string, options: DialCallOptions, callback: AsyncCallback\): void +dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback\): void 拨打电话,可设置通话参数。使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从API version 6 开始支持,从API version 9 开始废弃。请使用[dialCall](#calldialcall9)替代,替代接口能力仅对系统应用开放。 **需要权限**:ohos.permission.PLACE_CALL @@ -171,44 +202,31 @@ dialCall\(phoneNumber: string, options: DialCallOptions, callback: AsyncCallback **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ----------------------------------- | ---- | ------------------------------------ | -| phoneNumber | string | 是 | 电话号码。 | -| options | [DialCallOptions](#dialcalloptions9)| 是 | 通话参数,携带呼叫的其他配置信息。 | -| callback | AsyncCallback<boolean> | 是 | 回调函数,返回true为成功,false为失败。 | - -**错误码:** - -| 错误码ID | 错误信息 | -| -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ---------------------------- | ---- | --------------------------------------- | +| phoneNumber | string | 是 | 电话号码。 | +| options | [DialOptions](#dialoptions) | 是 | 通话参数,选择为语音通话还是视频通话。 | +| callback | AsyncCallback<boolean> | 是 | 回调函数,返回true为成功,false为失败。 | **示例:** ```js -call.dialCall("138xxxxxxxx", { - accountId: 0, - videoState: 0, - dialScene: 0, - dialType: 0, +call.dial("138xxxxxxxx", { + extras: false }, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` +## call.dial(deprecated) -## call.dialCall9+ - -dialCall\(phoneNumber: string, options?: DialCallOptions\): Promise +dial\(phoneNumber: string, options?: DialOptions\): Promise 拨打电话,可设置通话参数。使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从API version 6 开始支持,从API version 9 开始废弃。请使用[dialCall](#calldialcall9)替代,替代接口能力仅对系统应用开放。 **需要权限**:ohos.permission.PLACE_CALL @@ -216,36 +234,30 @@ dialCall\(phoneNumber: string, options?: DialCallOptions\): Promise **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ----------------------------------- | ---- | -------------------------------------- | -| phoneNumber | string | 是 | 电话号码。 | -| options | [DialCallOptions](#dialcalloptions9)| 否 | 通话参数,选择为语音通话还是视频通话。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | -------------------------------------- | +| phoneNumber | string | 是 | 电话号码。 | +| options | [DialOptions](#dialoptions) | 否 | 通话参数,选择为语音通话还是视频通话。 | -**错误码:** +**返回值:** -| 错误码ID | 错误信息 | -| -------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | -| 8300002 | Operation failed. Cannot connect to service. | -| 8300003 | System internal error. | -| 8300999 | Unknown error code. | +| 类型 | 说明 | +| ---------------------- | ------------------------------------------------------------ | +| Promise<boolean> | 以Promise形式返回拨打电话的结果,返回true为成功,false为失败。 | **示例:** ```js -let promise = call.dialCall("138xxxxxxxx", { +let promise = call.dial("138xxxxxxxx", { extras: false }); promise.then(data => { - console.log(`dialCall success, promise: data->${JSON.stringify(data)}`); + console.log(`dial success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`dialCall fail, promise: err->${JSON.stringify(err)}`); + console.error(`dial fail, promise: err->${JSON.stringify(err)}`); }); ``` - ## call.makeCall7+ makeCall(phoneNumber: string, callback: AsyncCallback\): void @@ -263,6 +275,8 @@ makeCall(phoneNumber: string, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -302,6 +316,8 @@ makeCall(phoneNumber: string): Promise\ **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -454,6 +470,8 @@ isEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback\) **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -489,6 +507,8 @@ isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, ca **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -529,6 +549,8 @@ isEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\): **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -567,6 +589,8 @@ formatPhoneNumber\(phoneNumber: string, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -603,6 +627,8 @@ formatPhoneNumber\(phoneNumber: string, options: NumberFormatOptions, callback: **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -647,6 +673,8 @@ formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -688,6 +716,8 @@ formatPhoneNumberToE164\(phoneNumber: string, countryCode: string, callback: Asy **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -732,6 +762,8 @@ formatPhoneNumberToE164\(phoneNumber: string, countryCode: string\): Promise\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | +| 201 | Permission denied. | | 401 | Parameter error. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | @@ -782,8 +817,8 @@ muteRinger\(callback: AsyncCallback\): void **示例:** ```js -call.muteRinger((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.muteRinger((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -808,11 +843,11 @@ muteRinger\(\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | -| 401 | Parameter error. | -| 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | | 8300999 | Unknown error code. | @@ -820,10 +855,9 @@ muteRinger\(\): Promise **示例:** ```js -let promise = call.muteRinger(); -promise.then(data => { - console.log(`muteRinger success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.muteRinger().then(() => { + console.log(`muteRinger success.`); +}).catch((err) => { console.error(`muteRinger fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -850,6 +884,8 @@ answerCall\(callId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -862,8 +898,8 @@ answerCall\(callId: number, callback: AsyncCallback\): void **示例:** ```js -call.answerCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.answerCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -894,6 +930,8 @@ answerCall(callId?: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -906,10 +944,9 @@ answerCall(callId?: number\): Promise **示例:** ```js -let promise = call.answerCall(1); -promise.then(data => { - console.log(`answerCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.answerCall(1).then(() => { + console.log(`answerCall success.`); +}).catch((err) => { console.error(`answerCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -935,6 +972,8 @@ answerCall\(callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -947,8 +986,8 @@ answerCall\(callback: AsyncCallback\): void **示例:** ```js -call.answerCall((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.answerCall((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -974,6 +1013,8 @@ hangUpCall\(callId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -986,8 +1027,8 @@ hangUpCall\(callId: number, callback: AsyncCallback\): void **示例:** ```js -call.hangUpCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.hangUpCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1018,6 +1059,8 @@ hangUpCall\(callId?: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1030,10 +1073,9 @@ hangUpCall\(callId?: number\): Promise **示例:** ```js -let promise = call.hangUpCall(1); -promise.then(data => { - console.log(`hangUpCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.hangUpCall(1).then(() => { + console.log(`hangUpCall success.`); +}).catch((err) => { console.error(`hangUpCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1059,6 +1101,8 @@ hangUpCall\(callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1072,8 +1116,8 @@ hangUpCall\(callback: AsyncCallback\): void **示例:** ```js -call.hangUpCall((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.hangUpCall((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1099,6 +1143,8 @@ rejectCall(callId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1112,8 +1158,8 @@ rejectCall(callId: number, callback: AsyncCallback\): void **示例:** ```js -call.rejectCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.rejectCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1140,6 +1186,8 @@ rejectCall\(callId: number, options: RejectMessageOptions, callback: AsyncCallba **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1155,8 +1203,8 @@ rejectCall\(callId: number, options: RejectMessageOptions, callback: AsyncCallba let rejectMessageOptions={ messageContent: "拦截陌生号码" } -call.rejectCall(1, rejectMessageOptions, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.rejectCall(1, rejectMessageOptions, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1188,6 +1236,8 @@ rejectCall(callId?: number, options?: RejectMessageOptions\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1203,10 +1253,9 @@ rejectCall(callId?: number, options?: RejectMessageOptions\): Promise let rejectMessageOptions={ messageContent: "拦截陌生号码" } -let promise = call.reject(1, rejectMessageOptions); -promise.then(data => { - console.log(`reject success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.reject(1, rejectMessageOptions).then(() => { + console.log(`reject success.`); +}).catch((err) => { console.error(`reject fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1232,6 +1281,8 @@ rejectCall\(callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1244,8 +1295,8 @@ rejectCall\(callback: AsyncCallback\): void **示例:** ```js -call.rejectCall((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.rejectCall((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1271,6 +1322,8 @@ rejectCall\(options: RejectMessageOptions, callback: AsyncCallback\): voi **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1286,8 +1339,8 @@ rejectCall\(options: RejectMessageOptions, callback: AsyncCallback\): voi let rejectMessageOptions={ messageContent: "拦截陌生号码" } -call.rejectCall(rejectMessageOptions, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.rejectCall(rejectMessageOptions, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1313,6 +1366,8 @@ holdCall\(callId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1325,8 +1380,8 @@ holdCall\(callId: number, callback: AsyncCallback\): void **示例:** ```js -call.holdCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.holdCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1357,6 +1412,8 @@ holdCall\(callId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1369,10 +1426,9 @@ holdCall\(callId: number\): Promise **示例:** ```js -let promise = call.holdCall(1); -promise.then(data => { - console.log(`holdCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.holdCall(1).then(() => { + console.log(`holdCall success.`); +}).catch((err) => { console.error(`holdCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1398,6 +1454,8 @@ unHoldCall\(callId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1410,8 +1468,8 @@ unHoldCall\(callId: number, callback: AsyncCallback\): void **示例:** ```js -call.unHoldCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.unHoldCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1442,6 +1500,8 @@ unHoldCall\(callId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1454,10 +1514,9 @@ unHoldCall\(callId: number\): Promise **示例:** ```js -let promise = call.unHoldCall(1); -promise.then(data => { - console.log(`unHoldCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.unHoldCall(1).then(() => { + console.log(`unHoldCall success.`); +}).catch((err) => { console.error(`unHoldCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1483,6 +1542,8 @@ switchCall\(callId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1495,8 +1556,8 @@ switchCall\(callId: number, callback: AsyncCallback\): void **示例:** ```js -call.switchCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.switchCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1527,6 +1588,8 @@ switchCall\(callId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1539,10 +1602,9 @@ switchCall\(callId: number\): Promise **示例:** ```js -let promise = call.switchCall(1); -promise.then(data => { - console.log(`switchCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.switchCall(1).then(() => { + console.log(`switchCall success.`); +}).catch((err) => { console.error(`switchCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1566,6 +1628,8 @@ combineConference\(callId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1577,8 +1641,8 @@ combineConference\(callId: number, callback: AsyncCallback\): void **示例:** ```js -call.combineConference(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.combineConference(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1607,6 +1671,8 @@ combineConference\(callId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1618,10 +1684,9 @@ combineConference\(callId: number\): Promise **示例:** ```js -let promise = call.combineConference(1); -promise.then(data => { - console.log(`combineConference success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.combineConference(1).then(() => { + console.log(`combineConference success.`); +}).catch((err) => { console.error(`combineConference fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1645,6 +1710,8 @@ getMainCallId\(callId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1687,6 +1754,8 @@ getMainCallId\(callId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1725,6 +1794,8 @@ getSubCallIdList\(callId: number, callback: AsyncCallback\>\): vo **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1766,6 +1837,8 @@ getSubCallIdList\(callId: number\): Promise\> **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1804,6 +1877,8 @@ getCallIdListForConference\(callId: number, callback: AsyncCallback\> **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1885,6 +1962,8 @@ getCallWaitingStatus\(slotId: number, callback: AsyncCallback **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1971,6 +2052,8 @@ setCallWaiting\(slotId: number, activate: boolean, callback: AsyncCallback { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setCallWaiting(0, true, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2016,6 +2099,8 @@ setCallWaiting\(slotId: number, activate: boolean\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2028,10 +2113,9 @@ setCallWaiting\(slotId: number, activate: boolean\): Promise **示例:** ```js -let promise = call.setCallWaiting(0, true); -promise.then(data => { - console.log(`setCallWaiting success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.setCallWaiting(0, true).then(() => { + console.log(`setCallWaiting success.`); +}).catch((err) => { console.error(`setCallWaiting fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2056,6 +2140,8 @@ startDTMF\(callId: number, character: string, callback: AsyncCallback\): **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -2067,8 +2153,8 @@ startDTMF\(callId: number, character: string, callback: AsyncCallback\): **示例:** ```js -call.startDTMF(1, "0", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.startDTMF(1, "0", (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2098,6 +2184,8 @@ startDTMF\(callId: number, character: string\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -2109,10 +2197,9 @@ startDTMF\(callId: number, character: string\): Promise **示例:** ```js -let promise = call.startDTMF(1, "0"); -promise.then(data => { - console.log(`startDTMF success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.startDTMF(1, "0").then(() => { + console.log(`startDTMF success.`); +}).catch((err) => { console.error(`startDTMF fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2136,6 +2223,8 @@ stopDTMF\(callId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -2147,8 +2236,8 @@ stopDTMF\(callId: number, callback: AsyncCallback\): void **示例:** ```js -call.stopDTMF(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.stopDTMF(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2177,6 +2266,8 @@ stopDTMF\(callId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -2188,10 +2279,9 @@ stopDTMF\(callId: number\): Promise **示例:** ```js -let promise = call.stopDTMF(1); -promise.then(data => { - console.log(`stopDTMF success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.stopDTMF(1).then(() => { + console.log(`stopDTMF success.`); +}).catch((err) => { console.error(`stopDTMF fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2216,6 +2306,8 @@ isInEmergencyCall\(callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2254,6 +2346,8 @@ isInEmergencyCall\(\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2290,11 +2384,13 @@ on\(type: 'callDetailsChange', callback: Callback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------- | ---- | -------------------------- | -| type | string | 是 | 通话时监听通话详情的变化。 | -| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | 是 | 回调函数。 | +| type | string | 是 | 通话时监听通话详情的变化,参数固定为'callDetailsChange'。 | +| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | 是 | 回调函数。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2328,11 +2424,13 @@ on\(type: 'callEventChange', callback: Callback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------ | ---- | -------------------------- | -| type | string | 是 | 通话时监听通话事件的变化。 | +| type | string | 是 | 通话时监听通话事件的变化,参数固定为'callEventChange'。 | | callback | Callback<[CallEventOptions](#calleventoptions8)> | 是 | 回调函数。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2366,11 +2464,13 @@ on\(type: 'callDisconnectedCause', callback: Callback): vo | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------ | ---- | -------------------------- | -| type | string | 是 | 通话时监听断开连接的原因。 | +| type | string | 是 | 通话时监听断开连接的原因,参数固定为'callDisconnectedCause'。 | | callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | 是 | 回调函数。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2404,11 +2504,13 @@ on\(type: 'mmiCodeResult', callback: Callback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------- | ---- | --------------------- | -| type | string | 是 | 通话时监听MMI码结果。 | +| type | string | 是 | 通话时监听MMI码结果,参数固定为'mmiCodeResult'。 | | callback | Callback<[MmiCodeResults](#mmicoderesults9)> | 是 | 回调函数。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2442,11 +2544,13 @@ off\(type: 'callDetailsChange', callback?: Callback\): vo | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------------------- | ---- | ---------------------------------- | -| type | string | 是 | 通话结束时取消监听通话详情的变化。 | +| type | string | 是 | 通话结束时取消监听通话详情的变化,参数固定为'callDetailsChange'。 | | callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | 否 | 回调函数。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2480,11 +2584,13 @@ off\(type: 'callEventChange', callback?: Callback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------ | ---- | ---------------------------------- | -| type | string | 是 | 通话结束时取消监听通话事件的变化。 | +| type | string | 是 | 通话结束时取消监听通话事件的变化,参数固定为'callEventChange'。 | | callback | Callback<[CallEventOptions](#calleventoptions8)> | 否 | 回调函数。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2517,12 +2623,14 @@ off\(type: 'callDisconnectedCause', callback?: Callback\): **参数:** | 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------------------------- | ---- | -------------------- | -| type | 'callDisconnectedCause' | 是 | 调用断开连接的原因。 | -| callback | Callback**<**[DisconnectedDetails](#disconnecteddetails9)> | 否 | 回调函数。 | +| -------- | ---------------------------------------------------------- | ---- | ------------------- | +| type | string | 是 | 调用断开连接的原因,参数固定为'callDisconnectedCause'。 | +| callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | 否 | 回调函数。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2554,13 +2662,15 @@ off\(type: 'mmiCodeResult', callback?: Callback\): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------ | ---- | ----------- | -| type | 'mmiCodeResult' | 是 | MMI码结果。 | -| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | 否 | 回调函数。 | +| type | string | 是 | MMI码结果,参数固定为'mmiCodeResult'。 | +| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | 否 | 回调函数。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2596,6 +2706,8 @@ isNewCallAllowed\(callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -2631,6 +2743,8 @@ isNewCallAllowed\(\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -2669,6 +2783,8 @@ separateConference\(callId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -2680,8 +2796,8 @@ separateConference\(callId: number, callback: AsyncCallback\): void **示例:** ```js -call.separateConference(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.separateConference(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2710,6 +2826,8 @@ separateConference\(callId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -2721,10 +2839,9 @@ separateConference\(callId: number\): Promise **示例:** ```js -let promise = call.separateConference(1); -promise.then(data => { - console.log(`separateConference success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.separateConference(1).then(() => { + console.log(`separateConference success.`); +}).catch((err) => { console.error(`separateConference fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2751,6 +2868,8 @@ getCallRestrictionStatus\(slotId: number, type: CallRestrictionType, callback: A **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2796,6 +2915,8 @@ getCallRestrictionStatus\(slotId: number, type: CallRestrictionType\): Promise { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setCallRestriction(0, callRestrictionInfo, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2888,6 +3011,8 @@ setCallRestriction\(slotId: number, info: CallRestrictionInfo\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2905,10 +3030,9 @@ let callRestrictionInfo={ password: "123456", mode: 1 } -let promise = call.setCallRestriction(0, callRestrictionInfo); -promise.then(data => { - console.log(`setCallRestriction success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.setCallRestriction(0, callRestrictionInfo).then(() => { + console.log(`setCallRestriction success.`); +}).catch((err) => { console.error(`setCallRestriction fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2935,6 +3059,8 @@ getCallTransferInfo\(slotId: number, type: CallTransferType, callback: AsyncCall **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2980,6 +3106,8 @@ getCallTransferInfo\(slotId: number, type: CallTransferType): Promise { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setCallTransfer(0, callTransferInfo, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3072,6 +3202,8 @@ setCallTransfer\(slotId: number, info: CallTransferInfo): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -3089,10 +3221,9 @@ let callTransferInfo={ type: 1, settingType: 1 } -let promise = call.setCallTransfer(0, callTransferInfo); -promise.then(data => { - console.log(`setCallTransfer success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.setCallTransfer(0, callTransferInfo).then(() => { + console.log(`setCallTransfer success.`); +}).catch((err) => { console.error(`setCallTransfer fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3117,6 +3248,8 @@ isRinging\(callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -3155,6 +3288,8 @@ isRinging\(\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -3193,6 +3328,8 @@ setMuted\(callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -3204,8 +3341,8 @@ setMuted\(callback: AsyncCallback\): void **示例:** ```js -call.setMuted((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setMuted((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3228,6 +3365,8 @@ setMuted\(\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -3239,10 +3378,9 @@ setMuted\(\): Promise **示例:** ```js -let promise = call.setMuted(); -promise.then(data => { - console.log(`setMuted success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.setMuted().then(() => { + console.log(`setMuted success.`); +}).catch((err) => { console.error(`setMuted fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3265,6 +3403,8 @@ cancelMuted(callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -3276,8 +3416,8 @@ cancelMuted(callback: AsyncCallback): void **示例:** ```js -call.cancelMuted((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.cancelMuted((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3300,6 +3440,8 @@ cancelMuted(): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -3311,10 +3453,9 @@ cancelMuted(): Promise **示例:** ```js -let promise = call.cancelMuted(); -promise.then(data => { - console.log(`cancelMuted success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.cancelMuted().then(() => { + console.log(`cancelMuted success.`); +}).catch((err) => { console.error(`cancelMuted fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3338,6 +3479,8 @@ setAudioDevice\(device: AudioDevice, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -3349,8 +3492,8 @@ setAudioDevice\(device: AudioDevice, callback: AsyncCallback\): void **示例:** ```js -call.setAudioDevice(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setAudioDevice(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3375,6 +3518,8 @@ setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: Asyn **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -3389,8 +3534,8 @@ setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: Asyn let audioDeviceOptions={ bluetoothAddress: "IEEE 802-2014" } -call.setAudioDevice(1, audioDeviceOptions, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setAudioDevice(1, audioDeviceOptions, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3420,6 +3565,8 @@ setAudioDevice(device: AudioDevice, options?: AudioDeviceOptions): Promise { - console.log(`setAudioDevice success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.setAudioDevice(1, audioDeviceOptions).then(() => { + console.log(`setAudioDevice success.`); +}).catch((err) => { console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3462,6 +3608,8 @@ joinConference(mainCallId: number, callNumberList: Array, callback: Asy **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -3476,8 +3624,8 @@ joinConference(mainCallId: number, callNumberList: Array, callback: Asy let callNumberList: Array = [ "138XXXXXXXX" ]; -call.joinConference(1, callNumberList, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.joinConference(1, callNumberList, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3506,6 +3654,8 @@ joinConference(mainCallId: number, callNumberList: Array): Promise): Promise = [ "138XXXXXXXX" ]; -let promise = call.joinConference(1, callNumberList); -promise.then(data => { - console.log(`joinConference success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.joinConference(1, callNumberList).then(() => { + console.log(`joinConference success.`); +}).catch((err) => { console.error(`joinConference fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3548,6 +3697,8 @@ updateImsCallMode(callId: number, mode: ImsCallMode, callback: AsyncCallback { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.updateImsCallMode(1, 1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3589,6 +3740,8 @@ updateImsCallMode(callId: number, mode: ImsCallMode): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -3600,10 +3753,9 @@ updateImsCallMode(callId: number, mode: ImsCallMode): Promise **示例:** ```js -let promise = call.updateImsCallMode(1, 1); -promise.then(data => { - console.log(`updateImsCallMode success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.updateImsCallMode(1, 1).then(() => { + console.log(`updateImsCallMode success.`); +}).catch((err) => { console.error(`updateImsCallMode fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3629,6 +3781,8 @@ enableImsSwitch(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -3641,8 +3795,8 @@ enableImsSwitch(slotId: number, callback: AsyncCallback): void **示例:** ```js -call.enableImsSwitch(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.enableImsSwitch(0, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3672,6 +3826,8 @@ enableImsSwitch(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -3684,10 +3840,9 @@ enableImsSwitch(slotId: number): Promise **示例:** ```js -let promise = call.enableImsSwitch(0); -promise.then(data => { - console.log(`enableImsSwitch success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.enableImsSwitch(0).then(() => { + console.log(`enableImsSwitch success.`); +}).catch((err) => { console.error(`enableImsSwitch fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3713,6 +3868,8 @@ disableImsSwitch(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -3725,8 +3882,8 @@ disableImsSwitch(slotId: number, callback: AsyncCallback): void **示例:** ```js -call.disableImsSwitch(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.disableImsSwitch(0, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3744,19 +3901,21 @@ disableImsSwitch(slotId: number): Promise **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | +| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | **返回值:** -| 类型 | 说明 | +| 类型 | 说明 | | ------------------- | --------------------------- | -| Promise<void> | 以Promise形式异步返回结果。 | +| Promise<void> | 以Promise形式异步返回结果。 | **错误码:** -| 错误码ID | 错误信息 | +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + +| 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | | 401 | Parameter error. | @@ -3768,10 +3927,9 @@ disableImsSwitch(slotId: number): Promise **示例:** ```js -let promise = call.disableImsSwitch(0); -promise.then(data => { - console.log(`disableImsSwitch success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.disableImsSwitch(0).then(() => { + console.log(`disableImsSwitch success.`); +}).catch((err) => { console.error(`disableImsSwitch fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3795,6 +3953,8 @@ isImsSwitchEnabled(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -3835,6 +3995,8 @@ isImsSwitchEnabled(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | 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 9bb488cd0f25aa51bc4b9c220d21f4c82d70e082..38166decdca37fe86b80ab0190efea32f3ecae83 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-camera.md +++ b/zh-cn/application-dev/reference/apis/js-apis-camera.md @@ -31,6 +31,15 @@ getCameraManager(context: Context): CameraManager | ----------------------------------------------- | ---------------------------- | | [CameraManager](#cameramanager) | 相机管理器。 | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | +| 7400201 | Camera service fatal error. | + **示例:** ```js @@ -90,10 +99,10 @@ let cameraManager = camera.getCameraManager(context); | 名称 | 类型 | 必填 | 说明 | | ----------------------------- | -------------------------------------------------- | --- |------------------- | -| previewProfiles | Array<[Profile](#profile)\> | 是 | 支持的预览配置信息。 | -| photoProfiles | Array<[Profile](#profile)\> | 是 | 支持的拍照配置信息。 | -| videoProfiles | Array<[VideoProfile](#videoprofile)\> | 是 | 支持的录像配置信息。 | -| supportedMetadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | 是 | 支持的metadata流类型信息。| +| previewProfiles | Array\<[Profile](#profile)\> | 是 | 支持的预览配置信息。 | +| photoProfiles | Array\<[Profile](#profile)\> | 是 | 支持的拍照配置信息。 | +| videoProfiles | Array\<[VideoProfile](#videoprofile)\> | 是 | 支持的录像配置信息。 | +| supportedMetadataObjectTypes | Array\<[MetadataObjectType](#metadataobjecttype)\> | 是 | 支持的metadata流类型信息。| ## CameraErrorCode @@ -119,7 +128,7 @@ let cameraManager = camera.getCameraManager(context); ### getSupportedCameras -getSupportedCameras(): Array +getSupportedCameras(): Array\ 获取支持指定的相机设备对象,同步返回结果。 @@ -129,7 +138,7 @@ getSupportedCameras(): Array | 类型 | 说明 | | ----------------------------------------------- | ---------------------------- | -| Array<[CameraDevice](#cameradevice)> | 相机设备列表。 | +| Array\<[CameraDevice](#cameradevice)> | 相机设备列表。 | **示例:** @@ -140,7 +149,7 @@ let cameras = cameraManager.getSupportedCameras(); ### getSupportedOutputCapability -getSupportedOutputCapability(cameraDevice:CameraDevice): CameraOutputCapability +getSupportedOutputCapability(camera:CameraDevice): CameraOutputCapability 查询相机设备在模式下支持的输出能力,同步返回结果。 @@ -255,6 +264,14 @@ createCameraInput(camera: CameraDevice): CameraInput | ---------- | ----------------------------- | | [CameraInput](#camerainput) | CameraInput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | + **示例:** ```js @@ -291,6 +308,14 @@ createCameraInput(position: CameraPosition, type: CameraType): CameraInput | ---------- | ----------------------------- | | [CameraInput](#camerainput) | CameraInput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | + **示例:** ```js @@ -327,6 +352,14 @@ createPreviewOutput(profile: Profile, surfaceId: string): PreviewOutput | ---------- | ----------------------------- | | [PreviewOutput](#previewoutput) | PreviewOutput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | + **示例:** ```js @@ -361,6 +394,14 @@ createPhotoOutput(profile: Profile, surfaceId: string): PhotoOutput | ---------- | ----------------------------- | | [PhotoOutput](#photooutput) | PhotoOutput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | + **示例:** ```js @@ -395,6 +436,14 @@ createVideoOutput(profile: VideoProfile, surfaceId: string): VideoOutput | ---------- | ----------------------------- | | [VideoOutput](#videooutput) | VideoOutput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | + **示例:** ```js @@ -410,7 +459,7 @@ try { ### createMetadataOutput -createMetadataOutput(metadataObjectTypes:Array): MetadataOutput +createMetadataOutput(metadataObjectTypes:Array\): MetadataOutput 创建metadata流输出对象,同步返回结果。 @@ -420,7 +469,7 @@ createMetadataOutput(metadataObjectTypes:Array): MetadataOu | 参数名 | 类型 | 必填 | 说明 | | -------------------- | -------------------------------------------------- | --- | ---------------------------- | -| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | 是 | metadata流类型信息,通过getSupportedOutputCapability接口获取。 | +| metadataObjectTypes | Array\<[MetadataObjectType](#metadataobjecttype)\> | 是 | metadata流类型信息,通过getSupportedOutputCapability接口获取。 | **返回值:** @@ -428,6 +477,14 @@ createMetadataOutput(metadataObjectTypes:Array): MetadataOu | ---------- | ----------------------------- | | [MetadataOutput](#metadataoutput) | MetadataOutput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | + **示例:** ```js @@ -455,6 +512,14 @@ createCaptureSession(): CaptureSession | ---------- | ----------------------------- | | [CaptureSession](#capturesession) | CaptureSession实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | + **示例:** ```js @@ -469,7 +534,7 @@ try { ### on('cameraStatus') -on(type: 'cameraStatus', callback: AsyncCallback): void +on(type: 'cameraStatus', callback: AsyncCallback\): void 相机设备状态回调,通过注册回调函数获取相机的状态变化。 @@ -480,7 +545,7 @@ on(type: 'cameraStatus', callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -----------------| ---- | --------- | | type | string | 是 | 监听事件,固定为'cameraStatus'。cameraManager对象获取成功后可监听。目前只支持对设备打开或者关闭会触发该事件并返回对应信息 | -| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | 是 | 回调函数,用于获取镜头状态变化信息。 | | +| callback | AsyncCallback\<[CameraStatusInfo](#camerastatusinfo)\> | 是 | 回调函数,用于获取镜头状态变化信息。 | | **示例:** @@ -493,7 +558,7 @@ cameraManager.on('cameraStatus', (cameraStatusInfo) => { ### on('cameraMute') -on(type: 'cameraMute', callback: AsyncCallback): void +on(type: 'cameraMute', callback: AsyncCallback\): void 禁用回调,通过注册回调函数获取相机禁用状态变化。 @@ -618,7 +683,7 @@ cameraManager.on('cameraMute', (curMuetd) => { ### open -open\(callback: AsyncCallback\): void +open\(callback: AsyncCallback\\): void 打开相机,通过注册回调函数获取状态。 @@ -628,7 +693,17 @@ open\(callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400107 | Can not use camera cause of conflict. | +| 7400108 | Camera disabled cause of security reason. | +| 7400201 | Camera service fatal error. | **示例:** @@ -644,7 +719,7 @@ cameraInput.open((err) => { ### open -open(): Promise +open(): Promise\ 打开相机,通过Promise获取相机的状态。 @@ -654,7 +729,17 @@ open(): Promise | 类型 | 说明 | | -------------- | ----------------------- | -| Promise | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| Promise\ | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400107 | Can not use camera cause of conflict. | +| 7400108 | Camera disabled cause of security reason. | +| 7400201 | Camera service fatal error. | **示例:** @@ -668,7 +753,7 @@ cameraInput.open().then(() => { ### close -close\(callback: AsyncCallback\): void +close\(callback: AsyncCallback\\): void 关闭相机,通过注册回调函数获取状态。 @@ -678,7 +763,15 @@ close\(callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | -------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | **示例:** @@ -694,7 +787,7 @@ cameraInput.close((err) => { ### close -close(): Promise +close(): Promise\ 关闭相机,通过Promise获取状态。 @@ -704,7 +797,15 @@ close(): Promise | 类型 | 说明 | | -------------- | ----------------------- | -| Promise | 使用Promise的方式获取结果。 | +| Promise\ | 使用Promise的方式获取结果。 | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | **示例:** @@ -718,7 +819,7 @@ cameraInput.close().then(() => { ### on('error') -on(type: 'error', cameraDevice:CameraDevice, callback: ErrorCallback): void +on(type: 'error', camera:CameraDevice, callback: ErrorCallback\): void 监听CameraInput的错误事件,通过注册回调函数获取结果。 @@ -730,7 +831,7 @@ on(type: 'error', cameraDevice:CameraDevice, callback: ErrorCallback | 是 | 回调函数,用于获取结果。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | ErrorCallback\ | 是 | 回调函数,用于获取结果。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | **示例:** @@ -823,6 +924,14 @@ beginConfig(): void | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | 接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400105 | Session config locked. | + **示例:** ```js @@ -836,7 +945,7 @@ try { ### commitConfig -commitConfig(callback: AsyncCallback): void +commitConfig(callback: AsyncCallback\): void 提交配置信息,通过注册回调函数获取结果。 @@ -846,7 +955,16 @@ commitConfig(callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | -------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400102 | Operation not allow. | +| 7400201 | Camera service fatal error. | **示例:** @@ -862,7 +980,7 @@ captureSession.commitConfig((err) => { ### commitConfig -commitConfig(): Promise +commitConfig(): Promise\ 提交配置信息,通过Promise获取结果。 @@ -872,7 +990,16 @@ commitConfig(): Promise | 类型 | 说明 | | -------------- | ------------------------ | -| Promise | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| Promise\ | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400102 | Operation not allow. | +| 7400201 | Camera service fatal error. | **示例:** @@ -905,6 +1032,15 @@ addInput(cameraInput: CameraInput): void | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | 接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | +| 7400102 | Operation not allow. | + **示例:** ```js @@ -936,6 +1072,15 @@ removeInput(cameraInput: CameraInput): void | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | 接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | +| 7400102 | Operation not allow. | + **示例:** ```js @@ -949,7 +1094,7 @@ try { ### addOutput -addOutput(previewOutput: CameraOutput): void +addOutput(cameraOutput: CameraOutput): void 把[CameraOutput](#cameraoutput)加入到会话。 @@ -959,7 +1104,7 @@ addOutput(previewOutput: CameraOutput): void | 参数名 | 类型 | 必填 | 说明 | | ------------- | ------------------------------- | ---- | ------------------------ | -| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要添加的previewoutput实例。 | +| cameraOutput | [CameraOutput](#cameraoutput) | 是 | 需要添加的CameraOutput实例。 | **返回值:** @@ -967,11 +1112,20 @@ addOutput(previewOutput: CameraOutput): void | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | 接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | +| 7400102 | Operation not allow. | + **示例:** ```js try { - captureSession.addOutput(previewOutput); + captureSession.addOutput(cameraOutput); } catch (error) { // 失败返回错误码error.code并处理 console.log(error.code); @@ -980,7 +1134,7 @@ try { ### removeOutput -removeOutput(previewOutput: CameraOutput): void +removeOutput(cameraOutput: CameraOutput): void 从会话中移除[CameraOutput](#cameraoutput)。 @@ -990,7 +1144,7 @@ removeOutput(previewOutput: CameraOutput): void | 参数名 | 类型 | 必填 | 说明 | | ------------- | ------------------------------- | ---- | ------------------------ | -| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要移除的previewoutput实例。 | +| cameraOutput | [CameraOutput](#cameraoutput) | 是 | 需要移除的CameraOutput实例。 | **返回值:** @@ -998,6 +1152,15 @@ removeOutput(previewOutput: CameraOutput): void | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | 接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | +| 7400102 | Operation not allow. | + **示例:** ```js @@ -1011,7 +1174,7 @@ try { ### start -start\(callback: AsyncCallback\): void +start\(callback: AsyncCallback\\): void 开始会话工作,通过注册回调函数获取结果。 @@ -1021,7 +1184,16 @@ start\(callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | -------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | +| 7400201 | Camera service fatal error. | **示例:** @@ -1037,7 +1209,7 @@ captureSession.start((err) => { ### start -start\(\): Promise +start\(\): Promise\ 开始会话工作,通过Promise获取结果。 @@ -1047,7 +1219,16 @@ start\(\): Promise | 类型 | 说明 | | -------------- | ------------------------ | -| Promise | 使用Promise的方式获取结果。 | +| Promise\ | 使用Promise的方式获取结果。 | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | +| 7400201 | Camera service fatal error. | **示例:** @@ -1061,7 +1242,7 @@ captureSession.start().then(() => { ### stop -stop\(callback: AsyncCallback\): void +stop\(callback: AsyncCallback\\): void 停止会话工作,通过注册回调函数获取结果。 @@ -1071,7 +1252,15 @@ stop\(callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | **示例:** @@ -1087,7 +1276,7 @@ captureSession.stop((err) => { ### stop -stop(): Promise +stop(): Promise\ 停止会话工作,通过Promise获取结果。 @@ -1097,7 +1286,15 @@ stop(): Promise | 类型 | 说明 | | -------------- | ----------------------- | -| Promise | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| Promise\ | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | **示例:** @@ -1111,7 +1308,7 @@ captureSession.stop().then(() => { ### release -release\(callback: AsyncCallback\): void +release\(callback: AsyncCallback\\): void 释放会话资源,通过注册回调函数获取结果。 @@ -1121,7 +1318,15 @@ release\(callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | -------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | **示例:** @@ -1137,7 +1342,7 @@ captureSession.release((err) => { ### release -release(): Promise +release(): Promise\ 释放会话资源,通过Promise获取结果。 @@ -1147,7 +1352,15 @@ release(): Promise | 类型 | 说明 | | -------------- | ------------------------ | -| Promise | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| Promise\ | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | **示例:** @@ -1173,6 +1386,14 @@ hasFlash(): boolean | ---------- | ----------------------------- | | boolean | 返回true表示设备支持闪光灯。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1204,6 +1425,14 @@ isFlashModeSupported(flashMode: FlashMode): boolean | ---------- | ----------------------------- | | boolean | 返回true表示支持该闪光灯模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1240,6 +1469,14 @@ setFlashMode(flashMode: FlashMode): void | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | 接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1265,6 +1502,14 @@ getFlashMode(): FlashMode | ---------- | ----------------------------- | | [FlashMode](#flashmode) | 获取当前设备的闪光灯模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1296,6 +1541,14 @@ isExposureModeSupported(aeMode: ExposureMode): boolean; | ---------- | ----------------------------- | | boolean | 获取是否支持曝光模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1321,6 +1574,14 @@ getExposureMode(): ExposureMode | ---------- | ----------------------------- | | [ExposureMode](#exposuremode) | 获取当前曝光模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1352,6 +1613,14 @@ setExposureMode(aeMode: ExposureMode): void | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | 接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1377,6 +1646,14 @@ getMeteringPoint(): Point | ---------- | ----------------------------- | | [Point](#point) | 获取当前曝光点。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1411,6 +1688,14 @@ setMeteringPoint(point: Point): void | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | 接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1425,7 +1710,7 @@ try { ### getExposureBiasRange -getExposureBiasRange(): Array +getExposureBiasRange(): Array\ 查询曝光补偿范围。 @@ -1435,7 +1720,15 @@ getExposureBiasRange(): Array | 类型 | 说明 | | ---------- | ----------------------------- | -| Array | 获取补偿范围的数组。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| Array\ | 获取补偿范围的数组。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | **示例:** @@ -1464,6 +1757,14 @@ setExposureBias(exposureBias: number): void | -------- | -------------------------------| ---- | ------------------- | | exposureBias | number | 是 | 曝光补偿,getExposureBiasRange查询支持的范围,接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1490,6 +1791,14 @@ getExposureValue(): number | ---------- | ----------------------------- | | number | 获取曝光值。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1521,6 +1830,14 @@ isFocusModeSupported(afMode: FocusMode): boolean | ---------- | ----------------------------- | | boolean | 返回true表示支持该焦距模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1554,6 +1871,14 @@ setFocusMode(afMode: FocusMode): void | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | 接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1579,6 +1904,14 @@ getFocusMode(): FocusMode | ---------- | ----------------------------- | | [FocusMode](#focusmode) | 获取当前设备的焦距模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1613,6 +1946,14 @@ setFocusPoint(point: Point): void | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | 接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1639,6 +1980,14 @@ getFocusPoint(): Point | ---------- | ----------------------------- | | [Point](#point) | 用于获取当前焦点。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1664,6 +2013,14 @@ getFocalLength(): number | ---------- | ----------------------------- | | number | 用于获取当前焦距。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1677,7 +2034,7 @@ try { ### getZoomRatioRange -getZoomRatioRange(): Array +getZoomRatioRange(): Array\ 获取支持的变焦范围。 @@ -1687,7 +2044,15 @@ getZoomRatioRange(): Array | 类型 | 说明 | | ---------- | ----------------------------- | -| Array | 用于获取可变焦距比范围,返回的数组包括其最小值和最大值。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| Array\ | 用于获取可变焦距比范围,返回的数组包括其最小值和最大值。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | **示例:** @@ -1720,6 +2085,14 @@ setZoomRatio(zoomRatio: number): void | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | 接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1746,6 +2119,14 @@ getZoomRatio(): number | ---------- | ----------------------------- | | number | 获取当前的变焦比结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1777,6 +2158,14 @@ isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean | ---------- | ----------------------------- | | boolean | 返回视频防抖模式是否支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1802,6 +2191,14 @@ getActiveVideoStabilizationMode(): VideoStabilizationMode | ---------- | ----------------------------- | | VideoStabilizationMode | 视频防抖是否正在使用。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1833,6 +2230,14 @@ setVideoStabilizationMode(mode: VideoStabilizationMode): void | ---------- | ----------------------------- | | [CameraErrorCode](#cameraerrorcode) | 接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | + **示例:** ```js @@ -1846,7 +2251,7 @@ try { ### on('focusStateChange') -on(type: 'focusStateChange', callback: AsyncCallback): void +on(type: 'focusStateChange', callback: AsyncCallback\): void 监听相机聚焦的状态变化,通过注册回调函数获取结果。 @@ -1857,7 +2262,7 @@ on(type: 'focusStateChange', callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------- | ---- | ------------------------ | | type | string | 是 | 监听事件,固定为'focusStateChange',session 创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件 | -| callback | AsyncCallback<[FocusState](#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | +| callback | AsyncCallback\<[FocusState](#focusstate)\> | 是 | 回调函数,用于获取当前对焦状态。 | **示例:** @@ -1869,7 +2274,7 @@ captureSession.on('focusStateChange', (focusState) => { ### on('error') -on(type: 'error', callback: ErrorCallback): void +on(type: 'error', callback: ErrorCallback\): void 监听拍照会话的错误事件,通过注册回调函数获取结果。 @@ -1880,7 +2285,7 @@ on(type: 'error', callback: ErrorCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------------------------- | ---- | ------------------------------ | | type | string | 是 | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用(beginConfig(),commitConfig(),addInput)等接口发生错误时返回错误信息。 | -| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | ErrorCallback\ | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | **示例:** @@ -1900,7 +2305,7 @@ captureSession.on('error', (error) => { ### start -start(callback: AsyncCallback): void +start(callback: AsyncCallback\): void 开始输出预览流,通过注册回调函数获取结果。 @@ -1910,7 +2315,15 @@ start(callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | -------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | **示例:** @@ -1926,7 +2339,7 @@ previewOutput.start((err) => { ### start -start(): Promise +start(): Promise\ 开始输出预览流,通过Promise获取结果。 @@ -1936,7 +2349,15 @@ start(): Promise | 类型 | 说明 | | -------------- | ----------------------- | -| Promise | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)| +| Promise\ | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)| + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | **示例:** @@ -1950,7 +2371,7 @@ previewOutput.start().then(() => { ### stop -stop(callback: AsyncCallback): void +stop(callback: AsyncCallback\): void 停止输出预览流,通过注册回调函数获取结果。 @@ -1960,7 +2381,7 @@ stop(callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | -------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1976,7 +2397,7 @@ previewOutput.stop((err) => { ### stop -stop(): Promise +stop(): Promise\ 停止输出预览流,通过Promise获取结果。 @@ -1986,7 +2407,7 @@ stop(): Promise | 类型 | 说明 | | -------------- | ------------------------ | -| Promise | 使用Promise的方式获取结果。 | +| Promise\ | 使用Promise的方式获取结果。 | **示例:** @@ -2000,7 +2421,7 @@ previewOutput.stop().then(() => { ### release -release(callback: AsyncCallback): void +release(callback: AsyncCallback\): void 释放输出资源,通过注册回调函数获取结果。 @@ -2010,7 +2431,15 @@ release(callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | **示例:** @@ -2026,7 +2455,7 @@ previewOutput.release((err) => { ### release -release(): Promise +release(): Promise\ 释放输出资源,通过Promise获取结果。 @@ -2036,7 +2465,15 @@ release(): Promise | 类型 | 说明 | | -------------- | ----------------------- | -| Promise | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| Promise\ | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | **示例:** @@ -2050,7 +2487,7 @@ previewOutput.release().then(() => { ### on('frameStart') -on(type: 'frameStart', callback: AsyncCallback): void +on(type: 'frameStart', callback: AsyncCallback\): void 监听预览帧启动,通过注册回调函数获取结果。 @@ -2061,7 +2498,7 @@ on(type: 'frameStart', callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | --------------------------------------- | | type | string | 是 | 监听事件,固定为'frameStart',previewOutput创建成功可监听。底层第一次开始曝光时触发该事件并返回 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。只要有该事件返回就证明预览开始 | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。只要有该事件返回就证明预览开始 | **示例:** @@ -2073,7 +2510,7 @@ previewOutput.on('frameStart', () => { ### on('frameEnd') -on(type: 'frameEnd', callback: AsyncCallback): void +on(type: 'frameEnd', callback: AsyncCallback\): void 监听预览帧结束,通过注册回调函数获取结果。 @@ -2084,7 +2521,7 @@ on(type: 'frameEnd', callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------------------- | | type | string | 是 | 监听事件,固定为'frameEnd',previewOutput创建成功可监听。预览完全结束最后一帧时触发该事件并返回, | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。只要有该事件返回就证明预览结束 | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。只要有该事件返回就证明预览结束 | **示例:** @@ -2096,7 +2533,7 @@ previewOutput.on('frameEnd', () => { ### on('error') -on(type: 'error', callback: ErrorCallback): void +on(type: 'error', callback: ErrorCallback\): void 监听预览输出的错误事件,通过注册回调函数获取结果。 @@ -2107,7 +2544,7 @@ on(type: 'error', callback: ErrorCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------| ---- | ------------------------ | | type | string | 是 | 监听事件,固定为'error',previewOutput创建成功可监听。预览接口使用错误时触发该事件,比如调用(start(),release())等接口发生错误时返回对应错误信息。| -| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | ErrorCallback\ | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | **示例:** @@ -2174,7 +2611,7 @@ previewOutput.on('error', (previewOutputError) => { ### capture -capture(callback: AsyncCallback): void +capture(callback: AsyncCallback\): void 以默认设置触发一次拍照,通过注册回调函数获取结果。 @@ -2184,7 +2621,16 @@ capture(callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400104 | Session not running. | +| 7400201 | Camera service fatal error. | **示例:** @@ -2200,7 +2646,7 @@ photoOutput.capture((err) => { ### capture -capture(): Promise +capture(): Promise\ 以默认设置触发一次拍照,通过Promise获取结果。 @@ -2210,7 +2656,16 @@ capture(): Promise | 类型 | 说明 | | -------------- | ------------------------ | -| Promise | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| Promise\ | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400104 | Session not running. | +| 7400201 | Camera service fatal error. | **示例:** @@ -2224,7 +2679,7 @@ photoOutput.capture().then(() => { ### capture -capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void +capture(setting: PhotoCaptureSetting, callback: AsyncCallback\): void 以指定参数触发一次拍照,通过注册回调函数获取结果。 @@ -2235,7 +2690,17 @@ capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------- | ---- | -------------------- | | setting | [PhotoCaptureSetting](#photocapturesetting) | 是 | 拍照设置。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | +| 7400104 | Session not running. | +| 7400201 | Camera service fatal error. | **示例:** @@ -2262,7 +2727,7 @@ photoOutput.capture(settings, (err) => { ### capture -capture(setting?: PhotoCaptureSetting): Promise +capture(setting?: PhotoCaptureSetting): Promise\ 以指定参数触发一次拍照,通过Promise获取结果。 @@ -2278,8 +2743,17 @@ capture(setting?: PhotoCaptureSetting): Promise | 类型 | 说明 | | -------------- | ------------------------ | -| Promise | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| Promise\ | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400101 | Parameter missing or parameter type incorrect | +| 7400104 | Session not running. | +| 7400201 | Camera service fatal error. | **示例:** @@ -2313,7 +2787,7 @@ let isSupported = photoOutput.isMirrorSupported(); ### release -release(callback: AsyncCallback): void +release(callback: AsyncCallback\): void 释放输出资源,通过注册回调函数获取结果。 @@ -2323,7 +2797,15 @@ release(callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | **示例:** @@ -2339,7 +2821,7 @@ photoOutput.release((err) => { ### release -release(): Promise +release(): Promise\ 释放输出资源,通过Promise获取结果。 @@ -2349,7 +2831,15 @@ release(): Promise | 类型 | 说明 | | -------------- | ----------------------- | -| Promise | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| Promise\ | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | **示例:** @@ -2363,7 +2853,7 @@ photoOutput.release().then(() => { ### on('captureStart') -on(type: 'captureStart', callback: AsyncCallback): void +on(type: 'captureStart', callback: AsyncCallback\): void 监听拍照开始,通过注册回调函数获取Capture ID。 @@ -2374,7 +2864,7 @@ on(type: 'captureStart', callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ------------------------------------------ | | type | string | 是 | 监听事件,固定为'captureStart',photoOutput创建成功后可监听。每次拍照,底层开始曝光时触发该事件并返回。 | -| callback | AsyncCallback | 是 | 使用callback的方式获取Capture ID。 | +| callback | AsyncCallback\ | 是 | 使用callback的方式获取Capture ID。 | **示例:** @@ -2386,7 +2876,7 @@ photoOutput.on('captureStart', (captureId) => { ### on('frameShutter') -on(type: 'frameShutter', callback: AsyncCallback): void +on(type: 'frameShutter', callback: AsyncCallback\): void 监听拍照帧输出捕获,通过注册回调函数获取结果。 @@ -2397,7 +2887,7 @@ on(type: 'frameShutter', callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------- | --- | ------------------------------------ | | type | string | 是 | 监听事件,固定为'frameShutter',photoOutput创建成功后可监听。 | -| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | 是 | 回调函数,用于获取相关信息。该回调返回意味着可以再次下发拍照请求。 | +| callback | AsyncCallback\<[FrameShutterInfo](#frameshutterinfo)\> | 是 | 回调函数,用于获取相关信息。该回调返回意味着可以再次下发拍照请求。 | **示例:** @@ -2410,7 +2900,7 @@ photoOutput.on('frameShutter', (frameShutterInfo) => { ### on('captureEnd') -on(type: 'captureEnd', callback: AsyncCallback): void +on(type: 'captureEnd', callback: AsyncCallback\): void 监听拍照结束,通过注册回调函数获取结果。 @@ -2421,7 +2911,7 @@ on(type: 'captureEnd', callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------- | ---- | ---------------------------------------- | | type | string | 是 | 监听事件,固定为'captureEnd',photoOutput创建成功后可监听。拍照完全结束可触发该事件发生并返回相应信息。 | -| callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | 是 | 回调函数,用于获取相关信息。 | +| callback | AsyncCallback\<[CaptureEndInfo](#captureendinfo)\> | 是 | 回调函数,用于获取相关信息。 | **示例:** @@ -2434,7 +2924,7 @@ photoOutput.on('captureEnd', (captureEndInfo) => { ### on('error') -on(type: 'error', callback: ErrorCallback): void +on(type: 'error', callback: ErrorCallback\): void 监听拍照输出发生错误,通过注册回调函数获取结果。 @@ -2445,7 +2935,7 @@ on(type: 'error', callback: ErrorCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------- | ---- | ----------------------------------- | | type | string | 是 | 监听事件,固定为'error',photoOutput创建成功后可监听。拍照接口调用时出现错误触发该事件并返回错误信息。 | -| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | ErrorCallback\ | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | **示例:** @@ -2483,7 +2973,7 @@ photoOutput.on('error', (error) => { ### start -start(callback: AsyncCallback): void +start(callback: AsyncCallback\): void 启动录制,通过注册回调函数获取结果。 @@ -2493,7 +2983,16 @@ start(callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | -------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | +| 7400201 | Camera service fatal error. | **示例:** @@ -2509,7 +3008,7 @@ videoOutput.start((err) => { ### start -start(): Promise +start(): Promise\ 启动录制,通过Promise获取结果。 @@ -2519,8 +3018,16 @@ start(): Promise | 类型 | 说明 | | -------------- | ----------------------- | -| Promise | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| Promise\ | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | +| 7400201 | Camera service fatal error. | **示例:** @@ -2534,7 +3041,7 @@ videoOutput.start().then(() => { ### stop -stop(callback: AsyncCallback): void +stop(callback: AsyncCallback\): void 结束录制,通过注册回调函数获取结果。 @@ -2544,7 +3051,7 @@ stop(callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。 | **示例:** @@ -2560,7 +3067,7 @@ videoOutput.stop((err) => { ### stop -stop(): Promise +stop(): Promise\ 结束录制,通过Promise获取结果。 @@ -2570,7 +3077,7 @@ stop(): Promise | 类型 | 说明 | | -------------- | ----------------------- | -| Promise | 使用Promise的方式获取结果。 | +| Promise\ | 使用Promise的方式获取结果。 | **示例:** @@ -2584,7 +3091,7 @@ videoOutput.stop().then(() => { ### release -release(callback: AsyncCallback): void +release(callback: AsyncCallback\): void 释放输出资源,通过注册回调函数获取结果。 @@ -2594,7 +3101,15 @@ release(callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | **示例:** @@ -2610,7 +3125,7 @@ videoOutput.release((err) => { ### release -release(): Promise +release(): Promise\ 释放输出资源,通过Promise获取结果。 @@ -2620,7 +3135,15 @@ release(): Promise | 类型 | 说明 | | -------------- | ----------------------- | -| Promise | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| Promise\ | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400201 | Camera service fatal error. | **示例:** @@ -2634,7 +3157,7 @@ videoOutput.release().then(() => { ### on('frameStart') -on(type: 'frameStart', callback: AsyncCallback): void +on(type: 'frameStart', callback: AsyncCallback\): void 监听录像开始,通过注册回调函数获取结果。 @@ -2645,7 +3168,7 @@ on(type: 'frameStart', callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ----------------------------------------- | | type | string | 是 | 监听事件,固定为'frameStart',videoOutput创建成功后可监听。底层第一次曝光时触发该事件并返回。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 只要有该事件返回就证明录像开始 | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。 只要有该事件返回就证明录像开始 | **示例:** @@ -2657,7 +3180,7 @@ videoOutput.on('frameStart', () => { ### on('frameEnd') -on(type: 'frameEnd', callback: AsyncCallback): void +on(type: 'frameEnd', callback: AsyncCallback\): void 监听录像结束,通过注册回调函数获取结果。 @@ -2668,7 +3191,7 @@ on(type: 'frameEnd', callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------------------------ | | type | string | 是 | 监听事件,固定为'frameEnd',videoOutput创建成功后可监听。录像完全结束最后一帧时触发该事件并返回 。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 只要有该事件返回就证明录像结束 | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。 只要有该事件返回就证明录像结束 | **示例:** @@ -2680,7 +3203,7 @@ videoOutput.on('frameEnd', () => { ### on('error') -on(type: 'error', callback: ErrorCallback): void +on(type: 'error', callback: ErrorCallback\): void 监听录像输出发生错误,通过注册回调函数获取结果。 @@ -2691,7 +3214,7 @@ on(type: 'error', callback: ErrorCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------- | ---- | -------------------------------------- | | type | string | 是 | 监听事件,固定为'error',videoOutput创建成功后可监听。录像接口调用出现错误时触发该事件并返回对应错误码,比如调用(start(),release())接口时出现错误返回对应错误信息。 | -| callback | Callback | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | Callback\ | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | **示例:** @@ -2707,7 +3230,7 @@ metadata流。继承[CameraOutput](#cameraoutput) ### start -start(callback: AsyncCallback): void +start(callback: AsyncCallback\): void 开始输出metadata,通过注册回调函数获取结果。 @@ -2717,7 +3240,16 @@ start(callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------- | ---- | ------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | +| 7400201 | Camera service fatal error. | **示例:** @@ -2733,7 +3265,7 @@ metadataOutput.start((err) => { ### start -start(): Promise +start(): Promise\ 开始输出metadata,通过Promise获取结果。 @@ -2743,7 +3275,16 @@ start(): Promise | 类型 | 说明 | | ---------------------- | ------------------------ | -| Promise | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| Promise\ | 使用Promise的方式获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | + +**错误码:** + +以下错误码的详细介绍请参见相机错误码 + +| 错误码ID | 错误信息 | +| --------------- | --------------- | +| 7400103 | Session not config. | +| 7400201 | Camera service fatal error. | **示例:** @@ -2757,7 +3298,7 @@ metadataOutput.start().then(() => { ### stop -stop(callback: AsyncCallback): void +stop(callback: AsyncCallback\): void 停止输出metadata,通过注册回调函数获取结果。 @@ -2767,7 +3308,7 @@ stop(callback: AsyncCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------- | ---- | ------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| callback | AsyncCallback\ | 是 | 回调函数,用于获取结果。 | **示例:** @@ -2783,7 +3324,7 @@ metadataOutput.stop((err) => { ### stop -stop(): Promise +stop(): Promise\ 停止输出metadata,通过Promise获取结果。 @@ -2793,7 +3334,7 @@ stop(): Promise | 类型 | 说明 | | ---------------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | +| Promise\ | 使用Promise的方式获取结果。 | **示例:** @@ -2807,7 +3348,7 @@ metadataOutput.stop().then(() => { ### on('metadataObjectsAvailable') -on(type: 'metadataObjectsAvailable', callback: AsyncCallback\>): void +on(type: 'metadataObjectsAvailable', callback: AsyncCallback\\>): void 监听检测到的metadata对象,通过注册回调函数获取结果。 @@ -2818,7 +3359,7 @@ on(type: 'metadataObjectsAvailable', callback: AsyncCallback\> | 是 | 回调函数,用于获取metadata数据。 | +| callback | Callback\\> | 是 | 回调函数,用于获取metadata数据。 | **示例:** @@ -2830,7 +3371,7 @@ metadataOutput.on('metadataObjectsAvailable', (metadataObjectArr) => { ### on('error') -on(type: 'error', callback: ErrorCallback): void +on(type: 'error', callback: ErrorCallback\): void 监听metadata流的错误,通过注册回调函数获取结果。 @@ -2841,7 +3382,7 @@ on(type: 'error', callback: ErrorCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------- | ---- | --------------------------------------- | | type | string | 是 | 监听事件,固定为'error',metadataOutput创建成功后可监听。metadata接口使用错误时触发该事件并返回对应错误码,比如调用(start(),release())接口时发生错误返回对应错误信息。 | -| callback | Callback | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | +| callback | Callback\ | 是 | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | **示例:** @@ -2878,6 +3419,8 @@ metadataOutput.on('error', (metadataOutputError) => { 相机元能力信息,[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.on('metadataObjectsAvailable')接口获取 +**系统能力:** SystemCapability.Multimedia.Camera.Core + | 名称 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | -----------------| | type | [MetadataObjectType](#metadataobjecttype) | 否 | metadata 类型,目前只有人脸识别。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-contact.md b/zh-cn/application-dev/reference/apis/js-apis-contact.md index 2b5bd4d18cf77bb4846081db199fab89cfe2603b..89ce7fd4540d84e2c5852d7b0ace78963fc6a30c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-contact.md +++ b/zh-cn/application-dev/reference/apis/js-apis-contact.md @@ -488,8 +488,6 @@ selectContact(callback: AsyncCallback<Array<Contact>>): void 选择联系人,使用callback方式作为异步方法。 -**需要权限**:ohos.permission.READ_CONTACTS - **系统能力**:SystemCapability.Applications.Contacts **参数:** @@ -517,8 +515,6 @@ selectContact(): Promise<Array<Contact>> 选择联系人,使用Promise方式作为异步方法。 -**需要权限**:ohos.permission.READ_CONTACTS - **系统能力**:SystemCapability.Applications.Contacts **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-curve.md b/zh-cn/application-dev/reference/apis/js-apis-curve.md index f3892ab6da6ca22906ad5e02042b358c7cb2d179..834ff5f9bcddbcf774371f593e1fcd2934bc4202 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-curve.md +++ b/zh-cn/application-dev/reference/apis/js-apis-curve.md @@ -35,7 +35,6 @@ initCurve(curve?: Curve):ICurve | ---------------------------------- | ---------------- | | [ICurve](#icurve) | 曲线的插值对象。 | - **示例:** ```ts @@ -57,7 +56,7 @@ stepsCurve(count: number, end: boolean):ICurve | 参数名 | 类型 | 必填 | 说明 | | ------ | ------- | ----| ------------------------------------------------------------ | -| count | number | 是 | 阶梯的数量,需要为正整数。 | +| count | number | 是 | 阶梯的数量,需要为正整数。
取值范围:[0, +∞)
**说明:**
设置小于0的值时,按值为0处理。 | | end | boolean | 是 | 在每个间隔的起点或是终点发生阶跃变化。
-true:在终点发生阶跃变化。
-false:在起点发生阶跃变化。 | **返回值:** @@ -66,7 +65,6 @@ stepsCurve(count: number, end: boolean):ICurve | ---------------------------------- | ---------------- | | [ICurve](#icurve) | 曲线的插值对象。 | - **示例:** ```ts @@ -85,12 +83,13 @@ cubicBezierCurve(x1: number, y1: number, x2: number, y2: number):ICurve **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | -------------- | -| x1 | number | 是 | 确定贝塞尔曲线第一点横坐标。 | -| y1 | number | 是 | 确定贝塞尔曲线第一点纵坐标。 | -| x2 | number | 是 | 确定贝塞尔曲线第二点横坐标。 | -| y2 | number | 是 | 确定贝塞尔曲线第二点纵坐标。 | + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| x1 | number | 是 | 确定贝塞尔曲线第一点横坐标。
取值范围:[0, 1]
**说明:**
设置的值小于0时,按0处理;设置的值大于1时,按1处理。 | +| y1 | number | 是 | 确定贝塞尔曲线第一点纵坐标。
取值范围:(-∞, +∞) | +| x2 | number | 是 | 确定贝塞尔曲线第二点横坐标。
取值范围:[0, 1]
**说明:**
设置的值小于0时,按0处理;设置的值大于1时,按1处理。 | +| y2 | number | 是 | 确定贝塞尔曲线第二点纵坐标。
取值范围:(-∞, +∞) | **返回值:** @@ -112,17 +111,17 @@ Curves.cubicBezierCurve(0.1, 0.0, 0.1, 1.0) // 创建一个三阶贝塞尔曲线 springCurve(velocity: number, mass: number, stiffness: number, damping: number):ICurve -构造弹簧曲线对象。 +构造弹簧曲线对象,曲线形状由弹簧参数决定,动画时长受animation、animateTo中的duration参数控制。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | ----- | -| velocity | number | 是 | 初始速度。是由外部因素对弹性动效产生的影响参数,其目的是保证对象从之前的运动状态平滑的过渡到弹性动效。 | -| mass | number | 是 | 质量。弹性系统的受力对象,会对弹性系统产生惯性影响。质量越大,震荡的幅度越大,恢复到平衡位置的速度越慢。 | -| stiffness | number | 是 | 刚度。是物体抵抗施加的力而形变的程度。在弹性系统中,刚度越大,抵抗变形的能力越强,恢复到平衡位置的速度就越快。 | -| damping | number | 是 | 阻尼。是一个纯数,无真实的物理意义,用于描述系统在受到扰动后震荡及衰减的情形。阻尼越大,弹性运动的震荡次数越少、震荡幅度越小。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ------------------------------------------------------------ | +| velocity | number | 是 | 初始速度。是由外部因素对弹性动效产生的影响参数,其目的是保证对象从之前的运动状态平滑的过渡到弹性动效。
取值范围:(-∞, +∞) | +| mass | number | 是 | 质量。弹性系统的受力对象,会对弹性系统产生惯性影响。质量越大,震荡的幅度越大,恢复到平衡位置的速度越慢。
取值范围:(0, +∞)
**说明:**
设置的值小于0时,按1处理。 | +| stiffness | number | 是 | 刚度。是物体抵抗施加的力而形变的程度。在弹性系统中,刚度越大,抵抗变形的能力越强,恢复到平衡位置的速度就越快。
取值范围:(0, +∞)
**说明:**
设置的值小于0时,按1处理。 | +| damping | number | 是 | 阻尼。是一个纯数,无真实的物理意义,用于描述系统在受到扰动后震荡及衰减的情形。阻尼越大,弹性运动的震荡次数越少、震荡幅度越小。
取值范围:(0, +∞)
**说明:**
设置的值小于0时,按1处理。 | **返回值:** @@ -149,18 +148,19 @@ springMotion(response?: number, dampingFraction?: number, overlapDuration?: numb **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | ----- | -| response | number | 否 | 弹簧自然振动周期,决定弹簧复位的速度。单位:秒,默认值:0.55。 | -| dampingFraction | number | 否 | 阻尼系数。
0表示无阻尼,一直处于震荡状态;
大于0小于1的值为欠阻尼,运动过程中会超出目标值;
等于1为临界阻尼;
大于1为过阻尼,运动过程中逐渐趋于目标值。
默认值:0.825。 | -| overlapDuration | number | 否 | 弹性动画衔接时长。发生动画继承时,如果前后两个弹性动画response不一致,response参数会在overlapDuration时间内平滑过渡。单位:秒,默认值:0。 | +| response | number | 否 | 弹簧自然振动周期,决定弹簧复位的速度。
默认值:0.55
单位:秒
取值范围:[0, +∞)
**说明:**
设置小于0的值时,按默认值0.55处理。 | +| dampingFraction | number | 否 | 阻尼系数。
0表示无阻尼,一直处于震荡状态;
大于0小于1的值为欠阻尼,运动过程中会超出目标值;
等于1为临界阻尼;
大于1为过阻尼,运动过程中逐渐趋于目标值。
默认值:0.825
单位:秒
取值范围:[0, +∞)
**说明:**
设置小于0的值时,按默认值0.55处理。 | +| overlapDuration | number | 否 | 弹性动画衔接时长。发生动画继承时,如果前后两个弹性动画response不一致,response参数会在overlapDuration时间内平滑过渡。
默认值:0
单位:秒
取值范围:[0, +∞)。
**说明:**
设置小于0的值时,按默认值0处理。
弹性动画曲线为物理曲线,[animation](../arkui-ts/ts-animatorproperty.md)、[animateTo](../arkui-ts/ts-explicit-animation.md)中的duration参数不生效,动画持续时间取决于springMotion动画曲线参数和之前的速度。时间不能归一,故不能通过该曲线的interpolate函数获得插值。 | **返回值:** | 类型 | 说明 | | ---------------------------------- | ---------------- | -| [ICurve](#icurve)| 曲线对象。
**说明:** 弹性动画曲线为物理曲线,animation、animateTo中的duration参数不生效,动画持续时间取决于springMotion动画曲线参数和之前的速度。时间不能归一,故不能通过该曲线的[interpolate](#interpolate)函数获得插值。 | +| [ICurve](#icurve)| 曲线对象。
**说明:** 弹性动画曲线为物理曲线,[animation](../arkui-ts/ts-animatorproperty.md)、[animateTo](../arkui-ts/ts-explicit-animation.md)中的duration参数不生效,动画持续时间取决于springMotion动画曲线参数和之前的速度。时间不能归一,故不能通过该曲线的[interpolate](#interpolate)函数获得插值。 | **示例:** @@ -182,17 +182,18 @@ responsiveSpringMotion(response?: number, dampingFraction?: number, overlapDurat **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | ----- | -| response | number | 否 | 解释同springMotion中的response。单位:秒,默认值:0.15。 | -| dampingFraction | number | 否 | 解释同springMotion中的dampingFraction。默认值:0.86。 | -| overlapDuration | number | 否 | 解释同springMotion中的overlapDuration。单位:秒,默认值:0.25。 | +| response | number | 否 | 解释同springMotion中的response。
默认值:0.15
单位:秒
取值范围:[0, +∞)
**说明:**
设置小于0的值时,按默认值0.15处理。 | +| dampingFraction | number | 否 | 解释同springMotion中的dampingFraction。
默认值:0.86
单位:秒
取值范围:[0, +∞)
**说明:**
设置小于0的值时,按默认值0.86处理。 | +| overlapDuration | number | 否 | 解释同springMotion中的overlapDuration。
默认值:0.25
单位:秒
取值范围:[0, +∞)
**说明:**
设置小于0的值时,按默认值0.25处理。
弹性跟手动画曲线为springMotion的一种特例,仅默认值不同。如果使用自定义参数的弹性曲线,推荐使用springMotion构造曲线。如果使用跟手动画,推荐使用默认参数的弹性跟手动画曲线。
[animation](../arkui-ts/ts-animatorproperty.md)、[animateTo](../arkui-ts/ts-explicit-animation.md)中的duration参数不生效,动画持续时间取决于responsiveSpringMotion动画曲线参数和之前的速度,也不能通过该曲线的interpolate函数获得插值。 | **返回值:** | 类型 | 说明 | | ---------------------------------- | ---------------- | -| [ICurve](#icurve)| 曲线对象。
**说明:**
1.弹性跟手动画曲线为springMotion的一种特例,仅默认值不同。如果使用自定义参数的弹性曲线,推荐使用springMotion构造曲线;如果使用跟手动画,推荐使用默认参数的弹性跟手动画曲线。
2.animation、animateTo中的duration参数不生效,动画持续时间取决于responsiveSpringMotion动画曲线参数和之前的速度,也不能通过该曲线的[interpolate](#interpolate)函数获得插值。 | +| [ICurve](#icurve)| 曲线对象。
**说明:**
1、弹性跟手动画曲线为springMotion的一种特例,仅默认值不同。如果使用自定义参数的弹性曲线,推荐使用springMotion构造曲线;如果使用跟手动画,推荐使用默认参数的弹性跟手动画曲线。
2、[animation](../arkui-ts/ts-animatorproperty.md)、[animateTo](../arkui-ts/ts-explicit-animation.md)中的duration参数不生效,动画持续时间取决于responsiveSpringMotion动画曲线参数和之前的速度,也不能通过该曲线的[interpolate](#interpolate)函数获得插值。 | **示例:** @@ -202,6 +203,39 @@ Curves.responsiveSpringMotion() // 创建一个默认弹性跟手动画曲线 ``` +##  Curves.interpolatingSpringCurve10+ + +interpolatingSpring(velocity: number, mass: number, stiffness: number, damping: number):ICurve + + +构造插值器弹簧曲线对象,生成一条从0到1的动画曲线,实际动画值根据曲线进行插值计算。动画时间由曲线参数决定,不受animation、animateTo中的duration参数控制。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ----- | +| velocity | number | 是 | 初始速度。外部因素对弹性动效产生的影响参数,目的是保证对象从之前的运动状态平滑的过渡到弹性动效。该速度是归一化速度,其值等于动画开始时的实际速度除以动画属性改变值。 | +| mass | number | 是 | 质量。弹性系统的受力对象,会对弹性系统产生惯性影响。质量越大,震荡的幅度越大,恢复到平衡位置的速度越慢。 | +| stiffness | number | 是 | 刚度。表示物体抵抗施加的力而形变的程度。刚度越大,抵抗变形的能力越强,恢复到平衡位置的速度越快。 | +| damping | number | 是 | 阻尼。是一个纯数,无真实的物理意义,用于描述系统在受到扰动后震荡及衰减的情形。阻尼越大,弹性运动的震荡次数越少、震荡幅度越小。 | + + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------- | ---------------- | +| [ICurve](#icurve)| 曲线的插值对象。 | + + +**示例:** + +```ts +import Curves from '@ohos.curves' +Curves.interpolatingSpring(100, 1, 228, 30) // 创建一个时长由弹簧参数决定的弹簧插值曲线 +``` + + ## ICurve @@ -217,9 +251,9 @@ interpolate(fraction: number): number **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------ | ---- | -------------------------------------------- | -| fraction | number | 是 |  当前的归一化时间参数,有效值范围0到1。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| fraction | number | 是 | 当前的归一化时间参数。
取值范围:[0,1]
**说明:**
设置的值小于0时,按0处理;设置的值大于1时,按1处理。 | **返回值:** 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 5af7eba6884396c0f309b3b2b74106f3b6d6c780..a44d2d568b7c9e8f202b5318cb9d869a3da953f0 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 @@ -363,7 +363,12 @@ save(deviceId: string, callback: AsyncCallback<SaveSuccessResponse>): void ```ts g_object.setSessionId("123456"); -g_object.save("local", (result) => { +g_object.save("local", (err, result) => { + if (err) { + console.info("save failed, error code = " + err.code); + console.info("save failed, error message: " + err.message); + return; + } console.info("save callback"); console.info("save sessionId: " + result.sessionId); console.info("save version: " + result.version); @@ -408,8 +413,9 @@ g_object.save("local").then((result) => { console.info("save sessionId " + result.sessionId); console.info("save version " + result.version); console.info("save deviceId " + result.deviceId); -}, () => { - console.error("save failed"); +}).catch((err) => { + console.info("save failed, error code = " + err.code); + console.info("save failed, error message: " + err.message); }); ``` @@ -435,16 +441,26 @@ revokeSave(callback: AsyncCallback<RevokeSaveSuccessResponse>): void ```js g_object.setSessionId("123456"); // 持久化数据 -g_object.save("local", (result) => { +g_object.save("local", (err, result) => { + if (err) { + console.info("save failed, error code = " + err.code); + console.info("save failed, error message: " + err.message); + return; + } console.info("save callback"); - console.info("save sessionId " + result.sessionId); - console.info("save version " + result.version); - console.info("save deviceId " + result.deviceId); + console.info("save sessionId: " + result.sessionId); + console.info("save version: " + result.version); + console.info("save deviceId: " + result.deviceId); }); // 删除持久化保存的数据 -g_object.revokeSave((result) => { - console.info("revokeSave callback"); - console.info("revokeSave sessionId " + result.sessionId); +g_object.revokeSave((err, result) => { + if (err) { + console.info("revokeSave failed, error code = " + err.code); + console.info("revokeSave failed, error message: " + err.message); + return; + } + console.info("revokeSave callback"); + console.info("revokeSave sessionId " + result.sessionId); }); ``` @@ -475,15 +491,17 @@ g_object.save("local").then((result) => { console.info("save sessionId " + result.sessionId); console.info("save version " + result.version); console.info("save deviceId " + result.deviceId); -}, () => { - console.error("save failed"); +}).catch((err) => { + console.info("save failed, error code = " + err.code); + console.info("save failed, error message: " + err.message); }); // 删除持久化保存的数据 g_object.revokeSave().then((result) => { console.info("revokeSave callback"); console.info("sessionId" + result.sessionId); -}, () => { - console.error("revokeSave failed"); +}).catch((err)=> { + console.info("revokeSave failed, error code = " + err.code); + console.info("revokeSave failed, error message = " + err.message); }); ``` @@ -583,7 +601,7 @@ on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<stri **示例:** ```js -import distributedObject from '@ohos.data.distributedDataObject'; +import distributedObject from '@ohos.data.distributedDataObject'; let 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); @@ -619,7 +637,7 @@ off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<st **示例:** ```js -import distributedObject from '@ohos.data.distributedDataObject'; +import distributedObject from '@ohos.data.distributedDataObject'; let g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, parent:{mother:"jack mom",father:"jack Dad"}}); // 删除数据变更回调changeCallback g_object.off("change", globalThis.changeCallback); @@ -680,7 +698,7 @@ off(type: 'status', callback?: Callback<{ sessionId: string, deviceId: string, s **示例:** ```js -import distributedObject from '@ohos.data.distributedDataObject'; +import distributedObject from '@ohos.data.distributedDataObject'; let 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; 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 d9bfa5e2d38b3a99cbeaeca7ad3d9084ec824899..9a04bf1a637f946b66b86b054b007a8612bdecc7 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 @@ -1,6 +1,6 @@ -# @ohos.data.preferences (首选项) +# @ohos.data.preferences (用户首选项) -首选项为应用提供Key-Value键值型的数据处理能力,支持应用持久化轻量级数据,并对其修改和查询。 +用户首选项为应用提供Key-Value键值型的数据处理能力,支持应用持久化轻量级数据,并对其修改和查询。 数据存储形式为键值对,键的类型为字符串型,值的存储数据类型包括数字型、字符型、布尔型以及这3种类型的数组类型。 @@ -181,7 +181,7 @@ deletePreferences(context: Context, name: string, callback: AsyncCallback<voi **错误码:** -以下错误码的详细介绍请参见[首选项错误码](../errorcodes/errorcode-preferences.md)。 +以下错误码的详细介绍请参见[用户首选项错误码](../errorcodes/errorcode-preferences.md)。 | 错误码ID | 错误信息 | | -------- | ------------------------------| @@ -258,7 +258,7 @@ deletePreferences(context: Context, name: string): Promise<void> **错误码:** -以下错误码的详细介绍请参见[首选项错误码](../errorcodes/errorcode-preferences.md)。 +以下错误码的详细介绍请参见[用户首选项错误码](../errorcodes/errorcode-preferences.md)。 | 错误码ID | 错误信息 | | -------- | ------------------------------| @@ -792,7 +792,7 @@ try { flush(callback: AsyncCallback<void>): void -将当前Preferences实例的数据异步存储到首选项持久化文件中,使用callback异步回调。 +将当前Preferences实例的数据异步存储到用户首选项的持久化文件中,使用callback异步回调。 **系统能力:** SystemCapability.DistributedDataManager.Preferences.Core @@ -823,7 +823,7 @@ try { flush(): Promise<void> -将当前Preferences实例的数据异步存储到首选项持久化文件中,使用Promise异步回调。 +将当前Preferences实例的数据异步存储到用户首选项的持久化文件中,使用Promise异步回调。 **系统能力:** SystemCapability.DistributedDataManager.Preferences.Core 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 12c7ff4f5e0fa234c19ac6dc05b65e5b468f94ed..b2b3cdd04722a53fd7713b3bdfd2407b6da454c6 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 @@ -349,6 +349,10 @@ inDevices(devices: Array<string>): RdbPredicates 同步分布式数据库时连接到组网内指定的远程设备。 +> **说明:** +> +> 其中devices通过调用[deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync)方法得到。deviceManager模块的接口均为系统接口,仅系统应用可用。 + **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core **参数:** @@ -366,8 +370,24 @@ inDevices(devices: Array<string>): RdbPredicates **示例:** ```js -let predicates = new data_rdb.RdbPredicates("EMPLOYEE") -predicates.inDevices(['12345678abcde']) +import deviceManager from '@ohos.distributedHardware.deviceManager'; +let dmInstance = null; + +deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { + if (err) { + console.log("create device manager failed, err=" + err); + return; + } + dmInstance = manager; + let devices = dmInstance.getTrustedDeviceListSync(); + let deviceIds = []; + for (var i = 0; i < devices.length; i++) { + deviceIds[i] = devices[i].deviceId; + } +}) + +let predicates = new data_rdb.RdbPredicates("EMPLOYEE"); +predicates.inDevices(deviceIds); ``` ### inAllDevices8+ @@ -1808,7 +1828,11 @@ promise.then(() => { obtainDistributedTableName(device: string, table: string, callback: AsyncCallback<string>): void -根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名, 使用callback异步回调。 +根据远程设备的本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名, 使用callback异步回调。 + +> **说明:** +> +> 其中device通过调用[deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync)方法得到。deviceManager模块的接口均为系统接口,仅系统应用可用。 **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC @@ -1818,14 +1842,28 @@ obtainDistributedTableName(device: string, table: string, callback: AsyncCallbac | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| device | string | 是 | 远程设备 。| -| table | string | 是 | 本地表名。 | +| device | string | 是 | 远程设备ID 。 | +| table | string | 是 | 远程设备的本地表名 | | callback | AsyncCallback<string> | 是 | 指定的callback回调函数。如果操作成功,返回远程设备的分布式表名。 | **示例:** ```js -rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, tableName) { +import deviceManager from '@ohos.distributedHardware.deviceManager'; +let dmInstance = null; + +deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { + if (err) { + console.log("create device manager failed, err=" + err); + return; + } + dmInstance = manager; + let devices = dmInstance.getTrustedDeviceListSync(); + let deviceId = devices[0].deviceId; +}) + + +rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) { if (err) { console.info('ObtainDistributedTableName failed, err: ' + err) return @@ -1838,7 +1876,11 @@ rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, obtainDistributedTableName(device: string, table: string): Promise<string> -根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名,使用Promise异步回调。 +根据远程设备的本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名,使用Promise异步回调。 + +> **说明:** +> +> 其中device通过调用[deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync)方法得到。deviceManager模块的接口均为系统接口,仅系统应用可用。 **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC @@ -1848,8 +1890,8 @@ rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| device | string | 是 | 远程设备。 | -| table | string | 是 | 本地表名。 | +| device | string | 是 | 远程设备ID。 | +| table | string | 是 | 远程设备的本地表名。 | **返回值**: @@ -1860,7 +1902,20 @@ rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, **示例:** ```js -let promise = rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE") +import deviceManager from '@ohos.distributedHardware.deviceManager'; +let dmInstance = null; + +deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { + if (err) { + console.log("create device manager failed, err=" + err); + return; + } + dmInstance = manager; + let devices = dmInstance.getTrustedDeviceListSync(); + let deviceId = devices[0].deviceId; +}) + +let promise = rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE") promise.then((tableName) => { console.info('ObtainDistributedTableName successfully, tableName= ' + tableName) }).catch((err) => { @@ -1889,8 +1944,24 @@ sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array **示例:** ```js +import deviceManager from '@ohos.distributedHardware.deviceManager'; +let dmInstance = null; + +deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { + if (err) { + console.log("create device manager failed, err=" + err); + return; + } + dmInstance = manager; + let devices = dmInstance.getTrustedDeviceListSync(); + let deviceIds = []; + for (var i = 0; i < devices.length; i++) { + deviceIds[i] = devices[i].deviceId; + } +}) + let predicates = new data_rdb.RdbPredicates('EMPLOYEE') -predicates.inDevices(['12345678abcde']) +predicates.inDevices(deviceIds) rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) { if (err) { console.log('Sync failed, err: ' + err) @@ -1929,8 +2000,24 @@ rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, resul **示例:** ```js +import deviceManager from '@ohos.distributedHardware.deviceManager'; +let dmInstance = null; + +deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { + if (err) { + console.log("create device manager failed, err=" + err); + return; + } + dmInstance = manager; + let devices = dmInstance.getTrustedDeviceListSync(); + let deviceIds = []; + for (var i = 0; i < devices.length; i++) { + deviceIds[i] = devices[i].deviceId; + } +}) + let predicates = new data_rdb.RdbPredicates('EMPLOYEE') -predicates.inDevices(['12345678abcde']) +predicates.inDevices(deviceIds) let promise = rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates) promise.then((result) =>{ console.log('Sync done.') diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md b/zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md index 564bde75b6d087feca5e8945eab230ad6551e372..9a238fa148fc5d604106ef43eef16d1c85a4ed90 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md @@ -414,9 +414,12 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); inDevices(devices: Array<string>): RdbPredicates - 同步分布式数据库时连接到组网内指定的远程设备。 +> **说明:** +> +> 其中devices通过调用[deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync)方法得到。deviceManager模块的接口均为系统接口,仅系统应用可用。 + **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core **参数:** @@ -434,8 +437,24 @@ inDevices(devices: Array<string>): RdbPredicates **示例:** ```js +import deviceManager from '@ohos.distributedHardware.deviceManager'; +let dmInstance = null; + +deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { + if (err) { + console.log("create device manager failed, err=" + err); + return; + } + dmInstance = manager; + let devices = dmInstance.getTrustedDeviceListSync(); + let deviceIds = []; + for (var i = 0; i < devices.length; i++) { + deviceIds[i] = devices[i].deviceId; + } +}) + let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); -predicates.inDevices(['12345678abcde']); +predicates.inDevices(deviceIds); ``` ### inAllDevices @@ -2008,24 +2027,41 @@ remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: A 根据指定条件查询远程设备数据库中的数据。使用callback异步回调。 +> **说明:** +> +> 其中device通过调用[deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync)方法得到。deviceManager模块的接口均为系统接口,仅系统应用可用。 + **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | -| device | string | 是 | 指定的远程设备的networkId。 | -| table | string | 是 | 指定的目标表名。 | -| predicates | [RdbPredicates](#rdbpredicates) | 是 | RdbPredicates的实例对象,指定查询的条件。 | -| columns | Array<string> | 是 | 表示要查询的列。如果值为空,则查询应用于所有列。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | -------------------------------------------- | ---- | --------------------------------------------------------- | +| device | string | 是 | 指定的远程设备ID。 | +| table | string | 是 | 指定的目标表名。 | +| predicates | [RdbPredicates](#rdbpredicates) | 是 | RdbPredicates的实例对象,指定查询的条件。 | +| columns | Array<string> | 是 | 表示要查询的列。如果值为空,则查询应用于所有列。 | | callback | AsyncCallback<[ResultSet](#resultset)> | 是 | 指定callback回调函数。如果操作成功,则返回ResultSet对象。 | **示例:** ```js +import deviceManager from '@ohos.distributedHardware.deviceManager'; +let dmInstance = null; + +deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { + if (err) { + console.log("create device manager failed, err=" + err); + return; + } + dmInstance = manager; + let devices = dmInstance.getTrustedDeviceListSync(); + let deviceId = devices[0].deviceId; +}) + let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); predicates.greaterThan("id", 0); -store.remoteQuery("deviceId", "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], +store.remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function(err, resultSet) { if (err) { console.error(`Failed to remoteQuery, err: ${err}`); @@ -2043,13 +2079,17 @@ remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: A 根据指定条件查询远程设备数据库中的数据。使用Promise异步回调。 +> **说明:** +> +> 其中device通过调用[deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync)方法得到。deviceManager模块的接口均为系统接口,仅系统应用可用。 + **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------ | ---- | ------------------------------------------------ | -| device | string | 是 | 指定的远程设备的networkId。 | +| device | string | 是 | 指定的远程设备ID。 | | table | string | 是 | 指定的目标表名。 | | predicates | [RdbPredicates](#rdbpredicates) | 是 | RdbPredicates的实例对象,指定查询的条件。 | | columns | Array<string> | 是 | 表示要查询的列。如果值为空,则查询应用于所有列。 | @@ -2063,6 +2103,19 @@ remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: A **示例:** ```js +import deviceManager from '@ohos.distributedHardware.deviceManager'; +let dmInstance = null; + +deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { + if (err) { + console.log("create device manager failed, err=" + err); + return; + } + dmInstance = manager; + let devices = dmInstance.getTrustedDeviceListSync(); + let deviceId = devices[0].deviceId; +}) + let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); predicates.greaterThan("id", 0); let promise = store.remoteQuery("deviceId", "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); @@ -2488,7 +2541,11 @@ promise.then(() => { obtainDistributedTableName(device: string, table: string, callback: AsyncCallback<string>): void -根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名, 使用callback异步回调。 +根据远程设备的本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名, 使用callback异步回调。 + +> **说明:** +> +> 其中device通过调用[deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync)方法得到。deviceManager模块的接口均为系统接口,仅系统应用可用。 **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC @@ -2498,14 +2555,27 @@ obtainDistributedTableName(device: string, table: string, callback: AsyncCallbac | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------------------------------------------ | -| device | string | 是 | 远程设备 。 | -| table | string | 是 | 本地表名。 | +| device | string | 是 | 远程设备ID 。 | +| table | string | 是 | 远程设备的本地表名。 | | callback | AsyncCallback<string> | 是 | 指定的callback回调函数。如果操作成功,返回远程设备的分布式表名。 | **示例:** ```js -store.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, tableName) { +import deviceManager from '@ohos.distributedHardware.deviceManager'; +let dmInstance = null; + +deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { + if (err) { + console.log("create device manager failed, err=" + err); + return; + } + dmInstance = manager; + let devices = dmInstance.getTrustedDeviceListSync(); + let deviceId = devices[0].deviceId; +}) + +store.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) { if (err) { console.error(`ObtainDistributedTableName failed, err: ${err}`); return; @@ -2518,7 +2588,11 @@ store.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, tab obtainDistributedTableName(device: string, table: string): Promise<string> -根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名,使用Promise异步回调。 +根据远程设备的本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名,使用Promise异步回调。 + +> **说明:** +> +> 其中device通过调用[deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync)方法得到。deviceManager模块的接口均为系统接口,仅系统应用可用。 **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC @@ -2526,10 +2600,10 @@ store.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, tab **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ---------- | -| device | string | 是 | 远程设备。 | -| table | string | 是 | 本地表名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------- | +| device | string | 是 | 远程设备ID。 | +| table | string | 是 | 远程设备的本地表名。 | **返回值**: @@ -2540,7 +2614,20 @@ store.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, tab **示例:** ```js -let promise = store.obtainDistributedTableName("12345678abcde", "EMPLOYEE"); +import deviceManager from '@ohos.distributedHardware.deviceManager'; +let dmInstance = null; + +deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { + if (err) { + console.log("create device manager failed, err=" + err); + return; + } + dmInstance = manager; + let devices = dmInstance.getTrustedDeviceListSync(); + let deviceId = devices[0].deviceId; +}) + +let promise = store.obtainDistributedTableName(deviceId, "EMPLOYEE"); promise.then((tableName) => { console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`); }).catch((err) => { @@ -2569,8 +2656,24 @@ sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array **示例:** ```js +import deviceManager from '@ohos.distributedHardware.deviceManager'; +let dmInstance = null; + +deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { + if (err) { + console.log("create device manager failed, err=" + err); + return; + } + dmInstance = manager; + let devices = dmInstance.getTrustedDeviceListSync(); + let deviceIds = []; + for (var i = 0; i < devices.length; i++) { + deviceIds[i] = devices[i].deviceId; + } +}) + let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); -predicates.inDevices(['12345678abcde']); +predicates.inDevices(deviceIds); store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) { if (err) { console.error(`Sync failed, err: ${err}`); @@ -2609,8 +2712,24 @@ store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, function (err, r **示例:** ```js +import deviceManager from '@ohos.distributedHardware.deviceManager'; +let dmInstance = null; + +deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { + if (err) { + console.log("create device manager failed, err=" + err); + return; + } + dmInstance = manager; + let devices = dmInstance.getTrustedDeviceListSync(); + let deviceIds = []; + for (var i = 0; i < devices.length; i++) { + deviceIds[i] = devices[i].deviceId; + } +}) + let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); -predicates.inDevices(['12345678abcde']); +predicates.inDevices(deviceIds); let promise = store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates); promise.then((result) =>{ console.info(`Sync done.`); 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 83f6e63572daa8b30d9decfa8a8e1131609c11ba..3c0701bd503245342420ea3cefb2f849d8b87ab6 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 @@ -96,7 +96,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager | CAR | 0x83 | 车 | | UNKNOWN_TYPE | 0 | 未知设备 | -## AuthForm +## AuthForm10+ 表示设备认证类型的枚举类。 @@ -262,8 +262,6 @@ getTrustedDeviceListSync(): Array<DeviceInfo> 同步获取所有可信设备列表。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **返回值:** @@ -296,8 +294,6 @@ getTrustedDeviceList(callback:AsyncCallback<Array<DeviceInfo>>): voi 获取所有可信设备列表。使用callback异步回调。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -336,8 +332,6 @@ getTrustedDeviceList(): Promise<Array<DeviceInfo>> 获取所有可信设备列表。使用Promise异步回调。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **返回值:** @@ -370,8 +364,6 @@ getLocalDeviceInfoSync(): [DeviceInfo](#deviceinfo) 同步获取本地设备信息。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **返回值:** @@ -404,8 +396,6 @@ getLocalDeviceInfo(callback:AsyncCallback<DeviceInfo>): void 获取本地设备信息。使用callback异步回调。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -444,8 +434,6 @@ getLocalDeviceInfo(): Promise<DeviceInfo> 获取本地设备信息。使用Promise异步回调。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **返回值:** @@ -478,8 +466,6 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void 发现周边设备。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -524,8 +510,6 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void 发现周边设备。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -580,8 +564,6 @@ stopDeviceDiscovery(subscribeId: number): void 停止发现周边设备。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -616,8 +598,6 @@ publishDeviceDiscovery(publishInfo: PublishInfo): void 发布设备发现。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -659,8 +639,6 @@ unPublishDeviceDiscovery(publishId: number): void 停止发布设备发现。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -695,8 +673,6 @@ authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: Async 认证设备。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -757,8 +733,6 @@ unAuthenticateDevice(deviceInfo: DeviceInfo): void 解除认证设备。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -798,8 +772,6 @@ verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, 验证认证信息。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -844,8 +816,6 @@ setUserOperation(operateAction: number, params: string): void; 设置用户ui操作行为。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -880,8 +850,6 @@ requestCredentialRegisterInfo(requestInfo: string, callback: AsyncCallback<{regi 获取凭据的注册信息。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -917,8 +885,6 @@ importCredential(credentialInfo: string, callback: AsyncCallback<{resultInfo: st 导入凭据信息。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -970,8 +936,6 @@ deleteCredential(queryInfo: string, callback: AsyncCallback<{resultInfo: string} 删除凭据信息。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -1008,8 +972,6 @@ on(type: 'uiStateChange', callback: Callback<{ param: string}>): void; ui状态变更回调。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -1040,8 +1002,6 @@ off(type: 'uiStateChange', callback?: Callback<{ param: string}>): void; 取消ui状态变更回调。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -1067,8 +1027,6 @@ on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChange 注册设备状态回调。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -1096,8 +1054,6 @@ off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChang 取消注册设备状态回调。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -1125,8 +1081,6 @@ on(type: 'deviceFound', callback: Callback<{ subscribeId: number, device: Dev 注册发现设备回调监听。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -1154,8 +1108,6 @@ off(type: 'deviceFound', callback?: Callback<{ subscribeId: number, device: D 取消注册设备发现回调。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -1183,8 +1135,6 @@ on(type: 'discoverFail', callback: Callback<{ subscribeId: number, reason: nu 注册设备发现失败回调监听。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -1212,8 +1162,6 @@ off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: 取消注册设备发现失败回调。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -1241,8 +1189,6 @@ on(type: 'publishSuccess', callback: Callback<{ publishId: number }>): voi 注册发布设备发现回调监听。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -1271,8 +1217,6 @@ off(type: 'publishSuccess', callback?: Callback<{ publishId: number }>): v 取消注册设备发布成功回调。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -1300,8 +1244,6 @@ on(type: 'publishFail', callback: Callback<{ publishId: number, reason: numbe 注册设备发布失败回调监听。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -1329,8 +1271,6 @@ off(type: 'publishFail', callback?: Callback<{ publishId: number, reason: num 取消注册设备发布失败回调。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -1358,8 +1298,6 @@ on(type: 'serviceDie', callback: () => void): void 注册设备管理服务死亡监听。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** @@ -1387,8 +1325,6 @@ off(type: 'serviceDie', callback?: () => void): void 取消注册设备管理服务死亡监听。 -**需要权限**:ohos.permission.ACCESS_SERVICE_DM,仅系统应用可用。 - **系统能力**:SystemCapability.DistributedHardware.DeviceManager **参数:** 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 1cade67ddc4d97371f9c07925a508a6195293efe..82c7205626934dbd5ddf5bca020ce943917b171a 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 @@ -232,7 +232,8 @@ setOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise<void> | 错误码ID | 错误信息| | -------- | ------------------- | | 12300001 | System service exception. | -| 12300002 | invalid accountInfo. | +| 12300002 | Invalid accountInfo. | +| 12300003 | Account not found. | **示例:** ```js @@ -325,4 +326,4 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise<void> | event | string | 是 | 分布式帐号登录状态,包括登录、登出、Token失效和注销,分别对应以下字符串:
- Ohos.account.event.LOGIN
- Ohos.account.event.LOGOUT
- Ohos.account.event.TOKEN_INVALID
- Ohos.account.event.LOGOFF | | nickname9+ | string | 否 | 分布式帐号的昵称,非空字符串。 | | avatar9+ | string | 否 | 分布式帐号的头像,非空字符串。 | -| scalableData | object | 否 | 分布式帐号扩展信息,根据业务所需,以k-v形式传递定制化信息。
说明:该参数是预留的可选项,目前查询和更新的方法实现中未使用。 | +| scalableData8+ | object | 否 | 分布式帐号扩展信息,根据业务所需,以k-v形式传递定制化信息。
说明:该参数是预留的可选项,目前查询和更新的方法实现中未使用。 | 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 385a0aa56f3ffbe2e53b49445f1ef59bad60fac9..1858e49ff90e8b98d9b321f5811ff72a366c4ead 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 @@ -578,7 +578,7 @@ try { | createIfMissing | boolean | 否 | 当数据库文件不存在时是否创建数据库,默认创建。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | | encrypt | boolean | 否 |设置数据库文件是否加密,默认不加密。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | | backup | boolean | 否 |设置数据库文件是否备份,默认备份。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| autoSync | boolean | 否 |设置数据库文件是否自动同步,默认不自动同步。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core
**需要权限**: ohos.permission.DISTRIBUTED_DATASYNC | +| autoSync | boolean | 否 |设置数据库文件是否自动同步。默认为false,即手动同步;设置为true时,表示自动同步。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core
**需要权限**: ohos.permission.DISTRIBUTED_DATASYNC | | kvStoreType | [KVStoreType](#kvstoretype) | 否 |设置要创建的数据库类型,默认为多设备协同数据库。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | | securityLevel | [SecurityLevel](#securitylevel) | 否 |设置数据库安全级别,默认不设置安全级别。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | | schema8+ | [Schema](#schema8) | 否 | 设置定义存储在数据库中的值。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | @@ -3755,6 +3755,9 @@ try { sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void 在手动同步方式下,触发数据库同步。关于分布式数据服务的同步方式说明,请见[分布式数据服务概述](../../database/database-mdds-overview.md)。 +> **说明:** +> +> 其中deviceIds通过调用[deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync)方法得到。deviceManager模块的接口均为系统接口,仅系统应用可用。 **需要权限**: ohos.permission.DISTRIBUTED_DATASYNC。 @@ -3771,8 +3774,41 @@ sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void **示例:** ```js +import deviceManager from '@ohos.distributedHardware.deviceManager'; + +let devManager; let kvStore; -kvStore.sync(['deviceIds'], distributedData.SyncMode.PULL_ONLY, 1000); +const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; +const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; +// create deviceManager +deviceManager.createDeviceManager('bundleName', (err, value) => { + if (!err) { + devManager = value; + let deviceIds = []; + if (devManager != null) { + var devices = devManager.getTrustedDeviceListSync(); + for (var i = 0; i < devices.length; i++) { + deviceIds[i] = devices[i].deviceId; + } + } + try { + kvStore.on('syncComplete', function (data) { + console.log('Sync dataChange'); + }); + kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log('Succeeded in putting data'); + const mode = distributedData.SyncMode.PULL_ONLY; + kvStore.sync(deviceIds, mode, 1000); + }); + } catch (e) { + console.log('Sync e' + e); + } + } +}); ``` ### on('dataChange')8+ @@ -5141,6 +5177,10 @@ sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void 在手动同步方式下,触发数据库同步。关于分布式数据服务的同步方式说明,请见[分布式数据服务概述](../../database/database-mdds-overview.md)。 +> **说明:** +> +> 其中devicesId通过调用[deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync)方法得到。deviceManager模块的接口均为系统接口,仅系统应用可用。 + **需要权限**: ohos.permission.DISTRIBUTED_DATASYNC。 **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core @@ -5156,22 +5196,41 @@ sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void **示例:** ```js +import deviceManager from '@ohos.distributedHardware.deviceManager'; + +let devManager; let kvStore; const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; -try { - kvStore.on('syncComplete', function (data) { +// create deviceManager +deviceManager.createDeviceManager('bundleName', (err, value) => { + if (!err) { + devManager = value; + let deviceIds = []; + if (devManager != null) { + var devices = devManager.getTrustedDeviceListSync(); + for (var i = 0; i < devices.length; i++) { + deviceIds[i] = devices[i].deviceId; + } + } + 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']; + }); + kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log('Succeeded in putting data'); const mode = distributedData.SyncMode.PULL_ONLY; - kvStore.sync(devices, mode); - }); -}catch(e) { - console.log('Sync e' + e); -} + kvStore.sync(deviceIds, mode, 1000); + }); + } catch (e) { + console.log('Sync e' + e); + } + } +}); ``` ### on('dataChange')8+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md b/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md index 84206aabcfe16da05849f39ad6f308eda9db28b8..ab644198723876b46e690bf9e6ef743892e50b80 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md @@ -151,7 +151,7 @@ import distributedKVStore from '@ohos.data.distributedKVStore'; | createIfMissing | boolean | 否 | 当数据库文件不存在时是否创建数据库,默认创建。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | | encrypt | boolean | 否 | 设置数据库文件是否加密,默认不加密。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | | backup | boolean | 否 | 设置数据库文件是否备份,默认备份。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| autoSync | boolean | 否 | 设置数据库文件是否自动同步,默认不自动同步。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core
**需要权限**: ohos.permission.DISTRIBUTED_DATASYNC | +| autoSync | boolean | 否 | 设置数据库文件是否自动同步。默认为false,即手动同步;设置为true时,表示自动同步。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core
**需要权限**: ohos.permission.DISTRIBUTED_DATASYNC | | kvStoreType | [KVStoreType](#kvstoretype) | 否 | 设置要创建的数据库类型,默认为多设备协同数据库。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | | securityLevel | [SecurityLevel](#securitylevel) | 是 |设置数据库安全级别。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | | schema | [Schema](#schema) | 否 | 设置定义存储在数据库中的值,默认不使用Schema。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | @@ -4485,6 +4485,9 @@ try { sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void 在手动同步方式下,触发数据库同步。关于分布式数据服务的同步方式说明,请见[分布式数据服务概述](../../database/database-mdds-overview.md)。 +> **说明:** +> +> 其中deviceIds通过调用[deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync)方法得到。deviceManager模块的接口均为系统接口,仅系统应用可用。 **需要权限**: ohos.permission.DISTRIBUTED_DATASYNC。 @@ -4510,26 +4513,41 @@ sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void **示例:** ```js +import deviceManager from '@ohos.distributedHardware.deviceManager'; + +let devManager; let kvStore; const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; -try { - kvStore.on('syncComplete', function (data) { +// create deviceManager +deviceManager.createDeviceManager('bundleName', (err, value) => { + if (!err) { + devManager = value; + let deviceIds = []; + if (devManager != null) { + var devices = devManager.getTrustedDeviceListSync(); + for (var i = 0; i < devices.length; i++) { + deviceIds[i] = devices[i].deviceId; + } + } + try { + kvStore.on('syncComplete', function (data) { console.log('Sync dataChange'); - }); - kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) { + }); + kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) { if (err != undefined) { - console.error(`Fail to sync.code is ${err.code},message is ${err.message}`); - return; + console.error(`Fail to sync.code is ${err.code},message is ${err.message}`); + return; } console.log('Succeeded in putting data'); - const devices = ['deviceList']; const mode = distributedKVStore.SyncMode.PULL_ONLY; - kvStore.sync(devices, mode, 1000); - }); -} catch (e) { - console.error(`Fail to sync.code is ${e.code},message is ${e.message}`); -} + kvStore.sync(deviceIds, mode, 1000); + }); + } catch (e) { + console.error(`Fail to sync.code is ${e.code},message is ${e.message}`); + } + } +}); ``` ### sync @@ -4537,6 +4555,9 @@ try { sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void 在手动同步方式下,触发数据库同步,此方法为同步方法。关于分布式数据服务的同步方式说明,请见[分布式数据服务概述](../../database/database-mdds-overview.md)。 +> **说明:** +> +> 其中deviceIds通过调用[deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync)方法得到。deviceManager模块的接口均为系统接口,仅系统应用可用。 **需要权限**: ohos.permission.DISTRIBUTED_DATASYNC。 @@ -4563,29 +4584,44 @@ sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void **示例:** ```js +import deviceManager from '@ohos.distributedHardware.deviceManager'; + +let devManager; let kvStore; const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; -try { - kvStore.on('syncComplete', function (data) { +// create deviceManager +deviceManager.createDeviceManager('bundleName', (err, value) => { + if (!err) { + devManager = value; + let deviceIds = []; + if (devManager != null) { + var devices = devManager.getTrustedDeviceListSync(); + for (var i = 0; i < devices.length; i++) { + deviceIds[i] = devices[i].deviceId; + } + } + try { + kvStore.on('syncComplete', function (data) { console.log('Sync dataChange'); - }); - kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) { + }); + kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) { if (err != undefined) { - console.error(`Fail to sync.code is ${err.code},message is ${err.message}`); - return; + console.error(`Fail to sync.code is ${err.code},message is ${err.message}`); + return; } console.log('Succeeded in putting data'); - const devices = ['deviceList']; const mode = distributedKVStore.SyncMode.PULL_ONLY; const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); query.deviceId('localDeviceId'); - kvStore.sync(devices, query, mode, 1000); - }); -} catch (e) { - console.error(`Fail to sync.code is ${e.code},message is ${e.message}`); -} + kvStore.sync(deviceIds, query, mode, 1000); + }); + } catch (e) { + console.error(`Fail to sync.code is ${e.code},message is ${e.message}`); + } + } +}); ``` ### on('dataChange') 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 5610c212819c32fc322225e6824da36fbc87a736..19e128c424c2554cf11544241c51389277e0bcdc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-effectKit.md +++ b/zh-cn/application-dev/reference/apis/js-apis-effectKit.md @@ -180,6 +180,93 @@ console.log('get main color =' + color); ``` ![zh-ch_image_Main_Color.png](figures/zh-ch_image_Main_Color.png) +### getLargestProportionColor10+ + +getLargestProportionColor(): Color + +读取图像占比最多的颜色值,结果写入[Color](#color)里,使用同步方式返回。 + +**系统能力:** SystemCapability.Multimedia.Image.Core + +**返回值:** + +| 类型 | 说明 | +| :------------- | :---------------------------------------------- | +| [Color](#color) | Color实例,即图像占比最多的颜色值,失败时返回null。 | + +**示例:** + +```js +let color = colorPicker.getLargestProportionColor(); +console.log('get largest proportion color =' + color); +``` +![zh-ch_image_Largest_Proportion_Color.png](figures/zh-ch_image_Largest_Proportion_Color.png) + +### getHighestSaturationColor10+ + +getHighestSaturationColor(): Color + +读取图像饱和度最高的颜色值,结果写入[Color](#color)里,使用同步方式返回。 + +**系统能力:** SystemCapability.Multimedia.Image.Core + +**返回值:** + +| 类型 | 说明 | +| :------------- | :---------------------------------------------- | +| [Color](#color) | Color实例,即图像饱和度最高的颜色值,失败时返回null。 | + +**示例:** + +```js +let color = colorPicker.getHighestSaturationColor(); +console.log('get highest saturation color =' + color); +``` +![zh-ch_image_Highest_Saturation_Color.png](figures/zh-ch_image_Highest_Saturation_Color.png) + +### getAverageColor10+ + +getAverageColor(): Color + +读取图像平均的颜色值,结果写入[Color](#color)里,使用同步方式返回。 + +**系统能力:** SystemCapability.Multimedia.Image.Core + +**返回值:** + +| 类型 | 说明 | +| :------------- | :---------------------------------------------- | +| [Color](#color) | Color实例,即图像平均的颜色值,失败时返回null。 | + +**示例:** + +```js +let color = colorPicker.getAverageColor(); +console.log('get average color =' + color); +``` +![zh-ch_image_Average_Color.png](figures/zh-ch_image_Average_Color.png) + +### isBlackOrWhiteOrGrayColor10+ + +isBlackOrWhiteOrGrayColor(color: number): boolean + +判断图像是否为黑白灰颜色,返回true或false。 + +**系统能力:** SystemCapability.Multimedia.Image.Core + +**返回值:** + +| 类型 | 说明 | +| :------------- | :---------------------------------------------- | +| boolean | 如果此图像为黑白灰颜色,则返回true;否则返回false。 | + +**示例:** + +```js +let bJudge = colorPicker.isBlackOrWhiteOrGrayColor(0xFFFFFFFF); +console.log('is black or white or gray color[bool](white) =' + bJudge); +``` + ## Filter 图像效果类,用于将指定的效果添加到输入图像中。在调用Filter的方法前,需要先通过[createEffect](#effectkitcreateeffect)创建一个Filter实例。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-file-fileUri.md b/zh-cn/application-dev/reference/apis/js-apis-file-fileUri.md new file mode 100644 index 0000000000000000000000000000000000000000..595a3a593dad5d384dbc7ff832285e07cd9b031a --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-file-fileUri.md @@ -0,0 +1,60 @@ +# @ohos.file.fileUri (文件URI) + +该模块提供通过PATH获取文件统一资源标志符(Uniform Resource Identifier,URI),后续可通过使用[@ohos.file.fs](js-apis-file-fs.md)进行相关open、read、write等操作,实现文件分享。 + +> **说明:** +> - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```js +import fileUri from "@ohos.file.fileUri"; +``` + +使用该功能模块前,需要先获取其应用沙箱路径,开发示例如下: + + ```js +import UIAbility from '@ohos.app.ability.UIAbility'; + +export default class EntryAbility extends UIAbility { + onWindowStageCreate(windowStage) { + let context = this.context; + let pathDir = context.filesDir; + } +} + ``` + +## fileUri.getUriFromPath + +getUriFromPath(path: string): string + +以同步方法获取文件URI。 + +**系统能力**:SystemCapability.FileManagement.AppFileService + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------------- | +| path | string | 是 | 文件的沙箱路径 | + +**返回值:** + + | 类型 | 说明 | + | ---------------------------- | ---------- | + | string | 返回文件URI | + +**错误码:** + +以下错误码的详细介绍请参见[文件管理子系统错误码](../errorcodes/errorcode-filemanagement.md#错误码适配指导) + | 错误码ID | 错误信息 | + | ---------------------------- | ---------- | + | 401 | The input parameter is invalid | + + +**示例:** + + ```js +let filePath = pathDir + "test.txt"; +let uri = fileUri.getUriFromPath(filePath); + ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-file-fs.md b/zh-cn/application-dev/reference/apis/js-apis-file-fs.md index 370c3d907c093061e0a542ed3ff7b00ba9f71568..9bc6e12e371d0c6f1517870fc8b3a6589dddd224 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-file-fs.md +++ b/zh-cn/application-dev/reference/apis/js-apis-file-fs.md @@ -600,7 +600,7 @@ read(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: numb let buf = new ArrayBuffer(4096); fs.read(file.fd, buf).then((readLen) => { console.info("read file data succeed"); - console.info(String.fromCharCode.apply(null, new Uint8Array(readLen))); + console.info(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen)))); fs.closeSync(file); }).catch((err) => { console.info("read file data failed with error message: " + err.message + ", error code: " + err.code); @@ -635,7 +635,7 @@ read(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: numb console.info("mkdir failed with error message: " + err.message + ", error code: " + err.code); } else { console.info("read file data succeed"); - console.info(String.fromCharCode.apply(null, new Uint8Array(readLen))); + console.info(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen)))); fs.closeSync(file); } }); @@ -2584,7 +2584,7 @@ read(buffer: ArrayBuffer, options?: { offset?: number; length?: number; }): Prom let buf = new ArrayBuffer(4096); ss.read(buf, {offset: 5, length: 5}).then((readLen) => { console.info("read data succeed"); - console.log(String.fromCharCode.apply(null, new Uint8Array(buf))); + console.log(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen)))); }).catch((err) => { console.info("read data failed with error message: " + err.message + ", error code: " + err.code); }); @@ -2618,7 +2618,7 @@ read(buffer: ArrayBuffer, options?: { position?: number; offset?: number; length console.info("read stream failed with error message: " + err.message + ", error code: " + err.code); } else { console.info("read data succeed"); - console.log(String.fromCharCode.apply(null, new Uint8Array(buf))); + console.log(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen)))); } }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-file-volumemanager.md b/zh-cn/application-dev/reference/apis/js-apis-file-volumemanager.md index 3a26a3679bbdeb8982f7a95cf182cafac1b549b2..289147e5a41d5cf52e7f480b77d3687480c9cb0b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-file-volumemanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-file-volumemanager.md @@ -1,6 +1,6 @@ # @ohos.file.volumeManager (卷管理) -该模块提供卷、磁盘查询和管理的相关功能:包括查询卷信息,对卷的挂载卸载、对磁盘分区以及卷的格式化等功能。 +该模块提供卷设备、磁盘设备查询和管理的相关功能:包括查询卷设备信息,对卷设备的挂载卸载、对磁盘设备分区以及卷设备的格式化等功能。 > **说明:** > @@ -18,7 +18,7 @@ import volumemanager from "@ohos.file.volumeManager"; getAllVolumes(): Promise<Array<Volume>> -异步获取当前所有可获得的卷信息,以promise方式返回。 +异步获取当前外置存储中所有卷设备信息,以promise方式返回。 **需要权限**:ohos.permission.STORAGE_MANAGER @@ -28,13 +28,15 @@ getAllVolumes(): Promise<Array<Volume>> | 类型 | 说明 | | ---------------------------------- | -------------------------- | - | Promise<[Volume](#volume)[]> | 返回当前所有可获得的卷信息 | + | Promise<[Volume](#volume)[]> | 返回当前所有可获得的卷设备信息 | **示例:** ```js volumemanager.getAllVolumes().then(function(volumes){ // do something + }).catch(function(error){ + console.info("getAllVolumes failed"); }); ``` @@ -42,7 +44,7 @@ getAllVolumes(): Promise<Array<Volume>> getAllVolumes(callback: AsyncCallback<Array<Volume>>): void -异步获取当前所有可获得的卷信息,以callback方式返回。 +异步获取当前外置存储中所有卷设备信息,以callback方式返回。 **需要权限**:ohos.permission.STORAGE_MANAGER @@ -52,7 +54,7 @@ getAllVolumes(callback: AsyncCallback<Array<Volume>>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------- | ---- | ------------------------------------ | - | callback | AsyncCallback<[Volume](#volume)[]> | 是 | 获取当前所有可获得的卷信息之后的回调 | + | callback | AsyncCallback<[Volume](#volume)[]> | 是 | 获取当前所有可获得的卷设备信息之后的回调 | **示例:** @@ -68,7 +70,7 @@ getAllVolumes(callback: AsyncCallback<Array<Volume>>): void mount(volumeId: string): Promise<void> -异步挂载指定卷,以promise方式返回。 +异步挂载指定卷设备,以promise方式返回。当前仅支持fat、exfat以及ntfs三中文件系统的卷设备挂载。 **需要权限**:ohos.permission.MOUNT_UNMOUNT_MANAGER @@ -78,20 +80,22 @@ mount(volumeId: string): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ---- | - | volumeId | string | 是 | 卷id | + | volumeId | string | 是 | 卷设备id | **返回值:** | 类型 | 说明 | | ---------------------- | ---------- | - | Promise<void> | 挂载指定卷 | + | Promise<void> | 挂载指定卷设备 | **示例:** ```js let volumeId = ""; - volumemanager.mount(volumeId).then(function(flag){ + volumemanager.mount(volumeId).then(function(){ // do something + }).catch(function(error){ + console.info("mount failed"); }); ``` @@ -99,7 +103,7 @@ mount(volumeId: string): Promise<void> mount(volumeId: string, callback:AsyncCallback<void>):void -异步获取指定卷的可用空间大小,以callback方式返回。 +异步挂载指定卷设备,以callback方式返回。当前仅支持fat、exfat以及ntfs三中文件系统的卷设备挂载。 **需要权限**:ohos.permission.MOUNT_UNMOUNT_MANAGER @@ -109,14 +113,14 @@ mount(volumeId: string, callback:AsyncCallback<void>):void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------- | ---- | -------------------- | - | volumeId | string | 是 | 卷id | - | callback | AsyncCallback<void> | 是 | 挂载指定卷之后的回调 | + | volumeId | string | 是 | 卷设备id | + | callback | AsyncCallback<void> | 是 | 挂载指定卷设备之后的回调 | **示例:** ```js let volumeId = ""; - volumemanager.mount(volumeId, function(error, flag){ + volumemanager.mount(volumeId, function(error){ // do something }); ``` @@ -125,7 +129,7 @@ mount(volumeId: string, callback:AsyncCallback<void>):void unmount(volumeId: string): Promise<void> -异步卸载指定卷,以promise方式返回。 +异步卸载指定卷设备,以promise方式返回。 **需要权限**:ohos.permission.MOUNT_UNMOUNT_MANAGER @@ -135,20 +139,22 @@ unmount(volumeId: string): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ---- | - | volumeId | string | 是 | 卷id | + | volumeId | string | 是 | 卷设备id | **返回值:** | 类型 | 说明 | | ---------------------- | ---------- | - | Promise<void> | 卸载指定卷 | + | Promise<void> | 卸载指定卷设备 | **示例:** ```js let volumeId = ""; - volumemanager.unmount(volumeId).then(function(flag){ + volumemanager.unmount(volumeId).then(function(){ // do something + }).catch(function(error){ + console.info("mount failed"); }); ``` @@ -156,7 +162,7 @@ unmount(volumeId: string): Promise<void> unmount(volumeId: string, callback: AsyncCallback<void>): void -异步卸载指定卷,以callback方式返回。 +异步卸载指定卷设备,以callback方式返回。 **需要权限**:ohos.permission.MOUNT_UNMOUNT_MANAGER @@ -166,14 +172,14 @@ unmount(volumeId: string, callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------- | ---- | -------------------- | - | volumeId | string | 是 | 卷id | - | callback | AsyncCallback<void> | 是 | 卸载指定卷之后的回调 | + | volumeId | string | 是 | 卷设备id | + | callback | AsyncCallback<void> | 是 | 卸载指定卷设备之后的回调 | **示例:** ```js let volumeId = ""; - volumemanager.unmount(volumeId, function(error, flag){ + volumemanager.unmount(volumeId, function(error){ // do something }); ``` @@ -182,7 +188,7 @@ unmount(volumeId: string, callback: AsyncCallback<void>): void getVolumeByUuid(uuid: string): Promise<Volume> -异步通过uuid获得卷信息,以promise方式返回。 +异步通过卷设备uuid获得指定卷设备信息,以promise方式返回。 **需要权限**:ohos.permission.STORAGE_MANAGER @@ -192,13 +198,13 @@ getVolumeByUuid(uuid: string): Promise<Volume> | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ---- | - | uuid | string | 是 | 卷uuid | + | uuid | string | 是 | 卷设备uuid | **返回值:** | 类型 | 说明 | | ---------------------------------- | -------------------------- | - | Promise<[Volume](#volume)> | 返回当前所有可获得的卷信息 | + | Promise<[Volume](#volume)> | 返回当前所有可获得的卷设备信息 | **示例:** @@ -215,7 +221,7 @@ getVolumeByUuid(uuid: string): Promise<Volume> getVolumeByUuid(uuid: string, callback: AsyncCallback<Volume>): void -异步通过uuid获得卷信息,以callback方式返回。 +异步通过卷设备uuid获得指定卷设备信息,以callback方式返回。 **需要权限**:ohos.permission.STORAGE_MANAGER @@ -225,8 +231,8 @@ getVolumeByUuid(uuid: string, callback: AsyncCallback<Volume>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------ | ---- | -------------------- | - | uuid | string | 是 | 卷uuid | - | callback | AsyncCallback<[Volume](#volume)> | 是 | 获取卷信息之后的回调 | + | uuid | string | 是 | 卷设备uuid | + | callback | AsyncCallback<[Volume](#volume)> | 是 | 获取卷设备信息之后的回调 | **示例:** @@ -241,7 +247,7 @@ getVolumeByUuid(uuid: string, callback: AsyncCallback<Volume>): void getVolumeById(volumeId: string): Promise<Volume> -异步通过卷id获得卷信息,以promise方式返回。 +异步通过卷设备id获得指定卷设备信息,以promise方式返回。 **需要权限**:ohos.permission.STORAGE_MANAGER @@ -251,13 +257,13 @@ getVolumeById(volumeId: string): Promise<Volume> | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ---- | - | volumeId | string | 是 | 卷id | + | volumeId | string | 是 | 卷设备id | **返回值:** | 类型 | 说明 | | ---------------------------------- | -------------------------- | - | Promise<[Volume](#volume)> | 返回当前所有可获得的卷信息 | + | Promise<[Volume](#volume)> | 返回当前所有可获得的卷设备信息 | **示例:** @@ -274,7 +280,7 @@ getVolumeById(volumeId: string): Promise<Volume> getVolumeById(volumeId: string, callback: AsyncCallback<Volume>): void -异步通过卷id获得卷信息,以callback方式返回。 +异步通过指定卷设备id获得卷设备信息,以callback方式返回。 **需要权限**:ohos.permission.STORAGE_MANAGER @@ -284,8 +290,8 @@ getVolumeById(volumeId: string, callback: AsyncCallback<Volume>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ----------------------------- | - | volumeId | string | 是 | 卷id | - | callback | AsyncCallback<[Volume](#volume)> | 是 | 获取卷信息之后的回调 | + | volumeId | string | 是 | 卷设备id | + | callback | AsyncCallback<[Volume](#volume)> | 是 | 获取卷设备信息之后的回调 | **示例:** @@ -300,7 +306,7 @@ getVolumeById(volumeId: string, callback: AsyncCallback<Volume>): void setVolumeDescription(uuid: string, description: string): Promise<void> -异步通过uuid设置卷描述,以promise方式返回。 +异步修改指定卷设备描述,以promise方式返回。 **需要权限**:ohos.permission.MOUNT_UNMOUNT_MANAGER @@ -310,14 +316,14 @@ setVolumeDescription(uuid: string, description: string): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | ---- | - | uuid | string | 是 | 卷uuid | - | description | string | 是 | 卷描述 | + | uuid | string | 是 | 卷设备uuid | + | description | string | 是 | 卷设备描述 | **返回值:** | 类型 | 说明 | | ---------------------- | -------------------------- | - | Promise<void> | 设置卷信息 | + | Promise<void> | 设置卷设备信息 | **示例:** @@ -335,7 +341,7 @@ setVolumeDescription(uuid: string, description: string): Promise<void> setVolumeDescription(uuid: string, description: string, callback: AsyncCallback<void>): void -异步通过uuid设置卷描述,以callback方式返回。 +异步修改指定卷设备描述,以callback方式返回。 **需要权限**:ohos.permission.MOUNT_UNMOUNT_MANAGER @@ -345,8 +351,8 @@ setVolumeDescription(uuid: string, description: string, callback: AsyncCallback& | 参数名 | 类型 | 必填 | 说明 | | ---------- | --------------------------------------- | ---- | ---------------- | - | uuid | string | 是 | 卷uuid | - | description | string | 是 | 卷描述 | + | uuid | string | 是 | 卷设备uuid | + | description | string | 是 | 卷设备描述 | | callback | AsyncCallback<void> | 是 | 设置卷描述之后的回调 | **示例:** @@ -354,7 +360,7 @@ setVolumeDescription(uuid: string, description: string, callback: AsyncCallback& ```js let uuid = ""; let description = ""; - volumemanager.setVolumeDescription(uuid, description, (error, bool) => { + volumemanager.setVolumeDescription(uuid, description, (error) => { // do something }); ``` @@ -363,7 +369,7 @@ setVolumeDescription(uuid: string, description: string, callback: AsyncCallback& format(volumeId: string, fsType: string): Promise<void> -异步对指定卷进行格式化,以promise方式返回。 +异步对指定卷设备进行格式化,以promise方式返回。当前仅支持vfat和exfat两种文件系统类型的格式化,只有处于卸载状态的卷设备可以进行格式化,格式化后卷设备的uuid、挂载路径和卷设备描述均会发生变化。 **需要权限**:ohos.permission.MOUNT_FORMAT_MANAGER @@ -373,14 +379,14 @@ format(volumeId: string, fsType: string): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ---- | - | volumeId | string | 是 | 卷id | - | fsType | string | 是 | 文件系统类型 | + | volumeId | string | 是 | 卷设备id | + | fsType | string | 是 | 文件系统类型(vfat或者exfat) | **返回值:** | 类型 | 说明 | | ---------------------- | ---------- | - | Promise<void> | 对指定卷进行格式化 | + | Promise<void> | 对指定卷设备进行格式化 | **示例:** @@ -398,7 +404,7 @@ format(volumeId: string, fsType: string): Promise<void> format(volumeId: string, fsType: string, callback: AsyncCallback<void>): void -异步对指定卷进行格式化,以callback方式返回。 +异步对指定卷设备进行格式化,以callback方式返回。当前仅支持vfat和exfat两种文件系统类型的格式化,只有处于卸载状态的卷设备可以进行格式化,格式化后卷设备的uuid、挂载路径和卷设备描述均会发生变化。 **需要权限**:ohos.permission.MOUNT_FORMAT_MANAGER @@ -408,16 +414,16 @@ format(volumeId: string, fsType: string, callback: AsyncCallback<void>): v | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ----------------------------- | - | volumeId | string | 是 | 卷id | - | fsType | string | 是 | 文件系统类型 | - | callback | AsyncCallback<void> | 是 | 对指定卷格式化后的回调 | + | volumeId | string | 是 | 卷设备id | + | fsType | string | 是 | 文件系统类型(vfat或者exfat) | + | callback | AsyncCallback<void> | 是 | 对指定卷设备格式化后的回调 | **示例:** ```js let volumeId = ""; let fsType = ""; - volumemanager.format(volumeId, fsType, (error, bool) => { + volumemanager.format(volumeId, fsType, (error) => { // do something }); ``` @@ -426,7 +432,7 @@ format(volumeId: string, fsType: string, callback: AsyncCallback<void>): v partition(diskId: string, type: number): Promise<void> -异步对磁盘进行分区,以promise方式返回。 +异步对磁盘设备进行分区,以promise方式返回。当前仅支持将磁盘设备重新分区为一个分区,系统是支持读取多分区的磁盘设备。 **需要权限**:ohos.permission.MOUNT_FORMAT_MANAGER @@ -436,7 +442,7 @@ partition(diskId: string, type: number): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ---- | - | diskId | string | 是 | 卷所属的磁盘id | + | diskId | string | 是 | 卷设备所属的磁盘设备id | | type | number | 是 | 分区类型 | **返回值:** @@ -461,7 +467,7 @@ partition(diskId: string, type: number): Promise<void> partition(diskId: string, type: number, callback: AsyncCallback<void>): void -异步对磁盘进行分区,以callback方式返回。 +异步对磁盘进行分区,以callback方式返回。当前仅支持将磁盘设备重新分区为一个分区,系统是支持读取多分区的磁盘设备。 **需要权限**:ohos.permission.MOUNT_FORMAT_MANAGER @@ -471,16 +477,16 @@ partition(diskId: string, type: number, callback: AsyncCallback<void>): vo | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------- | ---- | ---------------- | - | diskId | string | 是 | 卷所属的磁盘id | + | diskId | string | 是 | 卷设备所属的磁盘id | | type | number | 是 | 分区类型 | - | callback | AsyncCallback<void> | 是 | 对磁盘进行分区 | + | callback | AsyncCallback<void> | 是 | 对磁盘设备进行分区 | **示例:** ```js let diskId = ""; let type = 0; - volumemanager.partition(diskId, type, (error, bool) => { + volumemanager.partition(diskId, type, (error) => { // do something }); ``` @@ -493,10 +499,10 @@ partition(diskId: string, type: number, callback: AsyncCallback<void>): vo | 名称 | 类型 | 可读 | 可写 | 说明 | | ----------- | ------- | ------- | ----- | -------------------- | -| id | string | 是 | 否 | 卷id | -| uuid | string | 是 | 否 | 卷uuid | -| diskId | string | 是 | 否 | 卷所属的磁盘id | -| description | string | 是 | 否 | 卷相关描述 | -| removable | boolean | 是 | 否 | 是否为可移动存储设备 | -| state | number | 是 | 否 | 当前卷状态 | -| path | string | 是 | 否 | 卷的挂载地址 | \ No newline at end of file +| id | string | 是 | 否 | 卷设备ID的格式为vol-{主设备号}-{次设备号},主设备号用来区分不同种类的设备,次设备号用来区分同一类型的多个设备,卷设备ID会随着插卡顺序不同而变化。 | +| uuid | string | 是 | 否 | 卷设备uuid是卷设备的通用唯一识别码,不会随着插卡顺序变化而变化,但是卷设备的格式化会改变卷设备的uuid | +| diskId | string | 是 | 否 | 卷设备所属的磁盘ID,一个磁盘可以有一个或者多个卷设备。磁盘设备ID好格式为disk-{主设备号}-{次设备号},与卷设备ID相似。 | +| description | string | 是 | 否 | 卷设备描述、 | +| removable | boolean | 是 | 否 | 表示卷设备是否可移除,当前仅支持可移除存储设备、 | +| state | number | 是 | 否 | 卷设备状态标识:
0:卸载状态 UNMOUNTED
1:检查状态 CHECKING
2:挂载状态 MOUNTED
3:正在弹出状态 EJECTING | +| path | string | 是 | 否 | 卷设备的挂载地址,一般为/mnt/external/{uuid} | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileShare.md b/zh-cn/application-dev/reference/apis/js-apis-fileShare.md new file mode 100644 index 0000000000000000000000000000000000000000..bf8700d75fd6c63c15fe868a0f15ad8ae8da3823 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-fileShare.md @@ -0,0 +1,119 @@ +# @ohos.fileShare (文件分享) + +该模块提供文件分享能力,提供系统应用将公共目录文件统一资源标志符(Uniform Resource Identifier,URI)以读写权限授权给其他应用的接口,授权后应用可通过[@ohos.file.fs](js-apis-file-fs.md)的相关接口进行相关open、read、write等操作,实现文件分享。 + +> **说明:** +> - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```js +import fileShare from '@ohos.fileShare'; +``` + +## fileShare.grantUriPermission + +grantUriPermission(uri: string, bundleName: string, mode: number, callback: AsyncCallback<void>): void + +对公共目录文件URI进行授权操作,使用callback异步回调。 +**需要权限**:ohos.permission.WRITE_MEDIA +**系统接口**:此接口为系统接口 +**系统能力**:SystemCapability.FileManagement.AppFileService + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------------- | +| uri | string | 是 | 公共目录文件URI | +| bundleName | string | 是 | 分享目标的包名 | +| mode | number | 是 | 授权的权限,参考[wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags)
wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION:读授权
wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION:写授权| + | callback | AsyncCallback<void> | 是 | 异步授权之后的回调 | + +**错误码:** + +以下错误码的详细介绍请参见[文件管理子系统错误码](../errorcodes/errorcode-filemanagement.md#错误码适配指导) + + | 错误码ID | 错误信息 | + | ---------------------------- | ---------- | + | 201 | Permission verification failed | + | 202 | The caller is not a system application | + | 401 | The input parameter is invalid | + | 143000001 | IPC error | + + +**示例:** + + ```js +import wantConstant from '@ohos.app.ability.wantConstant'; + + +let uri = 'datashare:///media/image/8'; +let bundleName = 'com.demo.test'; +try { + fileShare.grantUriPermission(uri, bundleName, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION | wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION, (err) => { + if (err) { + console.error("grantUriPermission failed with error: " + err); + return; + } + console.info("grantUriPermission success!"); + }); +} catch (error) { + console.error("grantUriPermission failed with error:" + error); +} + ``` + + +## fileShare.grantUriPermission + +grantUriPermission(uri: string, bundleName: string, mode: number): Promise<void> + +将公共目录文件URI进行授权操作,使用Promise异步回调。 +**需要权限**:ohos.permission.WRITE_MEDIA +**系统接口**:此接口为系统接口 +**系统能力**:SystemCapability.FileManagement.AppFileService + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------------- | +| uri | string | 是 | 公共目录文件URI | +| bundleName | string | 是 | 分享目标的包名 | +| mode | number | 是 | 授权的权限,参考[wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags)
wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION:读授权
wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION:写授权| + +**返回值:** + + | 类型 | 说明 | + | ---------------------------- | ---------- | + | Promise<void> | Promise对象,无返回值 | + + +**错误码:** + +以下错误码的详细介绍请参见[文件管理子系统错误码](../errorcodes/errorcode-filemanagement.md#错误码适配指导) + + | 错误码ID | 错误信息 | + | ---------------------------- | ---------- | + | 201 | Permission verification failed | + | 202 | The caller is not a system application | + | 401 | The input parameter is invalid | + | 143000001 | IPC error | + + +**示例:** + + ```js +import wantConstant from '@ohos.app.ability.wantConstant'; + +let uri = 'datashare:///media/image/8'; +let bundleName = 'com.demo.test'; +try { + fileShare.grantUriPermission(uri, bundleName, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION | + wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION).then(function () { + console.info("grantUriPermission success!"); + }).catch(function (error) { + console.error("grantUriPermission failed with error:" + error); + }); +} catch (error) { + console.error("grantUriPermission failed with error:" + error); +} + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-freeInstall.md b/zh-cn/application-dev/reference/apis/js-apis-freeInstall.md index b5b7d4ac44a91d873c07827c3cd0e9b6dd4541e2..82865a328dca54530c4e2bd1af0725ac909369ff 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-freeInstall.md +++ b/zh-cn/application-dev/reference/apis/js-apis-freeInstall.md @@ -299,7 +299,7 @@ try { getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag): Promise\; -基于bundleName和bundleFlag来获取bundlePackInfo。使用Promise异步回调。 +基于bundleName和BundlePackFlag来获取bundlePackInfo。使用Promise异步回调。 **系统接口:** 此接口为系统接口。 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 afdc43e1e0896d996ac9512e096c6feef6666800..fbab7e810ae3f24faec4eb4d2a5f190ff145b6a4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-http.md +++ b/zh-cn/application-dev/reference/apis/js-apis-http.md @@ -332,7 +332,7 @@ httpRequest.destroy(); ### request210+ -request2(url: string, callback: AsyncCallback\): void +request2(url: string, callback: AsyncCallback\): void 根据URL地址和相关配置项,发起HTTP网络请求并返回流式响应,使用callback方式作为异步方法。 @@ -345,7 +345,7 @@ request2(url: string, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------------- | ---- | ----------------------------------------------- | | url | string | 是 | 发起网络请求的URL地址。 | -| callback | AsyncCallback\ | 是 | 回调函数。 | +| callback | AsyncCallback\<[number](#responsecode)\> | 是 | 回调函数。 | **错误码:** @@ -366,9 +366,9 @@ request2(url: string, callback: AsyncCallback\): void **示例:** ```js -httpRequest.request2("EXAMPLE_URL", (err) => { +httpRequest.request2("EXAMPLE_URL", (err, data) => { if (!err) { - console.info("request2 OK!"); + console.info("request2 OK! ResponseCode is " + JSON.stringify(data)); } else { console.info("request2 ERROR : err = " + JSON.stringify(err)); } @@ -377,7 +377,7 @@ httpRequest.request2("EXAMPLE_URL", (err) => { ### request210+ -request2(url: string, options: HttpRequestOptions, callback: AsyncCallback\): void +request2(url: string, options: HttpRequestOptions, callback: AsyncCallback\): void 根据URL地址和相关配置项,发起HTTP网络请求并返回流式响应,使用callback方式作为异步方法。 @@ -391,7 +391,7 @@ request2(url: string, options: HttpRequestOptions, callback: AsyncCallback\ | 是 | 回调函数。 | +| callback | AsyncCallback\<[number](#responsecode)\> | 是 | 回调函数。 | **错误码:** @@ -444,9 +444,9 @@ httpRequest.request2("EXAMPLE_URL", }, readTimeout: 60000, connectTimeout: 60000 -}, (err) => { +}, (err, data) => { if (!err) { - console.info("request2 OK!"); + console.info("request2 OK! ResponseCode is " + JSON.stringify(data)); } else { console.info("request2 ERROR : err = " + JSON.stringify(err)); } @@ -454,7 +454,7 @@ httpRequest.request2("EXAMPLE_URL", ``` ### request210+ -request2(url: string, options? : HttpRequestOptions): Promise\ +request2(url: string, options? : HttpRequestOptions): Promise\ 根据URL地址,发起HTTP网络请求并返回流式响应,使用Promise方式作为异步方法。 @@ -473,7 +473,7 @@ request2(url: string, options? : HttpRequestOptions): Promise\ | 类型 | 说明 | | :------------------------------------- | :-------------------------------- | -| Promise\ | 以Promise形式返回发起请求的结果。 | +| Promise\<[number](#responsecode)\> | 以Promise形式返回发起请求的结果。 | **错误码:** @@ -526,8 +526,8 @@ let promise = httpRequest.request("EXAMPLE_URL", { 'Content-Type': 'application/json' } }); -promise.then(() => { - console.info("request2 OK!"); +promise.then((data) => { + console.info("request2 OK!" + JSON.stringify(data)); }).catch((err) => { console.info("request2 ERROR : err = " + JSON.stringify(err)); }); 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 d7c79dfb6b106fe077fa7ecd50646322b6483253..4619c537101ab040caeb87d2067f32e419988914 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-huks.md +++ b/zh-cn/application-dev/reference/apis/js-apis-huks.md @@ -926,7 +926,7 @@ exportKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\ | 是 | 回调函数。返回HUKS_SUCCESS时表示接口使用成功,其他时为错误。outData:返回从密钥中导出的公钥。 | +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。不返回err值时表示接口使用成功,其他时为错误。outData:返回从密钥中导出的公钥。 | **示例:** @@ -1005,7 +1005,7 @@ getKeyItemProperties(keyAlias: string, options: HuksOptions, callback: AsyncCall | -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | 是 | 密钥别名,应与所用密钥生成时使用的别名相同。 | | options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | -| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。errorCode:返回HUKS_SUCCESS时表示接口使用成功,其他时为错误。 | +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。不返回err值时表示接口使用成功,其他时为错误。properties:返回值为生成密钥时所需参数。 | **示例:** @@ -1161,9 +1161,9 @@ initSession操作密钥接口,使用Callback回调异步返回结果。huks.in | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------- | ---- | ---------------------------------------------------- | -| keyAlias | string | 是 | Init操作密钥的别名。 | -| options | [HuksOptions](#huksoptions) | 是 | Init操作的参数集合。 | -| callback | AsyncCallback\<[HuksSessionHandle](#hukssessionhandle9)> | 是 | 回调函数。将Init操作操作返回的handle添加到密钥管理系统的回调。 | +| keyAlias | string | 是 | initSession操作密钥的别名。 | +| options | [HuksOptions](#huksoptions) | 是 | initSession操作的参数集合。 | +| callback | AsyncCallback\<[HuksSessionHandle](#hukssessionhandle9)> | 是 | 回调函数。将initSession操作返回的handle添加到密钥管理系统的回调。 | ## huks.initSession9+ @@ -1177,14 +1177,14 @@ initSession操作密钥接口,使用Promise方式异步返回结果。huks.ini | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------- | ---- | ------------------------------------------------ | -| keyAlias | string | 是 | Init操作密钥的别名。 | -| options | [HuksOptions](#huksoptions) | 是 | Init参数集合。 | +| keyAlias | string | 是 | initSession操作密钥的别名。 | +| options | [HuksOptions](#huksoptions) | 是 | initSession参数集合。 | **返回值**: | 类型 | 说明 | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksSessionHandle](#hukssessionhandle9)> | Promise对象。将Init操作返回的handle添加到密钥管理系统的回调。 | +| Promise\<[HuksSessionHandle](#hukssessionhandle9)> | Promise对象。将initSession操作返回的handle添加到密钥管理系统的回调。 | ## huks.updateSession9+ @@ -1198,9 +1198,9 @@ updateSession操作密钥接口,使用Callback回调异步返回结果。huks. | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------------------- | ---- | -------------------------------------------- | -| handle | number | 是 | Update操作的handle。 | -| options | [HuksOptions](#huksoptions) | 是 | Update的参数集合。 | -| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将Update操作的结果添加到密钥管理系统的回调。 | +| handle | number | 是 | updateSession操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | updateSession的参数集合。 | +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将updateSession操作的结果添加到密钥管理系统的回调。 | ## huks.updateSession9+ @@ -1215,16 +1215,16 @@ updateSession操作密钥接口,使用Callback回调异步返回结果。huks. | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------------------- | ---- | -------------------------------------------- | -| handle | number | 是 | Update操作的handle。 | -| options | [HuksOptions](#huksoptions) | 是 | Update操作的参数集合。 | -| token | Uint8Array | 是 | Update操作的token。 | -| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将Update操作的结果添加到密钥管理系统的回调。 | +| handle | number | 是 | updateSession操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | updateSession操作的参数集合。 | +| token | Uint8Array | 是 | updateSession操作的token。 | +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将updateSession操作的结果添加到密钥管理系统的回调。 | ## huks.updateSession9+ updateSession(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\ -uupdateSession操作密钥接口,使用Promise方式异步返回结果。huks.initSession, huks.updateSession, huks.finishSession为三段式接口,需要一起使用。 +updateSession操作密钥接口,使用Promise方式异步返回结果。huks.initSession, huks.updateSession, huks.finishSession为三段式接口,需要一起使用。 **系统能力**:SystemCapability.Security.Huks @@ -1232,15 +1232,15 @@ uupdateSession操作密钥接口,使用Promise方式异步返回结果。huks. | 参数名 | 类型 | 必填 | 说明 | | ------- | ---------------------------------------------- | ---- | -------------------------------------------- | -| handle | number | 是 | Update操作的handle。 | -| options | [HuksOptions](#huksoptions) | 是 | Update操作的参数集合。 | -| token | Uint8Array | 否 | Update操作的token。 | +| handle | number | 是 | updateSession操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | updateSession操作的参数集合。 | +| token | Uint8Array | 否 | updateSession操作的token。 | **返回值**: | 类型 | 说明 | | ----------------------------------- | -------------------------------------------------- | -| Promise<[HuksReturnResult](#huksreturnresult9)> | Promise对象。将Update操作的结果添加到密钥管理系统的回调。 | +| Promise<[HuksReturnResult](#huksreturnresult9)> | Promise对象。将updateSession操作的结果添加到密钥管理系统的回调。 | ## huks.finishSession9+ @@ -1254,10 +1254,10 @@ finishSession操作密钥接口,使用Callback回调异步返回结果。huks. | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------------------- | ---- | -------------------------------------------- | -| handle | number | 是 | Finish操作的handle。 | -| options | [HuksOptions](#huksoptions) | 是 | Finish的参数集合。 | -| token | Uint8Array | 是 | Finish操作的token。 | -| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将Finish操作的结果添加到密钥管理系统的回调。 | +| handle | number | 是 | finishSession操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | finishSession的参数集合。 | +| token | Uint8Array | 是 | finishSession操作的token。 | +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将finishSession操作的结果添加到密钥管理系统的回调。 | ## huks.finishSession9+ @@ -1271,10 +1271,10 @@ finishSession操作密钥接口,使用Callback回调异步返回结果。huks. | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------------------- | ---- | -------------------------------------------- | -| handle | number | 是 | Finish操作的handle。 | -| options | [HuksOptions](#huksoptions) | 是 | Finish的参数集合。 | -| token | Uint8Array | 是 | Finish操作的token。 | -| callback | AsyncCallback\<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将Finish操作的结果添加到密钥管理系统的回调。 | +| handle | number | 是 | finishSession操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | finishSession的参数集合。 | +| token | Uint8Array | 是 | finishSession操作的token。 | +| callback | AsyncCallback\<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将finishSession操作的结果添加到密钥管理系统的回调。 | ## huks.finishSession9+ @@ -1288,9 +1288,9 @@ finishSession操作密钥接口,使用Promise方式异步返回结果。huks.i | 参数名 | 类型 | 必填 | 说明 | | ------- | ----------------------------------------------- | ---- | ----------------------------------- | -| handle | number | 是 | Finish操作的handle。 | -| options | [HuksOptions](#huksoptions) | 是 | Finish操作的参数集合。 | -| token | Uint8Array | 否 | Finish操作的token。 | +| handle | number | 是 | finishSession操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | finishSession操作的参数集合。 | +| token | Uint8Array | 否 | finishSession操作的token。 | **返回值**: @@ -1302,7 +1302,7 @@ finishSession操作密钥接口,使用Promise方式异步返回结果。huks.i abortSession(handle: number, options: HuksOptions, callback: AsyncCallback\) : void -abort操作密钥接口,使用Callback回调异步返回结果 。 +abortSession操作密钥接口,使用Callback回调异步返回结果 。 **系统能力**:SystemCapability.Security.Huks @@ -1310,9 +1310,9 @@ abort操作密钥接口,使用Callback回调异步返回结果 。 | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------------------------- | -| handle | number | 是 | Abort操作的handle。 | -| options | [HuksOptions](#huksoptions) | 是 | Abort操作的参数集合。 | -| callback | AsyncCallback\ | 是 | 回调函数。将Abort操作的结果添加到密钥管理系统的回调。 | +| handle | number | 是 | abortSession操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | abortSession操作的参数集合。 | +| callback | AsyncCallback\ | 是 | 回调函数。将abortSession操作的结果添加到密钥管理系统的回调。 | **示例:** @@ -1447,7 +1447,7 @@ async function huksAbort() { abortSession(handle: number, options: HuksOptions) : Promise\; -abort操作密钥接口,使用Promise方式异步返回结果。 +abortSession操作密钥接口,使用Promise方式异步返回结果。 **系统能力**:SystemCapability.Security.Huks @@ -1455,14 +1455,14 @@ abort操作密钥接口,使用Promise方式异步返回结果。 | 参数名 | 类型 | 必填 | 说明 | | ------- | --------------------------- | ---- | ------------------------------------------- | -| handle | number | 是 | Abort操作的handle。 | -| options | [HuksOptions](#huksoptions) | 是 | Abort操作的参数集合。 | +| handle | number | 是 | abortSession操作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | abortSession操作的参数集合。 | **返回值**: | 类型 | 说明 | | ----------------------------------- | -------------------------------------------------- | -| Promise\ | Promise对象。将Abort操作的结果添加到密钥管理系统的回调。 | +| Promise\ | Promise对象。将abortSession操作的结果添加到密钥管理系统的回调。 | **示例:** 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 c2e88eeed1b761482ec958b0add5357f69c07fbc..1ab0f3ee0be051fe56bb233261285db7f0c3b5ea 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-i18n.md +++ b/zh-cn/application-dev/reference/apis/js-apis-i18n.md @@ -2112,6 +2112,75 @@ static getDateOrder(locale: string): string ``` +## Normalizer10+ + +### getInstance10+ + +static getInstance(mode: NormalizerMode): Normalizer + +获取文本正则化对象。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------- | +| mode | [NormalizerMode](#normalizermode10) | 是 | 文本正则化范式。 | + +**返回值:** + +| 类型 | 说明 | +| ------ | ------------------- | +| [Normalizer](#normalizer10) | 返回指定范式的文本正则化对象。 | + +**示例:** + ```js + let normalizer = I18n.Normalizer.getInstance(I18n.NormalizerMode.NFC); + ``` + + +### normalize10+ + +normalize(text: string): string + +对字符串进行正则化。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------- | +| text | string | 是 | 待正则化的字符串。 | + +**返回值:** + +| 类型 | 说明 | +| ------ | ------------------- | +| string | 正则化后的字符串。 | + +**示例:** + ```js + let normalizer = I18n.Normalizer.getInstance(I18n.NormalizerMode.NFC); + let normalizedText = normalizer.normalize('\u1E9B\u0323'); // normalizedText = \u1E9B\u0323 + ``` + + +## NormalizerMode10+ + +表示文本正则化范式的枚举。 + +**系统能力:** :SystemCapability.Global.I18n + +| 名称 | 值 | 说明 | +| -------- | -------- | -------- | +| NFC | 1 | NFC范式。 | +| NFD | 2 | NFD范式。 | +| NFKC | 3 | NFKC范式。 | +| NFKD | 4 | NFKD范式。 | + + ## I18n.getDisplayCountry(deprecated) getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-ability-want.md b/zh-cn/application-dev/reference/apis/js-apis-inner-ability-want.md index b9a0005234e5543cd7def7eb9967827d8e6a3f99..e37ad10f026c01739eb8f354723a3f917ded9326 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-ability-want.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-ability-want.md @@ -17,7 +17,7 @@ Want是对象间信息传递的载体, 可以用于应用组件间的信息传 | type | string | 否 | 表示MIME type类型,打开文件的类型,主要用于文管打开文件。比如:'text/xml' 、 'image/*'等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 | | flags | number | 否 | 表示处理Want的方式。默认传数字,具体参考:[flags说明](js-apis-ability-wantConstant.md#wantConstant.Flags)。 | | action | string | 否 | 表示要执行的通用操作(如:查看、分享、应用详情)。在隐式Want中,您可以定义该字段,配合uri或parameters来表示对数据要执行的操作。具体参考:[action说明](js-apis-app-ability-wantConstant.md#wantConstant.Action)。隐式Want定义及匹配规则参考:[显式Want与隐式Want匹配规则](application-models/explicit-implicit-want-mappings.md)。 | -| parameters | {[key: string]: any} | 否 | 表示WantParams,由开发者自行决定传入的键值对。默认会携带以下key值:
ohos.aafwk.callerPid 表示拉起方的pid。
ohos.aafwk.param.callerToken 表示拉起方的token。
ohos.aafwk.param.callerUid 表示[bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。
- component.startup.newRules:表示是否启用新的管控规则。
- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。
- ohos.dlp.params.sandbox:表示dlp文件才会有。 | +| parameters | {[key: string]: Object} | 否 | 表示WantParams,由开发者自行决定传入的键值对。默认会携带以下key值:
ohos.aafwk.callerPid 表示拉起方的pid。
ohos.aafwk.param.callerToken 表示拉起方的token。
ohos.aafwk.param.callerUid 表示[bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。
- component.startup.newRules:表示是否启用新的管控规则。
- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。
- ohos.dlp.params.sandbox:表示dlp文件才会有。 | | entities | Array\ | 否 | 表示目标Ability额外的类别信息(如:浏览器、视频播放器),在隐式Want中是对action字段的补充。在隐式Want中,您可以定义该字段,来过滤匹配Ability类型。具体参考:[entity说明](js-apis-app-ability-wantConstant.md#wantConstant.Entity)。 | | moduleName9+ | string | 否 | 表示待启动的Ability所属的模块(module)。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md index 1f45af02032486ff5cc5b4ad33ed54438a637a3f..9546f6d83aa87a3ad7730441518eed5b8a93a58d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md @@ -57,7 +57,7 @@ class EntryAbility extends AccessibilityExtensionAbility { **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ | ---- | ---- | --------- | | left | number | 是 | 否 | 矩形区域的左边界。 | | top | number | 是 | 否 | 矩形区域的上边界。 | @@ -85,14 +85,14 @@ setTargetBundleName(targetNames: Array\): Promise\; **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------- | ---- | -------- | | targetNames | Array<string> | 是 | 关注的目标包名。 | **返回值:** -| 类型 | 说明 | -| ---------------------- | --------------------- | +| 类型 | 说明 | +| ------------------- | ---------------- | | Promise<void> | 无返回结果的Promise对象。 | **示例:** @@ -120,9 +120,9 @@ setTargetBundleName(targetNames: Array\, callback: AsyncCallback\) **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------- | ---- | -------- | -| targetNames | Array<string> | 是 | 关注的目标包名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | ---------------------------------------- | +| targetNames | Array<string> | 是 | 关注的目标包名。 | | callback | AsyncCallback<void> | 是 | 回调函数,如果设置关注的目标包名失败,则AsyncCallback中err有数据返回。 | **示例:** @@ -152,7 +152,7 @@ getFocusElement(isAccessibilityFocus?: boolean): Promise\; **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------------------- | ------- | ---- | ------------------- | | isAccessibilityFocus | boolean | 否 | 获取的是否是无障碍焦点元素,默认为否。 | @@ -166,8 +166,8 @@ getFocusElement(isAccessibilityFocus?: boolean): Promise\; 以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。 -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------- | | 9300003 | Do not have accessibility right for this operation. | **示例:** @@ -196,16 +196,16 @@ getFocusElement(callback: AsyncCallback\): void; **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<AccessibilityElement> | 是 | 回调函数,返回当前对应的焦点元素。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ----------------- | +| callback | AsyncCallback<AccessibilityElement> | 是 | 回调函数,返回当前对应的焦点元素。 | **错误码:** 以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。 -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------- | | 9300003 | Do not have accessibility right for this operation. | **示例:** @@ -236,10 +236,10 @@ getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback\; **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------------- | ------- | ---- | ------------------- | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------------- | | windowId | number | 否 | 指定窗口的编号,未指定则从当前活跃窗口获取。 | **返回值:** @@ -283,8 +283,8 @@ getWindowRootElement(windowId?: number): Promise\; 以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。 -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------- | | 9300003 | Do not have accessibility right for this operation. | **示例:** @@ -313,16 +313,16 @@ getWindowRootElement(callback: AsyncCallback\): void; **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<AccessibilityElement> | 是 | 回调函数,返回指定窗口的根节点元素。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------ | +| callback | AsyncCallback<AccessibilityElement> | 是 | 回调函数,返回指定窗口的根节点元素。 | **错误码:** 以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。 -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------- | | 9300003 | Do not have accessibility right for this operation. | **示例:** @@ -353,17 +353,17 @@ getWindowRootElement(windowId: number, callback: AsyncCallback\>; **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------------- | ------- | ---- | ------------------- | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | --------------------- | | displayId | number | 否 | 指定的屏幕编号,未指定则从默认主屏幕获取。 | **返回值:** -| 类型 | 说明 | -| ----------------------------------- | ---------------------- | +| 类型 | 说明 | +| ---------------------------------------- | ---------------------- | | Promise<Array<AccessibilityElement>> | Promise对象,返回指定屏幕的所有窗口。 | **错误码:** 以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。 -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------- | | 9300003 | Do not have accessibility right for this operation. | **示例:** @@ -439,16 +439,16 @@ getWindows(callback: AsyncCallback\>): void; **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<Array<AccessibilityElement>> | 是 | 回调函数,返回指定屏幕的所有窗口。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ----------------- | +| callback | AsyncCallback<Array<AccessibilityElement>> | 是 | 回调函数,返回指定屏幕的所有窗口。 | **错误码:** 以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。 -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------- | | 9300003 | Do not have accessibility right for this operation. | **示例:** @@ -479,17 +479,17 @@ getWindows(displayId: number, callback: AsyncCallback\; **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ---------------------------------------- | ---- | -------------- | -| gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | 是 | 表示手势的路径信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ---------------------------------------- | ---- | ---------- | +| gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | 是 | 表示手势的路径信息。 | **返回值:** -| 类型 | 说明 | -| ----------------------------------- | ---------------------- | +| 类型 | 说明 | +| ------------------- | ---------------- | | Promise<void> | 无返回结果的Promise对象。 | **错误码:** 以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。 -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------- | | 9300003 | Do not have accessibility right for this operation. | **示例:** @@ -569,17 +569,17 @@ injectGesture(gesturePath: GesturePath, callback: AsyncCallback\): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ---------------------------------------- | ---- | -------------- | -| gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | 是 | 表示手势的路径信息。 | -| callback | AsyncCallback<void> | 是 | 回调函数,表示注入手势执行结果的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ---------------------------------------- | ---- | ------------------- | +| gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | 是 | 表示手势的路径信息。 | +| callback | AsyncCallback<void> | 是 | 回调函数,表示注入手势执行结果的回调。 | **错误码:** 以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。 -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------- | | 9300003 | Do not have accessibility right for this operation. | **示例:** @@ -620,8 +620,8 @@ attributeNames\(): Promise\>; **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ------------------------ | +| 类型 | 说明 | +| ----------------------------- | ------------------------ | | Promise<Array<T>> | Promise对象,返回节点元素的所有属性名称。 | **示例:** @@ -646,9 +646,9 @@ attributeNames\(callback: AsyncCallback\ **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ---------------------------------------- | ---- | -------------- | -| callback | AsyncCallback<Array<T>> | 是 | 回调函数,返回节点元素的所有属性名称。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------- | ---- | ------------------- | +| callback | AsyncCallback<Array<T>> | 是 | 回调函数,返回节点元素的所有属性名称。 | **示例:** @@ -674,22 +674,22 @@ attributeValue\(attributeName: T): Promi **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ---------------------------------------- | ---- | -------------- | -| attributeName | T | 是 | 表示属性的名称。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ---- | ---- | -------- | +| attributeName | T | 是 | 表示属性的名称。 | **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ------------------------ | +| 类型 | 说明 | +| ---------------------------------------- | --------------------------- | | Promise<ElementAttributeValues[T]> | Promise对象,返回根据节点属性名称获取的属性值。 | **错误码:** 以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。 -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | +| 错误码ID | 错误信息 | +| ------- | ----------------------------- | | 9300004 | This property does not exist. | **示例:** @@ -720,17 +720,17 @@ attributeValue\(attributeName: T, **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ---------------------------------------- | ---- | -------------- | -| attributeName | T | 是 | 表示属性的名称。 | -| callback | AsyncCallback<ElementAttributeValues[T]> | 是 | 回调函数,返回根据节点属性名称获取的属性值。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ---------------------------------------- | ---- | ---------------------- | +| attributeName | T | 是 | 表示属性的名称。 | +| callback | AsyncCallback<ElementAttributeValues[T]> | 是 | 回调函数,返回根据节点属性名称获取的属性值。 | **错误码:** 以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。 -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | +| 错误码ID | 错误信息 | +| ------- | ----------------------------- | | 9300004 | This property does not exist. | **示例:** @@ -762,8 +762,8 @@ actionNames(): Promise\>; **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ------------------------ | +| 类型 | 说明 | +| ---------------------------------- | -------------------------- | | Promise<Array<string>> | Promise对象,返回节点元素支持的所有操作名称。 | **示例:** @@ -788,9 +788,9 @@ actionNames(callback: AsyncCallback\>): void; **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ---------------------------------------- | ---- | -------------- | -| callback | AsyncCallback<Array<string>> | 是 | 回调函数,返回节点元素支持的所有操作名称。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | --------------------- | +| callback | AsyncCallback<Array<string>> | 是 | 回调函数,返回节点元素支持的所有操作名称。 | **示例:** @@ -819,20 +819,20 @@ performAction(actionName: string, parameters?: object): Promise\; | 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | actionName | string | 是 | 表示属性的名称,取值参考[Action](./js-apis-accessibility.md#action)。 -| parameters | object | 否 | 表示执行操作时所需要的参数。 | +| parameters | object | 否 | 表示执行操作时所需要的参数;当前版本暂不支持。 | **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ------------------------ | +| 类型 | 说明 | +| ------------------- | ---------------- | | Promise<void> | 无返回结果的Promise对象。 | **错误码:** 以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。 -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | +| 错误码ID | 错误信息 | +| ------- | ----------------------------- | | 9300005 | This action is not supported. | **示例:** @@ -868,8 +868,8 @@ performAction(actionName: string, callback: AsyncCallback\): void; 以下错误码的详细介绍请参见[无障碍子系统错误码](../errorcodes/errorcode-accessibility.md)。 -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | +| 错误码ID | 错误信息 | +| ------- | ----------------------------- | | 9300005 | This action is not supported. | **示例:** @@ -898,18 +898,18 @@ performAction(actionName: string, parameters: object, callback: AsyncCallback\; | 16000009 | Can not start ability in wukong mode. | | 16000010 | Can not operation with continue flag. | | 16000011 | Context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000051 | Network error. The network is abnormal. | | 16000052 | Free install not support. The application does not support freeinstall | | 16000053 | Not top ability. The application is not top ability. | @@ -195,6 +198,7 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void& | 16000009 | Can not start ability in wukong mode. | | 16000010 | Can not operation with continue flag. | | 16000011 | Context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000051 | Network error. The network is abnormal. | | 16000052 | Free install not support. The application does not support freeinstall | | 16000053 | Not top ability. The application is not top ability. | @@ -271,6 +275,7 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\< | 16000009 | Can not start ability in wukong mode. | | 16000010 | Can not operation with continue flag. | | 16000011 | Context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000051 | Network error. The network is abnormal. | | 16000052 | Free install not support. The application does not support freeinstall | | 16000053 | Not top ability. The application is not top ability. | @@ -346,6 +351,7 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca | 16000009 | Can not start ability in wukong mode. | | 16000010 | Can not operation with continue flag. | | 16000011 | Context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000051 | Network error. The network is abnormal. | | 16000052 | Free install not support. The application does not support freeinstall | | 16000053 | Not top ability. The application is not top ability. | @@ -430,6 +436,7 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): | 16000009 | Can not start ability in wukong mode. | | 16000010 | Can not operation with continue flag. | | 16000011 | Context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000051 | Network error. The network is abnormal. | | 16000052 | Free install not support. The application does not support freeinstall | | 16000053 | Not top ability. The application is not top ability. | @@ -1093,7 +1100,10 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; abilityName: 'MyAbility' }; let options = { - onConnect(elementName, remote) { console.log('----------- onConnect -----------') }, + onConnect(elementName, remote) { + commRemote = remote; + console.log('----------- onConnect -----------'); + }, onDisconnect(elementName) { console.log('----------- onDisconnect -----------') }, onFailed(code) { console.error('----------- onFailed -----------') } }; @@ -1154,7 +1164,10 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options }; let accountId = 100; let options = { - onConnect(elementName, remote) { console.log('----------- onConnect -----------'); }, + onConnect(elementName, remote) { + commRemote = remote; + console.log('----------- onConnect -----------'); + }, onDisconnect(elementName) { console.log('----------- onDisconnect -----------'); }, onFailed(code) { console.log('----------- onFailed -----------'); } }; @@ -1172,7 +1185,7 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback<void>): void; -将一个Ability与绑定的服务类型的Ability解绑。 +将一个Ability与绑定的服务类型的Ability解绑,断开连接之后需要将连接成功时返回的remote对象置空。 **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -1204,6 +1217,7 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback< try { this.context.disconnectServiceExtensionAbility(connection, (error) => { + commRemote = null; if (error.code) { // 处理业务逻辑错误 console.error('disconnectServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); @@ -1213,6 +1227,7 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback< console.log('disconnectServiceExtensionAbility succeed'); }); } catch (paramError) { + commRemote = null; // 处理入参错误异常 console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); } @@ -1222,7 +1237,7 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback< disconnectServiceExtensionAbility(connection: number): Promise<void>; -将一个Ability与绑定的服务类型的Ability解绑。通过Promise返回结果。 +将一个Ability与绑定的服务类型的Ability解绑,断开连接之后需要将连接成功时返回的remote对象置空(Promise形式返回结果)。 **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -1260,14 +1275,17 @@ disconnectServiceExtensionAbility(connection: number): Promise<void>; try { this.context.disconnectServiceExtensionAbility(connection) .then((data) => { + commRemote = null; // 执行正常业务 console.log('disconnectServiceExtensionAbility succeed'); }) .catch((error) => { + commRemote = null; // 处理业务逻辑错误 console.error('disconnectServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); }); } catch (paramError) { + commRemote = null; // 处理入参错误异常 console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); } @@ -1312,6 +1330,7 @@ startAbilityByCall(want: Want): Promise<Caller>; | 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | | 16000008 | Crowdtest App Expiration. | | 16000009 | Can not start ability in wukong mode. | +| 16000012 | The previous ability is starting, wait start later. | | 16000050 | Internal Error. | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md index 61bee851f877695cf4cacfbe4eb4ab51ac501a6e..1cf39b1e8171f8c419208e4b904bb18be6a17f18 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md @@ -54,6 +54,7 @@ startAbility(want: Want, callback: AsyncCallback<void>): void; | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | @@ -117,6 +118,7 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void& | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | @@ -189,6 +191,7 @@ startAbility(want: Want, options?: StartOptions): Promise<void>; | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | @@ -257,6 +260,7 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | @@ -324,6 +328,7 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | @@ -401,6 +406,7 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | @@ -471,6 +477,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | @@ -542,6 +549,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | @@ -621,6 +629,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | @@ -1349,6 +1358,7 @@ let want = { }; let options = { onConnect(elementName, remote) { + commRemote = remote; console.info('onConnect...') }, onDisconnect(elementName) { @@ -1415,6 +1425,7 @@ let want = { let accountId = 100; let options = { onConnect(elementName, remote) { + commRemote = remote; console.info('onConnect...') }, onDisconnect(elementName) { @@ -1438,7 +1449,7 @@ try { disconnectServiceExtensionAbility(connection: number): Promise\; -断开与ServiceExtensionAbility的连接(promise形式)。 +断开与ServiceExtensionAbility的连接,断开连接之后需要将连接成功时返回的remote对象置空(promise形式)。 **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -1471,6 +1482,7 @@ let connection = 1; try { this.context.disconnectServiceExtensionAbility(connection, (err) => { + commRemote = null; if (err.code) { // 处理业务逻辑错误 console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`); @@ -1480,6 +1492,7 @@ try { console.info('disconnectServiceExtensionAbility succeed'); }); } catch (err) { + commRemote = null; // 处理入参错误异常 console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`); } @@ -1489,7 +1502,7 @@ try { disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback\): void; -断开与ServiceExtensionAbility的连接(callback形式)。 +断开与ServiceExtensionAbility的连接,断开连接之后需要将连接成功时返回的remote对象置空(callback形式)。 **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -1517,6 +1530,7 @@ let connection = 1; try { this.context.disconnectServiceExtensionAbility(connection, (err) => { + commRemote = null; if (err.code) { // 处理业务逻辑错误 console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`); @@ -1526,6 +1540,7 @@ try { console.info('disconnectServiceExtensionAbility succeed'); }); } catch (err) { + commRemote = null; // 处理入参错误异常 console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`); } @@ -1569,6 +1584,7 @@ startAbilityByCall(want: Want): Promise<Caller>; | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | @@ -1675,6 +1691,7 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\< | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | @@ -1746,6 +1763,7 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | @@ -1819,6 +1837,7 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | +| 16000012 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md index d3c7dc85ce834a9f260efcae4a569666fc59cac5..ad0dcdade7eb8e05e066902451697ae36f538938 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md @@ -21,7 +21,7 @@ import InputMethodSubtype from '@ohos.InputMethodSubtype'; | 名称 | 类型 | 可读 | 可写 | 必选 | 说明 | | -------- | -------- | -------- | -------- | -------- | -------- | | label | string | 是 | 否 | 否 | 输入法子类型的标签。 | -| name | string | 是 | 否 | 是 | 输入法子类型的名字。 | +| name | string | 是 | 否 | 是 | 输入法应用的包名。 | | id | string | 是 | 否 | 是 | 输入法子类型的id。 | | mode | string | 是 | 否 | 否 | 输入法子类型的模式,包括upper(大写)和lower(小写)。 | | locale | string | 是 | 否 | 是 | 输入法子类型的方言版本。 | 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 892b9a2b98717c5ec5e2e8f787bd79619e563f22..e1b4c44893f56ce9965efc8f948cf0a1b849237c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -256,9 +256,9 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb ```js try { inputMethod.switchCurrentInputMethodSubtype({ - id: "com.example.kikakeyboard", - label: "ServiceExtAbility", - name: "", + id: "ServiceExtAbility", + label: "", + name: "com.example.kikakeyboard", mode: "upper", locale: "", language: "", @@ -317,9 +317,9 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise<boolean& ```js try { inputMethod.switchCurrentInputMethodSubtype({ - id: "com.example.kikakeyboard", - label: "ServiceExtAbility", - name: "", + id: "ServiceExtAbility", + label: "", + name: "com.example.kikakeyboard", mode: "upper", locale: "", language: "", @@ -391,25 +391,9 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp ```js let im = inputMethod.getCurrentInputMethod(); -let inputMethodProperty = { - packageName: im.packageName, - methodId: im.methodId, - name: im.packageName, - id: im.methodId, - extra: {} -} +let imSubType = inputMethod.getCurrentInputMethodSubtype(); try { - inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, { - id: "com.example.kikakeyboard", - label: "ServiceExtAbility", - name: "", - mode: "upper", - locale: "", - language: "", - icon: "", - iconId: 0, - extra: {} - }, (err,result) => { + inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType, (err,result) => { if (err !== undefined) { console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err)); return; @@ -461,25 +445,9 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp ```js let im = inputMethod.getCurrentInputMethod(); -let inputMethodProperty = { - packageName: im.packageName, - methodId: im.methodId, - name: im.packageName, - id: im.methodId, - extra: {} -} +let imSubType = inputMethod.getCurrentInputMethodSubtype(); try { - inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, { - id: im.packageName, - label: im.methodId, - name: "", - mode: "upper", - locale: "", - language: "", - icon: "", - iconId: 0, - extra: {} - }).then((result) => { + inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType).then((result) => { if (result) { console.info('Succeeded in switching currentInputMethodAndSubtype.'); } else { diff --git a/zh-cn/application-dev/reference/apis/js-apis-installer.md b/zh-cn/application-dev/reference/apis/js-apis-installer.md index 221dc9a44ff768ca296b5d57e8946c7bc9ca46b7..d00cf928cd584ae05e54c97ddb31486b3ef95e95 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-installer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-installer.md @@ -118,7 +118,8 @@ install(hapFilePaths: Array<string>, installParam: InstallParam, callback: | 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | | 17700018 | Failed to install because the dependent module does not exist. | | 17700031 | Failed to install the HAP because the overlay check of the HAP is failed. | -| 17700036 | Failed to install because without allow app shared bundle permission. | +| 17700036 | Failed to install the HSP because lacks appropriate permissions. | +| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. | **示例:** @@ -176,6 +177,7 @@ uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallbac | -------- | ------------------------------------------------------------ | | 17700004 | The specified user ID is not found. | | 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | +| 17700040 | The specified bundle is a shared bundle which cannot be uninstalled. | **示例:** @@ -281,7 +283,7 @@ uninstall(uninstallParam: UninstallParam) : Promise\; | 类型 | 说明 | | ------------- | -------------------------------------- | -| Promise | Promise对象。无返回结果的Promise对象。 | +| Promise\ | Promise对象。无返回结果的Promise对象。 | **错误码:** @@ -397,11 +399,11 @@ try { | 名称 | 类型 | 必填 | 说明 | | ------------------------------ | ------------------------------ | ------------------ | ------------------ | -| userId | number | 是 | 指示用户id,可使用[queryOsAccountLocalIdFromProcess](js-apis-osAccount.md#getOsAccountLocalId)获取当前进程所在用户。 | -| installFlag | number | 是 | 指示安装标志,枚举值:0:应用初次安装,1:应用覆盖安装。 | -| isKeepData | boolean | 是 | 卸载时是否保留数据目录。 | -| hashParams | Array<[HashParam](#hashparam)> | 是 | 哈希值参数。 | -| crowdtestDeadline| number | 是 |[众测](https://developer.huawei.com/consumer/cn/agconnect/crowd-test/)截止日期。 | +| userId | number | 否 | 指示用户id,可使用[queryOsAccountLocalIdFromProcess](js-apis-osAccount.md#getOsAccountLocalId)获取当前进程所在用户。 | +| installFlag | number | 否 | 指示安装标志,枚举值:0:应用初次安装,1:应用覆盖安装。 | +| isKeepData | boolean | 否 | 卸载时是否保留数据目录。 | +| hashParams | Array<[HashParam](#hashparam)> | 否 | 哈希值参数。 | +| crowdtestDeadline| number | 否 |[众测](https://developer.huawei.com/consumer/cn/agconnect/crowd-test/)截止日期。 | | sharedBundleDirPaths | Array\ | 否 |共享包文件所在路径。 | ## UninstallParam10+ @@ -415,4 +417,4 @@ try { | 名称 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 共享包包名。 | -| versionCode | number | 否 | 指示共享包的版本号。如果不填写versionCode,则卸载所有同版本共享包。 | \ No newline at end of file +| versionCode | number | 否 | 指示共享包的版本号。如果不填写versionCode,则卸载该包名的所有共享包。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-matrix4.md b/zh-cn/application-dev/reference/apis/js-apis-matrix4.md index 424e3d5b4cddc2ffbd92f00a3e76ed8e7a660d2a..8e5bd9f7f01cd257b104671976a23bdce21c2b83 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-matrix4.md +++ b/zh-cn/application-dev/reference/apis/js-apis-matrix4.md @@ -281,11 +281,11 @@ Matrix的平移函数,可以为当前矩阵增加x轴/Y轴/Z轴平移效果。 **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------------------------------------- | -| x | number | 否 | x轴的平移距离,单位px。
默认值:0 | -| y | number | 否 | y轴的平移距离,单位px。
默认值:0 | -| z | number | 否 | z轴的平移距离,单位px。
默认值:0 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ----------------------------------------------------------- | +| x | number | 否 | x轴的平移距离,单位px。
默认值:0
取值范围 (-∞, +∞) | +| y | number | 否 | y轴的平移距离,单位px。
默认值:0
取值范围 (-∞, +∞) | +| z | number | 否 | z轴的平移距离,单位px。
默认值:0
取值范围 (-∞, +∞) | **返回值:** @@ -328,13 +328,13 @@ Matrix的缩放函数,可以为当前矩阵增加x轴/Y轴/Z轴缩放效果。 **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | --------------------------------- | -| x | number | 否 | x轴的缩放倍数。
默认值:1 | -| y | number | 否 | y轴的缩放倍数。
默认值:1 | -| z | number | 否 | z轴的缩放倍数。
默认值:1 | -| centerX | number | 否 | 变换中心点x轴坐标。
默认值:0 | -| centerY | number | 否 | 变换中心点y轴坐标。
默认值:0 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| x | number | 否 | x轴的缩放倍数。x>1时以x轴方向放大,x<1时以x轴方向缩小。
默认值:1
取值范围 [0, +∞)
**说明:**
设置小于0的值时,按照默认值处理。 | +| y | number | 否 | y轴的缩放倍数。y>1时以y轴方向放大,y<1时以y轴方向缩小。
默认值:1
取值范围 [0, +∞)
**说明:**
设置小于0的值时,按照默认值处理。 | +| z | number | 否 | z轴的缩放倍数。z>1时以z轴方向放大,z<1时以z轴方向缩小。
默认值:1
取值范围 [0, +∞)
**说明:**
设置小于0的值时,按照默认值处理。 | +| centerX | number | 否 | 变换中心点x轴坐标。
默认值:0。
取值范围 (-∞, +∞) | +| centerY | number | 否 | 变换中心点y轴坐标。
默认值:0。
取值范围 (-∞, +∞) | **返回值:** @@ -376,14 +376,14 @@ Matrix的旋转函数,可以为当前矩阵增加x轴/Y轴/Z轴旋转效果。 **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | --------------------------------- | -| x | number | 否 | 旋转轴向量x坐标。
默认值:1 | -| y | number | 否 | 旋转轴向量y坐标。
默认值:1 | -| z | number | 否 | 旋转轴向量z坐标。
默认值:1 | -| angle | number | 否 | 旋转角度。
默认值:0 | -| centerX | number | 否 | 变换中心点x轴坐标。
默认值:0 | -| centerY | number | 否 | 变换中心点y轴坐标。
默认值:0 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------------------------------------------------- | +| x | number | 否 | 旋转轴向量x坐标。
默认值:1。
取值范围 (-∞, +∞) | +| y | number | 否 | 旋转轴向量y坐标。
默认值:1。
取值范围 (-∞, +∞) | +| z | number | 否 | 旋转轴向量z坐标。
默认值:1。
取值范围 (-∞, +∞) | +| angle | number | 否 | 旋转角度。
默认值:0 | +| centerX | number | 否 | 变换中心点x轴坐标。
默认值:0 | +| centerY | number | 否 | 变换中心点y轴坐标。
默认值:0 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-measure.md b/zh-cn/application-dev/reference/apis/js-apis-measure.md index 95bd545157f5c22d0dd8f38b1f9127468abe1289..07c24796a1f6325ba3cce2ae41fafe22cc565341 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-measure.md +++ b/zh-cn/application-dev/reference/apis/js-apis-measure.md @@ -58,6 +58,52 @@ struct Index { } ``` +## measure.measureTextSize10+ + +measureTextSize(options: MeasureOptions): SizeOptions + +计算指定文本单行布局下的宽度。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | --------- | +| options | [MeasureOptions](#measureoptions) | 是 | 被计算文本描述信息。 | + +**返回值:** + +| 类型 | 说明 | +| ------------ | --------- | +| SizeOptions | 返回文本所占布局宽度和高度。
**说明:** 文本宽度以及高度返回值单位均为px。 | + + +**示例:** + +```ts +import measure from '@ohos.measure' +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + textSize : SizeOptions = measure.measureTextSize({ + textContent: "Hello word", + fontSize: '50px' + }) + build() { + Row() { + Column() { + Text("The width of 'Hello World': " + this.textSize.width) + Text("The height of 'Hello World': " + this.textSize.height) + } + .width('100%') + } + .height('100%') + } +} +``` + ## MeasureOptions 被计算文本属性。 @@ -67,9 +113,16 @@ struct Index { | 名称 | 类型 | 必填 | 说明 | | -------------- | -------------------------------------------------------------------------------------------------- | ---- | ----------------------------------------------- | | textContent | string | 是 | 设置被计算文本内容。 | -| fontSize | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | 否 | 设置被计算文本字体大小,fontSize为number类型时,使用fp单位。
默认值:16fp。
**说明:**不支持设置百分比字符串。 | +| constraintWidth10+ | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | 否 | 设置被计算文本布局宽度。
**说明:** 默认单位为vp | +| fontSize | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | 否 | 设置被计算文本字体大小,fontSize为number类型时,使用fp单位。
默认值:16fp。
**说明:** 不支持设置百分比字符串。 | | fontStyle | number \| [FontStyle](../arkui-ts/ts-appendix-enums.md#fontstyle) | 否 | 设置被计算文本字体样式。
默认值:FontStyle.Normal | | fontWeight | number \| string \| [FontWeight](../arkui-ts/ts-appendix-enums.md#fontweight) | 否 | 设置被计算文本的字体粗细,number类型取值[100, 900],取值间隔为100,默认为400,取值越大,字体越粗。string类型仅支持number类型取值的字符串形式,例如"400",以及"bold"、"bolder"、"lighter"、"regular"、"medium",分别对应FontWeight中相应的枚举值。
默认值:FontWeight.Normal| | fontFamily | string \| [Resource](../arkui-ts/ts-types.md#resource) | 否 | 设置被计算文本字体列表。默认字体'HarmonyOS Sans',且当前只支持这种字体。| | letterSpacing | number \| string | 否 | 设置被计算文本字符间距。| +| textAlign10+ | number \| [TextAlign](../arkui-ts/ts-appendix-enums.md#textalign) | 否 | 设置被计算文本水平方向的对齐方式。
默认值:TextAlign.Start| +| overflow10+ | number \| [TextOverflow](../arkui-ts/ts-appendix-enums.md#textoverflow) | 否 | 设置被计算文本超长时的截断方式。| +| maxLines10+ | number | 否 | 设置被计算文本最大行数。| +| lineHeight10+ | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | 否 | 设置被计算文本行高。| +| baselineOffset10+ | number \| string | 否 | 设置被计算文本基线的偏移量。
默认值:0 | +| textCase10+ | number \| [TextCase](../arkui-ts/ts-appendix-enums.md#textcase) | 否 | 设置被计算文本大小写。
默认值:TextCase.Normal | 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 470a03662a97e34c6aa3e3fa27bf8eb156c7159f..67763454ef51f5844a638f5310c4a3ba6ac8966a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-media.md +++ b/zh-cn/application-dev/reference/apis/js-apis-media.md @@ -931,6 +931,14 @@ getTrackDescription(callback: AsyncCallback\>): void **示例:** ```js +printfDescription(obj) { + for (let item in obj) { + let property = obj[item]; + console.info('audio key is ' + item); + console.info('audio value is ' + property); + } +} + avPlayer.getTrackDescription((error, arrList) => { if ((arrList) != null) { for (let i = 0; i < arrList.length; i++) { @@ -968,6 +976,14 @@ getTrackDescription(): Promise\> ```js let arrayDescription; + +printfDescription(obj) { + for (let item in obj) { + let property = obj[item]; + console.info('audio key is ' + item); + console.info('audio value is ' + property); + } +} avPlayer.getTrackDescription().then((arrList) => { if (arrList != null) { arrayDescription = arrList; @@ -1557,6 +1573,8 @@ on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void **示例:** ```js +import audio from '@ohos.multimedia.audio'; + avPlayer.on('audioInterrupt', (info: audio.InterruptEvent) => { console.info('audioInterrupt success,and InterruptEvent info is:' + info) }) @@ -1758,7 +1776,7 @@ let AVRecorderConfig = { location : { latitude : 30, longitude : 130 } } -AVRecorder.prepare(AVRecorderConfig, (err) => { +avRecorder.prepare(AVRecorderConfig, (err) => { if (err == null) { console.info('prepare success'); } else { @@ -1829,7 +1847,7 @@ let AVRecorderConfig = { location : { latitude : 30, longitude : 130 } } -AVRecorder.prepare(AVRecorderConfig).then(() => { +avRecorder.prepare(AVRecorderConfig).then(() => { console.info('prepare success'); }).catch((err) => { console.info('prepare failed and catch error is ' + err.message); @@ -1870,7 +1888,7 @@ getInputSurface(callback: AsyncCallback\): void ```js let surfaceID = null; // 该surfaceID用于传递给相机接口创造videoOutput -AVRecorder.getInputSurface((err, surfaceId) => { +avRecorder.getInputSurface((err, surfaceId) => { if (err == null) { console.info('getInputSurface success'); surfaceID = surfaceId; @@ -1879,8 +1897,6 @@ AVRecorder.getInputSurface((err, surfaceId) => { } }); -// videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); - ``` ### getInputSurface9+ @@ -1916,14 +1932,12 @@ getInputSurface(): Promise\ ```js let surfaceID = null; // 该surfaceID用于传递给相机接口创造videoOutput -AVRecorder.getInputSurface().then((surfaceId) => { +avRecorder.getInputSurface().then((surfaceId) => { console.info('getInputSurface success'); surfaceID = surfaceId; }).catch((err) => { console.info('getInputSurface failed and catch error is ' + err.message); }); - -// videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID); ``` ### start9+
@@ -1955,7 +1969,7 @@ start(callback: AsyncCallback\): void **示例:** ```js -AVRecorder.start((err) => { +avRecorder.start((err) => { if (err == null) { console.info('start AVRecorder success'); } else { @@ -1993,7 +2007,7 @@ start(): Promise\ **示例:** ```js -AVRecorder.start().then(() => { +avRecorder.start().then(() => { console.info('start AVRecorder success'); }).catch((err) => { console.info('start AVRecorder failed and catch error is ' + err.message); @@ -2029,7 +2043,7 @@ pause(callback: AsyncCallback\): void **示例:** ```js -AVRecorder.pause((err) => { +avRecorder.pause((err) => { if (err == null) { console.info('pause AVRecorder success'); } else { @@ -2067,7 +2081,7 @@ pause(): Promise\ **示例:** ```js -AVRecorder.pause().then(() => { +avRecorder.pause().then(() => { console.info('pause AVRecorder success'); }).catch((err) => { console.info('pause AVRecorder failed and catch error is ' + err.message); @@ -2103,7 +2117,7 @@ resume(callback: AsyncCallback\): void **示例:** ```js -AVRecorder.resume((err) => { +avRecorder.resume((err) => { if (err == null) { console.info('resume AVRecorder success'); } else { @@ -2141,7 +2155,7 @@ resume(): Promise\ **示例:** ```js -AVRecorder.resume().then(() => { +avRecorder.resume().then(() => { console.info('resume AVRecorder success'); }).catch((err) => { console.info('resume AVRecorder failed and catch error is ' + err.message); @@ -2179,7 +2193,7 @@ stop(callback: AsyncCallback\): void **示例:** ```js -AVRecorder.stop((err) => { +avRecorder.stop((err) => { if (err == null) { console.info('stop AVRecorder success'); } else { @@ -2219,7 +2233,7 @@ stop(): Promise\ **示例:** ```js -AVRecorder.stop().then(() => { +avRecorder.stop().then(() => { console.info('stop AVRecorder success'); }).catch((err) => { console.info('stop AVRecorder failed and catch error is ' + err.message); @@ -2254,7 +2268,7 @@ reset(callback: AsyncCallback\): void **示例:** ```js -AVRecorder.reset((err) => { +avRecorder.reset((err) => { if (err == null) { console.info('reset AVRecorder success'); } else { @@ -2291,7 +2305,7 @@ reset(): Promise\ **示例:** ```js -AVRecorder.reset().then(() => { +avRecorder.reset().then(() => { console.info('reset AVRecorder success'); }).catch((err) => { console.info('reset AVRecorder failed and catch error is ' + err.message); @@ -2325,7 +2339,7 @@ release(callback: AsyncCallback\): void **示例:** ```js -AVRecorder.release((err) => { +avRecorder.release((err) => { if (err == null) { console.info('release AVRecorder success'); } else { @@ -2361,7 +2375,7 @@ release(): Promise\ **示例:** ```js -AVRecorder.release().then(() => { +avRecorder.release().then(() => { console.info('release AVRecorder success'); }).catch((err) => { console.info('release AVRecorder failed and catch error is ' + err.message); @@ -2386,9 +2400,8 @@ on(type: 'stateChange', callback: (state: AVRecorderState, reason: StateChangeRe **示例:** ```js -AVRecorder.on('stateChange', async (state, reason) => { +avRecorder.on('stateChange', async (state, reason) => { console.info('case state has changed, new state is :' + state + ',and new reason is : ' + reason); - } }); ``` @@ -2409,7 +2422,7 @@ off(type: 'stateChange'): void **示例:** ```js -AVRecorder.off('stateChange'); +avRecorder.off('stateChange'); ``` ### on('error')9+ @@ -2441,7 +2454,7 @@ on(type: 'error', callback: ErrorCallback): void **示例:** ```js -AVRecorder.on('error', (err) => { +avRecorder.on('error', (err) => { console.info('case avRecorder.on(error) called, errMessage is ' + err.message); }); ``` @@ -2472,7 +2485,7 @@ off(type: 'error'): void **示例:** ```js -AVRecorder.off('error'); +avRecorder.off('error'); ``` ## AVRecorderState9+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md index 585fb77a29c59dc7a361eb306c646879da8f6b09..40492367bd96e8ebdb15bac7a4ba24d07346d0b1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md +++ b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md @@ -294,8 +294,8 @@ let httpProxy = { port: 8080, exclusionList: exclusionArray } -connection.setGlobalHttpProxy(httpProxy).then((error, data) => { - console.info(JSON.stringify(data)); +connection.setGlobalHttpProxy(httpProxy).then(() => { + console.info("success"); }).catch(error=>{ console.info(JSON.stringify(error)); }) @@ -436,8 +436,8 @@ setAppNet(netHandle: NetHandle): Promise\; ```js connection.getDefaultNet().then(function (netHandle) { - connection.setAppNet(netHandle).then((error, data) => { - console.log(JSON.stringify(data)) + connection.setAppNet(netHandle).then(() => { + console.log("success") }).catch(error => { console.log(JSON.stringify(error)) }) @@ -1097,7 +1097,7 @@ getAddressesByName(host: string, callback: AsyncCallback\>): 使用默认网络解析主机名以获取所有IP地址,使用callback方式作为异步方法。 -**需要权限**:ohos.permission.GET_NETWORK_INFO +**需要权限**:ohos.permission.INTERNET **系统能力**:SystemCapability.Communication.NetManager.Core @@ -1134,7 +1134,7 @@ getAddressesByName(host: string): Promise\> 使用默认网络解析主机名以获取所有IP地址,使用Promise方式作为异步方法。 -**需要权限**:ohos.permission.GET_NETWORK_INFO +**需要权限**:ohos.permission.INTERNET **系统能力**:SystemCapability.Communication.NetManager.Core @@ -1639,7 +1639,7 @@ getAddressesByName(host: string, callback: AsyncCallback\>): 使用对应网络解析主机名以获取所有IP地址,使用callback方式作为异步方法。 -**需要权限**:ohos.permission.GET_NETWORK_INFO +**需要权限**:ohos.permission.INTERNET **系统能力**:SystemCapability.Communication.NetManager.Core @@ -1678,7 +1678,7 @@ getAddressesByName(host: string): Promise\> 使用对应网络解析主机名以获取所有IP地址,使用Promise方式作为异步方法。 -**需要权限**:ohos.permission.GET_NETWORK_INFO +**需要权限**:ohos.permission.INTERNET **系统能力**:SystemCapability.Communication.NetManager.Core @@ -1721,7 +1721,7 @@ getAddressByName(host: string, callback: AsyncCallback\): void 使用对应网络解析主机名以获取第一个IP地址,使用callback方式作为异步方法。 -**需要权限**:ohos.permission.GET_NETWORK_INFO +**需要权限**:ohos.permission.INTERNET **系统能力**:SystemCapability.Communication.NetManager.Core @@ -1760,7 +1760,7 @@ getAddressByName(host: string): Promise\ 使用对应网络解析主机名以获取第一个IP地址,使用Promise方式作为异步方法。 -**需要权限**:ohos.permission.GET_NETWORK_INFO +**需要权限**:ohos.permission.INTERNET **系统能力**:SystemCapability.Communication.NetManager.Core diff --git a/zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md b/zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md index 8fcb75209c766a0ca3b7ab20868b1ba4de9dec2a..982f8ac0517be4ed950af8dd73504753a582ac3d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md +++ b/zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md @@ -114,9 +114,9 @@ ethernet.setIfaceConfig("eth0", { dnsServers: "1.1.1.1", domain: "2.2.2.2" }).then(() => { - console.log("setIfaceConfig promiss ok "); + console.log("setIfaceConfig promise ok "); }).catch(error => { - console.log("setIfaceConfig promiss error = " + JSON.stringify(error)); + console.log("setIfaceConfig promise error = " + JSON.stringify(error)); }); ``` @@ -207,15 +207,15 @@ getIfaceConfig(iface: string): Promise\ ```js ethernet.getIfaceConfig("eth0").then((data) => { - console.log("getIfaceConfig promiss mode = " + JSON.stringify(data.mode)); - console.log("getIfaceConfig promiss ipAddr = " + JSON.stringify(data.ipAddr)); - console.log("getIfaceConfig promiss route = " + JSON.stringify(data.route)); - console.log("getIfaceConfig promiss gateway = " + JSON.stringify(data.gateway)); - console.log("getIfaceConfig promiss netMask = " + JSON.stringify(data.netMask)); - console.log("getIfaceConfig promiss dnsServers = " + JSON.stringify(data.dnsServers)); - console.log("getIfaceConfig promiss domain = " + JSON.stringify(data.domain)); + console.log("getIfaceConfig promise mode = " + JSON.stringify(data.mode)); + console.log("getIfaceConfig promise ipAddr = " + JSON.stringify(data.ipAddr)); + console.log("getIfaceConfig promise route = " + JSON.stringify(data.route)); + console.log("getIfaceConfig promise gateway = " + JSON.stringify(data.gateway)); + console.log("getIfaceConfig promise netMask = " + JSON.stringify(data.netMask)); + console.log("getIfaceConfig promise dnsServers = " + JSON.stringify(data.dnsServers)); + console.log("getIfaceConfig promise domain = " + JSON.stringify(data.domain)); }).catch(error => { - console.log("getIfaceConfig promiss error = " + JSON.stringify(error)); + console.log("getIfaceConfig promise error = " + JSON.stringify(error)); }); ``` @@ -300,9 +300,9 @@ isIfaceActive(iface: string): Promise\ ```js ethernet.isIfaceActive("eth0").then((data) => { - console.log("isIfaceActive promiss = " + JSON.stringify(data)); + console.log("isIfaceActive promise = " + JSON.stringify(data)); }).catch(error => { - console.log("isIfaceActive promiss error = " + JSON.stringify(error)); + console.log("isIfaceActive promise error = " + JSON.stringify(error)); }); ``` @@ -377,12 +377,12 @@ getAllActiveIfaces(): Promise\> ```js ethernet.getAllActiveIfaces().then((data) => { - console.log("getAllActiveIfaces promiss data.length = " + JSON.stringify(data.length)); + console.log("getAllActiveIfaces promise data.length = " + JSON.stringify(data.length)); for (let i = 0; i < data.length; i++) { - console.log("getAllActiveIfaces promiss = " + JSON.stringify(data[i])); + console.log("getAllActiveIfaces promise = " + JSON.stringify(data[i])); } }).catch(error => { - console.log("getAllActiveIfaces promiss error = " + JSON.stringify(error)); + console.log("getAllActiveIfaces promise error = " + JSON.stringify(error)); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-net-mdns.md b/zh-cn/application-dev/reference/apis/js-apis-net-mdns.md new file mode 100644 index 0000000000000000000000000000000000000000..cfbda46e5bce0aca5c80331cc37e80692d9c4365 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-net-mdns.md @@ -0,0 +1,551 @@ +# @ohos.net.mdns (MDNS管理) + +MDNS即多播DNS(Multicast DNS),提供局域网内的本地服务添加、移除、发现、解析等能力。 + +> **说明:** +> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```js +import mdns from '@ohos.net.mdns' +``` +## mdns.addLocalService + +addLocalService(context: Context, serviceInfo: LocalServiceInfo, callback: AsyncCallback\): void + +添加一个mDNS服务,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetManager.MDNS + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|-------------|----------------------------------|-----------|-------------------------------------------------| +| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 | +| serviceInfo | [LocalServiceInfo](#localserviceinfo) | 是 | mDNS服务的信息。 | +| callback | AsyncCallback\<[LocalServiceInfo](#localserviceinfo)> | 是 | 回调函数。成功添加error为undefined,data为添加到本地的mdns服务信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +|---------|---| +| 401 | Parameter error. | +| 2100002 | Operation failed. Cannot connect to service. | +| 2100003 | System internal error. | +| 2204003 | Callback duplicated. | +| 2204008 | Service instance duplicated. | +| 2204010 | Send packet failed. | + +>**错误码说明:** +> 以上错误码的详细介绍参见[MDNS错误码](../errorcodes/errorcode-net-mdns.md)。 + +**示例:** + +```js +let localServiceInfo = { + serviceType: "_print._tcp", + serviceName: "servicename", + port: 5555, + host: { + address: "10.14.**.***", + }, + serviceAttribute: [{ + key: "111", + value: [1] + }] +} + +mdns.addLocalService(context, localServiceInfo, function (error, data) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(data)) +}); +``` + +## mdns.addLocalService + +addLocalService(context: Context, serviceInfo: LocalServiceInfo): Promise\ + +添加一个mDNS服务,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetManager.MDNS + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|-------------|----------------------------------|-----------|-------------------------------------------------| +| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 | +| serviceInfo | [LocalServiceInfo](#localserviceinfo) | 是 | mDNS服务的信息。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------------------- | ------------------------------------- | +| Promise\<[LocalServiceInfo](#localserviceinfo)> | 以Promise形式返回添加的mdns服务信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +|---------|---| +| 401 | Parameter error. | +| 2100002 | Operation failed. Cannot connect to service. | +| 2100003 | System internal error. | +| 2204003 | Callback duplicated. | +| 2204008 | Service instance duplicated. | +| 2204010 | Send packet failed. | + +>**错误码说明:** +> 以上错误码的详细介绍参见[MDNS错误码](../errorcodes/errorcode-net-mdns.md)。 + +**示例:** + +```js +let localServiceInfo = { + serviceType: "_print._tcp", + serviceName: "servicename", + port: 5555, + host: { + address: "10.14.**.***", + }, + serviceAttribute: [{ + key: "111", + value: [1] + }] +} + +mdns.addLocalService(context, localServiceInfo).then(function (data) { + console.log(JSON.stringify(data)) +}); +``` + +## mdns.removeLocalService + +removeLocalService(context: Context, serviceInfo: LocalServiceInfo, callback: AsyncCallback\): void + +移除一个mDNS服务,使用callback方式作为异步方法。 + +**系统能力**: SystemCapability.Communication.NetManager.MDNS + +**参数** + +| 参数名 | 类型 | 必填 | 说明 | +|-------------|----------------------------------|-----------|-------------------------------------------------| +| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 | +| serviceInfo | [LocalServiceInfo](#localserviceinfo) | 是 | mDNS服务的信息。 | +| callback | AsyncCallback\<[LocalServiceInfo](#localserviceinfo)> | 是 | 回调函数。成功移除error为undefined,data为移除本地的mdns服务信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +|---------|---| +| 401 | Parameter error. | +| 2100002 | Operation failed. Cannot connect to service. | +| 2100003 | System internal error. | +| 2204002 | Callback not found. | +| 2204008 | Service instance duplicated. | +| 2204010 | Send packet failed. | + +>**错误码说明:** +> 以上错误码的详细介绍参见[MDNS错误码](../errorcodes/errorcode-net-mdns.md)。 + +**示例:** + +```js +let localServiceInfo = { + serviceType: "_print._tcp", + serviceName: "servicename", + port: 5555, + host: { + address: "10.14.**.***", + }, + serviceAttribute: [{ + key: "111", + value: [1] + }] +} + +mdns.removeLocalService(context, localServiceInfo, function (error, data) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(data)) +}); +``` + +## mdns.removeLocalService + +removeLocalService(context: Context, serviceInfo: LocalServiceInfo): Promise\ + +移除一个mDNS服务. 使用Promise方式作为异步方法。 + +**系统能力**: SystemCapability.Communication.NetManager.MDNS + +**参数** + +| 参数名 | 类型 | 必填 | 说明 | +|-------------|----------------------------------|-----------|-------------------------------------------------| +| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 | +| serviceInfo | [LocalServiceInfo](#localserviceinfo) | 是 | mDNS服务的信息。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------------------- | ------------------------------------- | +| Promise\<[LocalServiceInfo](#localserviceinfo)> | 以Promise形式返回移除的mdns服务信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +|---------|---| +| 401 | Parameter error. | +| 2100002 | Operation failed. Cannot connect to service. | +| 2100003 | System internal error. | +| 2204002 | Callback not found. | +| 2204008 | Service instance duplicated. | +| 2204010 | Send packet failed. | + +>**错误码说明:** +> 以上错误码的详细介绍参见[MDNS错误码](../errorcodes/errorcode-net-mdns.md)。 + +**示例:** + +```js +let localServiceInfo = { + serviceType: "_print._tcp", + serviceName: "servicename", + port: 5555, + host: { + address: "10.14.**.***", + }, + serviceAttribute: [{ + key: "111", + value: [1] + }] +} + +mdns.removeLocalService(context, localServiceInfo).then(function (data) { + console.log(JSON.stringify(data)) +}); +``` + +## mdns.createDiscoveryService + +createDiscoveryService(context: Context, serviceType: string): DiscoveryService + +返回一个DiscoveryService对象,该对象用于发现指定服务类型的mDNS服务。 + +**系统能力**:SystemCapability.Communication.NetManager.MDNS + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|-------------|---------|-----------| ------------------------------------------------------------ | +| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 | +| serviceType | string | 是 | 需要发现的mDNS服务类型。| + +**返回值:** + +| Type | Description | +| ----------------------------- |---------------------------------| +| DiscoveryService | 基于指定serviceType和Context的发现服务对象。 | + +**Example** + +```js +let serviceType = "_print._tcp"; + +let discoveryService = mdns.createDiscoveryService(context, serviceType); +``` + +## mdns.resolveLocalService + +resolveLocalService(context: Context, serviceInfo: LocalServiceInfo, callback: AsyncCallback\): void + +解析一个mDNS服务,使用callback方式作为异步方法。 + +**系统能力**: SystemCapability.Communication.NetManager.MDNS + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|-------------|----------------------------------|-----------|-------------------------------------------------------------| +| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 | +| serviceInfo | [LocalServiceInfo](#localserviceinfo) | 是 | mDNS服务的信息。 | +| callback | AsyncCallback\<[LocalServiceInfo](#localserviceinfo)> | 是 | 回调函数。成功移除error为undefined,data为解析的mdns服务信息。 | + +**错误码:** + +| 错误码ID | 错误信息 | +|---------|----------------------------------------------| +| 401 | Parameter error. | +| 2100002 | Operation failed. Cannot connect to service. | +| 2100003 | System internal error. | +| 2204003 | Callback duplicated. | +| 2204006 | Request timeout. | +| 2204010 | Send packet failed. | + +>**错误码说明:** +> 以上错误码的详细介绍参见[MDNS错误码](../errorcodes/errorcode-net-mdns.md)。 + +**示例:** + +```js +let localServiceInfo = { + serviceType: "_print._tcp", + serviceName: "servicename", + port: 5555, + host: { + address: "10.14.**.***", + }, + serviceAttribute: [{ + key: "111", + value: [1] + }] +} + +mdns.resolveLocalService(context, localServiceInfo, function (error, data) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(data)) +}); +``` + +## mdns.resolveLocalService + +resolveLocalService(context: Context, serviceInfo: LocalServiceInfo): Promise\ + +解析一个mDNS服务,使用Promise方式作为异步方法。 + +**系统能力**: SystemCapability.Communication.NetManager.MDNS + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|-------------|--------------|-----------|-----------------------------------------------------| +| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)。
Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 | +| serviceInfo | [LocalServiceInfo](#localserviceinfo) | 是 | mDNS服务的信息。 | + +**返回值:** + +| 类型 | 说明 | +|----------------------------| ------------------------------------- | +| Promise\<[LocalServiceInfo](#localserviceinfo)> | 以Promise形式返回解析的mDNS服务信息。| + +**错误码:** + +| 错误码ID | 错误信息 | +|---------|----------------------------------------------| +| 401 | Parameter error. | +| 2100002 | Operation failed. Cannot connect to service. | +| 2100003 | System internal error. | +| 2204003 | Callback duplicated. | +| 2204006 | Request timeout. | +| 2204010 | Send packet failed. | + +>**错误码说明:** +> 以上错误码的详细介绍参见[MDNS错误码](../errorcodes/errorcode-net-mdns.md)。 + +**示例:** + +```js +let localServiceInfo = { + serviceType: "_print._tcp", + serviceName: "servicename", + port: 5555, + host: { + address: "10.14.**.***", + }, + serviceAttribute: [{ + key: "111", + value: [1] + }] +} + +mdns.resolveLocalService(context, localServiceInfo).then(function (data){ + console.log(JSON.stringify(data)); +}) +``` + +## DiscoveryService + +指定服务类型的发现服务对象。 + +### startSearchingMDNS + +startSearchingMDNS(): void + +开始搜索局域网内的mDNS服务。 + +**系统能力**:SystemCapability.Communication.NetManager.MDNS + +**示例:** + +```js +let discoveryService = mdns.createDiscoveryService(context, serviceType); +discoveryService.startSearchingMDNS(); +``` + +### stopSearchingMDNS + +stopSearchingMDNS(): void + +停止搜索局域网内的mDNS服务。 + +**系统能力**:SystemCapability.Communication.NetManager.MDNS + +**示例:** + +```js +let discoveryService = mdns.createDiscoveryService(context, serviceType); +discoveryService.stopSearchingMDNS(); +``` + +### on('discoveryStart') + +on(type: 'discoveryStart', callback: Callback<{serviceInfo: LocalServiceInfo, errorCode?: MDNS_ERR}>): void + +订阅开启监听mDNS服务的通知。 + +**系统能力**:SystemCapability.Communication.NetManager.MDNS + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|-------------|--------------|-----------|-----------------------------------------------------| +| type | string | 是 |订阅事件,固定为'discoveryStart'。
discoveryStart:开始搜索局域网内的mDNS服务事件。 | +| callback | Callback<{serviceInfo: [LocalServiceInfo](#localserviceinfo), errorCode?: [MDNS_ERR](#mdns_err)}> | 是 | mDNS服务的信息和事件错误信息。 | + +**示例:** + +```js +// 参考mdns.createDiscoveryService +let discoveryService = mdns.createDiscoveryService(context, serviceType); +discoveryService.startSearchingMDNS(); + +discoveryService.on('discoveryStart', (data) => { + console.log(JSON.stringify(data)); +}); + +discoveryService.stopSearchingMDNS(); +``` + +### on('discoveryStop') + +on(type: 'discoveryStop', callback: Callback<{serviceInfo: LocalServiceInfo, errorCode?: MDNS_ERR}>): void + +订阅停止监听mDNS服务的通知。 + +**系统能力**:SystemCapability.Communication.NetManager.MDNS + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|-------------|--------------|-----------|-----------------------------------------------------| +| type | string | 是 |订阅事件,固定为'discoveryStop'。
discoveryStop:停止搜索局域网内的mDNS服务事件。 | +| callback | Callback<{serviceInfo: [LocalServiceInfo](#localserviceinfo), errorCode?: [MDNS_ERR](#mdns_err)}> | 是 | mDNS服务的信息和事件错误信息。 | + +**示例:** + +```js +// 参考mdns.createDiscoveryService +let discoveryService = mdns.createDiscoveryService(context, serviceType); +discoveryService.startSearchingMDNS(); + +discoveryService.on('discoveryStop', (data) => { + console.log(JSON.stringify(data)); +}); + +discoveryService.stopSearchingMDNS(); +``` + +### on('serviceFound') + +on(type: 'serviceFound', callback: Callback<[LocalServiceInfo](#localserviceinfo)>): void + +订阅发现mDNS服务的通知。 + +**系统能力**:SystemCapability.Communication.NetManager.MDNS + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|-------------|--------------|-----------|-----------------------------------------------------| +| type | string | 是 |订阅事件,固定为'serviceFound'。
serviceFound:发现mDNS服务事件。 | +| callback | Callback<[LocalServiceInfo](#localserviceinfo)> | 是 | mDNS服务的信息。 | + +**示例:** + +```js +// 参考mdns.createDiscoveryService +let discoveryService = mdns.createDiscoveryService(context, serviceType); +discoveryService.startSearchingMDNS(); + +discoveryService.on('serviceFound', (data) => { + console.log(JSON.stringify(data)); +}); + +discoveryService.stopSearchingMDNS(); +``` + +### on('serviceLost') + +on(type: 'serviceLost', callback: Callback<[LocalServiceInfo](#localserviceinfo)>): void + +订阅移除mDNS服务的通知。 + +**系统能力**:SystemCapability.Communication.NetManager.MDNS + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +|-------------|--------------|-----------|-----------------------------------------------------| +| type | string | 是 |订阅事件,固定为'serviceLost'。
serviceLost:移除mDNS服务事件。 | +| callback | Callback<[LocalServiceInfo](#localserviceinfo)> | 是 | mDNS服务的信息。 | + +**示例:** + +```js +// 参考mdns.createDiscoveryService +let discoveryService = mdns.createDiscoveryService(context, serviceType); +discoveryService.startSearchingMDNS(); + +discoveryService.on('serviceLost', (data) => { + console.log(JSON.stringify(data)); +}); + +discoveryService.stopSearchingMDNS(); +``` + +## LocalServiceInfo + +mDNS服务信息 + +**系统能力**:SystemCapability.Communication.NetManager.MDNS + +| 名称 | 类型 | 必填 | 说明 | +| --------------------- | ---------------------------------- | --- | ------------------------ | +| serviceType | string | 是 | mDNS服务的类型。格式_\.<_tcp/_udp>,name长度小于63字符并且不能包含字符'.'。 | +| serviceName | string | 是 | mDNS服务的名字。 | +| port | number | 否 | mDNS服务的端口号。 | +| host | [NetAddress](js-apis-net-connection.md#netaddress) | 否 | mDNS服务设备的IP地址。采用设备的IP,添加服务和移除服务时候不生效。 | +| serviceAttribute | serviceAttribute\<[ServiceAttribute](#serviceattribute)> | 否 | mDNS服务属性信息。 | + +## ServiceAttribute + +mDNS服务属性信息 + +**系统能力**:SystemCapability.Communication.NetManager.MDNS + +| 名称 | 类型 | 必填 | 说明 | +| --------------------- | ---------------------------------- | --- | ------------------------ | +| key | string | 是 | mDNS服务属性键值,键值长度应该小于9个字符。 | +| value | Array\ | 是 | mDNS服务属性值。 | + +## MDNS_ERR + +mDNS错误信息。 + +**系统能力**:SystemCapability.Communication.NetManager.MDNS + +| 名称 | 值 | 说明 | +| --------------- | ---- | ----------- | +| INTERNAL_ERROR | 0 | 内部错误导致操作失败。 | +| ALREADY_ACTIVE | 1 | 服务已经存在导致操作失败。 | +| MAX_LIMIT | 2 | 请求超过最大限制导致操作失败。(暂不支持) | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-observer.md b/zh-cn/application-dev/reference/apis/js-apis-observer.md index 17238e3671672b30bf3c3c41dbff645c5a82b951..5ca4f0376b6386f9458a5cc38bfa17cc143b7f49 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-observer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-observer.md @@ -25,13 +25,15 @@ on\(type: \'networkStateChange\', callback: Callback\): void; **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 网络状态变化事件 | -| callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | 是 | 回调函数。参考radio的[NetworkState](js-apis-radio.md#networkstate) | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------------- | ---- | ---------------------------------------------------------------- | +| type | string | 是 | 网络状态变化事件,参数固定为'networkStateChange'。 | +| callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | 是 | 回调函数。参考radio的[NetworkState](js-apis-radio.md#networkstate)| **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -62,14 +64,16 @@ on\(type: \'networkStateChange\', options: { slotId: number }, callback: Callbac **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | -------------------------------------- | -| type | string | 是 | 网络状态变化事件 | -| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------------- | ---- | ---------------------------------------------------------------- | +| type | string | 是 | 网络状态变化事件,参数固定为'networkStateChange'。 | +| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | | callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | 是 | 回调函数。参考radio的[NetworkState](js-apis-radio.md#networkstate) | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -104,7 +108,7 @@ off\(type: \'networkStateChange\', callback?: Callback\): void; | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 网络状态变化事件 | +| type | string | 是 | 网络状态变化事件,参数固定为'networkStateChange'。 | | callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | 否 | 回调函数。参考radio的[NetworkState](js-apis-radio.md#networkstate) | | 错误码ID | 错误信息 | @@ -138,12 +142,14 @@ on\(type: \'signalInfoChange\', callback: Callback\>): **参数:** | 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 信号状态变化事件 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | +| type | string | 是 | 信号状态变化事件,参数固定为'signalInfoChange'。 | | callback | Callback\> | 是 | 回调函数。参考radio的[SignalInformation](js-apis-radio.md#signalinformation) | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -172,14 +178,16 @@ on\(type: \'signalInfoChange\', options: { slotId: number }, callback: Callback< **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | -------------------------------------- | -| type | string | 是 | 信号状态变化事件 | -| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | +| type | string | 是 | 信号状态变化事件,参数固定为'signalInfoChange'。 | +| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | | callback | Callback\> | 是 | 回调函数。参考radio的[SignalInformation](js-apis-radio.md#signalinformation) | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -214,11 +222,13 @@ off\(type: \'signalInfoChange\', callback?: Callback\> | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 信号状态变化事件 | +| type | string | 是 | 信号状态变化事件,参数固定为'signalInfoChange'。 | | callback | Callback\> | 否 | 回调函数。参考radio的[SignalInformation](js-apis-radio.md#signalinformation) | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -239,6 +249,125 @@ observer.off('signalInfoChange', callback); observer.off('signalInfoChange'); ``` +## observer.on('cellInfoChange')8+ + +on\(type: \'cellInfoChange\', callback: Callback\): void; + +订阅小区信息变化事件,使用callback方式作为异步方法。 + +**系统接口:** 此接口为系统接口。 + +**需要权限**:ohos.permission.LOCATION 和 ohos.permission.APPROXIMATELY_LOCATION + +**系统能力**:SystemCapability.Telephony.StateRegistry + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------------- | ---- |------------------------------------------------------------| +| type | string | 是 | 小区信息变化事件,固定为'cellInfoChange'。 | +| callback | Callback\<[CellInformation](js-apis-radio.md#cellinformation8)\> | 是 | 回调函数。| + +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**示例:** + +```js +observer.on('cellInfoChange', data => { + console.log("on cellInfoChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.on('cellInfoChange')8+ + +on\(type: \'cellInfoChange\', options: { slotId: number }, callback: Callback\): void; + +订阅指定卡槽位的小区信息变化事件,使用callback方式作为异步方法。 + +**系统接口:** 此接口为系统接口。 + +**需要权限**:ohos.permission.LOCATION 和 ohos.permission.APPROXIMATELY_LOCATION + +**系统能力**:SystemCapability.Telephony.StateRegistry + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ |--------------------------------------------------| ---- |------------------------------------------------------------| +| type | string | 是 | 小区信息变化事件,固定为'cellInfoChange'。 | +| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | +| callback | Callback\<[CellInformation](js-apis-radio.md#cellinformation8)\> | 是 | 回调函数。| + +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**示例:** + +```js +observer.on('cellInfoChange', {slotId: 0}, data => { + console.log("on cellInfoChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.off('cellInfoChange')8+ + +off\(type: \'cellInfoChange\', callback?: Callback\): void; + +取消订阅小区信息变化事件,使用callback方式作为异步方法。 + +>**说明:** +> +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**系统接口:** 此接口为系统接口。 + +**系统能力**:SystemCapability.Telephony.StateRegistry + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 小区信息变化事件,固定为'cellInfoChange'。 | +| callback | Callback\<[CellInformation](js-apis-radio.md#cellinformation8)\> | 否 | 回调函数。| + +| 错误码ID | 错误信息 | +| -------- | -------------------------------------------- | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**示例:** + +```js +let callback = data => { + console.log("on cellInfoChange, data:" + JSON.stringify(data)); +} +observer.on('cellInfoChange', callback); +// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 +observer.off('cellInfoChange', callback); +observer.off('cellInfoChange'); +``` ## observer.on('callStateChange') @@ -251,12 +380,14 @@ on(type: 'callStateChange', callback: Callback\<{ state: CallState, number: stri **参数:** | 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 通话状态变化事件 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | +| type | string | 是 | 通话状态变化事件,参数固定为'callStateChange'。 | | callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | 是 | 回调函数,参考call的[CallState](js-apis-call.md#callstate)
number:电话号码 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -285,13 +416,15 @@ on(type: 'callStateChange', options: { slotId: number }, callback: Callback<{ st **参数:** | 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 通话状态变化事件 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | +| type | string | 是 | 通话状态变化事件,参数固定为'callStateChange'。 | | slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | | callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | 是 | 回调函数,参考call的[CallState](js-apis-call.md#callstate)
number:电话号码 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -324,12 +457,14 @@ off(type: 'callStateChange', callback?: Callback<{ state: CallState, number: str **参数:** | 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 通话状态变化事件 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | +| type | string | 是 | 通话状态变化事件,参数固定为'callStateChange'。 | | callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | 否 | 回调函数,参考call的[CallState](js-apis-call.md#callstate)
number:电话号码 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -363,11 +498,13 @@ on\(type: 'cellularDataConnectionStateChange', callback: Callback\<{ state: Data | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 蜂窝数据链路连接状态事件 | +| type | string | 是 | 蜂窝数据链路连接状态事件,参数固定为'cellularDataConnectionStateChange'。| | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | 是 | 回调函数,参考data的[DataConnectState](js-apis-telephony-data.md#dataconnectstate),radio的[RadioTechnology](js-apis-radio.md#radiotechnology)。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -397,12 +534,14 @@ on\(type: 'cellularDataConnectionStateChange', options: { slotId: number }, call | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 蜂窝数据链路连接状态事件 | +| type | string | 是 | 蜂窝数据链路连接状态事件,参数固定为'cellularDataConnectionStateChange'。| | slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | 是 | 回调函数,参考data的[DataConnectState](js-apis-telephony-data.md#dataconnectstate),radio的[RadioTechnology](js-apis-radio.md#radiotechnology)。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -436,11 +575,13 @@ off\(type: 'cellularDataConnectionStateChange', callback?: Callback\<{ state: D | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 蜂窝数据链路连接状态事件 | +| type | string | 是 | 蜂窝数据链路连接状态事件,参数固定为'cellularDataConnectionStateChange'。| | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | 否 | 回调函数,参考data的[DataConnectState](js-apis-telephony-data.md#dataconnectstate),radio的[RadioTechnology](js-apis-radio.md#radiotechnology)。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -474,11 +615,13 @@ on\(type: 'cellularDataFlowChange', callback: Callback\\): void; | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 蜂窝数据业务的上下行数据流状态状态事件 | +| type | string | 是 | 蜂窝数据业务的上下行数据流状态状态事件,参数固定为'cellularDataFlowChange'。 | | callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | 是 | 回调函数,参考data的[DataFlowType](js-apis-telephony-data.md#dataflowtype)。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -508,12 +651,14 @@ on\(type: 'cellularDataFlowChange', options: { slotId: number }, callback: Call | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 蜂窝数据业务的上下行数据流状态事件 | -| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | +| type | string | 是 | 蜂窝数据业务的上下行数据流状态状态事件,参数固定为'cellularDataFlowChange'。 | +| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | | callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | 是 | 回调函数,参考data的[DataFlowType](js-apis-telephony-data.md#dataflowtype)。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -545,13 +690,15 @@ off\(type: 'cellularDataFlowChange', callback?: Callback\\): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | 蜂窝数据业务的上下行数据流状态事件 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 蜂窝数据业务的上下行数据流状态状态事件,参数固定为'cellularDataFlowChange'。 | | callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | 否 | 回调函数,参考data的[DataFlowType](js-apis-telephony-data.md#dataflowtype)。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -584,12 +731,14 @@ on\(type: 'simStateChange', callback: Callback\\): void; **参数:** | 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | sim状态更改事件 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | +| type | string | 是 | sim状态更改事件,参数固定为'simStateChange'。 | | callback | Callback\<[SimStateData](#simstatedata7)\> | 是 | 回调函数。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -619,12 +768,14 @@ on\(type: 'simStateChange', options: { slotId: number }, callback: Callback\- 0:卡槽1
- 1:卡槽2 | | callback | Callback\<[SimStateData](#simstatedata7)\> | 是 | 回调函数。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -658,11 +809,13 @@ off\(type: 'simStateChange', callback?: Callback\\): void; | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | 是 | sim状态更改事件 | +| type | string | 是 | sim状态更改事件,参数固定为'simStateChange'。 | | callback | Callback\<[SimStateData](#simstatedata7)\> | 否 | 回调函数。 | **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | 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 b99b134d6a67d8eb2ddb534ad5b76a8682527a1e..dfe530d7cbc066330dff01f5f35a35a97ecc6654 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md @@ -326,9 +326,9 @@ checkOsAccountConstraintEnabled(localId: number, constraint: string, callback: A | 错误码ID | 错误信息 | | -------- | ------------------- | -| 12300001 | system service exception. | -| 12300002 | invalid localId or constraint. | -| 12300003 | the account indicated by localId dose not exist. | +| 12300001 | System service exception. | +| 12300002 | Invalid localId or constraint. | +| 12300003 | Account not found. | **示例:** 判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束 @@ -376,9 +376,9 @@ checkOsAccountConstraintEnabled(localId: number, constraint: string): Promise< | 错误码ID | 错误信息 | | -------- | ------------------- | -| 12300001 | system service exception. | -| 12300002 | invalid localId or constraint. | -| 12300003 | the account indicated by localId dose not exist. | +| 12300001 | System service exception. | +| 12300002 | Invalid localId or constraint. | +| 12300003 | Account not found. | **示例:** 判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束 @@ -487,7 +487,7 @@ checkOsAccountVerified(callback: AsyncCallback<boolean>): void | 错误码ID | 错误信息 | | -------- | ------------------- | -| 12300001 | system service exception. | +| 12300001 | System service exception. | **示例:** @@ -527,9 +527,9 @@ checkOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): | 错误码ID | 错误信息 | | -------- | ------------------- | -| 12300001 | system service exception. | -| 12300002 | invalid localId. | -| 12300003 | the account indicated by localId dose not exist. | +| 12300001 | System service exception. | +| 12300002 | Invalid localId. | +| 12300003 | Account not found. | **示例:** @@ -575,9 +575,9 @@ checkOsAccountVerified(localId: number): Promise<boolean> | 错误码ID | 错误信息 | | -------- | ------------------- | -| 12300001 | system service exception. | -| 12300002 | invalid localId. | -| 12300003 | the account indicated by localId dose not exist. | +| 12300001 | System service exception. | +| 12300002 | Invalid localId. | +| 12300003 | Account not found. | **示例:** @@ -720,7 +720,7 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl | 错误码ID | 错误信息 | | -------- | ------------------- | | 12300001 | System service exception. | -| 12300002 | Invalid localId. | +| 12300002 | Invalid localId or constraints. | | 12300003 | Account not found. | | 12300008 | Restricted Account. | @@ -774,7 +774,7 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl | 错误码ID | 错误信息 | | -------- | ------------------- | | 12300001 | System service exception. | -| 12300002 | Invalid localId. | +| 12300002 | Invalid localId or constraints. | | 12300003 | Account not found. | | 12300008 | Restricted Account. | @@ -987,7 +987,7 @@ getOsAccountLocalId(callback: AsyncCallback<number>): void | 错误码ID | 错误信息 | | -------- | ------------------- | -| 12300001 | system service exception. | +| 12300001 | System service exception. | **示例:** @@ -1024,7 +1024,7 @@ getOsAccountLocalId(): Promise<number> | 错误码ID | 错误信息 | | -------- | ------------------- | -| 12300001 | system service exception. | +| 12300001 | System service exception. | **示例:** @@ -1060,8 +1060,8 @@ getOsAccountLocalIdForUid(uid: number, callback: AsyncCallback<number>): v | 错误码ID | 错误信息 | | -------- | --------------- | -| 12300001 | system service exception. | -| 12300002 | invalid uid. | +| 12300001 | System service exception. | +| 12300002 | Invalid uid. | **示例:** 查询值为12345678的uid所属的系统帐号的帐号ID @@ -1104,8 +1104,8 @@ getOsAccountLocalIdForUid(uid: number): Promise<number> | 错误码ID | 错误信息 | | -------- | ------------- | -| 12300001 | system service exception. | -| 12300002 | invalid uid. | +| 12300001 | System service exception. | +| 12300002 | Invalid uid. | **示例:** 查询值为12345678的uid所属的系统帐号ID @@ -1144,8 +1144,8 @@ getOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo, callback: AsyncCallb | 错误码ID | 错误信息 | | -------- | ------------- | -| 12300001 | system service exception. | -| 12300002 | invalid domainInfo. | +| 12300001 | System service exception. | +| 12300002 | Invalid domainInfo. | **示例:** @@ -1191,8 +1191,8 @@ getOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo): Promise<number&g | 错误码ID | 错误信息 | | -------- | ------------- | -| 12300001 | system service exception. | -| 12300002 | invalid domainInfo. | +| 12300001 | System service exception. | +| 12300002 | Invalid domainInfo. | **示例:** @@ -1470,7 +1470,7 @@ getActivatedOsAccountLocalIds(callback: AsyncCallback<Array<number>> | 错误码ID | 错误信息 | | -------- | ------------- | -| 12300001 | system service exception. | +| 12300001 | System service exception. | **示例:** @@ -1507,7 +1507,7 @@ getActivatedOsAccountLocalIds(): Promise<Array<number>> | 错误码ID | 错误信息 | | -------- | ------------- | -| 12300001 | system service exception. | +| 12300001 | System service exception. | **示例:** @@ -1858,7 +1858,7 @@ queryOsAccountById(localId: number): Promise<OsAccountInfo> | 错误码ID | 错误信息 | | -------- | ------------------- | | 12300001 | System service exception. | -| 12300002 | Invalid localId. | +| 12300002 | Invalid localId. | | 12300003 | Account not found. | **示例:** 查询ID为100的系统帐号信息 @@ -2229,9 +2229,9 @@ getOsAccountLocalIdForSerialNumber(serialNumber: number, callback: AsyncCallback | 错误码ID | 错误信息 | | -------- | ------------------- | -| 12300001 | system service exception. | -| 12300002 | invalid serialNumber. | -| 12300003 | the account indicated by serialNumber dose not exist. | +| 12300001 | System service exception. | +| 12300002 | Invalid serialNumber. | +| 12300003 | The account indicated by serialNumber dose not exist. | **示例:** 查询与SN码12345关联的系统帐号的ID @@ -2272,9 +2272,9 @@ getOsAccountLocalIdForSerialNumber(serialNumber: number): Promise<number> | 错误码ID | 错误信息 | | -------- | ------------------- | -| 12300001 | system service exception. | -| 12300002 | invalid serialNumber. | -| 12300003 | the account indicated by serialNumber dose not exist. | +| 12300001 | System service exception. | +| 12300002 | Invalid serialNumber. | +| 12300003 | The account indicated by serialNumber dose not exist. | **示例:** 查询与SN码12345关联的系统帐号的ID @@ -2311,9 +2311,9 @@ getSerialNumberForOsAccountLocalId(localId: number, callback: AsyncCallback<n | 错误码ID | 错误信息 | | -------- | ------------------- | -| 12300001 | system service exception. | -| 12300002 | invalid localId. | -| 12300003 | the account indicated by localId dose not exist. | +| 12300001 | System service exception. | +| 12300002 | Invalid localId. | +| 12300003 | Account not found. | **示例:** 获取ID为100的系统帐号关联的SN码 @@ -2354,9 +2354,9 @@ getSerialNumberForOsAccountLocalId(localId: number): Promise<number> | 错误码ID | 错误信息 | | -------- | ------------------- | -| 12300001 | system service exception. | -| 12300002 | invalid localId. | -| 12300003 | the account indicated by localId dose not exist. | +| 12300001 | System service exception. | +| 12300002 | Invalid localId. | +| 12300003 | Account not found. | **示例:** 获取ID为100的系统帐号关联的SN码 @@ -2400,7 +2400,6 @@ on(type: 'activate' | 'activating', name: string, callback: Callback<number&g | -------- | ------------- | | 12300001 | System service exception. | | 12300002 | Invalid type or name. | -| 12300011 | Callback has been registered. | **示例:** @@ -2442,7 +2441,6 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback<number | -------- | ------------- | | 12300001 | System service exception. | | 12300002 | Invalid type or name. | -| 12300012 | Callback has not been registered. | **示例:** @@ -2479,8 +2477,8 @@ getBundleIdForUid(uid: number, callback: AsyncCallback<number>): void; | 错误码ID | 错误信息 | | -------- | ------------- | -| 12300001 | system service exception. | -| 12300002 | invalid uid. | +| 12300001 | System service exception. | +| 12300002 | Invalid uid. | **示例:** @@ -2522,8 +2520,8 @@ getBundleIdForUid(uid: number): Promise<number>; | 错误码ID | 错误信息 | | -------- | ------------- | -| 12300001 | system service exception. | -| 12300002 | invalid uid. | +| 12300001 | System service exception. | +| 12300002 | Invalid uid. | **示例:** @@ -2640,9 +2638,9 @@ getOsAccountConstraintSourceTypes(localId: number, constraint: string, callback: | 错误码ID | 错误信息 | | -------- | ------------- | -| 12300001 | system service exception. | -| 12300002 | invalid name or constraint. | -| 12300003 | the account indicated by localId dose not exist. | +| 12300001 | System service exception. | +| 12300002 | Invalid name or constraint. | +| 12300003 | Account not found. | **示例:** @@ -2687,9 +2685,9 @@ getOsAccountConstraintSourceTypes(localId: number, constraint: string): Promise& | 错误码ID | 错误信息 | | -------- | ------------- | -| 12300001 | system service exception. | -| 12300002 | invalid name or constraint. | -| 12300003 | the account indicated by localId dose not exist. | +| 12300001 | System service exception. | +| 12300002 | Invalid name or constraint. | +| 12300003 | Account not found. | **示例:** @@ -4113,9 +4111,9 @@ auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, | 12300101 | Credential is incorrect. | | 12300105 | Unsupported authTrustLevel. | | 12300106 | Unsupported authType. | -| 12300110 | Authentication locked. | +| 12300110 | Authentication is locked. | | 12300111 | Authentication timeout. | -| 12300112 | Authentication service busy. | +| 12300112 | Authentication service is busy. | **示例:** ```js @@ -4172,9 +4170,9 @@ authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLev | 12300101 | Credential is incorrect. | | 12300105 | Unsupported authTrustLevel. | | 12300106 | Unsupported authType. | -| 12300110 | Authentication locked. | +| 12300110 | Authentication is locked. | | 12300111 | Authentication timeout. | -| 12300112 | Authentication service busy. | +| 12300112 | Authentication service is busy. | **示例:** ```js @@ -4282,7 +4280,7 @@ registerInputer(inputer: IInputer): void; | 错误码ID | 错误信息 | | -------- | --------------------------- | | 12300001 | System service exception. | -| 12300102 | Invalid inputer. | +| 12300002 | Invalid inputer. | | 12300103 | Inputer already registered. | **示例:** @@ -4347,7 +4345,7 @@ static registerInputer(authType: AuthType, inputer: IInputer): void | 错误码ID | 错误信息 | | -------- | --------------------------- | | 12300001 | System service exception. | -| 12300102 | Invalid authType or inputer. | +| 12300002 | Invalid authType or inputer. | | 12300103 | The credential inputer has been registered. | | 12300106 | Unsupported authType. | @@ -4716,7 +4714,7 @@ static registerPlugin(plugin: DomainPlugin): void | 错误码ID | 错误信息 | | -------- | --------------------------- | -| 12300201 | the domain plugin has been registered. | +| 12300201 | The domain plugin has been registered. | **示例:** ```js @@ -4783,17 +4781,17 @@ auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUs | 错误码ID | 错误信息 | | -------- | --------------------------- | -| 12300001 | system service exception. | -| 12300002 | invalid domainAccountInfo or credential. | -| 12300003 | domain account does not exist. | -| 12300013 | network exception. | -| 12300101 | authentication failed. | -| 12300109 | authentication is canceled. | -| 12300110 | authentication is locked. | -| 12300111 | authentication timeout. | -| 12300112 | authentication service is busy. | -| 12300113 | authentication service does not exist. | -| 12300114 | authentication service exception. | +| 12300001 | System service exception. | +| 12300002 | Invalid domainAccountInfo or credential. | +| 12300003 | Domain account does not exist. | +| 12300013 | Network exception. | +| 12300101 | Authentication failed. | +| 12300109 | Authentication is canceled. | +| 12300110 | Authentication is locked. | +| 12300111 | Authentication timeout. | +| 12300112 | Authentication service is busy. | +| 12300113 | Authentication service does not exist. | +| 12300114 | Authentication service exception. | **示例:** ```js @@ -4836,16 +4834,16 @@ authWithPopup(callback: IUserAuthCallback): void | 错误码ID | 错误信息 | | -------- | --------------------------- | -| 12300001 | system service exception. | -| 12300003 | no domain account is bound. | -| 12300013 | network exception. | -| 12300101 | authentication failed. | -| 12300109 | authentication is canceled. | -| 12300110 | authentication is locked. | -| 12300111 | authentication timeout. | -| 12300112 | authentication service is busy. | -| 12300113 | authentication service does not exist. | -| 12300114 | authentication service exception. | +| 12300001 | System service exception. | +| 12300003 | No domain account is bound. | +| 12300013 | Network exception. | +| 12300101 | Authentication failed. | +| 12300109 | Authentication is canceled. | +| 12300110 | Authentication is locked. | +| 12300111 | Authentication timeout. | +| 12300112 | Authentication service is busy. | +| 12300113 | Authentication service does not exist. | +| 12300114 | Authentication service exception. | **示例:** ```js @@ -4884,17 +4882,17 @@ authWithPopup(localId: number, callback: IUserAuthCallback): void | 错误码ID | 错误信息 | | -------- | --------------------------- | -| 12300001 | system service exception. | -| 12300002 | invalid localId. | -| 12300003 | no domain account is bound. | -| 12300013 | network exception. | -| 12300101 | authentication failed. | -| 12300109 | authentication is canceled. | -| 12300110 | authentication is locked. | -| 12300111 | authentication timeout. | -| 12300112 | authentication service is busy. | -| 12300113 | authentication service does not exist. | -| 12300114 | authentication service exception. | +| 12300001 | System service exception. | +| 12300002 | Invalid localId. | +| 12300003 | No domain account is bound. | +| 12300013 | Network exception. | +| 12300101 | Authentication failed. | +| 12300109 | Authentication is canceled. | +| 12300110 | Authentication is locked. | +| 12300111 | Authentication timeout. | +| 12300112 | Authentication service is busy. | +| 12300113 | Authentication service does not exist. | +| 12300114 | Authentication service exception. | **示例:** ```js @@ -4933,9 +4931,9 @@ hasAccount(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback<bool | 错误码ID | 错误信息 | | -------- | --------------------------- | -| 12300001 | system service exception. | -| 12300002 | invalid domainAccountInfo. | -| 12300013 | network exception. | +| 12300001 | System service exception. | +| 12300002 | Invalid domainAccountInfo. | +| 12300013 | Network exception. | **示例:** ```js @@ -4984,9 +4982,9 @@ hasAccount(domainAccountInfo: DomainAccountInfo): Promise<boolean> | 错误码ID | 错误信息 | | -------- | --------------------------- | -| 12300001 | system service exception. | -| 12300002 | invalid domainAccountInfo. | -| 12300013 | network exception. | +| 12300001 | System service exception. | +| 12300002 | Invalid domainAccountInfo. | +| 12300013 | Network exception. | **示例:** ```js @@ -5389,7 +5387,6 @@ getAuthInfo(callback: AsyncCallback<Array<EnrolledCredInfo>>): void; | 错误码ID | 错误信息 | | -------- | --------------------- | | 12300001 | System service exception. | -| 12300102 | Credential not found. | **示例:** ```js @@ -5429,7 +5426,6 @@ getAuthInfo(authType: AuthType, callback: AsyncCallback<Array<EnrolledCred | -------- | ------------------- | | 12300001 | System service exception. | | 12300002 | Invalid authType. | -| 12300102 | Credential not found. | **示例:** ```js @@ -5474,7 +5470,6 @@ getAuthInfo(authType?: AuthType): Promise<Array<EnrolledCredInfo>>; | -------- | ------------------- | | 12300001 | System service exception. | | 12300002 | Invalid authType. | -| 12300102 | Credential not found. | **示例:** ```js @@ -5513,6 +5508,12 @@ onSetData: (authSubType: AuthSubType, data: Uint8Array) => void; | authSubType | [AuthSubType](#authsubtype8) | 是 | 用于认证的凭据子类型。 | | data | Uint8Array | 是 | 要设置的数据是凭据,用来在认证、添加、修改凭据操作。 | +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | ------------------- | +| 12300002 | Invalid pinSubType. | + **示例:** ```js let password = new Uint8Array([0, 0, 0, 0, 0, 0]); @@ -5975,7 +5976,7 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void; | ----------- | ------ | ---- | ---------- | | domain | string | 是 | 域名。 | | accountName | string | 是 | 域帐号名。 | -| accountId10+ | string | 否 | 域帐号标识。 | +| accountId10+ | string | 否 | 域帐号标识。
**系统接口:** 此接口为系统接口。 | ## 系统帐号约束列表 diff --git a/zh-cn/application-dev/reference/apis/js-apis-overlay.md b/zh-cn/application-dev/reference/apis/js-apis-overlay.md index 0d14da22d3ec2677e626d7f086242ad5af5ca3d5..3faa6159a50e121b6b2c99e548cfd0afa3cb8506 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-overlay.md +++ b/zh-cn/application-dev/reference/apis/js-apis-overlay.md @@ -6,8 +6,6 @@ > > 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -本模块接口为系统接口。 - ## 导入模块 ``` ts @@ -41,8 +39,8 @@ setOverlayEnabled(moduleName:string, isEnabled: boolean): Promise\; | 错误码ID | 错误信息 | | ------ | -------------------------------------- | -| 17700002 | The specified moduleName is not existed. | -| 17700033 | The specified moduleName is not overlay module. | +| 17700002 | The specified module name is not found. | +| 17700033 | The specified module is not an overlay module. | **示例:** @@ -76,7 +74,7 @@ setOverlayEnabled(moduleName:string, isEnabled: boolean, callback: AsyncCallback | ----------- | ------ | ---- | --------------------------------------- | | moduleName | string | 是 | overlay特征module的HAP名称。 | | isEnabled | boolean | 是 | 值为true表示使能,值为false表示禁用。| -| callback | AsyncCallback\ | 是 | 回调函数,当设置处置状态成功,err为undefined,否则为错误对象。 | +| callback | AsyncCallback\ | 是 | 回调函数,当设置指定module的overlay禁用使能状态成功时,err为undefined,否则为错误对象。 | **错误码:** @@ -84,8 +82,8 @@ setOverlayEnabled(moduleName:string, isEnabled: boolean, callback: AsyncCallback | 错误码ID | 错误信息 | | ------ | -------------------------------------- | -| 17700002 | The specified moduleName is not existed. | -| 17700033 | The specified moduleName is not overlay module. | +| 17700002 | The specified module name is not found. | +| 17700033 | The specified module is not an overlay module. | **示例:** @@ -138,10 +136,10 @@ setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: b | 错误码ID | 错误信息 | | ------ | -------------------------------------- | -| 17700001 | The specified bundleName is not found. | -| 17700002 | The specified moduleName is not existed. | -| 17700032 | The specified bundleName does not contain any overlay module. | -| 17700033 | The specified moduleName is not overlay module. | +| 17700001 | The specified bundleName is not found. | +| 17700002 | The specified module name is not found. | +| 17700032 | The specified bundle does not contain any overlay module. | +| 17700033 | The specified module is not an overlay module. | **示例:** @@ -181,7 +179,7 @@ setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: b | bundleName | string | 是 | 指定应用的bundle名称。 | | moduleName | string | 是 | 指定应用的overlay特征module的HAP名称。 | | isEnabled | boolean | 是 | 值为true表示使能,值为false表示禁用。 | -| callback | AsyncCallback\ | 是 | 回调函数。当获取应用的处置状态成功时,err为undefined,data为获取到的处置状态;否则为错误对象。 | +| callback | AsyncCallback\ | 是 | 回调函数。当设置指定应用的overlay module的禁用使能状态成功时,err为undefined,data为获取到的处置状态;否则为错误对象。 | **错误码:** @@ -189,10 +187,10 @@ setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: b | 错误码ID | 错误信息 | | ------ | -------------------------------------- | -| 17700001 | The specified bundleName is not found. | -| 17700002 | The specified moduleName is not existed. | -| 17700032 | The specified bundleName does not contain any overlay module. | -| 17700033 | The specified moduleName is not overlay module. | +| 17700001 | The specified bundleName is not found. | +| 17700002 | The specified module name is not found. | +| 17700032 | The specified bundle does not contain any overlay module. | +| 17700033 | The specified module is not an overlay module. | **示例:** @@ -232,7 +230,7 @@ getOverlayModuleInfo(moduleName: string): Promise\; | 类型 | 说明 | | ------------------------- | ------------------ | -| Promise\ | Promise对象,无返回结果的Promise对象 | +| Promise\ | Promise对象,返回OverlayModuleInfo| **错误码:** @@ -240,8 +238,9 @@ getOverlayModuleInfo(moduleName: string): Promise\; | 错误码ID | 错误信息 | | ------ | -------------------------------------- | -| 17700002 | The specified moduleName is not existed. | -| 17700033 | The specified moduleName is not overlay module. | +| 17700002 | The specified module name is not found. | +| 17700032 | he specified bundle does not contain any overlay module. | +| 17700033 | The specified module is not an overlay module. | **示例:** @@ -271,7 +270,7 @@ getOverlayModuleInfo(moduleName: string, callback: AsyncCallback\ | 是 | 回调函数,当设置处置状态成功时,err返回undefined。否则回调函数返回具体错误对象。 | +| callback | AsyncCallback\ | 是 | 回调函数,当获取当前应用中指定的module的overlayModuleInfo信息成功时,err返回undefined。否则回调函数返回具体错误对象。 | **错误码:** @@ -279,8 +278,9 @@ getOverlayModuleInfo(moduleName: string, callback: AsyncCallback\> | Promise对象,无返回结果的Promise对象 | +| Promise\> | Promise对象,返回\> | **错误码:** @@ -325,8 +325,8 @@ getTargetOverlayModuleInfos(targetModuleName: string): Promise\> | 是 | 回调函数,当设置处置状态成功时,err返回undefined。否则回调函数返回具体错误对象。 | +| callback | AsyncCallback\> | 是 | 回调函数,当获取指定的目标module的OverlayModuleInfo成功时,err返回undefined。否则回调函数返回具体错误对象。 | **错误码:** @@ -364,8 +364,8 @@ getTargetOverlayModuleInfos(targetModuleName: string, callback: AsyncCallback\> | Promise对象,无返回结果的Promise对象 | +| Promise\> | Promise对象,返回\ | **错误码:** @@ -416,9 +416,9 @@ getOverlayModuleInfoByBundleName(bundleName: string, moduleName?: string): Promi | 错误码ID | 错误信息 | | ------ | -------------------------------------- | | 17700001 | The specified bundleName is not found | -| 17700002 | The specified moduleName is not existed. | -| 17700032 | The specified bundleName does not contain any overlay module. | -| 17700033 | The specified moduleName is not overlay module. | +| 17700002 | The specified module name is not found. | +| 17700032 | The specified bundle does not contain any overlay module. | +| 17700033 | The specified module is not an overlay module. | **示例:** @@ -454,7 +454,7 @@ getOverlayModuleInfoByBundleName(bundleName: string, moduleName: string, callbac | ----------- | ------ | ---- | --------------------------------------- | | bundleName | string | 是 | 指定应用的bundle名称。 | | moduleName | string | 是 | 指定应用中的overlay module的HAP名称。缺省该字段时,查询接口将查询指定应用中所有module的OverlayModuleInfo信息。 | -| callback | AsyncCallback\> | 是 | 回调函数,当设置处置状态成功时,err返回undefined。否则回调函数返回具体错误对象。 | +| callback | AsyncCallback\> | 是 | 回调函数,当获取指定应用中指定module的OverlayModuleInfo信息成功时,err返回undefined。否则回调函数返回具体错误对象。 | **错误码:** @@ -463,9 +463,9 @@ getOverlayModuleInfoByBundleName(bundleName: string, moduleName: string, callbac | 错误码ID | 错误信息 | | ------ | -------------------------------------- | | 17700001 | The specified bundleName is not found | -| 17700002 | The specified moduleName is not existed. | -| 17700032 | The specified bundleName does not contain any overlay module. | -| 17700033 | The specified moduleName is not overlay module. | +| 17700002 | The specified module name is not found. | +| 17700032 | The specified bundle does not contain any overlay module. | +| 17700033 | The specified module is not an overlay module. | **示例:** @@ -503,7 +503,7 @@ getOverlayModuleInfoByBundleName(bundleName: string, callback: AsyncCallback\> | 是 | 回调函数,当设置处置状态成功时,err返回undefined。否则回调函数返回具体错误对象。 | +| callback | AsyncCallback\> | 是 | 回调函数,当获取指定应用中所有module的OverlayModuleInfo信息成功时,err返回undefined。否则回调函数返回具体错误对象。 | **错误码:** @@ -512,9 +512,9 @@ getOverlayModuleInfoByBundleName(bundleName: string, callback: AsyncCallback\> | Promise对象,无返回结果的Promise对象 | +| Promise\> | Promise对象,返回\> | **错误码:** @@ -566,9 +566,9 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName?: s | 错误码ID | 错误信息 | | ------ | -------------------------------------- | | 17700001 | The specified bundleName is not found | -| 17700002 | The specified moduleName is not existed. | -| 17700034 | The specified moduleName is overlay module. | -| 17700035 | The specified bundleName is overlay bundle. | +| 17700002 | The specified module name is not found. | +| 17700034 | The specified module is an overlay module. | +| 17700035 | The specified bundle is an overlay bundle. | **示例:** @@ -603,8 +603,8 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName: st | 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | targetBundleName | string | 是 | 指定目标应用的bundle名称。 | -| moduleName | string | 否 | 指定应用中的目标module的HAP名称。缺省该字段时,查询接口将查询指定应用中所有module所关联的OverlayModuleInfo信息。 | -| callback | AsyncCallback\> | 是 | 回调函数,当设置处置状态成功时,err返回undefined。否则回调函数返回具体错误对象。 | +| moduleName | string | 是 | 指定应用中的目标module的HAP名称。缺省该字段时,查询接口将查询指定应用中所有module所关联的OverlayModuleInfo信息。 | +| callback | AsyncCallback\> | 是 | 回调函数,当获取指定应用中指定module关联的所有OverlayModuleInfo信息成功时,err返回undefined。否则回调函数返回具体错误对象。 | **错误码:** @@ -613,9 +613,9 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName: st | 错误码ID | 错误信息 | | ------ | -------------------------------------- | | 17700001 | The specified bundleName is not found | -| 17700002 | The specified moduleName is not existed. | -| 17700034 | The specified moduleName is overlay module. | -| 17700035 | The specified bundleName is overlay bundle. | +| 17700002 | The specified module name is not found. | +| 17700034 | The specified module is an overlay module. | +| 17700035 | The specified bundle is an overlay bundle. | **示例:** @@ -653,7 +653,7 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, callback: Asyn | 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | targetBundleName | string | 是 | 指定目标应用的bundle名称。 | -| callback | AsyncCallback\> | 是 | 回调函数,当设置处置状态成功时,err返回undefined。否则回调函数返回具体错误对象。 | +| callback | AsyncCallback\> | 是 | 回调函数,当获取指定应用中所有module关联的所有OverlayModuleInfo信息成功时,err返回undefined。否则回调函数返回具体错误对象。 | **错误码:** @@ -662,9 +662,9 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, callback: Asyn | 错误码ID | 错误信息 | | ------ | -------------------------------------- | | 17700001 | The specified bundleName is not found | -| 17700002 | The specified moduleName is not existed. | -| 17700034 | The specified moduleName is overlay module. | -| 17700035 | The specified bundleName is overlay bundle. | +| 17700002 | The specified module name is not found. | +| 17700034 | The specified module is an overlay module. | +| 17700035 | The specified bundle is an overlay bundle. | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-power.md b/zh-cn/application-dev/reference/apis/js-apis-power.md index 3e253f3241eb521b5faf08d1e6f78bde517fdcb0..47027996ffa8ed2db9b6f5161700d2b7f561e4da 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-power.md +++ b/zh-cn/application-dev/reference/apis/js-apis-power.md @@ -293,7 +293,7 @@ power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE) rebootDevice(reason: string): void -> **说明:**
从API version 9开始不再维护,建议使用[power.reboot](#powerreboot9)替代。 +> **说明:**
从API version 7开始支持,从API version 9开始不再维护。建议使用[power.reboot](#powerreboot9)替代,替代接口能力仅对系统应用开放。 重启设备。 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 a8abc368b6b5652bdc11d892ae2b22db21d6f647..84beb19662ebd11529f7256c4ae745b6b5220e37 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md @@ -46,8 +46,8 @@ addPermissionUsedRecord(tokenID: number, permissionName: Permissions, successCou | 错误码ID | 错误信息 | | -------- | -------- | | 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256, or the count value is invalid. | -| 12100002 | The specified tokenID does not exist or it does not refer to an application process. | -| 12100003 | The specified permission does not exist or it is not an user_grant permission. | +| 12100002 | The specified tokenID does not exist or refer to an application process. | +| 12100003 | The specified permission does not exist or is not an user_grant permission. | | 12100007 | Service is abnormal. | | 12100008 | Out of memory. | @@ -96,8 +96,8 @@ addPermissionUsedRecord(tokenID: number, permissionName: Permissions, successCou | 错误码ID | 错误信息 | | -------- | -------- | | 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256, or the count value is invalid. | -| 12100002 | The specified tokenID does not exist or it does not refer to an application process. | -| 12100003 | The specified permission does not exist or it is not an user_grant permission. | +| 12100002 | The specified tokenID does not exist or refer to an application process. | +| 12100003 | The specified permission does not exist or is not an user_grant permission. | | 12100007 | Service is abnormal. | | 12100008 | Out of memory. | @@ -149,8 +149,8 @@ getPermissionUsedRecord(request: PermissionUsedRequest): Promise<PermissionUs | 错误码ID | 错误信息 | | -------- | -------- | | 12100001 | The parameter is invalid. the value of flag in request is invalid. | -| 12100002 | The specified tokenID does not exist or it does not refer to an application process. | -| 12100003 | The specified permission does not exist or it is not an user_grant permission. | +| 12100002 | The specified tokenID does not exist or refer to an application process. | +| 12100003 | The specified permission does not exist or is not an user_grant permission. | | 12100007 | Service is abnormal. | | 12100008 | Out of memory. | @@ -204,8 +204,8 @@ getPermissionUsedRecord(request: PermissionUsedRequest, callback: AsyncCallback& | 错误码ID | 错误信息 | | -------- | -------- | | 12100001 | The parameter is invalid. the value of flag in request is invalid. | -| 12100002 | The specified tokenID does not exist or it does not refer to an application process. | -| 12100003 | The specified permission does not exist or it is not an user_grant permission. | +| 12100002 | The specified tokenID does not exist or refer to an application process. | +| 12100003 | The specified permission does not exist or is not an user_grant permission. | | 12100007 | Service is abnormal. | | 12100008 | Out of memory. | @@ -267,8 +267,8 @@ startUsingPermission(tokenID: number, permissionName: Permissions): Promise<v | 错误码ID | 错误信息 | | -------- | -------- | | 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. | -| 12100002 | The specified tokenID does not exist or it does not refer to an application process. | -| 12100003 | The specified permission does not exist or it is not an user_grant permission. | +| 12100002 | The specified tokenID does not exist or refer to an application process. | +| 12100003 | The specified permission does not exist or is not an user_grant permission. | | 12100004 | The interface is called repeatedly with the same input. It means the application specified by the tokenID has been using the specified permission. | | 12100007 | Service is abnormal. | | 12100008 | Out of memory. | @@ -315,8 +315,8 @@ startUsingPermission(tokenID: number, permissionName: Permissions, callback: Asy | 错误码ID | 错误信息 | | -------- | -------- | | 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. | -| 12100002 | The specified tokenID does not exist or it does not refer to an application process. | -| 12100003 | The specified permission does not exist or it is not an user_grant permission. | +| 12100002 | The specified tokenID does not exist or refer to an application process. | +| 12100003 | The specified permission does not exist or is not an user_grant permission. | | 12100004 | The interface is called repeatedly with the same input. It means the application specified by the tokenID has been using the specified permission. | | 12100007 | Service is abnormal. | | 12100008 | Out of memory. | @@ -370,8 +370,8 @@ stopUsingPermission(tokenID: number, permissionName: Permissions): Promise<vo | 错误码ID | 错误信息 | | -------- | -------- | | 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. | -| 12100002 | The specified tokenID does not exist or it does not refer to an application process. | -| 12100003 | The specified permission does not exist or it is not an user_grant permission. | +| 12100002 | The specified tokenID does not exist or refer to an application process. | +| 12100003 | The specified permission does not exist or is not an user_grant permission. | | 12100004 | The interface is not used with | | 12100007 | Service is abnormal. | | 12100008 | Out of memory. | @@ -418,8 +418,8 @@ stopUsingPermission(tokenID: number, permissionName: Permissions, callback: Asyn | 错误码ID | 错误信息 | | -------- | -------- | | 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. | -| 12100002 | The specified tokenID does not exist or it does not refer to an application process. | -| 12100003 | The specified permission does not exist or it is not an user_grant permission. | +| 12100002 | The specified tokenID does not exist or refer to an application process. | +| 12100003 | The specified permission does not exist or is not an user_grant permission. | | 12100004 | The interface is not used with | | 12100007 | Service is abnormal. | | 12100008 | Out of memory. | @@ -512,7 +512,7 @@ off(type: 'activeStateChange', permissionList: Array<Permissions>, callbac | 错误码ID | 错误信息 | | -------- | -------- | -| 12100001 | The parameter is invalid. The permissionName in list is all invalid or the list size is larger than 1024. | +| 12100001 | The permissionNames in the list are all invalid, or the list size exceeds 1024 bytes. | | 12100004 | The interface is not used together with "on"| | 12100007 | Service is abnormal. | | 12100008 | Out of memory. | 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 6c62e6118b310315f335d472f3ccae9c4467ec0d..c5746422ef06f7aa7bd5a198c17e5281d74f0564 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-radio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-radio.md @@ -32,6 +32,8 @@ getRadioTech\(slotId: number, callback: AsyncCallback<\{psRadioTech: RadioTechno **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -75,6 +77,8 @@ getRadioTech\(slotId: number\): Promise<\{psRadioTech: RadioTechnology, csRadioT **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -115,6 +119,8 @@ getNetworkState\(callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -152,6 +158,8 @@ getNetworkState\(slotId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -195,6 +203,8 @@ getNetworkState\(slotId?: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -234,6 +244,8 @@ getNetworkSelectionMode\(slotId: number, callback: AsyncCallback **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -312,6 +326,8 @@ getISOCountryCodeForNetwork\(slotId: number, callback: AsyncCallback\): **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -352,6 +368,8 @@ getISOCountryCodeForNetwork\(slotId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -389,12 +407,13 @@ getPrimarySlotId\(callback: AsyncCallback\\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **示例:** @@ -422,12 +441,13 @@ getPrimarySlotId\(\): Promise\ **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **示例:** @@ -459,6 +479,8 @@ getSignalInformation\(slotId: number, callback: AsyncCallback\> **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -646,6 +670,8 @@ isRadioOn\(callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -683,6 +709,8 @@ isRadioOn\(slotId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -726,6 +754,8 @@ isRadioOn\(slotId?: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -765,6 +795,8 @@ getOperatorName\(slotId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -805,6 +837,8 @@ getOperatorName\(slotId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -846,6 +880,8 @@ setPrimarySlotId(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -860,8 +896,8 @@ setPrimarySlotId(slotId: number, callback: AsyncCallback): void ```js let slotId = 0; -radio.setPrimarySlotId(slotId, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +radio.setPrimarySlotId(slotId, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -892,6 +928,8 @@ setPrimarySlotId\(slotId: number\): Promise\ **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -907,9 +945,9 @@ setPrimarySlotId\(slotId: number\): Promise\ ```js let slotId = 0; let promise = radio.setPrimarySlotId(slotId); -promise.then(data => { - console.log(`setPrimarySlotId success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`setPrimarySlotId success.`); +}).catch((err) => { console.log(`setPrimarySlotId failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -934,6 +972,8 @@ getIMEI(callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -973,6 +1013,8 @@ getIMEI(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1018,6 +1060,8 @@ getIMEI(slotId?: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1059,6 +1103,8 @@ getMEID(callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1098,6 +1144,8 @@ getMEID(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1143,6 +1191,8 @@ getMEID(slotId?: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1184,6 +1234,8 @@ getUniqueDeviceId(callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1223,6 +1275,8 @@ getUniqueDeviceId(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1268,6 +1322,8 @@ getUniqueDeviceId(slotId?: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1309,6 +1365,8 @@ sendUpdateCellLocationRequest\(callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1321,8 +1379,8 @@ sendUpdateCellLocationRequest\(callback: AsyncCallback\): void **示例:** ```js -radio.sendUpdateCellLocationRequest((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +radio.sendUpdateCellLocationRequest((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1347,6 +1405,8 @@ sendUpdateCellLocationRequest\(slotId: number, callback: AsyncCallback\): **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1360,8 +1420,8 @@ sendUpdateCellLocationRequest\(slotId: number, callback: AsyncCallback\): ```js let slotId = 0; -radio.sendUpdateCellLocationRequest(slotId, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +radio.sendUpdateCellLocationRequest(slotId, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1391,6 +1451,8 @@ sendUpdateCellLocationRequest\(slotId?: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1404,10 +1466,9 @@ sendUpdateCellLocationRequest\(slotId?: number): Promise ```js let slotId = 0; -let promise = radio.sendUpdateCellLocationRequest(slotId); -promise.then(data => { - console.log(`sendUpdateCellLocationRequest success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +radio.sendUpdateCellLocationRequest(slotId).then(() => { + console.log(`sendUpdateCellLocationRequest success.`); +}).catch((err) => { console.log(`sendUpdateCellLocationRequest failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1432,6 +1493,8 @@ getCellInformation(callback: AsyncCallback>): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1471,6 +1534,8 @@ getCellInformation(slotId: number, callback: AsyncCallback\> **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1558,6 +1625,8 @@ setNetworkSelectionMode\(options: NetworkSelectionModeOptions, callback: AsyncCa **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1582,8 +1651,8 @@ let networkSelectionModeOptions={ networkInformation: networkInformation, resumeSelection: true } -radio.setNetworkSelectionMode(networkSelectionModeOptions, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +radio.setNetworkSelectionMode(networkSelectionModeOptions, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1613,6 +1682,8 @@ setNetworkSelectionMode\(options: NetworkSelectionModeOptions\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1638,9 +1709,9 @@ let networkSelectionModeOptions={ resumeSelection: true } let promise = radio.setNetworkSelectionMode(networkSelectionModeOptions); -promise.then(data => { - console.log(`setNetworkSelectionMode success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`setNetworkSelectionMode success.`); +}).catch((err) => { console.log(`setNetworkSelectionMode failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1666,6 +1737,8 @@ getNetworkSearchInformation\(slotId: number, callback: AsyncCallback **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1747,6 +1822,8 @@ getNrOptionMode(callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1783,6 +1860,8 @@ getNrOptionMode(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1825,6 +1904,8 @@ getNrOptionMode(slotId?: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1865,6 +1946,8 @@ turnOnRadio(callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1877,8 +1960,8 @@ turnOnRadio(callback: AsyncCallback): void **示例:** ```js -radio.turnOnRadio((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +radio.turnOnRadio((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1904,6 +1987,8 @@ turnOnRadio(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1917,8 +2002,8 @@ turnOnRadio(slotId: number, 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(slotId, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1949,6 +2034,8 @@ turnOnRadio(slotId?: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1962,10 +2049,9 @@ turnOnRadio(slotId?: number): Promise ```js let slotId = 0; -let promise = radio.turnOnRadio(slotId); -promise.then(data => { - console.log(`turnOnRadio success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +radio.turnOnRadio(slotId).then(() => { + console.log(`turnOnRadio success.`); +}).catch((err) => { console.error(`turnOnRadio failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1990,6 +2076,8 @@ turnOffRadio(callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2002,8 +2090,8 @@ turnOffRadio(callback: AsyncCallback): void **示例:** ```js -radio.turnOffRadio((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +radio.turnOffRadio((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2029,6 +2117,8 @@ turnOffRadio(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2042,8 +2132,8 @@ turnOffRadio(slotId: number, 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(slotId, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2074,6 +2164,8 @@ turnOffRadio(slotId?: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2087,10 +2179,9 @@ turnOffRadio(slotId?: number): Promise ```js let slotId = 0; -let promise = radio.turnOffRadio(slotId); -promise.then(data => { - console.log(`turnOffRadio success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +radio.turnOffRadio(slotId).then(() => { + console.log(`turnOffRadio success.`); +}).catch((err) => { console.error(`turnOffRadio failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2117,6 +2208,8 @@ setPreferredNetwork\(slotId: number, networkMode: PreferredNetworkMode, callback **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2129,8 +2222,9 @@ setPreferredNetwork\(slotId: number, networkMode: PreferredNetworkMode, callback **示例:** ```js -radio.setPreferredNetwork(0, 1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +let slotId = 0; +radio.setPreferredNetwork(slotId, radio.PreferredNetworkMode.PREFERRED_NETWORK_MODE_GSM, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2161,7 +2255,9 @@ setPreferredNetwork(slotId: number, networkMode: PreferredNetworkMode): Promise< **错误码:** -| 错误码ID | 错误信息 | +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + +| 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | | 401 | Parameter error. | @@ -2173,10 +2269,10 @@ setPreferredNetwork(slotId: number, networkMode: PreferredNetworkMode): Promise< **示例:** ```js -let promise = radio.setPreferredNetwork(0, 1); -promise.then(data => { - console.log(`setPreferredNetwork success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +let slotId = 0; +radio.setPreferredNetwork(slotId, radio.PreferredNetworkMode.PREFERRED_NETWORK_MODE_GSM).then(() => { + console.log(`setPreferredNetwork success.`); +}).catch((err) => { console.log(`setPreferredNetwork failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2202,6 +2298,8 @@ getPreferredNetwork\(slotId: number, callback: AsyncCallback **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2287,6 +2387,8 @@ getImsRegInfo(slotId: number, imsType: ImsServiceType, callback: AsyncCallback **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2374,6 +2478,8 @@ on(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback: **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2414,6 +2520,8 @@ off(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | 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 dcf6443aab41e058fb9a23741c3200da1d5e7b4d..f60cfaed73ab60480c0f13be76391cd404214a7c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -16,24 +16,6 @@ import request from '@ohos.request'; ## 限制与约束 - -在开发FA模型下的应用程序时, 默认支持https,如果要支持http,需要在config.json里增加network标签,属性标识 "cleartextTraffic": true。即: - -```js -var config = { - "deviceConfig": { - "default": { - "network": { - "cleartextTraffic": true - } - //... - } - } -} -``` - -在开发stage模型下的应用程序时,不涉及属性标识 "cleartextTraffic"。 - 下载服务器需要支持HTTP协议的head方法,能够通过Content-length获取下载数据大小,否则下载任务失败,可通过[on('fail')7+](#onfail7)查看失败原因。 上传目前仅支持HTTP请求,不支持HTTPS。 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 ca8ea3b810429de53b252355d378cd41d5c1db9c..fde185a857f3003328e25b39b80d3838061c6fd2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-router.md +++ b/zh-cn/application-dev/reference/apis/js-apis-router.md @@ -573,7 +573,7 @@ router.getParams(); | 名称 | 说明 | | -------- | ------------------------------------------------------------ | -| Standard | 标准模式。
目标页面会被添加到页面路由栈顶,无论栈中是否存在相同url的页面。
**说明:**不使用路由跳转模式时,按标准模式跳转。 | +| Standard | 标准模式。
目标页面会被添加到页面路由栈顶,无论栈中是否存在相同url的页面。
**说明:** 不使用路由跳转模式时,按标准模式跳转。 | | Single | 单实例模式。
如果目标页面的url在页面栈中已经存在同url页面,离栈顶最近的页面会被移动到栈顶,移动后的页面为新建页。
如目标页面的url在页面栈中不存在同url页面,按标准模式跳转。 | ## 完整示例 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 b6fd5d7be0c995263715fc242412c1398845055d..d533ba3be47e2b6dfe06320edc602f2057d86c11 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sim.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sim.md @@ -134,13 +134,14 @@ hasOperatorPrivileges(slotId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **示例:** @@ -173,13 +174,14 @@ hasOperatorPrivileges(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **示例:** @@ -210,6 +212,8 @@ getISOCountryCodeForSim\(slotId: number, callback: AsyncCallback\): voi **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -250,6 +254,8 @@ getISOCountryCodeForSim\(slotId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -288,6 +294,8 @@ getSimOperatorNumeric\(slotId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -328,6 +336,8 @@ getSimOperatorNumeric\(slotId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -366,6 +376,8 @@ getSimSpn\(slotId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -406,6 +418,8 @@ getSimSpn\(slotId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -444,13 +458,14 @@ getSimState\(slotId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **示例:** @@ -484,13 +499,14 @@ getSimState\(slotId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **示例:** @@ -521,6 +537,8 @@ getCardType\(slotId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -561,6 +579,8 @@ getCardType\(slotId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -599,13 +619,14 @@ hasSimCard\(slotId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **示例:** @@ -639,13 +660,14 @@ hasSimCard\(slotId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **示例:** @@ -680,6 +702,8 @@ getSimAccountInfo(slotId: number, callback: AsyncCallback): voi **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -726,6 +750,8 @@ getSimAccountInfo(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -768,6 +794,8 @@ getActiveSimAccountInfoList(callback: AsyncCallback>): vo **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -807,6 +835,8 @@ getActiveSimAccountInfoList(): Promise>; **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -849,6 +879,8 @@ setDefaultVoiceSlotId(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -863,8 +895,8 @@ setDefaultVoiceSlotId(slotId: number, callback: AsyncCallback): void **示例:** ```js -sim.setDefaultVoiceSlotId(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sim.setDefaultVoiceSlotId(0, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -895,6 +927,8 @@ setDefaultVoiceSlotId(slotId: number): Promise\ **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -910,9 +944,9 @@ setDefaultVoiceSlotId(slotId: number): Promise\ ```js let promise = sim.setDefaultVoiceSlotId(0); -promise.then(data => { - console.log(`setDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`setDefaultVoiceSlotId success.`); +}).catch((err) => { console.log(`setDefaultVoiceSlotId failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -939,6 +973,8 @@ setShowName\(slotId: number, name: string, callback: AsyncCallback\): voi **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -953,8 +989,8 @@ setShowName\(slotId: number, name: string, callback: AsyncCallback\): voi ```js let name = "ShowName"; -sim.setShowName(0, name, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sim.setShowName(0, name, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -985,6 +1021,8 @@ setShowName\(slotId: number, name: string\): Promise\ **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1000,9 +1038,9 @@ setShowName\(slotId: number, name: string\): Promise\ ```js let name = "ShowName"; let promise = sim.setShowName(0, name); -promise.then(data => { - console.log(`setShowName success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`setShowName success.`); +}).catch((err) => { console.log(`setShowName failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1028,6 +1066,8 @@ getShowName(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1073,6 +1113,8 @@ getShowName(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1116,6 +1158,8 @@ setShowNumber\(slotId: number, number: string, callback: AsyncCallback\): **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1130,8 +1174,8 @@ setShowNumber\(slotId: number, number: string, callback: AsyncCallback\): ```js let number = '+861xxxxxxxxxx'; -sim.setShowNumber(0, number, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sim.setShowNumber(0, number, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1163,6 +1207,8 @@ setShowNumber\(slotId: number, number: string\): Promise\ **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1178,9 +1224,9 @@ setShowNumber\(slotId: number, number: string\): Promise\ ```js let number = '+861xxxxxxxxxx'; let promise = sim.setShowNumber(0, number); -promise.then(data => { - console.log(`setShowNumber success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`setShowNumber success.`); +}).catch((err) => { console.log(`setShowNumber failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1206,6 +1252,8 @@ getShowNumber(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1251,6 +1299,8 @@ getShowNumber(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1293,6 +1343,8 @@ activateSim(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1306,8 +1358,8 @@ activateSim(slotId: number, callback: AsyncCallback): void **示例:** ```js -sim.activateSim(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sim.activateSim(0, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1338,6 +1390,8 @@ activateSim(slotId: number): Promise\ **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1352,9 +1406,9 @@ activateSim(slotId: number): Promise\ ```js let promise = sim.activateSim(0); -promise.then(data => { - console.log(`activateSim success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`activateSim success.`); +}).catch((err) => { console.log(`activateSim failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1380,6 +1434,8 @@ deactivateSim(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1393,8 +1449,8 @@ deactivateSim(slotId: number, callback: AsyncCallback): void **示例:** ```js -sim.deactivateSim(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sim.deactivateSim(0, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1425,6 +1481,8 @@ deactivateSim(slotId: number): Promise\ **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1439,9 +1497,9 @@ deactivateSim(slotId: number): Promise\ ```js let promise = sim.deactivateSim(0); -promise.then(data => { - console.log(`deactivateSim success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`deactivateSim success.`); +}).catch((err) => { console.log(`deactivateSim failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1468,6 +1526,8 @@ setLockState(slotId: number, options: LockInfo, callback: AsyncCallback **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1569,6 +1631,8 @@ getLockState(slotId: number, lockType: LockType, callback: AsyncCallback **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1661,6 +1727,8 @@ alterPin(slotId: number, newPin: string, oldPin: string, callback: AsyncCallback **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1709,6 +1777,8 @@ alterPin(slotId: number, newPin: string, oldPin: string): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -1940,6 +2018,8 @@ unlockPuk(slotId: number, newPin: string, puk: string, callback: AsyncCallback **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2130,6 +2216,8 @@ unlockPuk2(slotId: number, newPin2: string, puk2: string, callback: AsyncCallbac **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2180,6 +2268,8 @@ unlockPuk2(slotId: number, newPin2: string, puk2: string): Promise<LockStatus **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2245,6 +2335,8 @@ getSimIccId(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2290,6 +2382,8 @@ getSimIccId(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2332,6 +2426,8 @@ getVoiceMailIdentifier(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2377,6 +2473,8 @@ getVoiceMailIdentifier(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2419,6 +2517,8 @@ getVoiceMailNumber(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2464,6 +2564,8 @@ getVoiceMailNumber(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2509,6 +2611,8 @@ setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string, callback: **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2523,8 +2627,8 @@ setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string, callback: **示例:** ```js -sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com", (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2557,6 +2661,8 @@ setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string): Promise< **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2572,9 +2678,9 @@ setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string): 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 => { +promise.then(() => { + console.log(`setVoiceMailInfo success.`); +}).catch((err) => { console.log(`setVoiceMailInfo failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2600,6 +2706,8 @@ getSimTelephoneNumber(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2645,6 +2753,8 @@ getSimTelephoneNumber(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2687,6 +2797,8 @@ getSimGid1(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2732,6 +2844,8 @@ getSimGid1(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2774,6 +2888,8 @@ getIMSI(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2819,6 +2935,8 @@ getIMSI(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2861,6 +2979,8 @@ getOperatorConfigs(slotId: number, callback: AsyncCallback> **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2913,7 +3034,6 @@ getOperatorConfigs(slotId: number): Promise> | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **示例:** @@ -2949,6 +3069,8 @@ queryIccDiallingNumbers(slotId: number, type: ContactType, callback: AsyncCallba **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -2996,6 +3118,8 @@ queryIccDiallingNumbers(slotId: number, type: ContactType): Promise { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3094,6 +3220,8 @@ addIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: Dialli **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -3113,9 +3241,9 @@ let diallingNumbersInof = { number: "138xxxxxxxx" }; let promise = sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof); -promise.then(data => { - console.log(`addIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`addIccDiallingNumbers success.`); +}).catch((err) => { console.log(`addIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3143,6 +3271,8 @@ delIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: Dialli **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -3163,8 +3293,8 @@ let diallingNumbersInof = { recordNumber: 123, pin2: "1234" }; -sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3197,6 +3327,8 @@ delIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: Dialli **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -3216,9 +3348,9 @@ let diallingNumbersInof = { number: "138xxxxxxxx" }; let promise = sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof); -promise.then(data => { - console.log(`delIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`delIccDiallingNumbers success.`); +}).catch((err) => { console.log(`delIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3246,6 +3378,8 @@ updateIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: Dia **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -3266,8 +3400,8 @@ let diallingNumbersInof = { recordNumber: 123, pin2: "1234" }; -sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3300,6 +3434,8 @@ updateIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: Dia **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -3320,9 +3456,9 @@ let diallingNumbersInof = { recordNumber: 123 }; let promise = sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof); -promise.then(data => { - console.log(`updateIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`updateIccDiallingNumbers success.`); +}).catch((err) => { console.log(`updateIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3349,6 +3485,8 @@ sendEnvelopeCmd(slotId: number, cmd: string, callback: AsyncCallback): vo **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -3362,8 +3500,8 @@ sendEnvelopeCmd(slotId: number, cmd: string, callback: AsyncCallback): vo **示例:** ```js -sim.sendEnvelopeCmd(0, "ls", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sim.sendEnvelopeCmd(0, "ls", (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3395,6 +3533,8 @@ sendEnvelopeCmd(slotId: number, cmd: string): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -3409,9 +3549,9 @@ sendEnvelopeCmd(slotId: number, cmd: string): Promise ```js let promise = sim.sendEnvelopeCmd(0, "ls"); -promise.then(data => { - console.log(`sendEnvelopeCmd success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`sendEnvelopeCmd success.`); +}).catch((err) => { console.log(`sendEnvelopeCmd failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3438,6 +3578,8 @@ sendTerminalResponseCmd(slotId: number, cmd: string, callback: AsyncCallback { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sim.sendTerminalResponseCmd(0, "ls", (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3484,6 +3626,8 @@ sendTerminalResponseCmd(slotId: number, cmd: string): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -3498,9 +3642,9 @@ sendTerminalResponseCmd(slotId: number, cmd: string): Promise ```js let promise = sim.sendTerminalResponseCmd(0, "ls"); -promise.then(data => { - console.log(`sendTerminalResponseCmd success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`sendTerminalResponseCmd success.`); +}).catch((err) => { console.log(`sendTerminalResponseCmd failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3528,6 +3672,8 @@ unlockSimLock(slotId: number, lockInfo: PersoLockInfo, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -3629,7 +3779,6 @@ getOpKey(slotId: number, callback: AsyncCallback): void | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **示例:** @@ -3671,6 +3820,8 @@ getOpKey(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -3678,7 +3829,6 @@ getOpKey(slotId: number): Promise | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **示例:** @@ -3709,6 +3859,8 @@ getOpName(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -3716,7 +3868,6 @@ getOpName(slotId: number, callback: AsyncCallback): void | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **示例:** @@ -3758,6 +3909,8 @@ getOpName(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -3765,7 +3918,6 @@ getOpName(slotId: number): Promise | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | | 8300003 | System internal error. | -| 8300004 | Do not have sim card. | | 8300999 | Unknown error code. | **示例:** @@ -3847,17 +3999,17 @@ SIM卡状态。 **系统能力**:SystemCapability.Telephony.CoreService -| 名称 | 值 | 说明 | -| ------------ | ---- | ----------------------------------------------- | -| PN_PIN_LOCK | 0 | 定制网络PIN锁*(参照 3GPP TS 22.022 [33])*。 | +| 名称 | 值 | 说明 | +| ------------ | ---- | ------------------------------------------------ | +| 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_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_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_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_PIN_LOCK | 8 | 定制SIM的PIN锁(参照 3GPP TS 22.022 [33])。 | | SIM_PUK_LOCK | 9 | 定制SIM的PUK锁。 | ## LockStatusResponse7+ 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 f828f24f0468381373dd351bd4b7256e7b56e12e..b93e9ac1a15d4eb3f3bc053f63f4ec8facb6f1bb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sms.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sms.md @@ -91,6 +91,19 @@ sendMessage(options: SendMessageOptions): void | ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | options | [SendMessageOptions](#sendmessageoptions) | 是 | 发送短信的参数和回调,参考[SendMessageOptions](#sendmessageoptions)。 | +**错误码:** + +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + +| 错误码ID | 错误信息 | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + **示例:** ```js @@ -179,6 +192,8 @@ setDefaultSmsSlotId\(slotId: number, callback: AsyncCallback<void>\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -192,8 +207,8 @@ setDefaultSmsSlotId\(slotId: number, callback: AsyncCallback<void>\): void **示例:** ```js -sms.setDefaultSmsSlotId(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sms.setDefaultSmsSlotId(0, (err) => { + console.log(`callback: err->${JSON.stringify(err)}.`); }); ``` @@ -224,6 +239,8 @@ setDefaultSmsSlotId\(slotId: number\): Promise<void> **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -238,9 +255,9 @@ setDefaultSmsSlotId\(slotId: number\): Promise<void> ```js let promise = sms.setDefaultSmsSlotId(0); -promise.then(data => { - console.log(`setDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`setDefaultSmsSlotId success.`); +}).catch((err) => { console.error(`setDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -267,6 +284,8 @@ setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback\): **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -281,8 +300,8 @@ setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback\): ```js let slotId = 0; let smscAddr = '+861xxxxxxxxxx'; -sms.setSmscAddr(slotId, smscAddr, (err,data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sms.setSmscAddr(slotId, smscAddr, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -314,6 +333,8 @@ setSmscAddr\(slotId: number, smscAddr: string\): Promise\ **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -329,9 +350,9 @@ setSmscAddr\(slotId: number, smscAddr: string\): Promise\ let slotId = 0; let smscAddr = '+861xxxxxxxxxx'; let promise = sms.setSmscAddr(slotId, smscAddr); -promise.then(data => { - console.log(`setSmscAddr success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`setSmscAddr success.`); +}).catch((err) => { console.error(`setSmscAddr failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -358,6 +379,8 @@ getSmscAddr\(slotId: number, callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -403,6 +426,8 @@ getSmscAddr\(slotId: number\): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -464,6 +489,8 @@ splitMessage(content: string, callback: AsyncCallback>): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -509,6 +536,8 @@ splitMessage(content: string): Promise> **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -551,6 +580,8 @@ addSimMessage(options: SimMessageOptions, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -569,8 +600,8 @@ let simMessageOptions = { pdu: "xxxxxx", status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ }; -sms.addSimMessage(simMessageOptions, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sms.addSimMessage(simMessageOptions, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -601,6 +632,8 @@ addSimMessage(options: SimMessageOptions): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -620,9 +653,9 @@ let simMessageOptions = { status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ }; let promise = sms.addSimMessage(simMessageOptions); -promise.then(data => { - console.log(`addSimMessage success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`addSimMessage success.`); +}).catch((err) => { console.error(`addSimMessage failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -649,6 +682,8 @@ delSimMessage(slotId: number, msgIndex: number, callback: AsyncCallback): **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -663,8 +698,8 @@ delSimMessage(slotId: number, msgIndex: number, callback: AsyncCallback): ```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(slotId, msgIndex, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -696,6 +731,8 @@ delSimMessage(slotId: number, msgIndex: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -711,9 +748,9 @@ delSimMessage(slotId: number, msgIndex: number): Promise 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 => { +promise.then(() => { + console.log(`delSimMessage success.`); +}).catch((err) => { console.error(`delSimMessage failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -739,6 +776,8 @@ updateSimMessage(options: UpdateSimMessageOptions, callback: AsyncCallback { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sms.updateSimMessage(updateSimMessageOptions, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -790,6 +829,8 @@ updateSimMessage(options: UpdateSimMessageOptions): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -810,9 +851,9 @@ let updateSimMessageOptions = { smsc: "test" }; let promise = sms.updateSimMessage(updateSimMessageOptions); -promise.then(data => { - console.log(`updateSimMessage success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`updateSimMessage success.`); +}).catch((err) => { console.error(`updateSimMessage failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -838,6 +879,8 @@ getAllSimMessages(slotId: number, callback: AsyncCallback> **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -925,6 +970,8 @@ setCBConfig(options: CBConfigOptions, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -944,8 +991,8 @@ let cbConfigOptions = { endMessageId: 200, ranType: sms.RanType.TYPE_GSM }; -sms.setCBConfig(cbConfigOptions, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +sms.setCBConfig(cbConfigOptions, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -976,6 +1023,8 @@ setCBConfig(options: CBConfigOptions): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -996,9 +1045,9 @@ let cbConfigOptions = { ranType: sms.RanType.TYPE_GSM }; let promise = sms.setCBConfig(cbConfigOptions); -promise.then(data => { - console.log(`setCBConfig success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +promise.then(() => { + console.log(`setCBConfig success.`); +}).catch((err) => { console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1024,6 +1073,8 @@ getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean, callback **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1068,6 +1119,8 @@ getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1107,6 +1160,8 @@ isImsSmsSupported(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1149,6 +1204,8 @@ isImsSmsSupported(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1187,9 +1244,10 @@ getImsShortMessageFormat(callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | -| 201 | Permission denied. | | 401 | Parameter error. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | @@ -1223,9 +1281,10 @@ getImsShortMessageFormat(): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | -| 201 | Permission denied. | | 401 | Parameter error. | | 8300001 | Invalid parameter value. | | 8300002 | Operation failed. Cannot connect to service. | @@ -1262,6 +1321,8 @@ decodeMms(mmsFilePathName: string | Array, callback: AsyncCallback): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1343,6 +1406,8 @@ encodeMms(mms: MmsInformation, callback: AsyncCallback>): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | @@ -1393,6 +1458,8 @@ encodeMms(mms: MmsInformation): Promise> **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 401 | Parameter error. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-socket.md b/zh-cn/application-dev/reference/apis/js-apis-socket.md index 7c005e050863732e1af8ea6b4003135aeac1a1fe..f3d2dff5695686b48f76a97aab7fb3706d63165d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-socket.md +++ b/zh-cn/application-dev/reference/apis/js-apis-socket.md @@ -2674,4 +2674,4 @@ TLS通信的协议版本。 | 类型 | 说明 | | --------------------------------------------------------------------- | --------------------- | -|[cryptoFramework.EncodingBlob](js-apis-cryptoFramework.md#datablob) | 存储证书的数据和编码格式 | +|[cert.EncodingBlob](js-apis-cert.md#datablob) | 存储证书的数据和编码格式 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md b/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md index 32723c518063df016497a1f104d2bf0baf056442..0d44e435efd777c9f7a0c557ecbb69ca552c3d62 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md @@ -3,7 +3,8 @@ 该模块提供屏幕亮度和模式的查询、调节接口。 > **说明:** -> - 从API Version 7 开始不再维护,建议使用[`@ohos.brightness`](js-apis-brightness.md)替代。 +> +> - 从API Version 7 开始不再维护。建议使用[`@ohos.brightness`](js-apis-brightness.md)替代,替代接口能力仅对系统应用开放。 > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-configuration.md b/zh-cn/application-dev/reference/apis/js-apis-system-configuration.md index 3ab1617f8e9dcec885ee4503df291eba6e273f73..3c330f4869faaf3f86cc6d7a696a28afde553c55 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-configuration.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-configuration.md @@ -45,7 +45,7 @@ static getLocale(): LocaleResponse **系统能力**:以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Lite -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---- | ------ | ---- | ---- | ---------------------------------------- | | language | string | 是 | 否 | 语言。例如:zh。 | | countryOrRegion | string | 是 | 否 | 国家或地区。例如:CN。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-device.md b/zh-cn/application-dev/reference/apis/js-apis-system-device.md index 4215cce99d6414f55b0a047139273a5c87a573a3..b514f2afb2d0847419ac7615946a48b5ceb97f88 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-device.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-device.md @@ -16,11 +16,11 @@ import device from '@system.device'; ## device.getInfo -getInfo(Object): void +getInfo(options?: GetDeviceOptions): void 获取当前设备的信息。 -> **说明:** +> **说明:**
> 在首页的onShow生命周期之前不建议调用device.getInfo接口。 **系统能力:** SystemCapability.Startup.SystemInfo @@ -29,13 +29,27 @@ getInfo(Object): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| success | Function | 否 | 接口调用成功的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数。 | -| complete | Function | 否 | 接口调用结束的回调函数。 | +| options | [GetDeviceOptions](#getdeviceoptions) | 否 | 定义设备信息获取的参数选项。 | + +## GetDeviceOptions + +定义设备信息获取的参数选项。 -success返回值: +**系统能力:** SystemCapability.Startup.SystemInfo + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | (data:DeviceResponse)=> void | 否 | 接口调用成功的回调函数。 data为成功返回的设备信息,具体参考[DeviceResponse](#deviceresponse)。| +| fail | (data:any,code:number)=> void | 否 | 接口调用失败的回调函数。 code为失败返回的错误码。
code:200,表示返回结果中存在无法获得的信息。| +| complete | ()=> void | 否 | 接口调用结束的回调函数。 | -| 参数名 | 类型 | 说明 | +## DeviceResponse + +设备信息。 + +**系统能力:** SystemCapability.Startup.SystemInfo + +| 名称 | 类型 | 说明 | | -------- | -------- | -------- | | brand | string | 品牌。 | | manufacturer | string | 生产商。 | @@ -51,11 +65,6 @@ success返回值: | releaseType4+ | string | 版本发布类型,值为类型+版本号,如Beta1。
类型可能值有:
- Canary:同一apiVersion下,canary版本之间保持API兼容,beta版本不对canary版本兼容。
- Beta:同一apiVersion下,beta版本之间保持API兼容,release版本不对beta版本兼容。
- Release:release版本会保持5个API版本兼容。 | | deviceType4+ | string | 设备类型。 | -fail返回错误代码: - -| 错误码 | 说明 | -| -------- | -------- | -| 200 | 返回结果中存在无法获得的信息。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-fetch.md b/zh-cn/application-dev/reference/apis/js-apis-system-fetch.md index a3c71e776adc301450ed12afe4427a528a0fc86b..b4e7eb8eccbab3614d8182eb6492a9a9ce189d48 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-fetch.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-fetch.md @@ -23,7 +23,7 @@ fetch(Object): void **系统能力:** SystemCapability.Communication.NetStack **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | url | string | 是 | 资源地址。 | | data | string \| Object | 否 | 请求的参数,可选类型是字符串或者json对象。详见表 data与Content-Type关系。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-network.md b/zh-cn/application-dev/reference/apis/js-apis-system-network.md index 2008c020907e73b5c05423145edf06e4fb6aea4d..85e7aa74af1e2d315ba9d602d61528d2a1a4caa6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-network.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-network.md @@ -31,7 +31,7 @@ getType(Object): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | success | Function | 否 | 接口调用成功的回调函数,返回值为[NetworkResponse](#networkresponse) | | fail | Function | 否 | 接口调用失败的回调函数。 | @@ -71,7 +71,7 @@ subscribe(Object): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | success | Function | 否 | 网络发生变化的回调函数,返回值为[NetworkResponse](#networkresponse) | | fail | Function | 否 | 接口调用失败的回调函数。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-taskpool.md b/zh-cn/application-dev/reference/apis/js-apis-taskpool.md index ee10746563fe247ab24658a01fc503d9841ba538..89d050ecfc85ab531f3e7e3b4b04dd8cc9de4248 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-taskpool.md +++ b/zh-cn/application-dev/reference/apis/js-apis-taskpool.md @@ -13,7 +13,7 @@ ## 导入模块 -```js +```ts import taskpool from '@ohos.taskpool'; ``` @@ -58,9 +58,9 @@ Task的构造函数。 **示例:** -```js +```ts +@Concurrent function func(args) { - "use concurrent" console.log("func: " + args); return args; } @@ -110,9 +110,9 @@ execute(func: Function, ...args: unknown[]): Promise\ **示例:** -```js +```ts +@Concurrent function func(args) { - "use concurrent" console.log("func: " + args); return args; } @@ -158,9 +158,9 @@ execute(task: Task, priority?: Priority): Promise\ **示例:** -```js +```ts +@Concurrent function func(args) { - "use concurrent" console.log("func: " + args); return args; } @@ -199,9 +199,9 @@ cancel(task: Task): void **示例:** -```js +```ts +@Concurrent function func(args) { - "use concurrent" console.log("func: " + args); return args; } @@ -209,7 +209,11 @@ function func(args) { async function taskpoolTest() { let task = new taskpool.Task(func, 100); let value = await taskpool.execute(task); - taskpool.cancel(task); + try { + taskpool.cancel(task); + } catch (e) { + console.log("taskpool.cancel occur error:" + e); + } } taskpoolTest(); @@ -221,12 +225,19 @@ taskpoolTest(); 序列化支持类型包括:All Primitive Type(不包括symbol)、Date、String、RegExp、Array、Map、Set、Object、ArrayBuffer、TypedArray。 ### 注意事项 -taskpool任务只支持引用入参传递或者import的变量,不支持使用闭包变量。 +- 仅支持在Stage模型且module的compileMode为esmodule的project中使用taskpool api。确认module的compileMode方法:查看当前module的build-profile.json5,在buildOption中补充"compileMode": "esmodule"。 +- taskpool任务只支持引用入参传递或者import的变量,不支持使用闭包变量,使用装饰器@Concurrent进行拦截。 +- taskpool任务只支持普通函数或者async函数,不支持类成员函数或者匿名函数,使用装饰器@Concurrent进行拦截。 +- 装饰器@Concurrent仅支持在ets文件使用,在ts文件中创建taskpool任务需使用"use concurrent"。 -```js -// 1. 引用入参传递 +### 简单使用 + +**示例一** + +```ts +// 支持普通函数、引用入参传递 +@Concurrent function func(args) { - "use concurrent" console.log("func: " + args); return args; } @@ -245,17 +256,19 @@ async function taskpoolTest() { taskpoolTest(); ``` -```js -// 2. 引用import变量 +**示例二** -// b.ts +```ts +// b.ets export var c = 2000; +``` +```ts +// 引用import变量 +// a.ets(与b.ets位于同一目录中) +import { c } from "./b"; -// a.ts(与b.ts同目录) -import { c } from './b' - +@Concurrent function test(a) { - "use concurrent" console.log(a); console.log(c); return a; @@ -273,4 +286,64 @@ async function taskpoolTest() { } taskpoolTest(); +``` + +**示例三** + +```ts +// 支持async函数 +@Concurrent +async function task() { + let ret = await Promise.all([ + new Promise(resolve => setTimeout(resolve, 1000, "resolved")) + ]); + return ret; +} + +async function taskpoolTest() { + taskpool.execute(task).then((result) => { + console.log("TaskPoolTest task result: " + result); + }); +} + +taskpoolTest(); +``` + +**示例四** + +```ts +// 在ts文件中创建taskpool任务需使用"use concurrent" +// c.ts +function test1(n) { + "use concurrent" + return n; +} +export async function taskpoolTest1() { + console.log("taskpoolTest1 start"); + var task = new taskpool.Task(test1, 100); + var result = await taskpool.execute(task); + console.log("taskpoolTest1 result:" + result); +} + +async function test2() { + "use concurrent" + var ret = await Promise.all([ + new Promise(resolve => setTimeout(resolve, 1000, "resolved")) + ]); + return ret; +} +export async function taskpoolTest2() { + console.log("taskpoolTest2 start"); + taskpool.execute(test2).then((result) => { + console.log("TaskPoolTest2 result: " + result); + }); +} +``` + +```ts +// a.ets(与c.ts在同一目录中) +import { taskpoolTest1, taskpoolTest2 } from "./c"; + +taskpoolTest1(); +taskpoolTest2(); ``` \ 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 2f2c9114c9a42d702d1ab67ecc9f068ac640c5c0..268ecceda7a0bbdb2bfcef330ed4fe2d426fb2c5 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 @@ -100,6 +100,8 @@ setDefaultCellularDataSlotId(slotId: number, callback: AsyncCallback\): v **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -114,8 +116,8 @@ setDefaultCellularDataSlotId(slotId: number, callback: AsyncCallback\): v **示例:** ```js -data.setDefaultCellularDataSlotId(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +data.setDefaultCellularDataSlotId(0, (err) => { + console.log(`callback: err->${JSON.stringify(err)}.`); }); ``` @@ -145,6 +147,8 @@ setDefaultCellularDataSlotId(slotId: number): Promise\ **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -160,8 +164,8 @@ setDefaultCellularDataSlotId(slotId: number): Promise\ ```js let promise = data.setDefaultCellularDataSlotId(0); -promise.then((data) => { - console.log(`setDefaultCellularDataSlotId success, promise: data->${JSON.stringify(data)}`); +promise.then(() => { + console.log(`setDefaultCellularDataSlotId success.`); }).catch((err) => { console.error(`setDefaultCellularDataSlotId fail, promise: err->${JSON.stringify(err)}`); }); @@ -279,6 +283,8 @@ isCellularDataEnabled(callback: AsyncCallback\): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -314,6 +320,8 @@ isCellularDataEnabled(): Promise\ **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -353,6 +361,8 @@ isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback\) **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -394,6 +404,8 @@ isCellularDataRoamingEnabled(slotId: number): Promise\ **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -434,6 +446,8 @@ enableCellularData(callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -446,8 +460,8 @@ enableCellularData(callback: AsyncCallback): void **示例:** ```js -data.enableCellularData((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +data.enableCellularData((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -471,6 +485,8 @@ enableCellularData(): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -484,8 +500,8 @@ enableCellularData(): Promise ```js let promise = data.enableCellularData(); -promise.then((data) => { - console.log(`enableCellularData success, promise: data->${JSON.stringify(data)}`); +promise.then(() => { + console.log(`enableCellularData success.`); }).catch((err) => { console.error(`enableCellularData fail, promise: err->${JSON.stringify(err)}`); }); @@ -511,6 +527,8 @@ disableCellularData(callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -523,8 +541,8 @@ disableCellularData(callback: AsyncCallback): void **示例:** ```js -data.disableCellularData((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +data.disableCellularData((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -548,6 +566,8 @@ disableCellularData(): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -561,8 +581,8 @@ disableCellularData(): Promise ```js let promise = data.disableCellularData(); -promise.then((data) => { - console.log(`disableCellularData success, promise: data->${JSON.stringify(data)}`); +promise.then(() => { + console.log(`disableCellularData success.`); }).catch((err) => { console.error(`disableCellularData fail, promise: err->${JSON.stringify(err)}`); }); @@ -589,6 +609,8 @@ enableCellularDataRoaming(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -601,8 +623,8 @@ enableCellularDataRoaming(slotId: number, callback: AsyncCallback): void **示例:** ```js -data.enableCellularDataRoaming(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +data.enableCellularDataRoaming(0, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -632,6 +654,8 @@ enableCellularDataRoaming(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -645,8 +669,8 @@ enableCellularDataRoaming(slotId: number): Promise ```js let promise = data.enableCellularDataRoaming(0); -promise.then((data) => { - console.log(`enableCellularDataRoaming success, promise: data->${JSON.stringify(data)}`); +promise.then(() => { + console.log(`enableCellularDataRoaming success.`); }).catch((err) => { console.error(`enableCellularDataRoaming fail, promise: err->${JSON.stringify(err)}`); }); @@ -673,6 +697,8 @@ disableCellularDataRoaming(slotId: number, callback: AsyncCallback): void **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -685,8 +711,8 @@ disableCellularDataRoaming(slotId: number, callback: AsyncCallback): void **示例:** ```js -data.disableCellularDataRoaming(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +data.disableCellularDataRoaming(0, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -716,6 +742,8 @@ disableCellularDataRoaming(slotId: number): Promise **错误码:** +以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](../../reference/errorcodes/errorcode-telephony.md)错误码。 + | 错误码ID | 错误信息 | | -------- | -------------------------------------------- | | 201 | Permission denied. | @@ -729,8 +757,8 @@ disableCellularDataRoaming(slotId: number): Promise ```js let promise = data.disableCellularDataRoaming(0); -promise.then((data) => { - console.log(`disableCellularDataRoaming success, promise: data->${JSON.stringify(data)}`); +promise.then(() => { + console.log(`disableCellularDataRoaming success.`); }).catch((err) => { console.error(`disableCellularDataRoaming fail, promise: err->${JSON.stringify(err)}`); }); diff --git a/zh-cn/application-dev/reference/apis/js-apis-uiappearance.md b/zh-cn/application-dev/reference/apis/js-apis-uiappearance.md new file mode 100644 index 0000000000000000000000000000000000000000..28402007b002e0f214060f8dc9a629d2d042a311 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-uiappearance.md @@ -0,0 +1,106 @@ +# 用户界面外观 + +用户界面外观提供管理系统外观的一些基础能力,目前仅包括深浅色模式配置。 + +> **说明:** +> +> 从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> 本模块接口为系统接口。 + + +## 导入模块 + +```ts +import uiAppearance from '@ohos.uiAppearance' +``` + + +## DarkMode + +深色模式枚举。 + + +**系统能力:** SystemCapability.ArkUI.UiAppearance + +| 名称 | 值 | 说明 | +| -- | -- | -- | +| ALWAYS_DARK | 0 | 系统始终为深色。 | +| ALWAYS_LIGHT | 1 | 系统始终为浅色。 | + + +## uiAppearance.setDarkMode + +setDarkMode(mode: DarkMode, callback: AsyncCallback\): void + +设置系统深色模式。 + +**需要权限:** ohos.permission.UPDATE_CONFIGURATION + +**系统能力:** SystemCapability.ArkUI.UiAppearance + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -- | -- | -- | -- | +| mode | [DarkMode](#darkmode) | 是 | 指定系统的深色模式配置 | +| callback | AsyncCallback\| 是 | 配置深色模式的异步回调 | + +**示例:** + ```ts +uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK, (err) => { + console.info(`${err}`); +}) + ``` + + +## uiAppearance.setDarkMode + +setDarkMode(mode: DarkMode): Promise\; + +设置系统深色模式。 + +**需要权限:** ohos.permission.UPDATE_CONFIGURATION + +**系统能力:** SystemCapability.ArkUI.UiAppearance + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -- | -- | -- | -- | +| mode | [DarkMode](#darkmode) | 是 | 指定系统深色模式配置 | + +**返回值:** + +| 类型 | 说明 | +| ------ | ------------------------------ | +| Promise\ | Promise对象。无返回结果的Promise对象。| + +**示例:** + ```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; + +获取当前的深色模式配置。 + +**需要权限:** ohos.permission.UPDATE_CONFIGURATION + +**系统能力:** SystemCapability.ArkUI.UiAppearance + +**返回值:** +| 类型 | 说明 | +| -- | -- | +|[DarkMode](#darkmode) | 系统当前的深色模式配置 | + +**示例:** + ```ts +let darkMode = uiAppearance.getDarkMode(); +console.log(`Get dark-mode ${darkMode}`); + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md b/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md index ecc881616acbdece068111001a82daa64a93c14c..c7ca4781f1471cb644fe477972ac8bc0604fe88d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md @@ -399,44 +399,6 @@ try { } ``` -## userIAM_userAuth.getVersion9+ - -getVersion(): number - -获取认证器的版本信息。 - -**需要权限**:ohos.permission.ACCESS_BIOMETRIC - -**系统能力**:SystemCapability.UserIAM.UserAuth.Core - -**返回值:** - -| 类型 | 说明 | -| ------ | ---------------------- | -| number | 认证器版本信息。 | - -以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errorcode-useriam.md) - -**错误码:** - -| 错误码ID | 错误信息 | -| -------- | ------- | -| 201 | Permission verification failed. | -| 12500002 | General operation error. | - -**示例:** - -```js -import userIAM_userAuth from '@ohos.userIAM.userAuth'; - -try { - let version = userIAM_userAuth.getVersion(); - console.info("auth version = " + version); -} catch (error) { - console.info("get version failed, error = " + error); -} -``` - ## userIAM_userAuth.getAvailableStatus9+ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): void @@ -535,7 +497,7 @@ getVersion() : number 获取认证器的版本信息。 > **说明:** -> 从 API version 8 开始支持,从 API version 9 开始废弃,请使用[getVersion](#useriam_userauthgetversion9)替代。 +> 从 API version 8 开始支持,从 API version 9 开始废弃。 **需要权限**:ohos.permission.ACCESS_BIOMETRIC 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 4e303338a684f26a0c8ba6dc9d8d0ecb0b4d58e5..9bb19451f0b5c38dd4250215900a122d65e6ba77 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @@ -26,13 +26,15 @@ import wallpaper from '@ohos.wallpaper'; | WALLPAPER_LOCKSCREEN | 1 |锁屏壁纸标识。 | -## RgbaColor9+ +## RgbaColor(deprecated) 定义壁纸颜色信息结构。 -**系统能力**: SystemCapability.MiscServices.Wallpaper +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃。 -**系统接口**:此接口为系统接口。 +**系统能力**: SystemCapability.MiscServices.Wallpaper | 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-webSocket.md b/zh-cn/application-dev/reference/apis/js-apis-webSocket.md index b73344ad3ad60ecd0cc36dcec11c15cdd14c2b96..9853827f5e3a37af24b76d19c8c0e982dfcc5b93 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-webSocket.md +++ b/zh-cn/application-dev/reference/apis/js-apis-webSocket.md @@ -99,7 +99,7 @@ connect(url: string, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | ---------------------------- | | url | string | 是 | 建立WebSocket连接的URL地址。 | | callback | AsyncCallback\ | 是 | 回调函数。 | @@ -138,7 +138,7 @@ connect(url: string, options: WebSocketRequestOptions, callback: AsyncCallback\< **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | ------------------------------------------------------- | | url | string | 是 | 建立WebSocket连接的URL地址。 | | options | WebSocketRequestOptions | 是 | 参考[WebSocketRequestOptions](#websocketrequestoptions)。 | @@ -183,7 +183,7 @@ connect(url: string, options?: WebSocketRequestOptions): Promise\ **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | ----------------------- | ---- | ------------------------------------------------------- | | url | string | 是 | 建立WebSocket连接的URL地址。 | | options | WebSocketRequestOptions | 否 | 参考[WebSocketRequestOptions](#websocketrequestoptions)。 | @@ -227,7 +227,7 @@ send(data: string | ArrayBuffer, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | ------------ | | data | string \| ArrayBuffer | 是 | 发送的数据。
API 6及更早版本仅支持string类型。API 8起同时支持string和ArrayBuffer类型。 | | callback | AsyncCallback\ | 是 | 回调函数。 | @@ -268,7 +268,7 @@ send(data: string | ArrayBuffer): Promise\ **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------ | | data | string \| ArrayBuffer | 是 | 发送的数据。
API 6及更早版本仅支持string类型。API 8起同时支持string和ArrayBuffer类型。 | @@ -313,7 +313,7 @@ close(callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | ---------- | | callback | AsyncCallback\ | 是 | 回调函数。 | @@ -351,7 +351,7 @@ close(options: WebSocketCloseOptions, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | ----------------------------------------------------- | | options | WebSocketCloseOptions | 是 | 参考[WebSocketCloseOptions](#websocketcloseoptions)。 | | callback | AsyncCallback\ | 是 | 回调函数。 | @@ -393,7 +393,7 @@ close(options?: WebSocketCloseOptions): Promise\ **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | --------------------- | ---- | ----------------------------------------------------- | | options | WebSocketCloseOptions | 否 | 参考[WebSocketCloseOptions](#websocketcloseoptions)。 | @@ -437,7 +437,7 @@ on(type: 'open', callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | ----------------------------- | | type | string | 是 | 'open':WebSocket的打开事件。 | | callback | AsyncCallback\ | 是 | 回调函数。 | @@ -466,7 +466,7 @@ off(type: 'open', callback?: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | ----------------------------- | | type | string | 是 | 'open':WebSocket的打开事件。 | | callback | AsyncCallback\ | 否 | 回调函数。 | @@ -497,7 +497,7 @@ on(type: 'message', callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------------- | | type | string | 是 | 'message':WebSocket的接收到服务器消息事件。 | | callback | AsyncCallback\8+
\> | 是 | 回调函数。 | @@ -526,7 +526,7 @@ off(type: 'message', callback?: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------------- | ---- | -------------------------------------------- | | type | string | 是 | 'message':WebSocket的接收到服务器消息事件。 | | callback | AsyncCallback\8+
\> | 否 | 回调函数。 | @@ -549,7 +549,7 @@ on(type: 'close', callback: AsyncCallback\<{ code: number, reason: string }\>): **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------------- | ---- | ------------------------------ | | type | string | 是 | 'close':WebSocket的关闭事件。 | | callback | AsyncCallback\<{ code: number, reason: string }\> | 是 | 回调函数。
close:close错误码,reason:错误码说明 | @@ -577,7 +577,7 @@ off(type: 'close', callback?: AsyncCallback\<{ code: number, reason: string }\>) **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------------- | ---- | ------------------------------ | | type | string | 是 | 'close':WebSocket的关闭事件。 | | callback | AsyncCallback\<{ code: number, reason: string }\> | 否 | 回调函数。
close:close错误码,reason:错误码说明 | @@ -600,7 +600,7 @@ on(type: 'error', callback: ErrorCallback): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------- | ---- | ------------------------------- | | type | string | 是 | 'error':WebSocket的Error事件。 | | callback | ErrorCallback | 是 | 回调函数。 | @@ -628,7 +628,7 @@ off(type: 'error', callback?: ErrorCallback): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------- | ---- | ------------------------------- | | type | string | 是 | 'error':WebSocket的Error事件。 | | callback | ErrorCallback | 否 | 回调函数。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-webview.md b/zh-cn/application-dev/reference/apis/js-apis-webview.md index e9308759ceaf92cfa91cbe6a98b617f2a22f8fd9..48095aedd8d745ad631a239af57d794c8abea861 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-webview.md +++ b/zh-cn/application-dev/reference/apis/js-apis-webview.md @@ -422,7 +422,8 @@ struct WebComponent { } ``` -加载本地网页 +加载本地网页,加载本地资源文件有三种方式。 +1.$rawfile方式。 ```ts // xxx.ets import web_webview from '@ohos.web.webview' @@ -448,7 +449,7 @@ struct WebComponent { } } ``` - +2.resources协议。 ```ts // xxx.ets import web_webview from '@ohos.web.webview' @@ -475,6 +476,8 @@ struct WebComponent { } ``` +3.通过沙箱路径加载本地文件,可以参考[web](../arkui-ts/ts-basic-components-web.md#web)加载沙箱路径的示例代码。 + ```html @@ -3572,7 +3575,7 @@ struct Index { } ``` -### setAudioMuted +### setAudioMuted10+ setAudioMuted(mute: boolean): void @@ -3586,6 +3589,14 @@ setAudioMuted(mute: boolean): void | -------- | ------- | ---- | -------------------------------------- | | mute | boolean | 是 | 表示是否将网页设置为静音状态,true表示设置为静音状态,false表示取消静音状态。 | +**错误码:** + +以下错误码的详细介绍请参见[webview错误码](../errorcodes/errorcode-webview.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------------------------------------------------ | +| 17100001 | Init error. The WebviewController must be associated with a Web component. | + **示例:** ```ts diff --git a/zh-cn/application-dev/reference/arkui-js-lite/Readme-CN.md b/zh-cn/application-dev/reference/arkui-js-lite/Readme-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..9d94f7dd8f4595b8e23ddbeb69e6dc0f58d6a131 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/Readme-CN.md @@ -0,0 +1,37 @@ +# 兼容JS的类Web开发范式(ArkUI.Lite) + +- 框架说明 + - [文件组织](js-framework-file.md) + - [js标签配置](js-framework-js-tag.md) + - [app.js](js-framework-js-file.md) + - 语法 + - [HML语法参考](js-framework-syntax-hml.md) + - [CSS语法参考](js-framework-syntax-css.md) + - [JS语法参考](js-framework-syntax-js.md) +- 组件通用信息 + - [通用事件](js-common-events.md) + - [通用属性](js-common-attributes.md) + - [通用样式](js-common-styles.md) + - [动画样式](js-components-common-animation.md) + - [媒体查询](js-components-common-mediaquery.md) +- 容器组件 + - [div](js-components-container-div.md) + - [list](js-components-container-list.md) + - [list-item](js-components-container-list-item.md) + - [stack](js-components-container-stack.md) + - [swiper](js-components-container-swiper.md) +- 基础组件 + - [chart](js-components-basic-chart.md) + - [image](js-components-basic-image.md) + - [image-animator](js-components-basic-image-animator.md) + - [input](js-components-basic-input.md) + - [marquee](js-components-basic-marquee.md) + - [picker-view](js-components-basic-picker-view.md) + - [progress](js-components-basic-progress.md) + - [qrcode](js-components-basic-qrcode.md) + - [slider](js-components-basic-slider.md) + - [switch](js-components-basic-switch.md) + - [text](js-components-basic-text.md) +- 画布组件 + - [canvas组件](js-components-canvas-canvas.md) + - [CanvasRenderingContext2D对象](js-components-canvas-canvasrenderingcontext2d.md) diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/#000000.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/#000000.png new file mode 100644 index 0000000000000000000000000000000000000000..58293d5e874f2aa36ecaf7282ca9e4736318092f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/#000000.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/GIF.gif b/zh-cn/application-dev/reference/arkui-js-lite/figures/GIF.gif new file mode 100644 index 0000000000000000000000000000000000000000..fa77bb91654623c2de68a19e7f9f95bbd1d029bc Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/GIF.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/aliceblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/aliceblue.png new file mode 100644 index 0000000000000000000000000000000000000000..378000d344e90ab4db41869a4612daf6b60d66ab Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/aliceblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/antiquewhite.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/antiquewhite.png new file mode 100644 index 0000000000000000000000000000000000000000..8e195633945b3387c46a7d295862351d4ff1fc64 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/antiquewhite.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/aqua.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/aqua.png new file mode 100644 index 0000000000000000000000000000000000000000..3e6aaacfe1c26157294e6dedfeaa1488aeed12a3 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/aqua.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/aquamarine.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/aquamarine.png new file mode 100644 index 0000000000000000000000000000000000000000..c25a692065d473ccf9f5b6d36254787e2497fad6 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/aquamarine.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/azure.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/azure.png new file mode 100644 index 0000000000000000000000000000000000000000..2e7cec00f9d186d76ff5cb12d47811084217cc1c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/azure.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/barchart.PNG b/zh-cn/application-dev/reference/arkui-js-lite/figures/barchart.PNG new file mode 100644 index 0000000000000000000000000000000000000000..aa4ba3f9fa64250b1b86bd6d39b6a8071d3de1c3 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/barchart.PNG differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/beige.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/beige.png new file mode 100644 index 0000000000000000000000000000000000000000..21f20a4220aabf9449c707291633e7b3723fe378 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/beige.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/bisque.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/bisque.png new file mode 100644 index 0000000000000000000000000000000000000000..7983d590a2c617c6cad68c90af6b12aa17518810 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/bisque.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/blanchedalmond.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/blanchedalmond.png new file mode 100644 index 0000000000000000000000000000000000000000..04bcf099edface801be6074a33ff33a980c9b606 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/blanchedalmond.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/blue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/blue.png new file mode 100644 index 0000000000000000000000000000000000000000..e370a44cf043fc34bd8891f57faad2cd2ca05707 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/blue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/blueviolet.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/blueviolet.png new file mode 100644 index 0000000000000000000000000000000000000000..ca1edf2219980ab9c8533b9fda3219521c50533d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/blueviolet.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/brown.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/brown.png new file mode 100644 index 0000000000000000000000000000000000000000..0d22570503febc7a7dcba0d1e870f49f32fe489a Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/brown.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/burlywood.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/burlywood.png new file mode 100644 index 0000000000000000000000000000000000000000..0d53a47b7eace81d5c7da88c59fee61e30c89681 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/burlywood.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/cadetblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/cadetblue.png new file mode 100644 index 0000000000000000000000000000000000000000..a59bc9cdb0f75ad79e4714d3593216021369c862 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/cadetblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/chartreuse.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/chartreuse.png new file mode 100644 index 0000000000000000000000000000000000000000..3026d3c195598159232b4b1f08e9f198f4b4fa2c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/chartreuse.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/chocolate.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/chocolate.png new file mode 100644 index 0000000000000000000000000000000000000000..02d5f4e31b020ea9f64e36a7b7cd50299cf3d7f2 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/chocolate.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/coral.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/coral.png new file mode 100644 index 0000000000000000000000000000000000000000..8442c9b2258c79ee6b6a3d5963df5b792bbb1a16 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/coral.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/cornflowerblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/cornflowerblue.png new file mode 100644 index 0000000000000000000000000000000000000000..3621ef6876dbd1103487aed8ff190e6a0204ffde Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/cornflowerblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/cornsilk.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/cornsilk.png new file mode 100644 index 0000000000000000000000000000000000000000..bf38fe45eaf254939b88b9d2a66635408060acf7 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/cornsilk.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/crimson.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/crimson.png new file mode 100644 index 0000000000000000000000000000000000000000..bca655617699ef8dc1265bf692a3170c7effe15b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/crimson.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/cyan.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/cyan.png new file mode 100644 index 0000000000000000000000000000000000000000..3e6aaacfe1c26157294e6dedfeaa1488aeed12a3 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/cyan.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkblue.png new file mode 100644 index 0000000000000000000000000000000000000000..b234a769d1a9f1f30c4d2127160cf067e9f71ad6 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkcyan.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkcyan.png new file mode 100644 index 0000000000000000000000000000000000000000..b780eb08852e8916ec6ff1a401ea6946c8d727cf Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkcyan.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkgoldenrod.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkgoldenrod.png new file mode 100644 index 0000000000000000000000000000000000000000..26f2f228b47b8acb8adcddc3abf9156d6c29364e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkgoldenrod.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkgray.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkgray.png new file mode 100644 index 0000000000000000000000000000000000000000..f1abe2afcb7902557ac3c4f58abfdf333af03121 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkgray.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkgreen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkgreen.png new file mode 100644 index 0000000000000000000000000000000000000000..4c4c304b67c398f32c5fff516cdde377ca39c73d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkgreen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkgrey.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkgrey.png new file mode 100644 index 0000000000000000000000000000000000000000..f1abe2afcb7902557ac3c4f58abfdf333af03121 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkgrey.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkkhaki.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkkhaki.png new file mode 100644 index 0000000000000000000000000000000000000000..12085848c0f6472d53f7e6504c1924ea6f5a44c1 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkkhaki.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkmagenta.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkmagenta.png new file mode 100644 index 0000000000000000000000000000000000000000..9ed54c6c5c5186fb43f24dab24f7689ae0d14a12 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkmagenta.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkolivegreen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkolivegreen.png new file mode 100644 index 0000000000000000000000000000000000000000..53081e06f458cfc1772de30f669180333b8d783d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkolivegreen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkorange.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkorange.png new file mode 100644 index 0000000000000000000000000000000000000000..6064f64867e3aca621244e1e6fdb16d3ab2ed748 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkorange.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkorchid.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkorchid.png new file mode 100644 index 0000000000000000000000000000000000000000..6315d4654d04dd6b9b295fa1f8b37e8c550b17cf Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkorchid.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkred.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkred.png new file mode 100644 index 0000000000000000000000000000000000000000..c33d763d18f5108bf0eedba19c662d05af397ee9 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkred.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darksalmon.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darksalmon.png new file mode 100644 index 0000000000000000000000000000000000000000..57594c6855d4cdf1b37cc3e5354374c9dae0823b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darksalmon.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkseagreen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkseagreen.png new file mode 100644 index 0000000000000000000000000000000000000000..454b1796715794d51e2a1a4649bfafa1bfde80f0 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkseagreen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkslateblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkslateblue.png new file mode 100644 index 0000000000000000000000000000000000000000..7dfc7ee8793298d19c939369ba980abd547982ff Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkslateblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkslategray.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkslategray.png new file mode 100644 index 0000000000000000000000000000000000000000..5e23c304c4911dc0ef487dfeb8d7820aea5fb44b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkslategray.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkslategrey.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkslategrey.png new file mode 100644 index 0000000000000000000000000000000000000000..5e23c304c4911dc0ef487dfeb8d7820aea5fb44b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkslategrey.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkturquoise.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkturquoise.png new file mode 100644 index 0000000000000000000000000000000000000000..4e41450db5d70f6d10d6d7bf59daba33085c177e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkturquoise.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/darkviolet.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkviolet.png new file mode 100644 index 0000000000000000000000000000000000000000..6f085565bd8c64d44bf58ce0969557515ec7ab97 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/darkviolet.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/deeppink.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/deeppink.png new file mode 100644 index 0000000000000000000000000000000000000000..6348bb2b6ee281976f7d58159e4c33db29f542ad Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/deeppink.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/deepskyblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/deepskyblue.png new file mode 100644 index 0000000000000000000000000000000000000000..0ac129028e67b43fcae8e3d5c1a539cc45ba6d21 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/deepskyblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/default.PNG b/zh-cn/application-dev/reference/arkui-js-lite/figures/default.PNG new file mode 100644 index 0000000000000000000000000000000000000000..5e4322d20ad887573ad85958bc181a1be0f85f1c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/default.PNG differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/dimgray.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/dimgray.png new file mode 100644 index 0000000000000000000000000000000000000000..1072a50f468dda3c90c889c31424b7c290eb1a13 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/dimgray.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/dimgrey.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/dimgrey.png new file mode 100644 index 0000000000000000000000000000000000000000..1072a50f468dda3c90c889c31424b7c290eb1a13 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/dimgrey.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/dodgerblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/dodgerblue.png new file mode 100644 index 0000000000000000000000000000000000000000..fe422eecde9ec9f1fcac762bd81a23b3fa3abde7 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/dodgerblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/ellipse.PNG b/zh-cn/application-dev/reference/arkui-js-lite/figures/ellipse.PNG new file mode 100644 index 0000000000000000000000000000000000000000..d0379dfc66b4d2151dae49beeb8af38c774381aa Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/ellipse.PNG differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/firebrick.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/firebrick.png new file mode 100644 index 0000000000000000000000000000000000000000..af32ecea68c1cef693bcfa379af5ac28f66c1e14 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/firebrick.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/floralwhite.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/floralwhite.png new file mode 100644 index 0000000000000000000000000000000000000000..5ee9f7e893611dce988b8aa7ccfe3fab4b9d912f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/floralwhite.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/forestgreen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/forestgreen.png new file mode 100644 index 0000000000000000000000000000000000000000..7cfd4846ca697424582edbfed23ed93ef9e98138 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/forestgreen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/fuchsia.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/fuchsia.png new file mode 100644 index 0000000000000000000000000000000000000000..6823cbc9203b07abae455b4ee5c7692878c4be72 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/fuchsia.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/gainsboro.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/gainsboro.png new file mode 100644 index 0000000000000000000000000000000000000000..d1d37504e15eb6fccd6b1c8e985d37fcc8ba9875 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/gainsboro.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/gauge.PNG b/zh-cn/application-dev/reference/arkui-js-lite/figures/gauge.PNG new file mode 100644 index 0000000000000000000000000000000000000000..31c0141d716059519377e1f39b9b8305370f239a Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/gauge.PNG differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/ghostwhite.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/ghostwhite.png new file mode 100644 index 0000000000000000000000000000000000000000..45467f3e6fc0866b6da0521911bdb5e7d740df29 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/ghostwhite.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/gold.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/gold.png new file mode 100644 index 0000000000000000000000000000000000000000..91a276a7dffb4d98c507e9af6afa1912cca1fed2 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/gold.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/goldenrod.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/goldenrod.png new file mode 100644 index 0000000000000000000000000000000000000000..04ab7decab16cb7341665c2a67e8d5655a7eed6a Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/goldenrod.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/gray.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/gray.png new file mode 100644 index 0000000000000000000000000000000000000000..dfcb0c5e259b3f8d7375c21712249c1e847edd67 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/gray.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/green.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/green.png new file mode 100644 index 0000000000000000000000000000000000000000..bc28f5056c679e189543c8ad6fba67fb56db7655 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/green.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/greenyellow.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/greenyellow.png new file mode 100644 index 0000000000000000000000000000000000000000..c89f746719790333bce2bde8c5b8d86102fdfc33 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/greenyellow.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/grey.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/grey.png new file mode 100644 index 0000000000000000000000000000000000000000..dfcb0c5e259b3f8d7375c21712249c1e847edd67 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/grey.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/honeydew.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/honeydew.png new file mode 100644 index 0000000000000000000000000000000000000000..51fb00e10bb5c167506ddfae1689b58e368df340 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/honeydew.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/hotpink.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/hotpink.png new file mode 100644 index 0000000000000000000000000000000000000000..cbc1d312680f479e8c443476ea39eaf1e8a16e55 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/hotpink.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/image-animator.gif b/zh-cn/application-dev/reference/arkui-js-lite/figures/image-animator.gif new file mode 100644 index 0000000000000000000000000000000000000000..8321366bdb79b9e6530d53b0f45a6465ae7b967d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/image-animator.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/image.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/image.png new file mode 100644 index 0000000000000000000000000000000000000000..79db22cd94523a8854562e4c8b45ee22d8b45e90 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/image.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/indianred.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/indianred.png new file mode 100644 index 0000000000000000000000000000000000000000..069f570291be858a1768b75719a4a6adbd1bdef8 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/indianred.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/indigo.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/indigo.png new file mode 100644 index 0000000000000000000000000000000000000000..db83d39f98583ee653ee39b0237eb55961e539c7 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/indigo.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/input-type-button.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/input-type-button.png new file mode 100644 index 0000000000000000000000000000000000000000..247fed609d862aa73184f3428486ab62e82bf897 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/input-type-button.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/input-type-checkbox.gif b/zh-cn/application-dev/reference/arkui-js-lite/figures/input-type-checkbox.gif new file mode 100644 index 0000000000000000000000000000000000000000..2215e5cfa56f533c6b4d1318b2fa1fb07093dfaa Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/input-type-checkbox.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/input-type-radio.gif b/zh-cn/application-dev/reference/arkui-js-lite/figures/input-type-radio.gif new file mode 100644 index 0000000000000000000000000000000000000000..bd5fea51c64deb1268793f3a3f70a2c379aebfda Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/input-type-radio.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/ivory.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/ivory.png new file mode 100644 index 0000000000000000000000000000000000000000..ff0aa71de78cb461a6602398ee915c677efdf3d4 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/ivory.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/khaki.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/khaki.png new file mode 100644 index 0000000000000000000000000000000000000000..3fca22c329e9dc9ef73eee20757eac4ce7386842 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/khaki.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lavender.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lavender.png new file mode 100644 index 0000000000000000000000000000000000000000..44e4d991524bd0ef88a0dd10f204e022dd9d0621 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lavender.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lavenderblush.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lavenderblush.png new file mode 100644 index 0000000000000000000000000000000000000000..5b22707e37ec772dc08a961e557a937862210167 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lavenderblush.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lawngreen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lawngreen.png new file mode 100644 index 0000000000000000000000000000000000000000..41be1a646e14511b5d177d11a7bce10deaee5bc9 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lawngreen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lemonchiffon.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lemonchiffon.png new file mode 100644 index 0000000000000000000000000000000000000000..d77ed21418dc3035feb9f9c8e15815e577d71a90 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lemonchiffon.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lightblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightblue.png new file mode 100644 index 0000000000000000000000000000000000000000..7cc96f8f6364b93923f0a88b895fe6b151080932 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lightcoral.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightcoral.png new file mode 100644 index 0000000000000000000000000000000000000000..515185ab1b3cf9aaba1204760dae19ab3c112b42 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightcoral.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lightcyan.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightcyan.png new file mode 100644 index 0000000000000000000000000000000000000000..6f929d8ab35b708978d8053047cb56bec4fa83bc Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightcyan.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lightgoldenrodyellow.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightgoldenrodyellow.png new file mode 100644 index 0000000000000000000000000000000000000000..1b0ed50716d897398c1e9a741e08ff5f1b9fd9de Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightgoldenrodyellow.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lightgray.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightgray.png new file mode 100644 index 0000000000000000000000000000000000000000..0a5eb251a8d731dc6a9d8b1f31f904c42fd372c3 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightgray.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lightgreen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightgreen.png new file mode 100644 index 0000000000000000000000000000000000000000..f89943fc98661a6d2b78b5659c41483308a0c54b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightgreen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lightpink.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightpink.png new file mode 100644 index 0000000000000000000000000000000000000000..6eb2d41877c85cccfb918b042bc13c81c58ec191 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightpink.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lightsalmon.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightsalmon.png new file mode 100644 index 0000000000000000000000000000000000000000..d87462d1cdc9410e91ee050a53d58e71d1c5f312 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightsalmon.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lightseagreen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightseagreen.png new file mode 100644 index 0000000000000000000000000000000000000000..e863d7a1c3b9c1ca08bd182dce43c55a4866d59b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightseagreen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lightskyblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightskyblue.png new file mode 100644 index 0000000000000000000000000000000000000000..daa035cea33b810571c18de67e4ac887eeb11850 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightskyblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lightslategray.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightslategray.png new file mode 100644 index 0000000000000000000000000000000000000000..2dadb92ce56793e2dd693bfa7d99b0c1168130dc Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightslategray.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lightslategrey.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightslategrey.png new file mode 100644 index 0000000000000000000000000000000000000000..2dadb92ce56793e2dd693bfa7d99b0c1168130dc Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightslategrey.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lightsteelblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightsteelblue.png new file mode 100644 index 0000000000000000000000000000000000000000..ac0521001d2513fd69e48ce61e1d1128b9d3a6dd Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightsteelblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lightyellow.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightyellow.png new file mode 100644 index 0000000000000000000000000000000000000000..d1ca7dd07fe7812ec1f87bf748595174569a5672 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lightyellow.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lime.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/lime.png new file mode 100644 index 0000000000000000000000000000000000000000..481c833482d38c5f564127c8f412fe3c0275fd24 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lime.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/limegreen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/limegreen.png new file mode 100644 index 0000000000000000000000000000000000000000..63a8c6adc29d340634ed06a1006a0fb56c991a9d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/limegreen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/linen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/linen.png new file mode 100644 index 0000000000000000000000000000000000000000..486baf6be50982404fd1c68a5bc51db45c62046a Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/linen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/list.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/list.png new file mode 100644 index 0000000000000000000000000000000000000000..eea4ba1ba4f92ab65a41990b830e7b1c72d99f09 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/list.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lite_bar.PNG b/zh-cn/application-dev/reference/arkui-js-lite/figures/lite_bar.PNG new file mode 100644 index 0000000000000000000000000000000000000000..a180cd74fb6455adb495cf0d8471b34c93a9415e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lite_bar.PNG differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/lite_line.PNG b/zh-cn/application-dev/reference/arkui-js-lite/figures/lite_line.PNG new file mode 100644 index 0000000000000000000000000000000000000000..664ade98b38a3b6ac2b3e96dc4af8b75b6749a72 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/lite_line.PNG differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/magenta.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/magenta.png new file mode 100644 index 0000000000000000000000000000000000000000..6823cbc9203b07abae455b4ee5c7692878c4be72 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/magenta.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/maroon.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/maroon.png new file mode 100644 index 0000000000000000000000000000000000000000..1324b43b3f5b8dd0548cf2069c4c532c5284c445 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/maroon.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/marquee.gif b/zh-cn/application-dev/reference/arkui-js-lite/figures/marquee.gif new file mode 100644 index 0000000000000000000000000000000000000000..3b6df4b26274fdf5c3e6e1fab2423400455b7050 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/marquee.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumaquamarine.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumaquamarine.png new file mode 100644 index 0000000000000000000000000000000000000000..800bf296338fd01962f16a8863c37bfe515ce3be Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumaquamarine.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumblue.png new file mode 100644 index 0000000000000000000000000000000000000000..c0df3f4f7d99f0b8c39995133c71d944bc07ea4b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumorchid.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumorchid.png new file mode 100644 index 0000000000000000000000000000000000000000..664d13c38389361e61a45870899e2a6f0bfc835f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumorchid.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumpurple.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumpurple.png new file mode 100644 index 0000000000000000000000000000000000000000..848454297b67eb73ab641424badc438433e24479 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumpurple.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumseagreen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumseagreen.png new file mode 100644 index 0000000000000000000000000000000000000000..984e7a561e661ecefca8b60d5ac239b67f96c98c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumseagreen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumslateblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumslateblue.png new file mode 100644 index 0000000000000000000000000000000000000000..39cf9d01563cf63bee003a47cd88258e860a0757 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumslateblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumspringgreen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumspringgreen.png new file mode 100644 index 0000000000000000000000000000000000000000..56db1024a714f821528656c64e12520311bae8f5 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumspringgreen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumturquoise.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumturquoise.png new file mode 100644 index 0000000000000000000000000000000000000000..b3c353b6a872d3597b767f4c216b2d16bfc2139b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumturquoise.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumvioletred.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumvioletred.png new file mode 100644 index 0000000000000000000000000000000000000000..00767e63c899eec52c2c732e834bca8d26d348ce Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/mediumvioletred.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/midnightblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/midnightblue.png new file mode 100644 index 0000000000000000000000000000000000000000..ac66614c0f277cd722b3d090cb10efb973152b0f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/midnightblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/mintcream.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/mintcream.png new file mode 100644 index 0000000000000000000000000000000000000000..64fdda07447707816e8a6238939169f58a4ce58f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/mintcream.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/mistyrose.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/mistyrose.png new file mode 100644 index 0000000000000000000000000000000000000000..6f5fe69b5a5a62b2d2b719b2be0a17a501363918 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/mistyrose.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/moccasin.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/moccasin.png new file mode 100644 index 0000000000000000000000000000000000000000..115cb4c96382681743381aeba099549dc24c2ae5 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/moccasin.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/navajowhite.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/navajowhite.png new file mode 100644 index 0000000000000000000000000000000000000000..a68e61ab120651294310c5e3632ce22d71917a52 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/navajowhite.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/navy.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/navy.png new file mode 100644 index 0000000000000000000000000000000000000000..4e41c2cd90ba17798448d70b493ccceb3ac960f0 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/navy.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/oldlace.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/oldlace.png new file mode 100644 index 0000000000000000000000000000000000000000..ecf361e4c749446160da1e8a07169b21d99f362a Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/oldlace.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/olive.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/olive.png new file mode 100644 index 0000000000000000000000000000000000000000..0d386fef5c4fa9faf1b29c7667c7392db250f2eb Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/olive.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/olivedrab.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/olivedrab.png new file mode 100644 index 0000000000000000000000000000000000000000..639f16f8aaf261176b3bc760c2eb616ad2f4aa28 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/olivedrab.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/orange.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/orange.png new file mode 100644 index 0000000000000000000000000000000000000000..9c43caf5fdfd466eafc37b793f509a6bde2b885d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/orange.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/orangered.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/orangered.png new file mode 100644 index 0000000000000000000000000000000000000000..e72165fdf1b24d80f0abde742ad3d848497c6ea7 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/orangered.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/orchid.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/orchid.png new file mode 100644 index 0000000000000000000000000000000000000000..9114031e04fc28be59e8c9567c0fcfe81a9cc5cb Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/orchid.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/palegoldenrod.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/palegoldenrod.png new file mode 100644 index 0000000000000000000000000000000000000000..131584c72c082f40e2b466e2706c86a05df375e0 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/palegoldenrod.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/palegreen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/palegreen.png new file mode 100644 index 0000000000000000000000000000000000000000..891d52276622fd51893634ce26e08bd56f62b782 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/palegreen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/paleturquoise.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/paleturquoise.png new file mode 100644 index 0000000000000000000000000000000000000000..a618da21cf6c6d32066286e594921c0fc75b5dba Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/paleturquoise.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/palevioletred.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/palevioletred.png new file mode 100644 index 0000000000000000000000000000000000000000..c88212b6818d6d18c77ee497cfcafaf661a70d52 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/palevioletred.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/papayawhip.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/papayawhip.png new file mode 100644 index 0000000000000000000000000000000000000000..4b1948de8581602c6c5879c03d68c14f06eccd00 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/papayawhip.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/peachpuff.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/peachpuff.png new file mode 100644 index 0000000000000000000000000000000000000000..1821f9c40ad9d24dc10dc662ecbe7936c9e10633 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/peachpuff.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/peru.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/peru.png new file mode 100644 index 0000000000000000000000000000000000000000..3ca3e045717379bb09fa8d13ea0d42019bf546f2 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/peru.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/picker-view.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/picker-view.png new file mode 100644 index 0000000000000000000000000000000000000000..3e5375876c6c7403b254df56c75d08031ad9801d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/picker-view.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/pink.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/pink.png new file mode 100644 index 0000000000000000000000000000000000000000..5c5e360f249a2002ba68ad9b94bd7f66f5d6aab1 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/pink.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/plum.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/plum.png new file mode 100644 index 0000000000000000000000000000000000000000..1e0bad2b2bfed2559e53a8bc21162e6163ec8434 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/plum.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/powderblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/powderblue.png new file mode 100644 index 0000000000000000000000000000000000000000..8b3eec4e46f6a29dc47694940ceaef1cfa1314af Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/powderblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/progress.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/progress.png new file mode 100644 index 0000000000000000000000000000000000000000..fb9170121d950b8d8b5a4a5a209c25b452791d25 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/progress.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/purple.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/purple.png new file mode 100644 index 0000000000000000000000000000000000000000..8bc3583f82d21c8bec0c70b2da36ed05723fd9a7 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/purple.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/qrcode.gif b/zh-cn/application-dev/reference/arkui-js-lite/figures/qrcode.gif new file mode 100644 index 0000000000000000000000000000000000000000..53e718c2879554c82d4a3d9800507a00e37613dc Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/qrcode.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/rebeccapurple.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/rebeccapurple.png new file mode 100644 index 0000000000000000000000000000000000000000..6a64534a0a867d44cf81c8a34c9981b5fbaf5faf Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/rebeccapurple.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/red.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/red.png new file mode 100644 index 0000000000000000000000000000000000000000..309d1c46f8bc396df5eaed381a5ffa2f0389d602 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/red.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/rosybrown.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/rosybrown.png new file mode 100644 index 0000000000000000000000000000000000000000..adca00e684afb79ff4f21313d0586025576a8be1 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/rosybrown.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/royalblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/royalblue.png new file mode 100644 index 0000000000000000000000000000000000000000..69cb300d4bc8decee06c7fb64b03a24287865a8f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/royalblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/saddlebrown.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/saddlebrown.png new file mode 100644 index 0000000000000000000000000000000000000000..5d0ae86ad14ff863511a10ecc1a85b273e826dfc Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/saddlebrown.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/salmon.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/salmon.png new file mode 100644 index 0000000000000000000000000000000000000000..b80a6c31cdb287c35965c7841aa97711d79b371c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/salmon.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/sample1.gif b/zh-cn/application-dev/reference/arkui-js-lite/figures/sample1.gif new file mode 100644 index 0000000000000000000000000000000000000000..6168a14aa67c866abf6185ba3a3c2ae9f595153c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/sample1.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/sample_css.PNG b/zh-cn/application-dev/reference/arkui-js-lite/figures/sample_css.PNG new file mode 100644 index 0000000000000000000000000000000000000000..43c345e521bd9c87a9fb6da469548716cd20f918 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/sample_css.PNG differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/sandybrown.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/sandybrown.png new file mode 100644 index 0000000000000000000000000000000000000000..c952585d8032733700b57ce1a919d71ce9a4b58b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/sandybrown.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/seagreen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/seagreen.png new file mode 100644 index 0000000000000000000000000000000000000000..858c4187d3a2874f651adc09dcae9a32f8407d86 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/seagreen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/seashell.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/seashell.png new file mode 100644 index 0000000000000000000000000000000000000000..c0b21ed6b44c2f756458137f931873f540c16e5f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/seashell.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/sienna.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/sienna.png new file mode 100644 index 0000000000000000000000000000000000000000..bdb02fdda28a155e2f622eeea2ff820144780e50 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/sienna.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/silver.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/silver.png new file mode 100644 index 0000000000000000000000000000000000000000..0491d350277cd67d7774e3761164b9dd7038a117 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/silver.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/skyblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/skyblue.png new file mode 100644 index 0000000000000000000000000000000000000000..1c4f9ae52153198f8690a1066fe66ba8c7bd1ee1 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/skyblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/slateblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/slateblue.png new file mode 100644 index 0000000000000000000000000000000000000000..87915df37741dacfe9448bfebccf5a88d3ca2a76 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/slateblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/slategray.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/slategray.png new file mode 100644 index 0000000000000000000000000000000000000000..6e4476c4791e37d4681f8e12313ae1cad0887c1b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/slategray.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/slider.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/slider.png new file mode 100644 index 0000000000000000000000000000000000000000..b72ed8404c613ec9283d7be1f56071d70fcbbc1f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/slider.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/smoothOff.PNG b/zh-cn/application-dev/reference/arkui-js-lite/figures/smoothOff.PNG new file mode 100644 index 0000000000000000000000000000000000000000..c699e78774fadbd8da8c0cc290e88294d445aa6f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/smoothOff.PNG differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/smoothOn.PNG b/zh-cn/application-dev/reference/arkui-js-lite/figures/smoothOn.PNG new file mode 100644 index 0000000000000000000000000000000000000000..b7a5a2a819eeafeb000c00bd7009a02e5fe1bbe5 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/smoothOn.PNG differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/snow.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/snow.png new file mode 100644 index 0000000000000000000000000000000000000000..283cf90b3828b36af6fb3a746e806f6715053310 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/snow.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/springgreen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/springgreen.png new file mode 100644 index 0000000000000000000000000000000000000000..93825b7fe53a0794751ee4aa3ca46300c404835e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/springgreen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/sssssss.PNG b/zh-cn/application-dev/reference/arkui-js-lite/figures/sssssss.PNG new file mode 100644 index 0000000000000000000000000000000000000000..e108f5f8f2e096b319ef5097145ab43f2ad97594 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/sssssss.PNG differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/steelblue.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/steelblue.png new file mode 100644 index 0000000000000000000000000000000000000000..a9aba5f67b94427168fade014542532431e28a2e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/steelblue.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/swiper.gif b/zh-cn/application-dev/reference/arkui-js-lite/figures/swiper.gif new file mode 100644 index 0000000000000000000000000000000000000000..2ec52b162dcfdd39c2d2f5a7be4106321935b010 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/swiper.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/switch.gif b/zh-cn/application-dev/reference/arkui-js-lite/figures/switch.gif new file mode 100644 index 0000000000000000000000000000000000000000..102295bc63e3d373d45e74c23dcddc4f5532e9fb Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/switch.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/tan.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/tan.png new file mode 100644 index 0000000000000000000000000000000000000000..b162dbf0a6c890a03ea1aa0b28bdb454651b697c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/tan.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/teal.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/teal.png new file mode 100644 index 0000000000000000000000000000000000000000..93299fc38d761e5251673210c364f6825e319153 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/teal.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/text.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/text.png new file mode 100644 index 0000000000000000000000000000000000000000..d3a79bc7ae959d16d1eb4b915fa9040f00996b16 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/text.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/thistle.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/thistle.png new file mode 100644 index 0000000000000000000000000000000000000000..d62fc7767f7b2e0e8d0d7fed57e30bdf6a6a332f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/thistle.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/tomato.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/tomato.png new file mode 100644 index 0000000000000000000000000000000000000000..6d795f1618b1546c94266548069eccf9e9af2e01 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/tomato.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/turquoise.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/turquoise.png new file mode 100644 index 0000000000000000000000000000000000000000..a33c4fce8448e2127b21e277437195ce0002766b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/turquoise.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/violet.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/violet.png new file mode 100644 index 0000000000000000000000000000000000000000..e9a0799a203fdd7bd41fa5175585dc170a20156e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/violet.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/wheat.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/wheat.png new file mode 100644 index 0000000000000000000000000000000000000000..8a5c7039b580128e75299672dc5438151dcf3572 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/wheat.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/white.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/white.png new file mode 100644 index 0000000000000000000000000000000000000000..56d32d4cd371c5374b133cb81c9c077aaf7b110d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/white.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/whitesmoke.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/whitesmoke.png new file mode 100644 index 0000000000000000000000000000000000000000..6dc88e656c293c2e65939e4a793684488dfc81be Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/whitesmoke.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/yellow.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/yellow.png new file mode 100644 index 0000000000000000000000000000000000000000..b54dbc2391d1a8f16312dd02dc3d65a35ea2626f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/yellow.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/yellowgreen.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/yellowgreen.png new file mode 100644 index 0000000000000000000000000000000000000000..f89e20a55ba1e81f2cbda2bd0241edefadbe7149 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/yellowgreen.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789168.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789168.png new file mode 100644 index 0000000000000000000000000000000000000000..4481b08ab897619b408425f9bfe0fd5b1fcb6ef0 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789168.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789172.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789172.png new file mode 100644 index 0000000000000000000000000000000000000000..9a73bd33782f06a704ed9b288226dfa381d1d57c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789172.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789180.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789180.png new file mode 100644 index 0000000000000000000000000000000000000000..6e58c669a2976297f71d35c304e988c2884e7dc0 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789180.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789184.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789184.png new file mode 100644 index 0000000000000000000000000000000000000000..5113bc6bad4f88bc2558aae304394e00e107ce88 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789184.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789188.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789188.png new file mode 100644 index 0000000000000000000000000000000000000000..4d0696a9ade017acbbdfb8812dafdec5d715cac5 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789188.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789196.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789196.png new file mode 100644 index 0000000000000000000000000000000000000000..ee003430ca365892a94c0dbe3e7ba0879f83059d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789196.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789296.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789296.png new file mode 100644 index 0000000000000000000000000000000000000000..f627659cef03f443e01fb28b44ceb9363369b8d8 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380789296.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948700.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948700.png new file mode 100644 index 0000000000000000000000000000000000000000..8f6b4abcc27039c624bd21aad775db7c47a22dea Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948700.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948704.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948704.png new file mode 100644 index 0000000000000000000000000000000000000000..151ef990edbb33e1f54632609990f6c540149a5e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948704.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948708.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948708.png new file mode 100644 index 0000000000000000000000000000000000000000..e061801d6eeb27d7fee0b287414e512559a87ea9 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948708.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948712.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948712.png new file mode 100644 index 0000000000000000000000000000000000000000..56c65edbcd66a2ebe9d8ef35c55eba90652bca0f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948712.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948716.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948716.png new file mode 100644 index 0000000000000000000000000000000000000000..db54e678d8c42daca3e56dd85567c9978a9657c8 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948716.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948720.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948720.png new file mode 100644 index 0000000000000000000000000000000000000000..f59a10b44b9e9793bc3a9134f6c4633c8cfb49ce Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948720.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948828.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948828.png new file mode 100644 index 0000000000000000000000000000000000000000..f304daf1f80c86ca6f415e4f7a49b17ca20dae04 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001380948828.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108312.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108312.png new file mode 100644 index 0000000000000000000000000000000000000000..3917378fdcb47448e7daf8ae197e6d033fd345e9 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108312.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108316.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108316.png new file mode 100644 index 0000000000000000000000000000000000000000..4c8300af3bdf43e4d2192699b5ed4065fef451c0 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108316.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108320.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108320.png new file mode 100644 index 0000000000000000000000000000000000000000..3404b29dff12b910ae1be71ebf762252895468a8 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108320.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108324.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108324.png new file mode 100644 index 0000000000000000000000000000000000000000..dfee4f8cddcddd2ada89cb6d7e812fd0739d9cb8 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108324.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108328.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108328.png new file mode 100644 index 0000000000000000000000000000000000000000..33787429dd3205f9faac254950e95c097bd63b21 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108328.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108332.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108332.png new file mode 100644 index 0000000000000000000000000000000000000000..67959174e9b810b9278a7940bc097ac0c0738c7e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108332.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108420.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108420.png new file mode 100644 index 0000000000000000000000000000000000000000..3ecdf0c714fa633f03db339626f51e62318cbf82 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108420.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108436.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108436.png new file mode 100644 index 0000000000000000000000000000000000000000..f6288a0361793fbbce554fd293831fae4bcefc9d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381108436.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268264.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268264.png new file mode 100644 index 0000000000000000000000000000000000000000..0c8973bcb7d55910c6702fe6b9b54506ad3b3727 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268264.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268268.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268268.png new file mode 100644 index 0000000000000000000000000000000000000000..3cc02a6196604a6a3d64b9961c04aaaa51dc829e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268268.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268272.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268272.png new file mode 100644 index 0000000000000000000000000000000000000000..658dca4b52032016c15f77a94b3ef76c093b1d2c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268272.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268276.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268276.png new file mode 100644 index 0000000000000000000000000000000000000000..8192453ec25d486b3923da4a25b0a6fe5034d869 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268276.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268280.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268280.png new file mode 100644 index 0000000000000000000000000000000000000000..2f786e33181995c2b5bf5f835df4557ff3f7e9b4 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268280.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268284.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268284.png new file mode 100644 index 0000000000000000000000000000000000000000..9ac4a39e925322831752617b71a77d040626d251 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268284.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268388.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268388.png new file mode 100644 index 0000000000000000000000000000000000000000..366ab30f3e3f9f4b7e8b579b06cd84a76b2bfabc Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001381268388.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148353.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148353.png new file mode 100644 index 0000000000000000000000000000000000000000..e89a1b24da145cf480cceb28ed7249b717e614bf Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148353.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148357.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148357.png new file mode 100644 index 0000000000000000000000000000000000000000..68562c1006ec7c61c49c24aec99ecfd173ca055a Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148357.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148361.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148361.png new file mode 100644 index 0000000000000000000000000000000000000000..bd4f47314f89fa4bbbd2d14527dd250b5e3e141b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148361.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148365.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148365.png new file mode 100644 index 0000000000000000000000000000000000000000..42efd9018bc05408596a768cbbe309f1e46273d7 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148365.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148369.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148369.png new file mode 100644 index 0000000000000000000000000000000000000000..3108e0436219c1c3a7335679cdfea962c49f454d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148369.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148457.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148457.png new file mode 100644 index 0000000000000000000000000000000000000000..91c55d3677922b76ac78c4e56c87ef90b5b31fc2 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431148457.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308057.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308057.png new file mode 100644 index 0000000000000000000000000000000000000000..cc1dc87c79f827c8bb5be3f3771c37f4cb8b214e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308057.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308061.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308061.png new file mode 100644 index 0000000000000000000000000000000000000000..1362b8a3d98f4edf36420d3799f01476817e43d4 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308061.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308065.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308065.png new file mode 100644 index 0000000000000000000000000000000000000000..2f9a8bacc0f78cb141820e8188d4ae5ef03dc7c1 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308065.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308073.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308073.png new file mode 100644 index 0000000000000000000000000000000000000000..44ae627d6e40dd4b297eccdcf1c5dceef5a08d82 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308073.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308077.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308077.png new file mode 100644 index 0000000000000000000000000000000000000000..f4e18dbe51e815ccdfc6f594e3424850c3b93a12 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308077.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308169.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308169.png new file mode 100644 index 0000000000000000000000000000000000000000..612bc55f4aa5e832133801edf61cef01ffd1bc64 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308169.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308185.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308185.png new file mode 100644 index 0000000000000000000000000000000000000000..3dccd46b21e76a7bbbaabc1ab77a29bd72ae850d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431308185.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388505.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388505.png new file mode 100644 index 0000000000000000000000000000000000000000..47f90714bcb37e4df1b698503db6893d6c2a98c4 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388505.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388513.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388513.png new file mode 100644 index 0000000000000000000000000000000000000000..072d846a3cd629316cd0dcf25d5e9e1e1d3e0dc4 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388513.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388517.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388517.png new file mode 100644 index 0000000000000000000000000000000000000000..5b526bdf7cd539297715bbcddbbd505b7c683695 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388517.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388521.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388521.png new file mode 100644 index 0000000000000000000000000000000000000000..1d5aedb22cb51d00b176f44c5ac5f3ad29d843f2 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388521.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388525.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388525.png new file mode 100644 index 0000000000000000000000000000000000000000..1d71cee4618f1f2822cea1031c9b0e5d602e0a9b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388525.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388529.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388529.png new file mode 100644 index 0000000000000000000000000000000000000000..8253c65764c8d74e0a25404aa62fdd69d43f3c26 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388529.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388581.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388581.png new file mode 100644 index 0000000000000000000000000000000000000000..5ccdc532cb219f1175708b11241a37d912e2ec2e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388581.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388637.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388637.png new file mode 100644 index 0000000000000000000000000000000000000000..f9db5c31c8eae66244cd3f6e11336f72284bb2a6 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431388637.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548105.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548105.png new file mode 100644 index 0000000000000000000000000000000000000000..5da42e3e14d601745274cb62d914c6600620bb25 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548105.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548109.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548109.png new file mode 100644 index 0000000000000000000000000000000000000000..63b480df9e9700601da85abef015c8326095851f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548109.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548113.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548113.png new file mode 100644 index 0000000000000000000000000000000000000000..63f343e89f62b15c117e0148c87ac049308c3117 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548113.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548117.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548117.png new file mode 100644 index 0000000000000000000000000000000000000000..6afdd1b39e4bcb3664c7664a55b47b8537f4aeaa Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548117.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548121.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548121.png new file mode 100644 index 0000000000000000000000000000000000000000..d6bbab16659f4b34b38a714510665ea7fd309055 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548121.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548125.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548125.png new file mode 100644 index 0000000000000000000000000000000000000000..fea0122d3ef81899a02199c6cb265a099ad6c44f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548125.png differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548233.png b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548233.png new file mode 100644 index 0000000000000000000000000000000000000000..4cef59797fd8b9650c398562ac0b473485a9274b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/figures/zh-cn_image_0000001431548233.png differ diff --git "a/zh-cn/application-dev/reference/arkui-js-lite/figures/\345\212\250\347\224\273\346\240\267\345\274\217demo1.gif" "b/zh-cn/application-dev/reference/arkui-js-lite/figures/\345\212\250\347\224\273\346\240\267\345\274\217demo1.gif" new file mode 100644 index 0000000000000000000000000000000000000000..fc1eadbb05520daa6d79779683db96d0afe7cbdd Binary files /dev/null and "b/zh-cn/application-dev/reference/arkui-js-lite/figures/\345\212\250\347\224\273\346\240\267\345\274\217demo1.gif" differ diff --git "a/zh-cn/application-dev/reference/arkui-js-lite/figures/\345\212\250\347\224\273\346\240\267\345\274\217demo2.gif" "b/zh-cn/application-dev/reference/arkui-js-lite/figures/\345\212\250\347\224\273\346\240\267\345\274\217demo2.gif" new file mode 100644 index 0000000000000000000000000000000000000000..c3d337edf8e35352dcc9d9b9919019e1f7ec4d96 Binary files /dev/null and "b/zh-cn/application-dev/reference/arkui-js-lite/figures/\345\212\250\347\224\273\346\240\267\345\274\217demo2.gif" differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-common-attributes.md b/zh-cn/application-dev/reference/arkui-js-lite/js-common-attributes.md new file mode 100644 index 0000000000000000000000000000000000000000..36637b58e4af2013c749aadb93fc173bcfada4d7 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-common-attributes.md @@ -0,0 +1,28 @@ +# 通用属性 + + +## 常规属性 + +常规属性指的是组件普遍支持的用来设置组件基本标识和外观显示特征的属性。 + +| 名称 | 类型 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | +| id | string | 否 | 组件的唯一标识。 | +| style | string | 否 | 组件的样式声明。 | +| class | string | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + +## 渲染属性 + +组件普遍支持的用来设置组件是否渲染的属性。 + +| 名称 | 类型 | 描述 | +| -------- | -------- | -------- | +| for | Array | 根据设置的数据列表,展开当前元素。 | +| if | boolean | 根据设置的boolean值,添加或移除当前元素。 | +| show | boolean | 根据设置的boolean值,显示或隐藏当前元素。 | + +> **说明:** +> +> 属性和样式不能混用,不能在属性字段中进行样式设置。 diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-common-events.md b/zh-cn/application-dev/reference/arkui-js-lite/js-common-events.md new file mode 100644 index 0000000000000000000000000000000000000000..b97c3cc525ce41b8bc8a1a9f4d1e3ecc1b13e743 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-common-events.md @@ -0,0 +1,18 @@ +# 通用事件 + + +相对于私有事件,大部分组件都可以绑定如下事件。 + + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | SwipeEvent | 组件上快速滑动后触发。 | + + + **表6** SwipeEvent 基础事件对象属性列表(继承BaseEvent) + +| 属性 | 类型 | 说明 | +| -------- | -------- | -------- | +| direction | string | 滑动方向,可能值有:
1. left:向左滑动;
2. right:向右滑动;
3. up:向上滑动;
4. down:向下滑动。 | diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-common-styles.md b/zh-cn/application-dev/reference/arkui-js-lite/js-common-styles.md new file mode 100644 index 0000000000000000000000000000000000000000..48e1311e360318cab2a240d45d8e7075c5c5605b --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-common-styles.md @@ -0,0 +1,187 @@ +# 通用样式 + + +组件普遍支持的可以在style或css中设置组件外观样式。 + + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。

未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| opacity5+ | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + + +> **说明:** +> 通用样式都不是必填项。 +> +> 目前,样式支持的颜色格式如下: +> - rgb(255, 255, 255) +> +> - rgba(255, 255, 255, 1.0) +> +> - HEX格式:\#rrggbb,\#aarrggbb +> +> - 枚举格式:black,white等,详见 **表1** 当前支持的颜色枚举。Script脚本中不支持枚举格式。 + + + **表1** 当前支持的颜色枚举 + +| 枚举名称 | 对应颜色 | 颜色 | +| -------- | -------- | -------- | +| aliceblue | \#f0f8ff | ![aliceblue](figures/aliceblue.png) | +| antiquewhite | \#faebd7 | ![antiquewhite](figures/antiquewhite.png) | +| aqua | \#00ffff | ![aqua](figures/aqua.png) | +| aquamarine | \#7fffd4 | ![aquamarine](figures/aquamarine.png) | +| azure | \#f0ffff | ![azure](figures/azure.png) | +| beige | \#f5f5dc | ![beige](figures/beige.png) | +| bisque | \#ffe4c4 | ![bisque](figures/bisque.png) | +| black | \#000000 | ![#000000](figures/#000000.png) | +| blanchedalmond | \#ffebcd | ![blanchedalmond](figures/blanchedalmond.png) | +| blue | \#0000ff | ![blue](figures/blue.png) | +| blueviolet | \#8a2be2 | ![blueviolet](figures/blueviolet.png) | +| brown | \#a52a2a | ![brown](figures/brown.png) | +| burlywood | \#deB887 | ![burlywood](figures/burlywood.png) | +| cadetblue | \#5f9ea0 | ![cadetblue](figures/cadetblue.png) | +| chartreuse | \#7fff00 | ![chartreuse](figures/chartreuse.png) | +| chocolate | \#d2691e | ![chocolate](figures/chocolate.png) | +| coral | \#ff7f50 | ![coral](figures/coral.png) | +| cornflowerblue | \#6495ed | ![cornflowerblue](figures/cornflowerblue.png) | +| cornsilk | \#fff8dc | ![cornsilk](figures/cornsilk.png) | +| crimson | \#dc143c | ![crimson](figures/crimson.png) | +| cyan | \#00ffff | ![cyan](figures/cyan.png) | +| darkblue | \#00008b | ![darkblue](figures/darkblue.png) | +| darkcyan | \#008b8b | ![darkcyan](figures/darkcyan.png) | +| darkgoldenrod | \#b8860b | ![darkgoldenrod](figures/darkgoldenrod.png) | +| darkgray | \#a9a9a9 | ![darkgray](figures/darkgray.png) | +| darkgreen | \#006400 | ![darkgreen](figures/darkgreen.png) | +| darkgrey | \#a9a9a9 | ![darkgrey](figures/darkgrey.png) | +| darkkhaki | \#bdb76b | ![darkkhaki](figures/darkkhaki.png) | +| darkmagenta | \#8b008b | ![darkmagenta](figures/darkmagenta.png) | +| darkolivegreen | \#556b2f | ![darkolivegreen](figures/darkolivegreen.png) | +| darkorange | \#ff8c00 | ![darkorange](figures/darkorange.png) | +| darkorchid | \#9932cc | ![darkorchid](figures/darkorchid.png) | +| darkred | \#8b0000 | ![darkred](figures/darkred.png) | +| darksalmon | \#e9967a | ![darksalmon](figures/darksalmon.png) | +| darkseagreen | \#8fbc8f | ![darkseagreen](figures/darkseagreen.png) | +| darkslateblue | \#483d8b | ![darkslateblue](figures/darkslateblue.png) | +| darkslategray | \#2f4f4f | ![darkslategray](figures/darkslategray.png) | +| darkslategrey | \#2f4f4f | ![darkslategrey](figures/darkslategrey.png) | +| darkturquoise | \#00ced1 | ![darkturquoise](figures/darkturquoise.png) | +| darkviolet | \#9400d3 | ![darkviolet](figures/darkviolet.png) | +| deeppink | \#ff1493 | ![deeppink](figures/deeppink.png) | +| deepskyblue | \#00bfff | ![deepskyblue](figures/deepskyblue.png) | +| dimgray | \#696969 | ![dimgray](figures/dimgray.png) | +| dimgrey | \#696969 | ![dimgrey](figures/dimgrey.png) | +| dodgerblue | \#1e90ff | ![dodgerblue](figures/dodgerblue.png) | +| firebrick | \#b22222 | ![firebrick](figures/firebrick.png) | +| floralwhite | \#fffaf0 | ![floralwhite](figures/floralwhite.png) | +| forestgreen | \#228b22 | ![forestgreen](figures/forestgreen.png) | +| fuchsia | \#ff00ff | ![fuchsia](figures/fuchsia.png) | +| gainsboro | \#dcdcdc | ![gainsboro](figures/gainsboro.png) | +| ghostwhite | \#f8f8ff | ![ghostwhite](figures/ghostwhite.png) | +| gold | \#ffd700 | ![gold](figures/gold.png) | +| goldenrod | \#daa520 | ![goldenrod](figures/goldenrod.png) | +| gray | \#808080 | ![gray](figures/gray.png) | +| green | \#008000 | ![green](figures/green.png) | +| greenyellow | \#adff2f | ![greenyellow](figures/greenyellow.png) | +| grey | \#808080 | ![grey](figures/grey.png) | +| honeydew | \#f0fff0 | ![honeydew](figures/honeydew.png) | +| hotpink | \#ff69b4 | ![hotpink](figures/hotpink.png) | +| indianred | \#cd5c5c | ![indianred](figures/indianred.png) | +| indigo | \#4b0082 | ![indigo](figures/indigo.png) | +| ivory | \#fffff0 | ![ivory](figures/ivory.png) | +| khaki | \#f0e68c | ![khaki](figures/khaki.png) | +| lavender | \#e6e6fa | ![lavender](figures/lavender.png) | +| lavenderblush | \#fff0f5 | ![lavenderblush](figures/lavenderblush.png) | +| lawngreen | \#7cfc00 | ![lawngreen](figures/lawngreen.png) | +| lemonchiffon | \#fffacd | ![lemonchiffon](figures/lemonchiffon.png) | +| lightblue | \#add8e6 | ![lightblue](figures/lightblue.png) | +| lightcoral | \#f08080 | ![lightcoral](figures/lightcoral.png) | +| lightcyan | \#e0ffff | ![lightcyan](figures/lightcyan.png) | +| lightgoldenrodyellow | \#fafad2 | ![lightgoldenrodyellow](figures/lightgoldenrodyellow.png) | +| lightgray | \#d3d3d3 | ![lightgray](figures/lightgray.png) | +| lightgreen | \#90ee90 | ![lightgreen](figures/lightgreen.png) | +| lightpink | \#ffb6c1 | ![lightpink](figures/lightpink.png) | +| lightsalmon | \#ffa07a | ![lightsalmon](figures/lightsalmon.png) | +| lightseagreen | \#20b2aa | ![lightseagreen](figures/lightseagreen.png) | +| lightskyblue | \#87cefa | ![lightskyblue](figures/lightskyblue.png) | +| lightslategray | \#778899 | ![lightslategray](figures/lightslategray.png) | +| lightslategrey | \#778899 | ![lightslategrey](figures/lightslategrey.png) | +| lightsteelblue | \#b0c4de | ![lightsteelblue](figures/lightsteelblue.png) | +| lightyellow | \#ffffe0 | ![lightyellow](figures/lightyellow.png) | +| lime | \#00ff00 | ![lime](figures/lime.png) | +| limegreen | \#32cd32 | ![limegreen](figures/limegreen.png) | +| linen | \#faf0e6 | ![linen](figures/linen.png) | +| magenta | \#ff00ff | ![magenta](figures/magenta.png) | +| maroon | \#800000 | ![maroon](figures/maroon.png) | +| mediumaquamarine | \#66cdaa | ![mediumaquamarine](figures/mediumaquamarine.png) | +| mediumblue | \#0000cd | ![mediumblue](figures/mediumblue.png) | +| mediumorchid | \#ba55d3 | ![mediumorchid](figures/mediumorchid.png) | +| mediumpurple | \#9370db | ![mediumpurple](figures/mediumpurple.png) | +| mediumseagreen | \#3cb371 | ![mediumseagreen](figures/mediumseagreen.png) | +| mediumslateblue | \#7b68ee | ![mediumslateblue](figures/mediumslateblue.png) | +| mediumspringgreen | \#00fa9a | ![mediumspringgreen](figures/mediumspringgreen.png) | +| mediumturquoise | \#48d1cc | ![mediumturquoise](figures/mediumturquoise.png) | +| mediumvioletred | \#c71585 | ![mediumvioletred](figures/mediumvioletred.png) | +| midnightblue | \#191970 | ![midnightblue](figures/midnightblue.png) | +| mintcream | \#f5fffa | ![mintcream](figures/mintcream.png) | +| mistyrose | \#ffe4e1 | ![mistyrose](figures/mistyrose.png) | +| moccasin | \#ffe4b5 | ![moccasin](figures/moccasin.png) | +| navajowhite | \#ffdead | ![navajowhite](figures/navajowhite.png) | +| navy | \#000080 | ![navy](figures/navy.png) | +| oldlace | \#fdf5e6 | ![oldlace](figures/oldlace.png) | +| olive | \#808000 | ![olive](figures/olive.png) | +| olivedrab | \#6b8e23 | ![olivedrab](figures/olivedrab.png) | +| orange | \#ffa500 | ![orange](figures/orange.png) | +| orangered | \#ff4500 | ![orangered](figures/orangered.png) | +| orchid | \#da70d6 | ![orchid](figures/orchid.png) | +| palegoldenrod | \#eee8aa | ![palegoldenrod](figures/palegoldenrod.png) | +| palegreen | \#98fb98 | ![palegreen](figures/palegreen.png) | +| paleturquoise | \#afeeee | ![paleturquoise](figures/paleturquoise.png) | +| palevioletred | \#db7093 | ![palevioletred](figures/palevioletred.png) | +| papayawhip | \#ffefd5 | ![papayawhip](figures/papayawhip.png) | +| peachpuff | \#ffdab9 | ![peachpuff](figures/peachpuff.png) | +| peru | \#cd853f | ![peru](figures/peru.png) | +| pink | \#ffc0cb | ![pink](figures/pink.png) | +| plum | \#dda0dd | ![plum](figures/plum.png) | +| powderblue | \#b0e0e6 | ![powderblue](figures/powderblue.png) | +| purple | \#800080 | ![purple](figures/purple.png) | +| rebeccapurple | \#663399 | ![rebeccapurple](figures/rebeccapurple.png) | +| red | \#ff0000 | ![red](figures/red.png) | +| rosybrown | \#bc8f8f | ![rosybrown](figures/rosybrown.png) | +| royalblue | \#4169e1 | ![royalblue](figures/royalblue.png) | +| saddlebrown | \#8b4513 | ![saddlebrown](figures/saddlebrown.png) | +| salmon | \#fa8072 | ![salmon](figures/salmon.png) | +| sandybrown | \#f4a460 | ![sandybrown](figures/sandybrown.png) | +| seagreen | \#2e8b57 | ![seagreen](figures/seagreen.png) | +| seashell | \#fff5ee | ![seashell](figures/seashell.png) | +| sienna | \#a0522d | ![sienna](figures/sienna.png) | +| silver | \#c0c0c0 | ![silver](figures/silver.png) | +| skyblue | \#87ceeb | ![skyblue](figures/skyblue.png) | +| slateblue | \#6a5acd | ![slateblue](figures/slateblue.png) | +| slategray | \#708090 | ![slategray](figures/slategray.png) | +| slategrey | \#708090 | ![slategray](figures/slategray.png) | +| snow | \#fffafa | ![snow](figures/snow.png) | +| springgreen | \#00ff7f | ![springgreen](figures/springgreen.png) | +| steelblue | \#4682b4 | ![steelblue](figures/steelblue.png) | +| tan | \#d2b48c | ![tan](figures/tan.png) | +| teal | \#008080 | ![teal](figures/teal.png) | +| thistle | \#d8Bfd8 | ![thistle](figures/thistle.png) | +| tomato | \#ff6347 | ![tomato](figures/tomato.png) | +| turquoise | \#40e0d0 | ![turquoise](figures/turquoise.png) | +| violet | \#ee82ee | ![violet](figures/violet.png) | +| wheat | \#f5deb3 | ![wheat](figures/wheat.png) | +| white | \#ffffff | ![white](figures/white.png) | +| whitesmoke | \#f5f5f5 | ![whitesmoke](figures/whitesmoke.png) | +| yellow | \#ffff00 | ![yellow](figures/yellow.png) | +| yellowgreen | \#9acd32 | ![yellowgreen](figures/yellowgreen.png) | diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-chart.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-chart.md new file mode 100644 index 0000000000000000000000000000000000000000..71730347c3280ff915655e5d916c4c97fa5e3693 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-chart.md @@ -0,0 +1,275 @@ +# chart + +图表组件,用于呈现线形图、柱状图界面。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +不支持。 + + +## 属性 + +| 名称 | 类型 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | +| type | string | 否 | 设置图表类型(不支持动态修改),可选项有:
- bar:柱状图。
- line:线形图。
默认值:line | +| options | ChartOptions | 是 | 图表参数设置,柱状图和线形图必须设置参数设置。可以设置x轴、y轴的最小值、最大值、刻度数、是否显示,线条宽度、是否平滑等。(不支持动态修改) | +| datasets | Array<ChartDataset> | 是 | 数据集合,柱状图和线形图必须设置数据集合。可以设置多条数据集及其背景色。 | +| id | string | 否 | 组件的唯一标识。 | +| style | string | 否 | 组件的样式声明。 | +| class | string | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + **表2** ChartOptions + +| 名称 | 类型 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | +| xAxis | ChartAxis | 是 | x轴参数设置。可以设置x轴最小值、最大值、刻度数以及是否显示。 | +| yAxis | ChartAxis | 是 | y轴参数设置。可以设置y轴最小值、最大值、刻度数以及是否显示。 | +| series | ChartSeries | 否 | 数据序列参数设置。可以设置:
1. 线的样式,如线宽、是否平滑;
2. 设置线最前端位置白点的样式和大小。
**说明:**
仅线形图支持。 | + + **表3** ChartDataset + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| backgroundColor(deprecated) | <color> | \#ff6384 | 否 | 设置线或柱的颜色(不推荐使用)。 | +| strokeColor | <color> | \#ff6384 | 否 | 线条颜色。仅线形图支持。 | +| fillColor | <color> | \#ff6384 | 否 | 填充颜色。线形图表示填充的渐变颜色。 | +| data | Array<number> | - | 是 | 设置绘制线或柱中的点集。 | +| gradient | boolean | false | 否 | 设置是否显示填充渐变颜色。仅线形图支持。 | + + **表4** ChartAxis + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| min | number | 0 | 否 | 轴的最小值。
不支持负数。仅线形图支持。 | +| max | number | 100 | 否 | 轴的最大值。
不支持负数。仅线形图支持。 | +| axisTick | number | 10 | 否 | 轴显示的刻度数量。
**说明:**
仅支持1~20,且具体显示的效果与如下计算值有关(图的宽度所占的像素/(max-min))。
因轻量级智能穿戴为整型运行,在除不尽的情况下会有误差产生,具体的表现形式是x轴末尾可能会空出一段。
在柱状图中,每组数据显示的柱子数量与刻度数量一致,且柱子显示在刻度处。 | +| display | boolean | false | 否 | 是否显示轴。 | +| color | <color> | \#c0c0c0 | 否 | 轴颜色。 | + + **表5** ChartSeries + +| 名称 | 类型 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | +| lineStyle | ChartLineStyle | 否 | 线样式设置,如线宽、是否平滑。 | +| headPoint | PointStyle | 否 | 线最前端位置白点的样式和大小。 | +| topPoint | PointStyle | 否 | 最高点的样式和大小。 | +| bottomPoint | PointStyle | 否 | 最低点的样式和大小。 | +| loop | ChartLoop | 否 | 设置屏幕显示满时,是否需要重头开始绘制。 | + + **表6** ChartLineStyle + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| width | <length> | 1px | 否 | 线宽设置。 | +| smooth | boolean | false | 否 | 是否平滑。 | + + **表7** PointStyle + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| shape | string | circle | 否 | 高亮点的形状。可选值为:
- circle:圆形。 | +| size | <length> | 5px | 否 | 高亮点的大小。 | +| strokeWidth | <length> | 1px | 否 | 边框宽度 | +| strokeColor | <color> | \#ff0000 | 否 | 边框颜色。 | +| fillColor | <color> | \#ff0000 | 否 | 填充颜色。 | +| display | boolean | true | 否 | 是否高亮显示。 | + + **表8** ChartLoop + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| margin | <length> | 1 | 否 | 擦除点的个数(最新绘制的点与最老的点之间的横向距离)。注意:轻量设备margin和topPoint/bottomPoint/headPoint同时使用时,有概率出现point正好位于擦除区域的情况,导致point不可见,因此不建议同时使用。 | + + + + +## 方法 + +| 方法 | 参数 | 描述 | +| -------- | -------- | -------- | +| append | {
serial: number, // 设置要更新的线形图数据下标
data: Array<number>, // 设置新增的数据
} | 往已有的数据序列中动态添加数据,根据serial指定目标序列,serial为datasets数组的下标,从0开始。注意:不会更新datasets[index].data。仅线形图支持,按横坐标加1递增(与xAxis min/max设置相关)。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。

未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + +## 示例 + +1. 线形图 + + ```html + +
+ + +
+ ``` + + + ```css + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 454px; + height: 454px; + background-color: white; + } + .chart { + width: 300px; + height: 300px; + } + .button { + width: 280px; + border-radius: 0px; + } + ``` + + + ```js + // xxx.js + export default { + data: { + lineData: [ + { + strokeColor: '#0081ff', + fillColor: '#cce5ff', + data: [763, 550, 551, 554, 731, 654, 525, 696, 595, 628, 791, 505, 613, 575, 475, 553, 491, 680, 657, 716], + gradient: true, + } + ], + lineOps: { + xAxis: { + min: 0, + max: 20, + display: false, + }, + yAxis: { + min: 0, + max: 1000, + display: false, + }, + series: { + lineStyle: { + width: "5px", + smooth: true, + }, + headPoint: { + shape: "circle", + size: 10, + strokeWidth: 5, + fillColor: '#ffffff', + strokeColor: '#007aff', + display: true, + }, + loop: { + margin: 2, + gradient: true, + } + } + }, + }, + addData() { + this.$refs.linechart.append({ + serial: 0, + data: [Math.floor(Math.random() * 400) + 400] + }) + } + } + ``` + + ![lite_line](figures/lite_line.PNG) + +2. 柱状图 + + ```html + +
+ +
+ ``` + + + ```css + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 454px; + height: 454px; + background-color: white; + } + .chart { + width: 300px; + height: 300px; + } + ``` + + + ```js + // xxx.js + export default { + data: { + barData: [ + { + fillColor: '#f07826', + data: [763, 550, 551, 554, 731, 654, 525, 696, 595, 628], + }, + { + fillColor: '#cce5ff', + data: [535, 776, 615, 444, 694, 785, 677, 609, 562, 410], + }, + { + fillColor: '#ff88bb', + data: [673, 500, 574, 483, 702, 583, 437, 506, 693, 657], + }, + ], + barOps: { + xAxis: { + min: 0, + max: 20, + display: false, + axisTick: 10 + }, + yAxis: { + min: 0, + max: 1000, + display: false, + }, + }, + } + } + ``` + + ![lite_bar](figures/lite_bar.PNG) diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-image-animator.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-image-animator.md new file mode 100644 index 0000000000000000000000000000000000000000..9c85c0e3808241dda5faad0aa459c627d5ed069b --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-image-animator.md @@ -0,0 +1,207 @@ +# image-animator + +图片帧动画播放器。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +不支持。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| images | Array<ImageFrame> | - | 是 | 设置图片帧信息集合。每一帧的帧信息包含图片路径、图片大小和图片位置信息。目前支持以下图片格式:png、jpg和bmp。ImageFrame的详细说明请见表1。
**说明:**
使用时需要使用数据绑定的方式,如images = {{images}},js中声明相应变量:images: [{src: "/common/heart-rate01.png"}, {src: "/common/heart-rate02.png"}]。 | +| iteration | number \| string | infinite | 否 | 设置帧动画播放次数。number表示固定次数,infinite枚举表示无限次数播放。 | +| reverse | boolean | false | 否 | 设置播放顺序。false表示从第1张图片播放到最后1张图片; true表示从最后1张图片播放到第1张图片。 | +| fixedsize | boolean | true | 否 | 设置图片大小是否固定为组件大小。 true表示图片大小与组件大小一致,此时设置图片的width 、height 、top 和left属性是无效的。false表示每一张图片的 width 、height 、top和left属性都要单独设置。 | +| duration | string | - | 是 | 设置单次播放时长。单位支持[s(秒)\|ms(毫秒)],默认单位为ms。 duration为0时,不播放图片。 值改变只会在下一次循环开始时生效。 | +| fillmode5+ | string | forwards | 否 | 指定帧动画执行结束后的状态。可选项有:
- none:恢复初始状态。
- forwards:保持帧动画结束时的状态(在最后一个关键帧中定义)。 | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + **表2** ImageFrame说明 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| src | <uri> | - | 是 | 图片路径。 | +| width | <length> | 0 | 否 | 图片宽度。 | +| height | <length> | 0 | 否 | 图片高度。 | +| top | <length> | 0 | 否 | 图片相对于组件左上角的纵向坐标。 | +| left | <length> | 0 | 否 | 图片相对于组件左上角的横向坐标。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| stop | - | 帧动画结束时触发。 | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。

未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| opacity5+ | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + + +## 方法 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| start | - | 开始播放图片帧动画。再次调用,重新从第1帧开始播放。 | +| pause | - | 暂停播放图片帧动画。 | +| stop | - | 停止播放图片帧动画。 | +| resume | - | 继续播放图片帧。 | +| getState | - | 获取播放状态。可能值有:
- playing:播放中
- paused:已暂停
- stopped:已停止。 | + + +## 示例 + + +```html + +
+ +
+ + + + +
+
+``` + + +```css +/* xxx.css */ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 454px; + height: 454px; +} +.animator { + width: 70px; + height: 70px; +} +.btn-box { + width: 264px; + height: 120px; + flex-wrap: wrap; + justify-content: space-around; + align-items: center; +} +.btn { + border-radius: 8px; + width: 120px; + margin-top: 8px; +} +``` + + +```js +//xxx.js +export default { + data: { + frames: [ + { + src: "/common/asserts/heart78.png", + }, + { + src: "/common/asserts/heart79.png", + }, + { + src: "/common/asserts/heart80.png", + }, + { + src: "/common/asserts/heart81.png", + }, + { + src: "/common/asserts/heart82.png", + }, + { + src: "/common/asserts/heart83.png", + }, + { + src: "/common/asserts/heart84.png", + }, + { + src: "/common/asserts/heart85.png", + }, + { + src: "/common/asserts/heart86.png", + }, + { + src: "/common/asserts/heart87.png", + }, + { + src: "/common/asserts/heart88.png", + }, + { + src: "/common/asserts/heart89.png", + }, + { + src: "/common/asserts/heart90.png", + }, + { + src: "/common/asserts/heart91.png", + }, + { + src: "/common/asserts/heart92.png", + }, + { + src: "/common/asserts/heart93.png", + }, + { + src: "/common/asserts/heart94.png", + }, + { + src: "/common/asserts/heart95.png", + }, + { + src: "/common/asserts/heart96.png", + }, + ], + }, + handleStart() { + this.$refs.animator.start(); + }, + handlePause() { + this.$refs.animator.pause(); + }, + handleResume() { + this.$refs.animator.resume(); + }, + handleStop() { + this.$refs.animator.stop(); + }, +}; +``` + +![image-animator](figures/image-animator.gif) diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-image.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-image.md new file mode 100644 index 0000000000000000000000000000000000000000..838db18b496f1fd144bc2cebddb70dfc2e84e516 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-image.md @@ -0,0 +1,74 @@ +# image + +图片组件,用来渲染展示图片。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +不支持。 + + +## 属性 + +| 名称 | 类型 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | +| src | string | 否 |
图片的路径,支持的图片格式包括png、jpg。 | +| id | string | 否 | 组件的唯一标识。 | +| style | string | 否 | 组件的样式声明。 | +| class | string | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。

未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| opacity | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + +## 示例 + +```html + +
+ + +
+``` + +```css +/* xxx.css */ +.container { + justify-content: center; + align-items: center; + flex-direction: column; + width: 100%; + height: 100%; +} +``` + +![image](figures/image.png) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-input.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-input.md new file mode 100644 index 0000000000000000000000000000000000000000..facd4e72415f5c740b879c02698c0f4e5823e620 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-input.md @@ -0,0 +1,181 @@ +# input + +交互式组件,包括单选框,多选框,按钮。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +不支持。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| type | string |
button | 否 | input组件类型,可选值为button,checkbox,radio。

button,checkbox,radio不支持动态修改。可选值定义如下:
- button:定义可点击的按钮;
- checkbox:定义多选框;
- radio:定义单选按钮,允许在多个拥有相同name值的选项中选中其中一个; | +| checked | boolean | false | 否 | 当前组件是否选中,仅type为checkbox和radio生效。 | +| name | string | - | 否 | input组件的名称。 | +| value | string | - | 否 | input组件的value值,当类型为radio时必填且相同name值的选项该值唯一。 | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + +## 事件 + +- 当input类型为checkbox、radio时,支持如下事件: + | 名称 | 参数 | 描述 | + | -------- | -------- | -------- | + | change | { checked:true \| false } | checkbox多选框或radio单选框的checked状态发生变化时触发该事件。 | + | click | - | 点击动作触发该事件。 | + | longpress | - | 长按动作触发该事件。 | + | swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + +- 当input类型为button时,支持如下事件: + | 名称 | 参数 | 描述 | + | -------- | -------- | -------- | + | click | - | 点击动作触发该事件。 | + | longpress | - | 长按动作触发该事件。 | + | swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#ffffff | 否 | 按钮的文本颜色。 | +| font-size | <length> | 30px | 否 | 按钮的文本尺寸。 | +| width | <length> | - | 否 | type为button时,默认值为100px。 | +| height | <length> | - | 否 | type为button时,默认值为50px。 | +| font-family | string | SourceHanSansSC-Regular | 否 | 字体。目前仅支持SourceHanSansSC-Regular 字体。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + +## 示例 + +1. type为button + + ```html + +
+ +
+ ``` + + ```css + /* xxx.css */ + .div-button { + flex-direction: column; + align-items: center; + width: 100%; + height: 100%; + } + .button { + margin-top: 30px; + width: 280px; + } + ``` + + ![input-type-button](figures/input-type-button.png) + + + +2. type为checkbox + + ```html + +
+ + {{text}} +
+ ``` + + ```css + /* xxx.css */ + .content{ + width: 100%; + height: 100%; + flex-direction: column; + align-items: center; + justify-content: center; + } + .text{ + font-size: 30px; + text-align: center; + width: 200px; + margin-top: 20px; + height: 100px; + } + ``` + + ```javascript + // xxx.js + export default { + data: { + text: "text" + }, + checkboxOnChange(e) { + this.text = e.checked; + } + } + ``` + + ![input-type-checkbox](figures/input-type-checkbox.gif) + +3. type为radio + + ```html + +
+
+ + radio1 +
+
+ + radio2 +
+
+ + radio3 +
+
+ ``` + + ```css + /* xxx.css */ + .container { + width: 100%; + height: 100%; + justify-content: center; + align-items: center; + flex-direction: column; + } + .item { + width: 50%; + height: 30%; + justify-content: center; + } + .text { + margin-top: 25%; + font-size: 30px; + text-align: center; + width: 200px; + height: 100px; + } + ``` + + ![input-type-radio](figures/input-type-radio.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-marquee.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-marquee.md new file mode 100644 index 0000000000000000000000000000000000000000..e146eb244ac7c796efca5773842feaf1607502ee --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-marquee.md @@ -0,0 +1,118 @@ +# marquee + +跑马灯组件,用于展示一段单行滚动的文字。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +不支持。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| scrollamount | number | 6 | 否 | 跑马灯每次滚动时移动的最大长度。 | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#ffffff


| 否 | 设置跑马灯中文字的文本颜色。 | +| font-size | <length> |
30 | 否 | 设置跑马灯中文字的文本尺寸。 | +| font-family | string |

SourceHanSansSC-Regular | 否 |

字体。目前仅支持SourceHanSansSC-Regular 字体。 | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。

未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| opacity5+ | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + +## 示例 + +```html + +
+ {{marqueeCustomData}} + speed+ + speed- + changeData +
+``` + +```css +/* xxx.css */ +.container { + flex-direction: column; + width: 100%; + height: 100%; + flex-direction: column; + align-items: center; +} +.customMarquee { + width: 50%; + height: 80px; + padding: 10px; + margin: 20px; + border-width: 4px; + border-color: #ffffff; + border-radius: 20px; + font-size: 38px; +} +.text { + font-size: 30px; + text-align: center; + width: 30%; + height: 10%; + margin-top: 5%; + background-color: #f2f2f2; + border-radius: 40px; + color: #0d81f2; +} +``` + +```javascript +// xxx.js +export default { + data: { + scrollAmount: 30, + marqueeCustomData: 'Custom marquee Custom marquee Custom marquee' + }, + addSpeed() { + this.scrollAmount++; + }, + downSpeed() { + this.scrollAmount--; + }, + changeData() { + this.marqueeCustomData = 'Change Data Change Data Change Data'; + } +} +``` + +![marquee](figures/marquee.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-picker-view.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-picker-view.md new file mode 100644 index 0000000000000000000000000000000000000000..3722716aae1e0d42bf1638e0efc50d475430ee13 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-picker-view.md @@ -0,0 +1,145 @@ +# picker-view + +嵌入页面的滑动选择器。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +不支持。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| type | string | text | 否 | 设置滑动选择器的类型,该属性不支持动态修改,可选项有:
- text:文本选择器。
- time:时间选择器。 | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + +文本选择器:type=text + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| range | Array | - | 否 | 设置文本选择器的取值范围。
使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:["15", "20", "25"]。 | +| selected | string | 0 | 否 | 设置文本选择器的默认选择值,该值需要为range的索引。 | + +时间选择器:type=time + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| selected | string | 00:00 | 否 | 设置时间选择器的默认取值,格式为 HH:mm;
| + + +## 事件 + +type=text: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { newValue: newValue, newSelected: newSelected } | 文本选择器选定值后触发该事件。 | + +type=time: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { hour: hour, minute: minute} | 时间选择器选定值后触发该事件。
| + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#808080
| 否 | 候选项字体颜色。 | +| font-size | <length> | 30px
| 否 | 候选项字体尺寸,类型length,单位px。 | +| selected-color | <color> | \#ffffff
| 否 | 选中项字体颜色。 | +| selected-font-size | <length> | 38px
| 否 | 选中项字体尺寸,类型length,单位px。 | +| selected-font-family | string | HYQiHei-65S | 否 | 选中项字体类型。 | +| font-family | string |
HYQiHei-65S | 否 | 选项字体类型。 | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。

未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + + +## 示例 + + +```html + +
+ + Selected:{{time}} + + +
+``` + + +```css +/* xxx.css */ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 454px; + height: 454px; +} +.title { + font-size: 30px; + text-align: center; +} +.time-picker { + width: 500px; + height: 400px; + margin-top: 20px; +} +``` + + +```js +/* xxx.js */ +export default { + data: { + defaultTime: "", + time: "", + }, + onInit() { + this.defaultTime = this.now(); + }, + handleChange(data) { + this.time = this.concat(data.hour, data.minute); + }, + now() { + const date = new Date(); + const hours = date.getHours(); + const minutes = date.getMinutes(); + return this.concat(hours, minutes); + }, + + fill(value) { + return (value > 9 ? "" : "0") + value; + }, + + concat(hours, minutes) { + return `${this.fill(hours)}:${this.fill(minutes)}`; + }, +} +``` + +![picker-view](figures/picker-view.png) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-progress.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-progress.md new file mode 100644 index 0000000000000000000000000000000000000000..afbbb9010be0c457ac3419da1c5f30aae9fa8388 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-progress.md @@ -0,0 +1,125 @@ +# progress + +进度条,用于显示内容加载或操作处理进度。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +不支持。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| type | string | horizontal | 否 | 设置进度条的类型,该属性不支持动态修改,可选值为:
- horizontal:线性进度条;
- arc:弧形进度条。 | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + +不同类型的进度条还支持不同的属性: + +- 类型为horizontal时,支持如下属性: + | 名称 | 类型 | 默认值 | 必填 | 描述 | + | -------- | -------- | -------- | -------- | -------- | + | percent | number | 0 | 否 | 当前进度。取值范围为0-100。 | + +- 类型为arc时,支持如下属性: + | 名称 | 类型 | 默认值 | 必填 | 描述 | + | -------- | -------- | -------- | -------- | -------- | + | percent | number | 0 | 否 | 当前进度。取值范围为0-100。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + +## 样式 + +- type为horizontal,支持如下样式: + + | 名称 | 类型 | 默认值 | 必填 | 描述 | + | ------------ | -------------- | ---------------------------------------------- | ---- | ------------------ | + | color | <color> | \#6b9ac7 | 否 | 设置进度条的颜色。 | + | stroke-width | <length> | 321-4 \| 45+px | 否 | 设置进度条的宽度。 | + +- type为arc,支持如下样式: + + | 名称 | 类型 | 默认值 | 必填 | 描述 | + | ---------------- | -------------- | ------ | ---- | ------------------------------------------------------------ | + | color | <color> | - | 否 | 弧形进度条的颜色。 | + | background-color | <color> | - | 否 | 弧形进度条的背景色。 | + | stroke-width | <length> | - | 否 | 弧形进度条的宽度。
进度条宽度越大,进度条越靠近圆心。即进度条始终在半径区域内。 | + | start-angle | <deg> | 240 | 否 | 弧形进度条起始角度,以时钟0点为基线。范围为0到360(顺时针)。 | + | total-angle | <deg> | 240 | 否 | 弧形进度条总长度,范围为-360到360,负数标识起点到终点为逆时针。 | + | center-x | <length> | - | 否 | 弧形进度条中心位置,(坐标原点为组件左上角顶点)。该样式需要和center-y和radius一起。 | + | center-y | <length> | - | 否 | 弧形进度条中心位置,(坐标原点为组件左上角顶点)。该样式需要和center-x和radius一起。 | + | radius | <length> | - | 否 | 弧形进度条半径,该样式需要和center-x和center-y一起。 | + +除上述样式之外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。
未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。
未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + +## 示例 + +```html + +
+ + +
+``` + +```css +/* xxx.css */ +.container { + flex-direction: column; + height: 100%; + width: 100%; + align-items: center; +} +.min-progress { + width: 300px; + height: 300px; +} +``` + +```javascript +// xxx.js +export default { + data: { + arcVal: 0, + horizontalVal: 0 + }, + changeArc() { + this.arcVal+= 10; + }, + changeHorizontal() { + this.horizontalVal+= 10; + } +} +``` + +![progress](figures/progress.png) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-qrcode.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-qrcode.md new file mode 100644 index 0000000000000000000000000000000000000000..c454322301d03fe4ae53bb7d3c83aa3b733cf239 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-qrcode.md @@ -0,0 +1,125 @@ +# qrcode + + +生成并显示二维码。 + +> **说明:** +> +> 该组件从从API version 5 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +不支持。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| value | string | - | 是 | 用来生成二维码的内容。最大长度为256。 | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#000000 | 否 | 二维码颜色 | +| background-color | <color> | \#ffffff | 否 | 二维码背景颜色 | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。

未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + +> **说明:** +> - width和height不一致时,以二者最小值作为二维码的边长。且最终生成的二维码居中显示; +> +>- width和height的最小值为200px。 + + +## 示例 + + +```html + +
+ + Color + BackgroundColor + Value +
+``` + +```css +/* xxx.css */ +.container { + width: 100%; + height: 100%; + flex-direction: column; + justify-content: center; + align-items: center; +} +.qrCode { + width: 200px; + height: 200px; +} +.button { + width: 30%; + height: 10%; + margin-top: 5%; +} +``` + +```javascript +// xxx.js +export default { + data: { + qr_col: '#87ceeb', + qr_bcol: '#f0ffff', + qr_value: 'value' + }, + changeColor() { + if (this.qr_col == '#87ceeb') { + this.qr_col = '#fa8072'; + } else { + this.qr_col = '#87ceeb'; + } + }, + changeBackgroundColor() { + if (this.qr_bcol == '#f0ffff') { + this.qr_bcol = '#ffffe0'; + } else { + this.qr_bcol = '#f0ffff'; + } + }, + changeValue() { + if (this.qr_value == 'value') { + this.qr_value = 'change'; + } else { + this.qr_value = 'value'; + } + } +} +``` + +![qrcode](figures/qrcode.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-slider.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-slider.md new file mode 100644 index 0000000000000000000000000000000000000000..a686e9cf6202041c883ce347c9feaf34af329572 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-slider.md @@ -0,0 +1,102 @@ +# slider + +滑动条组件,用来快速调节设置值,如音量、亮度等。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +不支持。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| min | number | 0 | 否 | 滑动选择器的最小值。 | +| max | number | 100 | 否 | 滑动选择器的最大值。 | +| value | number | 0 | 否 | 滑动选择器的初始值。 | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | ChangeEvent | 选择值发生变化时触发该事件。 | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + **表2** ChangeEvent + +| 属性 | 类型 | 说明 | +| -------- | -------- | -------- | +| progress(deprecated5+) | string | 当前slider的进度值。 | +| value5+ | number | 当前slider的进度值。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#000000 | 否 | 滑动条的背景颜色。 | +| selected-color | <color> | \#ffffff | 否 | 滑动条的已选择颜色。 | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。

未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + +## 示例 + +```html + +
+ slider start value is {{startValue}} + slider current value is {{currentValue}} + slider end value is {{endValue}} + +
+``` + +```css +/* xxx.css */ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} +``` + +```javascript +// xxx.js +export default { + data: { + value: 0, + startValue: 0, + currentValue: 0, + endValue: 100, + }, + setvalue(e) { + this.currentValue = e.value; + } +} +``` + +![slider](figures/slider.png) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-switch.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-switch.md new file mode 100644 index 0000000000000000000000000000000000000000..2f09e3c14322014dda6b1e1afd922d4b94dead9a --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-switch.md @@ -0,0 +1,99 @@ +# switch + +开关选择器,通过开关,开启或关闭某个功能。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +不支持。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| checked | boolean | false | 否 | 是否选中。 | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { checked: checkedValue } | 选中状态改变时触发该事件。 | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。

未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + +## 示例 + +```html + +
+
+ + {{title}} +
+
+``` + +```css +/* xxx.css */ +.container { + width: 100%; + height: 100%; + justify-content: center; + align-items: center; +} +.box{ + width: 18%; + height: 25%; + flex-direction:column; + justify-content: center; + align-items: center; +} +``` + +```javascript +// xxx.js +export default { + data: { + title: '开启' + }, + switchChange(e){ + console.log(e.checked); + if(e.checked){ + this.title="开启" + }else{ + this.title="关闭" + } + } +} +``` + +![switch](figures/switch.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-text.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-text.md new file mode 100644 index 0000000000000000000000000000000000000000..fa258500f81b3b9436188afb6cb77740202ec831 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-basic-text.md @@ -0,0 +1,98 @@ +# text + +文本,用于呈现一段信息。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +不支持。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#ffffff | 否 | 设置文本的颜色。 | +| font-size | <length> | 30px | 否 | 设置文本的尺寸。
| +| letter-spacing | <length> | 2px | 否 | 设置文本的字符间距。 | +| text-align | string | left | 否 | 设置文本的文本对齐方式,可选值为:
- left:文本左对齐;
- center:文本居中对齐;
- right:文本右对齐; | +| text-overflow | string | clip | 否 | 可选值为:
- clip:将文本根据父容器大小进行裁剪显示;
- ellipsis:根据父容器大小显示,显示不下的文本用省略号代替。 | +| font-family | string | SourceHanSansSC-Regular | 否 | 字体。目前仅支持SourceHanSansSC-Regular 字体。 | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。
未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| opacity5+ | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + +## 示例 + +```html + +
+ + Hello {{ title }} + +
+``` + +```CSS +/* xxx.css */ +.container { + width: 100%; + height: 100%; + justify-content: center; + align-items: center; +} + +.title { + width: 100px; + font-size: 30px; + text-align: center; + color: red; +} +``` + +```javascript +// xxx.js +export default { + data: { + title: "" + }, + onInit() { + this.title = "World"; + } +} +``` + +![text](figures/text.png) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-canvas-canvas.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-canvas-canvas.md new file mode 100644 index 0000000000000000000000000000000000000000..4ba0df786f1c888c861e9e002c12ee35eb794d4a --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-canvas-canvas.md @@ -0,0 +1,55 @@ +# canvas组件 + +提供画布组件。用于自定义绘制图形。 + +> **说明:** +> +> 该组件从从API version 5 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +不支持。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。

未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + + +## 方法 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| getContext | string  | 获取canvas绘图上下文,参数仅支持“2d”,返回值为2D绘制对象,该对象提供具体的2D绘制操作。详见[CanvasRenderingContext2D对象](js-components-canvas-canvasrenderingcontext2d.md)章节。 | diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-canvas-canvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-canvas-canvasrenderingcontext2d.md new file mode 100644 index 0000000000000000000000000000000000000000..0986adc7e314f7f2ed5acc2d39c56352eca100f4 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-canvas-canvasrenderingcontext2d.md @@ -0,0 +1,365 @@ +# CanvasRenderingContext2D对象 + + +使用CanvasRenderingContext2D在canvas画布组件上进行绘制,绘制对象可以是矩形、文本。 + +**示例:** + +```html + + + + +``` + + +```javascript +// xxx.js +export default { + handleClick() { + const el = this.$refs.canvas1; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.arc(100, 75, 50, 0, 6.28); + ctx.stroke(); + }, +} +``` + + ![zh-cn_image_0000001431548113](figures/zh-cn_image_0000001431548113.png) + + +## fillRect() + +填充一个矩形。 + +**参数:** + +| 参数 | 类型 | 描述 | +| -------- | -------- | -------- | +| x | number | 指定矩形左上角点的x坐标。 | +| y | number | 指定矩形左上角点的y坐标。 | +| width | number | 指定矩形的宽度。 | +| height | number | 指定矩形的高度。 | + +**示例:** + + ![zh-cn_image_0000001431388525](figures/zh-cn_image_0000001431388525.png) + + + ```javascript + ctx.fillRect(20, 20, 200, 150); + ``` + + +## fillStyle + +指定绘制的填充色。 + +**参数:** + +| 参数 | 类型 | 描述 | +| -------- | -------- | -------- | +| color | <color> | 设置填充区域的颜色。 | + +**示例:** + + ![zh-cn_image_0000001431388505](figures/zh-cn_image_0000001431388505.png) + + + ```javascript + ctx.fillStyle = '#0000ff'; + ctx.fillRect(20, 20, 150, 100); + ``` + + +## strokeRect() + +绘制具有边框的矩形,矩形内部不填充。 + +**参数:** + +| 参数 | 类型 | 描述 | +| -------- | -------- | -------- | +| x | number | 指定矩形的左上角x坐标。 | +| y | number | 指定矩形的左上角y坐标。 | +| width | number | 指定矩形的宽度。 | +| height | number | 指定矩形的高度。 | + +**示例:** + + ![zh-cn_image_0000001381268264](figures/zh-cn_image_0000001381268264.png) + + + ```javascript + ctx.strokeRect(30, 30, 200, 150); + ``` + + +## fillText() + +绘制填充类文本。 + +**参数:** + +| 参数 | 类型 | 描述 | +| -------- | -------- | -------- | +| text | string | 需要绘制的文本内容。 | +| x | number | 需要绘制的文本的左下角x坐标。 | +| y | number | 需要绘制的文本的左下角y坐标。 | + +**示例:** + + ![zh-cn_image_0000001431548109](figures/zh-cn_image_0000001431548109.png) + + + ```javascript + ctx.font = '35px sans-serif'; + ctx.fillText("Hello World!", 20, 60); + ``` + + +## lineWidth + +指定绘制线条的宽度值。 + +**参数:** + +| 参数 | 类型 | 描述 | +| -------- | -------- | -------- | +| lineWidth | number | 设置绘制线条的宽度。 | + +**示例:** + + ![zh-cn_image_0000001431548121](figures/zh-cn_image_0000001431548121.png) + + + ```javascript + ctx.lineWidth = 5; + ctx.strokeRect(25, 25, 85, 105); + ``` + + +## strokeStyle + +设置描边的颜色。 + +**参数:** + +| 参数 | 类型 | 描述 | +| -------- | -------- | -------- | +| color | <color> | 指定描边使用的颜色 | + +**示例:** + + ![zh-cn_image_0000001380789172](figures/zh-cn_image_0000001380789172.png) + + + ```javascript + ctx.lineWidth = 10; + ctx.strokeStyle = '#0000ff'; + ctx.strokeRect(25, 25, 155, 105); + ``` + + +### stroke()5+ + +进行边框绘制操作。 + +**示例:** + +![zh-cn_image_0000001431388513](figures/zh-cn_image_0000001431388513.png) + + ```javascript + ctx.moveTo(25, 25); + ctx.lineTo(25, 105); + ctx.strokeStyle = 'rgb(0,0,255)'; + ctx.stroke(); + ``` + + +### beginPath()5+ + +创建一个新的绘制路径。 + +**示例:** + + ![zh-cn_image_0000001431548125](figures/zh-cn_image_0000001431548125.png) + + + ```javascript + ctx.beginPath(); + ctx.lineWidth = '6'; + ctx.strokeStyle = '#0000ff'; + ctx.moveTo(15, 80); + ctx.lineTo(280, 160); + ctx.stroke(); + ``` + + +### moveTo()5+ + +路径从当前点移动到指定点。 + +**参数:** + +| 参数 | 类型 | 描述 | +| -------- | -------- | -------- | +| x | number | 指定位置的x坐标。 | +| y | number | 指定位置的y坐标。 | + +**示例:** + + ![zh-cn_image_0000001431388529](figures/zh-cn_image_0000001431388529.png) + + ```javascript + ctx.beginPath(); + ctx.moveTo(10, 10); + ctx.lineTo(280, 160); + ctx.stroke(); + ``` + + +### lineTo()5+ + +从当前点到指定点进行路径连接。 + +**参数:** + +| 参数 | 类型 | 描述 | +| -------- | -------- | -------- | +| x | number | 指定位置的x坐标。 | +| y | number | 指定位置的y坐标。 | + +**示例:** + +![zh-cn_image_0000001431148365](figures/zh-cn_image_0000001431148365.png) + + ```javascript + ctx.beginPath(); + ctx.moveTo(10, 10); + ctx.lineTo(280, 160); + ctx.stroke(); + ``` + + +### closePath()5+ + +结束当前路径形成一个封闭路径。 + +**示例:** + + ![zh-cn_image_0000001381268284](figures/zh-cn_image_0000001381268284.png) + + + ```javascript + ctx.beginPath(); + ctx.moveTo(30, 30); + ctx.lineTo(110, 30); + ctx.lineTo(70, 90); + ctx.closePath(); + ctx.stroke(); + ``` + + +## font + +设置文本绘制中的字体样式。 + +**参数:** + +| 参数 | 类型 | 描述 | +| -------- | -------- | -------- | +| value | string | 字体样式支持:sans-serif, serif, monospace,该属性默认值为30px HYQiHei-65S。 | + +**示例:** + + ![zh-cn_image_0000001381108328](figures/zh-cn_image_0000001381108328.png) + + + ```javascript + ctx.font = '30px sans-serif'; + ctx.fillText("Hello World", 20, 60); + ``` + + +## textAlign + +设置文本绘制中的文本对齐方式。 + +**参数:** + +| 参数 | 类型 | 描述 | +| -------- | -------- | -------- | +| align | string | 可选值为:
- left(默认):文本左对齐;
- right:文本右对齐;
- center:文本居中对齐; | + +**示例:** + + ![zh-cn_image_0000001431388517](figures/zh-cn_image_0000001431388517.png) + + + ```javascript + ctx.strokeStyle = '#0000ff'; + ctx.moveTo(140, 10); + ctx.lineTo(140, 160); + ctx.stroke(); + + ctx.font = '18px sans-serif'; + + // Show the different textAlign values + ctx.textAlign = 'left'; + ctx.fillText('textAlign=left', 140, 100); + ctx.textAlign = 'center'; + ctx.fillText('textAlign=center',140, 120); + ctx.textAlign = 'right'; + ctx.fillText('textAlign=right',140, 140); + ``` + + +## arc()5+ + +绘制弧线路径。 + +**参数:** + +| 参数 | 类型 | 描述 | +| -------- | -------- | -------- | +| x | number | 弧线圆心的x坐标值。 | +| y | number | 弧线圆心的y坐标值。 | +| radius | number | 弧线的圆半径。 | +| startAngle | number | 弧线的起始弧度。 | +| endAngle | number | 弧线的终止弧度。 | +| anticlockwise | boolean | 是否逆时针绘制圆弧。 | + +**示例:** + +![zh-cn_image_0000001381108320](figures/zh-cn_image_0000001381108320.png) + + ```javascript + ctx.beginPath(); + ctx.arc(100, 75, 50, 0, 6.28); + ctx.stroke(); + ``` + + +### rect()5+ + +创建矩形路径。 + +**参数:** + +| 参数 | 类型 | 描述 | +| -------- | -------- | -------- | +| x | number | 指定矩形的左上角x坐标值。 | +| y | number | 指定矩形的左上角y坐标值。 | +| width | number | 指定矩形的宽度。 | +| height | number | 指定矩形的高度。 | + +**示例:** + +![zh-cn_image_0000001381108312](figures/zh-cn_image_0000001381108312.png) + + ```javascript + ctx.rect(20, 20, 100, 100); // Create a 100*100 rectangle at (20, 20) + ctx.stroke(); // Draw it + ``` diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-common-animation.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-common-animation.md new file mode 100644 index 0000000000000000000000000000000000000000..14f9864dd0a2fd63a1ee158668d09b4191b5e626 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-common-animation.md @@ -0,0 +1,63 @@ +# 动画样式 + + +组件普遍支持的可以在style或css中设置的动态的旋转、平移、缩放效果。 + + +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| transform | string | - | 详见表1。 | +| animation-name | string | - | 指定\@keyframes,详见表2。 | +| animation-delay | <time> | 0 | 定义动画播放的延迟时间。支持的单位为[s(秒)\|ms(毫秒) ],默认单位为ms,格式为:1000ms或1s。 | +| animation-duration | <time> | 0 | 定义一个动画周期。支持的单位为[s(秒)\|ms(毫秒) ],默认单位为ms,格式为:1000ms或1s。
**说明:**
animation-duration 样式必须设置,否则时长为 0,则不会播放动画。 | +| animation-iteration-count | number  \| infinite | 1 | 定义动画播放的次数,默认播放一次,可通过设置为infinite无限次播放。 | +| animation-timing-function | string |
linear | 描述动画执行的速度曲线,用于使动画更为平滑。
可选项有:
- linear:表示动画从头到尾的速度都是相同的。
- ease-in:表示动画以低速开始,cubic-bezier(0.42, 0.0, 1.0, 1.0)。
- ease-out:表示动画以低速结束,cubic-bezier(0.0, 0.0, 0.58, 1.0)。
- ease-in-out:表示动画以低速开始和结束,cubic-bezier(0.42, 0.0, 0.58, 1.0)。 | +| animation-fill-mode | string | none | 指定动画开始和结束的状态:
- none:在动画执行之前和之后都不会应用任何样式到目标上。
- forwards:在动画结束后,目标将保留动画结束时的状态(在最后一个关键帧中定义)。 | + + + **表1** transform操作说明 + +| 名称 | 类型 | 描述 | +| -------- | -------- | -------- | +| translateX | <length> | X轴方向平移动画属性 | +| translateY | <length> | Y轴方向平移动画属性 | +| rotate | <deg> \| <rad> | 旋转动画属性 | + +> **说明:** +> 轻量级智能穿戴仅支持原始大小的图片进行旋转。 + + + **表2** \@keyframes属性说明 + +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| background-color | <color> | - | 动画执行后应用到组件上的背景颜色。 | +| width | <length> | - | 动画执行后应用到组件上的宽度值。 | +| height | <length> | - | 动画执行后应用到组件上的高度值。 | +| transform | string | - | 定义应用在组件上的变换类型,见表1。 | + + +对于不支持起始值或终止值缺省的情况,可以通过from和to显示指定起始和结束。示例: + + +``` +@keyframes Go +{ + from { + background-color: #f76160; + } + to { + background-color: #09ba07; + } +} +``` + + +![动画样式demo1](figures/动画样式demo1.gif) + + + + + +> **说明:** +> \@keyframes的from/to不支持动态绑定。 diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-common-mediaquery.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-common-mediaquery.md new file mode 100644 index 0000000000000000000000000000000000000000..4ee8dd602ae16078380f199a889ca0613b420f37 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-common-mediaquery.md @@ -0,0 +1,110 @@ +# 媒体查询 + +> **说明:** +> +> - 从API version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> - media属性值默认为设备的真实尺寸大小、物理像素和真实的屏幕分辨率。 + + +媒体查询(Media Query)应用十分广泛,开发者经常需要根据设备的大致类型或者特定的特征和设备参数(例如屏幕分辨率)来修改应用的样式。使用媒体查询针对设备和应用的属性信息,可以设计出相匹配的布局样式。 + + +## CSS语法规则 + +使用@media来引入查询语句,具体规则如下: + +``` +@media [media-type] [and|or] [(media-feature)] { + CSS-Code; +} +``` + +@media screen and (round-screen: true) { … } : 当设备屏幕是圆形时条件成立 + +@media (max-height: 454) { … } :范围查询,CSS level 3 写法 + +> **说明:** +> +> - 不支持<=,>=,<,>操作符; +> - api 9开始才支持多重 () 嵌套使用; +> - media语句整体长度不能超过 512 个字符; +> - 单个media条件长度不能超过32个字符; + + +## 媒体类型 + +| 类型 | 说明 | +| ------ | -------------- | +| screen | 按屏幕相关参数进行媒体查询。 | + + +## 媒体逻辑操作 + +媒体逻辑操作符:and、or9+用于构成媒体查询语句,详细解释说明如下表。 + +**表1** 媒体逻辑操作符 + +| 类型 | 说明 | +| --------------- | ------------------------------------------------------------ | +| and | 将多个媒体特征(Media Feature)以“与”的方式连接成一个媒体查询,只有当所有媒体特征都为true,查询条件成立。另外,它还可以将媒体类型和媒体功能结合起来。
例如:screen and (device-type: liteWearable) and (max-height: 454) 表示当设备类型是智能穿戴同时应用的最大高度小于等于454个像素单位时成立。 | +| or9+ | 将多个媒体特征以“或”的方式连接成一个媒体查询,如果存在结果为true的媒体特征,则查询条件成立。
例如:screen and (max-height: 454)  or  (round-screen:true)表示当应用高度小于等于454个像素单位或者设备屏幕是圆形时,条件成立。 | + + + + +## 媒体特征 + +| 类型 | 说明 | +| ---------------- | ------------------------------------------------------------ | +| height | 应用页面显示区域的高度。 | +| min-height | 应用页面显示区域的最小高度。 | +| max-height | 应用页面显示区域的最大高度。 | +| width | 应用页面显示区域的宽度。 | +| min-width | 应用页面显示区域的最小宽度。 | +| max-width | 应用页面显示区域的最大宽度。 | +| aspect-ratio | 应用页面显示区域的宽度与高度的比值。
例如:aspect-ratio: 1/2 | +| min-aspect-ratio | 应用页面显示区域的宽度与高度的最小比值。 | +| max-aspect-ratio | 应用页面显示区域的宽度与高度的最大比值。 | +| round-screen | 屏幕类型,圆形屏幕为 true, 非圆形屏幕为 false。 | + + +## 通用媒体特征示例代码 + +多个.container中的所写的属性个数以及类型需要相同,若不相同会导致显示异常。 + +```html + +
+
+ Hello World +
+
+``` + +```css +/* xxx.css */ +.container { + width: 300px; + height: 600px; + background-color: #008000; +} +.title { + font-size: 30px; + text-align: center; +} +@media (device-type: samrtVision) { + .container { + width: 500px; + height: 500px; + background-color: #fa8072; + } +} +@media (device-type: liteWearable) { + .container { + width: 300px; + height: 300px; + background-color: #008b8b; + } +} +``` diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-div.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-div.md new file mode 100644 index 0000000000000000000000000000000000000000..d8485dc11445111f2c7165b8c2f7088d246328a8 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-div.md @@ -0,0 +1,154 @@ +# div + +基础容器,用作页面结构的根节点或将内容进行分组。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +支持。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| flex-direction | string | row | 否 | flex容器主轴方向。可选项有:
- column:垂直方向从上到下
- row:水平方向从左到右 | +| flex-wrap | string | nowrap | 否 | flex容器是单行还是多行显示,该值暂不支持动态修改。可选项有:
- nowrap:不换行,单行显示。
- wrap:换行,多行显示。 | +| justify-content | string | flex-start | 否 | flex容器当前行的主轴对齐格式。可选项有:
- flex-start:项目位于容器的开头。
- flex-end:项目位于容器的结尾。
- center:项目位于容器的中心。
- space-between:项目位于各行之间留有空白的容器内。
- space-around:项目位于各行之前、之间、之后都留有空白的容器内。 | +| align-items | string | stretch5+
flex-start1-4 | 否 | flex容器当前行的交叉轴对齐格式,可选值为:
- stretch:弹性元素被在交叉轴方向被拉伸到与容器相同的高度或宽度。5+
- flex-start:元素向交叉轴起点对齐。
- flex-end:元素向交叉轴终点对齐。
- center:元素在交叉轴居中。 | +| display | string | flex | 否 | 确定该元素视图框的类型,该值暂不支持动态修改。可选值为:
- flex:弹性布局
- none:不渲染此元素 | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。

未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| opacity5+ | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + + +## 示例 + +1. Flex样式 + + ```html + +
+
+
+
+
+
+
+ ``` + + + ```css + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 454px; + height: 454px; + } + .flex-box { + justify-content: space-around; + align-items: center; + width: 400px; + height: 140px; + background-color: #ffffff; + } + .flex-item { + width: 120px; + height: 120px; + border-radius: 16px; + } + .color-primary { + background-color: #007dff; + } + .color-warning { + background-color: #ff7500; + } + .color-success { + background-color: #41ba41; + } + ``` + + ![zh-cn_image_0000001381108420](figures/zh-cn_image_0000001381108420.png) + +2. Flex Wrap样式 + + ```html + +
+
+
+
+
+
+
+ ``` + + + ```css + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 454px; + height: 454px; + } + .flex-box { + justify-content: space-around; + align-items: center; + flex-wrap: wrap; + width: 300px; + height: 250px; + background-color: #ffffff; + } + .flex-item { + width: 120px; + height: 120px; + border-radius: 16px; + } + .color-primary { + background-color: #007dff; + } + .color-warning { + background-color: #ff7500; + } + .color-success { + background-color: #41ba41; + } + ``` + + ![zh-cn_image_0000001431148457](figures/zh-cn_image_0000001431148457.png) diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-list-item.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-list-item.md new file mode 100644 index 0000000000000000000000000000000000000000..8db4c78b3b042eaded0f5c90d6406917b1abf255 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-list-item.md @@ -0,0 +1,53 @@ +# list-item + +<[list](js-components-container-list.md)>的子组件,用来展示列表具体item。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +支持。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。
未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。
未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| opacity5+ | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | + + + +## 示例 + +参考 [list示例](js-components-container-list.md) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-list.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-list.md new file mode 100644 index 0000000000000000000000000000000000000000..905cf802427c20a6b474de2f32adcb241b01db28 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-list.md @@ -0,0 +1,123 @@ +# list + +列表包含一系列相同宽度的列表项。适合连续、多行呈现同类数据,例如图片和文本。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +仅支持<[list-item](js-components-container-list-item.md)>。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| scrollend | - | 列表滑动已经结束。 | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | +| scrolltop8+ | - | 当前列表已滑动到顶部位置。 | +| scrollbottom8+ | - | 当前列表已滑动到底部位置。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| flex-direction | string | column | 否 | 设置flex容器主轴的方向,指定flex项如何放置在flex容器中,可选值为:
- column:主轴为纵向。
- row:主轴为横向。
其他组件默认值为row,在list组件中默认值为column。轻量级智能穿戴不支持动态修改。 | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。

未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| opacity5+ | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + + +## 方法 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| scrollTo | { index: number(指定位置) } | list滑动到指定index的item位置。 | + + +## 示例 + + +```html + +
+ + + {{$item.title}} + {{$item.date}} + + +
+``` + + +```js +// index.js +export default { + data: { + todolist: [{ + title: '刷题', + date: '2021-12-31 10:00:00', + }, { + title: '看电影', + date: '2021-12-31 20:00:00', + }], + }, +} +``` + + +```css +/* index.css */ +.container { + display: flex; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 454px; + height: 454px; +} +.todo-wraper { + width: 454px; + height: 300px; +} +.todo-item { + width: 454px; + height: 80px; + flex-direction: column; +} +.todo-title { + width: 454px; + height: 40px; + text-align: center; +} +``` + +![list](figures/list.png) diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-stack.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-stack.md new file mode 100644 index 0000000000000000000000000000000000000000..47a0a062124bc9a92c26dc325739f5cb1b0b3812 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-stack.md @@ -0,0 +1,100 @@ +# stack + +堆叠容器,子组件按照顺序依次入栈,后一个子组件覆盖前一个子组件。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +支持。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。

未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| opacity5+ | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 由于绝对定位不支持设置百分比,所以也不支持stack组件的子组件上设置margin。 + + +## 示例 + + +```html + + +
+
+
+
+``` + + +```css +/* xxx.css */ +.stack-parent { + width: 400px; + height: 400px; + background-color: #ffffff; + border-width: 1px; + border-style: solid; +} +.back-child { + width: 300px; + height: 300px; + background-color: #3f56ea; +} +.front-child { + width: 100px; + height: 100px; + background-color: #00bfc9; +} +.positioned-child { + width: 100px; + height: 100px; + left: 50px; + top: 50px; + background-color: #47cc47; +} +.bd-radius { + border-radius: 16px; +} +``` + +![zh-cn_image_0000001380789188](figures/zh-cn_image_0000001380789188.png) diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-swiper.md b/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-swiper.md new file mode 100644 index 0000000000000000000000000000000000000000..37865ab41d81a1d873ab0df01b06253f397b779b --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-components-container-swiper.md @@ -0,0 +1,112 @@ +# swiper + +滑动容器,提供切换子组件显示的能力。 + +> **说明:** +> +> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +支持除<list>之外的子组件。 + + +## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| index | number | 0 | 否 | 当前在容器中显示的子组件的索引值。 | +| loop | boolean | true | 否 | 是否开启循环轮播。
| +| duration | number | - | 否 | 子组件切换的动画时长。 | +| vertical | boolean | false | 否 | 是否为纵向滑动,纵向滑动时采用纵向的指示器。
不支持动态修改。 | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | + + +## 事件 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { index: currentIndex } | 当前显示的组件索引变化时触发该事件。 | +| click | - | 点击动作触发该事件。 | +| longpress | - | 长按动作触发该事件。 | +| swipe5+ | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 | + + +## 样式 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | 否 | 设置组件自身的宽度。

未设置时组件宽度默认为0。 | +| height | <length> \| <percentage>5+ | - | 否 | 设置组件自身的高度。

未设置时组件高度默认为0。 | +| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。
  该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 否 | 设置左、上、右、下外边距属性。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| opacity5+ | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| [left\|top] | <length> \| <percentage>6+ | - | 否 | left\|top确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | + + +## 示例 + + +```html + + +
+ 1 +
+
+ 2 +
+
+ 3 +
+
+``` + + +```css +/* xxx.css */ +.container { + left: 0px; + top: 0px; + width: 454px; + height: 454px; +} +.swiper-item { + width: 454px; + height: 454px; + justify-content: center; + align-items: center; +} +.primary-item { + background-color: #007dff; +} +.warning-item { + background-color: #ff7500; +} +.success-item { + background-color: #41ba41; +} +``` + + +```js +/* xxx.js */ +export default { + data: { + index: 1 + } +} +``` + +![swiper](figures/swiper.gif) diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-framework-file.md b/zh-cn/application-dev/reference/arkui-js-lite/js-framework-file.md new file mode 100644 index 0000000000000000000000000000000000000000..f79c583bd930c9ba0439b80bef36aadf96d60fc2 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-framework-file.md @@ -0,0 +1,67 @@ +# 文件组织 + + +## 目录结构 + +JS FA应用的JS模块(entry/src/main/js/module)的典型开发目录结构如下: + + **图2** 目录结构   + +![zh-cn_image_0000001431388581](figures/zh-cn_image_0000001431388581.png) + +目录结构中文件分类如下: + +- .hml结尾的HML模板文件,这个文件用来描述当前页面的文件布局结构。 + +- .css结尾的CSS样式文件,这个文件用于描述页面样式。 + +- .js结尾的JS文件,这个文件用于处理页面和用户的交互。 + +各个文件夹的作用: + +- app.js文件用于全局JavaScript逻辑和应用生命周期管理。 + +- pages目录用于存放所有组件页面。 + +- common目录用于存放公共资源文件,比如:媒体资源和JS文件。 + +> **说明:** +> - 如下文件夹是开发保留文件夹,不可重命名: +> +> +> +> +> - 在使用DevEco Studio进行应用开发时,目录结构中的可选文件夹需要开发者根据实际情况自行创建。 + + +## 文件访问规则 + +应用资源可通过绝对路径或相对路径的方式进行访问,本开发框架中绝对路径以"/"开头,相对路径以"./"或"../"。具体访问规则如下: + +- 引用代码文件,需使用相对路径,比如:../common/utils.js。 + +- 引用资源文件,推荐使用绝对路径。比如:/common/xxx.png。 + +- 公共代码文件和资源文件推荐放在common下,通过以上两条规则进行访问。 + +- CSS样式文件中通过url()函数创建<url>数据类型,如:url(/common/xxx.png)。 + +> **说明:** +> 当代码文件A需要引用代码文件B时: +> +> - 如果代码文件A和文件B位于同一目录,则代码文件B引用资源文件时可使用相对路径,也可使用绝对路径。 +> +> - 如果代码文件A和文件B位于不同目录,则代码文件B引用资源文件时必须使用绝对路径。因为Webpack打包时,代码文件B的目录会发生变化。 +> +> + + +## 媒体文件格式 + + **表1** 支持的图片格式 + +| 格式 | 支持版本 | 支持的文件类型 | +| -------- | -------- | -------- | +| BMP | API Version 3+ | .bmp | +| JPEG | API Version 3+ | .jpg | +| PNG | API Version 3+ | .png | diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-framework-js-file.md b/zh-cn/application-dev/reference/arkui-js-lite/js-framework-js-file.md new file mode 100644 index 0000000000000000000000000000000000000000..15bd4ab324917fb730f0fb11876d0d0a6b3c4947 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-framework-js-file.md @@ -0,0 +1,26 @@ +# app.js + + +每个应用可以在app.js自定义应用级生命周期的实现逻辑,包括: + + +- onCreate:在应用生成时被调用的生命周期函数。 + +- onDestory:在应用销毁时被调用的生命周期函数。 + + +以下示例仅在生命周期函数中打印对应日志: + + + +``` +// app.js +export default { + onCreate() { + console.info('Application onCreate'); + }, + onDestroy() { + console.info('Application onDestroy'); + }, +} +``` diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-framework-js-tag.md b/zh-cn/application-dev/reference/arkui-js-lite/js-framework-js-tag.md new file mode 100644 index 0000000000000000000000000000000000000000..5866a02f7f613be4064058dbb94b82beb06fcd4a --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-framework-js-tag.md @@ -0,0 +1,73 @@ +# js标签配置 + + +js标签中包含了实例名称、页面路由信息。 + + +| 标签 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| name | string | default | 是 | 标识JS实例的名字。 | +| pages | Array | - | 是 | 路由信息,详见“**[pages](#pages)**”。 | + + +> **说明:** +> name、pages标签配置需在配置文件中的“js”标签中完成设置。 + + +## pages + +定义每个页面的路由信息,每个页面由页面路径和页面名组成,页面的文件名就是页面名。比如: + + +``` +{ + ... + "pages": [ + "pages/index/index", + "pages/detail/detail" + ] + ... +} +``` + + +> **说明:** +> +> +> - 应用首页固定为"pages/index/index"。 +> +> - 页面文件名不能使用组件名称,比如:text.hml、button.hml等。 + + +## 示例 + + +``` +{ + "app": { + "bundleName": "com.huawei.player", + "version": { + "code": 1, + "name": "1.0" + }, + "vendor": "example" + } + "module": { + ... + "js": [ + { + "name": "default", + "pages": [ + "pages/index/index", + "pages/detail/detail" + ] + } + ], + "abilities": [ + { + ... + } + ] + } +} +``` diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-framework-syntax-css.md b/zh-cn/application-dev/reference/arkui-js-lite/js-framework-syntax-css.md new file mode 100644 index 0000000000000000000000000000000000000000..b61f1a17c557b0871ce8caeb2cc85245edbb83af --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-framework-syntax-css.md @@ -0,0 +1,161 @@ +# CSS语法参考 + + +CSS是描述HML页面结构的样式语言。所有组件均存在系统默认样式,也可在页面CSS样式文件中对组件、页面自定义不同的样式。 + + +## 样式导入 + +为了模块化管理和代码复用,CSS样式文件支持 \@import 语句,导入 CSS 文件。 + + +## 声明样式 + +每个页面目录下存在一个与布局hml文件同名的css文件,用来描述该hml页面中组件的样式,决定组件应该如何显示。 + +1. 内部样式,支持使用style、class属性来控制组件的样式。例如: + + ``` + +
+ Hello World +
+ ``` + + + ``` + /* index.css */ + .container { + justify-content: center; + } + ``` + +2. 文件导入,合并外部样式文件。例如,在common目录中定义样式文件style.css,并在index.css文件首行中进行导入: + + ``` + /* style.css */ + .title { + font-size: 50px; + } + ``` + + + ``` + /* index.css */ + @import '../../common/style.css'; + .container { + justify-content: center; + } + ``` + + +## 选择器 + +css选择器用于选择需要添加样式的元素,支持的选择器如下表所示: + +| 选择器 | 样例 | 样例描述 | +| -------- | -------- | -------- | +| .class | .container | 用于选择class="container"的组件。 | +| \#id | \#titleId | 用于选择id="titleId"的组件。 | +| , | .title, .content | 用于选择class="title"和class="content"的组件。 | + +示例: + + +``` + +
+ 标题 +
+ 内容 +
+
+``` + + +``` +/* 页面样式xxx.css */ +/* 对class="title"的组件设置样式 */ +.title { + font-size: 30px; +} +/* 对id="contentId"的组件设置样式 */ +#contentId { + font-size: 20px; +} +/* 对所有class="title"以及class="content"的组件都设置padding为5px */ +.title, .content { + padding: 5px; +} + +``` + + +## 伪类 + +css伪类是选择器中的关键字,用于指定要选择元素的特殊状态。 + + + +| 名称 | 支持组件 | 描述 | +| -------- | -------- | -------- | +| :active |
input[type="button"] | 表示被用户激活的元素,如:被用户按下的按钮。轻量级智能穿戴上伪类选择器上仅支持background-color 和background-image 的样式设置。 | +| :checked | input[type="checkbox"、type="radio"] | 表示checked属性为true的元素。轻量级智能穿戴上伪类选择器上仅支持background-color 和background-image 的样式设置。 | + +伪类示例如下,设置按钮的:active伪类可以控制被用户按下时的样式: + + +``` + +
+ +
+``` + + +``` +/* index.css */ +.button:active { + background-color: #888888;/*按钮被激活时,背景颜色变为#888888 */ +} +``` + + +## 样式预编译 + +预编译提供了利用特有语法生成css的程序,可以提供变量、运算等功能,令开发者更便捷地定义组件样式,目前支持less、sass和scss的预编译。使用样式预编译时,需要将原css文件后缀改为less、sass或scss,如index.css改为index.less、index.sass或index.scss。 + +- 当前文件使用样式预编译,例如将原index.css改为index.less: + + ``` + /* index.less */ + /* 定义变量 */ + @colorBackground: #000000; + .container { + background-color: @colorBackground; /* 使用当前less文件中定义的变量 */ + } + ``` + +- 引用预编译文件,例如common中存在style.scss文件,将原index.css改为index.scss,并引入style.scss: + + ``` + /* style.scss */ + /* 定义变量 */ + $colorBackground: #000000; + ``` + + 在index.scss中引用: + + + ``` + /* index.scss */ + /* 引入外部scss文件 */ + @import '../../common/style.scss'; + .container { + background-color: $colorBackground; /* 使用style.scss中定义的变量 */ + } + ``` + + + > **说明:** + > 引用的预编译文件建议放在common目录进行管理。 diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-framework-syntax-hml.md b/zh-cn/application-dev/reference/arkui-js-lite/js-framework-syntax-hml.md new file mode 100644 index 0000000000000000000000000000000000000000..73ebc3421624f68c271b1bc3718136fc1a4b0556 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-framework-syntax-hml.md @@ -0,0 +1,308 @@ +# HML语法参考 + + +HML(OpenHarmony Markup Language)是一套类HTML的标记语言,通过组件,事件构建出页面的内容。页面具备数据绑定、事件绑定、列表渲染、条件渲染等高级能力。 + + +## 页面结构 + + +``` + +
+ Image Show +
+ +
+
+``` + + +## 数据绑定 + + +``` + +
+ {{content[1]}} +
+``` + + +``` +// xxx.js +export default { + data: { + content: ['Hello World!', 'Welcome to my world!'] + }, + changeText: function() { + this.content.splice(1, 1, this.content[0]); + } +} +``` + +> **说明:** +> - 针对数组内的数据修改,请使用splice方法生效数据绑定变更。 +> +> - hml中的js表达式不支持ES6语法。 + + +## 事件绑定 + +事件绑定的回调函数接收一个事件对象参数,可以通过访问该事件对象获取事件信息。 + + +``` + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+``` + + +``` +// xxx.js +export default { + data: { + obj: '', + }, + clickfunc: function(e) { + this.obj = 'Hello World'; + console.log(e); + }, +} +``` + +> **说明:** +> +> 事件冒泡机制从API Version 5开始支持。升级SDK后,运行存量JS应用,采用旧写法(onclick)的事件绑定还是按事件不冒泡进行处理。但如果使用新版本SDK重新打包JS应用,将旧写法按事件冒泡进行处理。为了避免业务逻辑错误,建议将旧写法(如onclick)改成新写法(grab:click)。 + +**示例:** + +``` + +
+ {{count}} +
+ + + + + + +
+
+``` + + +``` +/* xxx.js */ +export default { + data: { + count: 0 + }, + increase() { + this.count++; + }, + decrease() { + this.count--; + }, + multiply(multiplier) { + this.count = multiplier * this.count; + } +}; +``` + + +``` +/* xxx.css */ +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 454px; + height: 454px; +} +.title { + font-size: 30px; + text-align: center; + width: 200px; + height: 100px; +} +.box { + width: 454px; + height: 200px; + justify-content: center; + align-items: center; + flex-wrap: wrap; +} +.btn { + width: 200px; + border-radius: 0; + margin-top: 10px; + margin-left: 10px; +} +``` + + +## 列表渲染 + + +``` + +
+ + +
+ {{$idx}}.{{$item.name}} +
+ +
+ {{$idx}}.{{value.name}} +
+ +
+ {{index}}.{{value.name}} +
+
+``` + + +``` +// xxx.js +export default { + data: { + array: [ + {id: 1, name: 'jack', age: 18}, + {id: 2, name: 'tony', age: 18}, + ], + }, + changeText: function() { + if (this.array[1].name === "tony"){ + this.array.splice(1, 1, {id:2, name: 'Isabella', age: 18}); + } else { + this.array.splice(2, 1, {id:3, name: 'Bary', age: 18}); + } + }, +} +``` + +tid属性主要用来加速for循环的重渲染,旨在列表中的数据有变更时,提高重新渲染的效率。tid属性是用来指定数组中每个元素的唯一标识,如果未指定,数组中每个元素的索引为该元素的唯一id。例如上述tid="id"表示数组中的每个元素的id属性为该元素的唯一标识。for循环支持的写法如下: + +- for="array":其中array为数组对象,array的元素变量默认为$item。 + +- for="v in array":其中v为自定义的元素变量,元素索引默认为$idx。 + +- for="(i, v) in array":其中元素索引为i,元素变量为v,遍历数组对象array。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 数组中的每个元素必须存在tid指定的数据属性,否则运行时可能会导致异常。 +> +> - 数组中被tid指定的属性要保证唯一性,如果不是则会造成性能损耗。比如,示例中只有id和name可以作为tid字段,因为它们属于唯一字段。 +> +> - tid不支持表达式。 + + +## 条件渲染 + +条件渲染分为2种:if/elif/else和show。两种写法的区别在于:第一种写法里if为false时,组件不会在vdom中构建,也不会渲染,而第二种写法里show为false时虽然也不渲染,但会在vdom中构建;另外,当使用if/elif/else写法时,节点必须是兄弟节点,否则编译无法通过。实例如下: + + +``` + +
+ + + Hello-One + Hello-Two + Hello-World +
+``` + + +``` +// xxx.css +.container{ + flex-direction: column; + align-items: center; +} +.btn{ + width: 280px; + font-size: 26px; + margin: 10px 0; +} +``` + + +``` +// xxx.js +export default { + data: { + show: false, + display: true, + }, + toggleShow: function() { + this.show = !this.show; + }, + toggleDisplay: function() { + this.display = !this.display; + } +} +``` + +优化渲染优化:show方法。当show为真时,节点正常渲染;当为假时,仅仅设置display样式为none。 + + +``` + +
+ + Hello World +
+``` + + +``` +// xxx.css +.container{ + flex-direction: column; + align-items: center; +} +.btn{ + width: 280px; + font-size: 26px; + margin: 10px 0; +} +``` + + +``` +// xxx.js +export default { + data: { + visible: false, + }, + toggle: function() { + this.visible = !this.visible; + }, +} +``` + +> **说明:** +> 禁止在同一个元素上同时设置for和if属性。 diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-framework-syntax-js.md b/zh-cn/application-dev/reference/arkui-js-lite/js-framework-syntax-js.md new file mode 100644 index 0000000000000000000000000000000000000000..1a9c10683d0a75f0aab1997e49ada59b84a664c4 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-framework-syntax-js.md @@ -0,0 +1,122 @@ +# JS语法参考 + + +JS文件用来定义HML页面的业务逻辑,支持ECMA规范的JavaScript语言。基于JavaScript语言的动态化能力,可以使应用更加富有表现力,具备更加灵活的设计。下面讲述JS文件的编译和运行的支持情况。 + + +## 语法 + +支持ES6语法。轻量级智能穿戴支持的ES6语法有限,仅支持以下ES6 语法: + +1. let/const + +2. arrow functions + +3. class + +4. default value + +5. destructuring assignment + +6. destructuring binding pattern + +7. enhanced object initializer + +8. for-of + +9. rest parameter + +10. template strings + +- 模块声明 + 使用import方法引入功能模块: + + + ``` + import router from '@system.router'; + ``` + +- 代码引用 + 使用import方法导入js代码: + + + ``` + import utils from '../../common/utils.js'; + ``` + + +## 对象 + +- 页面对象 + | 属性 | 类型 | 描述 | + | -------- | -------- | -------- | + | data | Object/Function | 页面的数据模型,类型是对象或者函数,如果类型是函数,返回值必须是对象。属性名不能以$或_开头,不要使用保留字for, if, show, tid。
| + | $refs | Object | 持有注册过ref 属性的DOM元素或子组件实例的对象。示例见[获取DOM元素](#获取dom元素)。 | + + +## 获取DOM元素 + +1. 通过$refs获取DOM元素 + + ``` + +
+ +
+ ``` + + + ``` + // index.js + export default { + data: { + images: [ + { src: '/common/frame1.png' }, + { src: '/common/frame2.png' }, + { src: '/common/frame3.png' }, + ], + }, + handleClick() { + const animator = this.$refs.animator; // 获取ref属性为animator的DOM元素 + const state = animator.getState(); + if (state === 'paused') { + animator.resume(); + } else if (state === 'stopped') { + animator.start(); + } else { + animator.pause(); + } + }, + }; + ``` + + +## 生命周期接口 + +- 页面生命周期 + | 属性 | 类型 | 参数 | 返回值 | 描述 | 触发时机 | + | -------- | -------- | -------- | -------- | -------- | -------- | + | onInit | Function | 无 | 无 | 页面初始化 | 页面数据初始化完成时触发,只触发一次。 | + | onReady | Function | 无 | 无 | 页面创建完成 | 页面创建完成时触发,只触发一次。 | + | onShow | Function | 无 | 无 | 页面显示 | 页面显示时触发。 | + | onHide | Function | 无 | 无 | 页面消失 | 页面消失时触发。 | + | onDestroy | Function | 无 | 无 | 页面销毁 | 页面销毁时触发。 | + + 页面A的生命周期接口的调用顺序: + - 打开页面A:onInit() -> onReady() -> onShow() + + - 在页面A打开页面B:onHide() -> onDestroy() + + - 从页面B返回页面A:onInit() -> onReady() -> onShow() + + - 退出页面A:onHide() -> onDestroy() + + - 页面隐藏到后台运行:onHide() + + - 页面从后台运行恢复到前台:onShow() + +- 应用生命周期 + | 属性 | 类型 | 参数 | 返回值 | 描述 | 触发时机 | + | -------- | -------- | -------- | -------- | -------- | -------- | + | onCreate | Function | 无 | 无 | 应用创建 | 当应用创建时调用。 | + | onDestroy | Function | 无 | 无 | 应用退出 | 当应用退出时触发。 | diff --git a/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-caution.gif b/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-caution.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-caution.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-danger.gif b/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-danger.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-danger.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-note.gif b/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-note.gif new file mode 100644 index 0000000000000000000000000000000000000000..6314297e45c1de184204098efd4814d6dc8b1cda Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-note.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-notice.gif b/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-notice.gif new file mode 100644 index 0000000000000000000000000000000000000000..86024f61b691400bea99e5b1f506d9d9aef36e27 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-notice.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-tip.gif b/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-tip.gif new file mode 100644 index 0000000000000000000000000000000000000000..93aa72053b510e456b149f36a0972703ea9999b7 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-tip.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-warning.gif b/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-warning.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js-lite/public_sys-resources/icon-warning.gif differ 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 a0f754de20cb86ba2ba7bd370e52c5162e7d8417..b4f136fbe25313fbb7925f96d35bed69c8511219 100644 --- a/zh-cn/application-dev/reference/arkui-js/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-js/Readme-CN.md @@ -1,4 +1,4 @@ -# 兼容JS的类Web开发范式 +# 兼容JS的类Web开发范式(ArkUI.Full) - 组件通用信息 - [通用属性](js-components-common-attributes.md) 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 8b4292e8592f2ba22382ebf488ec8dd9e1c263e9..536201bfe0805ff55544d1c84de0fe137e7fcff7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -28,7 +28,6 @@ - [图形变换](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) @@ -43,6 +42,7 @@ - [背景模糊设置](ts-universal-attributes-backgroundBlurStyle.md) - [分布式迁移标识](ts-universal-attributes-restoreId.md) - [前景色设置](ts-universal-attributes-foreground-color.md) + - [文本通用属性](ts-universal-attributes-text-style.md) - 手势处理 - [绑定手势方法](ts-gesture-settings.md) - 基础手势 @@ -54,6 +54,7 @@ - [SwipeGesture](ts-basic-gestures-swipegesture.md) - [组合手势](ts-combined-gestures.md) - 基础组件 + - [AlphabetIndexer](ts-container-alphabet-indexer.md) - [Blank](ts-basic-components-blank.md) - [Button](ts-basic-components-button.md) - [Checkbox](ts-basic-components-checkbox.md) @@ -100,7 +101,6 @@ - [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) diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/ListDivider.png b/zh-cn/application-dev/reference/arkui-ts/figures/ListDivider.png new file mode 100644 index 0000000000000000000000000000000000000000..1842303447e7fbd1c9a59cd14dccd7a23eb42636 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/ListDivider.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/align.png b/zh-cn/application-dev/reference/arkui-ts/figures/align.png index ffabc26d3ee59984dda6cb375f8b18bb319b4fc7..5cdeb7cfd622b90a6fe52ef8cc94f187847d05b7 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/align.png and b/zh-cn/application-dev/reference/arkui-ts/figures/align.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/animation.PNG b/zh-cn/application-dev/reference/arkui-ts/figures/animation.PNG deleted file mode 100644 index 92f92e0001a90840d03ebd00e0b0ef736c2a94c8..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/animation.PNG and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/animation.gif b/zh-cn/application-dev/reference/arkui-ts/figures/animation.gif index 6cfbc07fc5122be3ecd69e6b33b6f00c0f676a0f..e1f1e9d8eedba5f4d7e9895fe10c1028cb8e19bd 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/animation.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/animation.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/animation1.PNG b/zh-cn/application-dev/reference/arkui-ts/figures/animation1.PNG deleted file mode 100644 index 98cc1fa8c0537071549fa8185fa14f7ad103e7f8..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/animation1.PNG and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/animation1.gif b/zh-cn/application-dev/reference/arkui-ts/figures/animation1.gif new file mode 100644 index 0000000000000000000000000000000000000000..d4fae00973755cc243e1d48f10acf9ef4b24682e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/animation1.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/coordinates.png b/zh-cn/application-dev/reference/arkui-ts/figures/coordinates.png new file mode 100644 index 0000000000000000000000000000000000000000..a975e862118c6048cec5981049a5df160444540b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/coordinates.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/progressMask.PNG b/zh-cn/application-dev/reference/arkui-ts/figures/progressMask.PNG new file mode 100755 index 0000000000000000000000000000000000000000..fac3dda28c11979572ff69ed3005be5d40e62b3b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/progressMask.PNG differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174104400.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174104400.gif index ec293bafaf6cd7204ebb231c4eee7daa504b78c3..da442c6a4f02d281bafff3f9fde8a51c6ebbf932 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174104400.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174104400.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-animatorproperty.md b/zh-cn/application-dev/reference/arkui-ts/ts-animatorproperty.md index 546783781c7be91d1eccd6d11de8fd9a954f3db7..4a3f72bfb5d05206e9370adc6c1449de15c24bbe 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-animatorproperty.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-animatorproperty.md @@ -14,13 +14,13 @@ animation(value: {duration?: number, tempo?: number, curve?: string | Curve | IC | 名称 | 参数类型 | 必填 | 描述 | | ---------- | ------------------------------------------| ---- | ------------------------------------------------------------ | -| duration | number | 否 | 设置动画时长。单位为毫秒,默认动画时长为1000毫秒。
默认值:1000
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
- 在ArkTS卡片上最大动画持续时间为1000毫秒,若超出则固定为1000毫秒。 | -| tempo | number | 否 | 动画播放速度。数值越大,动画播放速度越快,数值越小,播放速度越慢
值为0时,表示不存在动画。
默认值:1 | +| duration | number | 否 | 设置动画时长。
默认值:1000
单位:毫秒
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
- 在ArkTS卡片上最大动画持续时间为1000毫秒。
- 设置小于1的值时按0处理。
- 设置浮点型类型的值时,向下取整;设置值为1.2,按照1处理。 | +| tempo | number | 否 | 动画播放速度。数值越大,动画播放速度越快,数值越小,播放速度越慢。
值为0时,表示不存在动画。
默认值:1
**说明:**
当设置小于1的值时按值为1处理。 | | curve | string \| [Curve](ts-appendix-enums.md#curve) \| ICurve9+ | 否 | 设置动画曲线。默认曲线为线性。
默认值:Curve.Linear
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| delay | number | 否 | 设置动画延迟执行的时长。单位为毫秒,默认不延时播放。
默认值:0 | -| iterations | number | 否 | 设置播放次数。默认播放一次,设置为-1时表示无限次播放。
默认值:1 | +| delay | number | 否 | 设置动画延迟执行的时长。单位为毫秒,默认不延时播放。
默认值:0
取值范围:[0, +∞)
**说明:**
当设置的值小于1时按0处理。设置浮点型类型的值时,向下取整。例如,设置值为1.2,按照1处理。 | +| iterations | number | 否 | 设置播放次数。
默认值:1
取值范围:[-1, +∞)
**说明:**
设置为-1时表示无限次播放。设置为0时表示无动画效果。 | | playMode | [PlayMode](ts-appendix-enums.md#playmode) | 否 | 设置动画播放模式,默认播放完成后重头开始播放。
默认值:PlayMode.Normal
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| onFinish | () => void | 否 | 状态回调,动画播放完成时触发。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| onFinish | () => void | 否 | 状态回调,动画播放完成时触发。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
当iterations设置为-1时,动画效果无限循环不会停止,所以不会触发此回调。 | ## 示例 @@ -37,11 +37,11 @@ struct AttrAnimationExample { build() { Column() { - Button('change width and height') + Button('change size') .onClick(() => { if (this.flag) { - this.widthSize = 100 - this.heightSize = 50 + this.widthSize = 150 + this.heightSize = 60 } else { this.widthSize = 250 this.heightSize = 100 @@ -67,8 +67,8 @@ struct AttrAnimationExample { duration: 1200, curve: Curve.Friction, delay: 500, - iterations: -1, // 设置-1表示动画无限循环 - playMode: PlayMode.AlternateReverse + iterations: -1, // 设置-1表示动画无限循环 + playMode: PlayMode.Alternate }) }.width('100%').margin({ top: 20 }) } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-appendix-enums.md b/zh-cn/application-dev/reference/arkui-ts/ts-appendix-enums.md index 2526c1c5a986456530cf9c9f7da8af37756bfdce..ffb0167d050e18a7deefb55d0a14f91f5945ddfa 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-appendix-enums.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-appendix-enums.md @@ -237,8 +237,8 @@ | 名称 | 描述 | | ------ | -------------------------------------------------- | | All | 指定当前的Transition动效生效在组件的所有变化场景。 | -| Insert | 指定当前的Transition动效生效在组件的插入场景。 | -| Delete | 指定当前的Transition动效生效在组件的删除场景。 | +| Insert | 指定当前的Transition动效生效在组件的插入显示场景。 | +| Delete | 指定当前的Transition动效生效在组件的删除隐藏场景。 | ## RelateType @@ -311,7 +311,7 @@ | Start | 元素在Flex容器中,交叉轴方向首部对齐。 | | Center | 元素在Flex容器中,交叉轴方向居中对齐。 | | End | 元素在Flex容器中,交叉轴方向底部对齐。 | -| Stretch | 元素在Flex容器中,交叉轴方向拉伸填充,在未设置尺寸时,拉伸到容器尺寸。 | +| Stretch | 元素在Flex容器中,交叉轴方向拉伸填充。容器为Flex且设置Wrap为FlexWrap.Wrap或FlexWrap.WrapReverse时,元素拉伸到与当前行/列交叉轴长度最长的元素尺寸。其余情况在元素未设置尺寸时,拉伸到容器尺寸。 | | Baseline | 元素在Flex容器中,交叉轴方向文本基线对齐。 | ## FlexDirection @@ -417,21 +417,23 @@ 从API version 9开始,该接口支持在ArkTS卡片中使用。 -| 名称 | 描述 | -| ------ | -------------- | -| Start | 水平对齐首部。 | -| Center | 水平居中对齐。 | -| End | 水平对齐尾部。 | +| 名称 | 描述 | +| --------------------- | -------------- | +| Start | 水平对齐首部。 | +| Center | 水平居中对齐。 | +| End | 水平对齐尾部。 | +| Justify10+ | 双端对齐。 | ## TextOverflow 从API version 9开始,该接口支持在ArkTS卡片中使用。 -| 名称 | 描述 | -| -------- | -------------------------------------- | -| Clip | 文本超长时进行裁剪显示。 | -| Ellipsis | 文本超长时显示不下的文本用省略号代替。 | -| None | 文本超长时不进行裁剪。 | +| 名称 | 描述 | +| --------------------- | -------------------------------------- | +| None | 文本超长时不进行裁剪。 | +| Clip | 文本超长时进行裁剪显示。 | +| Ellipsis | 文本超长时显示不下的文本用省略号代替。 | +| Marquee10+ | 文本超长时以跑马灯的方式展示。 | ## TextDecorationType @@ -518,27 +520,35 @@ 该接口支持在ArkTS卡片中使用。 - | 名称 | 描述 | - | ------- | ---------- | - | Thin | 轻薄材质模糊。 | - | Regular | 普通厚度材质模糊。 | - | Thick | 厚材质模糊。 | - | BackgroundThin | 近距景深模糊。 | - | BackgroundRegular | 中距景深模糊。 | - | BackgroundThick | 远距景深模糊。 | - | BackgroundUltraThick | 超远距景深模糊。 | - +| 名称 | 描述 | +| ------- | ---------- | +| Thin | 轻薄材质模糊。 | +| Regular | 普通厚度材质模糊。 | +| Thick | 厚材质模糊。 | +| BackgroundThin | 近距景深模糊。 | +| BackgroundRegular | 中距景深模糊。 | +| BackgroundThick | 远距景深模糊。 | +| BackgroundUltraThick | 超远距景深模糊。 | + ## ThemeColorMode10+ - | 名称 | 描述 | - | ------- | ---------- | - | System | 跟随系统深浅色模式。 | - | Light | 固定使用浅色模式。 | - | Dark | 固定使用深色模式。 | +| 名称 | 描述 | +| ------- | ---------- | +| System | 跟随系统深浅色模式。 | +| Light | 固定使用浅色模式。 | +| Dark | 固定使用深色模式。 | ## AdaptiveColor10+ - | 名称 | 描述 | - | ------- | ----------- | - | Default | 不使用取色模糊。使用默认的颜色作为蒙版颜色。 | - | Average | 使用取色模糊。将取色区域的颜色平均值作为蒙版颜色。 | +| 名称 | 描述 | +| ------- | ----------- | +| Default | 不使用取色模糊。使用默认的颜色作为蒙版颜色。 | +| Average | 使用取色模糊。将取色区域的颜色平均值作为蒙版颜色。 | + +## TextHeightAdaptivePolicy10+ + +| 名称 | 描述 | +| ----------------------- | ------------------------------------------------ | +| MAX_LINES_FIRST | 设置文本高度自适应方式为以MaxLines优先。 | +| MIN_FONT_SIZE_FIRST | 设置文本高度自适应方式为以缩小字体优先。 | +| LAYOUT_CONSTRAINT_FIRST | 设置文本高度自适应方式为以布局约束(高度)优先。 | 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 2483a6f2d4a4c18ecdd17d5b15e4f4faa37557dd..ca748359ecfedfdccc02d7de409cd925cd765282 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 @@ -23,8 +23,7 @@ | 参数名 | 参数类型 | 必填 | 参数描述 | | ----------- | ---------- | ------| --------------------------------- | | type | ButtonType | 否 | 描述按钮显示样式。
默认值:ButtonType.Capsule | -| stateEffect | boolean | 否 | 按钮按下时是否开启按压态显示效果,当设置为false时,按压效果关闭。
默认值:true | - +| stateEffect | boolean | 否 | 按钮按下时是否开启按压态显示效果,当设置为false时,按压效果关闭。
默认值:true
**说明:**
当开启按压态显示效果,开发者设置状态样式时,会基于状态样式设置完成后的背景色再进行颜色叠加。 | **方法2:** Button(label?: ResourceStr, options?: { type?: ButtonType, stateEffect?: boolean }) @@ -36,16 +35,18 @@ | 参数名 | 参数类型 | 必填 | 参数描述 | | ------- | ----------------------------------- | ---- | ------------- | -| label | [ResourceStr](ts-types.md#resourcestr) | 否 | 按钮文本内容。 | +| label | [ResourceStr](ts-types.md#resourcestr) | 否 | 按钮文本内容。 | | options | { type?: ButtonType, stateEffect?: boolean } | 否 | 见方法1参数说明。 | - ## 属性 +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + | 名称 | 参数类型 | 描述 | | ----------- | ----------- | --------------------------------- | | type | ButtonType | 设置Button样式。
默认值:ButtonType.Capsule
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | stateEffect | boolean | 按钮按下时是否开启按压态显示效果,当设置为false时,按压效果关闭。
默认值:true
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| labelStyle10+ | [LabelStyle](#labelstyle10对象说明) | 设置Button组件label文本和字体的样式。 | ## ButtonType枚举说明 @@ -58,12 +59,25 @@ | Normal | 普通按钮(默认不带圆角)。 | > **说明:** -> - 按钮圆角通过[通用属性borderRadius](ts-universal-attributes-border.md)设置(不支持通过border接口设置圆角),且只支持设置一个相同的圆角。 -> - 当按钮类型为Capsule时,borderRadius设置不生效,按钮圆角始终为高度的一半。 +> - 按钮圆角通过[通用属性borderRadius](ts-universal-attributes-border.md)设置(不支持通过border接口设置圆角),且只支持设置参数为[Length](ts-types.md#length)的圆角。 +> - 当按钮类型为Capsule时,borderRadius设置不生效,按钮圆角始终为宽、高中较小值的一半。 > - 当按钮类型为Circle时,borderRadius即为按钮半径,若未设置borderRadius按钮半径则为宽、高中较小值的一半。 > - 按钮文本通过[通用文本样式](ts-universal-attributes-text-style.md)进行设置。 +> - 设置[颜色渐变](ts-universal-attributes-gradient-color.md)需先设置[backgroundColor](ts-universal-attributes-background.md)为透明色。 + +## LabelStyle10+对象说明 +| 名称 | 参数类型 | 必填 | 描述 | +| -------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| overflow | [TextOverflow](ts-appendix-enums.md#textoverflow) | 否 | 设置Label文本超长时的显示方式。文本截断是按字截断。例如,英文以单词为最小单位进行截断,若需要以字母为单位进行截断,可在字母间添加零宽空格。 | +| maxLines | number | 否 | 设置Label文本的最大行数。默认情况下,文本是自动折行的,如果指定此参数,则文本最多不会超过指定的行。如果有多余的文本,可以通过textOverflow来指定截断方式。 | +| minFontSize | number \| [ResourceStr](ts-types.md#resourcestr) | 否 | 设置Label文本最小显示字号。需配合maxFontSize以及maxLines或布局大小限制使用。 | +| maxFontSize | number \| [ResourceStr](ts-types.md#resourcestr) | 否 | 设置Label文本最大显示字号。需配合minFontSize以及maxLines或布局大小限制使用。 | +| heightAdaptivePolicy | [TextHeightAdaptivePolicy](ts-appendix-enums.md#TextHeightAdaptivePolicy10) | 否 | 设置Label文本自适应高度的方式。 | +| font | [Font](ts-types.md#Font) | 否 | 设置Label文本字体样式。 | +## 事件 +支持[通用事件](ts-universal-events-click.md)。 ## 示例 ```ts diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md index ab5f04d2981a6a063355d022a66eacd492011199..1a516dd67748cfb992494ff59ce149b982bc3828 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md @@ -21,7 +21,7 @@ Checkbox(options?: {name?: string, group?: string }) | 参数名 | 参数类型 | 必填 | 参数描述 | | --------| --------| ------ | -------- | | name | string | 否 | 多选框名称。 | -| group | string | 否 | 多选框的群组名称。 | +| group | string | 否 | 多选框的群组名称。
**说明:**
未配合使用CheckboxGroup组件时,此值无用。 | ## 属性 @@ -32,6 +32,8 @@ Checkbox(options?: {name?: string, group?: string }) | ------------- | ------- | -------- | | select | boolean | 设置多选框是否选中。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | selectedColor | [ResourceColor](ts-types.md#resourcecolor) | 设置多选框选中状态颜色。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| unselectedColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 设置多选框非选中状态边框颜色。 | +| mark10+ | [MarkStyle](#markstyle10对象说明) | 多选框内部图标样式。 | ## 事件 @@ -41,6 +43,14 @@ Checkbox(options?: {name?: string, group?: string }) | -------------------------------------------- | ------------------------------------------------------------ | | onChange(callback: (value: boolean) => void) | 当选中状态发生变化时,触发该回调。(只有手动触发且Checkbox状态改变时才会触发onChange回调)
- value为true时,表示已选中。
- value为false时,表示未选中。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +## MarkStyle10+对象说明 + +| 名称 | 类型 | 必填 | 默认值 | 描述 | +| ----------- | ------------------------------------------ | ---- | ----------- | ------------------------------------------------------------ | +| strokeColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | Color.White | 内部图标颜色。 | +| size | number \| string | 否 | - | 内部图标大小,单位vp。默认大小与多选框组件宽度设置值一致。
不支持百分比形式设置。当设置为非法值时,按照默认值处理。 | +| strokeWidth | number \| string | 否 | 2 | 内部图标粗细,单位vp。不支持百分比形式设置。当设置为非法值时,按照默认值处理。 | + ## 示例 ```ts 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 70d75bc16fce4d7e7f7ef8a86082594e550cd062..3358043333bb34ad64e4f9418811671816a1135d 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 @@ -30,8 +30,10 @@ CheckboxGroup(options?: { group?: string }) | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| selectAll | boolean | 设置是否全选。
默认值:false,若同组的Checkbox显式设置select,则Checkbox的优先级高。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| selectAll | boolean | 设置是否全选。
默认值:false,若同组的[Checkbox](ts-basic-components-checkbox.md)设置了select属性,则Checkbox的优先级高。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
若同组的[Checkbox](ts-basic-components-checkbox.md)显式设置了select属性,则Checkbox的优先级高。 | | selectedColor | [ResourceColor](ts-types.md#resourcecolor) | 设置被选中或部分选中状态的颜色。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| unselectedColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 设置非选中状态边框颜色。 | +| mark10+ | [MarkStyle](#markstyle10对象说明) | 多选框内部图标样式。 | ## 事件 @@ -60,6 +62,13 @@ CheckboxGroup(options?: { group?: string }) | Part | 群组多选择框部分选择。 | | None | 群组多选择框全部没有选择。 | +## MarkStyle10+对象说明 + +| 名称 | 类型 | 必填 | 默认值 | 描述 | +| ----------- | ------------------------------------------ | ---- | ----------- | ------------------------------------------------------------ | +| strokeColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | Color.White | 内部图标颜色。 | +| size | number \| string | 否 | - | 内部图标大小,单位vp。默认大小与多选框群组组件宽度设置值一致。
不支持百分比形式设置。当设置为非法值时,按照默认值处理。 | +| strokeWidth | number \| string | 否 | 2 | 内部图标粗细,单位vp。不支持百分比形式设置。当设置为非法值时,按照默认值处理。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md index 4adb26c5466bd1b1df352ed4b1775dfb0fc260a6..647e934cecd29e52ec55630de50f0310f01e267a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md @@ -28,6 +28,7 @@ DataPanel(options:{values: number[], max?: number, type?: DataPanelType}) | max | number | 否 | - max大于0,表示数据的最大值。
- max小于等于0,max等于value数组各项的和,按比例显示。
默认值:100 | | type8+ | [DataPanelType](#datapaneltype枚举说明) | 否 | 数据面板的类型(不支持动态修改)。
默认值:DataPanelType.Circle | + ## DataPanelType枚举说明 从API version 9开始,该接口支持在ArkTS卡片中使用。 @@ -38,6 +39,50 @@ DataPanel(options:{values: number[], max?: number, type?: DataPanelType}) | Circle | 环形数据面板。 | +## 属性 + +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + + +| 名称 | 参数类型 | 必填 | 描述 | +| ------------- | ------- | ---- | -------- | +| closeEffect | boolean | 是 | 关闭数据占比图表旋转动效。
默认值:false。| +| valueColors10+ | Array<[ResourceColor](ts-types.md#resourcecolor) \| [LinearGradient](#lineargradient10)> | 是 | 各数据段颜色,ResourceColor为纯色,LinearGradient为渐变色。| +| trackBackgroundColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 是 | 底板颜色。| +| strokeWidth10+ | [Length](ts-types.md#Length) | 是 | 圆环粗细。 | +| trackShadow10+ | [DataPanelShadowOption](#datapanelshadowoption10) | 是 | 投影样式,不设置为不开启投影。| + + +## DataPanelShadowOption10+ +| 名称 | 参数类型 | 必填 | 描述 | +| ------------- | ------- | ---- | -------- | +| radius | number \| [Resource](ts-types.md#resource类型) | 否 | 阴影模糊半径。
默认值:5vp。 | +| colors | Array<[ResourceColor](ts-types.md#resourcecolor) \| [LinearGradient](#lineargradient10)> | 否 | 各数据段阴影的颜色。
默认值:与valueColors值相同。 | +| offsetX | number \| [Resource](ts-types.md#resource类型) | 否 | X轴的偏移量。
默认值:5vp。 | +| offsetY | number \| [Resource](ts-types.md#resource类型) | 否 | Y轴的偏移量。
默认值:5vp。 | + +## LinearGradient10+ + +线性渐变颜色描述。 + +LinearGradient(colorStops: ColorStop[]) + +| 名称 | 参数类型 | 必填 | 描述 | +| ------------- | ------- | ---- | -------- | +| colorStops | [ColorStop](#colorstop10)[] | 是 | 存储渐变颜色和渐变点。| + + +## ColorStop10+ + +颜色断点类型,用于描述渐进色颜色断点。 + +| 名称 | 参数类型 | 必填 | 描述 | +| ------------- | ------- | ---- | -------- | +| color | [ResourceColor](ts-types.md#resourcecolor) | 是 | 颜色值。| +| offset | [Length](ts-types.md#Length) | 是 | 渐变色断点(0~1之间的比例值)。| + + + ## 示例 ```ts diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md index 23ee9d666a1cb8a15ca1edb1db80957ed70c23f6..0b161e3976cb3be23829e420f1f2f8c2d3bdeb07 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md @@ -1,6 +1,6 @@ # DatePicker -选择日期的滑动选择器组件 +日期选择器组件,用于根据指定日期范围创建日期滑动选择器。 > **说明:** > @@ -26,16 +26,28 @@ DatePicker(options?: {start?: Date, end?: Date, selected?: Date}) | end | Date | 否 | 指定选择器的结束日期。
默认值:Date('2100-12-31') | | selected | Date | 否 | 设置选中项的日期。
默认值:当前系统日期 | - ## 属性 +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + | 名称 | 参数类型 | 描述 | | ------| -------------- | -------- | | lunar | boolean | 日期是否显示农历。
- true:展示农历。
- false:不展示农历。
默认值:false | +| disappearTextStyle10+ | [PickerTextStyle](#pickertextstyle10类型说明) | 设置所有选项中最上和最下两个选项的文本颜色、字号、字体粗细。 | +| textStyle10+ | [PickerTextStyle](#pickertextstyle10类型说明) | 设置所有选项中除了最上、最下及选中项以外的文本颜色、字号、字体粗细。 | +| selectedTextStyle10+ | [PickerTextStyle](#pickertextstyle10类型说明) | 设置选中项的文本颜色、字号、字体粗细。 | +## PickerTextStyle10+类型说明 + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------ | ------------------------------------------ | ---- | -------------------------------------------- | +| color | [ResourceColor](ts-types.md#resourcecolor) | 否 | 文本颜色。 | +| font | [Font](ts-types.md#font) | 否 | 文本样式,picker只支持字号、字体粗细的设置。 | ## 事件 +除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: + | 名称 | 功能描述 | | -------- | -------- | | onChange(callback: (value: DatePickerResult) => void) | 选择日期时触发该事件。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-divider.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-divider.md index 5dfb1e71dee75a73698c1141fc46a4a950223e07..edac89e88e2d77fdc39d7a838df4fd666fce36d7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-divider.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-divider.md @@ -26,15 +26,10 @@ Divider() | ----------- | ---------- | ------------------ | | vertical | boolean | 使用水平分割线还是垂直分割线。false:水平分割线;true:垂直分割线。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | color | [ResourceColor](ts-types.md#resourcecolor) | 分割线颜色。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| strokeWidth | number \| string | 分割线宽度。
默认值:1
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| strokeWidth | number \| string | 分割线宽度。
默认值:1
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
分割线的宽度不支持百分比设置。 | | lineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | 分割线的端点样式。
默认值:LineCapStyle.Butt
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -## 事件 - -不支持通用事件。 - - ## 示例 ```ts diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-formcomponent.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-formcomponent.md index c8737ca8a0712ae7f8025b17fa46c1f4762c38f4..90a4e4d3d9c2ab1b991dc07d7b6eaa8e5b5ab34b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-formcomponent.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-formcomponent.md @@ -6,7 +6,7 @@ > > - 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > -> - 该组件为卡片组件的使用方,对应提供方的使用参考文档[JS服务卡片UI组件](../js-service-widget-ui/Readme-CN.md)。 +> - 该组件为卡片组件的使用方,对应提供方的使用参考文档[JS服务卡片UI组件](../js-service-widget-ui/js-service-widget-file.md)。 > > - 该组件使用需要具有系统签名。 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 f6bea4ffa03a0f8adc39b76c86bf7539656f8963..a96e5d27b901d036abe0a1998dabd4d5f92c5b61 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 @@ -19,7 +19,7 @@ ## 接口 -Image(src: string | PixelMap | Resource) +Image(src: PixelMap | ResourceStr | DrawableDescriptor) 通过图片数据源获取图片,用于后续渲染展示。 @@ -29,7 +29,7 @@ Image(src: string | PixelMap | Resource) | 参数名 | 参数类型 | 必填 | 参数描述 | | ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| src | string\| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource类型) | 是 | 图片的数据源,支持本地图片和网络图片。
当使用相对路径引用图片资源时,例如`Image("common/test.jpg")`,不支持跨包/跨模块调用该Image组件,建议使用`$r`方式来管理需全局使用的图片资源。
\- 支持的图片格式包括png、jpg、bmp、svg和gif。
\- 支持`Base64`字符串。格式`data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, 其中`[base64 data]`为`Base64`字符串数据。
\- 支持`datashare://`路径前缀的字符串,用于访问通过data ability提供的图片路径。图片加载前需要申请[媒体库功能相关权限](../../file-management/medialibrary-overview.md#申请媒体库功能相关权限)
\- 支持file:///data/storage路径前缀的字符串,用于读取本应用安装目录下files文件夹下的图片资源。需要保证目录包路径下的文件有可读权限。
**说明:**
- ArkTS卡片上支持gif图片格式动效,但仅在显示时播放一次。
- ArkTS卡片上不支持`http://`等网络相关路径前缀、`datashare://`路径前缀以及`file://data/storage`路径前缀的字符串
- ArkTS卡片上不支持 [PixelMap](../apis/js-apis-image.md#pixelmap7)类型 | +| src |  [PixelMap](../apis/js-apis-image.md#pixelmap7) \|ResourceStr\| [DrawableDescriptor](../apis/js-apis-arkui-drawableDescriptor.md#drawabledescriptor) | 是 | 图片的数据源,支持本地图片和网络图片。
当使用相对路径引用图片资源时,例如`Image("common/test.jpg")`,不支持跨包/跨模块调用该Image组件,建议使用`$r`方式来管理需全局使用的图片资源。
\- 支持的图片格式包括png、jpg、bmp、svg和gif。
\- 支持`Base64`字符串。格式`data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, 其中`[base64 data]`为`Base64`字符串数据。
\- 支持`datashare://`路径前缀的字符串,用于访问通过data ability提供的图片路径。图片加载前需要申请[媒体库功能相关权限](../../file-management/medialibrary-overview.md#申请媒体库功能相关权限)
\- 支持file:///data/storage路径前缀的字符串,用于读取本应用安装目录下files文件夹下的图片资源。需要保证目录包路径下的文件有可读权限。
\- 支持[DrawableDescriptor](../apis/js-apis-arkui-drawableDescriptor.md#drawabledescriptor)对象
**说明:**
- ArkTS卡片上支持gif图片格式动效,但仅在显示时播放一次。
- ArkTS卡片上不支持`http://`等网络相关路径前缀、`datashare://`路径前缀以及`file://data/storage`路径前缀的字符串
- ArkTS卡片上不支持 [PixelMap](../apis/js-apis-image.md#pixelmap7)类型 | ## 属性 @@ -83,7 +83,7 @@ Image(src: string | PixelMap | Resource) | 名称 | 功能描述 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| onComplete(callback: (event?: { width: number, height: number, componentWidth: number,
 componentHeight: number, loadingStatus: number }) => void) | 图片成功加载时触发该回调,返回成功加载的图片尺寸。
- width:图片的宽,单位为像素。
- height:图片的高,单位为像素。
- componentWidth:组件的宽,单位为像素。
- componentHeight:组件的高,单位为像素。
- loadingStatus:图片加载成功的状态。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| onComplete(callback: (event?: { width: number, height: number, componentWidth: number,
 componentHeight: number, loadingStatus: number }) => void) | 图片成功加载时触发该回调,返回成功加载的图片尺寸。
- width:图片的宽,单位为像素。
- height:图片的高,单位为像素。
- componentWidth:组件的宽,单位为像素。
- componentHeight:组件的高,单位为像素。
- loadingStatus:图片加载成功的状态。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
loadingStatus返回的状态值为0时,代表图片加载失败;返回的状态值为1时,代表图片加载成功。 | | onError(callback: (event?: { componentWidth: number, componentHeight: number , message9+: string }) => void) | 图片加载出现异常时触发该回调。
- componentWidth:组件的宽,单位为像素。
- componentHeight:组件的高,单位为像素。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | onFinish(event: () => void) | 当加载的源文件为带动效的svg图片时,当svg动效播放完成时会触发这个回调,如果动效为无限循环动效,则不会触发这个回调。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md index c43cdc2d4abec8e72c858d517a5dbb988e21b2ae..178c95ff9f2f3515d59ae425d5b1a8dfaa131ffa 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md @@ -17,9 +17,10 @@ ImageAnimator() - ## 属性 +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + | 参数名称 | 参数类型 |参数描述 | | ---------- | ----------------------- |-------- | | images | Array<[ImageFrameInfo](#imageframeinfo对象说明)> | 设置图片帧信息集合。每一帧的帧信息(ImageFrameInfo)包含图片路径、图片大小、图片位置和图片播放时长信息,详见ImageFrameInfo属性说明。
默认值:[]
**说明:**
不支持动态更新。 | @@ -42,9 +43,10 @@ ImageAnimator() | left | number \| string | 否 | 图片相对于组件左上角的横向坐标。
默认值:0 | | duration | number | 否 | 每一帧图片的播放时长,单位毫秒。
默认值:0 | - ## 事件 +除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: + | 名称 | 功能描述 | | -------- | -------- | | onStart(event: () => void) | 状态回调,动画开始播放时触发。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menu.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menu.md index dde03192a4d6bbcc5a935e4a0072351436c03131..4b969fc2a131e382b0a07670353af3ff096e2229 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menu.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menu.md @@ -22,7 +22,9 @@ Menu() | 名称 | 参数类型 | 描述 | | -------- | ------------------------- | ---------------------------------------------------------------- | -| fontSize | [Length](ts-types.md#length) | 统一设置Menu中所有文本的尺寸,Length为number类型时,使用fp单位。 | +| fontSizedeprecated | [Length](ts-types.md#length) | 统一设置Menu中所有文本的尺寸,Length为number类型时,使用fp单位。
从API Version 10开始废弃,建议使用font代替。 | +| font10+ | [Font](ts-types.md#font) | 统一设置Menu中所有文本的字体样式。 | +| fontColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 统一设置Menu中所有文本的颜色。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menuitem.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menuitem.md index 038af44a42a7ffbdc5fd9688be54b1fc0782c78d..baca369fe5b425e76e7471285da48a55dbf3a4f7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menuitem.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menuitem.md @@ -22,10 +22,10 @@ MenuItem(value?: MenuItemOptions| CustomBuilder) ## MenuItemOptions类型说明 -| 名称 | 类型 | 必填 | 描述 | -| --------- | ---------------------------------------- | ---- | -------------------------------------- | +| 名称 | 类型 | 必填 | 描述 | +| --------- | ------------------------------------------- | ---- | -------------------------------------- | | startIcon | [ResourceStr](ts-types.md#resourcestr) | 否 | item中显示在左侧的图标信息路径。 | -| content | [ResourceStr](ts-types.md#resourcestr) | 是 | item的内容信息。 | +| content | [ResourceStr](ts-types.md#resourcestr) | 否 | item的内容信息。 | | endIcon | [ResourceStr](ts-types.md#resourcestr) | 否 | item中显示在右侧的图标信息路径。 | | labelInfo | [ResourceStr](ts-types.md#resourcestr) | 否 | 定义结束标签信息,如快捷方式Ctrl+C等。 | | builder | [CustomBuilder](ts-types.md#custombuilder8) | 否 | 用于构建二级菜单。 | @@ -34,10 +34,14 @@ MenuItem(value?: MenuItemOptions| CustomBuilder) 除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: -| 名称 | 参数类型 | 描述 | -| ---------- | -------- | ---------------------------------------- | -| selected | boolean | 设置菜单项是否选中。
默认值:false | -| selectIcon | boolean | 当菜单项被选中时,是否显示被选中的图标。 | +| 名称 | 参数类型 | 描述 | +| ------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| selected | boolean | 设置菜单项是否选中。
默认值:false | +| selectIcon | boolean \| [ResourceStr](ts-types.md#resourcestr)10+ | 当菜单项被选中时,是否显示被选中的图标。
默认值:false
true: 菜单项被选中时,显示默认的对勾图标
false: 即使菜单项被选中也不显示图标
ResourceStr: 菜单项被选中时,显示指定的图标 | +| contentFont10+ | [Font](ts-types.md#font) | 设置菜单项中内容信息的字体样式。 | +| contentFontColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 设置菜单项中内容信息的字体颜色。 | +| labelFont10+ | [Font](ts-types.md#font) | 设置菜单项中标签信息的字体样式。 | +| labelFontColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 设置菜单项中标签信息的字体颜色。 | ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md index 9fad298ffe627e1c9c8d2f9cb9fc1ac1a0f6589e..32be817dcbc2a1548167670cdf5310da341f2a8f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md @@ -23,18 +23,18 @@ Navigation() | 名称 | 参数类型 | 描述 | | -------------- | ---------------------------------------- | ---------------------------------------- | -| title | string \| [CustomBuilder](ts-types.md#custombuilder8)8+ \| [NavigationCommonTitle](#navigationcommontitle类型说明)9+ \| [NavigationCustomTitle](#navigationcustomtitle类型说明)9+ | 页面标题。 | +| title | [ResourceStr](ts-types.md#resourcestr)10+ \| [CustomBuilder](ts-types.md#custombuilder8)8+ \| [NavigationCommonTitle](#navigationcommontitle类型说明)9+ \| [NavigationCustomTitle](#navigationcustomtitle类型说明)9+ | 页面标题。 | | subTitledeprecated | string | 页面副标题。从API Version 9开始废弃,建议使用title代替。 | | menus | Array<[NavigationMenuItem](#navigationmenuitem类型说明)> \| [CustomBuilder](ts-types.md#custombuilder8)8+ | 页面右上角菜单。使用Array<[NavigationMenuItem](#navigationmenuitem类型说明)> 写法时,竖屏最多支持显示3个图标,横屏最多支持显示5个图标,多余的图标会被放入自动生成的更多图标。 | | titleMode | [NavigationTitleMode](#navigationtitlemode枚举说明) | 页面标题栏显示模式。
默认值:NavigationTitleMode.Free | | toolBar | [object](#object类型说明) \| [CustomBuilder](ts-types.md#custombuilder8)8+ | 设置工具栏内容。
items: 工具栏所有项。 | | hideToolBar | boolean | 隐藏工具栏。
默认值:false
true: 隐藏工具栏。
false: 显示工具栏。 | | hideTitleBar | boolean | 隐藏标题栏。
默认值:false
true: 隐藏标题栏。
false: 显示标题栏。 | -| hideBackButton | boolean | 隐藏返回键。
默认值:false
true: 隐藏返回键。
false: 显示返回键。 | +| hideBackButton | boolean | 隐藏返回键。
默认值:false
true: 隐藏返回键。
false: 显示返回键。
不支持隐藏NavDestination组件标题栏中的返回图标。| | navBarWidth9+ | [Length](ts-types.md#length) | 导航栏宽度。
默认值:200vp | | navBarPosition9+ | [NavBarPosition](#navbarposition枚举说明) | 导航栏位置。
默认值:NavBarPosition.Start | | mode9+ | [NavigationMode](#navigationmode枚举说明) | 导航栏的显示模式。
默认值:NavigationMode.Auto | -| backButtonIcon9+ | string \| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource) | 设置导航栏返回图标。 | +| backButtonIcon9+ | string \| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource) | 设置导航栏返回图标。不支持隐藏NavDestination组件标题栏中的返回图标。| | hideNavBar9+ | boolean | 是否显示导航栏(仅在mode为NavigationMode.Split时生效)。 | @@ -229,4 +229,4 @@ struct NavigationExample { } ``` -![zh-cn_image_0000001192655288](figures/zh-cn_image_0000001192655288.gif) \ No newline at end of file +![zh-cn_image_0000001192655288](figures/zh-cn_image_0000001192655288.gif) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md index c1e1ec63eaebe421f29fbdba9656394e30c3d81a..a3cb4fb0b2188f67bf6a5c7b199008b53e891d3e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md @@ -5,6 +5,8 @@ > **说明:** > > 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> 二维码组件的像素点数量与内容有关,当组件尺寸过小时,可能出现无法展示内容的情况,此时需要适当调整组件尺寸。 ## 子组件 @@ -22,7 +24,7 @@ QRCode(value: string) | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| value | string | 是 | 二维码内容字符串。 | +| value | string | 是 | 二维码内容字符串。最大支持256个字符,若超出,则截取前256个字符。 | ## 属性 @@ -36,7 +38,7 @@ QRCode(value: string) ## 事件 -通用事件仅支持[点击事件](ts-universal-events-click.md)。 +通用事件支持[点击事件](ts-universal-events-click.md)、[触摸事件](ts-universal-events-touch.md)、[挂载卸载事件](ts-universal-events-show-hide.md)。 ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-radio.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-radio.md index 4a496bc9760dbaf909443ab5721d6bcc00bfd7d3..b9438839f0e0d154be97d214fa97d63ce5a29107 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-radio.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-radio.md @@ -31,7 +31,8 @@ Radio(options: {value: string, group: string}) | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| checked | boolean | 设置单选框的选中状态。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。| +| checked | boolean | 设置单选框的选中状态。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| radioStyle10+ | [RadioStyle](#radiostyle对象说明) | 设置单选框选中状态和非选中状态的样式。
从API version 10开始,该接口支持在ArkTS组件中使用。| ## 事件 @@ -39,8 +40,15 @@ Radio(options: {value: string, group: string}) | 名称 | 功能描述 | | -------- | -------- | -| onChange(callback: (isChecked: boolean) => void) | 单选框选中状态改变时触发回调。
-isChecked为true时,代表选中。
-isChecked为false时,代表未选中。
从API version 9开始,该接口支持在ArkTS卡片中使用。| +| onChange(callback: (isChecked: boolean) => void) | 单选框选中状态改变时触发回调。
- isChecked为true时,表示从未选中变为选中。
- isChecked为false时,表示从选中变为未选中。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +## RadioStyle对象说明 + +| 名称 | 类型 | 必填 | 默认值 | 描述 | +| ---------------------- | ------------------------------------------ | ---- | ------- | ---------------------- | +| checkedBackgroundColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | #007DFF | 开启状态底板颜色。 | +| uncheckedBorderColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | #182431 | 关闭状态描边颜色。 | +| indicatorColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | #FFFFFF | 开启状态内部圆饼颜色。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-rating.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-rating.md index e371f92c38183f150c4b0516e4547f0638e6df57..5805ebdc0642cc7d873fab4cc32f2d992a11cf91 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-rating.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-rating.md @@ -22,17 +22,23 @@ Rating(options?: { rating: number, indicator?: boolean }) | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| rating | number | 是 | 设置并接收评分值。
默认值:0 | -| indicator | boolean | 否 | 设置评分组件作为指示器使用,不可改变评分。
默认值:false, 可进行评分 | +| rating | number | 是 | 设置并接收评分值。
默认值:0
取值范围: [0, stars]
小于0取0,大于stars取最大值stars。 | +| indicator | boolean | 否 | 设置评分组件作为指示器使用,不可改变评分。
默认值:false, 可进行评分
**说明:**
indicator=true时,默认组件高度height=12.0vp,组件width=height*stars。
indicator=false时,默认组件高度height=28.0vp,组件width=height*stars。 | ## 属性 | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| stars | number | 设置评星总数。
默认值:5
从API version 9开始,该接口支持在ArkTS卡片中使用。| -| stepSize | number | 操作评级的步长。
默认值:0.5
从API version 9开始,该接口支持在ArkTS卡片中使用。| -| starStyle | {
backgroundUri: string,
foregroundUri: string,
secondaryUri?: string
} | backgroundUri:未选中的星级的图片链接,可由用户自定义或使用系统默认图片,仅支持本地图片。
foregroundUri:选中的星级的图片路径,可由用户自定义或使用系统默认图片,仅支持本地图片。
secondaryUir:部分选中的星级的图片路径,可由用户自定义或使用系统默认图片,仅支持本地图片。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| stars | number | 设置评分总数。
默认值:5
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
设置为小于0的值时,按默认值显示。 | +| stepSize | number | 操作评级的步长。
默认值:0.5
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
设置为小于0的值时,按默认值显示。
取值范围为[0.1, stars]。 | +| starStyle | {
backgroundUri: string,
foregroundUri: string,
secondaryUri?: string
} | backgroundUri:未选中的星级的图片链接,可由用户自定义或使用系统默认图片。
foregroundUri:选中的星级的图片路径,可由用户自定义或使用系统默认图片。
secondaryUir:部分选中的星级的图片路径,可由用户自定义或使用系统默认图片。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
startStyle属性所支持的图片类型能力参考[Image](ts-basic-components-image.md)组件。
支持加载本地图片和网络图片,暂不支持PixelMap类型和Resource资源。
默认图片加载方式为异步,暂不支持同步加载。
设置值为undefined或者空字符串时,rating会选择加载系统默认星型图源。 | + +> **说明:** +> +> rating宽高为[width, height]时,单个图片的绘制区域为[width / stars, height]。 +> +> 为了指定绘制区域为方形,建议自定义宽高时采取[height * stars, height], width = height * stars的方式。 ## 事件 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 496f2bd54a5b5e2098cabf46e061386cf665333b..77185a29a95553779eb45351b086d1944d53e95f 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 @@ -50,7 +50,7 @@ RichText(content:string) | \\ | 定义与常规文本风格不同的文本,像拼写错误的单词或者汉语中的专有名词,应尽量避免使用\为文本加下划线,用户会把它混淆为一个超链接。 | \

\这是带有下划线的段落\\

| | \ | 定义HTML文档的样式信息。 | \ | | style | 属性规定元素的行内样式,写在标签内部,在使用的时候需用引号来进行区分,并以; 间隔样式,style='width: 500px;height: 500px;border: 1px soild;margin: 0 auto;'。 | \

这是一个标题\

\

这是一个段落。\

| -| \ | 用于定义客户端文本,比如JavaScript。 | \ | +| \ | 用于定义客户端脚本,比如JavaScript。 | \ | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md index 443f68660dbeb6d1be95c1aa9468828a2db02e98..c49bc417980663ecf354c8569ae6f7b0a2b0d53c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md @@ -12,14 +12,14 @@ ## 接口 -Search(options?: { value?: string; placeholder?: string; icon?: string; controller?: SearchController }) +Search(options?: { value?: string; placeholder?: ResourceStr; icon?: string; controller?: SearchController }) **参数:** | 参数名 | 参数类型 | 必填 | 参数描述 | | ----------- | ---------------- | ---- | ------------------------------------------------------------ | -| value | string | 否 | 设置当前显示的搜索文本内容。 | -| placeholder | string | 否 | 设置无输入时的提示文本。 | +| value | string | 否 | 设置当前显示的搜索文本内容。 | +| placeholder | [ResourceStr](ts-types.md#resourcestr)10+ | 否 | 设置无输入时的提示文本。 | | icon | string | 否 | 设置搜索图标路径,默认使用系统搜索图标,图标支持的图源格式: svg、jpg和png。 | | controller | SearchController | 否 | 设置Search组件控制器。 | @@ -29,12 +29,46 @@ Search(options?: { value?: string; placeholder?: string; icon?: string; controll | 名称 | 参数类型 | 描述 | | ----------------------- | ------------------------------------------------ | ---------------------------------------------- | -| searchButton | string | 搜索框末尾搜索按钮文本内容,默认无搜索按钮。 | +| searchButton10+ | value: string,
option?: [SearchButtonOption](#searchbuttonoption10对象说明) | 搜索框末尾搜索按钮文本内容,默认无搜索按钮。 | | placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | 设置placeholder文本颜色。 | -| placeholderFont | [Font](ts-types.md#font) | 设置placeholder文本样式。 | -| textFont | [Font](ts-types.md#font) | 设置搜索框内输入文本样式。 | +| placeholderFont | [Font](ts-types.md#font) | 设置placeholder文本样式,包括字体大小,字体粗细,字体族,字体风格。目前仅支持默认字体族。 | +| textFont | [Font](ts-types.md#font) | 设置搜索框内输入文本样式,包括字体大小,字体粗细,字体族,字体风格。目前仅支持默认字体族。 | | textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本在搜索框中的对齐方式。
默认值:TextAlign.Start | | copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置输入的文本是否可复制。 | +| searchIcon10+ | [IconOptions](#iconoptions10对象说明) | 设置左侧搜索图标样式。 | +| cancelButton10+ | {
style? : [CancelButtonStyle](#cancelbuttonstyle10枚举说明)
icon?: [IconOptions](#iconoptions10对象说明)
} | 设置右侧清除按钮样式。 | +| fontColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 设置输入文本的字体颜色。 | +| caretStyle10+ | [CaretStyle](#caretstyle10对象说明) | 设置光标样式。 | + +## IconOptions10+对象说明 + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------ | ------------------------------------------ | ---- | ----------- | +| size | [Length](ts-types.md#length) | 否 | 图标尺寸。 | +| color | [ResourceColor](ts-types.md#resourcecolor) | 否 | 图标颜色。 | +| src | [ResourceStr](ts-types.md#resourcestr) | 否 | 图标/图片源。 | + +## CaretStyle10+对象说明 + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------ | ------------------------------------------ | ---- | -------- | +| width | [Length](ts-types.md#length) | 否 | 光标尺寸。 | +| color | [ResourceColor](ts-types.md#resourcecolor) | 否 | 光标颜色。 | + +## SearchButtonOption10+对象说明 + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| --------- | ------------------------------------------ | ---- | ---------------- | +| fontSize | [Length](ts-types.md#length) | 否 | 文本按钮字体大小。 | +| fontColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 文本按钮字体颜色。 | + +## CancelButtonStyle10+枚举说明 + +| 名称 | 描述 | +| ----------------------- | ---------------- | +| CONSTANT10+ | 清除按钮常显样式。 | +| INVISIBLE10+ | 清除按钮常隐样式。 | +| INPUT10+ | 清除按钮输入样式。 | ## 事件 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 ab4d9d7023f1df2500ceaeaadfd592127967c68f..6f8df5055fb91666b7d05219d38c0676f2fc4312 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 @@ -35,6 +35,15 @@ Select(options: Array\<[SelectOption](#selectoption对象说明)\>) | optionBgColor | [ResourceColor](ts-types.md#resourcecolor) | 设置下拉菜单项的背景色。 | | optionFont | [Font](ts-types.md#font) | 设置下拉菜单项的文本样式。 | | optionFontColor | [ResourceColor](ts-types.md#resourcecolor) | 设置下拉菜单项的文本颜色。 | +| space10+ | [Length](ts-types.md#length) | 设置下拉菜单项的文本与箭头之间的间距。 | +| arrowPosition10+ | [ArrowPosition](#arrowposition10枚举说明) | 设置下拉菜单项的文本与箭头之间的对齐方式。 | + +## ArrowPosition10+枚举说明 + +| 名称 | 描述 | +| ------------------- | ------------------ | +| END10+ | 文字在前,箭头在后。 | +| START10+ | 箭头在前,文字在后。 | ## 事件 @@ -49,20 +58,28 @@ Select(options: Array\<[SelectOption](#selectoption对象说明)\>) @Entry @Component struct SelectExample { + @State text: string = "TTTTT" + @State index: number = 2 + @State space: number = 8 + @State arrowPosition: ArrowPosition = ArrowPosition.END build() { Column() { Select([{ value: 'aaa', icon: "/common/public_icon.svg" }, { value: 'bbb', icon: "/common/public_icon.svg" }, { value: 'ccc', icon: "/common/public_icon.svg" }, { value: 'ddd', icon: "/common/public_icon.svg" }]) - .selected(2) - .value('TTTTT') + .selected(this.index) + .value(this.text) .font({ size: 16, weight: 500 }) .fontColor('#182431') .selectedOptionFont({ size: 16, weight: 400 }) .optionFont({ size: 16, weight: 400 }) - .onSelect((index: number) => { + .space(this.space) + .arrowPosition(this.arrowPosition) + .onSelect((index:number, text: string)=>{ console.info('Select:' + index) + this.index = index; + this.text = text; }) }.width('100%') } 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 462adf9df41dc616dd2f153f26630b68231a2d90..a4cebaf37820492bc57e7883b4dd65e1f3083ced 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 @@ -24,8 +24,8 @@ Slider(options?: {value?: number, min?: number, max?: number, step?: number, sty | -------- | -------- | -------- | -------- | | value | number | 否 | 当前进度值。
默认值:0 | | min | number | 否 | 设置最小值。
默认值:0 | -| max | number | 否 | 设置最大值。
默认值:100 | -| step | number | 否 | 设置Slider滑动步长。
默认值:1
取值范围:[0.01, max] | +| max | number | 否 | 设置最大值。
默认值:100
**说明:**
min >= max异常情况,min取默认值0,max取默认值100。
value不在[min, max]范围之内,取min/max,靠近min取min,靠近max取max。 | +| step | number | 否 | 设置Slider滑动步长。
默认值:1
取值范围:[0.01, max]
**说明:**
设置小于0或百分比的值时,按默认值显示。 | | style | [SliderStyle](#sliderstyle枚举说明) | 否 | 设置Slider的滑块与滑轨显示样式。
默认值:SliderStyle.OutSet | | direction8+ | [Axis](ts-appendix-enums.md#axis) | 否 | 设置滑动条滑动方向为水平或竖直方向。
默认值:Axis.Horizontal | | reverse8+ | boolean | 否 | 设置滑动条取值范围是否反向,横向Slider默认为从左往右滑动,竖向Slider默认为从上往下滑动。
默认值:false | @@ -39,9 +39,6 @@ Slider(options?: {value?: number, min?: number, max?: number, step?: number, sty | OutSet | 滑块在滑轨上。 | | InSet | 滑块在滑轨内。 | - -## 属性 - 支持除触摸热区以外的通用属性设置。 | 名称 | 参数类型 | 描述 | @@ -50,9 +47,35 @@ Slider(options?: {value?: number, min?: number, max?: number, step?: number, sty | trackColor | [ResourceColor](ts-types.md#resourcecolor) | 设置滑轨的背景颜色。
从API version 9开始,该接口支持在ArkTS卡片中使用。| | selectedColor | [ResourceColor](ts-types.md#resourcecolor) | 设置滑轨的已滑动部分颜色。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | showSteps | boolean | 设置当前是否显示步长刻度值。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。| -| showTips | boolean | 设置滑动时是否显示百分比气泡提示。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。| -| trackThickness | [Length](ts-types.md#length) | 设置滑轨的粗细。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| showTips | boolean | 设置滑动时是否显示百分比气泡提示。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
当direction的属性值为Axis.Horizontal时,tip显示在滑块正上方。值为Axis.Vertical时,tip显示在滑块正左边。
tip的绘制区域为Slider自身节点的overlay。
Slider不设置边距,或者边距比较小时,tip会被截断。 | +| trackThickness | [Length](ts-types.md#length) | 设置滑轨的粗细。
默认值:当参数style的值设置[SliderStyle](#sliderstyle枚举说明).OutSet 时为 4.0vp,[SliderStyle](#sliderstyle枚举说明).InSet时为20.0vp
从APIversion9开始,该接口支持在ArkTS卡片中使用。
**说明:**
设置为小于0的值时,按默认值显示。 | +| blockBorderColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 设置滑块描边颜色。 | +| blockBorderWidth10+ | [Length](ts-types.md#length) | 设置滑块描边粗细。 | +| stepColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 设置刻度颜色。 | +| trackBorderRadius10+ | [Length](ts-types.md#length) | 设置底板圆角半径。 | +| blockSize10+ | [SizeOptions](ts-types.md#sizeoptions) | 设置滑块大小。 | +| blockStyle10+ | [SliderBlockStyle](#sliderblockstyle10) | 设置滑块形状参数。 | +| stepSize10+ | [Length](ts-types.md#length) | 设置刻度大小(直径)。 | + +## SliderBlockStyle10+对象说明 + +Slider组件滑块形状参数。 + +| 名称 | 类型 | 必填 | 说明 | +| ----- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SliderBlockType](#sliderblocktype10) | 是 | 设置滑块形状。
默认值:SliderBlockType.DEFAULT,使用圆形滑块。 | +| image | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置滑块图片资源。
图片显示区域大小由blockSize属性控制,请勿输入尺寸过大的图片。 | +| shape | [Circle](ts-drawing-components-circle.md) \| [Ellipse](ts-drawing-components-ellipse.md) \| [Path](ts-drawing-components-path.md) \| [Rect](ts-drawing-components-rect.md)  | 否 | 设置滑块使用的自定义形状。 | + +## SliderBlockType10+枚举说明 + +Slier组件滑块形状枚举。 +| 名称 | 描述 | +| ------- | ---------------------- | +| DEFAULT | 使用默认滑块(圆形)。 | +| IMAGE | 使用图片资源作为滑块。 | +| SHAPE | 使用自定义形状作为滑块。 | ## 事件 @@ -60,7 +83,7 @@ Slider(options?: {value?: number, min?: number, max?: number, step?: number, sty | 名称 | 功能描述 | | -------- | -------- | -| onChange(callback: (value: number, mode: SliderChangeMode) => void) | Slider滑动时触发事件回调。
value:当前滑动进度值。若返回值有小数,可使用Math.toFixed()方法将数据处理为预期的精度。
mode:拖动状态。
从API version 9开始,该接口支持在ArkTS卡片中使用。| +| onChange(callback: (value: number, mode: SliderChangeMode) => void) | Slider拖到或点击时触发事件回调。
value:当前滑动进度值。若返回值有小数,可使用Math.toFixed()方法将数据处理为预期的精度。
mode:事件触发的相关状态值。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
Begin和End状态当手势点击时都会触发,Moving和Click状态当value值发生变换时触发。
当连贯动作为拖动动作时,不触发Click状态。
value值的变化范围为对应步长steps数组。 | ## SliderChangeMode枚举说明 @@ -68,9 +91,9 @@ Slider(options?: {value?: number, min?: number, max?: number, step?: number, sty | 名称 | 值 | 描述 | | -------- | -------- | -------- | -| Begin | 0 | 开始拖动滑块。 | +| Begin | 0 | 手势/鼠标接触或者按下滑块。 | | Moving | 1 | 正在拖动滑块过程中。 | -| End | 2 | 结束拖动滑块。 | +| End | 2 | 手势/鼠标离开滑块。 | | Click | 3 | 点击滑动条使滑块位置移动。 | 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 9392eef756b9c5eb3baace5dadb64b84ff4b21cc..1dbc2dd6ebb99eb8f2716566a8903edd002ee848 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 @@ -35,17 +35,23 @@ Text(content?: string | Resource) | maxLines | number | 设置文本的最大行数。
默认值:Infinity
**说明:**
默认情况下,文本是自动折行的,如果指定此参数,则文本最多不会超过指定的行。如果有多余的文本,可以通过 `textOverflow`来指定截断方式。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | lineHeight | string \| number \| [Resource](ts-types.md#resource) | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | decoration | {
type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),
color?: [ResourceColor](ts-types.md#resourcecolor)
} | 设置文本装饰线样式及其颜色。
默认值:{
type: TextDecorationType.None,
color:Color.Black
}
从API version 9开始,该接口支持在ArkTS卡片中使用。| -| baselineOffset | number \| string | 设置文本基线的偏移量,默认值0。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| letterSpacing | number \| string | 设置文本字符间距。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| baselineOffset | number \| string | 设置文本基线的偏移量,默认值0。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
设置该值为百分比时,按默认值显示。 | +| letterSpacing | number \| string | 设置文本字符间距。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
设置该值为百分比时,按默认值显示。 | | minFontSize | number \| string \| [Resource](ts-types.md#resource) | 设置文本最小显示字号。
需配合maxFontSize以及maxline或布局大小限制使用,单独设置不生效。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | maxFontSize | number \| string \| [Resource](ts-types.md#resource) | 设置文本最大显示字号。
需配合minFontSize以及maxline或布局大小限制使用,单独设置不生效。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | textCase | [TextCase](ts-appendix-enums.md#textcase) | 设置文本大小写。
默认值:TextCase.Normal
从API version 9开始,该接口支持在ArkTS卡片中使用。| | copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 组件支持设置文本是否可复制粘贴。
默认值:CopyOptions.None
该接口支持在ArkTS卡片中使用。 | +| textShadow10+ | [ShadowOptions](ts-universal-attributes-image-effect.md#shadowoptions对象说明) | 设置文字阴影效果。 | +| heightAdaptivePolicy10+ | [TextHeightAdaptivePolicy](ts-appendix-enums.md#TextHeightAdaptivePolicy10) | 设置文本自适应高度的方式。 | > **说明:** > > 不支持Text内同时存在文本内容和Span子组件。如果同时存在,只显示Span内的内容。 +## 事件 + +支持[通用事件](ts-universal-events-click.md)。 + ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md index 2acf7d3a89ea1d74e5387040fedb05ddd98fe148..0389e734d011200154e3832fdd90af7ce62f9d1e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md @@ -20,7 +20,7 @@ TextArea(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Tex | 参数名 | 参数类型 | 必填 | 参数描述 | | ----------------------- | ---------------------------------------- | ---- | -------------- | -| placeholder | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置无输入时的提示文本。 | +| placeholder | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置无输入时的提示文本,输入内容后,提示文本不显示。 | | text | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置输入框当前的文本内容。 | | controller8+ | [TextAreaController](#textareacontroller8) | 否 | 设置TextArea控制器。 | @@ -29,14 +29,18 @@ TextArea(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Tex 除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: -| 名称 | 参数类型 | 描述 | -| ------------------------ | ---------------------------------------- | ---------------------------------------- | -| placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | 设置placeholder文本颜色。 | -| placeholderFont | [Font](ts-types.md#font) | 设置placeholder文本样式。 | -| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本在输入框中的水平对齐式。
默认值:TextAlign.Start | -| caretColor | [ResourceColor](ts-types.md#resourcecolor) | 设置输入框光标颜色。 | +| 名称 | 参数类型 | 描述 | +| ------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | 设置placeholder文本颜色。 | +| placeholderFont | [Font](ts-types.md#font) | 设置placeholder文本样式,包括字体大小,字体粗细,字体族,字体风格。目前仅支持默认字体族。 | +| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本在输入框中的水平对齐式。
默认值:TextAlign.Start | +| caretColor | [ResourceColor](ts-types.md#resourcecolor) | 设置输入框光标颜色。 | | inputFilter8+ | {
value: [ResourceStr](ts-types.md#resourcestr),
error?: (value: string) => void
} | 通过正则表达式设置输入过滤器。匹配表达式的输入允许显示,不匹配的输入将被过滤。仅支持单个字符匹配,不支持字符串匹配。
- value:设置正则表达式。
- error:正则匹配失败时,返回被过滤的内容。 | -| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置输入的文本是否可复制。
设置CopyOptions.None时,当前TextArea中的文字无法被复制或剪切,仅支持粘贴。 | +| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置输入的文本是否可复制。
设置CopyOptions.None时,当前TextArea中的文字无法被复制或剪切,仅支持粘贴。 | + +> **说明:** +> +> [通用属性padding](ts-universal-attributes-size.md)的默认值为:
{
 top: 8 vp,
 right: 16 vp,
 bottom: 8 vp,
 left: 16 vp
} ## 事件 @@ -72,6 +76,18 @@ caretPosition(value: number): void | ------ | -------- | ---- | -------------------------------------- | | value | number | 是 | 从字符串开始到光标所在位置的字符长度。 | +### setTextSelection10+ + +setTextSelection(selectionStart: number, selectionEnd: number): void + +设置文本选择范围。 + +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------------- | -------- | ---- | ------------------ | +| selectionStart | number | 是 | 选择范围起始位置。 | +| selectionEnd | number | 是 | 选择范围结束位置。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md index b83500ff338d1136298dc5b085b2dcda8aa391ff..c266cfa7660e6994745d7c3ef977aa7eadf7571c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md @@ -34,7 +34,7 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te | type | [InputType](#inputtype枚举说明) | 设置输入框类型。
默认值:InputType.Normal | | placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | 设置placeholder文本颜色。| | placeholderFont | [Font](ts-types.md#font) | 设置placeholder文本样式。 | -| enterKeyType | [EnterKeyType](#enterkeytype枚举说明) | 设置输入法回车键类型,目前OpenHarmony输入法仅支持默认类型显示。
默认值:EnterKeyType.Done | +| enterKeyType | [EnterKeyType](#enterkeytype枚举说明) | 设置输入法回车键类型,目前仅支持默认类型显示。
默认值:EnterKeyType.Done | | caretColor | [ResourceColor](ts-types.md#resourcecolor) | 设置输入框光标颜色。 | | maxLength | number | 设置文本的最大输入字符数。 | | inputFilter8+ | {
value: [ResourceStr](ts-types.md#resourcestr),
error?: (value: string) => void
} | 正则表达式,匹配表达式的输入允许显示,不匹配的输入将被过滤。目前仅支持单个字符匹配,不支持字符串匹配。
- value:设置正则表达式。
- error:正则匹配失败时,返回被过滤的内容。 | @@ -42,6 +42,13 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te | showPasswordIcon9+ | boolean | 密码输入模式时,输入框末尾的图标是否显示。
默认值:true | | style9+ | [TextInputStyle](#textinputstyle9枚举说明) | 设置输入框为默认风格或内联输入风格。
默认值:TextInputStyle.Default | | textAlign9+ | [TextAlign](ts-appendix-enums.md#textalign) | 设置输入文本在输入框中的对齐方式。
默认值:TextAlign.Start | +| selectedBackgroundColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 设置文本选中底板颜色。 | +| caretStyle10+ | {
width: [Length](ts-types.md#length)
} | 设置光标风格。 | +| caretPosition10+ | number | 设置光标位置。 | + +> **说明:** +> +> [通用属性padding](ts-universal-attributes-size.md)的默认值为:
{
 top: 8 vp,
 right: 16 vp,
 bottom: 8 vp,
 left: 16 vp
} ## EnterKeyType枚举说明 @@ -58,8 +65,8 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te | 名称 | 描述 | | ------------------ | ------------- | | Normal | 基本输入模式。
支持输入数字、字母、下划线、空格、特殊字符。 | -| Password | 密码输入模式。 | -| Email | 邮箱地址输入模式。 | +| Password | 密码输入模式。支持输入数字、字母、下划线、空格、特殊字符。密码显示小眼睛图标并且默认会将文字变成圆点。 | +| Email | 邮箱地址输入模式。支持数字,字母,下划线,以及@字符(只能存在一个@字符)。 | | Number | 纯数字输入模式。 | | PhoneNumber9+ | 电话号码输入模式。
支持输入数字、+ 、-、*、#,长度不限。 | @@ -76,10 +83,10 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te | 名称 | 功能描述 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| onChange(callback: (value: string) => void) | 输入内容发生变化时,触发该回调。
value:输入的文本内容。 | +| onChange(callback: (value: string) => void) | 输入内容发生变化时,触发该回调。
value:输入的文本内容。
触发该事件的条件:
1、键盘输入。
2、粘贴、剪切。
3、键盘快捷键Ctrl+v。 | | onSubmit(callback: (enterKey: EnterKeyType) => void) | 按下输入法回车键触发该回调,返回值为当前输入法回车键的类型。
enterKeyType:输入法回车键类型。具体类型见[EnterKeyType枚举说明](#enterkeytype枚举说明)。 | | onEditChanged(callback: (isEditing: boolean) => void)(deprecated) | 输入状态变化时,触发该回调。从API 8开始,建议使用onEditChange。 | -| onEditChange(callback: (isEditing: boolean) => void)8+ | 输入状态变化时,触发该回调。isEditing为true表示正在输入。 | +| onEditChange(callback: (isEditing: boolean) => void)8+ | 输入状态变化时,触发该回调。有光标时为编辑态,无光标时为非编辑态。isEditing为true表示正在输入。 | | onCopy(callback:(value: string) => void)8+ | 长按输入框内部区域弹出剪贴板后,点击剪切板复制按钮,触发该回调。
value:复制的文本内容。 | | onCut(callback:(value: string) => void)8+ | 长按输入框内部区域弹出剪贴板后,点击剪切板剪切按钮,触发该回调。
value:剪切的文本内容。 | | onPaste(callback:(value: string) => void)8+ | 长按输入框内部区域弹出剪贴板后,点击剪切板粘贴按钮,触发该回调。
value:粘贴的文本内容。 | @@ -103,7 +110,18 @@ caretPosition(value: number): void | 参数名 | 参数类型 | 必填 | 参数描述 | | ------ | -------- | ---- | -------------------------------------- | | value | number | 是 | 从字符串开始到光标所在位置的字符长度。 | +### setTextSelection10+ + +setTextSelection(selectionStart: number, selectionStart: number): void + +设置文本选择区域并高亮显示。 + +**参数:** +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------------- | -------- | ---- | ---------------------- | +| selectionStart | number | 是 | 文本选择区域起始位置,文本框中文字的起始位置为0。 | +| selectionEnd | number | 是 | 文本选择区域结束位置。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md index 6a85cfa4b5e25080a61ffabfb1bcc05660b802bd..9d0f54ed31280dd0ac07a94793a8653e953ef1f3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md @@ -14,7 +14,7 @@ ## 接口 -TextPicker(options?: {range: string[]|Resource, selected?: number, value?: string}) +TextPicker(options?: {range: string[]|Resource|TextPickerRangeContent[], selected?: number, value?: string}) 根据range指定的选择范围创建文本选择器。 @@ -22,15 +22,27 @@ TextPicker(options?: {range: string[]|Resource, selected?: number, value?: strin | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| range | string[] \| [Resource](ts-types.md#resource类型) | 是 | 选择器的数据选择列表。 | +| range | string[] \| [Resource](ts-types.md#resource类型)\|[TextPickerRangeContent](#textpickerrangecontent10类型说明)[]10+ | 是 | 选择器的数据选择列表。不可设置为空数组,若设置为空数组,则不显示;若动态变化为空数组,则保持当前正常值显示。 | | selected | number | 否 | 设置默认选中项在数组中的索引值。
默认值:0 | -| value | string | 否 | 设置默认选中项的值,优先级低于selected。
默认值:第一个元素值 | +| value | string | 否 | 设置默认选中项的值,优先级低于selected。
默认值:第一个元素值
**说明**:只有显示文本列表时该值有效。显示图片或图片加文本的列表时,该值无效。 | + +## TextPickerRangeContent10+类型说明 + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------ | -------------------------------------------------------- | ---- | ---------- | +| icon | string \| [Resource](ts-types.md#resource) | 是 | 图片资源。 | +| text | string \| [Resource](ts-types.md#resource) | 否 | 文本信息。 | ## 属性 +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | defaultPickerItemHeight | number \| string | 设置Picker各选择项的高度。 | +| disappearTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 设置所有选项中最上和最下两个选项的文本颜色、字号、字体粗细。 | +| textStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 设置所有选项中除了最上、最下及选中项以外的文本颜色、字号、字体粗细。 | +| selectedTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 设置选中项的文本颜色、字号、字体粗细。 | ## 事件 @@ -38,7 +50,7 @@ TextPicker(options?: {range: string[]|Resource, selected?: number, value?: strin | 名称 | 描述 | | -------- | -------- | -| onChange(callback: (value: string, index: number) => void) | 滑动选中TextPicker文本内容后,触发该回调。
- value: 当前选中项的文本。
- index: 当前选中项的索引值。 | +| onChange(callback: (value: string, index: number) => void) | 滑动选中TextPicker文本内容后,触发该回调。
- value: 当前选中项的文本。
**说明**:当显示文本或图片加文本列表时,value值为选中项中的文本值,当显示图片列表时,value值为空。
- index: 当前选中项的索引值。 | ## 示例 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 96f6ea4e8d5d0d27c45970c2d4c744fa703d5123..0260d6ac8720c54fc7d42139b9478604ed8f14fb 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 @@ -1,6 +1,6 @@ # TimePicker -滑动选择时间的组件。 +时间选择组件,根据指定参数创建选择器,支持选择小时及分钟。 > **说明:** > @@ -24,16 +24,21 @@ TimePicker(options?: {selected?: Date}) | -------- | -------- | -------- | -------- | | selected | Date | 否 | 设置选中项的时间。
默认值:当前系统时间 | - ## 属性 +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | useMilitaryTime | boolean | 展示时间是否为24小时制,不支持动态修改。
默认值:false | - +| disappearTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 设置所有选项中最上和最下两个选项的文本颜色、字号、字体粗细。 | +| textStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 设置所有选项中除了最上、最下及选中项以外的文本颜色、字号、字体粗细。 | +| selectedTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 设置选中项的文本颜色、字号、字体粗细。 | ## 事件 +除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: + | 名称 | 功能描述 | | ---------------------------------------- | ----------- | | onChange(callback: (value: TimePickerResult ) => void) | 选择时间时触发该事件。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-toggle.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-toggle.md index bc0135a0c148d096edace00341da05f068d43a55..949cd14f77d1311bc4b4bbc10c8e8a16baabe02d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-toggle.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-toggle.md @@ -6,10 +6,6 @@ > > 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - - - ## 子组件 仅当ToggleType为Button时可包含子组件。 @@ -25,7 +21,7 @@ Toggle(options: { type: ToggleType, isOn?: boolean }) | 参数名 | 参数类型 | 必填 | 参数描述 | | ---- | ---------- | -----| -------------- | -| type | [ToggleType](#toggletype枚举说明) | 是 | 开关类型。 | +| type | [ToggleType](#toggletype枚举说明) | 是 | 开关的样式。 | | isOn | boolean | 否 | 开关是否打开,true:打开,false:关闭。
默认值:false | @@ -35,24 +31,26 @@ Toggle(options: { type: ToggleType, isOn?: boolean }) | 名称 | 描述 | | -------- | ---------------- | -| Checkbox | 提供单选框样式。
**说明:**
[通用属性padding](ts-universal-attributes-size.md)的默认值为:
{
 top: 14 vp,
 right: 6 vp,
 bottom: 14 vp,
 left: 6 vp
} | +| Checkbox | 提供单选框样式。
**说明:**
[通用属性margin](ts-universal-attributes-size.md)的默认值为:
{
 top: 12 vp,
 right: 12 vp,
 bottom: 12 vp,
 left: 12 vp
} | | Button | 提供状态按钮样式,如果子组件有文本设置,则相应的文本内容会显示在按钮内部。 | -| Switch | 提供开关样式。
**说明:**
[通用属性padding](ts-universal-attributes-size.md)默认值为:
{
 top: 12 vp,
 right: 12 vp,
 bottom: 12 vp,
 left: 12 vp
} | - +| Switch | 提供开关样式。
**说明:**
[通用属性margin](ts-universal-attributes-size.md)默认值为:
{
 top: 14 vp,
 right:6 vp,
 bottom: 6 vp,
 left: 14 vp
} | ## 属性 +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + | 名称 | 参数 | 参数描述 | | ---------------- | --------------------------- | ---------------------- | | selectedColor | [ResourceColor](ts-types.md#resourcecolor) | 设置组件打开状态的背景颜色。
从API version 9开始,该接口支持在ArkTS卡片中使用。| | switchPointColor | [ResourceColor](ts-types.md#resourcecolor) | 设置Switch类型的圆形滑块颜色。
**说明:**
仅对type为ToggleType.Switch生效。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | - ## 事件 +除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: + | 名称 | 功能描述 | | -------- | -------- | -| onChange(callback: (isOn: boolean) => void) | 开关状态切换时触发该事件。
从API version 9开始,该接口支持在ArkTS卡片中使用。| +| onChange(callback: (isOn: boolean) => void) | 开关状态切换时触发该事件。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
isOn为true时,代表状态从关切换为开。isOn为false时,代表状态从开切换为关。 | ## 示例 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 e0541598d1273d8cd0912af47f5c4b93e92eae87..afb97ce43429073227f53a53f7d7982eb069776a 100755 --- 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 @@ -534,6 +534,7 @@ mediaPlayGestureAccess(access: boolean) multiWindowAccess(multiWindow: boolean) 设置是否开启多窗口权限,默认不开启。 +使能多窗口权限时,需要实现onWindowNew事件,示例代码参考[onWindowNew事件](#onwindownew9)。 **参数:** @@ -554,7 +555,7 @@ multiWindowAccess(multiWindow: boolean) build() { Column() { Web({ src: 'www.example.com', controller: this.controller }) - .multiWindowAccess(true) + .multiWindowAccess(false) } } } @@ -1261,19 +1262,50 @@ allowWindowOpenMethod(flag: boolean) ```ts // xxx.ets import web_webview from '@ohos.web.webview' + //在同一page页有两个web组件。在WebComponent新开窗口时,会跳转到NewWebViewComp。 + @CustomDialog + struct NewWebViewComp { + controller: CustomDialogController + webviewController1: web_webview.WebviewController + build() { + Column() { + Web({ src: "", controller: this.webviewController1 }) + .javaScriptAccess(true) + .multiWindowAccess(false) + .onWindowExit(()=> { + console.info("NewWebViewComp onWindowExit") + this.controller.close() + }) + } + } + } + @Entry @Component struct WebComponent { controller: web_webview.WebviewController = new web_webview.WebviewController() - @State access: boolean = true - @State multiWindow: boolean = true - @State flag: boolean = true + dialogController: CustomDialogController = null build() { Column() { Web({ src: 'www.example.com', controller: this.controller }) - .javaScriptAccess(this.access) - .multiWindowAccess(this.multiWindow) - .allowWindowOpenMethod(this.flag) + .javaScriptAccess(true) + //需要使能multiWindowAccess + .multiWindowAccess(true) + .allowWindowOpenMethod(true) + .onWindowNew((event) => { + if (this.dialogController) { + this.dialogController.close() + } + let popController:web_webview.WebviewController = new web_webview.WebviewController() + this.dialogController = new CustomDialogController({ + builder: NewWebViewComp({webviewController1: popController}) + }) + this.dialogController.open() + //将新窗口对应WebviewController返回给Web内核。 + //如果不需要打开新窗口请调用event.handler.setWebController接口设置成null。 + //若不调用event.handler.setWebController接口,会造成render进程阻塞。 + event.handler.setWebController(popController) + }) } } } @@ -2719,7 +2751,9 @@ onFullScreenExit(callback: () => void) onWindowNew(callback: (event: {isAlert: boolean, isUserTrigger: boolean, targetUrl: string, handler: ControllerHandler}) => void) -通知用户新建窗口请求。 +使能multiWindowAccess情况下,通知用户新建窗口请求。 +若不调用event.handler.setWebController接口,会造成render进程阻塞。 +如果不需要打开新窗口,在调用event.handler.setWebController接口时须设置成null。 **参数:** @@ -2735,19 +2769,51 @@ onWindowNew(callback: (event: {isAlert: boolean, isUserTrigger: boolean, targetU ```ts // xxx.ets import web_webview from '@ohos.web.webview' + + //在同一page页有两个web组件。在WebComponent新开窗口时,会跳转到NewWebViewComp。 + @CustomDialog + struct NewWebViewComp { + controller: CustomDialogController + webviewController1: web_webview.WebviewController + build() { + Column() { + Web({ src: "", controller: this.webviewController1 }) + .javaScriptAccess(true) + .multiWindowAccess(false) + .onWindowExit(()=> { + console.info("NewWebViewComp onWindowExit") + this.controller.close() + }) + } + } + } + @Entry @Component struct WebComponent { controller: web_webview.WebviewController = new web_webview.WebviewController() + dialogController: CustomDialogController = null build() { Column() { - Web({ src:'www.example.com', controller: this.controller }) - .multiWindowAccess(true) - .onWindowNew((event) => { - console.log("onWindowNew...") - var popController: web_webview.WebviewController = new web_webview.WebviewController() - event.handler.setWebController(popController) - }) + Web({ src: 'www.example.com', controller: this.controller }) + .javaScriptAccess(true) + //需要使能multiWindowAccess + .multiWindowAccess(true) + .allowWindowOpenMethod(true) + .onWindowNew((event) => { + if (this.dialogController) { + this.dialogController.close() + } + let popController:web_webview.WebviewController = new web_webview.WebviewController() + this.dialogController = new CustomDialogController({ + builder: NewWebViewComp({webviewController1: popController}) + }) + this.dialogController.open() + //将新窗口对应WebviewController返回给Web内核。 + //如果不需要打开新窗口请调用event.handler.setWebController接口设置成null。 + //若不调用event.handler.setWebController接口,会造成render进程阻塞。 + event.handler.setWebController(popController) + }) } } } @@ -3174,13 +3240,13 @@ exitFullScreen(): void setWebController(controller: WebviewController): void -设置WebviewController对象。 +设置WebviewController对象,如果不需要打开新窗口请设置为null。 **参数:** | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | | ---------- | ------------- | ---- | ---- | ------------------------- | -| controller | [WebviewController](../apis/js-apis-webview.md#webviewcontroller) | 是 | - | 新建web组件的的WebviewController对象。 | +| controller | [WebviewController](../apis/js-apis-webview.md#webviewcontroller) | 是 | - | 新建web组件的WebviewController对象,如果不需要打开新窗口请设置为null。 | ## WebResourceError diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md index e810ec960e554e29a36275ff78400e3e6da2a499..238a97c6c63944bd1c75906b5ea9f98dc2212d1c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md @@ -17,7 +17,7 @@ PanGesture(value?: { fingers?: number; direction?: PanDirection; distance?: numb | 参数名称 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| fingers | number | 否 | 触发拖动的最少手指数,最小为1指, 最大取值为10指。
默认值:1 | +| fingers | number | 否 | 触发拖动的最少手指数,最小为1指, 最大取值为10指。
默认值:1
取值范围:[1,10]
**说明:**
当设置的值小于1或不设置时,会被转化为默认值。 | | direction | PanDirection | 否 | 触发拖动的手势方向,此枚举值支持逻辑与(&)和逻辑或(\|)运算。
默认值:PanDirection.All | | distance | number | 否 | 最小拖动识别距离,单位为vp。
默认值:5
**说明:**
[Tabs组件](ts-container-tabs.md)滑动与该拖动手势事件同时存在时,可将distance值设为1,使拖动更灵敏,避免造成事件错乱。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md index 8abf78ab1d71dbdb0b6d16b3c427f1f984af61de..e8752dc730b6322f37664478b457bbc7291c5f59 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md @@ -1,6 +1,6 @@ # TapGesture -支持单次或多次点击识别。 +支持单击、双击和多次点击事件的识别。 > **说明:** > @@ -15,8 +15,8 @@ TapGesture(value?: { count?: number, fingers?: number }) | 参数名称 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| count | number | 否 | 识别的连续点击次数。如果设置小于1,会被转化为默认值。
默认值:1
**说明:**
如配置多击,上一次抬起和下一次按下的超时时间为300毫秒。 | -| fingers | number | 否 | 触发点击的手指数,最小为1指, 最大为10指。
默认值:1
**说明:**
1. 当配置多指时,第一根手指按下后300毫秒内未有足够的手指数按下,手势识别失败。
2. 实际点击手指数超过配置值,手势识别失败。 | +| count | number | 否 | 识别的连续点击次数。当设置的值小于1或不设置时,会被转化为默认值。
默认值:1
**说明:**
如配置多击,上一次抬起和下一次按下的超时时间为300毫秒。 | +| fingers | number | 否 | 触发点击的手指数,最小为1指, 最大为10指。当设置小于1的值或不设置时,会被转化为默认值。
默认值:1
**说明:**
1. 当配置多指时,第一根手指按下后300毫秒内未有足够的手指数按下,手势识别失败。
2. 实际点击手指数超过配置值,手势识别失败。 | ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md b/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md index fed857649de4d14d3028fd5b2ab535431f619a29..6504c28f9530a96cc49e936c6f884e7859e12187 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md @@ -293,7 +293,7 @@ 提供卡片组件,实现卡片的显示功能。 - [Menu](ts-basic-components-menu.md) - 以垂直列表形式显示的菜单,优先用于PC端的菜单开发。 + 以垂直列表形式显示的菜单。 - [MenuItem](ts-basic-components-menuitem.md) 用来展示菜单Menu中具体的item菜单项。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md index 0f51f9689d3950555c31f283e2f2b87ea998eeaf..94f2a294869b0ccf6009b66f1d9bcb63119bf43a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md @@ -27,8 +27,8 @@ AlphabetIndexer(value: {arrayValue: Array<string>, selected: number}) 除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: -| 名称 | 参数类型 | 描述 | -| ----------------------- | --------------- | ----------------------------------------------------------- | +| 名称 | 参数类型 | 描述 | +| ----------------------- | --------------------| ------------------------------------------------------------------| | color | [ResourceColor](ts-types.md#resourcecolor) | 设置文字颜色。
默认值:0x99000000。 | | selectedColor | [ResourceColor](ts-types.md#resourcecolor) | 设置选中项文字颜色。
默认值:0xFF254FF7。 | | popupColor | [ResourceColor](ts-types.md#resourcecolor) | 设置提示弹窗文字颜色。
默认值:0xFF254FF7。 | @@ -39,9 +39,13 @@ AlphabetIndexer(value: {arrayValue: Array<string>, selected: number}) | popupFont | [Font](ts-types.md#font) | 设置提示弹窗字体样式。
默认值:
{
size:10,
style:FontStyle.Normal,
weight:FontWeight.Normal,
family:'HarmonyOS Sans'
} | | font | [Font](ts-types.md#font) | 设置字母索引条默认字体样式。
默认值:
{
size:10,
style:FontStyle.Normal,
weight:FontWeight.Normal,
family:'HarmonyOS Sans'
} | | itemSize | string \| number | 设置字母索引条字母区域大小,字母区域为正方形,即正方形边长。不支持设置为百分比。
默认值:24.0。 | -| alignStyle | IndexerAlign | 设置字母索引条弹框的对齐样式,支持弹窗显示在索引条右侧和左侧。
默认值:IndexerAlign.Right。 | +| alignStyle | value: [IndexerAlign](#indexeralign枚举说明),
offset10+?: [Length](ts-types.md#length) | value:设置字母索引条弹框的对齐样式,支持弹窗显示在索引条右侧和左侧。
默认值: IndexerAlign.Right。
offset:设置提示弹窗与索引条之间间距,大于等于0为有效值,在不设置或设置为小于0的情况下间距与popupPosition.x相同。 | | selected | number | 设置选中项索引值。
默认值:0。 | | popupPosition | [Position](ts-types.md#position8) | 设置弹出窗口相对于索引器条上边框中点的位置。
默认值:{x:96.0, y:48.0}。 | +| popupSelectedColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 设置提示弹窗非字母部分选中文字色。
默认值:#FF182431 | +| popupUnselectedColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 设置提示弹窗非字母部分未选中文字色。
默认值:#FF182431 | +| popupItemFont10+ | [Font](ts-types.md#font) | 设置提示弹窗非字母部分字体样式。
默认值:
{
size:24,
style:FontStyle.Medium
}| +| popupItemBackgroundColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 设置提示弹窗非字母部分背景色。
默认值:#FFFFFF | ## IndexerAlign枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md index 6161e5389802ff6b94d72cbb3878b00fe16286a7..89b012e6a400ccf07a4237c1c9117074453607fa 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md @@ -57,12 +57,15 @@ 从API version 9开始,该接口支持在ArkTS卡片中使用。 -| 名称 | 类型 | 必填 | 默认值 | 描述 | -| ---------- | ------------------------------------------ | ---- | ----------- | ------------------------------------------- | -| color | [ResourceColor](ts-types.md#resourcecolor) | 否 | Color.White | 文本颜色。 | -| fontSize | number \| string | 否 | 10 | 文本大小,单位vp。 | -| badgeSize | number \| string | 否 | 16 | Badge的大小,单位vp。不支持百分比形式设置。当设置为非法值时,按照默认值处理。 | -| badgeColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | Color.Red | Badge的颜色。 | +| 名称 | 类型 | 必填 | 默认值 | 描述 | +| ------------------------- | ------------------------------------------------------------ | ---- | ----------------- | ------------------------------------------------------------ | +| color | [ResourceColor](ts-types.md#resourcecolor) | 否 | Color.White | 文本颜色。 | +| fontSize | number \| string | 否 | 10 | 文本大小,单位vp。 | +| badgeSize | number \| string | 否 | 16 | Badge的大小,单位vp。不支持百分比形式设置。当设置为非法值时,按照默认值处理。 | +| badgeColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | Color.Red | Badge的颜色。 | +| fontWeight10+ | number \|[FontWeight](ts-appendix-enums.md#fontweight) \| string | 否 | FontWeight.Normal | 设置文本的字体粗细。 | +| borderColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 否 | Color.Red | 底板描边颜色。 | +| borderWidth10+ | [Length](ts-types.md#length) | 否 | 1.0vp | 底板描边粗细。 | ## 示例 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 a3a4e9b6c6dff24a44963b3b481fe9255f01d86c..fdc53cc542335c703974b7a40857b004983199d1 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 @@ -22,7 +22,7 @@ Column(value?: {space?: string | number}) | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| space | string \| number | 否 | 纵向布局元素垂直方向间距。
从API version 9开始,space为负数或者justifyContent设置为FlexAlign.SpaceBetween、FlexAlign.SpaceAround、FlexAlign.SpaceEvenly时不生效。
默认值:0 | +| space | string \| number | 否 | 纵向布局元素垂直方向间距。
从API version 9开始,space为负数或者justifyContent设置为FlexAlign.SpaceBetween、FlexAlign.SpaceAround、FlexAlign.SpaceEvenly时不生效。
默认值:0
**说明:**
可选值为大于等于0的数字,或者可以转换为数字的字符串。 | ## 属性 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-counter.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-counter.md index ff574a2ceb332fad15eacb6dc2c7aa2f95fbde56..13867745c882b6ee060fe8b79b8cd299ea9e6732 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-counter.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-counter.md @@ -18,6 +18,10 @@ Counter() 从API version 9开始,该接口支持在ArkTS卡片中使用。 +## 属性 + +支持[通用属性](ts-universal-attributes-size.md)。 + ## 事件 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 883884c91567ff4d775893dcfbaa21b1012eff18..841748e13e542cc41c8e4ba01308c2b28ccf6812 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 @@ -6,6 +6,7 @@ > > - 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > - Flex组件在渲染时存在二次布局过程,因此在对性能有严格要求的场景下建议使用[Column](ts-container-column.md)、[Row](ts-container-row.md)代替。 +> - Flex组件主轴默认不设置时撑满父容器,[Column](ts-container-column.md)、[Row](ts-container-row.md)组件主轴不设置时默认是跟随子节点大小。 ## 子组件 @@ -26,9 +27,9 @@ Flex(value?: { direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: Fle | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | | -------------- | ---------------------------------------- | ---- | ----------------- | ---------------------------------------- | | direction | [FlexDirection](ts-appendix-enums.md#flexdirection) | 否 | FlexDirection.Row | 子组件在Flex容器上排列的方向,即主轴的方向。 | -| wrap | [FlexWrap](ts-appendix-enums.md#flexwrap) | 否 | FlexWrap.NoWrap | Flex容器是单行/列还是多行/列排列。 | -| justifyContent | [FlexAlign](ts-appendix-enums.md#flexalign) | 否 | FlexAlign.Start | 子组件在Flex容器主轴上的对齐格式。 | -| alignItems | [ItemAlign](ts-appendix-enums.md#itemalign) | 否 | ItemAlign.Start | 子组件在Flex容器交叉轴上的对齐格式。 | +| wrap | [FlexWrap](ts-appendix-enums.md#flexwrap) | 否 | FlexWrap.NoWrap | Flex容器是单行/列还是多行/列排列。
**说明:**
在多行布局时,通过交叉轴方向,确认新行堆叠方向。 | +| justifyContent | [FlexAlign](ts-appendix-enums.md#flexalign) | 否 | FlexAlign.Start | 所有子组件在Flex容器主轴上的对齐格式。 | +| alignItems | [ItemAlign](ts-appendix-enums.md#itemalign) | 否 | ItemAlign.Start | 所以子组件在Flex容器交叉轴上的对齐格式。 | | alignContent | [FlexAlign](ts-appendix-enums.md#flexalign) | 否 | FlexAlign.Start | 交叉轴中有额外的空间时,多行内容的对齐方式。仅在wrap为Wrap或WrapReverse下生效。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md index ef8f2337eab6c6962066120ba4f6af42c41c42d0..837e139eda12d17eef6a47e15de921e125484179 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md @@ -9,7 +9,21 @@ ## 子组件 -包含[GridItem](ts-container-griditem.md)子组件。 +仅支持[GridItem](ts-container-griditem.md)子组件。 + +> **说明:** +> +> Grid子组件的索引值计算规则: +> +> 按子组件的顺序依次递增。 +> +> if/else语句中,只有条件成立分支内的子组件会参与索引值计算,条件不成立分支内的子组件不计算索引值。 +> +> ForEach/LazyForEach语句中,会计算展开所有子节点索引值。 +> +> if/else/ForEach/LazyForEach发生变化以后,会更新子节点索引值。 +> +> Grid子组件的visibility属性设置为Hidden或None时依然会计算索引值。 ## 接口 @@ -18,9 +32,9 @@ Grid(scroller?: Scroller) **参数:** -| 参数名 | 参数类型 | 必填 | 参数描述 | -| --------- | ---------------------------------------- | ---- | ----------------------- | -| scroller | [Scroller](ts-container-scroll.md#scroller) | 否 | 可滚动组件的控制器。用于与可滚动组件进行绑定。 | +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------- | ------------------------------------------- | ---- | ------------------------------------------------------------ | +| scroller | [Scroller](ts-container-scroll.md#scroller) | 否 | 可滚动组件的控制器。用于与可滚动组件进行绑定。
**说明:**
不允许和其他[滚动类组件](ts-container-list.md)绑定同一个滚动控制对象。 | ## 属性 @@ -28,41 +42,57 @@ Grid(scroller?: Scroller) | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| columnsTemplate | string | 设置当前网格布局列的数量,不设置时默认1列。
例如, '1fr 1fr 2fr' 是将父组件分3列,将父组件允许的宽分为4等份,第一列占1份,第二列占1份,第三列占2份。| -| rowsTemplate | string | 设置当前网格布局行的数量,不设置时默认1行。
例如, '1fr 1fr 2fr'是将父组件分三行,将父组件允许的高分为4等份,第一行占1份,第二行占一份,第三行占2份。 | -| columnsGap | Length | 设置列与列的间距。
默认值:0 | -| rowsGap | Length | 设置行与行的间距。
默认值:0 | +| columnsTemplate | string | 设置当前网格布局列的数量,不设置时默认1列。
例如, '1fr 1fr 2fr' 是将父组件分3列,将父组件允许的宽分为4等份,第一列占1份,第二列占1份,第三列占2份。
**说明:**
设置为'0fr'时,该列的列宽为0,不显示GridItem。设置为其他非法值时,GridItem显示为固定1列。 | +| rowsTemplate | string | 设置当前网格布局行的数量,不设置时默认1行。
例如, '1fr 1fr 2fr'是将父组件分三行,将父组件允许的高分为4等份,第一行占1份,第二行占一份,第三行占2份。
**说明:**
设置为'0fr',则这一行的行宽为0,这一行GridItem不显示。设置为其他非法值,按固定1行处理。 | +| columnsGap | [Length](ts-types.md#length) | 设置列与列的间距。
默认值:0
**说明:**
设置为小于0的值时,按默认值显示。 | +| rowsGap | [Length](ts-types.md#length) | 设置行与行的间距。
默认值:0
**说明:**
设置为小于0的值时,按默认值显示。 | | scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。
默认值:BarState.Off | -| scrollBarColor | string \| number \| Color | 设置滚动条的颜色。 | -| scrollBarWidth | string \| number | 设置滚动条的宽度。 | -| cachedCount | number | 设置预加载的GridItem的数量。具体使用可参考[减少应用白块说明](../../ui/ui-ts-performance-improvement-recommendation.md#减少应用滑动白块)。
默认值:1 | +| scrollBarColor | string \| number \| [Color](ts-appendix-enums.md#color) | 设置滚动条的颜色。 | +| scrollBarWidth | string \| number | 设置滚动条的宽度。宽度设置后,滚动条正常状态和按压状态宽度均为滚动条的宽度值。
默认值:4
单位:vp | +| cachedCount | number | 设置预加载的GridItem的数量,只在[LazyForEach](../../quick-start/arkts-rendering-control.md#数据懒加载)中生效。具体使用可参考[减少应用白块说明](../../ui/ui-ts-performance-improvement-recommendation.md#减少应用滑动白块)。
默认值:1
**说明:**
设置缓存后会在Grid显示区域上下各缓存cachedCount*列数个GridItem。
[LazyForEach](../../quick-start/arkts-rendering-control.md#数据懒加载)超出显示和缓存范围的GridItem会被释放。
设置为小于0的值时,按默认值显示。 | | editMode 8+ | boolean | 设置Grid是否进入编辑模式,进入编辑模式可以拖拽Grid组件内部[GridItem](ts-container-griditem.md)。
默认值:flase | | layoutDirection8+ | [GridDirection](#griddirection8枚举说明) | 设置布局的主轴方向。
默认值:GridDirection.Row | -| maxCount8+ | number | 当layoutDirection是Row/RowReverse时,表示可显示的最大列数
当layoutDirection是Column/ColumnReverse时,表示可显示的最大行数。
默认值:Infinity | -| minCount8+ | number | 当layoutDirection是Row/RowReverse时,表示可显示的最小列数。
当layoutDirection是Column/ColumnReverse时,表示可显示的最小行数。
默认值:1 | +| maxCount8+ | number | 当layoutDirection是Row/RowReverse时,表示可显示的最大列数
当layoutDirection是Column/ColumnReverse时,表示可显示的最大行数。
默认值:Infinity
**说明:**
当maxCount小于minCount时,maxCount和minCount都按默认值处理。
设置为小于0的值时,按默认值显示。 | +| minCount8+ | number | 当layoutDirection是Row/RowReverse时,表示可显示的最小列数。
当layoutDirection是Column/ColumnReverse时,表示可显示的最小行数。
默认值:1
**说明:**
设置为小于0的值时,按默认值显示。 | | cellLength8+ | number | 当layoutDirection是Row/RowReverse时,表示一行的高度。
当layoutDirection是Column/ColumnReverse时,表示一列的宽度。
默认值:第一个元素的大小 | | multiSelectable8+ | boolean | 是否开启鼠标框选。
默认值:false
- false:关闭框选。
- true:开启框选。 | -| supportAnimation8+ | boolean | 是否支持动画。
默认值:false | +| supportAnimation8+ | boolean | 是否支持动画。当前支持GridItem拖拽动画。
默认值:false | Grid组件根据rowsTemplate、columnsTemplate属性的设置情况,可分为以下三种布局模式: 1、rowsTemplate、columnsTemplate同时设置: -Grid只展示固定行列数的元素,其余元素不展示,且Grid不可滚动。例如rowsTemplate、columnsTemplate都设置为"1fr 1fr"时,则仅展示两行两列,共4个元素,其他元素不展示。 - -此模式下以下属性不生效:layoutDirection、maxCount、minCount、cellLength。 +- Grid只展示固定行列数的元素,其余元素不展示,且Grid不可滚动。 +- 此模式下以下属性不生效:layoutDirection、maxCount、minCount、cellLength。 +- Grid的宽高没有设置时,默认适应父组件尺寸。 +- Gird网格列大小按照Gird自身内容区域大小减去所有行列Gap后按各个行列所占比重分配。 +- GridItem默认填满网格大小。 +- 此模式下GridItem同时设置了rowStart、columnStart,会用设置的rowStart、columnStart所在位置摆放GridItem。如果这个位置已经有GridItem则会发生重叠。 +- 如果GridItem设置了rowStart、columnStart其中一个,会从上一个GridItem布局位置开始遍历寻找满足rowStart或columnStart的空闲位置摆放,如果无满足条件的空闲位置,则不布局该GridItem。 +- 如果GridItem的rowStart、columnStart属性都没有设置,会从上一个GridItem布局位置开始遍历寻找空闲位置摆放,如果没有空闲位置,则不布局该GridItem。 +- 如果GridItem的rowEnd有设置,但是rowStart没有设置,当做rowStart已经设置,并且和rowEnd设置为相同值。如果GridItem的columnEnd有设置,但是columnStart没有设置,当做columnStart已经设置,并且和columnEnd设置为相同值。 2、rowsTemplate、columnsTemplate仅设置其中的一个: -元素按照设置的方向进行排布,超出的元素可通过滚动的方式展示。例如Grid有十个元素,且设置columnsTemplate为"1fr 1fr 1fr",则Grid有三列,元素先填满一行,再填充下一行。在Grid区域外的元素,可通过竖直方向的滚动,进行展示。 - -此模式下以下属性不生效:layoutDirection、maxCount、minCount、cellLength。 +- 元素按照设置的方向进行排布,超出Grid显示区域后,Grid可通过滚动的方式展示。 +- 如果设置了columnsTemplate,Gird滚动方向为垂直方向,主轴方向为垂直方向,交叉轴方向为水平方向。 +- 如果设置了rowsTemplate,Gird滚动方向为水平方向,主轴方向为水平方向,交叉轴方向为垂直方向。 +- 此模式下以下属性不生效:layoutDirection、maxCount、minCount、cellLength。 +- 网格交叉轴方向尺寸根据Gird自身内容区域交叉轴尺寸减去交叉轴方向所有Gap后按所占比重分配。 +- 网格主轴方向尺寸取当前网格交叉轴方向所有GridItem高度最大值。 +- 此模式下GridItem同时设置了rowStart、columnStart,会用设置的rowStart、columnStart所在位置摆放GridItem。如果这个位置已经有GridItem则会发生重叠。 +- 如果GridItem设置了rowStart、columnStart其中一个,会从上一个GridItem布局位置开始遍历寻找满足rowStart或columnStart的空闲位置摆放。 +- 如果GridItem的rowStart、columnStart属性都没有设置,会从上一个GridItem布局位置开始遍历寻找空闲位置摆放。 +- 如果GridItem的rowEnd有设置,但是rowStart没有设置,当做rowStart已经设置,并且和rowEnd设置为相同值。如果GridItem的columnEnd有设置,但是columnStart没有设置,当做columnStart已经设置,并且和columnEnd设置为相同值。 3、rowsTemplate、columnsTemplate都不设置: -元素在layoutDirection方向上排布,列数由Grid的宽度、首个元素的宽度、minCount、maxCount、columnsGap共同决定;行数由Grid高度、首个元素高度、cellLength、rowsGap共同决定。超出行列容纳范围的元素不显示,也不能通过滚动进行展示。 - -此模式下仅生效以下属性:layoutDirection、maxCount、minCount、cellLength、editMode、columnsGap、rowsGap。 +- 元素在layoutDirection方向上排布,列数由Grid的宽度、首个元素的宽度、minCount、maxCount、columnsGap共同决定。 +- 行数由Grid高度、首个元素高度、cellLength、rowsGap共同决定。超出行列容纳范围的元素不显示,也不能通过滚动进行展示。 +- 此模式下仅生效以下属性:layoutDirection、maxCount、minCount、cellLength、editMode、columnsGap、rowsGap。 +- 当前layoutDirection设置为Row时,先从左到右排列,排满一行再排一下一列。剩余高度不足时不再布局,整体内容顶部居中。 +- 当前layoutDirection设置为Column时,先从上到下排列,排满一列再排一下一列,剩余宽度度不足时不再。整体内容顶部居中。 +- 此模式下GridItem的rowStart、columnStart不生效。 ## GridDirection8+枚举说明 @@ -73,14 +103,18 @@ Grid只展示固定行列数的元素,其余元素不展示,且Grid不可滚 | RowReverse | 主轴布局方向沿水平方向反向布局,即自右往左先填满一行,再去填下一行。 | | ColumnReverse | 主轴布局方向沿垂直方向反向布局,即自下往上先填满一列,再去填下一列。 | +> **说明:** +> +> List组件[通用属性clip](ts-universal-attributes-sharp-clipping.md)的默认值为true。 + ## 事件 除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: | 名称 | 功能描述 | | -------- | -------- | -| onScrollIndex(event: (first: number) => void) | 当前网格显示的起始位置item发生变化时触发。
- first: 当前显示的网格起始位置的索引值。 | -| onItemDragStart(event: (event: ItemDragInfo, itemIndex: number) => (() => any) \| void) | 开始拖拽网格元素时触发。
- event: 见[ItemDragInfo对象说明](#itemdraginfo对象说明)。
- itemIndex: 被拖拽网格元素索引值。 | +| onScrollIndex(event: (first: number) => void) | 当前网格显示的起始位置item发生变化时触发。列表初始化时会触发一次。
- first: 当前显示的网格起始位置的索引值。
Grid显示区域上第一个子组件的索引值有变化就会触发。 | +| onItemDragStart(event: (event: ItemDragInfo, itemIndex: number) => (() => any) \| void) | 开始拖拽网格元素时触发。
- event: 见[ItemDragInfo对象说明](#itemdraginfo对象说明)。
- itemIndex: 被拖拽网格元素索引值。
**说明:**
返回void表示不能拖拽。
手指长按GridItem时触发该事件。 | | onItemDragEnter(event: (event: ItemDragInfo) => void) | 拖拽进入网格元素范围内时触发。
- event: 见[ItemDragInfo对象说明](#itemdraginfo对象说明)。 | | onItemDragMove(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void) | 拖拽在网格元素范围内移动时触发。
- event: 见[ItemDragInfo对象说明](#itemdraginfo对象说明)。
- itemIndex: 拖拽起始位置。
- insertIndex: 拖拽插入位置。 | | onItemDragLeave(event: (event: ItemDragInfo, itemIndex: number) => void) | 拖拽离开网格元素时触发。
- event: 见[ItemDragInfo对象说明](#itemdraginfo对象说明)。
- itemIndex: 拖拽离开的网格元素索引值。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-gridrow.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-gridrow.md index ffa1b45018c52a81e4a2eb1176a85d960babcd1a..ff4fce4cb2691b29c509187627ce8911d8585686 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-gridrow.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-gridrow.md @@ -126,7 +126,11 @@ GridRow(option?: {columns?: number | GridRowColumnOption, gutter?: Length | Gutt ## 属性 -支持[通用属性](ts-universal-attributes-size.md)。 +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + +| 名称 | 参数类型 | 描述 | +| ----------------------- | ----------------------------------- | ------------------------------------------- | +| alignItems10+ | [ItemAlign](ts-appendix-enums.md#itemalign) | 设置GridRow中的GridCol垂直主轴方向对齐方式,默认值:ItemAlign.Start
说明:
GridCol本身也可通过alignSelf([ItemAlign](ts-appendix-enums.md#itemalign))设置自身对齐方式。当上述两种对齐方式都设置时,以GridCol自身设置为准。
从API version 10开始,该接口支持在ArkTS卡片中使用。 | ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md index d8efdcba02ce93942ef2974c83aba4b8a829137d..4a6ba919efbb06c8b77c66add018249b35ae3ef8 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md @@ -10,7 +10,23 @@ ## 子组件 -包含[ListItem](ts-container-listitem.md)、[ListItemGroup](ts-container-listitemgroup.md)子组件。 +仅支持[ListItem](ts-container-listitem.md)、[ListItemGroup](ts-container-listitemgroup.md)子组件。 + +> **说明:** +> +> List的子组件的索引值计算规则: +> +> 按子组件的顺序依次递增。 +> +> if/else语句中,只有条件成立的分支内的子组件会参与索引值计算,条件不成立的分支内子组件不计算索引值。 +> +> ForEach/LazyForEach语句中,会计算展开所有子节点索引值。 +> +> if/else/ForEach/LazyForEach发生变化以后,会更新子节点索引值。 +> +> ListItemGroup作为一个整体计算一个索引值,ListItemGroup内部的ListItem不计算索引值。 +> +> List子组件visibility属性设置为Hidden或None依然会计算索引值。 ## 接口 @@ -23,9 +39,9 @@ List(value?:{space?: number | string, initialIndex?: number, scroller? | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| space | number \| string | 否 | 列表项间距。
默认值:0 | -| initialIndex | number | 否 | 设置当前List初次加载时视口起始位置显示的item的索引值。如果设置的值超过了当前List最后一个item的索引值,则设置不生效。
默认值:0 | -| scroller | [Scroller](ts-container-scroll.md#scroller) | 否 | 可滚动组件的控制器。用于与可滚动组件进行绑定。 | +| space | number \| string | 否 | 子组件主轴方向的间隔。
默认值:0
**说明:**
设置为除-1外其他负数或百分比时,按默认值显示。
space参数值小于List分割线宽度时,子组件主轴方向的间隔取分割线宽度。 | +| initialIndex | number | 否 | 设置当前List初次加载时视口起始位置显示的item的索引值。
默认值:0
**说明:**
设置为除-1外其他负数或超过了当前List最后一个item的索引值时视为无效取值,无效取值按默认值显示。 | +| scroller | [Scroller](ts-container-scroll.md#scroller) | 否 | 可滚动组件的控制器。用于与可滚动组件进行绑定。
**说明:**
不允许和其他滚动类组件绑定同一个滚动控制对象。 | ## 属性 @@ -34,16 +50,16 @@ List(value?:{space?: number | string, initialIndex?: number, scroller? | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | listDirection | [Axis](ts-appendix-enums.md#axis) | 设置List组件排列方向。
默认值:Axis.Vertical
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| divider | {
strokeWidth: [Length](ts-types.md#length),
color?:[ResourceColor](ts-types.md#resourcecolor),
startMargin?: Length,
endMargin?: Length
} \| null | 设置ListItem分割线样式,默认无分割线。
- strokeWidth: 分割线的线宽。
- color: 分割线的颜色。
- startMargin: 分割线与列表侧边起始端的距离。
- endMargin: 分割线与列表侧边结束端的距离。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| divider | {
strokeWidth: [Length](ts-types.md#length),
color?:[ResourceColor](ts-types.md#resourcecolor),
startMargin?: Length,
endMargin?: Length
} \| null | 设置ListItem分割线样式,不支持设置百分比,默认无分割线。
- strokeWidth: 分割线的线宽。
- color: 分割线的颜色。
- startMargin: 分割线与列表侧边起始端的距离。
- endMargin: 分割线与列表侧边结束端的距离。
从API version 9开始,该接口支持在ArkTS卡片中使用。
endMargin +startMargin 不能超过列宽度。
startMargin和endMargin不支持设置百分比。
List的分割线画在主轴方向两个子组件之间,第一个子组件上方和最后一个子组件下方不会绘制分割线。
多列模式下,ListItem与ListItem之间的分割线起始边距从每一列的交叉轴方向起始边开始计算,其他情况从List交叉轴方向起始边开始计算。 | | scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。
默认值:BarState.Off
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| cachedCount | number | 设置列表中ListItem/ListItemGroup的预加载数量,其中ListItemGroup将作为一个整体进行计算,ListItemGroup中的所有ListItem会一次性全部加载出来。具体使用可参考[减少应用白块说明](../../ui/ui-ts-performance-improvement-recommendation.md#减少应用滑动白块)。
默认值:1
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| cachedCount | number | 设置列表中ListItem/ListItemGroup的预加载数量,只在[LazyForEach](../../quick-start/arkts-rendering-control.md#数据懒加载)中生效,其中ListItemGroup将作为一个整体进行计算,ListItemGroup中的所有ListItem会一次性全部加载出来。具体使用可参考[减少应用白块说明](../../ui/ui-ts-performance-improvement-recommendation.md#减少应用滑动白块)。
默认值:1
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
单列模式下,会在List显示的ListItem前后各缓存cachedCount个ListItem。
多列模式下, 会在List显示的ListItem前后各缓存cachedCount*列数个ListItem。 | | editMode(deprecated) | boolean | 声明当前List组件是否处于可编辑模式。
从API version9开始废弃。
默认值:false | -| edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置组件的滑动效果。
默认值:EdgeEffect.Spring
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置组件的滑动效果,支持弹簧效果和阴影效果。
默认值:EdgeEffect.Spring
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | chainAnimation | boolean | 设置当前List是否启用链式联动动效,开启后列表滑动以及顶部和底部拖拽时会有链式联动的效果。链式联动效果:List内的list-item间隔一定距离,在基本的滑动交互行为下,主动对象驱动从动对象进行联动,驱动效果遵循弹簧物理动效。
默认值:false
- false:不启用链式联动。
- true:启用链式联动。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | multiSelectable8+ | boolean | 是否开启鼠标框选。
默认值:false
- false:关闭框选。
- true:开启框选。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| lanes9+ | number \| [LengthConstrain](ts-types.md#lengthconstrain) | 以列模式为例(listDirection为Axis.Vertical):
lanes用于决定List组件在交叉轴方向按几列布局。
默认值:1
规则如下:
- lanes为指定的数量时,根据指定的数量与List组件的交叉轴宽度来决定每列的宽度;
- lane设置了{minLength,maxLength}时,根据List组件的宽度自适应决定lanes数量(即列数),保证缩放过程中lane的宽度符合{minLength,maxLength}的限制。其中,minLength条件会被优先满足,即优先保证符合ListItem的宽度符合最小宽度限制。例如在列模式下,设置了{minLength: 40vp,maxLength: 60vp},则当List组件宽度为70vp时,ListItem为一列,并且根据alignListItem属性做靠左、居中或者靠右布局;当List组件宽度变化至80vp时,符合两倍的minLength,则ListItem自适应为两列。
该接口支持在ArkTS卡片中使用。 | -| alignListItem9+ | ListItemAlign | List交叉轴方向宽度大于ListItem交叉轴宽度 * lanes时,ListItem在List交叉轴方向的布局方式,默认为首部对齐。
默认值:ListItemAlign.Start
该接口支持在ArkTS卡片中使用。 | -| sticky9+ | StickyStyle | 配合[ListItemGroup](ts-container-listitemgroup.md)组件使用,设置ListItemGroup中header和footer是否要吸顶或吸底。
默认值:StickyStyle.None
该接口支持在ArkTS卡片中使用。
**说明:**
sticky属性可以设置为 StickyStyle.Header \| StickyStyle.Footer 以同时支持header吸顶和footer吸底。 | +| lanes9+ | number \| [LengthConstrain](ts-types.md#lengthconstrain) | 以列模式为例(listDirection为Axis.Vertical):
lanes用于决定List组件在交叉轴方向按几列布局。
默认值:1
规则如下:
- lanes为指定的数量时,根据指定的数量与List组件的交叉轴尺寸除以列数作为列的宽度。
- lanes设置了{minLength,maxLength}时,根据List组件的宽度自适应决定lanes数量(即列数),保证缩放过程中lane的宽度符合{minLength,maxLength}的限制。其中,minLength条件会被优先满足,即优先保证符合ListItem的交叉轴尺寸符合最小限制。
- lanes设置了{minLength,maxLength},如果父组件交叉轴方向尺寸约束为无穷大时,固定按一列排列,列宽度按显示区域内最大的ListItem计算
- ListItemGroup在多列模式下也是独占一行,ListItemGroup中的ListItem按照List组件的lanes属性设置值来布局。
- lanes设置了{minLength,maxLength}时,计算列数会按照ListItemGroup的交叉轴尺寸计算。当ListItemGroup交叉轴尺寸与List交叉轴尺寸不一致时ListItemGroup中的列数与List中的列数可能不一样。
该接口支持在ArkTS卡片中使用。 | +| alignListItem9+ | [ListItemAlign](#listitemalign9枚举说明) | List交叉轴方向宽度大于ListItem交叉轴宽度 * lanes时,ListItem在List交叉轴方向的布局方式,默认为首部对齐。
默认值:ListItemAlign.Start
该接口支持在ArkTS卡片中使用。 | +| sticky9+ | [StickyStyle](#stickystyle9枚举说明) | 配合[ListItemGroup](ts-container-listitemgroup.md)组件使用,设置ListItemGroup中header和footer是否要吸顶或吸底。
默认值:StickyStyle.None
该接口支持在ArkTS卡片中使用。
**说明:**
sticky属性可以设置为 StickyStyle.Header \| StickyStyle.Footer 以同时支持header吸顶和footer吸底。 | ## ListItemAlign9+枚举说明 @@ -62,21 +78,23 @@ List(value?:{space?: number | string, initialIndex?: number, scroller? | 名称 | 描述 | | ------ | -------------------------------------- | | None | ListItemGroup的header不吸顶,footer不吸底。 | -| Header | ListItemGroup的header吸顶。 | -| Footer | ListItemGroup的footer吸底。 | - +| Header | ListItemGroup的header吸顶,footer不吸底。 | +| Footer | ListItemGroup的footer吸底,header不吸底。 | +> **说明:** +> +> List组件[通用属性clip](ts-universal-attributes-sharp-clipping.md)的默认值为true。 ## 事件 | 名称 | 功能描述 | | -------- | -------- | | onItemDelete(deprecated)(event: (index: number) => boolean) | 当List组件在编辑模式时,点击ListItem右边出现的删除按钮时触发。
从API version9开始废弃。
- index: 被删除的列表项的索引值。 | -| onScroll(event: (scrollOffset: number, scrollState: ScrollState) => void) | 列表滑动时触发。
- scrollOffset: 滑动偏移量。
- [scrollState](#scrollstate枚举说明): 当前滑动状态。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| onScrollIndex(event: (start: number, end: number) => void) | 列表滑动时触发。
计算索引值时,ListItemGroup作为一个整体占一个索引值,不计算ListItemGroup内部ListItem的索引值。
- start: 滑动起始位置索引值。
- end: 滑动结束位置索引值。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| onReachStart(event: () => void) | 列表到达起始位置时触发。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| onReachEnd(event: () => void) | 列表到底末尾位置时触发。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| onScrollFrameBegin9+(event: (offset: number, state: ScrollState) => { offsetRemain }) | 列表开始滑动时触发,事件参数传入即将发生的滑动量,事件处理函数中可根据应用场景计算实际需要的滑动量并作为事件处理函数的返回值返回,列表将按照返回值的实际滑动量进行滑动。
\- offset:即将发生的滑动量。
\- state:当前滑动状态。
- offsetRemain:实际滑动量。
该接口支持在ArkTS卡片中使用。 | +| onScroll(event: (scrollOffset: number, scrollState: ScrollState) => void) | 列表滑动时触发。
- scrollOffset: 滑动偏移量。
- [scrollState](#scrollstate枚举说明): 当前滑动状态。
使用控制器调用ScrollEdge和ScrollToIndex时不会触发,其余情况有滚动就会触发该事件。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| onScrollIndex(event: (start: number, end: number) => void) | 有子组件划入或划出List显示区域时触发。
计算索引值时,ListItemGroup作为一个整体占一个索引值,不计算ListItemGroup内部ListItem的索引值。
- start: 滑动起始位置索引值。
- end: 滑动结束位置索引值。
触发该事件的条件:列表初始化时会触发一次,List显示区域内第一个子组件的索引值或后一个子组件的索引值有变化时会触发。
List的边缘效果为弹簧效果时,在List划动到边缘继续划动和松手回弹过程不会触发onScrollIndex事件。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| onReachStart(event: () => void) | 列表到达起始位置时触发。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
List初始化时如果initialIndex为0会触发一次,List滚动到起始位置时触发一次。List边缘效果为弹簧效果时,划动经过起始位置时触发一次,回弹回起始位置时再触发一次。 | +| onReachEnd(event: () => void) | 列表到底末尾位置时触发。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
List边缘效果为弹簧效果时,划动经过末尾位置时触发一次,回弹回末尾位置时再触发一次。 | +| onScrollFrameBegin9+(event: (offset: number, state: ScrollState) => { offsetRemain }) | 列表开始滑动时触发,事件参数传入即将发生的滑动量,事件处理函数中可根据应用场景计算实际需要的滑动量并作为事件处理函数的返回值返回,列表将按照返回值的实际滑动量进行滑动。
\- offset:即将发生的滑动量,单位vp。
\- state:当前滑动状态。
- offsetRemain:实际滑动量,单位vp。
触发该事件的条件:手指拖动List、List惯性划动时每帧开始时触发;List超出边缘回弹、使用滚动控制器的滚动不会触发。
该接口支持在ArkTS卡片中使用。
**说明:**
当listDirection的值为Axis.Vertical时,返回垂直方向滑动量,当listDirection的值为Axis.Horizontal时,返回水平方向滑动量。 | | onScrollStart9+(event: () => void) | 列表滑动开始时触发。手指拖动列表或列表的滚动条触发的滑动开始时,会触发该事件。使用[Scroller](ts-container-scroll.md#scroller)滑动控制器触发的带动画的滑动,动画开始时会触发该事件。
该接口支持在ArkTS卡片中使用。 | | onScrollStop(event: () => void) | 列表滑动停止时触发。手拖动列表或列表的滚动条触发的滑动,手离开屏幕并且滑动停止时会触发该事件;使用[Scroller](ts-container-scroll.md#scroller)滑动控制器触发的带动画的滑动,动画停止会触发该事件。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | onItemMove(event: (from: number, to: number) => boolean) | 列表元素发生移动时触发。
- from: 移动前索引值。
- to: 移动后索引值。 | @@ -84,7 +102,7 @@ List(value?:{space?: number | string, initialIndex?: number, scroller? | onItemDragEnter(event: (event: ItemDragInfo) => void) | 拖拽进入列表元素范围内时触发。
- event: 见[ItemDragInfo对象说明](ts-container-grid.md#itemdraginfo对象说明)。 | | onItemDragMove(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void) | 拖拽在列表元素范围内移动时触发。
- event: 见[ItemDragInfo对象说明](ts-container-grid.md#itemdraginfo对象说明)。
- itemIndex: 拖拽起始位置。
- insertIndex: 拖拽插入位置。 | | onItemDragLeave(event: (event: ItemDragInfo, itemIndex: number) => void) | 拖拽离开列表元素时触发。
- event: 见[ItemDragInfo对象说明](ts-container-grid.md#itemdraginfo对象说明)。
- itemIndex: 拖拽离开的列表元素索引值。 | -| onItemDrop(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void) | 绑定该事件的列表元素可作为拖拽释放目标,当在列表元素内停止拖拽时触发。
- event: 见[ItemDragInfo对象说明](ts-container-grid.md#itemdraginfo对象说明)。
- itemIndex: 拖拽起始位置。
- insertIndex: 拖拽插入位置。
- isSuccess: 是否成功释放。 | +| onItemDrop(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void) | 绑定该事件的列表元素可作为拖拽释放目标,当在列表元素内停止拖拽时触发。
- event: 见[ItemDragInfo对象说明](ts-container-grid.md#itemdraginfo对象说明)。
- itemIndex: 拖拽起始位置。
- insertIndex: 拖拽插入位置。
- isSuccess: 是否成功释放。
**说明:**
跨List拖拽时,当拖拽释放的位置绑定了onItemDrop时会返回true,否则为false。List内部拖拽时,isSuccess为onItemMove事件的返回值。 | ## ScrollState枚举说明 @@ -92,9 +110,9 @@ List(value?:{space?: number | string, initialIndex?: number, scroller? | 名称 | 描述 | | ------ | ------------------------- | -| Idle | 未滑动状态。 | -| Scroll | 手指拖动状态。 | -| Fling | 惯性滑动状态。 | +| Idle | 空闲状态。使用控制器提供的方法滚动、拖动滚动条滚动时触发。 | +| Scroll | 手指拖动状态。使用手指拖动List滚动时触发。 | +| Fling | 惯性滚动状态。快速划动松手后惯性滚动和划动到边缘回弹时触发。 | > **说明:** > @@ -197,4 +215,70 @@ struct ListLanesExample { } ``` -![list](figures/list1.gif) \ No newline at end of file +![list](figures/list1.gif) + +```ts +// xxx.ets +@Entry +@Component +struct ListDividerTest { + private arr: number[] = [0, 1, 2, 3] + + @Builder header() { + Text('header') + .width('100%') + .height(50) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(0xFFEECC) + } + + @Builder footer() { + Text('footer') + .width('100%') + .height(40) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(0xFFEECC) + } + + @Builder item(index: number) { + Text('item' + index) + .width('100%').height(80) + .fontSize(16) + .textAlign(TextAlign.Center) + } + + build() { + Column() { + List() { + ForEach(this.arr, (item) => { + ListItem() { + this.item(item) + } + }, item => item) + ListItemGroup({ header: this.header, footer: this.footer }) { + ForEach(this.arr, (item) => { + ListItem() { + this.item(item) + } + }, item => item) + } + .divider({ strokeWidth: 2, color: Color.Red, startMargin: 20, endMargin: 10 }) + + ForEach(this.arr, (item) => { + ListItem() { + this.item(item) + } + }, item => item) + } + .lanes(2) + .divider({ strokeWidth: 2, color: Color.Red, startMargin: 20, endMargin: 10 }) + .margin(10).borderWidth(1) + }.width("100%") + .height("100%") + } +} +``` + +![ListDivider](figures/ListDivider.png) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-listitem.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-listitem.md index 22799b3ac2607dc2e0817862f33fafcd077cd1df..6563873c5d243b86b9f8fab1a64279037eaa6ef6 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-listitem.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-listitem.md @@ -27,7 +27,7 @@ ListItem(value?: string) | sticky(deprecated) | [Sticky](#stickydeprecated枚举说明) | 设置ListItem吸顶效果。
默认值:Sticky.None
从API version9开始废弃,推荐使用[List组件sticky属性](ts-container-list.md#属性)。 | | editable(deprecated) | boolean \| [EditMode](#editmodedeprecated枚举说明) | 当前ListItem元素是否可编辑,进入编辑模式后可删除或移动列表项。
从API version9开始废弃。
默认值:false | | selectable8+ | boolean | 当前ListItem元素是否可以被鼠标框选。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
外层List容器的鼠标框选开启时,ListItem的框选才生效。
默认值:true | -| swipeAction9+ | {
start?: CustomBuilder,
end?:CustomBuilder,
edgeEffect?: [SwipeEdgeEffect](#swipeedgeeffect9枚举说明),
} | 用于设置ListItem的划出组件。
- start: ListItem向右划动时item左边的组件(List垂直布局时)或ListItem向下划动时item上方的组件(List水平布局时)。
- end: ListItem向左划动时item右边的组件(List垂直布局时)或ListItem向上划动时item下方的组件(List水平布局时)。
- edgeEffect: 滑动效果。
| +| swipeAction9+ | {
start?: CustomBuilder,
end?:CustomBuilder,
edgeEffect?: [SwipeEdgeEffect](#swipeedgeeffect9枚举说明),
} | 用于设置ListItem的划出组件。
- start: ListItem向右划动时item左边的组件(List垂直布局时)或ListItem向下划动时item上方的组件(List水平布局时)。
- end: ListItem向左划动时item右边的组件(List垂直布局时)或ListItem向上划动时item下方的组件(List水平布局时)。
- edgeEffect: 滑动效果。
**说明:**
start和end对应的@builder函数中顶层必须是单个组件,不能是if/else、ForEach、LazyForEach语句。 | ## Sticky(deprecated)枚举说明 从API version9开始废弃,推荐使用[List组件stickyStyle枚举](ts-container-list.md#stickystyle9枚举说明)。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md index 29d42b8de0840788b1f4fe13b94986ad3d337790..fb27abb4a2393b4e75fcb533b5bbc387a2061d97 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md @@ -35,6 +35,14 @@ ListItemGroup(options?: {header?: CustomBuilder, footer?: CustomBuilder, space?: | -------- | -------- | -------- | | divider | {
strokeWidth: [Length](ts-types.md#length),
color?: [ResourceColor](ts-types.md#resourcecolor),
startMargin?: [Length](ts-types.md#length),
endMargin?: [Length](ts-types.md#length)
} \| null | 用于设置ListItem分割线样式,默认无分割线。
strokeWidth: 分割线的线宽。
color: 分割线的颜色。
startMargin: 分割线距离列表侧边起始端的距离。
endMargin: 分割线距离列表侧边结束端的距离。 | +> **说明:** +> +> ListItemGroup组件不支持设置[通用属性aspectRatio](ts-universal-attributes-layout-constraints.md)。 +> +> ListItemGroup组件如果主轴方向是垂直方向时,设置[通用属性height](ts-universal-attributes-size.md)属性不生效。 +> +> ListItemGroup组件如果主轴方向是水平方向时,设置[通用属性width](ts-universal-attributes-size.md)属性不生效。 + ## 示例 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 db1c26ddd171304b7301159c4881e229fdd1826c..1d4f7f8f449ecc9e3fc308bd34e84ea5518e7ba4 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 @@ -5,6 +5,8 @@ > **说明:** > > 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> 当设置自定义组件时,自定义组件的高度限制在64vp之内。 ## 子组件 @@ -12,15 +14,16 @@ ## 接口 -Refresh\(value: \{ refreshing: boolean, offset?: number | string , friction?: number | string \}\) +Refresh\(value: \{ refreshing: boolean, offset?: number | string , friction?: number | string, builder?: Custombuilder\}\) **参数:** | 参数 | 参数名 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | | refreshing | boolean | 是 | 当前组件是否正在刷新。
该参数支持[$$](../../quick-start/arkts-restrictions-and-extensions.md#变量的双向绑定)双向绑定变量。 | -| offset | string \| number | 否 | 刷新组件静止时距离父组件顶部的距离。
默认值:16,单位vp | +| offset | string \| number | 否 | 下拉起点距离组件顶部的距离。
默认值:16,单位vp
**说明:**
不支持百分比,不支持负数 | | friction | number \| string | 否 | 下拉摩擦系数,取值范围为0到100。
默认值:62
- 0表示下拉刷新容器不跟随手势下拉而下拉。
- 100表示下拉刷新容器紧紧跟随手势下拉而下拉。
- 数值越大,下拉刷新容器跟随手势下拉的反应越灵敏。 | +| builder | [CustomBuilder](ts-types.md#custombuilder8)10+ | 否 | 下拉时,自定义刷新样式的组件。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md index 69d6b435712382434f64b8c042755fd654dd2dc8..55793b7218f1dbc5beb6f7557a981331d4311928 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md @@ -22,7 +22,7 @@ Row(value?:{space?: number | string }) | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| space | string \| number | 否 | 横向布局元素间距。
从API version 9开始,space为负数或者justifyContent设置为FlexAlign.SpaceBetween、FlexAlign.SpaceAround、FlexAlign.SpaceEvenly时不生效。
默认值:0,单位vp | +| space | string \| number | 否 | 横向布局元素间距。
从API version 9开始,space为负数或者justifyContent设置为FlexAlign.SpaceBetween、FlexAlign.SpaceAround、FlexAlign.SpaceEvenly时不生效。
默认值:0,单位vp
**说明:**
可选值为大于等于0的数字,或者可以转换为数字的字符串。 | ## 属性 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 53803a4425e2c592b4f70e3dda1a2670d6e6ae71..bd8d15720086142ef5ce0d40c497bfff2a5730d0 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 @@ -31,9 +31,9 @@ Scroll(scroller?: Scroller) | 名称 | 参数类型 | 描述 | | -------------- | ---------------------------------------- | --------- | | scrollable | [ScrollDirection](#scrolldirection枚举说明) | 设置滚动方向。
默认值:ScrollDirection.Vertical | -| scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。
默认值:BarState.Auto | +| scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。
默认值:BarState.Auto
**说明:**
如果容器组件无法滚动,则滚动条不显示。 | | scrollBarColor | string \| number \| [Color](ts-appendix-enums.md#color) | 设置滚动条的颜色。 | -| scrollBarWidth | string \| number | 设置滚动条的宽度。 | +| scrollBarWidth | string \| number | 设置滚动条的宽度。
默认值:4
单位:vp | | edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置滑动效果,目前支持的滑动效果参见EdgeEffect的枚举说明。
默认值:EdgeEffect.None | ## ScrollDirection枚举说明 @@ -48,12 +48,12 @@ Scroll(scroller?: Scroller) | 名称 | 功能描述 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| onScrollFrameBegin9+(event: (offset: number, state: ScrollState) => { offsetRemain }) | 每帧开始滚动时触发,事件参数传入即将发生的滚动量,事件处理函数中可根据应用场景计算实际需要的滚动量并作为事件处理函数的返回值返回,Scroll将按照返回值的实际滚动量进行滚动。
\- offset:即将发生的滚动量。
\- state:当前滚动状态。
- offsetRemain:实际滚动量。 | -| onScroll(event: (xOffset: number, yOffset: number) => void) | 滚动事件回调, 返回滚动时水平、竖直方向偏移量。 | -| onScrollEdge(event: (side: Edge) => void) | 滚动到边缘事件回调。 | -| onScrollEnd(deprecated) (event: () => void) | 滚动停止事件回调。
该事件从API9开始废弃,使用onScrollStop事件替代。 | -| onScrollStart9+(event: () => void) | 滚动开始时触发。手指拖动Scroll或拖动Scroll的滚动条触发的滚动开始时,会触发该事件。使用[Scroller](#scroller)滚动控制器触发的带动画的滚动,动画开始时会触发该事件。 | -| onScrollStop9+(event: () => void) | 滚动停止时触发。手拖动Scroll或拖动Scroll的滚动条触发的滚动,手离开屏幕并且滚动停止时会触发该事件。使用[Scroller](#scroller)滚动控制器触发的带动画的滚动,动画停止时会触发该事件。 | +| onScrollFrameBegin9+(event: (offset: number, state: ScrollState) => { offsetRemain }) | 每帧开始滚动时触发,事件参数传入即将发生的滚动量,事件处理函数中可根据应用场景计算实际需要的滚动量并作为事件处理函数的返回值返回,Scroll将按照返回值的实际滚动量进行滚动。
\- offset:即将发生的滚动量。
\- state:当前滚动状态。
- offsetRemain:实际滚动量。
触发该事件的条件 :
1、滚动组件触发滚动时触发,包括键鼠操作等其他触发滚动的输入设置。
2、调用控制器接口时不触发。
3、越界回弹不触发。
**说明:**
支持offsetRemain为负值。
若通过onScrollFrameBegine事件和scrollBy方法实现容器嵌套滚动,需设置子滚动节点的EdgeEffect为None。如Scroll嵌套List滚动时,List组件的edgeEffect属性需设置为EdgeEffect.None。 | +| onScroll(event: (xOffset: number, yOffset: number) => void) | 滚动事件回调, 返回滚动时水平、竖直方向偏移量。
触发该事件的条件 :
1、滚动组件触发滚动时触发,支持键鼠操作等其他触发滚动的输入设置。
2、通过滚动控制器API接口调用。
3、越界回弹。 | +| onScrollEdge(event: (side: Edge) => void) | 滚动到边缘事件回调。
触发该事件的条件 :
1、滚动组件触发滚动时触发,支持键鼠操作等其他触发滚动的输入设置。
2、通过滚动控制器API接口调用。
3、越界回弹。 | +| onScrollEnd(deprecated) (event: () => void) | 滚动停止事件回调。
该事件从API version 9开始废弃,使用onScrollStop事件替代。
触发该事件的条件 :
1、滚动组件触发滚动后停止,支持键鼠操作等其他触发滚动的输入设置。
2、通过滚动控制器API接口调用后停止,带过渡动效。 | +| onScrollStart9+(event: () => void) | 滚动开始时触发。手指拖动Scroll或拖动Scroll的滚动条触发的滚动开始时,会触发该事件。使用[Scroller](#scroller)滚动控制器触发的带动画的滚动,动画开始时会触发该事件。
触发该事件的条件 :
1、滚动组件触发滚动后停止,支持键鼠操作等其他触发滚动的输入设置。
2、通过滚动控制器API接口调用后开始,带过渡动效。 | +| onScrollStop9+(event: () => void) | 滚动停止时触发。手拖动Scroll或拖动Scroll的滚动条触发的滚动,手离开屏幕并且滚动停止时会触发该事件。使用[Scroller](#scroller)滚动控制器触发的带动画的滚动,动画停止时会触发该事件。
触发该事件的条件 :
1、滚动组件触发滚动后停止,支持键鼠操作等其他触发滚动的输入设置。
2、通过滚动控制器API接口调用后开始,带过渡动效,。 | > **说明:** > @@ -61,7 +61,7 @@ Scroll(scroller?: Scroller) ## Scroller -可滚动容器组件的控制器,可以将此组件绑定至容器组件,然后通过它控制容器组件的滚动,同一个控制器不可以控制多个容器组件,目前支持绑定到List、Scroll、ScrollBar上。 +可滚动容器组件的控制器,可以将此组件绑定至容器组件,然后通过它控制容器组件的滚动,同一个控制器不可以控制多个容器组件,目前支持绑定到List、Scroll、ScrollBar、Grid、WaterFlow上。 ### 导入对象 @@ -82,9 +82,9 @@ scrollTo(value: { xOffset: number | string, yOffset: number | string, animation? | 参数名 | 参数类型 | 必填 | 参数描述 | | --------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| xOffset | Length | 是 | 水平滑动偏移。 | -| yOffset | Length | 是 | 竖直滑动偏移。 | -| animation | {
duration: number,
curve: [Curve](ts-appendix-enums.md#curve)
} | 否 | 动画配置:
- duration: 滚动时长设置。
- curve: 滚动曲线设置。 | +| xOffset | number \| string | 是 | 水平滑动偏移。
**说明:**
该参数值不支持设置百分比。
仅滚动轴为x轴时生效。 | +| yOffset | number \| string | 是 | 垂直滑动偏移。
**说明:**
该参数值不支持设置百分比。
仅滚动轴为y轴时生效。 | +| animation | {
duration: number,
curve: [Curve](ts-appendix-enums.md#curve)
} | 否 | 动画配置:
- duration: 滚动时长设置。
- curve: 滚动曲线设置。
默认值:
{
duration: 0,
curve: Curve.Ease
}
**说明:**
设置为小于0的值时,按默认值显示。 | ### scrollEdge @@ -92,7 +92,7 @@ scrollTo(value: { xOffset: number | string, yOffset: number | string, animation? scrollEdge(value: Edge): void -滚动到容器边缘。 +滚动到容器边缘,不区分滚动轴方向,Edge.Top和Edge.Start表现相同,Edge.Bottom和Edge.End表现相同。 **参数:** @@ -124,9 +124,9 @@ currentOffset(): { xOffset: number, yOffset: number } **返回值** -| 类型 | 描述 | -| ---------------------------------------- | ---------------------------------------- | -| {
xOffset: number,
yOffset: number
} | xOffset: 水平滑动偏移;
yOffset: 竖直滑动偏移。 | +| 类型 | 描述 | +| ---------------------------------------------------------- | ------------------------------------------------------------ | +| {
xOffset: number,
yOffset: number
} | xOffset: 水平滑动偏移;
yOffset: 竖直滑动偏移。
**说明:**
返回值单位为vp。 | ### scrollToIndex @@ -139,7 +139,7 @@ scrollToIndex(value: number): void > **说明:** > -> 仅支持Grid、list组件。 +> 仅支持Grid、List组件。 **参数:** @@ -158,7 +158,7 @@ scrollBy(dx: Length, dy: Length): void > **说明:** > -> 仅支持Scroll组件。 +> 仅支持Scroll、ScrollBar、Grid、List组件。 **参数:** @@ -198,7 +198,7 @@ struct ScrollExample { .scrollable(ScrollDirection.Vertical) // 滚动方向纵向 .scrollBar(BarState.On) // 滚动条常驻显示 .scrollBarColor(Color.Gray) // 滚动条颜色 - .scrollBarWidth(30) // 滚动条宽度 + .scrollBarWidth(10) // 滚动条宽度 .edgeEffect(EdgeEffect.None) .onScroll((xOffset: number, yOffset: number) => { console.info(xOffset + ' ' + yOffset) @@ -211,21 +211,25 @@ struct ScrollExample { }) Button('scroll 150') + .height('5%') .onClick(() => { // 点击后下滑指定距离150.0vp this.scroller.scrollBy(0,150) }) .margin({ top: 10, left: 20 }) Button('scroll 100') + .height('5%') .onClick(() => { // 点击后滑动到指定位置,即下滑100.0vp的距离 this.scroller.scrollTo({ xOffset: 0, yOffset: this.scroller.currentOffset().yOffset + 100 }) }) .margin({ top: 60, left: 20 }) Button('back top') + .height('5%') .onClick(() => { // 点击后回到顶部 this.scroller.scrollEdge(Edge.Top) }) .margin({ top: 110, left: 20 }) Button('next page') + .height('5%') .onClick(() => { // 点击后滑到下一页 this.scroller.scrollPage({ next: true }) }) 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 1e6a02dd7a8cbd08fb7d8ce6a942123103e9bdfd..9c65d75a6d4ac685e9020c1b12a080edc29303e4 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 @@ -11,6 +11,12 @@ 可以包含子组件。 +> **说明:** +> +> - 子组件类型:系统组件和自定义组件,不支持渲染控制类型([if/else](../../quick-start/arkts-rendering-control.md#条件渲染)、[ForEach](quick-start/arkts-rendering-control.md#循环渲染)和[LazyForEach](quick-start/arkts-rendering-control.md#数据懒加载))。 +> - 子组件个数:必须且仅包含2个子组件。 +> - 子组件个数异常时:3个或以上子组件,显示第一个和第二个。1个子组件,显示侧边栏,内容区为空白。 + ## 接口 @@ -31,26 +37,29 @@ SideBarContainer( type?: SideBarContainerType ) ## 属性 +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | showSideBar | boolean | 设置是否显示侧边栏。
默认值:true | -| controlButton | ButtonStyle | 设置侧边栏控制按钮的属性。 | +| controlButton | [ButtonStyle](#buttonstyle对象说明) | 设置侧边栏控制按钮的属性。 | | showControlButton | boolean | 设置是否显示控制按钮。
默认值:true | -| sideBarWidth | number \| Length9+ | 设置侧边栏的宽度。
默认值:200,单位vp | -| minSideBarWidth | number \| Length9+ | 设置侧边栏最小宽度。
默认值:200,单位vp | -| maxSideBarWidth | number \| Length9+ | 设置侧边栏最大宽度。
默认值:280,单位vp | -| autoHide9+ | boolean | 设置当侧边栏拖拽到小于最小宽度后,是否自动隐藏。
默认值:true | -| sideBarPosition9+ | SideBarPosition | 设置侧边栏显示位置。
默认值:SideBarPosition.Start | +| sideBarWidth | number \| [Length](ts-types.md#length)9+ | 设置侧边栏的宽度。
默认值:200
单位:vp
**说明:**
设置为小于0的值时按默认值显示。
受最小宽度和最大宽度限制,不在限制区域内取最近的点。
sideBarWidth优先于侧边栏子组件width,sideBarWidth未设置时默认值优先级低于侧边栏子组件width。 | +| minSideBarWidth | number \| [Length](ts-types.md#length)9+ | 设置侧边栏最小宽度。
默认值:200,单位vp
**说明:**
设置为小于0的值时按默认值显示。
值不能超过侧边栏容器本身宽度,超过使用侧边栏容器本身宽度。
minSideBarWidth优先于侧边栏子组件minWidth,minSideBarWidth未设置时默认值优先级低于侧边栏子组件minWidth。 | +| maxSideBarWidth | number \| [Length](ts-types.md#length)9+ | 设置侧边栏最大宽度。
默认值:280,单位vp
**说明:**
设置为小于0的值时按默认值显示。
值不能超过侧边栏容器本身宽度,超过使用侧边栏容器本身宽度。
maxSideBarWidth优先于侧边栏子组件maxWidth,maxSideBarWidth未设置时默认值优先级低于侧边栏子组件maxWidth。 | +| autoHide9+ | boolean | 设置当侧边栏拖拽到小于最小宽度后,是否自动隐藏。
默认值:true
**说明:**
受minSideBarWidth属性方法影响,minSideBarWidth属性方法未设置值使用默认值。
拖拽过程中判断是否要自动隐藏。小于最小宽度时需要阻尼效果触发隐藏(越界一段距离) | +| sideBarPosition9+ | [SideBarPosition](#sidebarposition9枚举说明) | 设置侧边栏显示位置。
默认值:SideBarPosition.Start | +| divider10+ | [DividerStyle](#dividerstyle10对象说明) \| null | 设置分割线的样式。
- 默认为DividerStyle:显示分割线。
- null:不显示分割线。 | ## ButtonStyle对象说明 | 名称 | 参数类型 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -| left | number | 否 | 设置侧边栏控制按钮距离容器左界限的间距。
默认值:16,单位vp | -| top | number | 否 | 设置侧边栏控制按钮距离容器上界限的间距。
默认值:48,单位vp | -| width | number | 否 | 设置侧边栏控制按钮的宽度。
默认值:32,单位vp | -| height | number | 否 | 设置侧边栏控制按钮的高度。
默认值:32,单位vp | -| icons | {
shown: string \| PixelMap \| [Resource](ts-types.md) ,
hidden: string \| PixelMap \| [Resource](ts-types.md) ,
switching?: string \| PixelMap \| [Resource](ts-types.md)
} | 否 | 设置侧边栏控制按钮的图标:

- shown: 设置侧边栏显示时控制按钮的图标。
- hidden: 设置侧边栏隐藏时控制按钮的图标。
- switching:设置侧边栏显示和隐藏状态切换时控制按钮的图标。 | +| left | number | 否 | 设置侧边栏控制按钮距离容器左界限的间距。
默认值:16
单位:vp | +| top | number | 否 | 设置侧边栏控制按钮距离容器上界限的间距。
默认值:48
单位:vp | +| width | number | 否 | 设置侧边栏控制按钮的宽度。
默认值:32
单位:vp | +| height | number | 否 | 设置侧边栏控制按钮的高度。
默认值:32
单位:vp | +| icons | {
shown: string \| PixelMap \| [Resource](ts-types.md) ,
hidden: string \| PixelMap \| [Resource](ts-types.md) ,
switching?: string \| PixelMap \| [Resource](ts-types.md)
} | 否 | 设置侧边栏控制按钮的图标:

- shown: 设置侧边栏显示时控制按钮的图标。
**说明:**
资源获取错误时,使用默认图标。
- hidden: 设置侧边栏隐藏时控制按钮的图标。
- switching:设置侧边栏显示和隐藏状态切换时控制按钮的图标。 | ## SideBarPosition9+枚举说明 @@ -59,11 +68,33 @@ SideBarContainer( type?: SideBarContainerType ) | Start | 侧边栏位于容器左侧。 | | End | 侧边栏位于容器右侧。 | +## DividerStyle10+对象说明 + +| 名称 | 参数类型 | 必填 | 描述 | +| ----------- | ------------- | ---- | ---------------------------------------- | +| strokeWidth | [Length](ts-types.md#length) | 是 | 分割线的线宽。
默认值:1
单位:vp | +| color | [ResourceColor](ts-types.md#resourcecolor) | 否 | 分割线的颜色。
默认值:#000000,3% | +| startMargin | [Length](ts-types.md#length) | 否 | 分割线与侧边栏顶端的距离。
默认值:0 | +| endMargin | [Length](ts-types.md#length) | 否 | 分割线与侧边栏底端的距离。
默认值:0 | +> **说明:** +> +> 针对侧边栏子组件设置[通用属性宽高](ts-universal-attributes-size.md)时,宽生效的前提是侧边栏容器不设置sideBarWidth,高度不生效。 +> 针对侧边栏内容区设置[通用属性宽高](ts-universal-attributes-size.md)时,宽高都不生效,默认占满SideBarContainer的剩余空间。 +> +> 当属性方法未设置时,依据组件大小进行自动显示: +> +> - 小于520vp:默认不显示侧边栏。 +> - 大于等于520vp:默认显示侧边栏。 +> - 小于520vp:不显示侧边栏。 +> - 大于等于520vp:显示侧边栏。 + ## 事件 +除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: + | 名称 | 功能描述 | | -------- | -------- | -| onChange(callback: (value: boolean) => void) | 当侧边栏的状态在显示和隐藏之间切换时触发回调。

true表示显示,false表示隐藏。 | +| onChange(callback: (value: boolean) => void) | 当侧边栏的状态在显示和隐藏之间切换时触发回调。true表示显示,false表示隐藏。
触发该事件的条件:
1、showSideBar属性值变换时;
2、showSideBar属性自适应行为变化时;
3、分割线拖拽触发autoHide时。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-stack.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-stack.md index d9f512ae3ac8ee670a63cedc7b695c05c21da2af..385f3fa1b2104c4eea94ca61a055ae4115fe45cf 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-stack.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-stack.md @@ -30,7 +30,7 @@ Stack(value?: { alignContent?: Alignment }) | 名称 | 参数类型 | 描述 | | ------------ | ------------------------------------------- | ------------------------------ | -| alignContent | [Alignment](ts-appendix-enums.md#alignment) | 设置子组件在容器内的对齐方式。 | +| alignContent | [Alignment](ts-appendix-enums.md#alignment) | 设置子组件在容器内的对齐方式。
默认值:Alignment.Center
从API version 9开始,该接口支持在ArkTS卡片中使用。 | ## 示例 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 66cdc22b56b222119f87550419fbdb4a923b7178..ac04ea0fc647ad43924f424d83ff05e4d5692f30 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 @@ -32,7 +32,7 @@ Swiper(controller?: SwiperController) | index | number | 设置当前在容器中显示的子组件的索引值。
默认值:0 | | autoPlay | boolean | 子组件是否自动播放。
默认值:false | | interval | number | 使用自动播放时播放的时间间隔,单位为毫秒。
默认值:3000 | -| indicator | boolean | 是否启用导航点指示器。
默认值:true | +| indicator10+ | [DotIndicator](#dotindicator) \| [DigitIndicator](#digitindicator) \| boolean | 设置可选导航点指示器样式。
\- DotIndicator:圆点指示器样式。
\- DigitIndicator:数字指示器样式。
\- boolean:是否启用导航点指示器。
  默认值:true
  默认类型:DotIndicator | | loop | boolean | 是否开启循环。
设置为true时表示开启循环,在LazyForEach懒循环加载模式下,加载的组件数量建议大于5个。
默认值:true | | duration | number | 子组件切换的动画时长,单位为毫秒。
默认值:400 | | vertical | boolean | 是否为纵向滑动。
默认值:false | @@ -80,6 +80,44 @@ finishAnimation(callback?: () => void): void | --------- | ---------- | ------ | -------- | | callback | () => void | 否 | 动画结束的回调。 | +## Indicator10+对象说明 + +设置导航点距离Swiper组件距离。 + +| 参数名 | 参数类型 | 必填项 | 参数描述 | +| ------ | -------- | ------ | ------------------------------------ | +| left | [Length](ts-types.md#length) | 否 | 设置导航点距离Swiper组件左边的距离。 | +| top | [Length](ts-types.md#length) | 否 | 设置导航点距离Swiper组件顶部的距离。 | +| right | [Length](ts-types.md#length) | 否 | 设置导航点距离Swiper组件右边的距离。 | +| bottom | [Length](ts-types.md#length) | 否 | 设置导航点距离Swiper组件底部的距离。 | + +### DotIndicator + +圆点指示器属性及功能继承自Indicator。 + +| 参数名 | 参数类型 | 必填项 | 参数描述 | +| ------------------ | ------------- | ------ | ------------------------------------------------------ | +| itemWidth | [Length](ts-types.md#length) | 否 | 设置Swiper组件圆点导航指示器的宽。 | +| itemHeight | [Length](ts-types.md#length) | 否 | 设置Swiper组件圆点导航指示器的高。 | +| selectedItemWidth | [Length](ts-types.md#length) | 否 | 设置选中Swiper组件圆点导航指示器的宽。 | +| selectedItemHeight | [Length](ts-types.md#length) | 否 | 设置选中Swiper组件圆点导航指示器的高。 | +| mask | boolean | 否 | 设置是否显示Swiper组件圆点导航指示器的蒙版样式。 | +| color | [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置Swiper组件圆点导航指示器的颜色。 | +| selectedColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置选中Swiper组件圆点导航指示器的颜色。 | + +### DigitIndicator + +数字指示器属性及功能继承自Indicator。 + +| 参数名 | 参数类型 | 必填项 | 参数描述 | +| ----------------- | ------------------------------------------------------------ | ------ | ------------------------------------------------------------ | +| fontColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置Swiper组件数字导航点的字体颜色。 | +| selectedFontColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置选中Swiper组件数字导航点的字体颜色。 | +| digitFont | {
size?:[Length](ts-types.md#length)
weight?:number \| [FontWeight](ts-appendix-enums.md#fontweight) \| string
} | 否 | 设置Swiper组件数字导航点的字体样式:
\- size:数字导航点指示器的字体大小。
\- weight:数字导航点指示器的字重。 | +| selectedDigitFont | {
size?:[Length](ts-types.md#length)
weight?:number \| [FontWeight](ts-appendix-enums.md#fontweight) \| string
} | 否 | 设置选中Swiper组件数字导航点的字体样式:
\- size:数字导航点选中指示器的字体大小。
\- weight:数字导航点选中指示器的字重。 | + + + ## 事件 ### onChange diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md index a9082e59775478927413364a1f807c83ff9a2ced..f43c2e8866b0aff7ad3cf48fee76a6137fd6a53a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md @@ -11,6 +11,10 @@ 支持单个子组件。 +> **说明:** +> +> 可内置系统组件和自定义组件,支持渲染控制类型([if/else](../../quick-start/arkts-rendering-control.md#条件渲染)、[ForEach](quick-start/arkts-rendering-control.md#循环渲染)和[LazyForEach](quick-start/arkts-rendering-control.md#数据懒加载))。 + ## 接口 @@ -23,19 +27,21 @@ TabContent() | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| tabBar | string \| Resource \| {
icon?: string \| Resource,
text?: string \| Resource
}
\| [CustomBuilder](ts-types.md)8+ | 设置TabBar上显示内容。
CustomBuilder: 构造器,内部可以传入组件(API8版本以上适用)。
>  **说明:**
> 如果icon采用svg格式图源,则要求svg图源删除其自有宽高属性值。如采用带有自有宽高属性的svg图源,icon大小则是svg本身内置的宽高属性值大小。 | -| tabBar9+ | [SubTabBarStyle](#subtabbarstyle) \| [BottomTabBarStyle](#bottomtabbarstyle) | 设置TabBar上显示内容。
SubTabBarStyle: 子页签样式,参数为文字。
BottomTabBarStyle: 底部页签和侧边页签样式,参数为文字和图片。 | +| tabBar | string \| Resource \| {
icon?: string \| Resource,
text?: string \| Resource
}
\| [CustomBuilder](ts-types.md)8+ | 设置TabBar上显示内容。
CustomBuilder: 构造器,内部可以传入组件(API8版本以上适用)。
>  **说明:**
> 如果icon采用svg格式图源,则要求svg图源删除其自有宽高属性值。如采用带有自有宽高属性的svg图源,icon大小则是svg本身内置的宽高属性值大小。
设置的内容超出tabbar页签时进行裁切。 | +| tabBar9+ | [SubTabBarStyle](#subtabbarstyle) \| [BottomTabBarStyle](#bottomtabbarstyle) | 设置TabBar上显示内容。
SubTabBarStyle: 子页签样式,参数为文字。
BottomTabBarStyle: 底部页签和侧边页签样式,参数为文字和图片。
**说明:**
底部样式没有下划线效果。
icon异常时显示灰色图块。 | > **说明:** -> - TabContent组件不支持设置通用宽度属性,其宽度默认撑满Tabs父组件。 -> - TabContent组件不支持设置通用高度属性,其高度由Tabs父组件高度与TabBar组件高度决定。 -> - TabContent组件不支持内容过长时页面的滑动,如需页面滑动,可嵌套List使用。 +> +> - TabContent组件不支持设置通用宽度属性,其宽度默认撑满Tabs父组件。 +> - TabContent组件不支持设置通用高度属性,其高度由Tabs父组件高度与TabBar组件高度决定。 +> - vertical属性为false值,交换上述2个限制。 +> - TabContent组件不支持内容过长时页面的滑动,如需页面滑动,可嵌套List使用。 ## SubTabBarStyle9+ 子页签样式。 -### constructor9+ +### constructor constructor(content: string | Resource) @@ -45,15 +51,71 @@ SubTabBarStyle的构造函数。 | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| content | string \| [Resource](ts-types.md#resource) | 是 | 页签内的文字内容。 | +| content | string \| [Resource](ts-types.md#resource) | 是 | 页签内的文字内容。从API version 10开始,content类型为ResourceStr。 | + +### of10+ + +static of(content: ResourceStr) + +SubTabBarStyle的静态构造函数。 + +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------- | ------------------------------------------ | ---- | ------------------ | +| content | [ResourceStr](ts-types.md#resourcestr) | 是 | 页签内的文字内容。 | + +### 属性 + +支持以下属性: + +| 名称 | 参数类型 | 描述 | +| ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| indicator10+ | [IndicatorStyle](#indicatorstyle10对象说明)| 设置选中子页签的下划线风格。
| +| selectedMode10+ | [SelectedMode](#selectedmode10枚举说明) | 设置选中子页签的显示方式。
默认值:SelectedMode.Indicator | +| board10+ | [BoardStyle](#boardstyle10对象说明) | 设置选中子页签的背板风格。 | +| labelStyle10+ | [LabelStyle](#labelstyle10对象说明) | 设置选中子页签的label文本和字体的样式。 | + +## IndicatorStyle10+对象说明 + +| 名称 | 参数类型 | 必填 | 描述 | +| -------- | -------- | -------- | -------------------------------- | +| color | [ResourceColor](ts-types.md#resourcecolor) | 否 | 下划线的颜色。
默认值:#FF007DFF | +| height | [Length](ts-types.md#length) | 否 | 下划线的高度。
默认值:2.0
单位:vp | +| width | [Length](ts-types.md#length) | 否 | 下划线的宽度。
默认值:0.0
单位:vp | +| borderRadius | [Length](ts-types.md#length) | 否 | 下划线的圆角半径。
默认值:0.0
单位:vp | +| marginTop | [Length](ts-types.md#length) | 否 | 下划线与文字的间距。
默认值:8.0
单位:vp | + +## SelectedMode10+枚举说明 +| 名称 | 描述 | +| ---------- | ------------------------ | +| Indicator | 使用下划线模式。 | +| Board | 使用背板模式。 | + +## BoardStyle10+对象说明 + +| 名称 | 参数类型 | 必填 | 描述 | +| -------- | -------- | -------- | ------------------------------------ | +| borderRadius | [Length](ts-types.md#length) | 否 | 下划线的圆角半径。
默认值:8.0
单位:vp | + +## LabelStyle10+对象说明 + +| 名称 | 参数类型 | 必填 | 描述 | +| -------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| overflow | [TextOverflow](ts-appendix-enums.md#textoverflow) | 否 | 设置Label文本超长时的显示方式。文本截断是按字截断。例如,英文以单词为最小单位进行截断,若需要以字母为单位进行截断,可在字母间添加零宽空格。 | +| maxLines | number | 否 | 设置Label文本的最大行数。默认情况下,文本是自动折行的,如果指定此参数,则文本最多不会超过指定的行。如果有多余的文本,可以通过 textOverflow来指定截断方式。 | +| minFontSize | number \| [ResourceStr](ts-types.md#resourcestr) | 否 | 设置Label文本最小显示字号。需配合maxFontSize以及maxLines或布局大小限制使用。 | +| maxFontSize | number \| [ResourceStr](ts-types.md#resourcestr) | 否 | 设置Label文本最大显示字号。需配合minFontSize以及maxLines或布局大小限制使用。 | +| heightAdaptivePolicy | [TextHeightAdaptivePolicy](ts-appendix-enums.md#textheightadaptivepolicy10) | 否 | 设置Label文本自适应高度的方式。 | +| font | [Font](ts-types.md#font) | 否 | 设置Label文本字体样式。 | ## BottomTabBarStyle9+ 底部页签和侧边页签样式。 -### constructor9+ +### constructor -constructor(icon: string | Resource, text: string | Resource) +constructor(icon: string | Resource, content: string | Resource) BottomTabBarStyle的构造函数。 @@ -61,8 +123,20 @@ BottomTabBarStyle的构造函数。 | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| icon | string \| [Resource](ts-types.md#resource) | 是 | 页签内的图片内容。 | -| text | string \| [Resource](ts-types.md#resource) | 是 | 页签内的文字内容。 | +| icon | string \| [Resource](ts-types.md#resource) | 是 | 页签内的图片内容。从API version 10开始,icon类型为ResourceStr。 | +| text | string \| [Resource](ts-types.md#resource) | 是 | 页签内的文字内容。从API version 10开始,text类型为ResourceStr。 | + +### of10+ + +static of(icon: ResourceStr, text: ResourceStr) +BottomTabBarStyle的静态构造函数。 + +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------- | -------- | -------- | -------- | +| icon | [ResourceStr](ts-types.md#resourcestr) | 是 | 页签内的图片内容。 | +| text | [ResourceStr](ts-types.md#resourcestr) | 是 | 页签内的文字内容。 | ## 示例 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 2787e1f58ed4ff75df39d9ce7c16dd5cea6dcd17..e2dd02f98f26881188899a70e223a59c42432e9b 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 @@ -21,7 +21,7 @@ Tabs(value?: {barPosition?: BarPosition, index?: number, controller?: [TabsContr | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | | barPosition | BarPosition | 否 | 设置Tabs的页签位置。
默认值:BarPosition.Start | -| index | number | 否 | 设置初始页签索引。
默认值:0 | +| index | number | 否 | 设置初始页签索引。
默认值:0
**说明:**
设置为小于0的值时按默认值显示。
可选值为[0, TabContent子节点数量-1]。
设置不同值时,默认生效切换动效,可以设置animationDuration为0关闭动画。 | | controller | [TabsController](#tabscontroller) | 否 | 设置Tabs控制器。 | ## BarPosition枚举说明 @@ -41,9 +41,20 @@ Tabs(value?: {barPosition?: BarPosition, index?: number, controller?: [TabsContr | vertical | boolean | 设置为false是为横向Tabs,设置为true时为纵向Tabs。
默认值:false | | scrollable | boolean | 设置为true时可以通过滑动页面进行页面切换,为false时不可滑动切换页面。
默认值:true | | barMode | BarMode | TabBar布局模式,具体描述见BarMode枚举说明。
默认值:BarMode.Fixed | -| barWidth | number \| Length8+ | TabBar的宽度值。 | -| barHeight | number \| Length8+ | TabBar的高度值。 | -| animationDuration | number | TabContent滑动动画时长。不设置时,点击切换页签无动画,滑动切换有动画;设置时,点击切换和滑动切换都有动画。
默认值:200 | +| barWidth | number \| Length8+ | TabBar的宽度值。
**说明:**
设置为小于0或大于Tabs宽度值时,按默认值显示。 | +| barHeight | number \| Length8+ | TabBar的高度值。
**说明:**
设置为小于0或大于Tabs宽度值时,按默认值显示。 | +| animationDuration | number | TabContent滑动动画时长。不设置时,点击切换页签无动画,滑动切换有动画;设置时,点击切换和滑动切换都有动画。
默认值:200
**说明:**
设置为小于0或百分比时,按默认值显示。| +| divider10+ | [DividerStyle](#dividerstyle10对象说明) \| null | 用于设置区分TabBar和TabContent的分割线样式设置分割线样式,默认不显示分割线。
DividerStyle: 分割线的样式;
null: 不显示分割线。 | +| FadingEdge10+ | boolean | 设置页签超过容器宽度时是否渐隐消失
默认值:true | + +## DividerStyle10+对象说明 + +| 名称 | 参数类型 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | +| strokeWidth | [Length](ts-types.md#length) | 是 | 分割线的线宽。 | +| color | [ResourceColor](ts-types.md#resourcecolor) | 否 | 分割线的颜色。
默认值:#33182431 | +| startMargin | [Length](ts-types.md#length) | 否 | 分割线与侧边栏顶端的距离。
默认值:0.0
单位:vp | +| endMargin | [Length](ts-types.md#length) | 否 | 分割线与侧边栏底端的距离。
默认值:0.0
单位:vp | ## BarMode枚举说明 @@ -58,7 +69,7 @@ Tabs(value?: {barPosition?: BarPosition, index?: number, controller?: [TabsContr | 名称 | 功能描述 | | -------- | -------- | -| onChange(event: (index: number) => void) | Tab页签切换后触发的事件。 | +| onChange(event: (index: number) => void) | Tab页签切换后触发的事件。
- index:当前显示的index索引,索引从0开始计算。
触发该事件的条件:
1、TabContent支持滑动时,组件触发滑动时触发。
2、通过[控制器](#tabscontroller)API接口调用。
3、通过[状态变量](../../quick-start/arkts-state-mgmt-page-level.md)构造的属性值进行修改。
4、通过页签处点击触发。 | ## TabsController @@ -66,9 +77,8 @@ Tabs组件的控制器,用于控制Tabs组件进行页签切换。不支持一 ### 导入对象 -``` +```ts controller: TabsController = new TabsController() - ``` ### changeIndex @@ -81,7 +91,7 @@ changeIndex(value: number): void | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| value | number | 是 | 页签在Tabs里的索引值,索引值从0开始。 | +| value | number | 是 | 页签在Tabs里的索引值,索引值从0开始。
**说明:**
设置小于0或大于最大数量的值时,该事件失效。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md index 63ede8489f4221fdbd710f1b7851f6b808aaf46e..97b87b882f057dd0ba3a8ca0f490ff0e56bb607a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md @@ -37,10 +37,10 @@ Circle(options?: {width?: string | number, height?: string | number}) | strokeDashArray | Array<Length> | 设置边框间隙。
默认值:[]
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | strokeDashOffset | number \| string | 边框绘制起点的偏移量。
默认值:0
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | 设置边框端点绘制样式。
默认值:LineCapStyle.Butt
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | 设置边框拐角绘制样式。
默认值:LineJoinStyle.Miter
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | 设置边框拐角绘制样式。
默认值:LineJoinStyle.Miter
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
Circle组件无法形成拐角,该属性设置无效。 | | strokeMiterLimit | number \| string | 设置斜接长度与边框宽度比值的极限值。
默认值:4
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
Circle组件无法设置尖角图形,该属性设置无效。 | | strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 设置边框透明度。
默认值:1
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 | -| strokeWidth | Length | 设置边框宽度。
默认值:1
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| strokeWidth | Length | 设置边框宽度。
默认值:1
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
该属性若为string类型, 暂不支持百分比。 | | antiAlias | boolean | 是否开启抗锯齿效果。
默认值:true
从API version 9开始,该接口支持在ArkTS卡片中使用。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md index bb7cd917cad709a29d4fdebea42497df76e5f1e0..441c147a844da8b1a3a70f08983edef5a03dfd63 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md @@ -37,10 +37,10 @@ Ellipse(options?: {width?: string | number, height?: string | number}) | strokeDashArray | Array<Length> | [] | 设置边框间隙。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | strokeDashOffset | number \| string | 0 | 边框绘制起点的偏移量。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 设置边框端点绘制样式。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置边框拐角绘制样式。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置边框拐角绘制样式。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
Ellipse组件无法形成拐角,该属性设置无效。 | | strokeMiterLimit | number \| string | 4 | 设置斜接长度与边框宽度比值的极限值。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
Ellipse组件无法设置尖角图形,该属性设置无效。 | | strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置边框透明度。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 | -| strokeWidth | Length | 1 | 设置边框宽度。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| strokeWidth | Length | 1 | 设置边框宽度。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
该属性若为string类型, 暂不支持百分比。 | | antiAlias | boolean | true | 是否开启抗锯齿效果。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md index 85f6d1289ce2b38e447f146ce547e094e9e1d9ee..c87ba0db483cc70e214e12dc35e4dc72e711a4cc 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md @@ -39,10 +39,10 @@ Line(value?: {width?: string | number, height?: string | number}) | strokeDashArray | Array<Length> | [] | 设置线条间隙。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | strokeDashOffset | number \| string | 0 | 线条绘制起点的偏移量。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 设置线条端点绘制样式。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置线条拐角绘制样式。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置线条拐角绘制样式。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
Line组件无法形成拐角,该属性设置无效。 | | strokeMiterLimit | number \| string | 4 | 设置锐角绘制成斜角的极限值。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
Line组件无法设置锐角图形,该属性设置无效。 | | strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置线条透明度。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 | -| strokeWidth | Length | 1 | 设置线条宽度。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| strokeWidth | Length | 1 | 设置线条宽度。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
该属性若为string类型, 暂不支持百分比。| | antiAlias | boolean | true | 是否开启抗锯齿效果。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | ## 示例 @@ -189,4 +189,4 @@ struct LineExample { } ``` -![zh-cn_image2_0000001219982725](figures/zh-cn_image2_0000001219982725.PNG) \ No newline at end of file +![zh-cn_image2_0000001219982725](figures/zh-cn_image2_0000001219982725.PNG) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md index 2aeb1cf919c9cd67e3ade9f106b390240b8edc08..71fa790219c90efaa162a3eb7de97f3623d9a574 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md @@ -41,7 +41,7 @@ Path(value?: { width?: number | string; height?: number | string; commands?: str | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置线条拐角绘制样式。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | strokeMiterLimit | number \| string | 4 | 设置斜接长度与边框宽度比值的极限值。斜接长度表示外边框外边交点到内边交点的距离,边框宽度即strokeWidth属性的值。
**说明:**
该属性取值需大于等于1,且在strokeLineJoin属性取值LineJoinStyle.Miter时生效。
从API version 9开始,该接口支持在ArkTS卡片中使用。| | strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置线条透明度。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。
从API version 9开始,该接口支持在ArkTS卡片中使用。| -| strokeWidth | Length | 1 | 设置线条宽度。
从API version 9开始,该接口支持在ArkTS卡片中使用。| +| strokeWidth | Length | 1 | 设置线条宽度。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
该属性若为string类型, 暂不支持百分比。| | antiAlias | boolean | true | 是否开启抗锯齿效果。
从API version 9开始,该接口支持在ArkTS卡片中使用。| commands支持的绘制命令如下: diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md index 1e63df5002792b90232dd73cec7b10643a90ab39..adefdb3b18bdb8c659de833cc953a31c280c0d69 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md @@ -42,7 +42,7 @@ Polygon(value?: {width?: string | number, height?: string | number}) | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置边框拐角绘制样式。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | strokeMiterLimit | number \| string | 4 | 设置斜接长度与边框宽度比值的极限值。斜接长度表示外边框外边交点到内边交点的距离,边框宽度即strokeWidth属性的值。
**说明:**
该属性取值需大于等于1,且在strokeLineJoin属性取值LineJoinStyle.Miter时生效。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置边框透明度。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| strokeWidth | Length | 1 | 设置边框宽度。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| strokeWidth | Length | 1 | 设置边框宽度。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
该属性若为string类型, 暂不支持百分比。| | antiAlias | boolean | true | 是否开启抗锯齿效果。
从API version 9开始,该接口支持在ArkTS卡片中使用。| ## Point diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md index 4cb64ed2723d69c7139e087bcc93e89f20bfe3a1..cfe8a337950e9f2fc577271a0d18da8d5128a5b9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md @@ -42,7 +42,7 @@ Polyline(value?: {width?: string | number, height?: string | number}) | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置线条拐角绘制样式。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | strokeMiterLimit | number \| string | 4 | 设置斜接长度与边框宽度比值的极限值。斜接长度表示外边框外边交点到内边交点的距离,边框宽度即strokeWidth属性的值。
**说明:**
该属性取值需大于等于1,且在strokeLineJoin属性取值LineJoinStyle.Miter时生效。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置线条透明度。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。
从API version 9开始,该接口支持在ArkTS卡片中使用。| -| strokeWidth | Length | 1 | 设置线条宽度。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| strokeWidth | Length | 1 | 设置线条宽度。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
该属性若为string类型, 暂不支持百分比。 | | antiAlias | boolean | true | 是否开启抗锯齿效果。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | ## Point diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md index 889b9f2f0d91311d2ec934cc8e46f6f4a67dc61b..23b4108f2f30db5d7f176ae7d9e870326ae201a3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md @@ -48,7 +48,7 @@ Rect(value?: {width?: string | number,height?: string | number,radius?: string | | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置边框拐角绘制样式。
从API version 9开始,该接口支持在ArkTS卡片中使用。| | strokeMiterLimit | number \| string | 4 | 设置斜接长度与边框宽度比值的极限值。斜接长度表示外边框外边交点到内边交点的距离,边框宽度即strokeWidth属性的值。
**说明:**
该属性取值需大于等于1,且在strokeLineJoin属性取值LineJoinStyle.Miter时生效。
从API version 9开始,该接口支持在ArkTS卡片中使用。| | strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置边框透明度。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。
从API version 9开始,该接口支持在ArkTS卡片中使用。| -| strokeWidth | Length | 1 | 设置边框宽度。
从API version 9开始,该接口支持在ArkTS卡片中使用。| +| strokeWidth | Length | 1 | 设置边框宽度。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
该属性若为string类型, 暂不支持百分比。| | antiAlias | boolean | true | 是否开启抗锯齿效果。
从API version 9开始,该接口支持在ArkTS卡片中使用。| diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md index 7586e24fe930715e2b7f3b6cf6d12dce50043dca..cdba2df4d4dfe6a55d1b4bf41e51f9ce56e74889 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md @@ -36,7 +36,7 @@ Shape(value?: PixelMap) | 名称 | 类型 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -| viewPort | {
x?: number \| string,
y?: number \| string,
width?: number \| string,
height?: number \| string
} | { x:0, y:0, width:0, height:0 } | 形状的视口。
从API version 9开始,该接口支持在ArkTS卡片中使用。| +| viewPort | {
x?: number \| string,
y?: number \| string,
width?: number \| string,
height?: number \| string
} | { x:0, y:0, width:0, height:0 } | 形状的视口。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
该属性若为string类型, 暂不支持百分比。| | fill | [ResourceColor](ts-types.md) | Color.Black | 设置填充区域颜色。
从API version 9开始,该接口支持在ArkTS卡片中使用。| | fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置填充区域透明度。
从API version 9开始,该接口支持在ArkTS卡片中使用。| | stroke | [ResourceColor](ts-types.md) | - | 设置边框颜色,不设置时,默认没有边框线条。
从API version 9开始,该接口支持在ArkTS卡片中使用。| @@ -46,7 +46,7 @@ Shape(value?: PixelMap) | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置边框拐角绘制样式。
从API version 9开始,该接口支持在ArkTS卡片中使用。| | strokeMiterLimit | number \| string | 4 | 设置斜接长度与边框宽度比值的极限值。斜接长度表示外边框外边交点到内边交点的距离,边框宽度即strokeWidth属性的值。
**说明:**
该属性取值需大于等于1,且在strokeLineJoin属性取值LineJoinStyle.Miter时生效。
从API version 9开始,该接口支持在ArkTS卡片中使用。| | strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置边框透明度。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。
从API version 9开始,该接口支持在ArkTS卡片中使用。| -| strokeWidth | number \| string | 1 | 设置边框宽度。
从API version 9开始,该接口支持在ArkTS卡片中使用。| +| strokeWidth | number \| string | 1 | 设置边框宽度。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
该属性若为string类型, 暂不支持百分比。| | antiAlias | boolean | true | 是否开启抗锯齿效果。
从API version 9开始,该接口支持在ArkTS卡片中使用。| | mesh8+ | Array<number>,number,number | [],0,0 | 设置mesh效果。第一个参数为长度(column + 1)* (row + 1)* 2的数组,它记录了扭曲后的位图各个顶点位置,第二个参数为mesh矩阵列数column,第三个参数为mesh矩阵行数row。
从API version 9开始,该接口支持在ArkTS卡片中使用。| diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md b/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md index 359b6890f857197555d65e39495eb2d0d558d48a..ca5bc50d38e9bf0b2d2d230c3cff6256239df3be 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md @@ -42,7 +42,7 @@ struct AnimateToExample { build() { Column() { - Button('change width and height') + Button('change size') .width(this.widthSize) .height(this.heightSize) .margin(30) @@ -57,8 +57,8 @@ struct AnimateToExample { console.info('play end') } }, () => { - this.widthSize = 100 - this.heightSize = 50 + this.widthSize = 150 + this.heightSize = 60 }) } else { animateTo({}, () => { @@ -77,7 +77,7 @@ struct AnimateToExample { curve: Curve.Friction, delay: 500, iterations: -1, // 设置-1表示动画无限循环 - playMode: PlayMode.AlternateReverse, + playMode: PlayMode.Alternate, onFinish: () => { console.info('play end') } @@ -90,10 +90,4 @@ struct AnimateToExample { } ``` -示意图: - -![animation](figures/animation.PNG) - -点击第一个按钮播放改变按钮大小的动画,点击第二个按钮播放按钮顺时针旋转90度的动画。 - -![animation1](figures/animation1.PNG) \ No newline at end of file +![animation1](figures/animation1.gif) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md b/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md index ee9d0f394150788b1aea9b45311fb81267cb6ed4..5621f3d58d9bac09a1623628b1f3871403dc908f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md @@ -34,7 +34,7 @@ | 名称 | 描述 | | -------- | -------- | | Normal | 不屏蔽子组件的手势,按照默认手势识别顺序进行识别。 | -| IgnoreInternal | 屏蔽子组件的手势,仅当前容器的手势进行识别。
子组件上系统内置的手势不会被屏蔽,如子组件为List组件时,内置的滑动手势仍然会触发。 | +| IgnoreInternal | 屏蔽子组件的手势,包括子组件上系统内置的手势,如子组件为List组件时,内置的滑动手势同样会被屏蔽。 | ## 响应手势事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md b/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md index ba54d01040d4c372cbcab714cd3b7c7e2f8b38f3..60a2352f3cab73db8afd799b52cc2ebce74186c9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md @@ -118,9 +118,9 @@ requestFullscreen(value: boolean) **参数:** -| 参数名 | 参数类型 | 必填 | 参数描述 | -| ----- | ------- | ---- | --------------------- | -| value | boolean | 是 | 是否全屏播放。
默认值:false | +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------ | -------- | ---- | -------------------------------------------------- | +| value | boolean | 是 | 是否全屏(填充满应用窗口)播放。
默认值:false | ### exitFullscreen @@ -173,7 +173,7 @@ struct VideoCreateComponent { previewUri: this.previewUri, currentProgressRate: this.curRate, controller: this.controller - }).width(800).height(600) + }).width('100%').height(600) .autoPlay(this.isAutoPlay) .controls(this.showControls) .onStart(() => { @@ -186,7 +186,7 @@ struct VideoCreateComponent { console.info('onFinish') }) .onError(() => { - console.info('onFinish') + console.info('onError') }) .onPrepared((e) => { console.info('onPrepared is ' + e.duration) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md index 2455f37d8358291ee204ed57fff3b1fce99e8911..91a807b281bd51dd0cf945435acddbfe5dbee18a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md @@ -37,6 +37,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, aut ```ts dialogController : CustomDialogController = new CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, autoCancel?: boolean}) ``` +**说明**:CustomDialogController仅在作为@CustomDialog和@Component struct的成员变量,且在@Component struct内部定义时赋值才有效,具体用法可看下方示例。 ### open() open(): void diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md index f3bd25442f3d688aec59f9ed2c3fb3a445d8398b..515389849fe32a961fecba1723d9394761d76400 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md @@ -21,6 +21,11 @@ show(options?: DatePickerDialogOptions) | end | Date | 否 | Date('2100-12-31') | 设置选择器的结束日期。 | | selected | Date | 否 | 当前系统日期 | 设置当前选中的日期。 | | lunar | boolean | 否 | false | 日期是否显示为农历。 | +| showTime10+ | boolean | 否 | false | 是否展示时间项。 | +| useMilitaryTime10+ | boolean | 否 | false | 展示时间是否为24小时制。 | +| disappearTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 否 | - | 设置所有选项中最上和最下两个选项的文本颜色、字号、字体粗细。 | +| textStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 否 | - | 设置所有选项中除了最上、最下及选中项以外的文本颜色、字号、字体粗细。 | +| selectedTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 否 | - | 设置选中项的文本颜色、字号、字体粗细。 | | onAccept | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult对象说明)) => void | 否 | - | 点击弹窗中的“确定”按钮时触发该回调。 | | onCancel | () => void | 否 | - | 点击弹窗中的“取消”按钮时触发该回调。 | | onChange | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult对象说明)) => void | 否 | - | 滑动弹窗中的滑动选择器使当前选中项改变时触发该回调。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md index 7bb99f5f46e8bcd2992b36025ca6e3c74a6465fc..ddcc46f2eb5f74f02de54e5d3d07c2f520e29609 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md @@ -17,10 +17,13 @@ show(options?: TextPickerDialogOptions) | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| range | string[] \| [Resource](ts-types.md#resource) | 是 | 设置文本选择器的选择范围。 | +| range | string[] \| [Resource](ts-types.md#resource)\|[TextPickerRangeContent](ts-basic-components-textpicker.md#textpickerrangecontent10类型说明)[]10+ | 是 | 设置文本选择器的选择范围。不可设置为空数组,若设置为空数组,则不弹出弹窗。 | | selected | number | 否 | 设置选中项的索引值。
默认值:0 | | value | string | 否 | 设置选中项的文本内容。当设置了selected参数时,该参数不生效。如果设置的value值不在range范围内,则默认取range第一个元素。| | defaultPickerItemHeight | number \| string | 否 | 设置选择器中选项的高度。 | +| disappearTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 否 | 设置所有选项中最上和最下两个选项的文本颜色、字号、字体粗细。 | +| textStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 否 | 设置所有选项中除了最上、最下及选中项以外的文本颜色、字号、字体粗细。 | +| selectedTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 否 | 设置选中项的文本颜色、字号、字体粗细。 | | onAccept | (value: [TextPickerResult](#textpickerresult对象说明)) => void | 否 | 点击弹窗中的“确定”按钮时触发该回调。 | | onCancel | () => void | 否 | 点击弹窗中的“取消”按钮时触发该回调。 | | onChange | (value: [TextPickerResult](#textpickerresult对象说明)) => void | 否 | 滑动弹窗中的选择器使当前选中项改变时触发该回调。 | @@ -29,7 +32,7 @@ show(options?: TextPickerDialogOptions) | 名称 | 类型 | 描述 | | -------- | -------- | -------- | -| value | string | 选中项的文本内容。 | +| value | string | 选中项的文本内容。
**说明**:当显示文本或图片加文本列表时,value值为选中项中的文本值,
当显示图片列表时,value值为空。 | | index | number | 选中项在选择范围数组中的索引值。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md index 97229576c98b61f2d7fb69cf0512adc03e00f8c6..fbd598c3269e88184ad54c1c704cf08b9274c50a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md @@ -19,6 +19,9 @@ show(options?: TimePickerDialogOptions) | -------- | -------- | -------- | -------- | | selected | Date | 否 | 设置当前选中的时间。
默认值:当前系统时间 | | useMilitaryTime | boolean | 否 | 展示时间是否为24小时制,默认为12小时制。
默认值:false | +| disappearTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 否 | 设置所有选项中最上和最下两个选项的文本颜色、字号、字体粗细。 | +| textStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 否 | 设置所有选项中除了最上、最下及选中项以外的文本颜色、字号、字体粗细。 | +| selectedTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10类型说明) | 否 | 设置选中项的文本颜色、字号、字体粗细。 | | onAccept | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult对象说明)) => void | 否 | 点击弹窗中的“确定”按钮时触发该回调。 | | onCancel | () => void | 否 | 点击弹窗中的“取消”按钮时触发该回调。 | | onChange | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult对象说明)) => void | 否 | 滑动弹窗中的选择器使当前选中时间改变时触发该回调。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-motion-path-animation.md b/zh-cn/application-dev/reference/arkui-ts/ts-motion-path-animation.md index adb197b0bff707b0f237933e1b48e21689e1154a..7b7bbcf002c7b6c351e3ef1e0d21f809d1383b14 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-motion-path-animation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-motion-path-animation.md @@ -11,7 +11,7 @@ | 名称 | 参数类型 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -| motionPath | {
path: string,
from?: number,
to?: number,
rotatable?: boolean
}
**说明:**
path中支持使用start和end进行起点和终点的替代,如:
'Mstart.x start.y L50 50 Lend.x end.y Z',更多说明请参考[绘制路径](../../ui/ui-js-components-svg-path.md)。 | {
'',
0.0,
1.0,
false
} | 设置组件的运动路径,入参说明如下:
- path:位移动画的运动路径,使用svg路径字符串。
- from:运动路径的起点,默认为0.0。
- to:运动路径的终点,默认为1.0。
- rotatable:是否跟随路径进行旋转。 | +| motionPath | {
path: string,
from?: number,
to?: number,
rotatable?: boolean
}
**说明:**
path中支持使用start和end进行起点和终点的替代,如:
'Mstart.x start.y L50 50 Lend.x end.y Z',更多说明请参考[绘制路径](../../ui/ui-js-components-svg-path.md)。 | {
'',
0.0,
1.0,
false
} | 设置组件的运动路径,入参说明如下:
- path:位移动画的运动路径,使用svg路径字符串。
- from:运动路径的起点。
默认值:0.0
取值范围:[0, 1]
设置小于0的值时,按值为0处理。设置大于1的值时,按值为1处理。
- to:运动路径的终点。
默认值:1.0
取值范围:[0, 1]
设置小于0的值时,按值为0处理。设置大于1的值时,按值为1处理。
- rotatable:是否跟随路径进行旋转。 | ## 示例 @@ -25,7 +25,7 @@ struct MotionPathExample { build() { Column() { - Button('click me') + Button('click me').margin(50) // 执行动画:从起点移动到(300,200),再到(300,500),再到终点 .motionPath({ path: 'Mstart.x start.y L300 200 L300 500 Lend.x end.y', from: 0.0, to: 1.0, rotatable: true }) .onClick(() => { 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 f2331b28049e098d21a064f5f75519e69e9d1075..6c92ac2d49ca83c70e4c814d64bf823804c9db33 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 @@ -1,6 +1,6 @@ # 页面间转场 -在全局pageTransition方法内配置页面入场和页面退场时的自定义转场动效。 +当路由进行切换时,可以通过 在pageTransition中自定义页面入场和页面退场的转场动效。 > **说明:** > @@ -10,8 +10,8 @@ | 名称 | 参数 | 参数描述 | | ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| PageTransitionEnter | {
type?: RouteType,
duration?: number,
curve?: [Curve](ts-appendix-enums.md#curve) \| string,
delay?: number
} | 设置当前页面的自定义入场动效。
- type:页面转场效果生效的路由类型。
默认值:RouteType.None。
**说明:** 没有匹配时使用系统默认的页面转场效果(根据设备可能会有差异),如需禁用系统默认页面转场效果,可以指定duration为0。
- duration:动画的时长,单位为毫秒。
- curve:动画曲线。string类型的取值支持"ease"、"ease-in"、"ease-out"、"ease-in-out"、"extreme-deceleration"、"fast-out-linear-in"、"fast-out-slow-in"、"friction"、"linear"、"linear-out-slow-in"、"rhythm"、"sharp"、"smooth"。
默认值:Curve.Linear
- delay:动画延迟时长,单位为毫秒,默认不延迟播放。 | -| PageTransitionExit | {
type?: RouteType,
duration?: number,
curve?: [Curve](ts-appendix-enums.md#curve) \| string,
delay?: number
} | 设置当前页面的自定义退场动效。
- type:页面转场效果生效的路由类型。
默认值:RouteType.None。
**说明:** 没有匹配时使用系统默认的页面转场效果(根据设备可能会有差异),如需禁用系统默认页面转场效果,可以指定duration为0。
- duration:动画的时长,单位为毫秒。
- curve:动画曲线,string类型取值与PageTransitionEnter相同。
 默认值:Curve.Linear
- delay:动画延迟时长,单位为毫秒,默认不延迟播放。 | +| PageTransitionEnter | {
type?: RouteType,
duration?: number,
curve?: [Curve](ts-appendix-enums.md#curve) \| string,
delay?: number
} | 设置当前页面的自定义入场动效。
- type:页面转场效果生效的路由类型。
默认值:RouteType.None。
**说明:**
没有匹配时使用系统默认的页面转场效果(根据设备可能会有差异),如需禁用系统默认页面转场效果,可以指定duration为0。
- duration:动画的时长
单位:毫秒
- curve:动画曲线。string类型的取值支持"ease"、"ease-in"、"ease-out"、"ease-in-out"、"extreme-deceleration"、"fast-out-linear-in"、"fast-out-slow-in"、"friction"、"linear"、"linear-out-slow-in"、"rhythm"、"sharp"、"smooth"。
默认值:Curve.Linear
- delay:动画延迟时长。
默认值:0
单位:毫秒 | +| PageTransitionExit | {
type?: RouteType,
duration?: number,
curve?: [Curve](ts-appendix-enums.md#curve) \| string,
delay?: number
} | 设置当前页面的自定义退场动效。
- type:页面转场效果生效的路由类型。
默认值:RouteType.None。
**说明:**
没有匹配时使用系统默认的页面转场效果(根据设备可能会有差异),如需禁用系统默认页面转场效果,可以指定duration为0。
- duration:动画的时长,单位为毫秒。
- curve:动画曲线,string类型取值与PageTransitionEnter相同。
 默认值:Curve.Linear
- delay:动画延迟时长。
默认值:0
单位:毫秒 | ## RouteType枚举说明 @@ -45,8 +45,8 @@ | 事件 | 功能描述 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| onEnter(event: (type?: RouteType, progress?: number) => void) | 回调入参为当前入场动画的归一化进度[0 - 1]。
- type:跳转方法。
- progress:当前进度。 | -| onExit(event: (type?: RouteType, progress?: number) => void) | 回调入参为当前退场动画的归一化进度[0 - 1]。
- type:跳转方法。
- progress:当前进度。 | +| onEnter(event: (type?: RouteType, progress?: number) => void) | 回调入参为当前入场动画的归一化进度[0 - 1]。
- type:跳转方法。
- progress:当前进度。
触发该事件的条件:
逐帧回调,直到入场动画结束,progress从0变化到1。 | +| onExit(event: (type?: RouteType, progress?: number) => void) | 回调入参为当前退场动画的归一化进度[0 - 1]。
- type:跳转方法。
- progress:当前进度。
触发该事件的条件:
逐帧回调,直到退场动画结束,progress从0变化到1。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-component.md b/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-component.md index f61a0286729dd0b62396baf06aa74e0269eb811f..8d2253624748281833834205d7620d6d25cc6cb4 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-component.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-component.md @@ -12,14 +12,14 @@ | 名称 | 参数类型 | 参数描述 | | -------- | -------- | -------- | -| transition | TransitionOptions | 所有参数均为可选参数,详细描述见TransitionOptions参数说明。 | +| transition | TransitionOptions | 设置组件插入显示和删除隐藏的过渡效果。
默认值:不设置任何过渡效果时,默认有透明度从0到1的过渡效果。若设置了其他过渡效果,以设置的过渡效果为准。
**说明:**
所有参数均为可选参数,详细描述见TransitionOptions参数说明。 | ## TransitionOptions参数说明 | 参数名称 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | | type | [TransitionType](ts-appendix-enums.md#transitiontype) | 否 | 默认包括组件新增和删除。
默认值:TransitionType.All
**说明:**
不指定Type时说明插入删除使用同一种效果。 | -| opacity | number | 否 | 设置组件转场时的透明度效果,为插入时起点和删除时终点的值。
默认值:1 | +| opacity | number | 否 | 设置组件转场时的透明度效果,为插入时起点和删除时终点的值。
默认值:1
取值范围: [0, 1]
**说明:**
设置小于0的值时,按值为0处理;设置大于1的值时,按值为1处理。 | | translate | {
x? : number \| string,
y? : number \| string,
z? : number \| string
} | 否 | 设置组件转场时的平移效果,为插入时起点和删除时终点的值。
-x:横向的平移距离。
-y:纵向的平移距离。
-z:竖向的平移距离。 | | scale | {
x? : number,
y? : number,
z? : number,
centerX? : number \| string,
centerY? : number \| string
} | 否 | 设置组件转场时的缩放效果,为插入时起点和删除时终点的值。
-x:横向放大倍数(或缩小比例)。
-y:纵向放大倍数(或缩小比例)。
-z:竖向放大倍数(或缩小比例)。
- centerX、centerY指缩放中心点,centerX和centerY默认值是"50%"。
- 中心点为0时,默认的是组件的左上角。
| | rotate | {
x?: number,
y?: number,
z?: number,
angle?: number \| string,
centerX?: number \| string,
centerY?: number \| string
} | 否 | 设置组件转场时的旋转效果,为插入时起点和删除时终点的值。
-x:横向的旋转向量。
-y:纵向的旋转向量。
-z:竖向的旋转向量。
- centerX,centerY指旋转中心点,centerX和centerY默认值是"50%"。
- 中心点为(0,0)时,默认的是组件的左上角。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md b/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md index a30820399e7e66b72019e7a5a111b3157308a27f..87c656eecb0d185fa13b2a88577f02faa6e60c34 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md @@ -1,6 +1,6 @@ # 共享元素转场 -设置页面间转场时共享元素的转场动效。 +当路由进行切换时,可以通过设置组件的 sharedTransition 属性将该元素标记为共享元素并设置对应的共享元素转场动效。 > **说明:** > @@ -12,7 +12,7 @@ | 名称 | 参数 | 参数描述 | | ---------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| sharedTransition | id: string,
{
 duration?: number,
 curve?: Curve \| string,
 delay?: number,
 motionPath?:
{
 path: string,
 form?: number,
 to?: number,
 rotatable?: boolean
},
zIndex?: number,
type?: [SharedTransitionEffectType](ts-appendix-enums.md#sharedtransitioneffecttype)
} | 两个页面中id值相同且不为空字符串的组件即为共享元素,在页面转场时可显示共享元素转场动效。
- id:设置组件的id。
- duration:单位为毫秒,默认动画时长为1000毫秒。
- curve:默认曲线为Linear,有效值参见[Curve](ts-animatorproperty.md)说明。
- delay:单位为毫秒,默认不延时播放。
- motionPath:运动路径信息,详细说明请参考[路径动画](ts-motion-path-animation.md)。
- path:设置路径。
- from:设置起始值。
- to:设置终止值。
- rotatable:是否旋转。
- zIndex:设置Z轴。
- type:动画类型。 | +| sharedTransition | id: string,
{
 duration?: number,
 curve?: Curve \| string,
 delay?: number,
 motionPath?:
{
 path: string,
 form?: number,
 to?: number,
 rotatable?: boolean
},
zIndex?: number,
type?: [SharedTransitionEffectType](ts-appendix-enums.md#sharedtransitioneffecttype)
} | 两个页面中id值相同且不为空字符串的组件即为共享元素,在页面转场时可显示共享元素转场动效。
- id:设置组件的id。
- duration:描述共享元素转场动效播放时长。
默认值:1000
单位:毫秒
取值范围:[0, +∞)
值为0时表示无动画。设置小于0的值时,按值为0处理。
- curve:默认曲线为Linear,有效值参见[Curve](ts-animatorproperty.md)说明。
- delay:用来描述共享元素转场动效延迟播放的时长。
默认值:0
单位:毫秒
取值范围:[0, +∞)
设置小于0的值时,按值为0处理。
- motionPath:运动路径信息,详细说明请参考[路径动画](ts-motion-path-animation.md)。
- path:设置路径。
- from:设置起始值。
- to:设置终止值。
- rotatable:是否旋转。
- zIndex:设置Z轴。
- type:动画类型。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-types.md b/zh-cn/application-dev/reference/arkui-ts/ts-types.md index 10348a88a641f6aa4ff7cddf686ade9a621b1b46..6dea36b625b7a3d267bf8f9066b6d244e298f1f7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-types.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-types.md @@ -122,8 +122,8 @@ | 类型 | 说明 | | ---------------------------------------- | ------------------------------------------------- | | [Color](ts-appendix-enums.md#color) | 颜色枚举值。 | -| number | HEX格式颜色。 | -| string | rgb或者rgba格式颜色。 | +| number | HEX格式颜色,支持rgb。 | +| string | rgb或者argb格式颜色。 | | [Resource](#resource) | 使用引入资源的方式,引入系统资源或者应用资源中的颜色。 | ## ColoringStrategy @@ -132,7 +132,7 @@ | 名称 | 描述 | | --------- | ------- | -| Invert | 设置前景色为控件背景色的反色。| +| INVERT | 设置前景色为控件背景色的反色。| ## LengthConstrain 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 d3ce69c6dae140a33f2a6f68ebf0757a9c9fc09c..4107ebe46ad7c0104ea0500e3121483272197ef4 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 @@ -11,8 +11,8 @@ | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | backgroundColor | [ResourceColor](ts-types.md#resourcecolor) | 设置组件的背景色。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| backgroundImage | src: [ResourceStr](ts-types.md#resourcestr),
repeat?: [ImageRepeat](ts-appendix-enums.md#imagerepeat) | src:图片地址,支持网络图片资源和本地图片资源地址(不支持svg类型的图片)。
repeat:设置背景图片的重复样式,默认不重复。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| backgroundImageSize | {
width?: [Length](ts-types.md#length),
height?: [Length](ts-types.md#length)
} \| [ImageSize](ts-appendix-enums.md#imagesize) | 设置背景图像的高度和宽度。当输入为{width: Length, height: Length}对象时,如果只设置一个属性,则第二个属性保持图片原始宽高比进行调整。默认保持原图的比例不变。
默认值:ImageSize.Auto
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| backgroundImage | src: [ResourceStr](ts-types.md#resourcestr),
repeat?: [ImageRepeat](ts-appendix-enums.md#imagerepeat) | src:图片地址,支持网络图片资源地址和本地图片资源地址和Base64,不支持svg类型的图片。
repeat:设置背景图片的重复样式,默认不重复。当设置的背景图片为透明底色图片,且同时设置了backgroundColor时,二者叠加显示,背景颜色在最底部。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| backgroundImageSize | {
width?: [Length](ts-types.md#length),
height?: [Length](ts-types.md#length)
} \| [ImageSize](ts-appendix-enums.md#imagesize) | 设置背景图像的高度和宽度。当输入为{width: Length, height: Length}对象时,如果只设置一个属性,则第二个属性保持图片原始宽高比进行调整。默认保持原图的比例不变。
width和height取值范围: [0, +∞)
默认值:ImageSize.Auto
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
设置为小于0的值时,按值为0显示。当设置了height未设置width时,width根据图片原始宽高比进行调整。 | | backgroundImagePosition | [Position](ts-types.md#position8) \| [Alignment](ts-appendix-enums.md#alignment) | 设置背景图在组件中显示位置,即相对于组件左上角的坐标。
默认值:
{
x: 0,
y: 0
}
x和y值设置百分比时,偏移量是相对组件自身宽高计算的。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-foreground-color.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-foreground-color.md index 0495a78c6e22b957c34aa76d550391ceb05b4f7e..f84e074a3f753252303a35494fe0eade922a8476 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-foreground-color.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-foreground-color.md @@ -10,7 +10,7 @@ | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| foregroundColor | [ResourceColor](ts-types.md#resourcecolor) \| [ColoringStrategy](ts-types.md#ColoringStrategy) | 设置组件的前景颜色或者根据智能取色策略设置前景颜色。 | +| foregroundColor | [ResourceColor](ts-types.md#resourcecolor) \| [ColoringStrategy](ts-types.md#coloringstrategy) | 设置组件的前景颜色或者根据智能取色策略设置前景颜色。 | ## 示例 @@ -47,12 +47,11 @@ struct ColoringStrategyExample { // 绘制一个直径为150的圆,设置前景色为组件背景色的反色 Circle({ width: 150, height: 200 }) .backgroundColor(Color.Black) - .foregroungColor(ColoringStrategy.Invert) + .foregroundColor(ColoringStrategy.INVERT) }.width('100%') } } ``` - ![foregroundColor_circle](figures/ColoringStrategy_circle.png) ### 示例3 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 bd84c5ac35432f3649a2f6c3e7d0365746a1858f..bb90448db55d8c50bb909e7f0a549e4d7ee9b478 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 @@ -12,9 +12,9 @@ | 名称 | 参数类型 | 描述 | | -------------- | -------------------------------------------- | ----------------------------------- | -| linearGradient | {
angle?: number \| string,
direction?: [GradientDirection](ts-appendix-enums.md#gradientdirection),
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | 线性渐变。
- angle: 线性渐变的起始角度。0点方向顺时针旋转为正向角度。
默认值:180
- direction: 线性渐变的方向,设置angle后不生效。
默认值:GradientDirection.Bottom
- colors: 为渐变的颜色描述。
- repeating: 为渐变的颜色重复着色。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| sweepGradient | {
center: Point,
start?: number \| string,
end?: number \| string,
rotation?: number\|string,
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | 角度渐变,仅绘制0-360度范围内的角度,超出时不绘制渐变色,只绘制纯色。
- center:为角度渐变的中心点,即相对于当前组件左上角的坐标。
- start:角度渐变的起点。
默认值:0
- end:角度渐变的终点。
默认值:0
- rotation: 角度渐变的旋转角度。
默认值:0
- colors: 为渐变的颜色描述。
- repeating: 为渐变的颜色重复着色。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| radialGradient | {
center: Point,
radius: number \| string,
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | 径向渐变。
- center:径向渐变的中心点,即相对于当前组件左上角的坐标。
- radius:径向渐变的半径。
- colors: 为渐变的颜色描述。
- repeating: 为渐变的颜色重复着色。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| linearGradient | {
angle?: number \| string,
direction?: [GradientDirection](ts-appendix-enums.md#gradientdirection),
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | 线性渐变。
- angle: 线性渐变的起始角度。0点方向顺时针旋转为正向角度。
默认值:180
- direction: 线性渐变的方向,设置angle后不生效。
默认值:GradientDirection.Bottom
- colors: 渐变的颜色描述。
- repeating: 为渐变的颜色重复着色。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| sweepGradient | {
center: Point,
start?: number \| string,
end?: number \| string,
rotation?: number\|string,
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | 角度渐变,仅绘制0-360度范围内的角度,超出时不绘制渐变色,只绘制纯色。
- center:为角度渐变的中心点,即相对于当前组件左上角的坐标。
- start:角度渐变的起点。
 默认值:0
- end:角度渐变的终点。
 默认值:0
- rotation: 角度渐变的旋转角度。
 默认值:0
- colors: 为渐变的颜色描述。
- repeating: 为渐变的颜色重复着色。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
设置为小于0的值时,按值为0处理,设置为大于360的值时,按值为360处理。
当start、end、rotation的数据类型为string,值为"90"或"90%",与90效果一致 | +| radialGradient | {
center: Point,
radius: number \| string,
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | 径向渐变。
- center:径向渐变的中心点,即相对于当前组件左上角的坐标。
- radius:径向渐变的半径。
 取值范围 [0,+∞)
  **说明:**
设置为小于的0值时,按值为0处理。
- colors: 为渐变的颜色描述。
- repeating: 为渐变的颜色重复着色。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-grid.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-grid.md index a81f4e0390a61127903e9ca41168c6b2e8786c1a..1e65c994d71e3e8b7db3c18b160a58aedc6a3374 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-grid.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-grid.md @@ -12,8 +12,8 @@ | 名称 | 参数类型 | 描述 | | ----------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| useSizeType | {
xs?: number \| { span: number, offset: number },
sm?: number \| { span: number, offset: number },
md?: number \| { span: number, offset: number },
lg?: number \| { span: number, offset: number }
} | 设置在特定设备宽度类型下的占用列数和偏移列数,span: 占用列数; offset: 偏移列数。
当值为number类型时,仅设置列数, 当格式如{"span": 1, "offset": 0}时,指同时设置占用列数与偏移列数。
- xs: 指设备宽度类型为SizeType.XS时的占用列数和偏移列数。
- sm: 指设备宽度类型为SizeType.SM时的占用列数和偏移列数。
- md: 指设备宽度类型为SizeType.MD时的占用列数和偏移列数。
- lg: 指设备宽度类型为SizeType.LG时的占用列数和偏移列数。 | -| gridSpan | number | 默认占用列数,指useSizeType属性没有设置对应尺寸的列数(span)时,占用的栅格列数。
**说明:**
设置了栅格span属性,组件的宽度由栅格布局决定。
默认值:1 | +| useSizeType(deprecated) | {
xs?: number \| { span: number, offset: number },
sm?: number \| { span: number, offset: number },
md?: number \| { span: number, offset: number },
lg?: number \| { span: number, offset: number }
} | 设置在特定设备宽度类型下的占用列数和偏移列数,span: 占用列数; offset: 偏移列数。
当值为number类型时,仅设置列数, 当格式如{"span": 1, "offset": 0}时,指同时设置占用列数与偏移列数。
- xs: 指设备宽度类型为SizeType.XS时的占用列数和偏移列数。
- sm: 指设备宽度类型为SizeType.SM时的占用列数和偏移列数。
- md: 指设备宽度类型为SizeType.MD时的占用列数和偏移列数。
- lg: 指设备宽度类型为SizeType.LG时的占用列数和偏移列数。
该属性从API version 9开始废弃,推荐使用新组件[GridCol](ts-container-gridcol.md)、[GridRow](ts-container-gridrow.md)。 | +| gridSpan | number | 默认占用列数,指useSizeType属性没有设置对应尺寸的列数(span)时,占用的栅格列数。
**说明:**
设置了栅格span属性,组件的宽度由栅格布局决定。
默认值:1 | | gridOffset | number | 默认偏移列数,指useSizeType属性没有设置对应尺寸的偏移(offset)时, 当前组件沿着父组件Start方向,偏移的列数,也就是当前组件位于第n列。
**说明:**
- 配置该属性后,当前组件在父组件水平方向的布局不再跟随父组件原有的布局方式,而是沿着父组件的Start方向偏移一定位移。
- 偏移位移 = (列宽 + 间距)\* 列数。
- 设置了偏移(gridOffset)的组件之后的兄弟组件会根据该组件进行相对布局,类似相对布局。
默认值:0 | 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 36fbde66b13830a33a59b8811ee733531d583cb7..a2666355283735e6935d12b6faf42a3fba6d683b 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 @@ -12,16 +12,16 @@ | 名称 | 参数类型 | 默认值 | 描述 | | ----------------------------- | ------------------------------------------------------------ | ------ | ------------------------------------------------------------ | -| blur | number | - | 为当前组件添加内容模糊效果,入参为模糊半径,模糊半径越大越模糊,为0时不模糊。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| backdropBlur | number | - | 为当前组件添加背景模糊效果,入参为模糊半径,模糊半径越大越模糊,为0时不模糊。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| blur | number | - | 为当前组件添加内容模糊效果,入参为模糊半径,模糊半径越大越模糊,为0时不模糊。
取值范围:[0, +∞)
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| backdropBlur | number | - | 为当前组件添加背景模糊效果,入参为模糊半径,模糊半径越大越模糊,为0时不模糊。
取值范围:[0, +∞)
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | shadow | [ShadowOptions](#shadowoptions对象说明) \| [ShadowStyle](#shadowstyle10枚举说明) | - | 为当前组件添加阴影效果。
入参类型为ShadowOptions时,可以指定模糊半径、阴影的颜色、X轴和Y轴的偏移量。
入参类型为ShadowStyle时,可指定不同阴影样式。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
ArkTS卡片上不支持参数为 [ShadowStyle](#shadowstyle10枚举说明)类型。 | -| grayscale | number | 0.0 | 为当前组件添加灰度效果。值定义为灰度转换的比例,入参1.0则完全转为灰度图像,入参则0.0图像无变化,入参在0.0和1.0之间时,效果呈线性变化。(百分比)
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| brightness | number | 1.0 | 为当前组件添加高光效果,入参为高光比例,值为1时没有效果,小于1时亮度变暗,0为全黑;大于1时亮度增加,数值越大亮度越大。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| saturate | number | 1.0 | 为当前组件添加饱和度效果,饱和度为颜色中的含色成分和消色成分(灰)的比例,入参为1时,显示原图像,大于1时含色成分越大,饱和度越大;小于1时消色成分越大,饱和度越小。(百分比)
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| contrast | number | 1.0 | 为当前组件添加对比度效果,入参为对比度的值,值为1时,显示原图;大于1时,值越大对比度越高,图像越清晰醒目;小于1时,值越小对比度越低;当对比度为0时,图像变为全灰。(百分比)
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| invert | number | 0 | 反转输入的图像。入参为图像反转的比例。值为1时完全反转。值为0则图像无变化。(百分比)
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| sepia | number | 0 | 将图像转换为深褐色。入参为图像反转的比例。值为1则完全是深褐色的,值为0图像无变化。 (百分比)
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| hueRotate | number \| string | '0deg' | 色相旋转效果,输入参数为旋转角度。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| grayscale | number | 0.0 | 为当前组件添加灰度效果。值定义为灰度转换的比例,入参1.0则完全转为灰度图像,入参则0.0图像无变化,入参在0.0和1.0之间时,效果呈线性变化。(百分比)
取值范围:[0, 1]
**说明:**
设置小于0的值时,按值为0处理,设置大于1的值时,按值为1处理。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| brightness | number | 1.0 | 为当前组件添加高光效果,入参为高光比例,值为1时没有效果,小于1时亮度变暗,0为全黑,大于1时亮度增加,数值越大亮度越大。
取值范围:[0, +∞)
**说明:**
设置小于0的值时,按值为0处理。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| saturate | number | 1.0 | 为当前组件添加饱和度效果,饱和度为颜色中的含色成分和消色成分(灰)的比例,入参为1时,显示原图像,大于1时含色成分越大,饱和度越大,小于1时消色成分越大,饱和度越小。(百分比)
取值范围:[0, +∞)
**说明:**
设置小于0的值时,按值为0处理。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| contrast | number | 1.0 | 为当前组件添加对比度效果,入参为对比度的值。值为1时,显示原图,大于1时,值越大对比度越高,图像越清晰醒目,小于1时,值越小对比度越低,当对比度为0时,图像变为全灰。(百分比)
取值范围:[0, +∞)
**说明:**
设置小于0的值时,按值为0处理。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| invert | number | 0 | 反转输入的图像。入参为图像反转的比例,值为1时完全反转,值为0则图像无变化。(百分比)
取值范围:[0, 1]
**说明:**
设置小于0的值时,按值为0处理。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| sepia | number | 0 | 将图像转换为深褐色。入参为图像反转的比例,值为1则完全是深褐色的,值为0图像无变化。 (百分比)
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| hueRotate | number \| string | '0deg' | 色相旋转效果,输入参数为旋转角度。
取值范围:(-∞, +∞)
**说明:**
色调旋转360度会显示原始颜色。先将色调旋转180 度,然后再旋转-180度会显示原始颜色。数据类型为number时,值为90和'90deg'效果一致。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | colorBlend 8+ | [Color](ts-appendix-enums.md#color) \| string \| [Resource](ts-types.md#resource) | - | 为当前组件添加颜色叠加效果,入参为叠加的颜色。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | ## ShadowOptions对象说明 @@ -32,8 +32,8 @@ | 名称 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | --------------- | -| radius | number \| [Resource](ts-types.md#resource) | 是 | 阴影模糊半径。 | -| color | [Color](ts-appendix-enums.md#color) \| string \| [Resource](ts-types.md#resource) | 否 | 阴影的颜色。
默认为灰色。 | +| radius | number \| [Resource](ts-types.md#resource) | 是 | 阴影模糊半径。
取值范围:[0, +∞)
**说明:**
设置小于0的值时,按值为0处理。 | +| color | [Color](ts-appendix-enums.md#color) \| string \| [Resource](ts-types.md#resource) | 否 | 阴影的颜色。
默认为黑色。 | | offsetX | number \| [Resource](ts-types.md#resource) | 否 | 阴影的X轴偏移量。
默认为0。 | | offsetY | number \| [Resource](ts-types.md#resource) | 否 | 阴影的Y轴偏移量。
默认为0。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md index 8f1b3645866cd02f121c59f4296e04689252c190..575ec64ce95aaa7084206efff6bde0c8926751f3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md @@ -14,7 +14,7 @@ | -------- | -------- | -------- | | align | [Alignment](ts-appendix-enums.md#alignment) | 设置元素内容在元素绘制区域内的对齐方式。
默认值:Alignment.Center
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | direction | [Direction](ts-appendix-enums.md#direction) | 设置元素水平方向的布局。
默认值:Direction.Auto
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| position | [Position](ts-types.md#position8) | 绝对定位,设置元素左上角相对于父容器左上角偏移位置。在布局容器中,设置该属性不影响父容器布局,仅在绘制时进行位置调整。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| position | [Position](ts-types.md#position8) | 绝对定位,设置元素左上角相对于父容器左上角偏移位置。在布局容器中,设置该属性不影响父容器布局,仅在绘制时进行位置调整。
适用于置顶显示、悬浮按钮等组件在父容器中位置固定的场景。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | markAnchor | [Position](ts-types.md#position8) | 设置元素在位置定位时的锚点,以元素左上角作为基准点进行偏移。通常配合position和offset属性使用,单独使用时,效果类似offset
默认值:
{
x: 0,
y: 0
}
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | offset | [Position](ts-types.md#position8) | 相对定位,设置元素相对于自身的偏移量。设置该属性,不影响父容器布局,仅在绘制时进行位置调整。
默认值:
{
x: 0,
y: 0
}
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | alignRules9+ | {
left?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };
right?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };
middle?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };
top?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) };
bottom?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) };
center?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) }
} | 指定相对容器的对齐规则,仅当父容器为[RelativeContainer](ts-container-relativecontainer.md)时生效。
- left:设置左对齐参数。
- right:设置右对齐参数。
- middle:设置中间对齐的参数。
- top:设置顶部对齐的参数。
- bottom:设置底部对齐的参数。
- center:设置中心对齐的参数。
该接口支持在ArkTS卡片中使用。
**说明:**
- anchor:设置作为锚点的组件的id值。
- align:设置相对于锚点组件的对齐方式。 | @@ -32,19 +32,15 @@ struct PositionExample1 { Column({ space: 10 }) { // 元素内容<元素宽高,设置内容在与元素内的对齐方式 Text('align').fontSize(9).fontColor(0xCCCCCC).width('90%') - Text('top start') - .align(Alignment.TopStart) - .height(50) - .width('90%') - .fontSize(16) - .backgroundColor(0xFFE4C4) - - Text('Bottom end') - .align(Alignment.BottomEnd) - .height(50) - .width('90%') - .fontSize(16) - .backgroundColor(0xFFE4C4) + Stack() { + Text('First show in bottom end').height('65%').backgroundColor(0xD2B48C) + Text('Second show in bottom end').backgroundColor(0xF5DEB3).opacity(0.9) + }.width('90%').height(50).margin({ top: 5 }).backgroundColor(0xFFE4C4) + .align(Alignment.BottomEnd) + Stack() { + Text('top start') + }.width('90%').height(50).margin({ top: 5 }).backgroundColor(0xFFE4C4) + .align(Alignment.TopStart) // 父容器设置direction为Direction.Ltr,子元素从左到右排列 Text('direction').fontSize(9).fontColor(0xCCCCCC).width('90%') @@ -86,6 +82,7 @@ struct PositionExample2 { Text('position').fontSize(12).fontColor(0xCCCCCC).width('90%') Row() { Text('1').size({ width: '30%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16) + .textAlign(TextAlign.Center) Text('2 position(30, 10)') .size({ width: '60%', height: '30' }) .backgroundColor(0xbbb2cb) @@ -94,6 +91,7 @@ struct PositionExample2 { .align(Alignment.Start) .position({ x: 30, y: 10 }) Text('3').size({ width: '45%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16) + .textAlign(TextAlign.Center) Text('4 position(50%, 70%)') .size({ width: '50%', height: '50' }) .backgroundColor(0xbbb2cb) @@ -110,14 +108,20 @@ struct PositionExample2 { .size({ width: '100', height: '100' }) .backgroundColor(0xdeb887) Text('text') + .fontSize('30px') + .textAlign(TextAlign.Center) .size({ width: 25, height: 25 }) .backgroundColor(Color.Green) .markAnchor({ x: 25, y: 25 }) Text('text') + .fontSize('30px') + .textAlign(TextAlign.Center) .size({ width: 25, height: 25 }) .backgroundColor(Color.Green) .markAnchor({ x: -100, y: -25 }) Text('text') + .fontSize('30px') + .textAlign(TextAlign.Center) .size({ width: 25, height: 25 }) .backgroundColor(Color.Green) .markAnchor({ x: 25, y: -25 }) @@ -127,6 +131,7 @@ struct PositionExample2 { Text('offset').fontSize(12).fontColor(0xCCCCCC).width('90%') Row() { Text('1').size({ width: '15%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16) + .textAlign(TextAlign.Center) Text('2 offset(15, 30)') .size({ width: 120, height: '50' }) .backgroundColor(0xbbb2cb) @@ -135,6 +140,7 @@ struct PositionExample2 { .align(Alignment.Start) .offset({ x: 15, y: 30 }) Text('3').size({ width: '15%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16) + .textAlign(TextAlign.Center) Text('4 offset(-10%, 20%)') .size({ width: 100, height: '50' }) .backgroundColor(0xbbb2cb) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md index e95f066470d5881d87ab5b2e32b56b9b25a158a7..e15fc1b17998ce850e2943cb213129e24f0153be 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md @@ -10,18 +10,25 @@ ## 属性 -| 名称 | 参数类型 | 描述 | +| 名称 | 参数类型 | 描述 | | ---------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| bindMenu | Array<[MenuItem](#menuitem)> \| [CustomBuilder](ts-types.md#custombuilder8) | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持文本和自定义两种功能。 | +| bindMenu | content: Array<[MenuItem](#menuitem)> \| [CustomBuilder](ts-types.md#custombuilder8),
options10+: [MenuOptions](#menuoptions10)10+ | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持图标+文本排列和自定义两种功能。
content: 必填,配置菜单项图标和文本的数组,或者自定义组件
options: 非必填,配置弹出菜单的参数 | | bindContextMenu8+ | content: [CustomBuilder](ts-types.md#custombuilder8),
responseType: [ResponseType](ts-appendix-enums.md#responsetype8) | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。 | ## MenuItem -| 名称 | 类型 | 描述 | -| ------ | ----------------------- | ----------- | -| value | string | 菜单项文本。 | -| action | () => void | 点击菜单项的事件回调。 | +| 名称 | 类型 | 必填 | 描述 | +| ------------------ | -------------------------------------- | ---- | ---------------------- | +| value | string | 是 | 菜单项文本。 | +| icon10+ | [ResourceStr](ts-types.md#resourcestr) | 否 | 菜单项图标。 | +| action | () => void | 是 | 点击菜单项的事件回调。 | +## MenuOptions10+ + +| 名称 | 类型 | 必填 | 描述 | +| ------ | -------------------------------- | ---- | ------------------------------------------------------ | +| title | string | 否 | 菜单标题。 | +| offset | [Position](ts-types.md#position8) | 否 | 菜单弹出位置的偏移量,不会导致菜单显示超出屏幕范围。 | ## 示例 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 54de8ab03769624a928d9a1dc3e2fe4fe3b2353a..f3b2f7d831c4d6fc6d83ae28e222238d8215d79f 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 @@ -26,7 +26,15 @@ | arrowOffset9+ | [Length](ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,数值为0表示箭头居最左侧,偏移量为箭头至最左侧的距离,默认居中。箭头在气泡左右侧时,偏移量为箭头至最上侧的距离,默认居中。如果显示在屏幕边缘,气泡会自动左右偏移,数值为0时箭头始终指向绑定组件。 | | showInSubWindow9+ | boolean | 否 | 是否在子窗口显示气泡,默认值为false。 | | mask10+ | boolean \| [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置气泡是否有遮罩层及遮罩颜色。如果设置为false,则没有遮罩层;如果设置为true,则设置有遮罩层并且颜色为透明色;如果设置为Color,则为遮罩层的颜色。 | +| messageOptions10+ | [PopupMessageOptions](#popupmessageoptions10) | 否 | 设置弹窗信息文本参数。 | +| targetSpace10+ | [Length](ts-types.md#length) | 否 | 设置popup与目标的间隙。 | +## PopupMessageOptions10+类型说明 + +| 名称 | 类型 | 必填 | 描述 | +| --------- | ------------------------------------------ | ---- | ---------------------- | +| textColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置弹窗信息文本颜色。 | +| font | [Font](ts-types.md#Font) | 否 | 设置弹窗信息字体属性。 | ## CustomPopupOptions8+类型说明 | 名称 | 类型 | 必填 | 描述 | @@ -40,7 +48,7 @@ | arrowOffset9+ | [Length](ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,数值为0表示箭头居最左侧,偏移量为箭头至最左侧的距离,默认居中。箭头在气泡左右侧时,偏移量为箭头至最上侧的距离,默认居中。如果显示在屏幕边缘,气泡会自动左右偏移,数值为0时箭头始终指向绑定组件。 | | showInSubWindow9+ | boolean | 否 | 是否在子窗口显示气泡,默认值为false。 | | mask10+ | boolean \| [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置气泡是否有遮罩层及遮罩颜色。如果设置为false,则没有遮罩层;如果设置为true,则设置有遮罩层并且颜色为透明色;如果设置为Color,则为遮罩层的颜色。 | - +| targetSpace10+ | [Length](ts-types.md#length) | 否 | 设置popup与目标的间隙。 | ## 示例 ```ts diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md index d7c6f070afe88b8046b38870ef2e7176491661d1..ec3199756cb5a8540ec57e1fcf176ae937400c60 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md @@ -13,11 +13,56 @@ | 名称 | 参数类型 | 描述 | | -----| ------------------------------------------ | ------------------------------------ | | clip | [Circle](ts-drawing-components-circle.md) \| [Ellipse](ts-drawing-components-ellipse.md) \| [Path](ts-drawing-components-path.md) \| [Rect](ts-drawing-components-rect.md) \| boolean | 参数为相应类型的组件,按指定的形状对当前组件进行裁剪;参数为boolean类型时,设置是否按照父容器边缘轮廓进行裁剪。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| mask | [Circle](ts-drawing-components-circle.md) \| [Ellipse](ts-drawing-components-ellipse.md) \| [Path](ts-drawing-components-path.md) \| [Rect](ts-drawing-components-rect.md) | 在当前组件上加上指定形状的遮罩。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| mask | [Circle](ts-drawing-components-circle.md) \| [Ellipse](ts-drawing-components-ellipse.md) \| [Path](ts-drawing-components-path.md) \| [Rect](ts-drawing-components-rect.md)\| [ProgressMask](##progressmask10)  | 在当前组件上加上指定形状的遮罩。
从API version 9开始,该接口支持在ArkTS卡片中使用。
从API version 10开始,该接口支持ProgressMask参数。 | + +## ProgressMask10+ + +ProgressMask设置遮罩的进度、最大值和遮罩颜色。 + +### constructor10+ + +constructor(value: number, total: number, color: ResourceColor) + +构造ProgressMask对象。 + +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------ | ------------------------------------------ | ---- | ------------------ | +| value | number | 是 | 进度遮罩的当前值。 | +| total | number | 是 | 进度遮罩的最大值。 | +| color | [ResourceColor](ts-types.md#resourcecolor) | 是 | 进度遮罩的颜色。 | + +### updateProgress10+ + +updateProgress(value: number): void + +更新进度遮罩的进度值。 + +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------ | -------- | ---- | ------------------ | +| value | number | 是 | 进度遮罩的当前值。 | + +### updateColor10+ + +updateColor(value: ResourceColor): void + +更新进度遮罩的颜色。 + +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------ | ------------------------------------------ | ---- | ---------------- | +| value | [ResourceColor](ts-types.md#resourcecolor) | 是 | 进度遮罩的颜色。 | + ## 示例 +### 示例1 + ```ts // xxx.ets @Entry @@ -53,4 +98,62 @@ struct ClipAndMaskExample { } ``` -![clipAndMask](figures/clipAndMask.PNG) \ No newline at end of file +![clipAndMask](figures/clipAndMask.PNG) + +### 示例2 + +```ts +@Entry +@Component +struct ProgressMask { + @State progressflag1: boolean = true; + @State color: Color = 0x01006CDE; + @State value: number = 10.0; + @State progress: ProgressMask = new ProgressMask(10.0, 100.0, Color.Gray); + build() { + Column({ space: 15 }) { + Text('progress mask').fontSize(12).width('75%').fontColor('#DCDCDC') + // 给图片添加了一个280px*280px的进度遮罩 + Image($r('app.media.testImg')) + .width('500px').height('280px') + .mask(this.progress) + .animation({ + duration: 2000, // 动画时长 + curve: Curve.Linear, // 动画曲线 + delay: 0, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal // 动画模式 + }) // 对Button组件的宽高属性进行动画配置 + + // 更新进度遮罩的进度值 + Button('updateProgress') + .onClick((event: ClickEvent) => { + this.value += 10; + this.progress.updateProgress(this.value); + }).width(200).height(50).margin(20) + + // 更新进度遮罩的颜色 + Button('updateColor') + .onClick((event: ClickEvent) => { + if (this.progressflag1) { + this.progress.updateColor(0x9fff0000); + } else { + this.progress.updateColor(0x9f0000ff); + } + this.progressflag1 = !this.progressflag1 + }).width(200).height(50).margin(20) + + // 恢复进度遮罩 + Button('click reset!') + .onClick((event: ClickEvent) => { + this.value = 0; + this.progress.updateProgress(this.value); + }).width(200).height(50).margin(20) + } + .width('100%') + .margin({ top: 15 }) + } +} +``` + +![progressMask](figures/progressMask.PNG) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md index c091d5e51f1954fe78e4750bf8401dc797163d5e..ae2a96ee9a199d25f891ccb2c566a7d85d8d4495 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md @@ -18,7 +18,7 @@ | padding | [Padding](ts-types.md#padding) \| [Length](ts-types.md#length) | 设置内边距属性。
参数为Length类型时,四个方向内边距同时生效。
默认值:0
padding设置百分比时,上下左右内边距均以父容器的width作为基础值。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | margin | [Margin](ts-types.md#margin) \| [Length](ts-types.md#length) | 设置外边距属性。
参数为Length类型时,四个方向外边距同时生效。
默认值:0
margin设置百分比时,上下左右外边距均以父容器的width作为基础值。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | constraintSize | {
minWidth?: [Length](ts-types.md#length),
maxWidth?: [Length](ts-types.md#length),
minHeight?: [Length](ts-types.md#length),
maxHeight?: [Length](ts-types.md#length)
} | 设置约束尺寸,组件布局时,进行尺寸范围限制。constraintSize的优先级高于Width和Height。若设置的minWidth大于maxWidth,则minWidth生效,minHeight与maxHeight同理。
默认值:
{
minWidth: 0,
maxWidth: Infinity,
minHeight: 0,
maxHeight: Infinity
}
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| layoutWeight | number \| string | 父容器尺寸确定时,设置了layoutWeight属性的子元素与兄弟元素占主轴尺寸按照权重进行分配,忽略元素本身尺寸设置,表示自适应占满剩余空间。
**说明:**
仅在Row/Column/Flex布局中生效。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| layoutWeight | number \| string | 父容器尺寸确定时,设置了layoutWeight属性的子元素与兄弟元素占主轴尺寸按照权重进行分配,忽略元素本身尺寸设置,表示自适应占满剩余空间。
默认值:0
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
仅在Row/Column/Flex布局中生效。
可选值为大于等于0的数字,或者可以转换为数字的字符串。 | ## 示例 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 aef10210d43b6564996a2bdbdad5801c00a879c0..5cb4dcb09c9d2b7ff7c23ede334363329d791044 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,6 @@ -# 文本样式设置 +# 文本通用属性 -针对包含文本元素的组件,设置文本样式。 +文本通用属性目前只针对包含文本元素的组件,设置文本样式。 > **说明:** > @@ -18,6 +18,8 @@ | fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | 设置字体样式。
默认值:FontStyle.Normal | | fontWeight | number \| [FontWeight](ts-appendix-enums.md#fontweight) \| string | 设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,默认为400,取值越大,字体越粗。string类型仅支持number类型取值的字符串形式,例如"400",以及"bold"、"bolder"、"lighter"、"regular"、"medium",分别对应FontWeight中相应的枚举值。
默认值:FontWeight.Normal | | fontFamily | string \| [Resource](ts-types.md#resource) | 设置字体列表。默认字体'HarmonyOS Sans',且当前只支持这种字体。| +| lineHeight | string \| number \| [Resource](ts-types.md#resource) | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。 | +| decoration | {
type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),
color?: [ResourceColor](ts-types.md#resourcecolor)
} | 设置文本装饰线样式及其颜色。
默认值:{
type: TextDecorationType.None,
color:Color.Black
} | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md index 648f16c3e6166c41a15204f6587ba5c4ad162001..946e084308de2e15002518ad952f94909022ccf8 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md @@ -9,13 +9,16 @@ ## 属性 -| 名称 | 参数类型 | 描述 | -| --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| rotate | {
x?: number,
y?: number,
z?: number,
angle: number \| string,
centerX?: number \| string,
centerY?: number \| string
} | (x, y, z)指定一个矢量,表示旋转轴,正角度为顺时针转动,负角度为逆时针转动,默认值为0,同时可以通过centerX和centerY设置旋转的中心点。
默认值:
{
x: 0,
y: 0,
z: 0,
angle: 0,
centerX: '50%',
centerY: '50%'
}
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| translate | {
x?: number \| string,
y?: number \| string,
z? : number \| string
} | 可以分别设置X轴、Y轴、Z轴的平移距离,距离的正负控制平移的方向。不支持百分比形式的输入。
默认值:
{
x: 0,
y: 0,
z: 0
}
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| 名称 | 参数类型 | 描述 | +| --------- | ---------------------------------------- | ---------------------------------------- | +| rotate | {
x?: number,
y?: number,
z?: number,
angle: number \| string,
centerX?: number \| string,
centerY?: number \| string
} | 可使组件在以组件左上角为坐标原点的坐标系中进行旋转(坐标系如下图所示)。其中,(x, y, z)指定一个矢量,作为旋转轴。
- angle:旋转角度。取值为正时相对于旋转轴方向顺时针转动,取值为负时相对于旋转轴方向逆时针转动。取值可为string类型,如'90deg'。
- centerX和centerY用于指定旋转的中心点。
旋转轴和旋转中心点都基于坐标系设定,组件发生位移时,坐标系不会随之移动。
默认值:
{
x: 0,
y: 0,
z: 0,
centerX: '50%',
centerY: '50%'
}
![coordinates](figures/coordinates.png)
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| translate | {
x?: number \| string,
y?: number \| string,
z? : number \| string
} | 可使组件在以组件左上角为坐标原点的坐标系中进行移动(坐标系如下图所示)。其中,x,y,z的值分别表示在对应轴移动的距离,值为正时表示向对应轴的正向移动,值为负时表示向对应轴的反向移动。移动距离支持数字和字符串(比如'10px',‘10%’)两种类型。
默认值:
{
x: 0,
y: 0,
z: 0
}
![coordinates](figures/coordinates.png)
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | scale | {
x?: number,
y?: number,
z?: number,
centerX?: number \| string,
centerY?: number \| string
} | 可以分别设置X轴、Y轴、Z轴的缩放比例,默认值为1,同时可以通过centerX和centerY设置缩放的中心点。
默认值:
{
x: 1,
y: 1,
z: 1,
centerX:'50%',
centerY:'50%'
}
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| transform | [Matrix4Transit](../apis/js-apis-matrix4.md) | 设置当前组件的变换矩阵。 | +| transform | [Matrix4Transit](../apis/js-apis-matrix4.md) | 设置当前组件的变换矩阵。 | +> **说明:** +> +> 当组件同时设置了rotate和scale属性时,centerX和centerY的取值会发生冲突,此时centerX和centerY的值以后设定属性的值为准。 ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md index 6a8eb04f8e394d7966c6d0180923a81f6f52ab87..39760592bf318d9c0f0166ab0fd4a75f9e7e251d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md @@ -10,7 +10,7 @@ | 名称 | 支持冒泡 | 功能描述 | | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ | -| onDragStart(event: (event?: [DragEvent](#dragevent说明), extraParams?: string) =>  [CustomBuilder](ts-types.md#custombuilder8) \| [DragItemInfo](#dragiteminfo说明)) | 否 | 第一次拖拽此事件绑定的组件时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见[extraParams](#extraparams说明)说明。
返回值:当前跟手效果所拖拽的对象,用于显示拖拽时的提示组件。
长按150ms可触发拖拽事件。优先级:长按手势配置时间小于等于150ms时,长按手势优先触发,否则拖拽事件优先触发。 | +| onDragStart(event: (event?: [DragEvent](#dragevent说明), extraParams?: string) =>  [CustomBuilder](ts-types.md#custombuilder8) \| [DragItemInfo](#dragiteminfo说明)) | 否 | 第一次拖拽此事件绑定的组件时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见[extraParams](#extraparams说明)说明。
返回值:当前跟手效果所拖拽的对象,用于显示拖拽时的提示组件。
长按500ms可触发拖拽事件。优先级:长按手势配置时间小于等于500ms时,长按手势优先触发,否则拖拽事件优先触发。 | | onDragEnter(event: (event?: [DragEvent](#dragevent说明), extraParams?: string) => void) | 否 | 拖拽进入组件范围内时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见[extraParams](#extraparams说明)说明。
当监听了onDrop事件时,此事件才有效。 | | onDragMove(event: (event?: [DragEvent](#dragevent说明), extraParams?: string) => void) | 否 | 拖拽在组件范围内移动时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见[extraParams](#extraparams说明)说明。
当监听了onDrop事件时,此事件才有效。 | | onDragLeave(event: (event?: [DragEvent](#dragevent说明), extraParams?: string) => void) | 否 | 拖拽离开组件范围内时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见[extraParams](#extraparams说明)说明。
当监听了onDrop事件时,此事件才有效。 | @@ -67,7 +67,7 @@ struct DragExample { @State bananaVisible: Visibility = Visibility.Visible private dragList: string[] = ['apple', 'orange', 'banana'] @State fruitVisible: Visibility[] = [Visibility.Visible, Visibility.Visible, Visibility.Visible] - @State index: number = 0 + @State idx: number = 0 // 自定义拖拽过程中显示的内容 @Builder pixelMapBuilder() { @@ -104,7 +104,7 @@ struct DragExample { .onTouch((event: TouchEvent) => { if (event.type === TouchType.Down) { this.eventType = 'Down' - this.index = index + this.idx = index } if (event.type === TouchType.Up) { this.eventType = 'Up' @@ -157,7 +157,7 @@ struct DragExample { this.numbers.splice(jsonString.insertIndex, 0, this.text) this.bool = false } - this.fruitVisible[this.index] = Visibility.None + this.fruitVisible[this.idx] = Visibility.None }) }.width('100%').height('100%').padding({ top: 20 }).margin({ top: 20 }) } diff --git a/zh-cn/application-dev/reference/errorcodes/Readme-CN.md b/zh-cn/application-dev/reference/errorcodes/Readme-CN.md index 6f6b2cb855d65b2d2820613ae9273c74f763ce28..6267fa52fc5786b5b355242dcced764b3112ea15 100644 --- a/zh-cn/application-dev/reference/errorcodes/Readme-CN.md +++ b/zh-cn/application-dev/reference/errorcodes/Readme-CN.md @@ -43,7 +43,7 @@ - [数据共享错误码](errorcode-datashare.md) - [分布式数据对象错误码](errorcode-distributed-dataObject.md) - [分布式键值数据库错误码](errorcode-distributedKVStore.md) - - [首选项错误码](errorcode-preferences.md) + - [用户首选项错误码](errorcode-preferences.md) - 文件管理 - [文件管理子系统错误码](errorcode-filemanagement.md) - 电话服务 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-CommonEventService.md b/zh-cn/application-dev/reference/errorcodes/errorcode-CommonEventService.md index 449647cc0ccb75ccf12adac41b9ef7eabba7caac..a48197d1f81a2fec9e12708949dc3f32f88e4084 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-CommonEventService.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-CommonEventService.md @@ -1,127 +1,131 @@ -# 事件错误码 +# 事件错误码 + +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 ## 1500001 want中Action为空 **错误信息** -> The action field in the want parameter is null. +The action field in the want parameter is null. **错误描述** -> 发送事件的`want`中的`Action`属性为空时系统会产生此错误码。 +发送事件的`want`中的`Action`属性为空时系统会产生此错误码。 **可能原因** -> 发送事件的`want`中的`Action`属性为空。 +发送事件的`want`中的`Action`属性为空。 **处理步骤** -> 检查传入`want`的`Action`属性是否为空。 +检查传入`want`的`Action`属性是否为空。 ## 1500002 沙箱应用无法发送公共事件 **错误信息** -> A sandbox application cannot send common events. +A sandbox application cannot send common events. **错误描述** -> 沙箱应用无法发送公共事件。 +沙箱应用无法发送公共事件。 **可能原因** -> 事件发送方应用为沙箱应用,发送事件会被拦截。 +事件发送方应用为沙箱应用,发送事件会被拦截。 **处理步骤** -> 沙箱应用无法发送公共事件,发送公共事件前确认是否为沙箱应用。 +沙箱应用无法发送公共事件,发送公共事件前确认是否为沙箱应用。 ## 1500003 事件发送频率过高 **错误信息** -> Too many common events are send in a short period of time. +Too many common events are send in a short period of time. **错误描述** -> 应用发送事件过于频繁。 +应用发送事件过于频繁。 **可能原因** -> 短时间内应用发送过多事件。 +短时间内应用发送过多事件。 **处理步骤** -> 检查应用是否过于频繁地发送事件。 +检查应用是否过于频繁地发送事件。 ## 1500004 无法发送系统公共事件 **错误信息** -> A third-party application cannot send system common events. +A third-party application cannot send system common events. **错误描述** -> 当前应用无法发送系统公共事件。 +当前应用无法发送系统公共事件。 **可能原因** -> 非系统应用或非系统服务发送系统公共事件。 +非系统应用或非系统服务发送系统公共事件。 **处理步骤** -> 确认当前应用是否为系统应用,或当前服务是否为系统服务。 +确认当前应用是否为系统应用,或当前服务是否为系统服务。 ## 1500005 未找到订阅者 **错误信息** -> The subscriber is not found. +The subscriber is not found. **错误描述** -> 找不到订阅者。 +找不到订阅者。 **可能原因** -> 订阅者被删除。 +订阅者被删除。 **处理步骤** -> 检查是否有重复取消订阅。 +检查是否有重复取消订阅。 ## 1500006 无效userId **错误信息** -> Invalid userId. +Invalid userId. **错误描述** -> 无效的userId。 +无效的userId。 **可能原因** -> 和系统`userId`不一致或不是系统应用或系统服务进程。 +和系统`userId`不一致或不是系统应用或系统服务进程。 **处理步骤** -> 1. 检查当前`userId`是否和系统`userId`一致。 -> 2. 检查当前应用是否为系统应用或系统服务。 +1. 检查当前`userId`是否和系统`userId`一致。 +2. 检查当前应用是否为系统应用或系统服务。 ## 1500007 IPC请求发送失败 **错误信息** -> Failed to send the message. +Failed to send the message. **错误描述** -> `IPC`发送请求失败。 +`IPC`发送请求失败。 **可能原因** -> 没有成功创建连接对象。 +没有成功创建连接对象。 **处理步骤** -> 请勿频繁建立链接,稍后重新尝试。 +请勿频繁建立链接,稍后重新尝试。 ## 1500008 读取数据失败 **错误信息** -> Failed to read the data. +Failed to read the data. **错误描述** -> 服务端发生错误。 +服务端发生错误。 **可能原因** -> 服务端处理数据时发现业务异常。 +服务端处理数据时发现业务异常。 **处理步骤** -> 稍后重新尝试。 +稍后重新尝试。 ## 1500009 系统错误 **错误信息** -> System error. +System error. **错误描述** -> 处理业务时系统发生异常,如获取系统当前时间失败。 +处理业务时系统发生异常,如获取系统当前时间失败。 **可能原因** -> 系统故障,获取系统当前时间发生异常。 +系统故障,获取系统当前时间发生异常。 **处理步骤** -> 稍后重新尝试。 +稍后重新尝试。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-DeviceUsageStatistics.md b/zh-cn/application-dev/reference/errorcodes/errorcode-DeviceUsageStatistics.md index dda2607a4d9de5f979f26ca206313fad3dd84804..dc395884e59bc146ebcfb845bae4452685101fe9 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-DeviceUsageStatistics.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-DeviceUsageStatistics.md @@ -1,5 +1,9 @@ # DeviceUsageStatistics错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 10000001 内存操作失败 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-DistributedNotificationService.md b/zh-cn/application-dev/reference/errorcodes/errorcode-DistributedNotificationService.md index 2049cb646f6a757784bf52f93507e1c078a30e18..b40c48cfed25840c6359f2f17295803668192bf0 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-DistributedNotificationService.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-DistributedNotificationService.md @@ -1,5 +1,9 @@ # DistributedNotificationService错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 1600001 内部错误 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-DistributedSchedule.md b/zh-cn/application-dev/reference/errorcodes/errorcode-DistributedSchedule.md index 49ef0e73a0ec747d6160e18c7885029dbb5f975a..19eeda1a67ea22159d9a48f92f6f91fba608edea 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-DistributedSchedule.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-DistributedSchedule.md @@ -1,5 +1,9 @@ # DistributedSchedule错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 16600001 系统服务工作异常 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-ability.md b/zh-cn/application-dev/reference/errorcodes/errorcode-ability.md index b83f43dd935c55bd5a034a8384b80ab20125bb69..202bd9d425c7f583b5db8c075e6b3df57fc196f0 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-ability.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-ability.md @@ -1,5 +1,9 @@ # 元能力子系统错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 16000001 指定的Ability名称不存在 **错误信息** @@ -182,6 +186,24 @@ The context does not exist. 请检查上下文对象是否可用。 +## 16000012 上一个Ability未启动完成,先缓存在队列中等待后续启动。 + +**错误信息** + +The previous ability is starting, wait start later. + +**错误描述** + +需要启动的Ability过多,由于系统处理能力有限,会先将请求缓存在队列中,按照顺序依次处理。 + +**可能原因** + +系统并发大。 + +**处理步骤** + +无需处理,等待启动即可。 + ## 16000050 内部错误 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-access-token.md b/zh-cn/application-dev/reference/errorcodes/errorcode-access-token.md index 16a8cf53764e369e6b3f916063da3c10c5bb4b9c..ea6afd6598b93f5710d75f1fc3859003c051013b 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-access-token.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-access-token.md @@ -1,5 +1,9 @@ # AccessToken错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 12100001 入参错误 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-accessibility.md b/zh-cn/application-dev/reference/errorcodes/errorcode-accessibility.md index e8674f395457d04a6f8f53f5933be94a9082ae5d..c8a8a16424c79da82f63c94a4afbd08e9a45ea9f 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-accessibility.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-accessibility.md @@ -1,5 +1,9 @@ # 无障碍子系统错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 9300001 输入无效的包名称或者Ability名称 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-account.md b/zh-cn/application-dev/reference/errorcodes/errorcode-account.md index 1e74da9b940222ef4764e0074da94c5401ed2415..5ecb53db80372d488d7be6f5a3d388eec685d185 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-account.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-account.md @@ -1,5 +1,9 @@ # 帐号管理错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + 以下错误码包括系统帐号、分布式帐号和应用帐号错误码。 ## 12300001 系统服务异常 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-animator.md b/zh-cn/application-dev/reference/errorcodes/errorcode-animator.md index b07c42ebb8fee6b564c521d6f431a6f337ce2f9e..f1ae2a1ab9ff8b622ace8950221b03cafe478717 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-animator.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-animator.md @@ -1,5 +1,9 @@ # 动画错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 100001 内部错误 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-audio.md b/zh-cn/application-dev/reference/errorcodes/errorcode-audio.md index 0746dc22f236b5c62a392bbde82dc0db4c318203..254e084d00928573c4c8665e15e0a540b5f37354 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-audio.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-audio.md @@ -1,4 +1,8 @@ -# Audio错误码 +# Audio错误码 + +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 ## 6800101 无效入参 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-avsession.md b/zh-cn/application-dev/reference/errorcodes/errorcode-avsession.md index 59b93001ecb83570a69f405b8aacfe1444a8bbed..1e14de458aadb4ae7176ad8ec50d3b45b91db12b 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-avsession.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-avsession.md @@ -1,5 +1,9 @@ # 媒体会话管理错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 6600101 会话服务端异常 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md b/zh-cn/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md index c876f929ed256d9db9bb5a69d09671d7e335c9ed..687227b21bd5066b9072928924c3de70f26f2c09 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md @@ -1,5 +1,9 @@ # backgroundTaskManager错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 9800001 内存操作失败 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-batteryStatistics.md b/zh-cn/application-dev/reference/errorcodes/errorcode-batteryStatistics.md index 5787950b7a841ffdefa230e42493180dcc68f29f..77019c1ae94a351935e220060069418e2a4e28ef 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-batteryStatistics.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-batteryStatistics.md @@ -1,5 +1,9 @@ # 耗电统计错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 4600101 连接服务失败 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-bluetoothManager.md b/zh-cn/application-dev/reference/errorcodes/errorcode-bluetoothManager.md index cbeb39e34a20ae984a62c6f55373c63eb26371d4..d01e71420fc16ea4480775897f68ac69a8da9d9c 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-bluetoothManager.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-bluetoothManager.md @@ -1,5 +1,9 @@ # 蓝牙服务子系统错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 2900001 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-brightness.md b/zh-cn/application-dev/reference/errorcodes/errorcode-brightness.md index b5d83d90fde5bdf977f6afb76f41d1bed9bab4ed..033036cef4695b2076f9336e854bc021528f0a43 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-brightness.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-brightness.md @@ -1,5 +1,9 @@ # 屏幕亮度错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 4700101 连接服务失败 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-bundle.md b/zh-cn/application-dev/reference/errorcodes/errorcode-bundle.md index 58f43d71aa878ac09703d76678c6e7b54a1611b0..c68152ab39b592fb7c7c4b7abfcf71da535605e7 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-bundle.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-bundle.md @@ -1,453 +1,547 @@ -# 包管理子系统通用错误码 - -## 17700001 指定的bundleName不存在 - -**错误信息**
-The specified bundle name is not found. - -**错误描述**
-调用查询等接口时,传入的bundleName不存在。 - -**可能原因**
- -1. 输入的bundleName有误。 -2. 系统中对应的应用没有安装。 - -**处理步骤**
-1. 检查bundleName拼写是否正确。 -2. 确认对应的应用是否安装。 - -## 17700002 指定的moduleName不存在 - -**错误信息**
-The specified module name is not found. - -**错误描述**
-调用查询或者免安装相关接口时,传入的moduleName不存在。 - -**可能原因**
-1. 输入的moduleName有误。 -2. 系统中对应的应用没有安装该模块。 - -**处理步骤**
-1. 检查moduleName拼写是否正确。 -2. 确认对应的应用是否安装该模块。 - -## 17700003 指定的abilityName不存在 - -**错误信息**
-The specified ability name is not found. - -**错误描述**
-调用查询等接口时,传入的abilityName不存在。 - -**可能原因**
-1. 输入的abilityName有误。 -2. 系统中对应的应用不存在该abilityName对应的ability。 - -**处理步骤**
-1. 检查abilityName拼写是否正确。 -2. 确认对应的应用是否存在该abilityName对应的ability。 - -## 17700004 指定的用户不存在 - -**错误信息**
-The specified user ID is not found. - -**错误描述**
-调用与用户相关接口时,传入的用户不存在。 - -**可能原因**
-1. 输入的用户名有误。 -2. 系统中没有该用户。 - -**处理步骤**
-1. 检查用户名拼写是否正确。 -2. 确认系统中存在该用户。 - -## 17700005 指定的appId为空字符串 - -**错误信息**
-The specified app ID is empty string. - -**错误描述**
-调用appControl模块中的相关接口时,传入的appId为空字符串。 - -**可能原因**
-传入的appId为空字符串。 - -**处理步骤**
-检查appId是否为空字符串。 - -## 17700006 查询的权限不存在 - -**错误信息**
-The specified permission is not found. - -**错误描述**
-调用bundleManager模块中的getPermissionDef接口时,传入的权限不存在。 - -**可能原因**
-1. 传入的permission名称拼写有误。 -2. 系统中不存在对应的权限。 - -**处理步骤**
-1. 检查permission拼写是否正确。 -2. 确认系统中是否有该权限。 - -## 17700007 输入的设备Id有误 - -**错误信息**
-The specified device ID is not found. - -**错误描述**
-调用distributedBundle模块相关接口时,传入的设备id有误。 - -**可能原因**
-1. 传入的deviceId拼写有误。 -2. deviceId不存在。 - -**处理步骤**
-1. 检查deviceId拼写是否正确。 -2. 确认deviceId是否存在。 - -## 17700010 文件解析失败导致应用安装失败 - -**错误信息**
-Failed to install the HAP because the HAP fails to be parsed. - -**错误描述**
-调用installer模块中的install接口时,传入的HAP解析失败。 - -**可能原因**
-1. HAP的格式不是zip格式。 -2. HAP的配置文件不满足json格式。 -3. HAP的配置文件缺少必要的字段。 - -**处理步骤**
-1. 确认hap的格式是zip。 -2. 确认hap的配置文件满足[配置文件json格式](../../quick-start/application-configuration-file-overview-stage.md)。 -3. 检查DevEco Studio编译hap时是否有错误提示,缺省字段时会有相应的报错。 - -## 17700011 签名校验失败导致应用安装失败 - -**错误信息**
-Failed to install the HAP because the HAP signature fails to be verified. - -**错误描述**
-调用installer模块中的install接口时,签名校验失败导致应用安装失败。 - -**可能原因**
- -1. HAP没有签名。 -2. hap签名信息来源不可靠。 -3. 升级的HAP与已安装的HAP签名信息不一致。 -4. 多个hap的签名信息不一致。 - -**处理步骤**
-1. 确认hap包是否签名成功。 -2. 确认hap包的签名证书是从应用市场申请。 -3. 确认多个hap包签名时使用的证书相同。 -4. 确认升级的ha包p签名证书与已安装的hap包相同。 - -## 17700012 安装包路径无效或者文件过大导致应用安装失败 - -**错误信息**
-Failed to install the HAP because the HAP path is invalid or the HAP is too large. - -**错误描述**
-调用installer模块中的install接口时,安装包路径无效或者文件过大导致应用安装失败。 - -**可能原因**
-1. 输入错误,HAP的文件路径不存在。 -2. HAP的路径无法访问。 -3. HAP的大小超过最大限制4G。 - -**处理步骤**
-1. 确认hap是否存在。 -2. 查看hap的可执行权限,是否可读。 -3. 查看HAP的大小是否超过4G。 - -## 17700015 多个HAP配置信息不同导致应用安装失败 - -**错误信息**
-Failed to install the HAPs because they have different configuration information. - -**错误描述**
-调用installer模块中的install接口时,多个HAP配置信息不同导致应用安装失败。 - -**可能原因**
-多个hap包中配置文件中app标签下面的字段信息不一致。 - -**处理步骤**
-确认多个HAP中配置文件app下面的字段是否一致。 - -## 17700016 系统磁盘空间不足导致应用安装失败 - -**错误信息**
-Failed to install the HAP because of insufficient system disk space. - -**错误描述**
-调用installer模块中的install接口时,系统磁盘空间不足导致应用安装失败。 - -**可能原因**
-系统空间不足。 - -**处理步骤**
-确认系统是否有足够的空间。 - -## 17700017 新安装的应用版本号低于已安装的版本号导致应用安装失败 - -**错误信息**
-Failed to install the HAP since the version of the HAP to install is too early. - -**错误描述**
-调用installer模块中的install接口时,新安装的应用版本号低于已安装的版本号导致应用安装失败。 - -**可能原因**
-新安装的应用版本号低于已安装的版本号。 - -**处理步骤**
-确认新安装的应用版本号是否不低于已安装的同应用版本号。 - -## 17700020 预置应用无法卸载 - -**错误信息**
-The preinstalled app cannot be uninstalled. - -**错误描述**
-调用installer模块中的uninstall接口卸载预置应用时,无法卸载。 - -**可能原因**
-1. 传入的bundleName拼写有误。 -2. 对应的预置应用无法卸载。 - -**处理步骤**
-1. 确认bundleName是否拼写正确。 -1. 确认对应的预置应用是否可卸载。 - -## 17700021 指定的uid无效 - -**错误信息**
-The specified uid is invalid. - -**错误描述**
-调用bundleManager模块中的getBundleNameByUid接口时,指定的uid无效。 - -**可能原因**
-1. 传入的uid拼写有误。 -2. 传入的uid在系统中不存在。 - -**处理步骤**
-1. 检查uid的拼写。 -2. 检查系统中是否存在该uid。 - -## 17700022 输入的待解析源文件无效 - -**错误信息**
-The input source file is invalid. - -**错误描述**
-调用bundleManager模块中的getBundleArchiveInfo接口时,传入的HAP路径无效。 - -**可能原因**
-1. 待解析的源文件不存在。 -2. 待解析的源文件不符合zip格式。 - -**处理步骤**
-1. 确认待解析的源文件是否存在。 -2. 确认待解析的源文件符合zip格式。 - -## 17700023 指定的默认应用不存在 - -**错误信息**
-The specified default app does not exist. - -**错误描述**
-调用defaultAppManager模块中的getDefaultApplication接口时,指定的默认应用不存在。 - -**可能原因**
-设备没有设置对应的默认应用。 - -**处理步骤**
-确认设备是否设置了对应的默认应用。 - -## 17700024 没有相应的配置文件 - -**错误信息**
-Failed to get the profile because there is no profile in the HAP. - -**错误描述**
-调用查询profile文件的相关接口时,没有相应的配置文件。 - -**可能原因**
-1. 输入的metadata name在配置文件中不存在。 -2. 配置文件的内容不是json格式。 - -**处理步骤**
-1. 确认要查询的ability或者extensionAbility中的metadata name是否存在。 -2. 确认指定查询的profile文件的内容是否为json格式。 - -## 17700025 输入的type无效 - -**错误信息**
-The specified type is invalid. - -**错误描述**
-调用defaultAppManager模块的相关接口时,输入的type无效。 - -**可能原因**
-1. 输入的type拼写有误。 -2. 输入的type不存在。 - -**处理步骤**
-1. 确认输入的type是否拼写正确。 -2. 确认输入的type是否存在。 - -## 17700026 指定应用被禁用 - -**错误信息**
-The specified bundle is disabled. - -**错误描述**
-当调用查询应用的相关信息接口时,指定应用被禁用。 - -**可能原因**
-设备上对应的应用已经被禁用,无法查询。 - -**处理步骤**
-确认设备上对应的应用是否被禁用。 - -## 17700027 分布式服务未启动 - -**错误信息**
-The distributed service is not running. - -**错误描述**
-当调用distributedBundle模块的相关接口时,分布式服务未启动。 - -**可能原因**
-设备未组网。 - -**处理步骤**
-确认设备是否组网成功。 -## 17700028 输入的ability与type不匹配 - -**错误信息**
-The ability does not match the type. - -**错误描述**
-当调用defaultAppManager模块中的setDefaultApplication接口时,输入的ability与type不匹配。 - -**可能原因**
-输入的ability和type拼写有误。 - -**处理步骤**
-确认输入的ability和type拼写是否正确。 - -## 17700029 指定的ability被禁用 - -**错误信息**
-The specified ability is disabled. - -**错误描述**
-当调用查询ability相关信息的接口时,指定的ability被禁用。 - -**可能原因**
-指定的ability被禁用。 - -**处理步骤**
-确认指定的ability是否被禁用,可以使用[bm工具命令](../../../readme/%E5%8C%85%E7%AE%A1%E7%90%86%E5%AD%90%E7%B3%BB%E7%BB%9F.md%23bm%E5%B7%A5%E5%85%B7%E5%91%BD%E4%BB%A4)查询对应的应用信息。 - -## 17700030 指定的应用不支持清除缓存文件 - -**错误信息**
-The specified bundle does not support clearing of cache files. - -**错误描述**
-当调用bundleManager模块中的cleanBundleCacheFiles接口时,指定的应用不支持清除缓存文件。 - -**可能原因**
-指定的应用为系统应用且在签名证书中配置了不能清除数据(AllowAppDataNotCleared)的字段。 - -**处理步骤**
-1.确认指定的应用是否为系统应用,可以使用[bm工具命令](../../../readme/%E5%8C%85%E7%AE%A1%E7%90%86%E5%AD%90%E7%B3%BB%E7%BB%9F.md%23bm%E5%B7%A5%E5%85%B7%E5%91%BD%E4%BB%A4)查询对应的应用信息,查看isSystemApp是否为true。 -2.确认指定的应用是否配置了能清除缓存(AllowAppDataNotCleared)的字段,可以使用[bm工具命令](../../../readme/%E5%8C%85%E7%AE%A1%E7%90%86%E5%AD%90%E7%B3%BB%E7%BB%9F.md%23bm%E5%B7%A5%E5%85%B7%E5%91%BD%E4%BB%A4)查询对应的应用信息,查看userDataClearable是否为true。 - -## 17700031 Overlay特性校验失败导致HAP安装失败 - -**错误信息**
-Failed to install the HAP because the overlay check of the HAP is failed. - -**错误描述**
-当安装overlay特征的应用时,指定的应用和待安装的overlay特征应用不为预置应用,或者目标应用/目标module是overlay特征的应用/module。 - -**可能原因**
-1. 使用应用间的overlay特性时,overlay特征应用必须为预置应用。 -2. 使用应用间的overlay特性时,目标应用必须为预置应用。 -3. 使用应用间的overlay特性时,目标应用不能是具有overlay特征的应用 -4. 目标module不能是具有overlay特征的module。 - -**处理步骤**
-1. 检查overlay特征应用是否为预置应用。 -2. 检查目标应用是否为预置应用。 -3. 检查目标应用是否不为overlay特征的应用 -4. 检查目标module是否不为overlay特征的module。 - -## 17700032 指定的应用不包含overlay特征的module - -**错误信息**
-The specified bundle does not contain any overlay module. - -**错误描述**
-查询指定应用中overlay特征module的overlayModuleInfo时, 指定的应用不包含overlay特征module。 - -**可能原因**
-指定的应用不包含overlay特征module。 - -**处理步骤**
-检查指定的应用是否不包含overlay特征module。 - -## 17700033 指定的module不是overlay特征的module - -**错误信息**
-The specified module is not overlay module. - -**错误描述**
-查询指定的overlay特征module的overlayModuleInfo时, 指定的module不是overlay特征module。 - -**可能原因**
-指定的module不是overlay特征的module。 - -**处理步骤**
-检查指定的module是否不为overlay特征的module。 - -## 17700034 指定的module是overlay特征的module - -**错误信息**
-The specified module is overlay module. - -**错误描述**
-查询指定的目标module所关联的overlayModuleInfo时, 指定的module是overlay特征module。 - -**可能原因**
-指定的module是overlay特征的module。 - -**处理步骤**
-检查指定的module是否为overlay特征的module。 - -## 17700035 指定的应用只包含overlay特征的module - -**错误信息**
-The specified bundle is overlay bundle. - -**错误描述**
-查询指定应用的目标module所关联的overlayModuleInfo时, 指定的应用只包含overlay特征的module。 - -**可能原因**
-指定的应用只包含overlay特征的module。 - -**处理步骤**
-检查指定的应用是否只包含overlay特征的module。 - +# 包管理子系统通用错误码 + +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + +## 17700001 指定的bundleName不存在 + +**错误信息**
+The specified bundle name is not found. + +**错误描述**
+调用查询等接口时,传入的bundleName不存在。 + +**可能原因**
+ +1. 输入的bundleName有误。 +2. 系统中对应的应用没有安装。 + +**处理步骤**
+1. 检查bundleName拼写是否正确。 +2. 确认对应的应用是否安装。 + +## 17700002 指定的moduleName不存在 + +**错误信息**
+The specified module name is not found. + +**错误描述**
+调用查询或者免安装相关接口时,传入的moduleName不存在。 + +**可能原因**
+1. 输入的moduleName有误。 +2. 系统中对应的应用没有安装该模块。 + +**处理步骤**
+1. 检查moduleName拼写是否正确。 +2. 确认对应的应用是否安装该模块。 + +## 17700003 指定的abilityName不存在 + +**错误信息**
+The specified ability name is not found. + +**错误描述**
+调用查询等接口时,传入的abilityName不存在。 + +**可能原因**
+1. 输入的abilityName有误。 +2. 系统中对应的应用不存在该abilityName对应的ability。 + +**处理步骤**
+1. 检查abilityName拼写是否正确。 +2. 确认对应的应用是否存在该abilityName对应的ability。 + +## 17700004 指定的用户不存在 + +**错误信息**
+The specified user ID is not found. + +**错误描述**
+调用与用户相关接口时,传入的用户不存在。 + +**可能原因**
+1. 输入的用户名有误。 +2. 系统中没有该用户。 + +**处理步骤**
+1. 检查用户名拼写是否正确。 +2. 确认系统中存在该用户。 + +## 17700005 指定的appId为空字符串 + +**错误信息**
+The specified app ID is empty string. + +**错误描述**
+调用appControl模块中的相关接口时,传入的appId为空字符串。 + +**可能原因**
+传入的appId为空字符串。 + +**处理步骤**
+检查appId是否为空字符串。 + +## 17700006 查询的权限不存在 + +**错误信息**
+The specified permission is not found. + +**错误描述**
+调用bundleManager模块中的getPermissionDef接口时,传入的权限不存在。 + +**可能原因**
+1. 传入的permission名称拼写有误。 +2. 系统中不存在对应的权限。 + +**处理步骤**
+1. 检查permission拼写是否正确。 +2. 确认系统中是否有该权限。 + +## 17700007 输入的设备Id有误 + +**错误信息**
+The specified device ID is not found. + +**错误描述**
+调用distributedBundle模块相关接口时,传入的设备id有误。 + +**可能原因**
+1. 传入的deviceId拼写有误。 +2. deviceId不存在。 + +**处理步骤**
+1. 检查deviceId拼写是否正确。 +2. 确认deviceId是否存在。 + +## 17700010 文件解析失败导致应用安装失败 + +**错误信息**
+Failed to install the HAP because the HAP fails to be parsed. + +**错误描述**
+调用installer模块中的install接口时,传入的HAP解析失败。 + +**可能原因**
+1. HAP的格式不是zip格式。 +2. HAP的配置文件不满足json格式。 +3. HAP的配置文件缺少必要的字段。 + +**处理步骤**
+1. 确认hap的格式是zip。 +2. 确认hap的配置文件满足[配置文件json格式](../../quick-start/application-configuration-file-overview-stage.md)。 +3. 检查DevEco Studio编译hap时是否有错误提示,缺省字段时会有相应的报错。 + +## 17700011 签名校验失败导致应用安装失败 + +**错误信息**
+Failed to install the HAP because the HAP signature fails to be verified. + +**错误描述**
+调用installer模块中的install接口时,签名校验失败导致应用安装失败。 + +**可能原因**
+ +1. HAP没有签名。 +2. hap签名信息来源不可靠。 +3. 升级的HAP与已安装的HAP签名信息不一致。 +4. 多个hap的签名信息不一致。 + +**处理步骤**
+1. 确认hap包是否签名成功。 +2. 确认hap包的签名证书是从应用市场申请。 +3. 确认多个hap包签名时使用的证书相同。 +4. 确认升级的ha包p签名证书与已安装的hap包相同。 + +## 17700012 安装包路径无效或者文件过大导致应用安装失败 + +**错误信息**
+Failed to install the HAP because the HAP path is invalid or the HAP is too large. + +**错误描述**
+调用installer模块中的install接口时,安装包路径无效或者文件过大导致应用安装失败。 + +**可能原因**
+1. 输入错误,HAP的文件路径不存在。 +2. HAP的路径无法访问。 +3. HAP的大小超过最大限制4G。 + +**处理步骤**
+1. 确认hap是否存在。 +2. 查看hap的可执行权限,是否可读。 +3. 查看HAP的大小是否超过4G。 + +## 17700015 多个HAP配置信息不同导致应用安装失败 + +**错误信息**
+Failed to install the HAPs because they have different configuration information. + +**错误描述**
+调用installer模块中的install接口时,多个HAP配置信息不同导致应用安装失败。 + +**可能原因**
+多个hap包中配置文件中app标签下面的字段信息不一致。 + +**处理步骤**
+确认多个HAP中配置文件app下面的字段是否一致。 + +## 17700016 系统磁盘空间不足导致应用安装失败 + +**错误信息**
+Failed to install the HAP because of insufficient system disk space. + +**错误描述**
+调用installer模块中的install接口时,系统磁盘空间不足导致应用安装失败。 + +**可能原因**
+系统空间不足。 + +**处理步骤**
+确认系统是否有足够的空间。 + +## 17700017 新安装的应用版本号低于已安装的版本号导致应用安装失败 + +**错误信息**
+Failed to install the HAP since the version of the HAP to install is too early. + +**错误描述**
+调用installer模块中的install接口时,新安装的应用版本号低于已安装的版本号导致应用安装失败。 + +**可能原因**
+新安装的应用版本号低于已安装的版本号。 + +**处理步骤**
+确认新安装的应用版本号是否不低于已安装的同应用版本号。 + +## 17700018 安装失败,依赖的模块不存在 + +**错误信息**
+Failed to install because the dependent module does not exist. + +**错误描述**
+安装hap或者hsp时,依赖的模块不存在。 + +**可能原因**
+依赖的模块没有安装。 + +**处理步骤**
+先安装依赖的模块。 + +## 17700020 预置应用无法卸载 + +**错误信息**
+The preinstalled app cannot be uninstalled. + +**错误描述**
+调用installer模块中的uninstall接口卸载预置应用时,无法卸载。 + +**可能原因**
+1. 传入的bundleName拼写有误。 +2. 对应的预置应用无法卸载。 + +**处理步骤**
+1. 确认bundleName是否拼写正确。 +1. 确认对应的预置应用是否可卸载。 + +## 17700021 指定的uid无效 + +**错误信息**
+The specified uid is invalid. + +**错误描述**
+调用bundleManager模块中的getBundleNameByUid接口时,指定的uid无效。 + +**可能原因**
+1. 传入的uid拼写有误。 +2. 传入的uid在系统中不存在。 + +**处理步骤**
+1. 检查uid的拼写。 +2. 检查系统中是否存在该uid。 + +## 17700022 输入的待解析源文件无效 + +**错误信息**
+The input source file is invalid. + +**错误描述**
+调用bundleManager模块中的getBundleArchiveInfo接口时,传入的HAP路径无效。 + +**可能原因**
+1. 待解析的源文件不存在。 +2. 待解析的源文件不符合zip格式。 + +**处理步骤**
+1. 确认待解析的源文件是否存在。 +2. 确认待解析的源文件符合zip格式。 + +## 17700023 指定的默认应用不存在 + +**错误信息**
+The specified default app does not exist. + +**错误描述**
+调用defaultAppManager模块中的getDefaultApplication接口时,指定的默认应用不存在。 + +**可能原因**
+设备没有设置对应的默认应用。 + +**处理步骤**
+确认设备是否设置了对应的默认应用。 + +## 17700024 没有相应的配置文件 + +**错误信息**
+Failed to get the profile because there is no profile in the HAP. + +**错误描述**
+调用查询profile文件的相关接口时,没有相应的配置文件。 + +**可能原因**
+1. 输入的metadata name在配置文件中不存在。 +2. 配置文件的内容不是json格式。 + +**处理步骤**
+1. 确认要查询的ability或者extensionAbility中的metadata name是否存在。 +2. 确认指定查询的profile文件的内容是否为json格式。 + +## 17700025 输入的type无效 + +**错误信息**
+The specified type is invalid. + +**错误描述**
+调用defaultAppManager模块的相关接口时,输入的type无效。 + +**可能原因**
+1. 输入的type拼写有误。 +2. 输入的type不存在。 + +**处理步骤**
+1. 确认输入的type是否拼写正确。 +2. 确认输入的type是否存在。 + +## 17700026 指定应用被禁用 + +**错误信息**
+The specified bundle is disabled. + +**错误描述**
+当调用查询应用的相关信息接口时,指定应用被禁用。 + +**可能原因**
+设备上对应的应用已经被禁用,无法查询。 + +**处理步骤**
+确认设备上对应的应用是否被禁用。 + +## 17700027 分布式服务未启动 + +**错误信息**
+The distributed service is not running. + +**错误描述**
+当调用distributedBundle模块的相关接口时,分布式服务未启动。 + +**可能原因**
+设备未组网。 + +**处理步骤**
+确认设备是否组网成功。 +## 17700028 输入的ability与type不匹配 + +**错误信息**
+The ability does not match the type. + +**错误描述**
+当调用defaultAppManager模块中的setDefaultApplication接口时,输入的ability与type不匹配。 + +**可能原因**
+输入的ability和type拼写有误。 + +**处理步骤**
+确认输入的ability和type拼写是否正确。 + +## 17700029 指定的ability被禁用 + +**错误信息**
+The specified ability is disabled. + +**错误描述**
+当调用查询ability相关信息的接口时,指定的ability被禁用。 + +**可能原因**
+指定的ability被禁用。 + +**处理步骤**
+确认指定的ability是否被禁用,可以使用[bm工具命令](../../../readme/%E5%8C%85%E7%AE%A1%E7%90%86%E5%AD%90%E7%B3%BB%E7%BB%9F.md%23bm%E5%B7%A5%E5%85%B7%E5%91%BD%E4%BB%A4)查询对应的应用信息。 + +## 17700030 指定的应用不支持清除缓存文件 + +**错误信息**
+The specified bundle does not support clearing of cache files. + +**错误描述**
+当调用bundleManager模块中的cleanBundleCacheFiles接口时,指定的应用不支持清除缓存文件。 + +**可能原因**
+指定的应用为系统应用且在签名证书中配置了不能清除数据(AllowAppDataNotCleared)的字段。 + +**处理步骤**
+1.确认指定的应用是否为系统应用,可以使用[bm工具命令](../../../readme/%E5%8C%85%E7%AE%A1%E7%90%86%E5%AD%90%E7%B3%BB%E7%BB%9F.md%23bm%E5%B7%A5%E5%85%B7%E5%91%BD%E4%BB%A4)查询对应的应用信息,查看isSystemApp是否为true。 +2.确认指定的应用是否配置了能清除缓存(AllowAppDataNotCleared)的字段,可以使用[bm工具命令](../../../readme/%E5%8C%85%E7%AE%A1%E7%90%86%E5%AD%90%E7%B3%BB%E7%BB%9F.md%23bm%E5%B7%A5%E5%85%B7%E5%91%BD%E4%BB%A4)查询对应的应用信息,查看userDataClearable是否为true。 + +## 17700031 Overlay特性校验失败导致HAP安装失败 + +**错误信息**
+Failed to install the HAP because the overlay check of the HAP is failed. + +**错误描述**
+当安装overlay特征的应用时,指定的应用和待安装的overlay特征应用不为预置应用,或者目标应用/目标module是overlay特征的应用/module。 + +**可能原因**
+1. 使用应用间的overlay特性时,overlay特征应用必须为预置应用。 +2. 使用应用间的overlay特性时,目标应用必须为预置应用。 +3. 使用应用间的overlay特性时,目标应用不能是具有overlay特征的应用 +4. 目标module不能是具有overlay特征的module。 + +**处理步骤**
+1. 检查overlay特征应用是否为预置应用。 +2. 检查目标应用是否为预置应用。 +3. 检查目标应用是否不为overlay特征的应用 +4. 检查目标module是否不为overlay特征的module。 + +## 17700032 指定的应用不包含overlay特征的module + +**错误信息**
+The specified bundle does not contain any overlay module. + +**错误描述**
+查询指定应用中overlay特征module的overlayModuleInfo时, 指定的应用不包含overlay特征module。 + +**可能原因**
+指定的应用不包含overlay特征module。 + +**处理步骤**
+检查指定的应用是否不包含overlay特征module。 + +## 17700033 指定的module不是overlay特征的module + +**错误信息**
+The specified module is not an overlay module. + +**错误描述**
+查询指定的overlay特征module的overlayModuleInfo时, 指定的module不是overlay特征module。 + +**可能原因**
+指定的module不是overlay特征的module。 + +**处理步骤**
+检查指定的module是否不为overlay特征的module。 + +## 17700034 指定的module是overlay特征的module + +**错误信息**
+The specified module is an overlay module. + +**错误描述**
+查询指定的目标module所关联的overlayModuleInfo时, 指定的module是overlay特征module。 + +**可能原因**
+指定的module是overlay特征的module。 + +**处理步骤**
+检查指定的module是否为overlay特征的module。 + +## 17700035 指定的应用只包含overlay特征的module + +**错误信息**
+The specified bundle is an overlay bundle. + +**错误描述**
+查询指定应用的目标module所关联的overlayModuleInfo时, 指定的应用只包含overlay特征的module。 + +**可能原因**
+指定的应用只包含overlay特征的module。 + +**处理步骤**
+检查指定的应用是否只包含overlay特征的module。 + +## 17700036 共享库缺少AllowAppShareLibrary特权导致安装失败 + +**错误信息**
+Failed to install the HSP because lacks appropriate permissions. + +**错误描述**
+共享库未申请配置AllowAppShareLibrary特权,可能存在安全隐私风险,不允许安装。 + +**可能原因**
+发布共享库前,未申请配置AllowAppShareLibrary特权。 + +**处理步骤**
+为共享库申请配置AllowAppShareLibrary特权,重新签名并发布。 + +## 17700037 被卸载的shared library版本被其他应用依赖 + +**错误信息**
+The version of shared bundle is dependent on other applications. + +**错误描述**
+当卸载shared library某一版本时,指定的shared library的版本被其他应用依赖,卸载失败。 + +**可能原因**
+1. 当前卸载的版本是shared library的最高版本,且该shared library被其他应用依赖。 +2. 当前卸载时未指定shared library的版本,会卸载shared library的所有版本,该shared library被其他应用依赖。 + +**处理步骤**
+1. 检查被卸载的shared library是否被其他应用依赖。 +2. 检查被卸载的版本是否为shared library的最高版本。 + +## 17700038 被卸载的shared library不存在 + +**错误信息**
+The specified shared bundle does not exist. + +**错误描述**
+当卸载shared library时,卸载的shared library不存在。 + +**可能原因**
+1. 当前指定卸载的版本不存在与被卸载的shared library中。 +2. 当前指定卸载的shared library不存在与设备中。 + +**处理步骤**
+1. 检查被卸载的shared library是否存在于当前设备中。 +2. 检查被卸载的版本是否存在于被卸载的shared library中。 + +## 17700039 不允许安装应用间共享库 +**错误信息**
+Failed to install because disallow install a shared bundle by hapFilePaths. + +**错误描述**
+安装应用时,传入的安装包为应用间共享库类型。 + +**可能原因**
+1. 通过bm工具安装应用时,-p参数传入了应用间共享库的安装包路径。 +2. 通过install接口安装应用时,hapFilePaths参数传入了应用间共享库的安装包路径。 + +**处理步骤**
+1. 通过-s参数指定应用间共享库的安装包路径。 +2. 通过installParam参数的sharedBundleDirPaths字段指定应用间共享库的安装包路径。 + +## 17700040 不允许卸载应用间共享库 +**错误信息**
+The specified bundle is a shared bundle which cannot be uninstalled. + +**错误描述**
+卸载应用时,传入的是应用间共享库的包名。 + +**可能原因**
+1. 通过bm工具卸载应用时,-n参数传入了应用间共享库的包名。 +2. 通过uninstall接口卸载应用时,bundleName传入的是应用间共享库的包名。 + +**处理步骤**
+1. 通过-s参数指定卸载的应用为共享库应用。 +2. 通过UninstallParam参数的bundleName及versionCode指定卸载的共享库的包名及版本。 + \ No newline at end of file diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-cert.md b/zh-cn/application-dev/reference/errorcodes/errorcode-cert.md index d74648af4d4ad600f10018a4f8aacb195b4d6d0d..cd94931d1547f1ca6ff27da8134d7e185cda70f8 100755 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-cert.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-cert.md @@ -1,4 +1,8 @@ -# cert错误码 +# cert错误码 + +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 ## 19020001 内存错误 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-colorspace-manager.md b/zh-cn/application-dev/reference/errorcodes/errorcode-colorspace-manager.md index 28fc683cfb07d50038eba50994836a8b2af14b0a..6ec08ccdb426b19a1d8ad01d1063c2897e43d050 100755 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-colorspace-manager.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-colorspace-manager.md @@ -1,5 +1,9 @@ # 色彩管理错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 18600001 参数值异常 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-crypto-framework.md b/zh-cn/application-dev/reference/errorcodes/errorcode-crypto-framework.md index 5795b9b30ebd9de96559da6c73075d4fdeb18a0c..e84ee9283a4f82325c794bf3ab95d02dcd34809e 100755 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-crypto-framework.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-crypto-framework.md @@ -1,4 +1,8 @@ -# crypto framework错误码 +# crypto framework错误码 + +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 ## 17620001 内存错误 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-data-rdb.md b/zh-cn/application-dev/reference/errorcodes/errorcode-data-rdb.md index 14f6bfc1665c1b6e990f5d5ac610f6a137988032..1b6a13893ed3c8dd093745f60e27ec866bd4e0d0 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-data-rdb.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-data-rdb.md @@ -1,5 +1,9 @@ # 关系型数据库错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 14800010 数据库名称不合法 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-datashare.md b/zh-cn/application-dev/reference/errorcodes/errorcode-datashare.md index b4deb99c4328c4e234b1e7a18d014e77da402a6c..4f7446c3eaed0fd052f5f5490c5845c8f1699379 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-datashare.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-datashare.md @@ -1,5 +1,9 @@ # 数据共享错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 15700010 创建DataShareHelper异常 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-device-manager.md b/zh-cn/application-dev/reference/errorcodes/errorcode-device-manager.md index 1884284f55f3636e0b366820dffa7d48a225da72..ae2b8ee9215e52d1d6b2f8033c52a696fe6d0dd2 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-device-manager.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-device-manager.md @@ -1,5 +1,9 @@ # 设备管理错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 11600101 服务调用异常 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-display.md b/zh-cn/application-dev/reference/errorcodes/errorcode-display.md index 2bcfa0750ea9341974bf8dd66388b36353d18ed6..3f45f72ce299fc7fb895fc58dcfef40ed6beac61 100755 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-display.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-display.md @@ -1,5 +1,9 @@ # 屏幕错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 1400001 无效的显示设备 **错误信息**
Invalid display or screen. diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-distributed-dataObject.md b/zh-cn/application-dev/reference/errorcodes/errorcode-distributed-dataObject.md index 1a48200bf58c284f7ba46b257d00d98d3e506904..f2a47b9dfa0e5d3f261671257787182c4df5cd78 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-distributed-dataObject.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-distributed-dataObject.md @@ -1,5 +1,9 @@ # 分布式数据对象错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 15400001 创建内存数据库失败 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md b/zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md index c387747a3624faee64a3540945112c879c8a073f..960121c19ab71165d2112b3dd0f09a1481f9d824 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md @@ -1,5 +1,9 @@ # 分布式键值数据库错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 15100001 超过最大订阅数量 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-enterpriseDeviceManager.md b/zh-cn/application-dev/reference/errorcodes/errorcode-enterpriseDeviceManager.md index d8437ae84065a31262e8e17003e9a26190cd89a6..d44bae35cadf409fed2557018602e56501329a3a 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-enterpriseDeviceManager.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-enterpriseDeviceManager.md @@ -1,5 +1,9 @@ # 企业设备管理错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 9200001 应用没有激活成设备管理器 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-faultlogger.md b/zh-cn/application-dev/reference/errorcodes/errorcode-faultlogger.md index 52d7ea0e205dd965a373e404a3beac3669524f78..e4aa5cf05a44602901040b3f2769cd52d9416962 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-faultlogger.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-faultlogger.md @@ -1,5 +1,9 @@ # Faultlogger 错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 10600001 服务未启动或故障 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-filemanagement.md b/zh-cn/application-dev/reference/errorcodes/errorcode-filemanagement.md index d9af0b188582db333768b05a65c43b5a46ca303f..3c68d9eb0a5b0b1f44c4dbf1bb54fd26ea70c24e 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-filemanagement.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-filemanagement.md @@ -1,4 +1,9 @@ -# 文件管理子系统错误码 +# 文件管理错误码 + +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + 文件管理子系统错误码由四部分组成,分别是基础文件IO错误码、用户数据管理错误码、公共文件访问错误码和空间统计错误码组成。 ## 基础文件IO错误码 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-form.md b/zh-cn/application-dev/reference/errorcodes/errorcode-form.md index e5e05c3d76aeb97993dec9a9f89f3d40880946fb..7b15d808c428e485f3a1b09bddd5b6ba16b4b830 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-form.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-form.md @@ -1,5 +1,9 @@ # 卡片错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 16500001 内部错误 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-geoLocationManager.md b/zh-cn/application-dev/reference/errorcodes/errorcode-geoLocationManager.md index 59e55fbac0939b26f787555c7d46be6bb9158b03..9ce9ce18fed30455f5da33e35a495caf36d01cc6 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-geoLocationManager.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-geoLocationManager.md @@ -1,5 +1,9 @@ # 位置服务子系统错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 3301000 位置服务不可用 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-hiappevent.md b/zh-cn/application-dev/reference/errorcodes/errorcode-hiappevent.md index 1e607fb6272dd722c7c4da63bd791c6b9e2706ba..1249deef43af46f479ec2ba0ac5d3abcff535066 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-hiappevent.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-hiappevent.md @@ -1,4 +1,8 @@ -# 应用事件打点错误码 +# 应用事件打点错误码 + +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 ## 11100001 打点功能被关闭 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-hisysevent.md b/zh-cn/application-dev/reference/errorcodes/errorcode-hisysevent.md index 05de6b20d7d83bc1ad752804cba1804a6f3187c3..e09a5899bffca01afe67f3e25107f5b3625acce1 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-hisysevent.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-hisysevent.md @@ -1,5 +1,9 @@ # 系统事件错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 1120001 非法的事件领域 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-hiviewdfx-hidebug.md b/zh-cn/application-dev/reference/errorcodes/errorcode-hiviewdfx-hidebug.md index 4c843b8bbde55cd2fe27b1d4a47c10126a023c0f..2c050a6a237d91985cc50f6ed5f86bd83816d9a1 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-hiviewdfx-hidebug.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-hiviewdfx-hidebug.md @@ -1,5 +1,8 @@ # Hidebug错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 ## 11400101 系统服务获取失败 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-huks.md b/zh-cn/application-dev/reference/errorcodes/errorcode-huks.md index d7222587ff651d569577e796449b74a011ca34ef..69aad2a6ede66487a6f321dbb0d323b01c16a182 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-huks.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-huks.md @@ -1,5 +1,9 @@ # HUKS错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 12000001 该子功能不支持(特性) **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-i18n.md b/zh-cn/application-dev/reference/errorcodes/errorcode-i18n.md index 3b6ba5548faa1d029b060135bf1990d9e5c02c4b..f0c62b09735560bfe14cf3271f24e6e910276926 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-i18n.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-i18n.md @@ -1,5 +1,9 @@ # I18n错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 890001 参数类型错误 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-inputmethod-framework.md b/zh-cn/application-dev/reference/errorcodes/errorcode-inputmethod-framework.md index 1a1ff6b678814c19bcceb1ec491d27488c6e0477..8da20d94a83b74fdfa869de87ec68d8b27708dac 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-inputmethod-framework.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-inputmethod-framework.md @@ -1,5 +1,9 @@ # 输入法框架错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 12800001 包管理服务异常 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-media.md b/zh-cn/application-dev/reference/errorcodes/errorcode-media.md index afce30c4f0b185f49b2805a17abd1360f25bd77b..9683b5805a3686bc81acc8084d17522a9016a7f5 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-media.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-media.md @@ -1,4 +1,8 @@ -# Media错误码 +# Media错误码 + +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 ## 5400101 内存分配失败 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-multimodalinput.md b/zh-cn/application-dev/reference/errorcodes/errorcode-multimodalinput.md index d2dff5f5ca02401a4e6037ad82ec8fe3c5e077cb..94683a9fbed9f6eec70f4d2aa26907d7495fecdc 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-multimodalinput.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-multimodalinput.md @@ -1,5 +1,9 @@ # 键鼠穿越管理错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 4400001 目标设备描述符错误 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-net-connection.md b/zh-cn/application-dev/reference/errorcodes/errorcode-net-connection.md index 13a0082b9cfcbbb4d83100d2d8501577d8dce377..d3bd94b8b3ae99c3fe396906c4c48afaee121711 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-net-connection.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-net-connection.md @@ -1,5 +1,9 @@ # 网络连接管理错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 2100001 非法参数值 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-net-ethernet.md b/zh-cn/application-dev/reference/errorcodes/errorcode-net-ethernet.md index 2a262a58a29c022e764ed7149427c27323f32e5c..9da62b519dee086e40edcad453daee5e3c0a41b6 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-net-ethernet.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-net-ethernet.md @@ -1,5 +1,9 @@ # 以太网错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 2200001 非法参数值 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-net-http.md b/zh-cn/application-dev/reference/errorcodes/errorcode-net-http.md index c2b4187289de4cf9454bdb46b6a7fd41c0e7f01a..0dc5c021972ed263bf093d499d3a43d7764e982f 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-net-http.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-net-http.md @@ -1,5 +1,9 @@ # HTTP错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 2300001 不支持的协议 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-net-mdns.md b/zh-cn/application-dev/reference/errorcodes/errorcode-net-mdns.md new file mode 100644 index 0000000000000000000000000000000000000000..3578cc6a5775252a1f3e85f85cb8d52008823782 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-net-mdns.md @@ -0,0 +1,117 @@ +# MDNS错误码 + +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + +## 2100002 连接服务失败 + +**错误信息** + +Operation failed. Cannot connect to service. + +**错误描述** + +操作失败,连接系统服务发生异常。 + +**可能原因** + +服务发生异常。 + +**处理步骤** + +检查系统服务运行状态是否正常。 + +## 2100003 系统内部错误 + +**错误信息** + +System internal error. + +**错误描述** + +系统内部错误。 + +**可能原因** + +1.内存异常。 + +2.空指针。 + +**处理步骤** + +1.检查内存空间是否充足,清理内存后重试。 + +2.系统异常,请稍后重试或重启设备。 + +## 2204003 重复注册 + +**错误信息** + +Callback duplicated. + +**错误描述** + +callback 已经存在。 + +**可能原因** + +重复注册相同名称和类型的mDNS服务。 + +**处理步骤** + +检查mDNS服务是否存在。 + +## 2204008 删除服务失败 + +**错误信息** + +Service instance duplicated. + +**错误描述** + +想要移除的服务不存在。 + +**可能原因** + +之前已经把服务删除,二次删除相同服务。 + +**处理步骤** + +检查mDNS服务是否存在。 + +## 2204010 发送消息失败 + +**错误信息** + +Send packet failed. + +**错误描述** + +发送信息失败。 + +**可能原因** + +局域网内不存在该mDNS服务。 + +**处理步骤** + +检查局域网内目标mDNS服务是否存在。 + +## 2204006 解析服务超时 + +**错误信息** + +Request timeout. + +**错误描述** + +解析服务超时。 + +**可能原因** + +局域网内不存在该类型的mDNS服务。 + +**处理步骤** + +检查局域网内目标类型的mDNS服务是否存在。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-net-policy.md b/zh-cn/application-dev/reference/errorcodes/errorcode-net-policy.md index 49db93f50b06584933a33ba608eb78db4c9dce90..f296f790cab8a15a81e965b80adeb9cec84833b8 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-net-policy.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-net-policy.md @@ -1,5 +1,9 @@ # 策略管理错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 2100001 非法参数值 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-net-sharing.md b/zh-cn/application-dev/reference/errorcodes/errorcode-net-sharing.md index 45da80ee1357b3ac7adb7c2ded0972ce34c645d6..69f483e09e621dd61764101a4928a814ad8363b0 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-net-sharing.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-net-sharing.md @@ -1,5 +1,9 @@ # 网络共享错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 2200001 非法参数值 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-net-socket.md b/zh-cn/application-dev/reference/errorcodes/errorcode-net-socket.md index f0bb305a18f0dcab466b678a3bf3c2c8e66f0031..dc037fcff3c611ed6ef72867539d1e3f2aef05df 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-net-socket.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-net-socket.md @@ -1,5 +1,9 @@ # Socket 错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 2301001 操作不允许 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-nfc.md b/zh-cn/application-dev/reference/errorcodes/errorcode-nfc.md index 9c73fdd1a51dc669768f88c0488d5d92d60f3ac3..044cb9e7e7c5b0e142bc9a906111c1e5f2c77ad2 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-nfc.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-nfc.md @@ -1,5 +1,9 @@ # NFC错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 3100101 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-notification.md b/zh-cn/application-dev/reference/errorcodes/errorcode-notification.md index cbeb3d3de04f386b31a25d6ae71f9fa195261a8c..901816affc8f5733eb086aecb518612b7846e59e 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-notification.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-notification.md @@ -1,5 +1,9 @@ # 通知错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 1600001 内部错误 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-pasteboard.md b/zh-cn/application-dev/reference/errorcodes/errorcode-pasteboard.md index 03f37480020359c096ad06cbdf9d16d4df32988e..1ee942912743ea69067919d23be7c285e88d2951 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-pasteboard.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-pasteboard.md @@ -1,5 +1,9 @@ # 剪贴板错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 12900001 索引超过范围 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-power.md b/zh-cn/application-dev/reference/errorcodes/errorcode-power.md index 235c30c55270902327d319a843c21d7ea250d0a1..3adeb45e6b0e7aec5e386ab8dd93223a372d4ace 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-power.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-power.md @@ -1,5 +1,9 @@ # 系统电源管理错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 4900101 连接服务失败 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-preferences.md b/zh-cn/application-dev/reference/errorcodes/errorcode-preferences.md index 46326c2abce75072ea3c1f0968743d0d8bed1f70..2a7fca5cc095bc5a4823f9ce587d7487adbb74de 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-preferences.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-preferences.md @@ -1,13 +1,17 @@ -# 首选项错误码 +# 用户首选项错误码 -## 15500010 删除首选项失败 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + +## 15500010 删除用户首选项持久化文件失败 **错误信息** Failed to delete preferences. **错误描述** -删除首选项失败。 +删除用户首选项持久化文件失败。 **可能原因** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-promptAction.md b/zh-cn/application-dev/reference/errorcodes/errorcode-promptAction.md index 193f2fad84401f0064e8ae2b817cf3dd270f9381..2cb583dededc690bd0f7bbf0ae4de3a139b902f3 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-promptAction.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-promptAction.md @@ -1,5 +1,9 @@ # 弹窗错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 100001 内部错误 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-reminderAgentManager.md b/zh-cn/application-dev/reference/errorcodes/errorcode-reminderAgentManager.md index 25ac918c2fc32f984f96e112f860ed122c8152c3..b2df9dd191f56b42bcd1a502b2beaf6f4527d296 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-reminderAgentManager.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-reminderAgentManager.md @@ -1,5 +1,9 @@ # reminderAgentManager错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 1700001 通知使能未开启 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-request.md b/zh-cn/application-dev/reference/errorcodes/errorcode-request.md index de898cb9a20669b61219528368bd5b934a00744e..12f9370e04454e4208eccdb01b53ce610f695044 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-request.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-request.md @@ -1,5 +1,9 @@ # 上传下载错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 13400001 文件操作异常 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md b/zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md index 93fbc1f8423fc26a45262d7055d77657f98bdb46..e18d833d8037993b8526a47a867c888a6d27f25b 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md @@ -1,5 +1,9 @@ # 资源管理错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 9001001 无效的资源id **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-router.md b/zh-cn/application-dev/reference/errorcodes/errorcode-router.md index 6c0c856d7b7e6a62fb25f215a5e0d34a0e5d0ca0..474adf54898b3af6e183e6ea6d9621294dc9c54b 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-router.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-router.md @@ -1,5 +1,9 @@ # 页面路由错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 100001 内部错误 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-rpc.md b/zh-cn/application-dev/reference/errorcodes/errorcode-rpc.md index 533764276a46c24626c94a3af7927b92d290c036..b24b45d4a77440c05718b515c55932fab8a09141 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-rpc.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-rpc.md @@ -1,5 +1,9 @@ # RPC错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + 从API version 9起,IPC支持异常返回功能。错误码对应数值及含义如下。 ## 1900001 系统调用mmap失败 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-runninglock.md b/zh-cn/application-dev/reference/errorcodes/errorcode-runninglock.md index e346d88ec7d26c3d25e0b935ce1d1007b659cd78..27da400a345622ef1a995b28725443fc96f29e69 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-runninglock.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-runninglock.md @@ -1,5 +1,9 @@ # RunningLock锁错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 4900101 连接服务失败 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-screenlock.md b/zh-cn/application-dev/reference/errorcodes/errorcode-screenlock.md index 5f9cf5bbfa52f24a3d2461e2a4b8516127bb9495..e0a90fbd216ae53a72e8abb9bc6ca31949161aae 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-screenlock.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-screenlock.md @@ -1,5 +1,9 @@ # 锁屏服务错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 13200002 锁屏服务异常 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-sensor.md b/zh-cn/application-dev/reference/errorcodes/errorcode-sensor.md index add7b1aa6109a85fab4741bcb205fa4ec2f891fd..954d2b372edff6bc8cbd90005a55ae07e8379485 100755 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-sensor.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-sensor.md @@ -1,5 +1,9 @@ # 传感器错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 14500101 传感器服务异常 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-system-parameterV9.md b/zh-cn/application-dev/reference/errorcodes/errorcode-system-parameterV9.md index 58b8a3e1340479efa4dae169c9f0c7e787654d29..7cd3ae4991f6c9219a7ae1ec7db504d28d2afff9 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-system-parameterV9.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-system-parameterV9.md @@ -1,5 +1,9 @@ # 系统参数错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 14700101 系统参数查找失败 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-telephony.md b/zh-cn/application-dev/reference/errorcodes/errorcode-telephony.md index a80ec138f93e6fad1ab340ee77506a0250ca3642..de54fa37a38ea3ad19d9bac634e09e78f0627ad4 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-telephony.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-telephony.md @@ -1,5 +1,9 @@ # 电话子系统错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 8300001 输入参数不在处理范围内 **错误信息** @@ -165,8 +169,8 @@ UT未连接 **可能原因** -当前运营商不支持从Wifi下发UT请求,但是当前手机Wifi已连上。 +当前运营商不支持从WIFI下发UT请求,但是当前设备WIFI已连上。 **处理步骤** -断开wifi,再重发UT请求。 +断开WIFI,再重发UT请求。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-thermal.md b/zh-cn/application-dev/reference/errorcodes/errorcode-thermal.md index e5665089092a315655ceb517e275147af89776b6..3147fa1ea50f89e4e519327835c941bdb3452120 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-thermal.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-thermal.md @@ -1,5 +1,9 @@ # 热管理错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 4800101 连接服务失败 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-time.md b/zh-cn/application-dev/reference/errorcodes/errorcode-time.md index 1ceca485130c9cb34734cd37c23f04b3c6249054..0db7d914609f68b460b55ffd7e5a9b9f57adeb13 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-time.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-time.md @@ -1,5 +1,9 @@ # 时间时区服务错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## -1 锁屏服务异常 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-uitest.md b/zh-cn/application-dev/reference/errorcodes/errorcode-uitest.md index dda3aabebadab92b9937e8f86039344e87329343..f338af3a2c01ba5e32a5b7b3cf3fc9a1aa34a190 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-uitest.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-uitest.md @@ -1,5 +1,9 @@ # uitest错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 17000001 初始化失败 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-update.md b/zh-cn/application-dev/reference/errorcodes/errorcode-update.md index 22ae27375a550ebc47d1ddadd2d9ea843254907c..a524c29cfaa081355fe1d04ac6e65337991139d7 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-update.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-update.md @@ -1,5 +1,9 @@ # 升级错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 11500104 IPC通信异常 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-usb.md b/zh-cn/application-dev/reference/errorcodes/errorcode-usb.md index 4a7910cc0b9a9074c002185ab880e9a3030a91ac..cdd4f5e38be8927562d57490898158220d7f1f7e 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-usb.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-usb.md @@ -1,5 +1,9 @@ # USB服务错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 14400001 连接USB设备被拒绝 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-useriam.md b/zh-cn/application-dev/reference/errorcodes/errorcode-useriam.md index dd75ce307816b83054f586a8ae6b7f2d9b6ac1c4..e4f0730df0c192f96055bff6ccb9de918290f00e 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-useriam.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-useriam.md @@ -1,16 +1,8 @@ -# 用户认证错误码 +# 用户认证错误码 -## 201 权限验证失败 - -具体参见[通用错误码](./errorcode-universal.md) - -## 202 调用方不是一个系统应用 - -具体参见[通用错误码](./errorcode-universal.md) - -## 401 参数不正确 - -具体参见[通用错误码](./errorcode-universal.md) +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 ## 12500001 认证失败 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-utils.md b/zh-cn/application-dev/reference/errorcodes/errorcode-utils.md index eab38038d22bcd536f7a131261296cb16e652600..a672b1cfb0dadc5470fc9f990e542e64b616a93f 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-utils.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-utils.md @@ -1,5 +1,9 @@ # 语言基础类库错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 10200001 参数范围越界错误 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-vibrator.md b/zh-cn/application-dev/reference/errorcodes/errorcode-vibrator.md index 5787a083a24ecde7ceaa44ff579ade5332064f7f..7a0e2c8b82e836532768f7953e01206222fd5f66 100755 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-vibrator.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-vibrator.md @@ -1,5 +1,9 @@ # 振动错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 14600101 操作设备失败 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-webview.md b/zh-cn/application-dev/reference/errorcodes/errorcode-webview.md index cd26bd77161593095c7773e63c95e74f06a04be4..6158032e12d0e9359550be693a66510bcb041f00 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-webview.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-webview.md @@ -1,5 +1,8 @@ # Webview错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 ## 17100001 WebviewController没有和具体的Web组件关联 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-wifi.md b/zh-cn/application-dev/reference/errorcodes/errorcode-wifi.md index 348a833f12c55cf709c9c22c8ec00e516421b27a..6f73f658a0da1b3ecdbdb669a0f59da19bbda93c 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-wifi.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-wifi.md @@ -1,5 +1,9 @@ # WIFI错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 2401000 STA内部异常 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-window.md b/zh-cn/application-dev/reference/errorcodes/errorcode-window.md index ece08787c2d65a1a7b120e6447196d26c8419c86..bb34be2b84169a9a4bbfe28ff63a8c616f1970b2 100755 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-window.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-window.md @@ -1,5 +1,9 @@ # 窗口错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 1300001 重复操作 **错误信息**
Repeated operation. diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-workScheduler.md b/zh-cn/application-dev/reference/errorcodes/errorcode-workScheduler.md index 4177243c2312a4bcef18cd5f74526085e7283d43..4d40e59ea0e42933143358bb8ddf169c81249930 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-workScheduler.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-workScheduler.md @@ -1,5 +1,9 @@ # workScheduler错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 9700001 内存操作失败 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-zlib.md b/zh-cn/application-dev/reference/errorcodes/errorcode-zlib.md index 5c70b5f61069f05093c8a53d8aa3e35123c52f38..7702ca82f46d12042a6b187df3cd2cf06b93e861 100755 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-zlib.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-zlib.md @@ -1,5 +1,9 @@ # zlib子系统错误码 +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。 + ## 900001 传入的源文件错误 **错误信息** diff --git a/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-basic-span.md b/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-basic-span.md index cd221afedbcecb0f1858dc4945c18039b23f4f81..48f95def63cb5744d872baa1860385a8292bb8fd 100644 --- a/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-basic-span.md +++ b/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-basic-span.md @@ -25,7 +25,7 @@ | 名称 | 类型 | 默认值 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -------- | | color | <color> | - | 否 | 设置文本段落的文本颜色。 | -| font-size | <length> | 30px | 否 | 设置文本段落的文本尺寸。 | +| font-size | <length> | 16px | 否 | 设置文本段落的文本尺寸。 | | font-style | string | normal | 否 | 设置文本段落的字体样式,见[text组件font-style的样式属性](js-service-widget-basic-text.md#样式)。 | | font-weight | number \| string | normal | 否 | 设置文本段落的字体粗细,见[text组件font-weight的样式属性](js-service-widget-basic-text.md#样式)。 | | text-decoration | string | none | 否 | 设置文本段落的文本修饰,见[text组件text-decoration样式属性](js-service-widget-basic-text.md#样式)。 | diff --git a/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-basic-text.md b/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-basic-text.md index f96d625c8a3f7c98fdbaeb6ef25b43de3f442de4..9c9a92037787fd8ce1be188c987e1b6c1ba225a1 100644 --- a/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-basic-text.md +++ b/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-basic-text.md @@ -25,7 +25,7 @@ | 名称 | 类型 | 默认值 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -------- | | color | <color> | - | 否 | 设置文本的颜色。 | -| font-size | <length> | 30px | 否 | 设置文本的尺寸。 | +| font-size | <length> | 16px | 否 | 设置文本的尺寸。 | | letter-spacing | <length> | 0px | 否 | 设置文本的字符间距。 | | font-style | string | normal | 否 | 设置文本的字体样式,可选值为:
- normal:标准的字体样式;
- italic:斜体的字体样式。 | | font-weight | number \| string | normal | 否 | 设置文本的字体粗细,number类型取值[100, 900],默认为400,取值越大,字体越粗。
- number取值必须为100的整数倍。
- string类型取值支持如下四个值:lighter、normal、bold、bolder。 | diff --git a/zh-cn/application-dev/reference/syscap-list.md b/zh-cn/application-dev/reference/syscap-list.md index 33f6ac5f09f4578a8d9b6414b4047854e23303d4..bf16e4e60f4b369a0b6b7d097bc6ad637e2068bd 100644 --- a/zh-cn/application-dev/reference/syscap-list.md +++ b/zh-cn/application-dev/reference/syscap-list.md @@ -172,14 +172,6 @@ WebGL2.0 标准api | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -## SystemCapability.Communication.NetManager.Extension - -网络管理扩展服务 - -| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | -| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | -| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | - ## SystemCapability.Communication.NetStack 基础网络协议栈能力 @@ -315,14 +307,6 @@ GNSS硬件相关能力 | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -## SystemCapability.MultimodalInput.Input.RemoteInputDevice - -分布式输入设备管理 - -| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | -| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | -| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | - ## SystemCapability.MultimodalInput.Input.InputMonitor 输入事件监听者 @@ -347,14 +331,6 @@ GNSS硬件相关能力 | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -## SystemCapability.MultimodalInput.Input.InputFilter - -输入事件过滤器 - -| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | -| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | -| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | - ## SystemCapability.PowerManager.BatteryManager.Extension 电池服务扩展能力 @@ -1347,7 +1323,7 @@ FA模型 | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | -## SystemCapability.Applictaions.settings.Core +## SystemCapability.Applications.settings.Core 设置API @@ -1657,4 +1633,37 @@ VPN | Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | -| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | \ No newline at end of file +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.MultimodalInput.Input.Pointer + +Pointer输入增强能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Communication.SecureElement + +安全单元芯片访问能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | + +## SystemCapability.Msdp.DeviceStatus.Stationarty + +设备状态感知 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Base + +通用类型 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | + diff --git a/zh-cn/application-dev/security/accesstoken-guidelines.md b/zh-cn/application-dev/security/accesstoken-guidelines.md index 7e1b4947bfecd9fc8f09281002c720d92b612c1e..98b075a8cd8168f0167124850dfb94e688e40db3 100644 --- a/zh-cn/application-dev/security/accesstoken-guidelines.md +++ b/zh-cn/application-dev/security/accesstoken-guidelines.md @@ -110,7 +110,7 @@ "acls":{ "allowed-acls":[ "ohos.permission.WRITE_AUDIO", - "ohos.permission.CAPTURE_SCREEN" + "ohos.permission.CAPTURE_SCREEN" ] } } @@ -131,7 +131,7 @@ 以允许应用读取日历信息为例进行说明。 -1. 申请`ohos.permission.READ_CALENDAR`权限,配置方式请参见[访问控制授权申请](#配置文件权限声明)。 +1. 申请`ohos.permission.READ_CALENDAR`权限,配置方式请参见[配置文件权限声明](#配置文件权限声明)。 2. 校验当前是否已经授权。 @@ -335,4 +335,4 @@ reqPermissions() { 针对访问控制,有以下相关实例可供参考: - [AbilityAccessCtrl:访问权限控制(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/SystemFeature/Security/AbilityAccessCtrl) -- [为应用添加运行时权限(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/codelabs/tree/master/Ability/AccessPermission) \ No newline at end of file +- [为应用添加运行时权限(ArkTS)(Full SDK)(API9)](https://gitee.com/openharmony/codelabs/tree/master/Ability/AccessPermission) diff --git a/zh-cn/application-dev/security/app-provision-structure.md b/zh-cn/application-dev/security/app-provision-structure.md index 0bee0fc5f8540d8026f026da84a17e4ef2eba842..f3103bd235e2e1d8ce1740b9f274f47e7d27d4da 100644 --- a/zh-cn/application-dev/security/app-provision-structure.md +++ b/zh-cn/application-dev/security/app-provision-structure.md @@ -62,7 +62,7 @@ HarmonyAppProvision文件示例: ### bundle-info对象内部结构 -**说明:** HarmonyAppProvision文件中的bundle-info对象中bundle-name需要和所签名应用的包名bundleName(config.js/module.json5)保持一致。为了防止同一个HarmonyAppProvision配置文件任意用于不同应用的签名,在应用安装过程中,系统会校验HAP签名信息的bundleName与HAP的配置文件中的bundleName是否一致,如果不一致,HAP无法安装。 +**说明:** HarmonyAppProvision文件中的bundle-info对象中bundle-name需要和所签名应用的包名bundleName(config.json/module.json5)保持一致。为了防止同一个HarmonyAppProvision配置文件任意用于不同应用的签名,在应用安装过程中,系统会校验HAP签名信息的bundleName与HAP的配置文件中的bundleName是否一致,如果不一致,HAP无法安装。 | 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 | | ------------------------ | ------------------------------- | ------- | -------- | --------- | diff --git a/zh-cn/application-dev/security/permission-list.md b/zh-cn/application-dev/security/permission-list.md index 72501e07bb83ea82926ecf9a9c81c5a7bb523bd6..e89b3ef3fd297eefe2dd73e38f388d95333b74e4 100644 --- a/zh-cn/application-dev/security/permission-list.md +++ b/zh-cn/application-dev/security/permission-list.md @@ -964,6 +964,16 @@ **ACL使能**:TRUE +## ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY + +允许设备管理员设置包安装管理策略。 + +**权限级别**:system_basic + +**授权方式**:system_grant + +**ACL使能**:TRUE + ## ohos.permission.NFC_TAG 允许应用读取Tag卡片。 @@ -1716,4 +1726,34 @@ **授权方式**:system_grant -**ACL使能**:TRUE \ No newline at end of file +**ACL使能**:TRUE + +## ohos.permission.CONNECT_CELLULAR_CALL_SERVICE + +允许系统服务访问蜂窝通话SA。 + +**权限级别**:system_basic + +**授权方式**:system_grant + +**ACL使能**:FALSE + +## ohos.permission.CONNECT_IMS_SERVICE + +允许系统服务访问IMS SA。 + +**权限级别**:system_basic + +**授权方式**:system_grant + +**ACL使能**:FALSE + +## ohos.permission.ACCESS_SENSING_WITH_ULTRASOUND + +允许应用使用超声波感知。 + +**权限级别**:system_basic + +**授权方式**:system_grant + +**ACL使能**:FALSE diff --git a/zh-cn/application-dev/security/userauth-guidelines.md b/zh-cn/application-dev/security/userauth-guidelines.md index f6b31bc96ed0635ab85a9294522de3aae7015103..80ccb1974280e59cff6f42c307a63402e6119b0f 100644 --- a/zh-cn/application-dev/security/userauth-guidelines.md +++ b/zh-cn/application-dev/security/userauth-guidelines.md @@ -17,7 +17,6 @@ userIAM_userAuth模块提供了用户认证的相关方法,包括查询认证 | 接口名称 | 功能描述 | | ---------- | ----------------------- | -| getVersion() : number | 获取认证对象的版本信息。 | | getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): void | 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力。 | | getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel : AuthTrustLevel): AuthInstance | 获取AuthInstance对象,用于执行用户身份认证。 | | on(name : AuthEventKey, callback : AuthEvent) : void | 订阅指定类型的用户认证事件。 | @@ -25,26 +24,6 @@ userIAM_userAuth模块提供了用户认证的相关方法,包括查询认证 | start: void | 执行用户认证。 | | cancel: void | 取消本次认证操作。 | -## 获取认证对象的版本信息 - -### 开发步骤 - -1. 申请权限。调用[getVersion](../reference/apis/js-apis-useriam-userauth.md#useriam_userauthgetversion9)接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息请参考[Stage模型应用程序包结构](../quick-start/module-configuration-file.md)。 - -2. 调用[getVersion](../reference/apis/js-apis-useriam-userauth.md#useriam_userauthgetversion9)接口获取版本信息。 - - ```js - import userIAM_userAuth from '@ohos.userIAM.userAuth'; - - // 获取版本信息 - try { - let version = userIAM_userAuth.getVersion(); - console.info("auth version = " + version); - } catch (error) { - console.info("get version failed, error = " + error); - } - ``` - ## 查询当前设备是否支持相应的认证能力 ### 开发步骤 diff --git a/zh-cn/application-dev/task-management/reminder-agent-development.md b/zh-cn/application-dev/task-management/reminder-agent-development.md index cc57f01db881131f73ea7b11392005dd03fc0442..ed069b3469316412901df7eef20a13c03aadcfd8 100644 --- a/zh-cn/application-dev/task-management/reminder-agent-development.md +++ b/zh-cn/application-dev/task-management/reminder-agent-development.md @@ -19,7 +19,7 @@ ## 开发步骤 -1. 申请`ohos.permission.PUBLISH_AGENT_REMINDER`权限,配置方式请参见[访问控制授权申请](../security/accesstoken-guidelines.md#配置文件权限声明)。 +1. 需要申请`ohos.permission.PUBLISH_AGENT_REMINDER`权限,配置方式请参见[配置文件权限声明](../security/accesstoken-guidelines.md#配置文件权限声明)。 2. [使能通知开关](../notification/notification-enable.md),获得用户授权后,才能使用代理提醒功能。 @@ -180,4 +180,4 @@ 基于后台代理提醒的开发,有以下相关实例可供参考: -- [闹钟(ArkTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/CommonEventAndNotification/AlarmClock) \ No newline at end of file +- [闹钟(ArkTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/CommonEventAndNotification/AlarmClock) diff --git a/zh-cn/application-dev/tools/bm-tool.md b/zh-cn/application-dev/tools/bm-tool.md index e47fe4ef6bfd98029fd009e47bd326dbeb46b675..f7d9ff64e913212554d419eebfb16f0ec2556e5d 100644 --- a/zh-cn/application-dev/tools/bm-tool.md +++ b/zh-cn/application-dev/tools/bm-tool.md @@ -56,6 +56,7 @@ bm install [-h] [-p path] [-u userId] [-r] [-w waitting-time] | -u | 否,默认安装到当前所有用户上 | 给指定用户安装一个HAP | | -r | 否,默认值为覆盖安装 | 覆盖安装一个HAP | | -w | 否,默认等待5s | 安装HAP时指定bm工具等待时间,最小的等待时长为5s,最大的等待时长为600s, 默认缺省为5s | +| -s | 否 | 安装应用间HSP路径,支持指定多个应用间HSP路径同时安装 | 示例: @@ -64,6 +65,12 @@ bm install [-h] [-p path] [-u userId] [-r] [-w waitting-time] bm install -p /data/app/ohosapp.hap -u 100 -w 5s -r // 执行结果 install bundle successfully. +# 安装一个应用间共享库 +bm install -s xxx.hsp +# 同时安装多个应用间共享库 +bm install -s xxx.hsp yyy.hsp +# 同时安装使用方应用和其依赖的应用间共享库 +bm install -p aaa.hap -s xxx.hsp yyy.hsp ``` @@ -83,6 +90,8 @@ bm uninstall [-h help] [-n bundleName] [-m moduleName] [-u userId] [-k] | -m | 否,默认卸载所有模块 | 指定卸载应用的一个模块 | | -u | 否,默认卸载当前所有用户下该应用 | 指定用户卸载应用 | | -k | 否,默认卸载应用时不保存应用数据 | 卸载应用时保存应用数据 | +| -s | 否 | 安装应用间HSP路径,支持指定多个应用间HSP路径同时安装 | +| -v | 否,默认卸载同包名的所有共享包 | 指示共享包的版本号 | 示例: @@ -91,6 +100,10 @@ bm uninstall [-h help] [-n bundleName] [-m moduleName] [-u userId] [-k] bm uninstall -n com.ohos.app -m com.ohos.app.EntryAbility -u 100 -k // 执行结果 uninstall bundle successfully. +# 卸载一个shared bundle +bm uninstall -s -n com.ohos.example +# 卸载一个shared bundle的指定版本 +bm uninstall -s -n com.ohos.example -v 100001 ``` @@ -286,3 +299,30 @@ bm quickfix -a -f /data/app/ //执行结果 apply quickfix succeed. ``` + +## 共享库查询命令 + +```bash +bm dump-shared [-h help] [-a] [-n bundleName] [-m moudleName] +``` + + **表11** 共享库查询命令列表 + +| 命令 | 描述 | +| ------------------------------------------------ | -------------------------------------- | +| bm dump-shared -h | 显示dump-shared支持的命令信息 | +| bm dump-shared -a | 查询系统中已安装所有共享库 | +| bm dump-shared -n | 查询指定共享库包名的详细信息 | +| bm dump-dependencies -h | 显示bm dump-dependencies支持的命令信息 | +| bm dump-dependencies -n bundleName -m moudleName | 查询指定应用指定模块依赖的共享库信息 | + +示例: + +```bash +# 显示所有已安装共享库包名 +bm dump-shared -a +# 显示该共享库的详细信息 +bm dump-shared -n com.ohos.lib +# 显示指定应用指定模块依赖的共享库信息 +bm dump-dependencies -n com.ohos.app -m entry +``` diff --git a/zh-cn/application-dev/ui/ui-ts-animation-feature.md b/zh-cn/application-dev/ui/ui-ts-animation-feature.md index beaa8f4ac9087a663203422d16d6ee7710ca27c3..4373539cca6f91f044e37bc702aeb5fa6e6663f7 100644 --- a/zh-cn/application-dev/ui/ui-ts-animation-feature.md +++ b/zh-cn/application-dev/ui/ui-ts-animation-feature.md @@ -132,7 +132,7 @@ .onAppear(() => { animateTo({ - duration: 2000, + duration: 1000, curve: this.curve1, delay: 100, onFinish: () => { @@ -199,7 +199,7 @@ .opacity(this.opacityValue) .onAppear(() => { animateTo({ - duration: 2000, + duration: 1000, curve: this.curve1, delay: 100, onFinish: () => { 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 6da6959c439004112f76ed51d92439306fb64edc..c2f44d025894846f7fac4cf5e6dd879b691b845a 100644 --- a/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md +++ b/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md @@ -106,7 +106,7 @@ listener.on('change', onPortrait) | min-device-height | 设备的最小高度。 | | max-device-height | 设备的最大高度。 | | device-width | 设备的宽度。 | -| device-type | 设备的类型。
可选值:default | +| device-type | 设备的类型。
可选值:default、tablet | | min-device-width | 设备的最小宽度。 | | max-device-width | 设备的最大宽度。 | | round-screen | 屏幕类型,圆形屏幕为true,  非圆形屏幕为  false。 | diff --git a/zh-cn/application-dev/website.md b/zh-cn/application-dev/website.md index 44a0cae7aee4f5bee0a29f4204b5abeca3521270..65030d6f11fb6d1f5f5f96b105c9b27e341020ac 100644 --- a/zh-cn/application-dev/website.md +++ b/zh-cn/application-dev/website.md @@ -667,7 +667,7 @@ - [类型说明](reference/arkui-ts/ts-types.md) - 已停止维护的组件 - [GridContainer](reference/arkui-ts/ts-container-gridcontainer.md) - - 组件参考(兼容JS的类Web开发范式) + - 组件参考(兼容JS的类Web开发范式-ArkUI.Full) - 组件通用信息 - [通用属性](reference/arkui-js/js-components-common-attributes.md) - [通用样式](reference/arkui-js/js-components-common-styles.md) @@ -768,6 +768,41 @@ - [生命周期定义](reference/arkui-js/js-components-custom-lifecycle.md) - [动态创建组件](reference/arkui-js/js-components-create-elements.md) - [数据类型说明](reference/arkui-js/js-appendix-types.md) + - 组件参考(兼容JS的类Web开发范式-ArkUI.Lite) + - 框架说明 + - [文件组织](js-framework-file.md) + - [js标签配置](js-framework-js-tag.md) + - [app.js](js-framework-js-file.md) + - 语法 + - [HML语法参考](js-framework-syntax-hml.md) + - [CSS语法参考](js-framework-syntax-css.md) + - [JS语法参考](js-framework-syntax-js.md) + - 组件通用信息 + - [通用事件](js-common-events.md) + - [通用属性](js-common-attributes.md) + - [通用样式](js-common-styles.md) + - [动画样式](js-components-common-animation.md) + - 容器组件 + - [div](js-components-container-div.md) + - [list](js-components-container-list.md) + - [list-item](js-components-container-list-item.md) + - [stack](js-components-container-stack.md) + - [swiper](js-components-container-swiper.md) + - 基础组件 + - [chart](js-components-basic-chart.md) + - [image](js-components-basic-image.md) + - [image-animator](js-components-basic-image-animator.md) + - [input](js-components-basic-input.md) + - [marquee](js-components-basic-marquee.md) + - [picker-view](js-components-basic-picker-view.md) + - [progress](js-components-basic-progress.md) + - [qrcode](js-components-basic-qrcode.md) + - [slider](js-components-basic-slider.md) + - [switch](js-components-basic-switch.md) + - [text](js-components-basic-text.md) + - 画布组件 + - [canvas组件](js-components-canvas-canvas.md) + - [CanvasRenderingContext2D对象](js-components-canvas-canvasrenderingcontext2d.md) - JS服务卡片UI组件参考 - JS服务卡片UI框架说明 - [文件组织](reference/js-service-widget-ui/js-service-widget-file.md) diff --git a/zh-cn/contribute/OpenHarmony-JavaScript-coding-style-guide.md b/zh-cn/contribute/OpenHarmony-JavaScript-coding-style-guide.md index 168183261dd57cf172ff0a2b4e5211051d0b16b5..e42c06b89114b1fb2749f151c00e0b293eef6358 100755 --- a/zh-cn/contribute/OpenHarmony-JavaScript-coding-style-guide.md +++ b/zh-cn/contribute/OpenHarmony-JavaScript-coding-style-guide.md @@ -169,13 +169,13 @@ function render(container, dataSource) { **例外:** 如果一行注释包含了超过120 个字符的命令或URL,则可以保持一行,以方便复制、粘贴和通过grep查找; 预处理的 error 信息在一行便于阅读和理解,即使超过 120 个字符。 -#### 规则3.3 大括号的使用须遵循约定: +#### 规则2.3 大括号的使用须遵循约定: 1. 如果大括号内为空,则允许简写成`{}`,且无需换行; 2. 左大括号前不换行,括号后换行; 3. 右大括号前换行,括号后还有`else`、`catch`等情况下不换行,其他情况都换行。 -#### 规则3.4 条件语句和循环语句的实现必须使用大括号包裹,即使只有一条语句。 +#### 规则2.4 条件语句和循环语句的实现必须使用大括号包裹,即使只有一条语句。 **反例:** diff --git "a/zh-cn/contribute/\347\254\254\344\270\211\346\226\271\345\274\200\346\272\220\350\275\257\344\273\266\345\217\212\350\256\270\345\217\257\350\257\201\350\257\264\346\230\216.md" "b/zh-cn/contribute/\347\254\254\344\270\211\346\226\271\345\274\200\346\272\220\350\275\257\344\273\266\345\217\212\350\256\270\345\217\257\350\257\201\350\257\264\346\230\216.md" index 672f0adbdd911217e22fa1cf49c448a4dfa8bd33..e0f3c4710340b3db20827d58481228f4b65788b0 100755 --- "a/zh-cn/contribute/\347\254\254\344\270\211\346\226\271\345\274\200\346\272\220\350\275\257\344\273\266\345\217\212\350\256\270\345\217\257\350\257\201\350\257\264\346\230\216.md" +++ "b/zh-cn/contribute/\347\254\254\344\270\211\346\226\271\345\274\200\346\272\220\350\275\257\344\273\266\345\217\212\350\256\270\345\217\257\350\257\201\350\257\264\346\230\216.md" @@ -90,8 +90,8 @@ OpenHarmony使用了如下第三方开源软件,下表对各开源软件采用 | third_party_mksh | MirOS License | 该License无强制开放源码义务条款。 | | third_party_toybox | Public Domain License | 该License无强制开放源码义务条款。 | | third_party_optimized_routines | MIT License | 该License无强制开放源码义务条款。 | -| third_party_libsnd | LGPL v2.1 | 该License无强制开放源码义务条款。部分测试代码使用GPL-3.0-or-later协议,部分测试代码使用GPL-2.0-or-later协议 | -| third_party_pulseaudio | LGPL v2.1 | 该License无强制开放源码义务条款。 | +| third_party_libsnd | LGPL v2.1 | 采用动态链接调用,OpenHarmony进程不受LGPL影响。部分测试代码使用GPL-3.0-or-later协议,部分测试代码使用GPL-2.0-or-later协议 | +| third_party_pulseaudio | LGPL v2.1 | 采用动态链接调用,OpenHarmony进程不受LGPL影响。| | third_party_ffmpeg | LGPL v2.1 | OpenHarmony采用动态链接方式使用LGPL许可证下的ffmpeg库,不会导致该项目其它代码受到LGPL许可证的影响。 | | third_party_quickjs | MIT licence | 该License无强制开放源码义务条款。| | third_party_icu | BSD 3-Clause License, ICU License, UNICODE INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE | License无强制开放源码义务条款。 | diff --git a/zh-cn/device-dev/Readme-CN.md b/zh-cn/device-dev/Readme-CN.md index 75f58ab4228925d2c57096ed3d2d29cff2e28314..0ee0a90d465c6b126a4baeca742ce2cec4cd1882 100644 --- a/zh-cn/device-dev/Readme-CN.md +++ b/zh-cn/device-dev/Readme-CN.md @@ -38,10 +38,8 @@ - [图形图像](subsystems/subsys-graphics-overview.md) - [媒体](subsystems/subsys-multimedia-camera-overview.md) - [公共基础](subsystems/subsys-utils-guide.md) - - [AI框架](subsystems/subsys-ai-aiframework-devguide.md) - - [数据管理](subsystems/subsys-data-relational-database-overview.md) + - [AI框架](subsystems/subsys-ai-aiframework-devguide.md) - [Sensor服务](subsystems/subsys-sensor-overview.md) - - [USB服务](subsystems/subsys-usbservice-overview.md) - [用户程序框架](subsystems/subsys-application-framework-overview.md) - [OTA升级](subsystems/subsys-ota-guide.md) - [电话服务](subsystems/subsys-tel-overview.md) diff --git a/zh-cn/device-dev/subsystems/Readme-CN.md b/zh-cn/device-dev/subsystems/Readme-CN.md index 98e48250028ffbc93a511cd67980b08e9f4586ba..ada771ceab4cca745ffee93a9455450bb83d278b 100644 --- a/zh-cn/device-dev/subsystems/Readme-CN.md +++ b/zh-cn/device-dev/subsystems/Readme-CN.md @@ -39,21 +39,10 @@ - [音视频录制开发指导](subsys-multimedia-video-record-guide.md) - [公共基础库开发指导](subsys-utils-guide.md) - [AI框架开发指导](subsys-ai-aiframework-devguide.md) -- 数据管理 - - 关系型数据库 - - [关系型数据库概述](subsys-data-relational-database-overview.md) - - [关系型数据库开发指导](subsys-data-relational-database-guide.md) - - 轻量级数据存储 - - [轻量级数据存储概述](subsys-data-storage-overview.md) - - [轻量级数据存储开发指导](subsys-data-storage-guide.md) - Sensor服务 - [Sensor服务概述](subsys-sensor-overview.md) - [Sensor服务使用指导](subsys-sensor-guide.md) - [Sensor服务使用实例](subsys-sensor-demo.md) -- USB服务 - - [USB服务概述](subsys-usbservice-overview.md) - - [USB服务使用指导](subsys-usbservice-guide.md) - - [USB服务使用实例](subsys-usbservice-demo.md) - 用户程序框架 - [概述](subsys-application-framework-overview.md) - [搭建环境](subsys-application-framework-envbuild.md) @@ -101,7 +90,6 @@ - [HiSysEvent订阅指导](subsys-dfx-hisysevent-listening.md) - [HiSysEvent查询指导](subsys-dfx-hisysevent-query.md) - [HiSysEvent工具使用指导](subsys-dfx-hisysevent-tool.md) - - [HiDumper开发指导](subsys-dfx-hidumper.md) - [HiChecker开发指导](subsys-dfx-hichecker.md) - [Faultlogger开发指导](subsys-dfx-faultlogger.md) - [Hiview开发指导](subsys-dfx-hiview.md) @@ -109,6 +97,7 @@ - [bytrace使用指导](subsys-toolchain-bytrace-guide.md) - [hdc使用指导](subsys-toolchain-hdc-guide.md) - [hiperf使用指导](subsys-toolchain-hiperf.md) + - [HiDumper使用指导](subsys-dfx-hidumper.md) - 电源管理 - 显示管理 - - [系统亮度范围定制开发指导](subsys-power-brightness-customization.md) \ No newline at end of file + - [系统亮度范围定制开发指导](subsys-power-brightness-customization.md) diff --git a/zh-cn/device-dev/subsystems/figures/dfx-overview.png b/zh-cn/device-dev/subsystems/figures/dfx-overview.png new file mode 100644 index 0000000000000000000000000000000000000000..42ee515131dbf60c56c5eb4abafbc0603e027f0e Binary files /dev/null and b/zh-cn/device-dev/subsystems/figures/dfx-overview.png differ diff --git a/zh-cn/device-dev/subsystems/figures/zh-cn_image_0000001261812333.png b/zh-cn/device-dev/subsystems/figures/zh-cn_image_0000001261812333.png deleted file mode 100644 index 76fd15e43b8ccf8566ed55cc0592d3f3e6580319..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/subsystems/figures/zh-cn_image_0000001261812333.png and /dev/null differ diff --git a/zh-cn/device-dev/subsystems/figures/zh-cn_image_0000001261812334.png b/zh-cn/device-dev/subsystems/figures/zh-cn_image_0000001261812334.png new file mode 100644 index 0000000000000000000000000000000000000000..0a91177b3004ff030d3ff86b79e2193f52725f87 Binary files /dev/null and b/zh-cn/device-dev/subsystems/figures/zh-cn_image_0000001261812334.png differ diff --git a/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md b/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md index c1bd5906e9b3b09a0bb798d9ff7e3f0153160f86..d419e97908206ae61b47aaacbe0ecae625f56db9 100755 --- a/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md @@ -63,6 +63,7 @@ OpenHarmony提供通用的应用特权和可由设备厂商针对不同设备单 | allowAbilityExcludeFromMissions | bool | false| 是否允许Ability不在任务栈中显示。 | | allowAppUsePrivilegeExtension | bool | false|是否允许应用使用ServiceExtension、DataExtension。 | | allowFormVisibleNotify | bool | false| 是否允许桌面卡片可见。 | +| allowAppShareLibrary | bool | false | 是否允许为其它应用提供[应用间`HSP`](../../application-dev/quick-start/cross-app-hsp.md)能力。 ### 配置方式 @@ -90,6 +91,7 @@ OpenHarmony提供通用的应用特权和可由设备厂商针对不同设备单 "allowAbilityExcludeFromMissions": true, // 允许Ability不在任务栈中显示 "allowAppUsePrivilegeExtension": true, // 允许应用使用ServiceExtension、DataExtension "allowFormVisibleNotify": true // 允许桌面卡片可见 + "allowAppShareLibrary": true // 允许应用提供应用间HSP能力 }, } ``` 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 deleted file mode 100644 index 888c1d09552d9b77beaaf73dd3912f892e42b2df..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-data-relational-database-guide.md +++ /dev/null @@ -1,346 +0,0 @@ -# 关系型数据库开发指导 - -## 场景介绍 - -关系型数据库是在SQLite基础上实现的本地数据操作机制,提供给用户无需编写原生SQL语句就能进行数据增删改查的方法,同时也支持原生SQL语句操作。 - -## 接口说明 -### 数据库的创建和删除 - -关系型数据库提供了数据库创建方式,以及对应的删除接口,涉及的API如下所示。 - -表1 数据库创建和删除API - -| 类名 | 接口名 | 描述 | -| ---- | ---- | ---- | -| RdbStoreConfig | RdbStoreConfig(const std::string &path,
StorageMode storageMode = StorageMode::MODE_DISK,
bool readOnly = false,
const std::vector &encryptKey = std::vector(),
const std::string &journalMode = "",
const std::string &syncMode = "",
const std::string &databaseFileType = "",
const std::string &databaseFileSecurityLevel = "") | 对数据库进行配置,包括设置数据库名、存储模式、日志模式、同步模式,是否为只读,及数据库加密。

  • path:数据库路径;
  • readOnly:是否只读;
  • storageMode:存储模式;
  • encryptKey:加密密钥;
  • journalMode:日志模式;
  • syncMode:同步模式;
  • databaseFileType:数据库类型;
  • databaseFileSecurityLevel:安全等级
| -| RdbOpenCallback | int OnCreate(RdbStore &rdbStore) | 数据库创建时被回调,开发者可以在该方法中初始化表结构,并添加一些应用使用到的初始化数据。 | -| RdbOpenCallback | int OnUpgrade(RdbStore &rdbStore, int currentVersion, int targetVersion) | 数据库升级时被回调。 | -| RdbOpenCallback | int OnDowngrade(RdbStore &rdbStore, int currentVersion, int targetVersion) | 数据库降级时被回调。 | -| RdbHelper | std::shared_ptr\ GetRdbStore(const RdbStoreConfig &config, int version, RdbOpenCallback &openCallback, int &errCode) | 根据配置创建或打开数据库。 | -| RdbHelper | int DeleteRdbStore(const std::string &path) | 删除指定的数据库。 | - -### 数据库谓词的使用 - -关系型数据库提供了用于设置数据库操作条件的谓词AbsRdbPredicates,其中包括两个实现子类RdbPredicates和RawRdbPredicates: - -- RdbPredicates:开发者无需编写复杂的SQL语句,仅通过调用该类中条件相关的方法,如equalTo、notEqualTo、groupBy、orderByAsc、beginsWith等,就可自动完成SQL语句拼接,方便用户聚焦业务操作。 -- RawRdbPredicates:可满足复杂SQL语句的场景,支持开发者自己设置where条件子句和whereArgs参数。不支持equalTo等条件接口的使用。 - - 表2 数据库谓词API - | 类名 | 接口名 | 描述 | - | ---- | ---- | ---- | - | RdbPredicates | AbsPredicates *EqualTo(std::string field, std::string value) | 设置谓词条件,满足field字段与value值相等。 | - | RdbPredicates | AbsPredicates *NotEqualTo(std::string field, std::string value) | 设置谓词条件,满足field字段与value值不相等。 | - | RdbPredicates | AbsPredicates *BeginsWith(std::string field, std::string value) | 设置谓词条件,满足field字段以value值开头。 | - | RdbPredicates | AbsPredicates *Between(std::string field, std::string low, std::string high) | 设置谓词条件,满足field字段在最小值low和最大值high之间。 | - | RdbPredicates | AbsPredicates *OrderByAsc(std::string field) | 设置谓词条件,根据field字段升序排列。 | - | RdbPredicates | void SetWhereClause(std::string whereClause) | 设置where条件子句。 | - | RdbPredicates | void SetWhereArgs(std::vector\ whereArgs) | 设置whereArgs参数,该值表示where子句中占位符的值。 | - | RdbPredicates | AbsRdbPredicates *InDevices(std::vector& devices) | 设置谓词条件,同步分布式数据库时指定组网内的远程设备。 | - | RdbPredicates | AbsRdbPredicates *InAllDevices() | 设置谓词条件,同步分布式数据库时连接到组网内的所有远程设备。| - - -### 数据表的增删改查 - -关系型数据库提供对本地数据增删改查操作的能力,相关API如下所示。 - -- 新增 - - 关系型数据库提供了插入数据的接口,通过ValuesBucket输入要存储的数据,通过返回值判断是否插入成功,插入成功时返回最新插入数据所在的行号,失败时则返回-1。 - - 表3 数据表插入API - - | 类名 | 接口名 | 描述 | - | ---- | ---- | ---- | - | RdbStore | int Insert(int64_t &outRowId, const std::string &table, const ValuesBucket &initialValues) | 向数据库插入数据。
  • table:待添加数据的表名。
  • initialValues:以ValuesBucket存储的待插入的数据。它提供一系列put方法,如PutString(const std::string &columnName, const std::string &value),PutDouble(const std::string &columnName, double value),用于向ValuesBucket中添加数据。
| - -- 删除 - - 调用删除接口,通过AbsRdbPredicates指定删除条件。该接口的返回值表示删除的数据行数,可根据此值判断是否删除成功。如果删除失败,则返回0。 - - 表4 数据表删除API - | 类名 | 接口名 | 描述 | - | ---- | ---- | ---- | - | RdbStore | int Delete(int &deletedRows, const AbsRdbPredicates &predicates) | 删除数据。
  • deletedRows:删除的记录条数。
  • predicates:Rdb谓词,指定了删除操作的表名和条件。AbsRdbPredicates的实现类有两个:RdbPredicates和RawRdbPredicates。
    • RdbPredicates:支持调用谓词提供的equalTo等接口,设置删除条件。
    • RawRdbPredicates:仅支持设置表名、where条件子句、whereArgs三个参数,不支持equalTo等接口调用。
| - -- 更新 - - 调用更新接口,传入要更新的数据,并通过AbsRdbPredicates指定更新条件。该接口的返回值表示更新操作影响的行数。如果更新失败,则返回0。 - - 表5 数据表更新API - | 类名 | 接口名 | 描述 | - | ---- | ---- | ---- | - | RdbStore | int Update(int &changedRows, const ValuesBucket &values, const AbsRdbPredicates &predicates) | 更新数据库表中符合谓词指定条件的数据。
  • changedRows:更新的记录条数。
  • values:以ValuesBucket存储的要更新的数据。
  • predicates:指定了更新操作的表名和条件。AbsRdbPredicates的实现类有两个:RdbPredicates和RawRdbPredicates。
    • RdbPredicates:支持调用谓词提供的equalTo等接口,设置更新条件。
    • RawRdbPredicates:仅支持设置表名、where条件子句、whereArgs三个参数,不支持equalTo等接口调用。
| - -- 查询 - - 关系型数据库提供了两种查询数据的方式: - - - 直接调用查询接口。使用该接口,会将包含查询条件的谓词自动拼接成完整的SQL语句进行查询操作,无需用户传入原生的SQL语句。 - - 执行原生的SQL语句进行查询操作。 - - 表6 数据表查询API - | 类名 | 接口名 | 描述 | - | ---- | ---- | ---- | - | RdbStore | std::unique_ptr Query(const AbsRdbPredicates &predicates, const std::vector\ columns) | 查询数据。
  • predicates:谓词,可以设置查询条件。AbsRdbPredicates的实现类有两个:RdbPredicates和RawRdbPredicates。
    • RdbPredicates:支持调用谓词提供的equalTo等接口,设置查询条件。
    • RawRdbPredicates:仅支持设置表名、where条件子句、whereArgs三个参数,不支持equalTo等接口调用。
  • columns:规定查询返回的列。
| - | RdbStore | std::unique_ptr QuerySql(const std::string &sql, const std::vector\ &selectionArgs = std::vector\()) | 执行原生的用于查询操作的SQL语句。
  • sql:原生用于查询的sql语句。
  • selectionArgs:sql语句中占位符参数的值,若select语句中没有使用占位符,该参数可以设置为null。
| - -### 查询结果集的使用 - -关系型数据库提供了查询返回的结果集ResultSet,其指向查询结果中的一行数据,供用户对查询结果进行遍历和访问。ResultSet对外API如下所示。 - -表7 结果集API -| 类名 | 接口名 | 描述 | -| ---- | ---- | ---- | -| ResultSet | int GoTo(int offset) | 从结果集当前位置移动指定偏移量。 | -| ResultSet | int GoToRow(int position) | 将结果集移动到指定位置。 | -| ResultSet | int GoToNextRow() | 将结果集向后移动一行。 | -| ResultSet | int GoToPreviousRow() | 将结果集向前移动一行。 | -| ResultSet | int IsStarted(bool &result) | 判断结果集是否被移动过。 | -| ResultSet | int IsEnded(bool &result) | 判断结果集是否被移动到最后一行之后。 | -| ResultSet | int IsAtFirstRow(bool &result) | 判断结果集当前位置是否在第一行。 | -| ResultSet | int IsAtLastRow(bool &result) | 判断结果集当前位置是否在最后一行。 | -| ResultSet | int GetRowCount(int &count) | 获取当前结果集中的记录条数。 | -| ResultSet | int GetColumnCount(int &count) | 获取结果集中的列数。 | -| ResultSet | int GetString(int columnIndex, std::string &value) | 获取当前行指定列的值,以String类型返回。 | -| ResultSet | int GetBlob(int columnIndex, std::vector\ &blob) | 获取当前行指定列的值,以字节数组形式返回。 | -| ResultSet | int GetDouble(int columnIndex, double &value) | 获取当前行指定列的值,以double型返回。 | - -### 设置分布式列表 - -用户可以对当前数据库中的列表设置为分布式列表。 - -表8 设置分布式列表 -| 类名 | 接口名 | 描述 | -| ---- | ---- | ---- | -| RdbStore | bool SetDistributedTables(const std::vector& tables) | 设置分布式列表。
  • tables:要设置的分布式列表表名
- -### 根据本地表名获取指定远程设备的分布式表名 - -用户根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名。 - -表9 根据本地表名获取指定远程设备的分布式表名 -| 类名 | 接口名 | 描述 | -| ---- | ---- | ---- | -| RdbStore | std::string ObtainDistributedTableName(const std::string& device, const std::string& table) | 根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名。
  • device:远程设备ID
  • table:本地表名
- -### 在设备之间同步数据 - -表10 在设备之间同步数据 -| 类名 | 接口名 | 描述 | -| ---- | ---- | ---- | -| RdbStore | bool Sync(const SyncOption& option, const AbsRdbPredicates& predicate, const SyncCallback& callback) | 在设备之间同步数据。
  • option:同步选项;mode:同步模式(PUSH表示数据从本地设备推送到远程设备/PULL表示数据从远程设备拉至本地设备);isBlock:是否阻塞
  • callback:指定的callback回调函数
- -### 注册数据库的观察者 - -表11 注册数据库的观察者 -| 类名 | 接口名 | 描述 | -| ---- | ---- | ---- | -| RdbStore | bool Subscribe(const SubscribeOption& option, RdbStoreObserver *observer) | 注册数据库的观察者。当分布式数据库中的数据发生更改时,将调用回调。
  • option:订阅类型;
  • observer:指分布式数据库中数据更改事件的观察者
- -### 从数据库中删除指定类型的指定观察者 - -表12 从数据库中删除指定类型的指定观察者 -| 类名 | 接口名 | 描述 | -| ---- | ---- | ---- | -| RdbStore | bool UnSubscribe(const SubscribeOption& option, RdbStoreObserver *observer) | 从数据库中删除指定类型的指定观察者。
  • option:订阅类型;
  • observer:指已注册的数据更改观察者
- -### 数据库的备份和恢复 - -关系型数据库提供对本地数据库文件的备份和恢复能力,相关API如下所示。 - -- 备份 - - 关系型数据库提供了备份数据库文件的接口,通过databasePath指定的备份文件名(支持路径)备份当前数据库文件。通过返回值判断是否备份成功,成功时返回0,失败时则返回相应的错误码。 - - 表13 数据库备份API - - | 类名 | 接口名 | 描述 | - | ---- | ---- | ---- | - | RdbStore | int Backup(const std::string databasePath, const std::vector<uint8_t> destEncryptKey) | 备份数据库文件。
  • databasePath:指定的备份文件名。
  • destEncryptKey:数据库的加密密钥。注意:当前只支持非加密数据库的备份。
| - -- 恢复 - - 关系型数据库提供了恢复数据库文件的接口,通过backupPath指定的备份文件名(支持路径)恢复当前数据库文件。通过返回值判断是否恢复成功,成功时返回0,失败时则返回相应的错误码。 - - 表14 数据库恢复API - - | 类名 | 接口名 | 描述 | - | ---- | ---- | ---- | - | RdbStore | int Restore(const std::string backupPath, const std::vector<uint8_t> &newKey) | 恢复数据库文件。
  • backupPath:指定的备份文件名。
  • newKey:数据库的加密密钥。注意:当前只支持非加密数据库的恢复。
| - -### 事务 - - 事务(Transaction)是一个对数据库执行工作单元。通过返回值判断事务是否成功,成功时返回0,失败时则返回相应的错误码。 - - 表15 事务API - - | 类名 | 接口名 | 描述 | - | ---- | ---- | ---- | - | RdbStore | int BeginTransaction() | 开启一个事务。 | - | RdbStore | int Commit() | 保存更改。 | - | RdbStore | int RollBack() | 回滚所做的更改。 | - -## 约束与限制 - -无。 - -## 开发步骤 - -1. 创建数据库。 - - a. 配置数据库相关信息,包括数据库的名称、存储模式、是否为只读模式等。 - - b. 初始化数据库表结构和相关数据。 - - c. 创建数据库。 - - 示例代码如下: - ```c++ - const std::string DATABASE_NAME = RDB_TEST_PATH + "RdbStoreTest.db"; - const std::string CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, salary REAL, blobType BLOB)"; - - class OpenCallback : public RdbOpenCallback { - public: - int OnCreate(RdbStore &rdbStore) override; - int OnUpgrade(RdbStore &rdbStore, int oldVersion, int newVersion) override; - }; - - int OpenCallback::OnCreate(RdbStore &store) - { - return store.ExecuteSql(CREATE_TABLE_TEST); - } - - RdbStoreConfig config(DATABASE_NAME); - OpenCallback callback; - - std::shared_ptr store = RdbHelper::GetRdbStore(config, 1, callback, 0); - ``` - -2. 插入数据。 - - a. 构造要插入的数据,以ValuesBucket形式存储。 - - b. 调用关系型数据库提供的插入接口。 - - c. 创建数据库。 - - 示例代码如下: - ```c++ - ValuesBucket values; - - values.PutInt("id", 1); - values.PutString("name", std::string("Tom")); - values.PutInt("age", 18); - values.PutDouble("salary", 100.5); - values.PutBlob("blobType", std::vector{ 1, 2, 3 }); - store->Insert(id, "test", values); - ``` - -3. 查询数据。 - - a. 构造用于查询的谓词对象,设置查询条件。 - - b. 指定查询返回的数据列。 - - c. 调用查询接口查询数据。 - - d. 调用结果集接口,遍历返回结果。 - - 示例代码如下: - ```c++ - std::vector columns = {"id", "name", "age", "salary"}; - - RdbPredicates predicates("test"); - predicates.EqualTo("age", "25")->OrderByAsc("salary"); - std::unique_ptr resultSet = store->Query(predicates, columns) - resultSet.goToNextRow(); - ``` - -4. 设置分布式同步表 - - a. 调用接口设置分布式同步表。 - - 示例代码如下: - - ```c++ - store->SetDistributedTables("test"); - ``` - -5. 分布式数据同步 - - a. 定义同步模式和阻塞状态。 - - b. 构造用于同步分布式表的谓词对象,指定组网内的远程设备。 - - c. 调用接口同步数据。 - - 示例代码如下: - - ```c++ - SyncOption option; - option.mode = PUSH; - option.isBlock = true; - AbsRdbPredicates predicate("test"); - predicate.InAllDevices(); - store->Sync(option, predicate, [](const SyncResult& result) { - for (const auto& [device, status] : result) { - LogI("device=%s status=%d", device.c_str(), status); - } - }); - ``` - -6. 分布式数据订阅 - - a. 重写数据更改观察者OnChange()函数。 - - b. 定义分布式数据订阅类型。 - - c. 调用接口实现分布式数据订阅,或取消订阅。 - - 示例代码如下: - - ```c++ - class MyObserver : public RdbStoreObserver { - public: - void OnChange(const std::vector& devices) override { - for (const auto& device : devices) { - LOGI("device=%s data change", device.c_str()); - } - } - }; - - SubscribeOption option; - option.mode = SubscribeMode::REMOTE; - MyObserver observer; - store->Subscribe(option, &observer); // 分布式数据订阅 - - store->UnSubscribe(option, &observer); // 取消订阅 - ``` - -7. 跨设备查询 - - a. 根据本地表名获取指定远程设备的分布式表名。 - - b. 根据指定SQL语句查询数据库中的数据。 - - 示例代码如下: - ```c++ - std::string tableName = store->ObtainDistributedTableName("123456789abcd", "test"); - auto resultSet = store->QuerySql("SELECT * from ?;", tableName); - ``` - -8. 数据库的备份和恢复 - - a. 根据指定的数据库备份文件名备份当前数据库。 - - b. 根据指定的数据库备份文件恢复当前数据库。 - - 示例代码如下: - ```c++ - std::string backupName = "backup.db"; // 指定数据库的备份文件名 - std::vector key; // 数据库的加密密钥 - int errno = store->Backup(backupName, key); - errno = store->Restore(backupName, key); - ``` \ No newline at end of file diff --git a/zh-cn/device-dev/subsystems/subsys-data-relational-database-overview.md b/zh-cn/device-dev/subsystems/subsys-data-relational-database-overview.md deleted file mode 100644 index 90ef4efc82a04fd03a0083f9ecc92c54f3fec8f6..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-data-relational-database-overview.md +++ /dev/null @@ -1,39 +0,0 @@ -# 关系型数据库概述 - -关系型数据库(Relational Database,RDB)是一种基于关系模型来管理数据的数据库。OpenHarmony关系型数据库基于SQLite组件提供了一套完整的对本地数据库进行管理的机制,对外提供了一系列的增、删、改、查等接口,也可以直接运行用户输入的SQL语句来满足复杂的场景需要。 - -## 基本概念 - -- 关系型数据库 - - 基于关系模型来管理数据的数据库,以行和列的形式存储数据。 - -- 谓词 - - 数据库中用来代表数据实体的性质、特征或者数据实体之间关系的词项,主要用来定义数据库的操作条件。 - -- 结果集 - - 指用户查询之后的结果集合,可以对数据进行访问。结果集提供了灵活的数据访问方式,可以更方便的拿到用户想要的数据。 - -- SQLite数据库 - - 一款遵守ACID的轻型开源关系型数据库管理系统。 - -## 运作机制 -OpenHarmony关系型数据库对外提供通用的操作接口(即Rdb Store接口),底层使用第三方开源组件SQLite作为持久化存储引擎,支持SQLite具有的所有数据库特性。 - -**图1** 关系型数据库运作机制 - -![](figures/zh-cn_image_0000001115980740.png) - -## 默认配置 -- 如果不指定数据库的日志模式,那么系统默认日志方式是WAL(Write Ahead Log)模式。 -- 如果不指定数据库的落盘模式,那么系统默认落盘方式是FULL模式。 -- OpenHarmony数据库使用的共享内存默认大小是8MB,单次查询使用的共享内存默认大小是2MB。 - -## 约束与限制 -- 数据库中连接池的最大数量是4个,用以管理用户的读操作。 -- 为保证数据的准确性,数据库同一时间只能支持一个写操作。 - - diff --git a/zh-cn/device-dev/subsystems/subsys-data-storage-guide.md b/zh-cn/device-dev/subsystems/subsys-data-storage-guide.md deleted file mode 100755 index edadbed8f145320327af3d3f1cdb158df1428ae4..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-data-storage-guide.md +++ /dev/null @@ -1,193 +0,0 @@ -# 轻量级数据存储开发指导 - -## 场景介绍 - -轻量级数据存储功能通常用于保存应用的一些常用配置信息,并不适合需要存储大量数据和频繁改变数据的场景。应用的数据保存在文件中,这些文件可以持久化地存储在设备上。需要注意的是,应用访问的实例包含文件所有数据,这些数据会一直加载在设备的内存中,直到应用主动从内存中将其移除前,应用可以通过Preferences的API进行数据操作。 - -## 接口说明 - -轻量级存储为应用提供key-value键值型的文件数据处理能力,支持应用对数据进行轻量级存储及查询。数据存储形式为键值对,键的类型为字符串型,值的存储数据类型包括字符串型、布尔型、整数型、长整型、浮点型、双精度类型和字符串数组。 - -**创建存储实例** - -读取指定文件,将数据加载到Preferences实例,即可创建一个存储实例,用于数据操作。 - -**表 1** 轻量级数据存储实例创建接口 - -| 类名 | 方法名 | 描述 | -| --- | ----- | ----| -| PreferencesHelper | static std::shared_ptr GetPreferences(const std::string &path, int &errCode); | path:应用程序内部数据存储路径。
errCode:错误码。
返回值:轻量级存储实例。 | - -**存入数据** - -通过Put系列方法,可以增加或修改Preferences实例中的数据。 - -**表 2** 轻量级偏好数据库存入接口 - -| 类名 | 方法名 | 描述 | -| --- | ----- | ----| -| Preferences | int PutInt(const std::string &key, int value); | key:将要存储的key名称,不能为空。
value:将要存储的value。
返回值:错误码。 | -| Preferences | int PutString(const std::string &key, const std::string &value); | key:将要存储的key名称,不能为空。
value:将要存储的value。
返回值:错误码。 | -| Preferences | int PutBool(const std::string &key, bool value); | key:将要存储的key名称,不能为空。
value:将要存储的value。
返回值:错误码。 | -| Preferences | int PutLong(const std::string &key, int64_t value); | key:将要存储的key名称,不能为空。
value:将要存储的value。
返回值:错误码。 | -| Preferences | int PutFloat(const std::string &key, float value); | key:将要存储的key名称,不能为空。
value:将要存储的value。
返回值:错误码。 | -| Preferences | int PutDouble(const std::string &key, double value); | key:将要存储的key名称,不能为空。
value:将要存储的value。
返回值:错误码。 | -| Preferences | int PutStringSet(const std::string &key, const std::set\ &value); | key:将要存储的key名称,不能为空。
value:将要存储的。
返回值:错误码。 | - -**读取数据** - -通过调用Get系列方法,可以读取Preferences中的数据。 - -**表 3** 轻量级数据读取接口 - -| 类名 | 方法名 | 描述 | -| --- | ----- | ----| -| Preferences | int GetInt(const std::string &key, const int defValue = 0); | key:要获取的存储key名称,不能为空。
defValue:若获取失败或value不存在返回此默认值。
返回值:value。 | -| Preferences | std::string GetString(const std::string &key, const std::string &defValue = {}); | key:要获取的存储key名称,不能为空。
defValue:若获取失败或value不存在返回此默认值。
返回值:value。 | -| Preferences | bool GetBool(const std::string &key, const bool defValue = false); | key:要获取的存储key名称,不能为空。
defValue:若获取失败或value不存在返回此默认值。
返回值:value。 | -| Preferences | float GetFloat(const std::string &key, const float defValue = 0); | key:要获取的存储key名称,不能为空。
defValue:若获取失败或value不存在返回此默认值。
返回值:value。 | -| Preferences | double GetDouble(const std::string &key, const double defValue = 0); | key:要获取的存储key名称,不能为空。
defValue:若获取失败或value不存在返回此默认值。
返回值:value。 | -| Preferences | int64_t GetLong(const std::string &key, const int64_t defValue = 0); | key:要获取的存储key名称,不能为空。
defValue:若获取失败或value不存在返回此默认值。
返回值:value。 | -| Preferences | std::set\ GetStringSet(const std::string &key, const std::set\ &defValue = {}); | key:要获取的存储key名称,不能为空。
defValue:若获取失败或value不存在返回此默认值。
返回值:value。 | - -**数据持久化** - -通过执行Flush()或者FlushSync()方法,应用可以将缓存的数据再次写回文本文件中进行持久化存储。 - -**表 5** 轻量级数据数据持久化接口 - -| 类名 | 方法名 | 描述 | -| --- | ----- | ----| -| Preferences | void Flush(); | 将Preferences实例通过异步线程回写入文件中。 | -| Preferences | int FlushSync(); | 将Preferences实例通过同步线程回写入文件中,并返回错误码。 | - -**订阅数据变化** - -订阅数据变化需要指定PreferencesObserver作为回调方法。订阅的key的值发生变更后,当执行flush方法时,PreferencesObserver被回调。 - -**表 5** 轻量级数据变化订阅接口 - -| 类名 | 方法名 | 描述 | -| --- | ----- | ----| -| Preferences | void RegisterObserver(std::shared_ptr preferencesObserver); | preferencesObserver:需要订阅的回调对象实例。 | -| Preferences | void UnRegisterObserver(std::shared_ptr preferencesObserver); | preferencesObserver:需要注销订阅的回调对象实例。 | - -**删除数据文件** - -通过调用以下两种接口,可以删除数据实例或对应的文件。 - -**表 6** 轻量级数据存储删除接口 - -| 类名 | 方法名 | 描述 | -| --- | ----- | ----| -| PreferencesHelper | int DeletePreferences(const std::string &path); | 将Preferences实例从内存中移除,同时删除其在设备上的持久化文件。path:应用程序内部数据存储路径。
返回值:错误码。 | -| PreferencesHelper | int RemovePreferencesFromCache(const std::string &path); | 仅将Preferences实例从内存中移除。path:应用程序内部数据存储路径。
返回值:错误码。 | - -## 开发步骤 - -1. 准备工作,引入preferences以及相关的头文件到开发环境。 - - ``` C++ - 头文件路径://distributeddatamgr_appdatamgr/interfaces/innerkits/native_preferences/include - ``` - -2. 获取Preferences实例。 - - 读取指定文件,将数据加载到Preferences实例,用于数据操作。 - - ``` C++ - int errCode = E_OK; - Preferences pref = PreferencesHelper::GetPreferences(PREF_TEST_PATH + "test.xml", errCode); // PREF_TEST_PATH须为应用沙箱路径。 - EXPECT_EQ(errCode, E_OK); - ``` - - -3. 存入数据。 - - 使用Preferences put方法保存数据到缓存的实例中。 - - ```C++ - pref->PutString("test", "remove"); - ``` - -4. 读取数据。 - - 使用Preferences get方法读取数据。 - - ``` C++ - std::string ret = pref->GetString("test", "defaultValue"); - EXPECT_EQ(ret, "remove"); - ``` - - -5. 数据持久化。 - - 应用存入数据到Preferences实例后,可以通过Flush()或者FlushSync()方法将Preferences实例回写到文件中。 - - ```C++ - int err = pref->FlushSync(); - EXPECT_EQ(ret, E_OK); - ``` - -6. 订阅数据变化。 - - 应用订阅数据变化需要指定PreferencesObserver作为回调方法。订阅的key的值发生变更后,当执行flush或者flushSync方法时,PreferencesObserver被触发回调。不再需要PreferencesObserver时请注销。 - - 自定义类,实现PreferencesObserver接口: - ``` C++ - class PreferencesObserverCounter : public PreferencesObserver { - public: - virtual ~PreferencesObserverCounter(); - void OnChange(Preferences &preferences, const std::string &key) override; - - std::atomic_int notifyTimes; - static const std::vector NOTIFY_KEYS_VECTOR; - }; - - PreferencesObserverCounter::~PreferencesObserverCounter() {} - - void PreferencesObserverCounter::OnChange(Preferences &preferences, const std::string &key) - { - for (auto it = NOTIFY_KEYS_VECTOR.cbegin(); it != NOTIFY_KEYS_VECTOR.cend(); it++) { - if (key.compare(*it)) { - notifyTimes++; - break; - } - } - } - - const std::vector 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 }; - ``` - - 订阅数据变化,并触发执行回调方法: - ``` C++ - std::shared_ptr counter = - std::make_shared(); - pref->RegisterObserver(counter); // 注册数据变化的回调。 - - pref->PutString(PreferencesTest::KEY_TEST_STRING_ELEMENT, "test"); - pref->Flush(); // 触发执行counter的onChanged回调方法。 - EXPECT_EQ(static_cast(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(counter.get())->notifyTimes, 2); - - pref->UnRegisterObserver(counter); // 注销注册数据变化的回调。 - ``` - - -7. 删除指定文件。 - - 从使用PreferencesHelper内存中移除指定文件对应的Preferences单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。删除后,数据及文件将不可恢复。 - - ``` C++ - pref = nullptr; - int ret = PreferencesHelper::DeletePreferences("/data/test/test"); - EXPECT_EQ(ret, E_OK); - ``` - diff --git a/zh-cn/device-dev/subsystems/subsys-data-storage-overview.md b/zh-cn/device-dev/subsystems/subsys-data-storage-overview.md deleted file mode 100755 index 67dfa96b86233202ae94f46c0492377fcd87ccb3..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-data-storage-overview.md +++ /dev/null @@ -1,31 +0,0 @@ -# 轻量级数据存储概述 - -轻量级数据存储适用于对Key-Value结构的数据进行存取和持久化操作。应用获取某个轻量级存储对象后,该存储对象中的数据将会被缓存在内存中,以便应用获得更快的数据存取速度。应用也可以将缓存的数据再次写回文本文件中进行持久化存储,由于文件读写将产生不可避免的系统资源开销,建议应用减少对持久化文件的读写频率。 - -## 基本概念 - -- **Key-Value数据结构** - - 一种键值结构数据类型。Key是不重复的关键字,Value是数据值。 - -- **非关系型数据库** - - 区别于关系数据库,不保证遵循ACID(Atomic、Consistency、Isolation及Durability)特性,不采用关系模型来组织数据,数据之间无关系。 - - -## 运作机制 - -1. 应用通过指定Preferences文件将其中的数据加载到Preferences实例,系统会通过静态容器将该实例存储在内存中,同一应用或进程中每个文件仅存在一个Preferences实例,直到应用主动从内存中移除该实例或者删除该Preferences文件。 -2. 应用获取到Preferences文件对应的实例后,可以从Preferences实例中读取数据,或者将数据存入Preferences实例中。通过调用flush或者flushSync方法可以将Preferences实例中的数据回写到文件里。 - -**图 1** 轻量级数据存储运作机制
- - -![](figures/zh-cn_image_0000001192123772.png) - -## 约束与限制 - -- 因Preferences实例会加载到内存中,建议存储的数据不超过一万条,并及时清理不再使用的实例,以便减少非内存开销。 -- 数据中的key为string类型,要求非空且字符长度不超过80个。 -- 当数据中的value为string类型时,允许为空,字符长度不超过8192个。 - diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-faultlogger.md b/zh-cn/device-dev/subsystems/subsys-dfx-faultlogger.md index b290303ffdac4b6f3fb877e0436e793f7f365f4a..06e91d7b7f0a19ee6418efcce03cfd9222bc3a15 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-faultlogger.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-faultlogger.md @@ -18,15 +18,15 @@ FaultLogger承载OpenHarmony系统上的故障记录功能,按照服务对象 **图1** 进程崩溃处理流程图 -![zh-cn_image_0000001261812333](figures/zh-cn_image_0000001261812333.png) +![zh-cn_image_0000001261812333](figures/zh-cn_image_0000001261812334.png) -1. 进程安装信号处理器后,通过DFX_SignalHandler函数检测并响应进程崩溃异常信号; +1. 进程安装信号处理器后,通过DFX_SignalHandler函数检测并响应由Kernel抛出的进程崩溃异常信号; 2. SignalHandler检测到异常信号后Fork出子进程,并运行ProcessDump程序开始dump崩溃进程和线程的堆栈信息; -3. ProcessDump程序在读取异常堆栈信息后将日志写入到Faultloggerd中的临时存储目录,进而生成完整的崩溃日志; +3. ProcessDump程序向Faultloggerd服务申请用于存储故障日志的文件句柄,在读取到异常堆栈信息后写入到该文件中,进而生成完整的崩溃日志; -4. Faultloggerd根据需要将故障通过Hiview提供的AddFaultLog()接口进行上报,hiview将处理生成简化的崩溃日志,并上报Hisysevent事件。 +4. ProcessDump完成崩溃日志收集后,根据需要将故障通过Hiview提供的AddFaultLog()接口进行上报,hiview将处理生成简化的崩溃日志,并上报Hisysevent事件。 基于这样的设计,在资源有限的小型系统上可只部署Faultloggerd,也依然可以获取用于定位崩溃问题的日志。 @@ -39,14 +39,14 @@ Faultloggerd意在为开发者在开发测试过程中遇到的崩溃或卡死 **表1** Faultloggerd模块应用场景 -| 场景描述 | 使用工具 | 使用方式 | +| 场景描述 | 使用工具 | 使用方式 | | -------- | -------- | -------- | -| 了解函数的调用顺序 | DumpCatcher API | 参见:[使用DumpCatcher获取调用栈](#使用dumpcatcher获取调用栈) | -| 应用卡死/CPU占用高 | ProcessDump | 参见:[使用ProcessDump获取调用栈](#使用processdump获取调用栈) | -| 进程未处理信号崩溃 | 崩溃日志和addr2line工具 | 参见:[基于崩溃日志对问题进行定位](#基于崩溃日志对问题进行定位) | +| 了解函数的调用顺序 | DumpCatcher API | 参见:[使用DumpCatcher接口获取调用栈](#使用dumpcatcher接口获取调用栈) | +| 应用卡死/CPU占用高 | DumpCatcher Command Tool | 参见:[使用DumpCatcher命令获取调用栈](#使用dumpcatcher命令获取调用栈) | +| 崩溃问题定位 | 崩溃日志和addr2line工具 | 参见:[基于崩溃日志定位问题](#基于崩溃日志定位问题) | -## 使用DumpCatcher获取调用栈 +## 使用DumpCatcher接口获取调用栈 ### 接口说明 @@ -55,57 +55,70 @@ DumpCatcher可以抓取OpenHarmony指定进程(线程)的调用栈。 **表2** DumpCatcher接口说明 -| 类 | 方法 | 描述 | +| 类 | 方法 | 描述 | | -------- | -------- | -------- | -| DfxDumpCatcher | bool DumpCatch(const int pid, const int tid, std::string& msg) |   接口返回值:
- true:回栈成功,回栈信息存储在msg字符串对象中;
- false:回栈失败。
  输入参数:
- pid:目标进程号;
- tid:目标线程号,如果需要回栈进程中的所有线程,则tid设定为0;
  输出参数:
- msg:如果回栈成功,则通过msg返回调用栈信息。 | +| DfxDumpCatcher | bool DumpCatch(const int pid, const int tid, std::string& msg) | 接口返回值:
- true:回栈成功,回栈信息存储在msg字符串对象中;
- false:回栈失败。
输入参数:
- pid:目标进程号;
- tid:目标线程号,如果需要回栈进程中的所有线程,则tid设定为0;
输出参数:
- msg:如果回栈成功,则通过msg返回调用栈信息。 | +| DfxDumpCatcher | bool DumpCatchMix(const int pid, const int tid, std::string& msg) | 接口返回值:
- true:回栈成功,回栈信息存储在msg字符串对象中;
- false:回栈失败。
输入参数:
- pid:目标进程号;
- tid:目标线程号,如果需要回栈进程中的所有线程,则tid设定为0;
输出参数:
- msg:如果回栈成功,则通过msg返回混合栈信息。 | +| DfxDumpCatcher | bool DumpCatchFd(const int pid, const int tid, std::string& msg, int fd) | 接口返回值:
- true:回栈成功,回栈信息存储在msg字符串对象中;
- false:回栈失败。
输入参数:
- pid:目标进程号;
- tid:目标线程号,如果需要回栈进程中的所有线程,则tid设定为0;
- fd:指定写入的文件句柄号;
输出参数:
- msg:如果回栈成功,则通过msg返回调用栈信息。 | +| DfxDumpCatcher | bool DumpCatchMultiPid(const std::vector\ pidV, std::string& msg) | 接口返回值:
- true:回栈成功,回栈信息存储在msg字符串对象中;
- false:回栈失败。
输入参数:
- pidV:目标进程号列表;
输出参数:
- msg:如果回栈成功,则通过msg返回调用栈信息。 | > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 当调用此接口的进程id与目标pid不一致时需要调用者是管理员(system,root)用户。当抓取非本用户组进程调用栈时还需具备读取对方/proc/pid/maps及ptrace到对方进程的权限。 +> 当调用此接口的进程id与目标pid不一致时需要调用者是管理员(system,root)用户。 ### 开发实例 -系统应用开发者可以用DumpCatcher在自己的应用中获取指定进程(线程)的调用栈。下文以dumpcatcherdemo模块使用DumpCatcher接口获取调用栈作为实例进行讲解。 +系统应用开发者可以用DumpCatcher在自己的应用中获取指定进程(线程)的调用栈。下文以dumpcatcherdemo模块使用DumpCatcher基础接口获取调用栈作为实例进行讲解。 1. 编译构建文件添加dumpcatcher依赖:以/base/hiviewdfx/faultloggerd/example/BUILD.gn为例,在include_dirs中添加DfxDumpCatcher头文件路径,并在deps中添加“//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher”模块依赖。 - + ``` import("//base/hiviewdfx/faultloggerd/faultloggerd.gni") import("//build/ohos.gni") - + config("dumpcatcherdemo_config") { visibility = [ ":*" ] - + include_dirs = [ ".", "//utils/native/base/include", "//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher/include/", # 添加dumpcatcher头文件路径 ] } - - ohos_executable("dumpcatcherdemo") { sources = [ "dump_catcher_demo.cpp" ] configs = [ ":dumpcatcherdemo_config" ] deps = [ "//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher", # 添加dumpcathcer模块依赖 "//utils/native/base:utils", ] external_deps = [ "hilog_native:libhilog" ] install_enable = true part_name = "faultloggerd" subsystem_name = "hiviewdfx" + + ohos_executable("dumpcatcherdemo") { + sources = [ "dump_catcher_demo.cpp" ] + configs = [ ":dumpcatcherdemo_config" ] + deps = [ + "//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher", # 添加dumpcathcer模块依赖 + "//utils/native/base:utils", + ] + external_deps = [ "hilog_native:libhilog" ] + install_enable = true + part_name = "faultloggerd" + subsystem_name = "hiviewdfx" } ``` 2. 头文件定义用到的函数:以/base/hiviewdfx/faultloggerd/example/dump_catcher_demo.h为例,本样例代码中,通过调用栈深度测试的测试函数来构造一个指定深度的调用栈。 - + ``` #ifndef DUMP_CATCHER_DEMO_H #define DUMP_CATCHER_DEMO_H - + #include - + #define NOINLINE __attribute__((noinline)) - + // 定义该宏函数用于自动生成函数调用链 #define GEN_TEST_FUNCTION(FuncNumA, FuncNumB) \ __attribute__((noinline)) int TestFunc##FuncNumA() \ { \ return TestFunc##FuncNumB(); \ } - + // 调用栈深度测试的测试函数 int TestFunc0(void); int TestFunc1(void); @@ -118,22 +131,22 @@ DumpCatcher可以抓取OpenHarmony指定进程(线程)的调用栈。 int TestFunc8(void); int TestFunc9(void); int TestFunc10(void); - + #endif // DUMP_CATCHER_DEMO_H ``` 3. 在源文件中调用DumpCatch接口:以/base/hiviewdfx/faultloggerd/example/dump_catcher_demo.cpp为例,引用dfx_dump_catcher.h头文件,声明DfxDumpCatcher对象,通过宏函数构造函数调用链,并最后调用DumpCatch接口方法,传入需要抓取调用栈的进程号、线程号。 - + ``` #include "dump_catcher_demo.h" - + #include #include #include // dfx_dump_catcher.h头文件引入 #include "dfx_dump_catcher.h" using namespace std; - + NOINLINE int TestFunc10(void) { OHOS::HiviewDFX::DfxDumpCatcher dumplog; @@ -144,7 +157,7 @@ DumpCatcher可以抓取OpenHarmony指定进程(线程)的调用栈。 } return 0; } - + // 通过宏函数自动生成函数调用链 GEN_TEST_FUNCTION(0, 1) GEN_TEST_FUNCTION(1, 2) @@ -156,7 +169,7 @@ DumpCatcher可以抓取OpenHarmony指定进程(线程)的调用栈。 GEN_TEST_FUNCTION(7, 8) GEN_TEST_FUNCTION(8, 9) GEN_TEST_FUNCTION(9, 10) - + int main(int argc, char *argv[]) { TestFunc0(); @@ -165,55 +178,57 @@ DumpCatcher可以抓取OpenHarmony指定进程(线程)的调用栈。 ``` -## 使用ProcessDump获取调用栈 +## 使用DumpCatcher命令获取调用栈 ### 工具说明 -ProcessDump是一个抓取调用栈的命令行工具,在OpenHarmony系统中可直接使用,该工具通过-p、-t参数指定进程和线程,命令执行后在命令行窗口打印指定进程的线程栈信息。 +DumpCatcher Command Tool是一个抓取调用栈的命令行工具,在OpenHarmony系统中可直接使用,该工具通过-p、-t参数指定进程和线程,命令执行后在命令行窗口打印指定进程的线程栈信息。还可通过添加-m参数来抓取应用进程的JS Native混合栈。 - **表3** ProcessDump命令行工具使用说明 + **表3** DumpCatcher Command Tool使用说明 -| 工具名称 | 命令行工具路径 | 执行命令 | 描述 | +| 工具名称 | 命令行工具路径 | 执行命令 | 描述 | | -------- | -------- | -------- | -------- | -| processdump | /system/bin | - processdump -p [pid]
- processdump -p [pid] -t [tid] | **参数说明:**
- -p [pid]:打印指定进程下面的所有线程栈信息。
- -p [pid] -t [tid]:打印指定进程下面的指定线程信息。
**返回值说明:**
如果栈信息解析成功,则将信息显示到标准输出;失败则打印错误信息。 | - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 此工具需要在root下使用,或调用者有权限ptrace到目标进程,并读取目标进程的smaps。 +| dumpcatcher | /system/bin | - dumpcatcher -p [pid]
- dumpcatcher -p [pid] -t [tid]
- dumpcatcher -m -p [pid]
- dumpcatcher -m -p [pid] -t [tid]
| **参数说明:**
- -p [pid]:打印指定进程下面的所有线程栈信息。
- -p [pid] -t [tid]:打印指定进程下面的指定线程信息。
- -m -p [pid]:打印指定进程下面的所有线程混合栈信息。
- -m -p [pid] -t [tid]:打印指定进程下面的指定线程混合栈信息。
**返回值说明:**
如果栈信息解析成功,则将信息显示到标准输出;失败则打印错误信息。 | ### 使用实例 -通过processdump命令行工具打印hiview进程的调用栈。 +通过dumpcatcher命令打印hiview进程的调用栈。 + - ``` -# ps -A | grep hiview - 114 ? 00:00:00 hiview -# processdump -p 114 -t 114 -Tid:114, Name:hiview -#00 pc 0000000000089824(00000000b6f44824) /system/lib/ld-musl-arm.so.1(ioctl+68) -#01 pc 000000000002a709(00000000b6c56709) /system/lib/libipc_core.z.so(_ZN4OHOS15BinderConnector11WriteBinderEmPv+16) -#02 pc 000000000002ba75(00000000b6c57a75) /system/lib/libipc_core.z.so(_ZN4OHOS13BinderInvoker18TransactWithDriverEb+224) -#03 pc 000000000002bb37(00000000b6c57b37) /system/lib/libipc_core.z.so(_ZN4OHOS13BinderInvoker13StartWorkLoopEv+22) -#04 pc 000000000002c211(00000000b6c58211) /system/lib/libipc_core.z.so(_ZN4OHOS13BinderInvoker10JoinThreadEb+36) -#05 pc 0000000000038d07(00000000004bcd07) /system/bin/hiview(_ZNSt3__h6vectorINS_9sub_matchINS_11__wrap_iterIPKcEEEENS_9allocatorIS6_EEE8__appendEj+596) -#06 pc 0000000000028655(00000000004ac655) /system/bin/hiview -#07 pc 00000000000c2b08(00000000b6f7db08) /system/lib/ld-musl-arm.so.1(__libc_start_main+116) -#08 pc 00000000000285f4(00000000004ac5f4) /system/bin/hiview -#09 pc 0000000000028580(00000000004ac580) /system/bin/hiview +# ps -ef |grep hiview +hiview 240 1 0 17:01:49 ? 00:00:14 hiview +root 1822 1560 7 20:56:36 pts/0 00:00:00 grep hiview +# dumpcatcher -p 240 -t 240 +Result: 0 ( no error ) +Timestamp:2017-08-05 20:56:43.000 +Pid:240 +Uid:1201 +Process name:/system/bin/hiview +Tid:240, Name:hiview +#00 pc 00098f8c /system/lib/ld-musl-arm.so.1(ioctl+68) +#01 pc 0000e2a1 /system/lib/chipset-pub-sdk/libipc_single.z.so +#02 pc 0000ed59 /system/lib/chipset-pub-sdk/libipc_single.z.so +#03 pc 0000ee1f /system/lib/chipset-pub-sdk/libipc_single.z.so +#04 pc 0000f745 /system/lib/chipset-pub-sdk/libipc_single.z.so +#05 pc 00037577 /system/bin/hiview +#06 pc 00025973 /system/bin/hiview +#07 pc 000db210 /system/lib/ld-musl-arm.so.1 +#08 pc 000258d8 /system/bin/hiview +#09 pc 0002587c /system/bin/hiview ``` -## 基于崩溃日志对问题进行定位 +## 基于崩溃日志定位问题 开发者可以通过faultloggerd生成的崩溃堆栈日志进行问题定位。本章节将主要介绍如何利用addr2line工具进行崩溃问题定位。 1. 程序自崩溃或构造崩溃。 例如将如下代码植入自己的代码中,调用触发一个无效内存访问故障(SIGSEGV)。 - + ``` NOINLINE int TriggerSegmentFaultException() { @@ -226,42 +241,43 @@ Tid:114, Name:hiview ``` 2. 获取崩溃函数调用栈日志。 - 因为存在未处理的异常,进程会在 /data/log/faultlog/temp路径下生成临时的日志文件,其命名规则为: + 因为存在未处理的异常,进程会在/data/log/faultlog/temp路径下生成临时的日志文件,其命名规则为: + - ``` cppcrash-pid-time ``` 获取其生成的调用栈如下: - + ``` + Timestamp:2017-08-05 17:35:03.000 Pid:816 Uid:0 - Process name:./crasher + Process name:./crasher_c Reason:Signal:SIGSEGV(SEGV_ACCERR)@0x0042d33d Fault thread Info: Tid:816, Name:crasher + #00 pc 0000332c /data/crasher(TriggerSegmentFaultException+15)(8bc37ceb8d6169e919d178fdc7f5449e) + #01 pc 000035c7 /data/crasher(ParseAndDoCrash+277)(8bc37ceb8d6169e919d178fdc7f5449e) + #02 pc 00003689 /data/crasher(main+39)(8bc37ceb8d6169e919d178fdc7f5449e) + #03 pc 000c3b08 /system/lib/ld-musl-arm.so.1(__libc_start_main+116) + #04 pc 000032f8 /data/crasher(_start_c+112)(8bc37ceb8d6169e919d178fdc7f5449e) + #05 pc 00003284 /data/crasher(_start+32)(8bc37ceb8d6169e919d178fdc7f5449e) + Registers: r0:0042d33d r1:0000000b r2:1725d4c4 r3:b6f9fa84 r4:bec97e69 r5:b6fc0268 r6:0042d661 r7:bec97d60 r8:00000000 r9:00000000 r10:00000000 fp:bec97d20 ip:00000020 sp:bec97cd0 lr:b6f9fae4 pc:0042d32c - - #00 pc 000000000000332c(000000000042d32c) /data/crasher(TriggerSegmentFaultException+15) - #01 pc 00000000000035c7(000000000042d5c7) /data/crasher(ParseAndDoCrash+277) - #02 pc 0000000000003689(000000000042d689) /data/crasher(main+39) - #03 pc 00000000000c3b08(00000000b6fbbb08) /system/lib/ld-musl-arm.so.1(__libc_start_main+116) - #04 pc 00000000000032f8(000000000042d2f8) /data/crasher(_start_c+112) - #05 pc 0000000000003284(000000000042d284) /data/crasher(_start+32) ``` 3. 利用addr2line工具进行调用栈分析。 使用addr2line工具根据偏移地址解析行号: - + ``` - root:~/OpenHarmony/out/hi3516dv300/exe.unstripped/hiviewdfx/faultloggerd$ addr2line -e crasher 000332c + root:~/OpenHarmony/out/hi3516dv300/exe.unstripped/hiviewdfx/faultloggerd$ addr2line -e crasher 0000332c base/hiviewdfx/faultloggerd/tools/crasher/dfx_crasher.c:57 ``` diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hicollie.md b/zh-cn/device-dev/subsystems/subsys-dfx-hicollie.md index fa0a13a42b766da47c2071970e7613576099be21..b3c51302cea94d9360ec3877828091e1059790fc 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hicollie.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hicollie.md @@ -8,45 +8,28 @@ HiCollie提供了软件看门狗功能。针对系统服务死锁、应用主线 ## 接口说明 - **表1** C++接口功能描述表 + **表1** XCollieChecker接口 -| 所属类 | 接口定义 | 描述 | -| -------- | -------- | -------- | -| XCollieChecker类接口 | virtual void CheckBlock() | 接口功能:卡死检测回调函数。
输入参数:无。
输出参数:无。
返回值:无。 | -| XCollieChecker类接口 | virtual void CheckThreadBlock() | 接口功能:线程卡死检测回调函数。
输入参数:无。
输出参数:无。
返回值:无。 | -| XCollie类接口 | void RegisterXCollieChecker(const sptr&lt;XCollieChecker&gt; &checker, unsigned int type) | 接口功能:线程卡死检测回调函数注册。
输入参数:
- checker:XCollieChecker实例指针。
- type:卡死检测类型,取值设置为XCOLLIE_THREAD。
输出参数:无。
返回值:无。 | -| XCollie类接口 | int SetTimer(const std::string &name, unsigned int timeout, std::function&lt;void (void _)&gt; func, void _arg, unsigned int flag) | 接口功能:添加定时器。
输入参数:
- name:定时器名称。
- timeout:超时时间,单位为秒。
- func:超时回调函数。
- arg:超时回调函数参数指针。
- flag:定时器操作类型。
  XCOLLIE_FLAG_DEFAULT  // 其他三个选项功能之和
  XCOLLIE_FLAG_NOOP // 仅调用超时回调函数
  XCOLLIE_FLAG_LOG //  生成超时故障日志
  XCOLLIE_FLAG_RECOVERY //  进程退出
输出参数:无。
返回值:成功返回定时器标识,失败返回-1。 | -| XCollie类接口 | bool UpdateTimer(int id, unsigned int timeout) | 接口功能:更新定时器。
输入参数:
- id:定时器标识。
- timeout:超时时间,单位为秒。
输出参数:无。
返回值:成功返回true,失败返回false。 | -| XCollie类接口 | void CancelTimer(int id) | 接口功能:取消定时器。
输入参数:定时器标识。
输出参数:无。
返回值:无。 | +| 接口名称 | 描述 | +| -------- | -------- | +| virtual void CheckBlock() | 接口功能:卡死检测回调函数。
输入参数:无。
输出参数:无。
返回值:无。 | +| virtual void CheckThreadBlock() | 接口功能:线程卡死检测回调函数。
输入参数:无。
输出参数:无。
返回值:无。 | -## 效果 + **表2** XCollie接口 -日志打印: - - -``` -timeout: TimeoutTimer start at 1611040305 to check 1s ago - -----------StacktraceCatcher CurrentTime:2021-01-19 15:11:45 Unexecuted(-1)(LogType:Stacktrace Pid:27689 Process:XCollieTimeoutModuleTest)---------- - - ------ pid 27689 at 2021-01-19 15:11:45 ----- -Cmd line: ./XCollieTimeoutModuleTest -ABI: 'arm64' - -"XCollieTimeoutM" sysTid=27689 - #01 pc 00000000000174cc /data/test/XCollieTimeoutModuleTest -``` +| 接口名称 | 描述 | +| -------- | -------- | +| void RegisterXCollieChecker(const sptr<XCollieChecker> &checker, unsigned int type) | 接口功能:线程卡死检测回调函数注册。
输入参数:
- **checker**:XCollieChecker实例指针。
- **type**:卡死检测类型,取值设置为**XCOLLIE_THREAD**。
输出参数:无。
返回值:无。 | +| int SetTimer(const std::string &name, unsigned int timeout, std::function<void(void*)> func, void *arg, unsigned int flag) | 接口功能:添加定时器。
输入参数:
- **name**:定时器名称。
- **timeout**:超时时间,单位为秒。
- **func**:超时回调函数。
- **arg**:超时回调函数参数指针。
- **flag**:定时器操作类型。
XCOLLIE_FLAG_DEFAULT:其他三个选项功能之和
XCOLLIE_FLAG_NOOP:仅调用超时回调函数
XCOLLIE_FLAG_LOG:生成超时故障日志
XCOLLIE_FLAG_RECOVERY:进程退出
输出参数:无。
返回值:成功返回定时器标识,失败返回 **-1**。 | +| bool UpdateTimer(int id, unsigned int timeout) | 接口功能:更新定时器。
输入参数:
- **id**:定时器标识。
- **timeout**:超时时间,单位为秒。
输出参数:无。
返回值:成功返回**true**,失败返回**false**。 | +| void CancelTimer(int id) | 接口功能:取消定时器。
输入参数:
- **id**:定时器标识。
输出参数:无。
返回值:无。 | ## 开发实例 -### C++接口开发实例 - - -### 线程卡死监控 +### 线程卡死监控开发实例 线程卡死监控功能需要开发者实现两个卡死检测回调函数,XCollieChecker类的CheckBlock和CheckThreadBlock接口函数。实现了该回调函数之后,开发者还需要通过XCollie类的RegisterXCollieChecker函数,将该回调函数的类实例成功注册。卡死监控线程会定时执行全部已成功注册的回调函数,检查线程逻辑完成标志位,判定已经成功注册的线程逻辑是否被卡死。 @@ -59,7 +42,7 @@ ABI: 'arm64' 在业务代码中使用: - + ``` void MyXCollieChecker::CheckLock() { @@ -78,13 +61,13 @@ ABI: 'arm64' ``` 2. 编译设置,在BUILD.gn里增加子系统SDK依赖: - + ``` external_deps = [ "hiviewdfx:libxcollie" ] ``` -### 超时监控 +### 超时监控开发实例 单个进程通过SetTimer接口函数添加定时器最多可以设置128个,超过上限则添加定时器操作会失败。 @@ -96,7 +79,7 @@ ABI: 'arm64' ``` 在业务代码中使用(添加/更新/取消): - + ``` std::function callback = [](void *args) { @@ -112,7 +95,7 @@ ABI: 'arm64' ``` 2. 编译设置,在BUILD.gn里增加子系统SDK依赖: - + ``` external_deps = [ "hiviewdfx:libxcollie" ] ``` diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md b/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md index 5128f267e6f92b73f2dd768482a36f6855ee62ef..7112238681fcb2a2ac40c4e8892f5f824621eb22 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hidumper.md @@ -1,14 +1,11 @@ -# HiDumper开发指导 +# HiDumper概述 -## 概述 - - -### 功能简介 +## 功能简介 HiDumper是OpenHarmony为开发、测试人员、IDE工具提供的系统信息获取工具,帮助开发者分析、定位问题。本章节内容适用于标准系统。 -### 源码目录说明 +## 源码目录说明 ``` @@ -34,10 +31,10 @@ HiDumper是OpenHarmony为开发、测试人员、IDE工具提供的系统信息 ``` -## 使用指导 +# HiDumper使用指导 -### 命令参数说明 +## 命令参数说明 **表1** HiDumper命令参数说明 @@ -63,7 +60,7 @@ HiDumper是OpenHarmony为开发、测试人员、IDE工具提供的系统信息 | --zip | 将导出信息压缩到固定文件夹下。 | -### 使用实例 +## 使用实例 HiDumper可以为开发者导出系统当前基本信息,通过这些基本信息可以定位分析问题。给子服务和元能力传递复杂参数时,参数需要加双引号。 diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md index 285a917f36d6e4491b333cb619c81e572acb3497..175b49816ea59a74ed28651cdca2b607fc8f1c7d 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md @@ -6,18 +6,18 @@ ### 功能简介 -组件若有HiSysEvent事件的打点需求,则需要先定义yaml文件并在bundle.json文件中[配置yaml文件的路径](subsys-dfx-hisysevent-logging-config.md#配置yaml文件路径)。OpenHarmony编译框架在编译过程中则会通过python编译脚本解析校验bundle.json文件指定的所有yaml文件。在解析校验之后,编译框架会将这些yaml文件中配置的信息汇总转换成名为hisysevent.def的json文件。最后,将此json文件打包到系统指定路径下,用作HiSysEvent事件落盘的判断依据。 +组件若有HiSysEvent事件的打点需求,则需要先定义yaml文件并在bundle.json文件中[配置yaml文件的路径](subsys-dfx-hisysevent-logging-config.md#验证yaml文件)。OpenHarmony编译框架在编译过程中则会通过python编译脚本解析校验bundle.json文件指定的所有yaml文件。在解析校验之后,编译框架会将这些yaml文件中配置的信息汇总转换成名为hisysevent.def的json文件。最后,将此json文件打包到系统指定路径下,用作HiSysEvent事件落盘的判断依据。 ### 基本概念 在配置HiSysEvent打点之前,开发者应了解以下基本概念: -- 事件领域 用于标识事件所属的领域,在yaml文件中以domain为键值指定,可参考yaml文件样例中的[domain](subsys-dfx-hisysevent-logging-config.md#编写样例)。 +- 事件领域 用于标识事件所属的领域,在yaml文件中以domain为键值指定,可参考yaml文件样例中的[domain](subsys-dfx-hisysevent-logging-config.md#编写yaml文件)。 -- 事件名称 用于指定事件领域包含的所有事件,可参考yaml文件样例中的[EVENT_NAMEA/EVENT_NAMEB](subsys-dfx-hisysevent-logging-config.md#编写样例)。 +- 事件名称 用于指定事件领域包含的所有事件,可参考yaml文件样例中的[EVENT_NAMEA/EVENT_NAMEB](subsys-dfx-hisysevent-logging-config.md#编写yaml文件)。 -- 参数 用于定义某个事件名称包含的所有键值,可参考yaml文件样例中的[__BASE/NAME1/NAME2](subsys-dfx-hisysevent-logging-config.md#编写样例)。 +- 参数 用于定义某个事件名称包含的所有键值,可参考yaml文件样例中的[__BASE/NAME1/NAME2](subsys-dfx-hisysevent-logging-config.md#编写yaml文件)。 ### 约束与限制 @@ -47,10 +47,13 @@ | desc | 字段作用:必选字段,用来对该参数进行描述。
定义规则:
- 至少包含3个字符,最多包含128个字符,字符范围[a-zA-Z0-9 _] | -## 编写yaml文件 +## 开发步骤 -### 编写规则 +### 编写yaml文件 + + +**编写规则** - 事件领域命名规则: - 字母开头,且只能由大写字母/数字/下划线组成; @@ -63,11 +66,11 @@ - 参数命名规则: - 字母开头,且只能由大写字母/数字/下划线组成; - - 字符串长度取值范围1~32; + - 字符串长度取值范围1~48; - 单个事件名称内包含的参数的个数不能超过128个。 -### 编写样例 +**编写样例** - yaml文件样例指定的事件领域名称为MODULEA,该事件领域包含两个事件,名称分别是EVENT_NAMEA和EVENT_NAMEB。 @@ -95,10 +98,10 @@ ``` -## 验证yaml文件 +### 验证yaml文件 -### 配置yaml文件路径 +**配置yaml文件路径** 在bundle.json文件中通过hisysevent_config属性完成yaml文件的路径指定: @@ -149,7 +152,7 @@ > yaml文件可根据实际需求置于组件工程的任意目录下,只要在bundle.json文件指定即可。 -### 编译yaml文件 +**编译yaml文件** - 全量编译: - 全量编译整个系统,会将所有组件配置的yaml文件中的配置进行汇总,正常完成系统编译后,指定目录下就会生成hisysevent.def文件。 diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-overview.md b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-overview.md index 65f825ea1bacf5f9c8bdf59897e74a2023ba4852..ce9d2adb2545c64a6ce3437208bf57601f3e10bb 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-overview.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-overview.md @@ -1,7 +1,7 @@ # HiSysEvent概述 -## 概述 +## 简介 HiSysEvent是面向OpenHarmony系统开发者提供的系统打点功能,通过在关键路径埋点来记录系统在运行过程中的重要信息,辅助开发者定位问题,此外还支持开发者将打点数据上传到云进行大数据质量度量。 diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hitracechain.md b/zh-cn/device-dev/subsystems/subsys-dfx-hitracechain.md index 1c2cdf491de1474253287ada866d2de343d83553..1941e1a7db0f0bc7c091fb3a08703f41310dc6fd 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hitracechain.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hitracechain.md @@ -51,61 +51,93 @@ HiTraceChain实现在C层,主要原理是在一次业务调用流程中,利 | | **C++** | **C** | | -------- | -------- | -------- | | **类** | **函数** | **函数** | -| HiTraceChain | HiTraceId Begin(const std::string& name, int flags) | HiTraceIdStruct HiTraceChainBegin(const char\* name, int flags) | -| | void End(const HiTraceId& id) | void HiTraceChainEnd(const HiTraceIdStruct\* pId) | -| | HiTraceId GetId(); | HiTraceIdStruct HiTraceChainGetId() | -| | void SetId(const HiTraceId& id) | void HiTraceChainSetId(const HiTraceIdStruct\* pId) | -| | void ClearId() | void HiTraceChainClearId() | -| | HiTraceId CreateSpan() | HiTraceIdStruct HiTraceChainCreateSpan() | -| | void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char\* fmt, ...) | void HiTraceChainTracepoint(HiTraceTracepointType type, const HiTraceIdStruct_ pId, const char_ fmt, ...) | -| | void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char\* fmt, ...) | void HiTraceChainTracepointEx(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceIdStruct_ pId, const char_ fmt, ...) | -| HiTraceId | HiTraceId(); | void HiTraceChainInitId(HiTraceIdStruct\* pId) | -| | HiTraceId(const uint8_t\* pIdArray, int len) | HiTraceIdStruct HiTraceChainBytesToId(const uint8_t\* pIdArray, int len) | -| | bool IsValid() | int HiTraceChainIsValid(const HiTraceIdStruct\* pId) | -| | bool IsFlagEnabled(HiTraceFlag flag) | int HiTraceChainIsFlagEnabled(const HiTraceIdStruct\* pId, HiTraceFlag flag) | -| | void EnableFlag(HiTraceFlag flag) | void HiTraceChainEnableFlag(HiTraceIdStruct\* pId, HiTraceFlag flag) | -| | int GetFlags() | int HiTraceChainGetFlags(const HiTraceIdStruct\* pId) | -| | void SetFlags(int flags) | void HiTraceChainSetFlags(HiTraceIdStruct\* pId, int flags) | -| | uint64_t GetChainId() | uint64_t HiTraceChainGetChainId(const HiTraceIdStruct\* pId) | -| | void SetChainId(uint64_t chainId) | void HiTraceChainSetChainId(HiTraceIdStruct\* pId, uint64_t chainId) | -| | uint64_t GetSpanId() | uint64_t HiTraceChainGetSpanId(const HiTraceIdStruct\* pId) | -| | void SetSpanId(uint64_t spanId) | void HiTraceChainSetSpanId(HiTraceIdStruct\* pId, uint64_t spanId) | -| | uint64_t GetParentSpanId() | uint64_t HiTraceChainGetParentSpanId(const HiTraceIdStruct\* pId) | -| | void SetParentSpanId(uint64_t parentSpanId) | void HiTraceChainSetParentSpanId(HiTraceIdStruct\* pId, uint64_t parentSpanId) | -| | int ToBytes(uint8_t\* pIdArray, int len) | int HiTraceChainIdToBytes(const HiTraceIdStruct_ pId, uint8_t_ pIdArray, int len) | +| HiTraceChain | HiTraceId Begin(const std::string& name, int flags) | HiTraceIdStruct HiTraceChainBegin(const char* name, int flags) | +| | void End(const HiTraceId& id) | void HiTraceChainEnd(const HiTraceIdStruct* pId) | +| | HiTraceId GetId(); | HiTraceIdStruct HiTraceChainGetId() | +| | void SetId(const HiTraceId& id) | void HiTraceChainSetId(const HiTraceIdStruct* pId) | +| | void ClearId() | void HiTraceChainClearId() | +| | HiTraceId CreateSpan() | HiTraceIdStruct HiTraceChainCreateSpan() | +| | void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...) | void HiTraceChainTracepoint(HiTraceTracepointType type, const HiTraceIdStruct* pId, const char* fmt, ...) | +| | void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...) | void HiTraceChainTracepointEx(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceIdStruct* pId, const char* fmt, ...) | +| HiTraceId | HiTraceId(); | void HiTraceChainInitId(HiTraceIdStruct* pId) | +| | HiTraceId(const uint8_t* pIdArray, int len) | HiTraceIdStruct HiTraceChainBytesToId(const uint8_t* pIdArray, int len) | +| | bool IsValid() | int HiTraceChainIsValid(const HiTraceIdStruct* pId) | +| | bool IsFlagEnabled(HiTraceFlag flag) | int HiTraceChainIsFlagEnabled(const HiTraceIdStruct* pId, HiTraceFlag flag) | +| | void EnableFlag(HiTraceFlag flag) | void HiTraceChainEnableFlag(HiTraceIdStruct* pId, HiTraceFlag flag) | +| | int GetFlags() | int HiTraceChainGetFlags(const HiTraceIdStruct* pId) | +| | void SetFlags(int flags) | void HiTraceChainSetFlags(HiTraceIdStruct* pId, int flags) | +| | uint64_t GetChainId() | uint64_t HiTraceChainGetChainId(const HiTraceIdStruct* pId) | +| | void SetChainId(uint64_t chainId) | void HiTraceChainSetChainId(HiTraceIdStruct* pId, uint64_t chainId) | +| | uint64_t GetSpanId() | uint64_t HiTraceChainGetSpanId(const HiTraceIdStruct* pId) | +| | void SetSpanId(uint64_t spanId) | void HiTraceChainSetSpanId(HiTraceIdStruct* pId, uint64_t spanId) | +| | uint64_t GetParentSpanId() | uint64_t HiTraceChainGetParentSpanId(const HiTraceIdStruct* pId) | +| | void SetParentSpanId(uint64_t parentSpanId) | void HiTraceChainSetParentSpanId(HiTraceIdStruct* pId, uint64_t parentSpanId) | +| | int ToBytes(uint8_t* pIdArray, int len) | int HiTraceChainIdToBytes(const HiTraceIdStruct_ pId, uint8_t* pIdArray, int len) | ### 接口功能参数 - **表2** C++接口说明函数参数和功能 + **表2** 跟踪标志组合类型枚举 + +| **名称** | **值** | **说明** | +| -------- | -------- | -------- | +| HITRACE_FLAG_DEFAULT | 0 | 缺省标志。 | +| HITRACE_FLAG_INCLUDE_ASYNC | 1 | 异步调用标志。启动跟踪时,缺省只跟踪同步调用。设置该标志,同时跟踪同步、异步调用。 | +| HITRACE_FLAG_DONOT_CREATE_SPAN | 1 << 1 | 无分支标志。启动跟踪时,在同步、异步调用时缺省自动创建分支信息。设置该标志,指示不创建分支。 | +| HITRACE_FLAG_TP_INFO | 1 << 2 | 埋点标志。启动跟踪式时,缺省不进行埋点。调试场景下设置该标志,在同步、异步调用的收发侧自动埋点,输出埋点信息和时间戳。收发埋点按照client、server分为client send(CS)、server receive(SR)、server send(SS)、client receive(CR)四类信息。一次同步调用输出CS/SR/SS/CR,一次异步调用输出CS/SR/SS三个埋点信息。 | +| HITRACE_FLAG_NO_BE_INFO | 1 << 3 | 无起始结束标志。启动跟踪时,缺省打印启动及结束跟踪信息。设置该标志,指示不打印启动及结束跟踪信息。 | +| HITRACE_FLAG_DONOT_ENABLE_LOG | 1 << 4 | 日志关联标志。设置该标志,指示隐藏日志中的跟踪信息。 | +| HITRACE_FLAG_FAULT_TRIGGER | 1 << 5 | 故障触发标志。预置标志,暂时没有作用。 | +| HITRACE_FLAG_D2D_TP_INFO | 1 << 6 | 设备间埋点标志。TP_INFO的一个子集,设置该标志,只进行设备间的调用埋点。 | + + **表3** 跟踪埋点类型枚举 + +| **名称** | **值** | **说明** | +| -------- | -------- | -------- | +| HITRACE_TP_CS | 0 | 客户端发送类型,标识client侧的发送埋点。 | +| HITRACE_TP_CR | 1 | 客户端接收类型,标识client侧的接收埋点。 | +| HITRACE_TP_SS | 2 | 服务端发送类型,标识server侧的发送埋点。 | +| HITRACE_TP_SR | 3 | 服务端接收类型,标识server侧的接收埋点。 | +| HITRACE_TP_GENERAL | 4 | 一般类型,标识CS、CR、SS、SR四种场景之外的埋点。| + + **表4** 跟踪通信类型枚举 + +| **名称** | **值** | **说明** | +| -------- | -------- | -------- | +| HITRACE_CM_DEFAULT | 0 | 缺省通信类型 | +| HITRACE_CM_THREAD | 1 | 线程间通信类型 | +| HITRACE_CM_PROCESS | 2 | 进程间通信类型 | +| HITRACE_CM_DEVICE | 3 | 设备间通信类型 | + + **表5** C++接口说明函数参数和功能 | **类** | **方法** | **描述** | | -------- | -------- | -------- | -| HiTraceChain | HiTraceId Begin(const std::string& name, int flags) | 功能:启动HiTraceChain跟踪、生成HiTraceId对象并设置到当前线程TLS中。
输入参数:
- name:业务流程名称。
- flags:跟踪指示位,可以组合使用,具体含义为:
  - HITRACE_FLAG_INCLUDE_ASYNC:同时跟踪同步调用和异步调用,缺省只跟踪同步调用。
  - HITRACE_FLAG_DONOT_CREATE_SPAN:不创建子分支,缺省创建子分支。
  - HITRACE_FLAG_TP_INFO:输出tracepoint信息,缺省不输出。
  - HITRACE_FLAG_NO_BE_INFO:不输出起始、结束信息,缺省输出。
  - HITRACE_FLAG_DONOT_ENABLE_LOG:不与日志关联输出,缺省关联。
  - HITRACE_FLAG_FAULT_TRIGGER:故障触发的跟踪,缺省为正常启动的。
  - HITRACE_FLAG_D2D_TP_INFO:输出设备间tracepoint信息,缺省不输出。
  - HITRACE_FLAG_DEFAULT: 缺省标志。
- 输出参数:无
- 返回值:启动跟踪超过返回有效HiTraceId对象,否则返回无效对象。
注意:嵌套启动跟踪时,内层启动调用返回无效对象。 | -| | void End(const HiTraceId& id) | 功能:根据Begin返回的HiTraceId停止HiTraceChain跟踪;清除当前线程TLS中HiTraceId内容。
输入参数:
- id:HiTraceId对象。
输出参数:无。
返回值:无。 | -| | HiTraceId GetId(); | 功能:从当前线程TLS中获取HiTraceId对象。
输入参数:无。
输出参数:无。
返回值:当前线程上下文的HiTraceId对象。 | -| | void SetId(const HiTraceId& id) | 功能:设置HiTraceId对象内容到当前线程TLS中。
输入参数:
- id:HiTraceId对象。
输出参数:无。
返回值:无。 | -| | void ClearId() | 功能:清除当前线程TLS中的HiTraceId对象。
输入参数:无。
输出参数:无。
返回值:无。 | -| | HiTraceId CreateSpan() | 接口功能:获取当前HiTraceId对象中的分支ID。
输入参数:无。
输出参数:无。
返回值:当前分支ID。 | -| | void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char\* fmt, ...) | 功能:根据埋点信息类型输出HiTraceChain埋点信息,包括时间戳、子分支HiTraceId对象信息。
输入参数:
- type:埋点信息类型,具体为
  - HITRACE_TP_CS:Client Send,同步/异步通信客户端发送信息。
  - HITRACE_TP_SR:Server Receive, 同步/异步通信服务端接收信息。
  - HITRACE_TP_SS:Server Send,同步通信服务端发送响应信息。
  - HITRACE_TP_CR:Client Receive,同步通信客户端接收响应信息。
  - HITRACE_TP_GENERAL:普通输出信息。
- id:当前子分支id。
- fmt:格式化变参描述字符串。
- args:变参。
输出参数:无。
返回值:无。 | -| | void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char\* fmt, ...) | 功能:根据通信模式、埋点信息类型输出HiTraceChain埋点信息,包括时间戳、子分支HiTraceId对象信息。
输入参数:
- mode:通信模式,具体为
  - HITRACE_CM_DEFAULT:未指定通信模式。
  - HITRACE_CM_THREAD:线程间通信。
  - HITRACE_CM_PROCESS:进程间通信。
  - HITRACE_CM_DEVICE:设备间通信。
- type:埋点信息类型,具体为
  - HITRACE_TP_CS:Client Send,同步/异步通信客户端发送信息。
  - HITRACE_TP_SR:Server Receive, 同步/异步通信服务端接收信息。
  - HITRACE_TP_SS:Server Send,同步通信服务端发送响应信息。
  - HITRACE_TP_CR:Client Receive,同步通信客户端接收响应信息。
  - HITRACE_TP_GENERAL:普通输出信息。
- id:当前子分支id。
- fmt:格式化变参描述字符串。
- args:变参。
输出参数:无。
返回值:无。 | +| HiTraceChain | HiTraceId Begin(const std::string& name, int flags) | 功能:启动HiTraceChain跟踪、生成HiTraceId对象并设置到当前线程TLS中。
输入参数:
- name:业务流程名称。
- flags:跟踪指示位,可以组合使用,具体说明请参考**表2** 跟踪标志组合类型枚举。
- 输出参数:无
- 返回值:启动跟踪超过返回有效HiTraceId对象,否则返回无效对象。
注意:嵌套启动跟踪时,内层启动调用返回无效对象。 | +| | void End(const HiTraceId& id) | 功能:根据Begin返回的HiTraceId停止HiTraceChain跟踪;清除当前线程TLS中HiTraceId内容。
输入参数:
- id:HiTraceId对象。
输出参数:无。
返回值:无。 | +| | HiTraceId GetId(); | 功能:从当前线程TLS中获取HiTraceId对象。
输入参数:无。
输出参数:无。
返回值:当前线程上下文的HiTraceId对象。 | +| | void SetId(const HiTraceId& id) | 功能:设置HiTraceId对象内容到当前线程TLS中。
输入参数:
- id:HiTraceId对象。
输出参数:无。
返回值:无。 | +| | void ClearId() | 功能:清除当前线程TLS中的HiTraceId对象。
输入参数:无。
输出参数:无。
返回值:无。 | +| | HiTraceId CreateSpan() | 接口功能:获取当前HiTraceId对象中的分支ID。
输入参数:无。
输出参数:无。
返回值:当前分支ID。 | +| | void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...) | 功能:根据埋点信息类型输出HiTraceChain埋点信息,包括时间戳、子分支HiTraceId对象信息。
输入参数:
- type:埋点信息类型,具体说明请参考**表3** 跟踪埋点类型枚举。
- id:当前子分支id。
- fmt:格式化变参描述字符串。
- args:变参。
输出参数:无。
返回值:无。 | +| | void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...) | 功能:根据通信模式、埋点信息类型输出HiTraceChain埋点信息,包括时间戳、子分支HiTraceId对象信息。
输入参数:
- mode:通信模式,具体说明请参考**表4** 跟踪通信类型枚举。
- type:埋点信息类型,具体说明请参考**表3** 跟踪埋点类型枚举。
- id:当前子分支id。
- fmt:格式化变参描述字符串。
- args:变参。
输出参数:无。
返回值:无。 | | HiTraceId | HiTraceId(); | 功能:缺省构造函数,生成无效HiTraceId对象。
输入参数:无。
输出参数:无。
返回值:无。 | -| | HiTraceId(const uint8_t\* pIdArray, int len) | 功能:构造函数,根据字节数组创建跟踪HiTraceId对象。
输入参数:
- pIdArray:字节数组指针。
- len:字节数组长度。
输出参数:无。
返回值:无。 | -| | bool IsValid() | 功能:HiTraceId对象是否有效。
输入参数:无。
输出参数:无。
返回值:true 有效;false 无效。 | -| | bool IsFlagEnabled(HiTraceFlag flag) | 功能:HiTraceId对象的某标志是否置位。
输入参数:
- flag:跟踪指示位,具体含义见Begin函数中的定义。
输出参数:无。
返回值:true 该标志置位;false 该标志未置位。 | -| | void EnableFlag(HiTraceFlag flag) | 功能:设置某跟踪标志位到HiTraceId对象中。
输入参数:
- flag:跟踪指示位,具体含义见Begin函数中的定义。
输出参数:无。
返回值:无。 | -| | int GetFlags() | 功能:获取HiTraceId对象中设置的标志位。
输入参数:无。
输出参数:无。
返回值:跟踪指示位组合,具体含义见Begin函数中的定义。 | -| | void SetFlags(int flags) | 功能:设置跟踪标志位到HiTraceId对象中。
输入参数:
- flags:跟踪指示位组合,具体含义见Begin函数中的定义。
输出参数:无。
返回值:无。 | -| | uint64_t GetChainId() | 功能:获取跟踪链ID。
输入参数:无。
输出参数:无。
返回值:跟踪链ID。 | -| | void SetChainId(uint64_t chainId) | 功能:设置跟踪链ID到HiTraceId对象中。
输入参数:
- chainId:跟踪链ID。
输出参数:无。
返回值:无。 | -| | uint64_t GetSpanId() | 接口功能:获取当前HiTraceId对象中的分支ID。
输入参数:无。
输出参数:无。
返回值:当前分支ID。 | -| | void SetSpanId(uint64_t spanId) | 功能:设置分支ID到HiTraceId对象中。
输入参数:
- spanId:分支ID。
输出参数:无。
返回值:无。 | -| | uint64_t GetParentSpanId() | 功能:获取当前HiTraceId对象中的父分支ID。
输入参数:无。
输出参数:无。
返回值:父分支ID。 | -| | void SetParentSpanId(uint64_t parentSpanId) | 功能:设置父分支ID到HiTraceId对象中。
输入参数:
- parentSpanId:父分支ID。
输出参数:无。
返回值:无。 | -| | int ToBytes(uint8_t\* pIdArray, int len) | 功能:将HiTraceId对象转换为字节数组,便于缓存或者通信传递。
输入参数:
- pIdArray:字节数组指针,数组长度至少为HITRACE_ID_LEN。
- len: 字节数组长度
输出参数:
- pIdArray:字节数组指针,对象有效时存储转换后的对象数据。
返回值:0 转换失败; &gt;0 有效对象转换数组长度。 | - - -## 通信调用处理 +| | HiTraceId(const uint8_t* pIdArray, int len) | 功能:构造函数,根据字节数组创建跟踪HiTraceId对象。
输入参数:
- pIdArray:字节数组指针。
- len:字节数组长度。
输出参数:无。
返回值:无。 | +| | bool IsValid() | 功能:HiTraceId对象是否有效。
输入参数:无。
输出参数:无。
返回值:true 有效;false 无效。 | +| | bool IsFlagEnabled(HiTraceFlag flag) | 功能:HiTraceId对象的某标志是否置位。
输入参数:
- flag:跟踪指示位,具体含义见Begin函数中的定义。
输出参数:无。
返回值:true 该标志置位;false 该标志未置位。 | +| | void EnableFlag(HiTraceFlag flag) | 功能:设置某跟踪标志位到HiTraceId对象中。
输入参数:
- flag:跟踪指示位,具体含义见Begin函数中的定义。
输出参数:无。
返回值:无。 | +| | int GetFlags() | 功能:获取HiTraceId对象中设置的标志位。
输入参数:无。
输出参数:无。
返回值:跟踪指示位组合,具体含义见Begin函数中的定义。 | +| | void SetFlags(int flags) | 功能:设置跟踪标志位到HiTraceId对象中。
输入参数:
- flags:跟踪指示位组合,具体含义见Begin函数中的定义。
输出参数:无。
返回值:无。 | +| | uint64_t GetChainId() | 功能:获取跟踪链ID。
输入参数:无。
输出参数:无。
返回值:跟踪链ID。 | +| | void SetChainId(uint64_t chainId) | 功能:设置跟踪链ID到HiTraceId对象中。
输入参数:
- chainId:跟踪链ID。
输出参数:无。
返回值:无。 | +| | uint64_t GetSpanId() | 接口功能:获取当前HiTraceId对象中的分支ID。
输入参数:无。
输出参数:无。
返回值:当前分支ID。 | +| | void SetSpanId(uint64_t spanId) | 功能:设置分支ID到HiTraceId对象中。
输入参数:
- spanId:分支ID。
输出参数:无。
返回值:无。 | +| | uint64_t GetParentSpanId() | 功能:获取当前HiTraceId对象中的父分支ID。
输入参数:无。
输出参数:无。
返回值:父分支ID。 | +| | void SetParentSpanId(uint64_t parentSpanId) | 功能:设置父分支ID到HiTraceId对象中。
输入参数:
- parentSpanId:父分支ID。
输出参数:无。
返回值:无。 | +| | int ToBytes(uint8_t* pIdArray, int len) | 功能:将HiTraceId对象转换为字节数组,便于缓存或者通信传递。
输入参数:
- pIdArray:字节数组指针,数组长度至少为HITRACE_ID_LEN。
- len: 字节数组长度
输出参数:
- pIdArray:字节数组指针,对象有效时存储转换后的对象数据。
返回值:0 转换失败; &gt;0 有效对象转换数组长度。 | + + +### 通信调用处理 业务使用时跨设备/跨进程/跨线程的调用是通过通信机制实现的,HiTraceChain需要通信机制传递traceid。 diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hitracemeter.md b/zh-cn/device-dev/subsystems/subsys-dfx-hitracemeter.md index 96533e1f799ea0f2dae796180cc1a373437175c6..58a4e82fea85f151a2101dd586adec0c520bed21 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hitracemeter.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hitracemeter.md @@ -1,344 +1,353 @@ -# HiTraceMeter概述 - -## 简介 - -HiTraceMeter在OpenHarmony中,为开发者提供业务流程调用链跟踪的维测接口。通过使用该接口所提供的功能,可以帮助开发者迅速获取指定业务流程调用链的运行日志、定位跨设备/跨进程/跨线程的故障问题。HiTraceMeter用来支持用户态的打点,采集用户态和内核态的trace数据,从而进行性能跟踪与分析的系统。 - -## 基本概念 - -HiTraceMeter系统主要分为三部分: -- JS/C++应用打点API; -- Trace数据采集命令行工具; -- Trace数据图形分析工具。 - -其中,前两者运行在设备端侧,图形工具运行在PC主机侧。打点API部分提供了C++和JS接口,供开发过程中打点使用,打点用于产生Trace数据流,是抓Trace数据的基础条件。 - -命令行工具用于采集Trace数据,用来抓取Trace数据流并保存到文本文件。 - -Trace数据分析可以在图形工具中人工分析,也可以使用分析脚本自动化分析,Trace分析工具以Trace命令行工具的采集结果数据文件为输入。 - - HiTraceMeter跟踪数据使用类别分类,类别分类称作Trace Tag或Trace Category,一般一个端侧软件子系统对应一个Tag。该Tag在打点API中以类别Tag参数传入。Trace命令行工具采集跟踪数据时,只采集Tag类别选项指定的跟踪数据。应用程序跟踪数据标签都是属于APP Tag,从而JS接口不需要输入tag参数。目前HiTraceMeter支持的Trace Tag表如下(可在hitrace_meter.h [hitrace_meter.h](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/interfaces/native/innerkits/include/hitrace_meter/hitrace_meter.h) 中查看): - -```cpp -constexpr uint64_t HITRACE_TAG_NEVER = 0; // This tag is never enabled. -constexpr uint64_t HITRACE_TAG_ALWAYS = (1ULL << 0); // This tag is always enabled. -constexpr uint64_t HITRACE_TAG_DLP_CREDENTIAL = (1ULL << 21); // This tag is dlp credential service. -constexpr uint64_t HITRACE_TAG_ACCESS_CONTROL = (1ULL << 22); // This tag is access control tag. -constexpr uint64_t HITRACE_TAG_NET = (1ULL << 23); // Net tag. -constexpr uint64_t HITRACE_TAG_NWEB = (1ULL << 24); // NWeb tag. -constexpr uint64_t HITRACE_TAG_HUKS = (1ULL << 25); // This tag is huks. -constexpr uint64_t HITRACE_TAG_USERIAM = (1ULL << 26); // This tag is useriam. -constexpr uint64_t HITRACE_TAG_DISTRIBUTED_AUDIO = (1ULL << 27); // Distributed audio tag. -constexpr uint64_t HITRACE_TAG_DLSM = (1ULL << 28); // device security level tag. -constexpr uint64_t HITRACE_TAG_FILEMANAGEMENT = (1ULL << 29); // filemanagement tag. -constexpr uint64_t HITRACE_TAG_OHOS = (1ULL << 30); // OHOS generic tag. -constexpr uint64_t HITRACE_TAG_ABILITY_MANAGER = (1ULL << 31); // Ability Manager tag. -constexpr uint64_t HITRACE_TAG_ZCAMERA = (1ULL << 32); // Camera module tag. -constexpr uint64_t HITRACE_TAG_ZMEDIA = (1ULL << 33); // Media module tag. -constexpr uint64_t HITRACE_TAG_ZIMAGE = (1ULL << 34); // Image module tag. -constexpr uint64_t HITRACE_TAG_ZAUDIO = (1ULL << 35); // Audio module tag. -constexpr uint64_t HITRACE_TAG_DISTRIBUTEDDATA = (1ULL << 36); // Distributeddata manager module tag. -constexpr uint64_t HITRACE_TAG_MDFS = (1ULL << 37); // Mobile distributed file system tag. -constexpr uint64_t HITRACE_TAG_GRAPHIC_AGP = (1ULL << 38); // Graphic module tag. -constexpr uint64_t HITRACE_TAG_ACE = (1ULL << 39); // ACE development framework tag. -constexpr uint64_t HITRACE_TAG_NOTIFICATION = (1ULL << 40); // Notification module tag. -constexpr uint64_t HITRACE_TAG_MISC = (1ULL << 41); // Notification module tag. -constexpr uint64_t HITRACE_TAG_MULTIMODALINPUT = (1ULL << 42); // Multi modal module tag. -constexpr uint64_t HITRACE_TAG_SENSORS = (1ULL << 43); // Sensors mudule tag. -constexpr uint64_t HITRACE_TAG_MSDP = (1ULL << 44); // Multimodal Sensor Data Platform module tag. -constexpr uint64_t HITRACE_TAG_DSOFTBUS = (1ULL << 45); // Distributed Softbus tag. -constexpr uint64_t HITRACE_TAG_RPC = (1ULL << 46); // RPC and IPC tag. -constexpr uint64_t HITRACE_TAG_ARK = (1ULL << 47); // ARK tag. -constexpr uint64_t HITRACE_TAG_WINDOW_MANAGER = (1ULL << 48); // window manager tag. -constexpr uint64_t HITRACE_TAG_ACCOUNT_MANAGER = (1ULL << 49); // account manager tag. -constexpr uint64_t HITRACE_TAG_DISTRIBUTED_SCREEN = (1ULL << 50); // Distributed screen tag. -constexpr uint64_t HITRACE_TAG_DISTRIBUTED_CAMERA = (1ULL << 51); // Distributed camera tag. -constexpr uint64_t HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK = (1ULL << 52); // Distributed hardware fwk tag. -constexpr uint64_t HITRACE_TAG_GLOBAL_RESMGR = (1ULL << 53); // Global resource manager tag. -constexpr uint64_t HITRACE_TAG_DEVICE_MANAGER = (1ULL << 54); // Distributed hardware devicemanager tag. -constexpr uint64_t HITRACE_TAG_SAMGR = (1ULL << 55); // SA tag. -constexpr uint64_t HITRACE_TAG_POWER = (1ULL << 56); // power manager tag. -constexpr uint64_t HITRACE_TAG_DISTRIBUTED_SCHEDULE = (1ULL << 57); // Distributed schedule tag. -constexpr uint64_t HITRACE_TAG_DEVICE_PROFILE = (1ULL << 58); // device profile tag. -constexpr uint64_t HITRACE_TAG_DISTRIBUTED_INPUT = (1ULL << 59); // Distributed input tag. -constexpr uint64_t HITRACE_TAG_BLUETOOTH = (1ULL << 60); // bluetooth tag. -constexpr uint64_t HITRACE_TAG_ACCESSIBILITY_MANAGER = (1ULL << 61); // accessibility manager tag. -constexpr uint64_t HITRACE_TAG_APP = (1ULL << 62); // App tag. - -constexpr uint64_t HITRACE_TAG_LAST = HITRACE_TAG_APP; -constexpr uint64_t HITRACE_TAG_NOT_READY = (1ULL << 63); // Reserved for initialization. -constexpr uint64_t HITRACE_TAG_VALID_MASK = ((HITRACE_TAG_LAST - 1) | HITRACE_TAG_LAST); -``` - -## 实现原理 - -HiTraceMeter主要提供抓取用户态和内核态Trace数据的命令行工具,提供用户态打点的innerkits接口(c++)和kits接口(js),HiTraceMeter基于内核ftrace提供的用户态打点的扩展,利用ftrace的trace_marker节点,将用户空间通过打点接口写入的数据写进内核循环buffer缓冲区。其基本架构图如下: - - - -![输入图片说明](figures/HiTraceMeter.png) - - - - -## 约束与限制 - -- HiTraceMeter所有功能与接口的实现都依赖于内核提供的ftrace功能,ftrace 是内核提供的一个 framework,采用 plugin 的方式支持开发人员添加更多种类的 trace 功能,因此使用HiTraceMeter之前要使能 ftrace,否则HiTraceMeter的功能无法使用(目前大部分Linux内核默认使能了ftrace,关于ftrace的详细介绍可查看内核ftrace相关资料 - [ftrace相关资料](https://blog.csdn.net/Luckiers/article/details/124646205) )。 -- HiTraceMeter仅限小型系统、标准系统下使用。 - - - -# HiTraceMeter开发指导 - -HiTraceMeter分为JS/C++应用打点API与数据采集命令行工具hitrace,下面分别介绍接口和命令行工具。 - - - - -## 场景介绍 - -在实际开发过程中,开发者可能会遇到app卡顿或者在代码调试过程中需要查看代码调用流程,HiTraceMeter接口提供了相应的接口来跟踪程序延时和代码调用流程,分析性能问题。 - -## 接口说明 - -C++接口仅系统开发者使用,JS(目前暂未开放js接口)应用开发者可以略过本节。标准系统上接口描述如下(hitrace_meter.h [hitrace_meter.h](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/interfaces/native/innerkits/include/hitrace_meter/hitrace_meter.h) ): - -**表 1** 同步接口 - -| Sync trace | 功能描述 |参数说明 | -| :----------------------------------------------------------- | ------------- |------------- | -| void StartTrace(uint64_t label, const std::string& value, float limit = -1); | 启动同步trace |label: Trace category。
value: Trace携带的信息,表明当前的某种状态,例如内存大小,队列长短等。 | -| void FinishTrace(uint64_t label); | 关闭同步trace |label: Trace category。 | - - -同步接口StartTrace和FinishTrace必须配对使用,FinishTrace和前面最近的StartTrace进行匹配。StartTrace和FinishTrace函数对可以嵌套模式使用,跟踪数据解析时使用栈式数据结构进行匹配。接口中的limit参数用于限流,使用默认值即可。 - -**表 2** 异步接口 - -| Async trace | 功能描述 |参数说明 | -| ------------------------------------------------------------ | ------------- |------------- | -| void StartAsyncTrace(uint64_t label, const std::string& value, int32_t taskId, float limit = -1); | 开启异步trace | label: Trace category。
value: Trace携带的信息,表明当前的某种状态,例如内存大小,队列长短等。
taskId:异步Trace中用来表示关联的ID。 | -| void FinishAsyncTrace(uint64_t label, const std::string& value, int32_t taskId); | 关闭异步trace | label: Trace category。
value: Trace携带的信息,表明当前的某种状态,例如内存大小,队列长短等。
taskId:异步Trace中用来表示关联的ID。 | - - - -异步接口StartAsyncTrace和FinishAsyncTrace的跟踪数据匹配时,使用参数中的value和taskId配对匹配,可以不按顺序使用,主要用于异步场景。在C++程序中,使用异步跟踪的场景很少。 - -**表 3** 计数器接口 - -| Counter Trace | 功能描述 |参数说明 | -| ------------------------------------------------------------ | --------- |--------- | -| void CountTrace(uint64_t label, const std::string& name, int64_t); | 计数trace |label: Trace category。
name: Trace的名称,IDE中会以此字段展示这段Trace。 | - - -## 开发步骤 -1. 编译依赖添加,需要修改的编译配置文件base\hiviewdfx\hitrace\cmd\BUILD.gn 。 - - ``` - external_deps = [ "hitrace_native:hitrace_meter"] - ``` -2. 头文件依赖添加。 - - ```cpp - #include "hitrace_meter.h"//接口函数定义头文件 - ``` - -3. 接口调用,将需要跟踪的Trace value传入参数,目前HiTraceMeter支持的Trace Tag在基本概念hitrace_meter.h中都已列出,我们以OHOS这个Tag为例,假设我们需要获取func1,func2函数的Trace数据,参考下面实例,在shell中执行hitrace命令后会自动抓取Trace数据,抓到的Trace数据中包括了函数调用过程以及调用过程消耗的内存和时间,可用于分析代码调用流程,代码性能问题。 - - -```cpp -#include "hitrace_meter.h" // 包含hitrace_meter.h -using namespace std; - -int main() -{ - uint64_t label = BYTRACE_TAG_OHOS; - sleep(1); - CountTrace(label, "count number", 2000); // 整数跟踪 - - StartTrace(label, "func1Trace", -1); // func1Start的跟踪起始点 - sleep(1); - StartTrace(label, "func2Trace", -1); // func2Start的跟踪起始点 - sleep(2); - FinishTrace(label); // func2Trace的结束点 - sleep(1); - FinishTrace(label); // func1Trace的结束点 - - StartAsyncTrace(label, "asyncTrace1", 1234); // 异步asyncTrace1的开始点 - FinishAsyncTrace(label, "asyncTrace1", 1234); // 异步asyncTrace2的结束点 - - return 0; - } - ``` - -4. 使用方法,打点编译部署完成后,运行下面命令行来抓取Trace。然后在端侧shell里运行应用,可以抓取到Trace数据。 - - ``` - hdc_std shell hitrace -t 10 ohos > .\myapp_demo.ftrace - ``` - - 抓取之后的数据可以在smartperf中"Open trace file"或者直接拖入图形区打开,关于smartperf的详细介绍可查看 [smartperf](https://toscode.gitee.com/openharmony-sig/smartperf) 。 - - -## 调测验证 - -以下为一个demo调试过程,该demo使用了同步接口中的StartTrace和FinishTrace。 - -1. 编写测试代码hitrace_example.cpp( [hitrace_example.cpp](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/cmd/example/hitrace_example.cpp) ),将使用到的接口加入代码: - - ```cpp - int main() - { - thread t1(ThreadFunc1); - t1.join(); - - StartTrace(LABEL, "testStart"); - sleep(SLEEP_ONE_SECOND); - - StartTrace(LABEL, "funcAStart", SLEEP_ONE_SECOND); // 打印起始点 - FuncA(); - FinishTrace(LABEL); - sleep(SLEEP_TWO_SECOND); - - thread t2(ThreadFunc2); - t2.join(); - - StartTrace(LABEL, "funcBStart", SLEEP_TWO_SECOND); - FuncB(); - FinishTrace(LABEL);// 打印结束点 - sleep(SLEEP_TWO_SECOND); - - sleep(SLEEP_ONE_SECOND); - FinishTrace(LABEL); - FuncC(); - - return 0; - } - ``` - -2. 修改gn编译文件并编译,编译配置文件路径base\hiviewdfx\hitrace\cmd\BUILD.gn 。 - - ``` - ohos_executable("hitrace_example") { - sources = [ "example/hitrace_example.cpp" ] - - external_deps = [ "hitrace_native:hitrace_meter" ] - - subsystem_name = "hiviewdfx" - part_name = "hitrace_native" - } - - group("hitrace_target") { - deps = [ - ":hitrace", - ":hitrace_example", - ] - } - ``` - -3. 将编译出来的hitrace_example可执行文件放到设备中的/system/bin目录下,在shell中执行依次执行如下命令: - - ```shell - hitrace --trace_begin ohos - hitrace_exampe - hitrace --trace_dump - ``` - - 当我们看到Trace数据中有我们需要的Trace value时,说明成功抓取Trace,成功的数据如下所示: - - ``` - <...>-1651 (-------) [002] .... 327.194136: tracing_mark_write: S|1650|H:testAsync 111 - <...>-1650 (-------) [001] .... 332.197640: tracing_mark_write: B|1650|H:testStart - <...>-1650 (-------) [001] .... 333.198018: tracing_mark_write: B|1650|H:funcAStart - <...>-1650 (-------) [001] .... 334.198507: tracing_mark_write: E|1650| - <...>-1654 (-------) [003] .... 341.201673: tracing_mark_write: F|1650|H:testAsync 111 - <...>-1650 (-------) [001] .... 341.202168: tracing_mark_write: B|1650|H:funcBStart - <...>-1650 (-------) [001] .... 343.202557: tracing_mark_write: E|1650| - <...>-1650 (-------) [001] .... 346.203178: tracing_mark_write: E|1650| - <...>-1650 (-------) [001] .... 346.203457: tracing_mark_write: C|1650|H:count number 1 - <...>-1650 (-------) [001] .... 347.203818: tracing_mark_write: C|1650|H:count number 2 - <...>-1650 (-------) [001] .... 348.204207: tracing_mark_write: C|1650|H:count number 3 - <...>-1650 (-------) [001] .... 349.204473: tracing_mark_write: C|1650|H:count number 4 - <...>-1650 (-------) [001] .... 350.204851: tracing_mark_write: C|1650|H:count number 5 - <...>-1655 (-------) [001] .... 365.944658: tracing_mark_write: trace_event_clock_sync: realtime_ts=1502021460925 - <...>-1655 (-------) [001] .... 365.944686: tracing_mark_write: trace_event_clock_sync: parent_ts=365.944641 - ``` - - - -# HiTraceMeter命令行工具使用指导 - -HiTraceMeter提供了可执行的二进制程序hitrace,设备刷openharmony后直接在shell中运行以下命令,抓取内核运行的数据,当前支持的操作如下: - -**表 4** 命令行列表 - -| Option | Description | -| ------------------------------ | ------------------------------------------------------------ | -| -h,--help | 查看option帮助 | -| -b n,--buffer_size n | 指定n(KB)内存大小用于存取trace日志,默认2048KB | -| -t n,--time n | 用来指定trace运行的时间(单位:s),取决于需要分析过程的时间 | -| --trace_clock clock | trace输出的时钟类型,一般设备支持boot、global、mono、uptime、perf等,默认为boot | -| --trace_begin | 启动抓trace | -| --trace_dump | 将数据输出到指定位置(默认控制台) | -| --trace_finish | 停止抓trace,并将数据输出到指定位置(默认控制台) | -| -l,--list_categories | 输出手机能支持的trace模块 | -| --overwrite | 当缓冲区满的时候,将丢弃最新的信息。(默认丢弃最老的日志) | -| -o filename,--output filename | 指定输出的目标文件名称 | -| -z | 抓取trace后进行压缩 | - -以下是常用hitrace命令示例,供开发者参考: - -- 查询支持的label。 - - ``` - hitrace -l - ``` - - 或者 - - ``` - hitrace --list_categories - ``` - - -- 设置4M缓存,抓取10秒,抓取label为ability的trace信息。 - - ``` - hitrace -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace - ``` - - -- 设置trace的输出时钟为mono。 - - ``` - hitrace --trace_clock mono -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace - ``` - - -- 抓取trace后进行压缩。 - - ``` - hitrace -z -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace - ``` - - - -# 常见问题 - -### hitrace抓数据不全或者没抓到数据 - -#### 现象描述 - - 执行hitrace命令抓数据不全或者没抓到数据。 - -#### 解决方法 - - 参数-t 时间设置过小或者-b缓冲区buffer设置过小导致数据丢失,可设置-t 60,-b 204800扩大抓trace时间和缓冲区buffer解决。 - - - -# 参考 - -更多关于HiTraceMeter的详细内容请参考:[hiviewdfx_hitrace: A Lightweight Distributed Tracing | 轻量级的分布式调用链跟踪 (gitee.com)](https://gitee.com/openharmony/hiviewdfx_hitrace) 。 - +# HiTraceMeter概述 + +## 简介 + +HiTraceMeter在OpenHarmony中,为开发者提供业务流程调用链跟踪的维测接口。通过使用该接口所提供的功能,可以帮助开发者迅速获取指定业务流程调用链的运行日志、定位跨设备/跨进程/跨线程的故障问题。HiTraceMeter用来支持用户态的打点,采集用户态和内核态的trace数据,从而进行性能跟踪与分析的系统。 + +## 基本概念 + +HiTraceMeter系统主要分为三部分: + +- JS/C++应用打点API; +- Trace数据采集命令行工具; +- Trace数据图形分析工具。 + +其中,前两者运行在设备端侧,图形工具运行在PC主机侧。打点API部分提供了C++和JS接口,供开发过程中打点使用,打点用于产生Trace数据流,是抓Trace数据的基础条件。 + +命令行工具用于采集Trace数据,用来抓取Trace数据流并保存到文本文件。 + +Trace数据分析可以在图形工具中人工分析,也可以使用分析脚本自动化分析,Trace分析工具以Trace命令行工具的采集结果数据文件为输入。 + + HiTraceMeter跟踪数据使用类别分类,类别分类称作Trace Tag或Trace Category,一般一个端侧软件子系统对应一个Tag。该Tag在打点API中以类别Tag参数传入。Trace命令行工具采集跟踪数据时,只采集Tag类别选项指定的跟踪数据。应用程序跟踪数据标签都是属于APP Tag,从而JS接口不需要输入tag参数。目前HiTraceMeter支持的Trace Tag表如下(可在hitrace_meter.h [hitrace_meter.h](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/interfaces/native/innerkits/include/hitrace_meter/hitrace_meter.h) 中查看): + +```cpp +constexpr uint64_t HITRACE_TAG_NEVER = 0; // This tag is never enabled. +constexpr uint64_t HITRACE_TAG_ALWAYS = (1ULL << 0); // This tag is always enabled. +constexpr uint64_t HITRACE_TAG_DLP_CREDENTIAL = (1ULL << 21); // This tag is dlp credential service. +constexpr uint64_t HITRACE_TAG_ACCESS_CONTROL = (1ULL << 22); // This tag is access control tag. +constexpr uint64_t HITRACE_TAG_NET = (1ULL << 23); // Net tag. +constexpr uint64_t HITRACE_TAG_NWEB = (1ULL << 24); // NWeb tag. +constexpr uint64_t HITRACE_TAG_HUKS = (1ULL << 25); // This tag is huks. +constexpr uint64_t HITRACE_TAG_USERIAM = (1ULL << 26); // This tag is useriam. +constexpr uint64_t HITRACE_TAG_DISTRIBUTED_AUDIO = (1ULL << 27); // Distributed audio tag. +constexpr uint64_t HITRACE_TAG_DLSM = (1ULL << 28); // device security level tag. +constexpr uint64_t HITRACE_TAG_FILEMANAGEMENT = (1ULL << 29); // filemanagement tag. +constexpr uint64_t HITRACE_TAG_OHOS = (1ULL << 30); // OHOS generic tag. +constexpr uint64_t HITRACE_TAG_ABILITY_MANAGER = (1ULL << 31); // Ability Manager tag. +constexpr uint64_t HITRACE_TAG_ZCAMERA = (1ULL << 32); // Camera module tag. +constexpr uint64_t HITRACE_TAG_ZMEDIA = (1ULL << 33); // Media module tag. +constexpr uint64_t HITRACE_TAG_ZIMAGE = (1ULL << 34); // Image module tag. +constexpr uint64_t HITRACE_TAG_ZAUDIO = (1ULL << 35); // Audio module tag. +constexpr uint64_t HITRACE_TAG_DISTRIBUTEDDATA = (1ULL << 36); // Distributeddata manager module tag. +constexpr uint64_t HITRACE_TAG_MDFS = (1ULL << 37); // Mobile distributed file system tag. +constexpr uint64_t HITRACE_TAG_GRAPHIC_AGP = (1ULL << 38); // Graphic module tag. +constexpr uint64_t HITRACE_TAG_ACE = (1ULL << 39); // ACE development framework tag. +constexpr uint64_t HITRACE_TAG_NOTIFICATION = (1ULL << 40); // Notification module tag. +constexpr uint64_t HITRACE_TAG_MISC = (1ULL << 41); // Notification module tag. +constexpr uint64_t HITRACE_TAG_MULTIMODALINPUT = (1ULL << 42); // Multi modal module tag. +constexpr uint64_t HITRACE_TAG_SENSORS = (1ULL << 43); // Sensors mudule tag. +constexpr uint64_t HITRACE_TAG_MSDP = (1ULL << 44); // Multimodal Sensor Data Platform module tag. +constexpr uint64_t HITRACE_TAG_DSOFTBUS = (1ULL << 45); // Distributed Softbus tag. +constexpr uint64_t HITRACE_TAG_RPC = (1ULL << 46); // RPC and IPC tag. +constexpr uint64_t HITRACE_TAG_ARK = (1ULL << 47); // ARK tag. +constexpr uint64_t HITRACE_TAG_WINDOW_MANAGER = (1ULL << 48); // window manager tag. +constexpr uint64_t HITRACE_TAG_ACCOUNT_MANAGER = (1ULL << 49); // account manager tag. +constexpr uint64_t HITRACE_TAG_DISTRIBUTED_SCREEN = (1ULL << 50); // Distributed screen tag. +constexpr uint64_t HITRACE_TAG_DISTRIBUTED_CAMERA = (1ULL << 51); // Distributed camera tag. +constexpr uint64_t HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK = (1ULL << 52); // Distributed hardware fwk tag. +constexpr uint64_t HITRACE_TAG_GLOBAL_RESMGR = (1ULL << 53); // Global resource manager tag. +constexpr uint64_t HITRACE_TAG_DEVICE_MANAGER = (1ULL << 54); // Distributed hardware devicemanager tag. +constexpr uint64_t HITRACE_TAG_SAMGR = (1ULL << 55); // SA tag. +constexpr uint64_t HITRACE_TAG_POWER = (1ULL << 56); // power manager tag. +constexpr uint64_t HITRACE_TAG_DISTRIBUTED_SCHEDULE = (1ULL << 57); // Distributed schedule tag. +constexpr uint64_t HITRACE_TAG_DEVICE_PROFILE = (1ULL << 58); // device profile tag. +constexpr uint64_t HITRACE_TAG_DISTRIBUTED_INPUT = (1ULL << 59); // Distributed input tag. +constexpr uint64_t HITRACE_TAG_BLUETOOTH = (1ULL << 60); // bluetooth tag. +constexpr uint64_t HITRACE_TAG_ACCESSIBILITY_MANAGER = (1ULL << 61); // accessibility manager tag. +constexpr uint64_t HITRACE_TAG_APP = (1ULL << 62); // App tag. + +constexpr uint64_t HITRACE_TAG_LAST = HITRACE_TAG_APP; +constexpr uint64_t HITRACE_TAG_NOT_READY = (1ULL << 63); // Reserved for initialization. +constexpr uint64_t HITRACE_TAG_VALID_MASK = ((HITRACE_TAG_LAST - 1) | HITRACE_TAG_LAST); +``` + +## 实现原理 + +HiTraceMeter主要提供抓取用户态和内核态Trace数据的命令行工具,提供用户态打点的innerkits接口(c++)和kits接口(js),HiTraceMeter基于内核ftrace提供的用户态打点的扩展,利用ftrace的trace_marker节点,将用户空间通过打点接口写入的数据写进内核循环buffer缓冲区。其基本架构图如下: + + + +![输入图片说明](figures/HiTraceMeter.png) + + + +## 约束与限制 + +- HiTraceMeter所有功能与接口的实现都依赖于内核提供的ftrace功能,ftrace 是内核提供的一个 framework,采用 plugin 的方式支持开发人员添加更多种类的 trace 功能,因此使用HiTraceMeter之前要使能 ftrace,否则HiTraceMeter的功能无法使用(目前大部分Linux内核默认使能了ftrace,关于ftrace的详细介绍可查看内核ftrace相关资料 + [ftrace相关资料](https://blog.csdn.net/Luckiers/article/details/124646205) )。 +- HiTraceMeter仅限小型系统、标准系统下使用。 + + + +# HiTraceMeter开发指导 + +HiTraceMeter分为JS/C++应用打点API与数据采集命令行工具hitrace,下面分别介绍接口和命令行工具。 + + + +## 场景介绍 + +在实际开发过程中,开发者可能会遇到app卡顿或者在代码调试过程中需要查看代码调用流程,HiTraceMeter接口提供了相应的接口来跟踪程序延时和代码调用流程,分析性能问题。 + +## 接口说明 + +C++接口仅系统开发者使用,JS(目前暂未开放js接口)应用开发者可以略过本节。标准系统上接口描述如下(hitrace_meter.h [hitrace_meter.h](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/interfaces/native/innerkits/include/hitrace_meter/hitrace_meter.h) ): + +**表 1** 同步接口 + +| Sync trace | 功能描述 | 参数说明 | +|:---------------------------------------------------------------------------- | --------- | --------------------------------------------------------------------- | +| void StartTrace(uint64_t label, const std::string& value, float limit = -1); | 启动同步trace | label: Trace category。
value: Trace携带的信息,表明当前的某种状态,例如内存大小,队列长短等。 | +| void FinishTrace(uint64_t label); | 关闭同步trace | label: Trace category。 | + +同步接口StartTrace和FinishTrace必须配对使用,FinishTrace和前面最近的StartTrace进行匹配。StartTrace和FinishTrace函数对可以嵌套模式使用,跟踪数据解析时使用栈式数据结构进行匹配。接口中的limit参数用于限流,使用默认值即可。 + +**表 2** 异步接口 + +| Async trace | 功能描述 | 参数说明 | +| ------------------------------------------------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------- | +| void StartAsyncTrace(uint64_t label, const std::string& value, int32_t taskId, float limit = -1); | 开启异步trace | label: Trace category。
value: Trace携带的信息,表明当前的某种状态,例如内存大小,队列长短等。
taskId:异步Trace中用来表示关联的ID。 | +| void FinishAsyncTrace(uint64_t label, const std::string& value, int32_t taskId); | 关闭异步trace | label: Trace category。
value: Trace携带的信息,表明当前的某种状态,例如内存大小,队列长短等。
taskId:异步Trace中用来表示关联的ID。 | + + + +异步接口StartAsyncTrace和FinishAsyncTrace的跟踪数据匹配时,使用参数中的value和taskId配对匹配,可以不按顺序使用,主要用于异步场景。在C++程序中,使用异步跟踪的场景很少。 + +**表 3** 计数器接口 + +| Counter Trace | 功能描述 | 参数说明 | +| ------------------------------------------------------------------ | ------- | -------------------------------------------------------------- | +| void CountTrace(uint64_t label, const std::string& name, int64_t); | 计数trace | label: Trace category。
name: Trace的名称,IDE中会以此字段展示这段Trace。 | + +## 开发步骤 + +1. 编译依赖添加,需要修改的编译配置文件base\hiviewdfx\hitrace\cmd\BUILD.gn 。 + + ``` + external_deps = [ "hitrace_native:hitrace_meter"] + ``` + +2. 头文件依赖添加。 + + ```cpp + #include "hitrace_meter.h"//接口函数定义头文件 + ``` + +3. 接口调用,将需要跟踪的Trace value传入参数,目前HiTraceMeter支持的Trace Tag在基本概念hitrace_meter.h中都已列出,我们以OHOS这个Tag为例,假设我们需要获取func1,func2函数的Trace数据,参考下面实例,在shell中执行hitrace命令后会自动抓取Trace数据,抓到的Trace数据中包括了函数调用过程以及调用过程消耗的内存和时间,可用于分析代码调用流程,代码性能问题。 + + ```cpp + #include "hitrace_meter.h" // 包含hitrace_meter.h + using namespace std; + + int main() + { + uint64_t label = BYTRACE_TAG_OHOS; + sleep(1); + CountTrace(label, "count number", 2000); // 整数跟踪 + + StartTrace(label, "func1Trace", -1); // func1Start的跟踪起始点 + sleep(1); + StartTrace(label, "func2Trace", -1); // func2Start的跟踪起始点 + sleep(2); + FinishTrace(label); // func2Trace的结束点 + sleep(1); + FinishTrace(label); // func1Trace的结束点 + + StartAsyncTrace(label, "asyncTrace1", 1234); // 异步asyncTrace1的开始点 + FinishAsyncTrace(label, "asyncTrace1", 1234); // 异步asyncTrace1的结束点 + + return 0; + } + ``` + +4. 使用方法,打点编译部署完成后,运行下面命令行来抓取Trace。然后在端侧shell里运行应用,可以抓取到Trace数据。 + + ``` + hdc_std shell hitrace -t 10 ohos > .\myapp_demo.ftrace + ``` + + 抓取之后的数据可以在smartperf中"Open trace file"或者直接拖入图形区打开,关于smartperf的详细介绍可查看 [smartperf](https://toscode.gitee.com/openharmony-sig/smartperf) 。 + +## 调测验证 + +以下为一个demo调试过程,该demo使用了同步接口中的StartTrace和FinishTrace。 + +1. 编写测试代码hitrace_example.cpp( [hitrace_example.cpp](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/cmd/example/hitrace_example.cpp) ),将使用到的接口加入代码: + + ```cpp + int main() + { + thread t1(ThreadFunc1); + t1.join(); + + StartTrace(LABEL, "testStart"); + sleep(SLEEP_ONE_SECOND); + + StartTrace(LABEL, "funcAStart", SLEEP_ONE_SECOND); // 打印起始点 + FuncA(); + FinishTrace(LABEL); + sleep(SLEEP_TWO_SECOND); + + thread t2(ThreadFunc2); + t2.join(); + + StartTrace(LABEL, "funcBStart", SLEEP_TWO_SECOND); + FuncB(); + FinishTrace(LABEL);// 打印结束点 + sleep(SLEEP_TWO_SECOND); + + sleep(SLEEP_ONE_SECOND); + FinishTrace(LABEL); + FuncC(); + + return 0; + } + ``` + +2. 修改gn编译文件并编译,编译配置文件路径base\hiviewdfx\hitrace\cmd\BUILD.gn 。 + + ``` + ohos_executable("hitrace_example") { + sources = [ "example/hitrace_example.cpp" ] + + external_deps = [ "hitrace_native:hitrace_meter" ] + + subsystem_name = "hiviewdfx" + part_name = "hitrace_native" + } + + group("hitrace_target") { + deps = [ + ":hitrace", + ":hitrace_example", + ] + } + ``` + +3. 将编译出来的hitrace_example可执行文件放到设备中的/system/bin目录下,在shell中执行依次执行如下命令: + + ```shell + hitrace --trace_begin ohos + hitrace_exampe + hitrace --trace_dump + ``` + + 当我们看到Trace数据中有我们需要的Trace value时,说明成功抓取Trace,成功的数据如下所示: + + ``` + <...>-1651 (-------) [002] .... 327.194136: tracing_mark_write: S|1650|H:testAsync 111 + <...>-1650 (-------) [001] .... 332.197640: tracing_mark_write: B|1650|H:testStart + <...>-1650 (-------) [001] .... 333.198018: tracing_mark_write: B|1650|H:funcAStart + <...>-1650 (-------) [001] .... 334.198507: tracing_mark_write: E|1650| + <...>-1654 (-------) [003] .... 341.201673: tracing_mark_write: F|1650|H:testAsync 111 + <...>-1650 (-------) [001] .... 341.202168: tracing_mark_write: B|1650|H:funcBStart + <...>-1650 (-------) [001] .... 343.202557: tracing_mark_write: E|1650| + <...>-1650 (-------) [001] .... 346.203178: tracing_mark_write: E|1650| + <...>-1650 (-------) [001] .... 346.203457: tracing_mark_write: C|1650|H:count number 1 + <...>-1650 (-------) [001] .... 347.203818: tracing_mark_write: C|1650|H:count number 2 + <...>-1650 (-------) [001] .... 348.204207: tracing_mark_write: C|1650|H:count number 3 + <...>-1650 (-------) [001] .... 349.204473: tracing_mark_write: C|1650|H:count number 4 + <...>-1650 (-------) [001] .... 350.204851: tracing_mark_write: C|1650|H:count number 5 + <...>-1655 (-------) [001] .... 365.944658: tracing_mark_write: trace_event_clock_sync: realtime_ts=1502021460925 + <...>-1655 (-------) [001] .... 365.944686: tracing_mark_write: trace_event_clock_sync: parent_ts=365.944641 + ``` + + + +# HiTraceMeter命令行工具使用指导 + +HiTraceMeter提供了可执行的二进制程序hitrace,设备刷openharmony后直接在shell中运行以下命令,抓取内核运行的数据,当前支持的操作如下: + +**表 4** 命令行列表 + +| Option | Description | +| ----------------------------- | -------------------------------------------------------- | +| -h,--help | 查看option帮助 | +| -b n,--buffer_size n | 指定n(KB)内存大小用于存取trace日志,默认2048KB | +| -t n,--time n | 用来指定trace运行的时间(单位:s),取决于需要分析过程的时间 | +| --trace_clock clock | trace输出的时钟类型,一般设备支持boot、global、mono、uptime、perf等,默认为boot | +| --trace_begin | 启动抓trace | +| --trace_dump | 将数据输出到指定位置(默认控制台) | +| --trace_finish | 停止抓trace,并将数据输出到指定位置(默认控制台) | +| -l,--list_categories | 输出手机能支持的trace模块 | +| --overwrite | 当缓冲区满的时候,将丢弃最新的信息。(默认丢弃最老的日志) | +| -o filename,--output filename | 指定输出的目标文件名称 | +| -z | 抓取trace后进行压缩 | + +以下是常用hitrace命令示例,供开发者参考: + +- 查询支持的label。 + + ``` + + hitrace -l + + ``` + + 或者 + + ``` + + hitrace --list_categories + + ``` + +- 设置4M缓存,抓取10秒,抓取label为ability的trace信息。 + + ``` + + hitrace -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace + + ``` + +- 设置trace的输出时钟为mono。 + + ``` + + hitrace --trace_clock mono -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace + + ``` + +- 抓取trace后进行压缩。 + + ``` + + hitrace -z -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace + + ``` + + + +# 常见问题 + +### hitrace抓数据不全或者没抓到数据 + +#### 现象描述 + +执行hitrace命令抓数据不全或者没抓到数据。 + +#### 根因分析 + +参数-t 时间设置过小或者-b缓冲区buffer设置过小导致数据丢失。 + +#### 解决方法 + +可设置-t 60,-b 204800扩大抓trace时间和缓冲区buffer解决。 + + + +# 参考 + +更多关于HiTraceMeter的详细内容请参考:[轻量级的分布式调用链跟踪](https://gitee.com/openharmony/hiviewdfx_hitrace) 。 + + diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-overview.md b/zh-cn/device-dev/subsystems/subsys-dfx-overview.md index f1c06a3c423a210fc491f7fe9c994ff242146cc9..bc4c9e8a6c4de388101d6b8824cf3a7df641a3e1 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-overview.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-overview.md @@ -7,22 +7,25 @@ 提供以下功能: -- HiLog流水日志,轻量系统类设备(参考内存≥128KiB)、小型系统类设备(参考内存≥1MiB)、标准系统类设备(参考内存≥128MB)适用。 +- HiLog流水日志,标准系统类设备(参考内存≥128MB)适用、HiLog_Lite轻量流水日志,轻量系统类设备(参考内存≥128KiB),小型系统类设备(参考内存≥1MiB)适用。 - HiTraceChain分布式跟踪,标准系统类设备(参考内存≥128MiB)适用。 +- HiTraceMeter性能跟踪,标准系统类设备(参考内存≥128MiB)适用。 + - HiCollie卡死故障检测,标准系统类设备(参考内存≥128MiB)适用。 - HiSysEvent系统事件埋点,标准系统类设备(参考内存≥128MiB)适用。 -- HiChecker缺陷扫描,标准系统类设备(参考内存≥128MB)适用。 - - HiDumper信息导出,标准系统类设备(参考内存≥128MB)适用。 - Faultlogger崩溃故障检测,标准系统类设备(参考内存≥128MB)适用。 - Hiview插件平台,标准系统类设备(参考内存≥128MB)适用。 +- HiAppEvent应用事件及HiChecker缺陷扫描仅供应用开发者使用。 + +![dfx特性概览](figures/dfx-overview.png) ## 基本概念 diff --git a/zh-cn/device-dev/subsystems/subsys-toolchain-hiperf.md b/zh-cn/device-dev/subsystems/subsys-toolchain-hiperf.md index 461e3f1dcd4036741d1bf5721c86789c0098262f..7dfe5ae62c8564df7a0cd77c9e4bf4ad23bc1b24 100644 --- a/zh-cn/device-dev/subsystems/subsys-toolchain-hiperf.md +++ b/zh-cn/device-dev/subsystems/subsys-toolchain-hiperf.md @@ -207,6 +207,9 @@ Usage: hiperf record [options] ## report 命令 + +### 参数说明 + 此命令主要用于展示record中抓取的采样数据 @@ -230,7 +233,7 @@ Usage: hiperf report [option] | -o <_filename_> | 指定输出的报告文件名。 | -## 使用示例 +### 使用示例 - 输出采样数据的报告,默认读取perf.data文件 diff --git a/zh-cn/device-dev/subsystems/subsys-usbservice-demo.md b/zh-cn/device-dev/subsystems/subsys-usbservice-demo.md deleted file mode 100644 index ad6e84ec1ce098166779ea978ed39345448eda09..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-usbservice-demo.md +++ /dev/null @@ -1,187 +0,0 @@ -# USB服务子系统使用实例 - - -```cpp -#include -#include -#include -#include -#include -#include -#include "if_system_ability_manager.h" -#include "ipc_skeleton.h" -#include "iremote_object.h" -#include "iservice_registry.h" -#include "iusb_srv.h" -#include "string_ex.h" -#include "system_ability_definition.h" -#include "usb_common.h" -#include "usb_device.h" -#include "usb_errors.h" -#include "usb_request.h" -#include "usb_server_proxy.h" -#include "usb_srv_client.h" - -const int32_t REQUESTYPE = ((1 << 7) | (0 << 5) | (0 & 0x1f)); -const int32_t REQUESTCMD = 6; -const int32_t VALUE = (2 << 8) + 0; -const int32_t TIMEOUT = 5000; -const int32_t ITFCLASS = 10; -const int32_t PRAMATYPE = 2; -const int32_t BUFFERLENGTH = 21; - -void GetType(OHOS::USB::USBEndpoint &tep, OHOS::USB::USBEndpoint &outEp, bool &outEpFlg) -{ - if ((tep.GetType() == PRAMATYPE)) { - if (tep.GetDirection() == 0) { - outEp = tep; - outEpFlg = true; - } - } -} - -bool SelectEndpoint(OHOS::USB::USBConfig config, - std::vector interfaces, - OHOS::USB::UsbInterface &interface, - OHOS::USB::USBEndpoint &outEp, - bool &outEpFlg) -{ - for (int32_t i = 0; i < config.GetInterfaceCount(); ++i) { - OHOS::USB::UsbInterface tif = interfaces[i]; - std::vector mEndpoints = tif.GetEndpoints(); - for (int32_t j = 0; j < tif.GetEndpointCount(); ++j) { - OHOS::USB::USBEndpoint tep = mEndpoints[j]; - if ((tif.GetClass() == ITFCLASS) && (tif.GetSubClass() == 0) && (tif.GetProtocol() == PRAMATYPE)) { - GetType(tep, outEp, outEpFlg); - } - } - if (outEpFlg) { - interface = interfaces[i]; - return true; - } - std::cout << std::endl; - } - return false; -} - -int OpenDeviceTest(OHOS::USB::UsbSrvClient &Instran, OHOS::USB::UsbDevice device, OHOS::USB::USBDevicePipe &pip) -{ - int ret = Instran.RequestRight(device.GetName()); - std::cout << "device RequestRight ret = " << ret << std::endl; - if (0 != ret) { - std::cout << "device RequestRight failed = " << ret << std::endl; - } - ret = Instran.OpenDevice(device, pip); - return ret; -} - -int CtrTransferTest(OHOS::USB::UsbSrvClient &Instran, OHOS::USB::USBDevicePipe &pip) -{ - std::cout << "usb_device_test : << Control Transfer >> " << std::endl; - std::vector vData; - const OHOS::USB::UsbCtrlTransfer tctrl = {REQUESTYPE, REQUESTCMD, VALUE, 0, TIMEOUT}; - int ret = Instran.ControlTransfer(pip, tctrl, vData); - if (ret != 0) { - std::cout << "control message read failed width ret = " << ret << std::endl; - } else { - } - std::cout << "control message read success" << std::endl; - - return ret; -} - -int ClaimTest(OHOS::USB::UsbSrvClient &Instran, - OHOS::USB::USBDevicePipe &pip, - OHOS::USB::UsbInterface &interface, - bool interfaceFlg) -{ - if (interfaceFlg) { - std::cout << "ClaimInterface InterfaceInfo:" << interface.ToString() << std::endl; - int ret = Instran.ClaimInterface(pip, interface, true); - if (ret != 0) { - std::cout << "ClaimInterface failed width ret = " << ret << std::endl; - } else { - std::cout << "ClaimInterface success" << std::endl; - } - } - return 0; -} - -int BulkTransferTest(OHOS::USB::UsbSrvClient &Instran, - OHOS::USB::USBDevicePipe &pip, - OHOS::USB::USBEndpoint &outEp, - bool interfaceFlg, - bool outEpFlg) -{ - if (interfaceFlg) { - std::cout << "usb_device_test : << Bulk transfer start >> " << std::endl; - if (outEpFlg) { - uint8_t buffer[50] = "hello world 123456789"; - std::vector vData(buffer, buffer + BUFFERLENGTH); - int ret = Instran.BulkTransfer(pip, outEp, vData, TIMEOUT); - if (ret != 0) { - std::cout << "Bulk transfer write failed width ret = " << ret << std::endl; - } else { - std::cout << "Bulk transfer write success" << std::endl; - } - return ret; - } - } - return 0; -} - -int main(int argc, char **argv) -{ - std::cout << "usb_device_test " << std::endl; - static OHOS::USB::UsbSrvClient &Instran = OHOS::USB::UsbSrvClient::GetInstance(); - // GetDevices - std::vector deviceList; - int32_t ret = Instran.GetDevices(deviceList); - if (ret != 0) { - return OHOS::USB::UEC_SERVICE_INVALID_VALUE; - } - if (deviceList.empty()) { - return OHOS::USB::UEC_SERVICE_INVALID_VALUE; - } - - OHOS::USB::UsbDevice device = deviceList[0]; - std::vector configs = device.GetConfigs(); - OHOS::USB::USBConfig config = configs[0]; - std::vector interfaces = config.GetInterfaces(); - OHOS::USB::UsbInterface interface; - OHOS::USB::USBEndpoint outEp; - bool interfaceFlg = false; - bool outEpFlg = false; - interfaceFlg = SelectEndpoint(config, interfaces, interface, outEp, outEpFlg); - - // OpenDevice - std::cout << "usb_device_test : << OpenDevice >> test begin -> " << std::endl; - OHOS::USB::USBDevicePipe pip; - ret = OpenDeviceTest(Instran, device, pip); - if (ret != 0) { - return OHOS::USB::UEC_SERVICE_INVALID_VALUE; - } - - // ControlTransfer - CtrTransferTest(Instran, pip); - - // ClaimInterface - ClaimTest(Instran, pip, interface, interfaceFlg); - - // BulkTransferWrite - BulkTransferTest(Instran, pip, outEp, interfaceFlg, outEpFlg); - - // CloseDevice - std::cout << "usb_device_test : << Close Device >> " << std::endl; - ret = Instran.Close(pip); - if (ret == 0) { - std::cout << "Close device failed width ret = " << ret << std::endl; - return OHOS::USB::UEC_SERVICE_INVALID_VALUE; - } else { - std::cout << "Close Device success" << std::endl; - } - return 0; -} -``` - - diff --git a/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md b/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md deleted file mode 100644 index ea46f8f7e445897feb58684f702ef578e466a8f8..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md +++ /dev/null @@ -1,51 +0,0 @@ -# USB服务子系统使用指导 - - -下面使用步骤以bulktransfer为例。 - -使用步骤 - -1. 获取usb service实例 - - ```cpp - static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance(); - ``` - -2. 获取usb设备列表 - - ```cpp - std::vector deviceList; - int32_t ret = g_usbClient.GetDevices(deviceList); - ``` - -3. 申请设备权限 - - ```cpp - int32_t ret = g_usbClient.RequestRight(device.GetName()); - ``` - -4. 打开设备 - - ```cpp - USBDevicePipe pip; - int32_t et = g_usbClient.OpenDevice(device, pip); - ``` - -5. 配置设备接口 - - ```cpp - ret = g_usbClient.ClaimInterface(pip, interface, true); //interface为deviceList中device的interface。 - ``` - -6. 数据传输 - - ```cpp - srvClient.BulkTransfer(pipe, endpoint, vdata, timeout); - ``` - pipe为打开设备后的数据传输通道,endpoint为device中数据传输的端点,vdata是需要传输或读取的二进制数据块,timeout为传输超时时长。 - -7. 关闭设备 - - ```cpp - ret = g_usbClient.Close(pip); - ``` diff --git a/zh-cn/device-dev/subsystems/subsys-usbservice-overview.md b/zh-cn/device-dev/subsystems/subsys-usbservice-overview.md deleted file mode 100644 index d3bf8b07e67ce76f23a2b66a6add3887cbe522cf..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-usbservice-overview.md +++ /dev/null @@ -1,338 +0,0 @@ -# USB服务 - -## 概述 - -### 功能简介 - -USB设备分为Host设备(主机设备)和Device设备(从设备)。用户可通过Port Service来根据实际业务把运行OpenHarmony的设备切换为Host设备或者Device设备。目前在Host模式下,支持获取USB设备列表,USB设备权限管理,控制传输、批量传输的同异步数据传输等,在Device模式下,支持HDC(调试)、ACM(串口)、ECM(网口)等功能的切换。 - -### 基本概念 - -- USB服务 - - USB服务是应用访问底层的一种设备抽象概念。开发者根据提供的USB API,可以获取设备列表、控制设备访问权限、以及与连接的设备进行数据传输、控制命令传输等。 - -- USB API - - 基于USB Service服务,使用NAPI技术,向上提供JS接口。提供USB的基础API,主要包含查询USB设备的列表、设备插拔通知、USB HOST/DEVICE 功能切换、批量数据传输、控制命令传输、USB设备打开的权限控制及USB device模式下的function功能切换等。 - -- USB Service - - 使用C++代码实现,包含Host、Device、Port、Right四个模块。基于HDI接口,主要实现USB设备列表管理、Function 管理、Port管理、USB设备权限管理等功能。主要实现HAL层数据接收、解析、分发,前后台的策略管控,对该设备USB的管理,USB权限管控等。 - -- USB HAL - - 使用C代码实现,基于Host DDK(Driver Develop Kit)和Device DDK,封装了对USB设备的基本操作,向上提供C++接口,同时通过HDF框架接收内核上报的信息。 - -### 运作机制 - -USB服务系统包含USB API、USB Service、USB HAL。 - - **图1** USB服务架构图 - ![zh-cn_image_0000001267088285](figures/zh-cn_image_0000001267088285.png) - -- USB API:提供USB的基础API,主要包含查询USB设备列表、批量数据传输、控制命令传输、权限控制等。 - -- USB Service:主要实现HAL层数据的接收、解析、分发,前后台的策略管控以及对设备的管理等。 - -- USB HAL层:提供给用户态可直接调用的驱动能力接口。 - -## 使用指导 - -### 场景介绍 - -Host模式下,可以获取到已经连接的设备列表,并根据需要打开和关闭设备、控制设备权限、进行数据传输等。 - -### 接口说明 - - **表1** Host部分 - -| 接口名称 | 功能描述 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| int32_t OpenDevice(const UsbDevice &device, USBDevicePipe &pip); | 打开USB设备,建立连接 | -| bool HasRight(std::string deviceName); | 判断是否有权访问设备 | -| int32_t RequestRight(std::string deviceName); | 请求给定软件包的临时权限以访问设备 | -| int32_t GetDevices(std::vector &deviceList); | 获取USB设备列表 | -| int32_t ClaimInterface(USBDevicePipe &pip, const UsbInterface &interface, bool force); | 打开接口,并申明独占接口,必须在数据传输前执行 | -| int32_t ReleaseInterface(USBDevicePipe &pip, const UsbInterface &interface); | 关闭接口,释放接口的占用,在停止数据传输后执行 | -| int32_t BulkTransfer(USBDevicePipe &pip, const USBEndpoint &endpoint, std::vector &vdata, int32_t timeout); | 在给定端点上执行批量数据传输, 返回读取或发送的数据长度,通过端点方向确定读取或发送数据 | -| int32_t ControlTransfer(USBDevicePipe &pip, const UsbCtrlTransfer &ctrl, std::vector &vdata); | 对此设备执行端点零的控制事务,传输方向由请求类型决定 | -| int32_t SetConfiguration(USBDevicePipe &pip, const USBConfig &config); | 设置设备当前使用的配置,通过配置值进行指定 | -| int32_t SetInterface(USBDevicePipe &pipe, const UsbInterface &interface); | 设置指定接口的备选设置,用于在具有相同ID但不同备用设置的两个接口之间进行选择 | -| int32_t GetRawDescriptors(std::vector &vdata); | 获取原始的USB描述符 | -| int32_t GetFileDescriptor(); | 获取文件描述符 | -| bool Close(const USBDevicePipe &pip); | 关闭设备,释放与设备相关的所有系统资源 | -| int32_t PipeRequestWait(USBDevicePipe &pip, int64_t timeout, UsbRequest &req); | 获取异步传输结果 | -| int32_t RequestInitialize(UsbRequest &request); | 初始化异步数据传输request | -| int32_t RequestFree(UsbRequest &request); | 释放异步数据传输request | -| int32_t RequestAbort(UsbRequest &request); | 取消待处理的数据请求 | -| int32_t RequestQueue(UsbRequest &request); | 将指定的端点进行异步数据发送或者接收请求,数据传输方向由端点方向决定 | -| int32_t RegBulkCallback(USBDevicePipe &pip, const USBEndpoint &endpoint, const sptr &cb); | 注册批量传输异步回调函数 | -| int32_t UnRegBulkCallback(USBDevicePipe &pip, const USBEndpoint &endpoint); | 注销批量传输异步回调函 | -| int32_t BulkRead(USBDevicePipe &pip, const USBEndpoint &endpoint, sptr &ashmem); | 批量传输异步读数据 | -| int32_t BulkWrite(USBDevicePipe &pip, const USBEndpoint &endpoint, sptr &ashmem); | 批量传输异步写 | -| int32_t BulkCancel(USBDevicePipe &pip, const USBEndpoint &endpoint); | 批量传输异步取消接口,用于取消当前接口的异步批量读写操作 | - - **表2** Device部分 - -| 接口名称 | 功能描述 | -| -------------------------------------------------- | ------------------------------------------------------ | -| int32_t GetCurrentFunctions(int32_t &funcs); | 获取设备模式下的当前USB功能列表的数字组合掩码 | -| int32_t SetCurrentFunctions(int32_t funcs); | 在设备模式下设置当前的USB功能列表 | -| int32_t UsbFunctionsFromString(std::string funcs); | 将给定的功能列表描述字符串转换为功能列表的数字组合掩码 | -| std::string UsbFunctionsToString(int32_t funcs); | 将给定的功能列表的数字组合掩码转换为功能列表描述字符串 | - - **表3** Port部分 - -| 接口名称 | 功能描述 | -| ------------------------------------------------------------ | -------------------------------------------------------- | -| int32_t GetSupportedModes(int32_t portId, int32_t &supportedModes); | 获取指定的端口支持的模式列表的组合掩码 | -| int32_t SetPortRole(int32_t portId, int32_t powerRole, int32_t dataRole); | 设置指定的端口支持的角色模式,包含充电角色、数据传输角色 | -| int32_t GetPorts(std::vector &usbPorts); | 获取物理USB端口描述信息列表 | - -### USB服务子系统使用步骤 - -以bulktransfer为例。 - -1. 获取usb service实例。 - - ```cpp - static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance(); - ``` - -2. 获取usb设备列表。 - - ```cpp - std::vector deviceList; - int32_t ret = g_usbClient.GetDevices(deviceList); - ``` - -3. 申请设备权限。 - - ```cpp - int32_t ret = g_usbClient.RequestRight(device.GetName()); - ``` - -4. 打开设备。 - - ```cpp - USBDevicePipe pip; - int32_t et = g_usbClient.OpenDevice(device, pip); - ``` - -5. 配置设备接口。 - - ```cpp - //interface为deviceList中device的interface。 - ret = g_usbClient.ClaimInterface(pip, interface, true); - ``` - -6. 数据传输。 - - ```cpp - // pipe为打开设备后的数据传输通道,endpoint为device中数据传输的端点,vdata是需要传输或读取的二进制数据块,timeout为传输超时时长。 - srvClient.BulkTransfer(pipe, endpoint, vdata, timeout); - ``` - -7. 关闭设备。 - - ```cpp - ret = g_usbClient.Close(pip); - ``` - -### USB服务子系统使用实例 - -```cpp -#include -#include -#include -#include -#include -#include -#include "if_system_ability_manager.h" -#include "ipc_skeleton.h" -#include "iremote_object.h" -#include "iservice_registry.h" -#include "iusb_srv.h" -#include "string_ex.h" -#include "system_ability_definition.h" -#include "usb_common.h" -#include "usb_device.h" -#include "usb_errors.h" -#include "usb_request.h" -#include "usb_server_proxy.h" -#include "usb_srv_client.h" - -const int32_t REQUESTYPE = ((1 << 7) | (0 << 5) | (0 & 0x1f)); -const int32_t REQUESTCMD = 6; -const int32_t VALUE = (2 << 8) + 0; -const int32_t TIMEOUT = 5000; -const int32_t ITFCLASS = 10; -const int32_t PRAMATYPE = 2; -const int32_t BUFFERLENGTH = 21; - -void GetType(OHOS::USB::USBEndpoint &tep, OHOS::USB::USBEndpoint &outEp, bool &outEpFlg) -{ - if ((tep.GetType() == PRAMATYPE)) { - if (tep.GetDirection() == 0) { - outEp = tep; - outEpFlg = true; - } - } -} - -bool SelectEndpoint(OHOS::USB::USBConfig config, - std::vector interfaces, - OHOS::USB::UsbInterface &interface, - OHOS::USB::USBEndpoint &outEp, - bool &outEpFlg) -{ - for (int32_t i = 0; i < config.GetInterfaceCount(); ++i) { - OHOS::USB::UsbInterface tif = interfaces[i]; - std::vector mEndpoints = tif.GetEndpoints(); - for (int32_t j = 0; j < tif.GetEndpointCount(); ++j) { - OHOS::USB::USBEndpoint tep = mEndpoints[j]; - if ((tif.GetClass() == ITFCLASS) && (tif.GetSubClass() == 0) && (tif.GetProtocol() == PRAMATYPE)) { - GetType(tep, outEp, outEpFlg); - } - } - if (outEpFlg) { - interface = interfaces[i]; - return true; - } - std::cout << std::endl; - } - return false; -} - -int OpenDeviceTest(OHOS::USB::UsbSrvClient &Instran, OHOS::USB::UsbDevice device, OHOS::USB::USBDevicePipe &pip) -{ - int ret = Instran.RequestRight(device.GetName()); - std::cout << "device RequestRight ret = " << ret << std::endl; - if (0 != ret) { - std::cout << "device RequestRight failed = " << ret << std::endl; - } - ret = Instran.OpenDevice(device, pip); - return ret; -} - -int CtrTransferTest(OHOS::USB::UsbSrvClient &Instran, OHOS::USB::USBDevicePipe &pip) -{ - std::cout << "usb_device_test : << Control Transfer >> " << std::endl; - std::vector vData; - const OHOS::USB::UsbCtrlTransfer tctrl = {REQUESTYPE, REQUESTCMD, VALUE, 0, TIMEOUT}; - int ret = Instran.ControlTransfer(pip, tctrl, vData); - if (ret != 0) { - std::cout << "control message read failed width ret = " << ret << std::endl; - } else { - } - std::cout << "control message read success" << std::endl; - - return ret; -} - -int ClaimTest(OHOS::USB::UsbSrvClient &Instran, - OHOS::USB::USBDevicePipe &pip, - OHOS::USB::UsbInterface &interface, - bool interfaceFlg) -{ - if (interfaceFlg) { - std::cout << "ClaimInterface InterfaceInfo:" << interface.ToString() << std::endl; - int ret = Instran.ClaimInterface(pip, interface, true); - if (ret != 0) { - std::cout << "ClaimInterface failed width ret = " << ret << std::endl; - } else { - std::cout << "ClaimInterface success" << std::endl; - } - } - return 0; -} - -int BulkTransferTest(OHOS::USB::UsbSrvClient &Instran, - OHOS::USB::USBDevicePipe &pip, - OHOS::USB::USBEndpoint &outEp, - bool interfaceFlg, - bool outEpFlg) -{ - if (interfaceFlg) { - std::cout << "usb_device_test : << Bulk transfer start >> " << std::endl; - if (outEpFlg) { - uint8_t buffer[50] = "hello world 123456789"; - std::vector vData(buffer, buffer + BUFFERLENGTH); - int ret = Instran.BulkTransfer(pip, outEp, vData, TIMEOUT); - if (ret != 0) { - std::cout << "Bulk transfer write failed width ret = " << ret << std::endl; - } else { - std::cout << "Bulk transfer write success" << std::endl; - } - return ret; - } - } - return 0; -} - -int main(int argc, char **argv) -{ - std::cout << "usb_device_test " << std::endl; - static OHOS::USB::UsbSrvClient &Instran = OHOS::USB::UsbSrvClient::GetInstance(); - // GetDevices - std::vector deviceList; - int32_t ret = Instran.GetDevices(deviceList); - if (ret != 0) { - return OHOS::USB::UEC_SERVICE_INVALID_VALUE; - } - if (deviceList.empty()) { - return OHOS::USB::UEC_SERVICE_INVALID_VALUE; - } - - OHOS::USB::UsbDevice device = deviceList[0]; - std::vector configs = device.GetConfigs(); - OHOS::USB::USBConfig config = configs[0]; - std::vector interfaces = config.GetInterfaces(); - OHOS::USB::UsbInterface interface; - OHOS::USB::USBEndpoint outEp; - bool interfaceFlg = false; - bool outEpFlg = false; - interfaceFlg = SelectEndpoint(config, interfaces, interface, outEp, outEpFlg); - - // OpenDevice - std::cout << "usb_device_test : << OpenDevice >> test begin -> " << std::endl; - OHOS::USB::USBDevicePipe pip; - ret = OpenDeviceTest(Instran, device, pip); - if (ret != 0) { - return OHOS::USB::UEC_SERVICE_INVALID_VALUE; - } - - // ControlTransfer - CtrTransferTest(Instran, pip); - - // ClaimInterface - ClaimTest(Instran, pip, interface, interfaceFlg); - - // BulkTransferWrite - BulkTransferTest(Instran, pip, outEp, interfaceFlg, outEpFlg); - - // CloseDevice - std::cout << "usb_device_test : << Close Device >> " << std::endl; - ret = Instran.Close(pip); - if (ret == 0) { - std::cout << "Close device failed width ret = " << ret << std::endl; - return OHOS::USB::UEC_SERVICE_INVALID_VALUE; - } else { - std::cout << "Close Device success" << std::endl; - } - return 0; -} -``` - -### 参考手册 - -[驱动子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E9%A9%B1%E5%8A%A8%E5%AD%90%E7%B3%BB%E7%BB%9F.md) - -[drivers\_peripheral](https://gitee.com/openharmony/drivers_peripheral/blob/master/README_zh.md) - -[drivers\_framework](https://gitee.com/openharmony/drivers_framework/blob/master/README_zh.md) - -[drivers\_adapter](https://gitee.com/openharmony/drivers_adapter/blob/master/README_zh.md) - -[drivers\_adapter\_khdf\_linux](https://gitee.com/openharmony/drivers_adapter_khdf_linux/blob/master/README_zh.md) \ No newline at end of file diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md index 221a960eb6e41f361cddaf2663aefb7afdb61026..8585b5294294a8c3a86b0fc73f69997332486bd2 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -418,21 +418,10 @@ - [音视频录制开发指导](subsystems/subsys-multimedia-video-record-guide.md) - [公共基础库开发指导](subsystems/subsys-utils-guide.md) - [AI框架开发指导](subsystems/subsys-ai-aiframework-devguide.md) - - 数据管理 - - 关系型数据库 - - [关系型数据库概述](subsystems/subsys-data-relational-database-overview.md) - - [关系型数据库开发指导](subsystems/subsys-data-relational-database-guide.md) - - 轻量级数据存储 - - [轻量级数据存储概述](subsystems/subsys-data-storage-overview.md) - - [轻量级数据存储开发指导](subsystems/subsys-data-storage-guide.md) - Sensor服务 - [Sensor服务概述](subsystems/subsys-sensor-overview.md) - [Sensor服务使用指导](subsystems/subsys-sensor-guide.md) - [Sensor服务使用实例](subsystems/subsys-sensor-demo.md) - - USB服务 - - [USB服务概述](subsystems/subsys-usbservice-overview.md) - - [USB服务使用指导](subsystems/subsys-usbservice-guide.md) - - [USB服务使用实例](subsystems/subsys-usbservice-demo.md) - 用户程序框架 - [概述](subsystems/subsys-application-framework-overview.md) - [搭建环境](subsystems/subsys-application-framework-envbuild.md) 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 6f9c571461072ad5b20c7131570c3848b8046d17..f8ce7de1145bfd293d218a1546675ef1114b54e7 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" @@ -230,6 +230,4 @@ Linux: [kernel\_linux\_build](https://gitee.com/openharmony/kernel_linux_build/blob/master/README_zh.md) -[kernel\_linux\_4.19](https://gitee.com/openharmony/kernel_linux_4.19/blob/master/README) - [kernel\_linux\_5.10](https://gitee.com/openharmony/kernel_linux_5.10/blob/master/README) diff --git "a/zh-cn/readme/\345\214\205\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\345\214\205\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" index 6e03c53b4051934c2b75bd342be154f6e0153c5b..cef954a720be1813449838a97ecbed052b4ff74d 100755 --- "a/zh-cn/readme/\345\214\205\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\345\214\205\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" @@ -179,6 +179,8 @@ bm get -u 包管理子系统 -[**appexecfwk_standard**](https://gitee.com/openharmony/appexecfwk_standard) +[**bundlemanager_bundle_framework**](https://gitee.com/openharmony/bundlemanager_bundle_framework) + +[**bundlemanager_bundle_framework_lite**](https://gitee.com/openharmony/bundlemanager_bundle_framework_lite) [developtools_packing_tool](https://gitee.com/openharmony/developtools_packing_tool) diff --git "a/zh-cn/readme/\345\233\276\345\275\242\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\345\233\276\345\275\242\345\255\220\347\263\273\347\273\237.md" index f8497b863dc38fe4ebc66f62db2131c1a97ec2ee..080320478a8afbeb377f74a07522fe0bd77da36e 100644 --- "a/zh-cn/readme/\345\233\276\345\275\242\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\345\233\276\345\275\242\345\255\220\347\263\273\347\273\237.md" @@ -123,7 +123,7 @@ foundation/graphic/standard/ **图形子系统** -- [**graphic_graphic_2d**](https://gitee.com/abbuu_openharmony/graphic_graphic_2d) +- [**graphic_graphic_2d**](https://gitee.com/openharmony/graphic_graphic_2d) - [arkui_ace_engine](https://gitee.com/openharmony/arkui_ace_engine) - [ability_ability_runtime](https://gitee.com/openharmony/ability_ability_runtime) - [multimedia_player_framework](https://gitee.com/openharmony/multimedia_player_framework) diff --git a/zh-cn/release-notes/OpenHarmony-v3.1.3-release.md b/zh-cn/release-notes/OpenHarmony-v3.1.3-release.md index 493b77b534ac0e867c7cd417067022a983b1df0c..47b48ac3385903392c30a14f651ecdd58817bfe6 100644 --- a/zh-cn/release-notes/OpenHarmony-v3.1.3-release.md +++ b/zh-cn/release-notes/OpenHarmony-v3.1.3-release.md @@ -13,7 +13,7 @@ | 软件 | 版本 | 备注 | | -------- | -------- | -------- | | OpenHarmony | 3.1.3 Release | NA | -| Full SDK | Ohos_sdk_full 3.1.7.7 (API Version 8 Relese) | 面向OEM厂商提供,包含了需要使用系统权限的系统接口。
使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)。 | +| Full SDK | Ohos_sdk_full 3.1.7.7 (API Version 8 Release) | 面向OEM厂商提供,包含了需要使用系统权限的系统接口。
使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](../application-dev/quick-start/full-sdk-switch-guide.md)。 | | Public SDK | Ohos_sdk_public 3.1.7.7 (API Version 8 Release) | 面向应用开发者提供,不包含需要使用系统权限的系统接口。
DevEco Studio 3.0 Beta4版本起,通过DevEco Studio获取的SDK默认为Public SDK。 | | HUAWEI DevEco Studio(可选) | 3.0 Release for OpenHarmony | OpenHarmony应用开发推荐使用。 | | HUAWEI DevEco Device Tool(可选) | 3.0 Release | OpenHarmony智能设备集成开发环境推荐使用。 | diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-bundlemanager.md b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-bundlemanager.md new file mode 100644 index 0000000000000000000000000000000000000000..8cb911d0fe15bf51e1a612d63010d50849b2ffc5 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-bundlemanager.md @@ -0,0 +1,60 @@ +# 包管理子系统ChangeLog + +## cl.bundlemanager.1 app.json配置文件删除atomicService标签 +删除配置文件app.json中atomicService标签 + +**变更影响**
+删除配置文件app.json中atomicService标签,IDE中不再支持配置该标签,使用该标签会导致IDE编译报错 + +**适配指导**
+删除atomicService标签 + +## cl.bundlemanager.2 app.json配置文件新增bundleType标签 +配置文件app.json中新增bundleType标签 + +**变更影响**
+现存的元服务([installationFree](../../../application-dev/quick-start/module-configuration-file.md)为true),必须在app.json中指定bundleType为atomicService,否则打包失败。 + +**适配指导**
+新增[bundleType](../../../application-dev/quick-start/app-configuration-file.md)标签。该标签为可缺省(缺省值为app)。该标签需要和module.json中[installationFree](../../../application-dev/quick-start/module-configuration-file.md)字段保持一一对应,其相应规则为: +- 当bundleType为app时,installationFree必须为false。 +- 当bundleType为atomicService时,installationFree必须为true。 + +## cl.bundlemanager.3 包管理ApplicationInfo结构体中删除split字段。 + +包管理[ApplicationInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/ApplicationInfo.d.ts)结构体中删除split字段。 + +**变更影响**
+使用之前已发布的API 9各beta版本且使用到了split的,会编译失败。 + +**关键的接口/组件变更**
+包管理[ApplicationInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/ApplicationInfo.d.ts)结构体中删除split字段。 + +**适配指导**
+删除ApplicationInfo结构体中的split字段。目前元服务中stage模型强制分包,不支持不分包。 + +## cl.bundlemanager.4 包管理HapModuleInfo结构体中删除atomicServiceModuleType字段。 + +包管理[HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts)结构体中删除atomicServiceModuleType字段。 + +**变更影响**
+使用之前已发布的API 9各beta版本且使用到了atomicServiceModuleType的,会编译失败。 + +**关键的接口/组件变更**
+包管理[HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts)结构体中删除atomicServiceModuleType字段。 + +**适配指导**
+删除[HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts)结构体中的atomicServiceModuleType字段。判断atomicServiceModuleType字段的部分,用[HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts)结构体中的moduleType代替。 + +## cl.bundlemanager.5 包管理删除AtomicServiceModuleType枚举值。 + +包管理[HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts)结构体中删除atomicServiceModuleType字段。 + +**变更影响**
+使用之前已发布的API 9各beta版本且使用到了atomicServiceModuleType的,会编译失败。 + +**关键的接口/组件变更**
+包管理[HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts)结构体中删除atomicServiceModuleType字段。 + +**适配指导**
+删除[HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts)结构体中的atomicServiceModuleType字段。判断atomicServiceModuleType字段的部分,用[HapModuleInfo](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/bundleManager/HapModuleInfo.d.ts)结构体中的moduleType代替。 \ No newline at end of file diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-imf.md b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-imf.md new file mode 100644 index 0000000000000000000000000000000000000000..a6cdab6b8d7e7fc6a97698ce9b2e2a84ba32076a --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-imf.md @@ -0,0 +1,21 @@ +# 输入法框架子系统-输入法框架服务ChangeLog + + +## @ohos.InputMethodSubtype 中输入法子类型中name、label、id属性值变更 +从API9开始,变更如上三个属性值 + +开发者需要根据以下说明对应用进行适配。 + +**变更影响** + +此三个属性的取值发生变化,需要开发者进行适配更新 + +| 名称 | 变更前 | 变更后 | +| -------- | -------- | -------- | +| label | (1)取值:输入法子类型的id。| (1)取值:输入法子类型的标签。| +| name | (1)说明:输入法子类型的名字;(2)取值:输入法子类型的标签。| (1)说明:输入法应用的包名;(2)取值:输入法应用的包名。| +| id | (1)取值:输入法应用的包名。| (1)取值:输入法子类型的id。| + +**适配指导** + +请按上述取值变更结果适配更新。 diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-wallpaper.md b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-wallpaper.md index d3b6dfdf0a1426295d9ebf5203962c3e3b3d09a6..13baab45851959398ccf4689543f91c5e1aa1d68 100644 --- a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-wallpaper.md +++ b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.12/changelog-wallpaper.md @@ -253,7 +253,7 @@ ``` -## cl.wallpaper.2 getIdSync、getFileSync、isChangeAllowed、isUserChangeAllowed、on、off接口废弃变更 +## cl.wallpaper.2 getIdSync、getFileSync、isChangeAllowed、isUserChangeAllowed、on、off、RgbaColor接口废弃变更 从API9开始,废弃此接口。 开发者需要根据以下说明对应用进行适配。 @@ -271,6 +271,12 @@ function isUserChangeAllowed(): boolean; function on(type: 'colorChange', callback: (colors: Array, wallpaperType: WallpaperType) => void): void; function off(type: 'colorChange', callback?: (colors: Array, wallpaperType: WallpaperType) => void): void; + interface RgbaColor { + red: number; + green: number; + blue: number; + alpha: number; + } ``` - 变更前: @@ -282,6 +288,12 @@ function isUserChangeAllowed(): boolean; function on(type: 'colorChange', callback: (colors: Array, wallpaperType: WallpaperType) => void): void; function off(type: 'colorChange', callback?: (colors: Array, wallpaperType: WallpaperType) => void): void; + interface RgbaColor { + red: number; + green: number; + blue: number; + alpha: number; + } ``` - 变更后:删除接口,停止对外开放。 diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-bundlemanager.md b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-bundlemanager.md index ee19ef727948307f189f19ef2857e3f02eb64c70..a35a20b092e9c8095deaaf85fb73ec575fcf936a 100644 --- a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-bundlemanager.md +++ b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-bundlemanager.md @@ -230,4 +230,10 @@ module.json配置文件中的ability的[name](../../../application-dev/quick-sta 删除配置文件module.json[distroFilter](../../../application-dev/quick-start/module-configuration-file.md)标签,IDE中不再支持配置该标签,使用该标签会导致IDE编译报错 **适配指导**
-删除module.json中[distroFilter](../../../application-dev/quick-start/module-configuration-file.md)标签,使用distributionFilter替代 \ No newline at end of file +删除module.json中[distroFilter](../../../application-dev/quick-start/module-configuration-file.md)标签,使用distributionFilter替代 + +## cl.bundlemanager.20 module.json配置文件中launchTypede标签standard模式修改为multiton +删除module.json中[launchType](../../../application-dev/quick-start/module-configuration-file.md)标签的standard模式修改为multiton + +**适配指导**
+删除module.json中[launchType](../../../application-dev/quick-start/module-configuration-file.md)标签的standard模式,使用multiton替代 \ No newline at end of file diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.9.3/changelogs-useriam.md b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.9.3/changelogs-useriam.md new file mode 100644 index 0000000000000000000000000000000000000000..e781172a332f8bc19c89d43cfa72c29eb8df44d3 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.9.3/changelogs-useriam.md @@ -0,0 +1,39 @@ +# 用户IAM子系统Changelog + +## cl.useriam.1 API9 GetVesion接口删除 + +为优化用户IAM接口,从当前版本开始做如下变更: + +用户IAM删除GetVersion(API 9)接口。 + +**变更影响** + +对用户IAM GetVersion(API 9)接口的使用有影响,需删除对此接口的调用,否则会调用失败。 + +**关键接口/组件变更** + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +| ---------------------- | ------------------- | ------------------------- | ------------------------ | +| ohos.userIAM.userAuth | function | getVersion() : number | 删除 | + +**适配指导** + +需删除对用户IAM GetVersion(API 9)接口的调用。 + +## cl.useriam.2 API8 GetVesion接口返回值变更 + +为统一用户IAM GetVersion(API 8)接口的返回值。从当前版本开始做如下变更: + +用户IAM GetVersion(API 8)接口的返回值由0变更为1。 + +**变更影响** + +对用户IAM GetVersion(API 8)接口的使用有影响,如应用校验了此接口的返回值,修改后校验不通过。 + +**关键接口/组件变更** + +用户IAM GetVersion(API 8)接口的返回值由0变更为1。 + +**适配指导** + +此接口已废弃,需删除对用户IAM GetVersion(API 8)接口的使用。 diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.5.2/changelogs-ability.md b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.5.2/changelogs-ability.md new file mode 100644 index 0000000000000000000000000000000000000000..ba5ef87f8bb33c7ffb56cba4e92e711f07248c79 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.5.2/changelogs-ability.md @@ -0,0 +1,64 @@ +# 元能力子系统ChangeLog + +## cl.ability.appRecovery新增saveAppState接口 + +新增接口saveAppState(context?: UIAbilityContext): boolean; + +**变更影响** + +基于OpenHarmony4.0.5.2及之后的SDK版本开发的应用,可以使用saveAppState接口传入指定Ability Context,实现主动保存指定的Ability状态。 + +**关键接口/组件变更** + +@ohos.app.ability.appRecovery.d.ts中新增saveAppState接口。 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +| -- | -- | -- | -- | +| @ohos.app.ability.appRecovery.d.ts | appRecovery | saveAppState(context?: UIAbilityContext): boolean; | 新增 | + +**适配指导** + +通过调用saveAppState传入UIAbility Context参数主动保存此指定的Ability的状态。 + +```ts +import appRecovery from '@ohos.app.ability.appRecovery'; +onBackground() { + hilog.info(0x0000, '[demo]', '%{public}s', 'EntryAbility onBackground'); + appRecovery.saveAppState(this.context) +} +``` +## cl.ability.appRecovery新增setRestartWant接口 + +新增接口setRestartWant(want: Want): void; + +**变更影响** + +基于OpenHarmony4.0.5.2及之后的SDK版本开发的应用,可以使用setRestartWant接口设置下次由恢复主动拉起场景下的Ability。 + +**关键接口/组件变更** + +@ohos.app.ability.appRecovery.d.ts中新增setRestartWant接口。 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +| -- | -- | -- | -- | +| @ohos.app.ability.appRecovery.d.ts | appRecovery | setRestartWant(want: Want): void; | 新增 | + +**适配指导** + +通过调用setRestartWant设置下次恢复到的指定Ability。 + +```ts +import appRecovery from '@ohos.app.ability.appRecovery'; +Button("启动到恢复Ability") + .fontSize(40) + .fontWeight(FontWeight.Bold) + .onClick(()=> { + // set restart want + let want = { + bundleName: "ohos.samples.recovery", + abilityName: "RecoveryAbility" + }; + + appRecovery.setRestartWant(want); + }) +``` \ No newline at end of file diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.5.3/changelog-imf.md b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.5.3/changelog-imf.md new file mode 100644 index 0000000000000000000000000000000000000000..a6cdab6b8d7e7fc6a97698ce9b2e2a84ba32076a --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.5.3/changelog-imf.md @@ -0,0 +1,21 @@ +# 输入法框架子系统-输入法框架服务ChangeLog + + +## @ohos.InputMethodSubtype 中输入法子类型中name、label、id属性值变更 +从API9开始,变更如上三个属性值 + +开发者需要根据以下说明对应用进行适配。 + +**变更影响** + +此三个属性的取值发生变化,需要开发者进行适配更新 + +| 名称 | 变更前 | 变更后 | +| -------- | -------- | -------- | +| label | (1)取值:输入法子类型的id。| (1)取值:输入法子类型的标签。| +| name | (1)说明:输入法子类型的名字;(2)取值:输入法子类型的标签。| (1)说明:输入法应用的包名;(2)取值:输入法应用的包名。| +| id | (1)取值:输入法应用的包名。| (1)取值:输入法子类型的id。| + +**适配指导** + +请按上述取值变更结果适配更新。 diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.5.3/changelog-wallpaper.md b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.5.3/changelog-wallpaper.md index d3b6dfdf0a1426295d9ebf5203962c3e3b3d09a6..13baab45851959398ccf4689543f91c5e1aa1d68 100644 --- a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.5.3/changelog-wallpaper.md +++ b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.5.3/changelog-wallpaper.md @@ -253,7 +253,7 @@ ``` -## cl.wallpaper.2 getIdSync、getFileSync、isChangeAllowed、isUserChangeAllowed、on、off接口废弃变更 +## cl.wallpaper.2 getIdSync、getFileSync、isChangeAllowed、isUserChangeAllowed、on、off、RgbaColor接口废弃变更 从API9开始,废弃此接口。 开发者需要根据以下说明对应用进行适配。 @@ -271,6 +271,12 @@ function isUserChangeAllowed(): boolean; function on(type: 'colorChange', callback: (colors: Array, wallpaperType: WallpaperType) => void): void; function off(type: 'colorChange', callback?: (colors: Array, wallpaperType: WallpaperType) => void): void; + interface RgbaColor { + red: number; + green: number; + blue: number; + alpha: number; + } ``` - 变更前: @@ -282,6 +288,12 @@ function isUserChangeAllowed(): boolean; function on(type: 'colorChange', callback: (colors: Array, wallpaperType: WallpaperType) => void): void; function off(type: 'colorChange', callback?: (colors: Array, wallpaperType: WallpaperType) => void): void; + interface RgbaColor { + red: number; + green: number; + blue: number; + alpha: number; + } ``` - 变更后:删除接口,停止对外开放。 diff --git a/zh-cn/release-notes/release-definitions/Release-version-definitions.md b/zh-cn/release-notes/release-definitions/Release-version-definitions.md old mode 100644 new mode 100755 index e17d819f8bb9cfb840b5268474c8490e96bef8ee..7a4f97ed628e69b48113fc3b52d32aa4fbbee13c --- a/zh-cn/release-notes/release-definitions/Release-version-definitions.md +++ b/zh-cn/release-notes/release-definitions/Release-version-definitions.md @@ -25,49 +25,31 @@ OpenHarmony社区Beta分支是在社区开发和演进过程中不定期从Maste OpenHarmony社区基于LTS/Release分支以patch形式合入少量补丁代码,用于解决单点bug、安全漏洞、以及其他必须的适配修改,经过集成验证之后发布的稳定可靠的标签版本。 -### 维护分支下载命令 +社区版本发布在:https://gitee.com/openharmony/docs/tree/master/zh-cn/release-notes -| 分支 | 下载命令(repo + https) | 下载命令(repo + ssh) | -| ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| 1.0.1-Release | repo init -u https://gitee.com/openharmony/manifest -b OpenHarmony_1.0.1_release -m default.xml --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull' | repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.1-Release -m default.xml --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull' | -| 3.0-LTS | repo init -u https://gitee.com/openharmony/manifest.git -b OpenHarmony-3.0-LTS --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull' | repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.0-LTS --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull' | -| 3.1-Release | repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.1-Release -m default.xml --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull' | repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.1-Release -m default.xml --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull' | - - - -## 维护策略 - -### 生命周期策略 - -OpenHarmony对已发布的LTS和Release分支提供生命周期管理服务,分为两个部分: - -#### 发布->停止主动维护: - -​ Release sig团队会定期规划维护标签版本计划,用于解决单点bug、安全漏洞、以及其他必须的修改,以此确保分支持续处于稳定可用状态。 +## 生命周期策略 -#### 停止主动维护->停止维护: +OpenHarmony社区依据《OpenHarmony版本生命周期管理》对Release和LTS分支提供维护和技术支持。 -​ Release sig团队不再主动规划和发布标签版本,仅对社区安全漏洞和严重缺陷在对应分支进行修复。 - -### LTS/Release分支维护策略 - -LTS分支:分支发布之日起,提供两年主动维护,并提供1.5年被动维护。 +### 维护时间表 -Release分支:分支发布之日起,提供一年主动维护,并提供一年被动维护。 +OpenHarmony目前已发布的LTS/Release分支的维护时间表如下: -### 分支合入管控策略 +| 分支名 | 分支类型 | 发布时间 | 停止主动维护 | 停止维护 | +| ------------- | -------- | --------- | ------------ | --------- | +| 1.0.1-Release | Release | 2021-3-30 | 2022-3-30 | 2023-3-30 | +| 3.0-LTS | LTS | 2021-9-30 | 2023-9-30 | 2025-3-30 | +| 3.1-Release | Release | 2022-3-30 | 2023-3-30 | 2024-3-30 | -LTS/Release分支发布后,Release sig团队负责其生命周期管理,在维护周期内,我们只接受安全问题、acts套件问题以及其他重大问题的修复及合入,对应分支的合入会严格管控。目前分支合入管控策略已生效,合入请求需要在committer审查通过后联系对应[owner](https://gitee.com/openharmony/community/blob/master/zh/BRANCHOWNER)评论approve后合入。 +分支下载命令如下: -### 维护时间表 +| 分支 | 下载命令(repo + https) | 下载命令(repo + ssh) | +| ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| 1.0.1-Release | repo init -u https://gitee.com/openharmony/manifest -b OpenHarmony_1.0.1_release -m default.xml --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull' | repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.1-Release -m default.xml --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull' | +| 3.0-LTS | repo init -u https://gitee.com/openharmony/manifest.git -b OpenHarmony-3.0-LTS --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull' | repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.0-LTS --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull' | +| 3.1-Release | repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.1-Release -m default.xml --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull' | repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.1-Release -m default.xml --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull' | -OpenHarmony目前已发布的LTS/Release分支的维护时间表如下: -| NO. | 分支名 | 分支类型 | 发布时间 | 停止主动维护 | 停止维护 | -| :--- | ------------- | :------- | :-------- | :----------- | :-------- | -| 1 | 1.0.1-Release | Release | 2021-3-30 | 2022-3-30 | 2023-3-30 | -| 2 | 3.0-LTS | LTS | 2021-9-30 | 2023-9-30 | 2025-3-30 | -| 3 | 3.1-Release | Release | 2022-3-30 | 2023-3-30 | 2024-3-30 | ### 版本计划 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 60222a480c852f19216688d99dda1dd9822005cc..22be4e935cf4b4388efdb3f4c443ff4ca7ad7c29 100644 --- a/zh-cn/third-party-components/npm-third-party-guide.md +++ b/zh-cn/third-party-components/npm-third-party-guide.md @@ -1,7 +1,7 @@ # 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静态共享包,即HAR(Harmony Archive),可以包含js/ts代码、c++库、资源和配置文件。通过HAR,可以实现多个模块或者多个工程共享ArkUI组件、资源等相关代码。HAR不同于HAP,不能独立安装运行在设备上,只能作为应用模块的依赖项被引用。 @@ -11,41 +11,164 @@ OpenHarmony JS和TS三方组件是以OpenHarmony npm包的形式,在传统的n -2. 访问[OpenHarmony官网](https://www.openharmony.cn/mainPlay/tpc),通过类型,分类,以及关键字搜索需要的三方组件。 +2. 访问[OpenHarmony官网](https://growing.openharmony.cn/mainPlay/tpc),通过类型,分类,以及关键字搜索需要的三方组件。 ![official-website.png](official-website.png) ## 安装并使用OpenHarmony JS和TS语言的三方组件 -在应用开发的过程中,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)。 - -2. 在Terminal项目终端中,进入entry目录,并执行目标组件命令进行安装。具体的下载命令详见OpenHarmony官网该三方组件的“下载安装“模块。 - - 以安装[vcard三方组件](https://growing.openharmony.cn/mainPlay/libraryMaps/vcard_595)为例,找到“下载安装”模块获取其安装命令,并执行该命令安装: - - ![npm-usage1.png](npm-usage1.png) - - ![npm-usage2.png](npm-usage2.png) - -3. 下载完成后在项目文件下自动生成node_modules文件,下载的三方库即node_modules目录下的@ohos\VCard。 - - ![npm-usage3.png](npm-usage3.png) - -4. 在package.json中会自动添加如下依赖: - - ``` - "dependencies": { - "@ohos/vcard": "^2.0.5" +引用三方HAR,包括从仓库进行安装和从本地库模块中进行安装两种方式。 + +**引用仓库安装的HAR** + +引用ohpm仓中的HAR,首先需要设置三方HAR的仓库信息,DevEco Studio默认仓库地址是"https://repo.harmonyos.com/ohpm/",如果您想设置自定义仓库,请在DevEco Studio的Terminal窗口执行如下命令进行设置(执行命令前,请确保将DevEco Studio中ohpm安装地址配置在“环境变量-系统变量-PATH”中): +``` +ohpm config set registry=your_registry1,your_registry2 +``` +说明:ohpm支持多个仓库地址,采用英文逗号分隔。 +然后通过如下两种方式设置三方包依赖信息: + - 方式一:在Terminal窗口中,执行如下命令安装三方包,DevEco Studio会自动在工程的oh-package.json5中自动添加三方包依赖。 +``` +ohpm install @ohos/lottie --save +``` + - 方式二:在工程的oh-package.json5中设置三方包依赖,配置示例如下: +``` +"dependencies": { "@ohos/lottie": "^2.0.0"} +``` +依赖设置完成后,需要执行ohpm install命令安装依赖包,依赖包会存储在工程的oh_modules目录下。 +``` +ohpm install +``` + +**引用本地库模块的文件和资源** + +- 方式一:在Terminal窗口中,执行如下命令进行安装,并会在oh-package5.json中自动添加依赖。 +``` +ohpm install ../library --save +``` +- 方式二:在工程的oh-package.json5中设置三方包依赖,配置示例如下: +``` +"dependencies": { + "@ohos/library": "file:../library" +} +``` +依赖设置完成后,需要执行ohpm install命令安装依赖包,依赖包会存储在工程的oh_modules目录下。 +``` +ohpm install +``` + +> **说明:** +> +> 在引用OpenHarmony HAR时,请注意以下事项 +>- 当前只支持在模块和工程下的oh-package.json5文件中声明dependencies依赖,才会被当做OpenHarmony依赖使用,并在编译构建过程中进行相应的处理。 +>- 引用的模块的compileSdkVersion不能低于其依赖的OpenHarmony ohpm三方包(可在oh_modules目录下,找到引用的ohpm包的src > main > module.json5 中查看)。 + + + +### 引用OpenHarmony HAR hml页面 +在JS工程范式中,组件功能由hml承载,开发者可以在JS工程的hml页面通过标签来引入OpenHarmony HAR中的共享hml页面,示例如下: +``` + +``` +其中,@ohos/library为OpenHarmony HAR的包名,hml页面的路径为OpenHarmony HAR中的相对路径。 +随后便可以通过设置的name来使用该element元素,以引用OpenHarmony HAR中的hml页面,示例如下: +```typescript + + +
+ + + {{ $t('strings.hello') }} {{ title }} + +
+``` +### 引用OpenHarmony HAR ArkTS页面 +ArkTS是TypeScript的扩展,因此导出和引入的语法与TypeScript一致。在OpenHarmony ohpm模块中,可以通过export导出ArkTS页面,示例如下: +```typescript +// library/src/main/ets/components/MainPage/MainPage.ets +@Entry +@Component +export struct MainPage { + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } .height('100%') } - ``` - -5. 在需要使用该组件的文件中导入组件。 - - ![npm-usage4.png](npm-usage4.png) - -6. 导入组件后直接使用方法即可。 - - ![npm-usage5.png](npm-usage5.png) \ No newline at end of file +} +``` +然后在其它模块中通过import引入导出的ArkTS页面,示例如下所示: +```typescript +// entry/MainAbility/pages/index.ets + +import { MainPage } from "@ohos/library" +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + build() { + Column() { + MainPage() + Row() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('10%') + } +} +``` +引用OpenHarmony HAR内ts/js方法ts/js方法的导出和引用,与ArkTS页面的引用相同,即在OpenHarmony ohpm模块中,可以通过export导出ts/js方法,示例如下所示: +```typescript +// library/index.js +export function func() { + return "[ohpm] func1"; +} +``` +然后在其它的ts/js页面中,通过import引入导出的ts/js方法,示例如下所示: +```typescript +// entry/src/main/js/MainAbility/pages/index/index.js +import {func} from "@ohos/library" +export default { + data: { + title: "" + }, + onInit() { + this.title = func(); + } +} +``` +引用OpenHarmony HAR内资源支持在OpenHarmony ohpm模块和依赖OpenHarmony ohpm的模块中引用OpenHarmony ohpm模块内的资源。例如在OpenHarmony ohpm模块的scr/main/resources里添加字符串资源(在string.json中定义,name:hello_ohpm)和图片资源(icon_ohpm.png)。然后在Entry模块中引用该字符串资源和图片资源的示例如下: +当前暂不支持类Web范式引用i18n文件中的国际化资源。 +```typescript +// entry/src/main/ets/MainAbility/pages/index.ets +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + build() { + Column() { + Row() { + Text($r("app.string.hello_ohpm")) // 字符串资源 + .fontSize(40) + .fontWeight(FontWeight.Bold) + } + .width('50%') + Image($r("app.media.icon_ohpm")) // 图片资源 + } + .height('100%') + } +} +``` +在编译构建HAP中,DevEco Studio会从HAP模块及依赖的模块中收集资源文件,如果不同模块的相同限定词目录下的资源文件出现重名冲突时,DevEco Studio会按照以下优先级进行覆盖(优先级由高到低): +- AppScope(仅API 9的Stage模型支持) +- HAP包自身模块 +- 依赖的OpenHarmonyHarmony ohpm模块 \ No newline at end of file diff --git a/zh-cn/third-party-components/npm-usage1.png b/zh-cn/third-party-components/npm-usage1.png deleted file mode 100644 index 9dc9a72717182136e77d620c90e45669c4059043..0000000000000000000000000000000000000000 Binary files a/zh-cn/third-party-components/npm-usage1.png and /dev/null differ diff --git a/zh-cn/third-party-components/npm-usage2.png b/zh-cn/third-party-components/npm-usage2.png deleted file mode 100644 index ce9e34ec18125ff473ad48667808081adc1a95d7..0000000000000000000000000000000000000000 Binary files a/zh-cn/third-party-components/npm-usage2.png and /dev/null differ diff --git a/zh-cn/third-party-components/npm-usage3.png b/zh-cn/third-party-components/npm-usage3.png deleted file mode 100644 index 66b6a14069cec3caaa42c0007f7b12ff09773f6f..0000000000000000000000000000000000000000 Binary files a/zh-cn/third-party-components/npm-usage3.png and /dev/null differ diff --git a/zh-cn/third-party-components/npm-usage4.png b/zh-cn/third-party-components/npm-usage4.png deleted file mode 100644 index 8cd881a7ddf90aed5570411c943794829c2fa24d..0000000000000000000000000000000000000000 Binary files a/zh-cn/third-party-components/npm-usage4.png and /dev/null differ diff --git a/zh-cn/third-party-components/npm-usage5.png b/zh-cn/third-party-components/npm-usage5.png deleted file mode 100644 index ec7f772f86dad4deb5f061f6e7cf6ac41748a225..0000000000000000000000000000000000000000 Binary files a/zh-cn/third-party-components/npm-usage5.png and /dev/null differ 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 31f1ab1bfd795ff7b8154455a16d59ca234cd494..aaa89c4fac1bb47e7689a963c46e8c62cc81e18a 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 HAR的方式引入,在应用开发中使用。另一种是C和C++语言的三方组件,通常以源码或OpenHarmony hpm包的方式引入,在应用开发中以NAPI的方式使用,或直接编译在OpenHarmony操作系统镜像中。