提交 454d29a4 编写于 作者: X xuzhihao 提交者: Gitee

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

Signed-off-by: Nxuzhihao <xuzhihao16@huawei.com>
...@@ -12,10 +12,13 @@ The **AccessibilityExtensionAbility** module provides accessibility extension ca ...@@ -12,10 +12,13 @@ The **AccessibilityExtensionAbility** module provides accessibility extension ca
This document is organized as follows: This document is organized as follows:
- [Creating an AccessibilityExtAbility File](#creating-an-accessibility-extension-service) - [AccessibilityExtensionAbility Development](#accessibilityextensionability-development)
- [Processing an Accessibility Event](#processing-an-accessibility-event) - [Creating an Accessibility Extension Service](#creating-an-accessibility-extension-service)
- [Declaring Capabilities of Accessibility Extension Services](#declaring-capabilities-of-accessibility-extension-services) - [Creating a Project](#creating-a-project)
- [Enabling a Custom Accessibility Extension Service](#enabling-a-custom-accessibility-extension-service) - [Creating an AccessibilityExtAbility File](#creating-an-accessibilityextability-file)
- [Processing an Accessibility Event](#processing-an-accessibility-event)
- [Declaring Capabilities of Accessibility Extension Services](#declaring-capabilities-of-accessibility-extension-services)
- [Enabling a Custom Accessibility Extension Service](#enabling-a-custom-accessibility-extension-service)
## Creating an Accessibility Extension Service ## Creating an Accessibility Extension Service
...@@ -79,13 +82,13 @@ You can also process physical key events in the accessibility extension service. ...@@ -79,13 +82,13 @@ You can also process physical key events in the accessibility extension service.
## Declaring Capabilities of Accessibility Extension Services ## Declaring Capabilities of Accessibility Extension Services
After developing the custom logic for an accessibility extension service, you must add the configuration information of the service to the corresponding module-level **module.json5** file in the project directory. In the file, the **srcEntrance** tag indicates the path to the accessibility extension service. Make sure the value of the **type** tag is fixed at **accessibility**. Otherwise, the connection to the service will fail. After developing the custom logic for an accessibility extension service, you must add the configuration information of the service to the corresponding module-level **module.json5** file in the project directory. In the file, the **srcEntry** tag indicates the path to the accessibility extension service. Make sure the value of the **type** tag is fixed at **accessibility**. Otherwise, the connection to the service will fail.
```json ```json
"extensionAbilities": [ "extensionAbilities": [
{ {
"name": "AccessibilityExtAbility", "name": "AccessibilityExtAbility",
"srcEntrance": "./ets/AccessibilityExtAbility/AccessibilityExtAbility.ts", "srcEntry": "./ets/AccessibilityExtAbility/AccessibilityExtAbility.ts",
"label": "$string:MainAbility_label", "label": "$string:MainAbility_label",
"description": "$string:MainAbility_desc", "description": "$string:MainAbility_desc",
"type": "accessibility", "type": "accessibility",
......
...@@ -22,8 +22,6 @@ A static subscriber is started once it receives a target event published by the ...@@ -22,8 +22,6 @@ A static subscriber is started once it receives a target event published by the
You can implement service logic in the **onReceiveEvent** callback. You can implement service logic in the **onReceiveEvent** callback.
2. Project Configuration for a Static Subscriber 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: After writing the static subscriber code, configure the subscriber in the **module.json5** file. The configuration format is as follows:
...@@ -35,12 +33,12 @@ A static subscriber is started once it receives a target event published by the ...@@ -35,12 +33,12 @@ A static subscriber is started once it receives a target event published by the
"extensionAbilities": [ "extensionAbilities": [
{ {
"name": "StaticSubscriber", "name": "StaticSubscriber",
"srcEntrance": "./ets/StaticSubscriber/StaticSubscriber.ts", "srcEntry": "./ets/StaticSubscriber/StaticSubscriber.ts",
"description": "$string:StaticSubscriber_desc", "description": "$string:StaticSubscriber_desc",
"icon": "$media:icon", "icon": "$media:icon",
"label": "$string:StaticSubscriber_label", "label": "$string:StaticSubscriber_label",
"type": "staticSubscriber", "type": "staticSubscriber",
"visible": true, "exported": true,
"metadata": [ "metadata": [
{ {
"name": "ohos.extension.staticSubscriber", "name": "ohos.extension.staticSubscriber",
...@@ -56,7 +54,7 @@ A static subscriber is started once it receives a target event published by the ...@@ -56,7 +54,7 @@ A static subscriber is started once it receives a target event published by the
Pay attention to the following fields in the JSON file: 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. - **srcEntry**: 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**. - **type**: ExtensionAbility type. For a static subscriber, set this field to **staticSubscriber**.
......
...@@ -60,15 +60,15 @@ To implement EnterpriseAdminExtensionAbility, you need to activate the device ad ...@@ -60,15 +60,15 @@ To implement EnterpriseAdminExtensionAbility, you need to activate the device ad
}; };
``` ```
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. 4. Register **ServiceExtensionAbility** in the [**module.json5**](../quick-start/module-configuration-file.md) file corresponding to the project module. Set **type** to **enterpriseAdmin** and **srcEntry** to the path of the ExtensionAbility code.
```ts ```ts
"extensionAbilities": [ "extensionAbilities": [
{ {
"name": "ohos.samples.enterprise_admin_ext_ability", "name": "ohos.samples.enterprise_admin_ext_ability",
"type": "enterpriseAdmin", "type": "enterpriseAdmin",
"visible": true, "exported": true,
"srcEntrance": "./ets/enterpriseextability/EnterpriseAdminAbility.ts" "srcEntry": "./ets/enterpriseextability/EnterpriseAdminAbility.ts"
} }
] ]
``` ```
......
...@@ -54,7 +54,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth ...@@ -54,7 +54,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth
1. **InputMethodService.ts** file: 1. **InputMethodService.ts** file:
In this file, add the dependency package for importing InputMethodExtensionAbility. Customize a class that inherits from InputMethodExtensionAbility and add the required lifecycle callbacks. In the **InputMethodService.ts** file, add the dependency package for importing InputMethodExtensionAbility. Customize a class that inherits from InputMethodExtensionAbility and add the required lifecycle callbacks.
```ts ```ts
import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility'; import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
...@@ -233,7 +233,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth ...@@ -233,7 +233,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth
Add the path to this file to the **src** field in the **resources/base/profile/main_pages.json** file. Add the path to this file to the **src** field in the **resources/base/profile/main_pages.json** file.
```ets ```ts
import { numberSourceListData, sourceListType } from './keyboardKeyData' import { numberSourceListData, sourceListType } from './keyboardKeyData'
@Component @Component
...@@ -342,7 +342,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth ...@@ -342,7 +342,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth
} }
``` ```
Register the InputMethodExtensionAbility in the [module.json5 file](../quick-start/module-configuration-file.md) corresponding to the target module. Set **type** to **"inputMethod"** and **srcEntrance** to the code path of the InputMethodExtensionAbility component. Register the InputMethodExtensionAbility in the [module.json5 file](../quick-start/module-configuration-file.md) corresponding to the target module. Set **type** to **"inputMethod"** and **srcEntry** to the code path of the InputMethodExtensionAbility component.
```ts ```ts
{ {
...@@ -353,9 +353,9 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth ...@@ -353,9 +353,9 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth
"description": "inputMethod", "description": "inputMethod",
"icon": "$media:icon", "icon": "$media:icon",
"name": "InputMethodExtAbility", "name": "InputMethodExtAbility",
"srcEntrance": "./ets/inputmethodextability/InputMethodService.ts", "srcEntry": "./ets/inputmethodextability/InputMethodService.ts",
"type": "inputMethod", "type": "inputMethod",
"visible": true, "exported": true,
} }
] ]
} }
......
# FAQs # FAQs
- [Programming Languages](faqs-language.md) - [Ability Development](faqs-ability.md)
- [Ability Framework Development](faqs-ability.md) - [Bundle Management Development](faqs-bundle-management.md)
- [Resource Manager Development](faqs-globalization.md) - [Resource Manager Development](faqs-globalization.md)
- [ArkUI (ArkTS) Development](faqs-ui-ets.md)
- [ArkUI Web Component (ArkTS) Development](faqs-web-arkts.md)
- [ArkUI (JavaScript) Development](faqs-ui-js.md)
- [Common Event and Notification Development](faqs-event-notification.md) - [Common Event and Notification Development](faqs-event-notification.md)
- [Graphics and Image Development](faqs-graphics.md) - [Graphics Development](faqs-graphics.md)
- [Media Development](faqs-media.md) - [Window Management Development](faqs-window-manager.md)
- [Multimedia Development](faqs-multimedia.md)
- [Basic Security Capability Development](faqs-security.md) - [Basic Security Capability Development](faqs-security.md)
- [Application Access Control Development](faqs-ability-access-control.md) - [Ability Access Control Development](faqs-ability-access-control.md)
- [Data Management Development](faqs-distributed-data-management.md) - [Data Management Development](faqs-distributed-data-management.md)
- [File Management Development](faqs-file-management.md) - [File Management Development](faqs-file-management.md)
- [Network Management Development](faqs-network-management.md) - [Network Management Development](faqs-network-management.md)
- [DFX Development](faqs-dfx.md) - [DFX Development](faqs-dfx.md)
- [Native API Usage](faqs-native.md) - [Pan-Sensor Development](faqs-sensor.md)
- [Startup Development](faqs-startup.md) - [Startup Development](faqs-startup.md)
- [Usage of Third- and Fourth-Party Libraries](faqs-third-party-library.md) - [Distributed Device Development](faqs-distributed-device-profile.md)
- [IDE Usage](faqs-ide.md) - [Usage of Third- and Fourth-Party Libraries](faqs-third-fourth-party-library.md)
\ No newline at end of file
# Application Access Control Development # Ability Access Control Development
## Can the app listen for the permission change after its permission is modified in Settings? ## Can the app listen for the permission change after its permission is modified in Settings?
......
# Bundle Management Development
## How do I determine whether an application is a system application?
Applicable to: OpenHarmony 3.2 Beta 5 (API version 9)
**Solution**
Use **bundleManager.getApplicationInfo** (available only for system applications) to obtain application information, and check the value of **systemApp** in the information. The application is a system application if the value is **true**.
**Reference**
[bundleManager](../reference/apis/js-apis-bundleManager.md)
## How do I obtain the version code and version name of an application?
Applicable to: OpenHarmony 3.2 Beta 5 (API version 9)
**Solution**
Use **bundleManager.getBundleInfoForSelf\(\)** to obtain the bundle information, which contains the version code (specified by **BundleInfo.versionCode**) and version name (specified by **BundleInfo.versionName**) .
**Example**
```
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
try {
bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
const versionCode = data.versionCode;
const versionName = data.versionName;
hilog.info(0x0000, 'testTag', `successfully. versionCode: ${versionCode}, versionName: ${versionName}`);
}).catch(err => {
hilog.error(0x0000, 'testTag', 'failed. Cause: %{public}s', err.message);
});
} catch (err) {
hilog.error(0x0000, 'testTag', 'failed: %{public}s', err.message);
}
```
**Reference**
[getBundleInfoForSelf](../reference/apis/js-apis-bundleManager.md#bundlemanagergetbundleinfoforself)
## How do I obtain the bundle name of the current application?
Applicable to: OpenHarmony 3.2 Beta5 (API version 9)
**Solution**
Obtain the bundle name from **UIAbilityContext.abilityInfo.bundleName**.
**Example**
```
import common from '@ohos.app.ability.common';
const context = getContext(this) as common.UIAbilityContext
console.log(`bundleName: ${context.abilityInfo.bundleName}`)
```
**Reference**
[UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontext) and [AbilityInfo](../reference/apis/js-apis-bundleManager-abilityInfo.md#abilityinfo)
## How do I obtain the application version number, version name, and screen resolution?
Applicable to: OpenHarmony 3.2 Beta5
**Solution**
1. Obtain the bundle information from the **@ohos.bundle.bundleManager** module.
The bundle information contains the application version number and version name.
```
import bundleManager from '@ohos.bundle.bundleManager';
...
bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION).then((bundleInfo)=>{
let versionName = bundleInfo.versionName; // Application version name.
let versionNo = bundleInfo.versionCode; // Application version number.
}).catch((error)=>{
console.error("get bundleInfo failed,error is "+error)
})
```
2. Obtain **screenDensity** from the **@ohos.app.ability.Configuration** module. **screenDensity** contains the screen resolution information.
```
import common from '@ohos.app.ability.common';
...
let context = getContext(this) as common.UIAbilityContext;
let screenDensity = context.config.screenDensity;
```
## How do I obtain the source file path of the current application?
Applicable to: OpenHarmony 3.2 Beta 5 (API version 9)
**Solution**
- Method 1: Use the application context to obtain the source file path.
```
this.uiAbilityContext.abilityInfo.applicationInfo.codePath
```
- Method 2: Use **@ohos.bundle.bundleManager** to obtain the source file path.
1. Import the **@ohos.bundle.bundleManager** module and use **bundleManager.getBundleInfoForSelf\(\)** to obtain the bundle information.
2. Obtain the source file path from **bundleInfo.appInfo.codePath**.
```
import bundleManager from '@ohos.bundle.bundleManager';
bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION).then((bundleInfo)=>{
this.sourcePath = bundleInfo.appInfo.codePath;
})
```
## Can I obtain the HAP information of other applications from the current application?
Applicable to: OpenHarmony 3.2 Beta (API version 9)
According to the OpenHarmony security design specifications, the SDK does not provide APIs for third-party applications to obtain bundle information (including but not limited to the application name and version number) of other applications.
# Bundle Management Development
## How do I obtain the version code and version name of an application?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
Use **bundle.getBundleInfo()** to obtain the bundle information, which contains the version code and version name.
Reference: [Bundle](../reference/apis/js-apis-Bundle.md#bundlegetbundleinfo)
## How do I obtain the bundle name of an application?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
Obtain the bundle name through **context.abilityInfo.bundleName**.
Reference: [AbilityInfo](../reference/apis/js-apis-bundle-AbilityInfo.md)
## How do I obtain an application icon?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
Use **bundle.getAbilityIcon** to obtain the application icon. To use this API, you must configure the permission **ohos.permission.GET_BUNDLE_INFO**.
Reference: [Bundle](../reference/apis/js-apis-Bundle.md#bundlegetbundleinfo)
## How do I determine whether an application is a system application?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
Use **bundle.getApplicationInfo** to obtain the application information, and then check the value of **systemApp** in the information. The application is a system application if the value is **true**.
# Distributed Device Development
## How do I view the IMEI of an OpenHarmony device?
Applicable to: OpenHarmony 3.2 Beta 5 (API version 9)
**Solution**
Obtain the device IMEI from the **HUKS\_TAG\_ATTESTATION\_ID\_IMEI** parameter of the **HuksTag** API. [Reference](../reference/apis/js-apis-huks.md)
# Graphics and Image Development # Graphics Development
## Why do the isStatusBarLightIcon and isNavigationBarLightIcon attributes not take effect when window.setSystemBarProperties() is called? ## How do I obtain the DPI of a device?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9 Applicable to: OpenHarmony 3.2 Beta5 (API version 9, stage model)
In effect, the **isStatusBarLightIcon** and **isNavigationBarLightIcon** attributes turn the font white when set to **true**. If **statusBarContentColor** is also set in **window.setSystemBarProperties()**, the **isStatusBarLightIcon** attribute does not take effect. Similarly, if **navigationBarContentColor** is set, the **isNavigationBarLightIcon** attribute does not take effect. **Solution**
## How do I set the style of the system bar? Import the **@ohos.display** module and call the **getDefaultDisplaySync\(\)** API.
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9 **Example**
Import the **\@ohos.window** module, and call **window.setSystemBarProperties()**. ```
import display from '@ohos.display';
let displayClass = null;
try {
displayClass = display.getDefaultDisplaySync();
console.info('Test densityDPI:' + JSON.stringify(displayClass.densityDPI));
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
```
## How do I hide the status bar to get the immersive effect? ## How do I hide the status bar to get the immersive effect?
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9 Applicable to: OpenHarmony 3.2 Beta5 (API version 9, stage model)
1. Use the **onWindowStageCreate** to obtain a **windowClass** object. **Solution**
```ts 1. Use **onWindowStageCreate** to obtain a **windowClass** object.
onWindowStageCreate(windowStage) {
// When the main window is created, set the main page for this ability. ```
console.log("[Demo] EntryAbility onWindowStageCreate") onWindowStageCreate(windowStage) {
windowStage.getMainWindow((err, data) => { // When the main window is created, set the main page for this ability.
if (err.code) { console.log("[Demo] MainAbility onWindowStageCreate")
console.error('Failed to obtain the main window.') windowStage.getMainWindow((err, data) => {
return; if (err.code) {
} console.error('Failed to obtain the main window.')
// Obtain a windowClass object. return;
globalThis.windowClass = data; }
}) // Obtain a windowClass object.
} globalThis.windowClass = data;
``` })
}
2. Enable the full-screen mode for the window and hide the status bar. ```
```ts 2. Enable the full-screen mode for the window and hide the status bar.
globalThis.windowClass.setFullScreen(isFullScreen, (err, data) => {
if (err.code) { ```
console.error('Failed to enable the full-screen mode. Cause:' + JSON.stringify(err)); globalThis.windowClass.setFullScreen(isFullScreen, (err, data) => {
return; if (err.code) {
} console.error('Failed to enable the full-screen mode. Cause:' + JSON.stringify(err));
console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); return;
}); }
``` console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data));
});
```
## How do I obtain the window width and height? ## How do I obtain the window width and height?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9 Applicable to: OpenHarmony SDK 3.2 Beta5 (API version 9, stage model)
Use **window.getProperties()** to obtain the window properties. The **windowRect** field in the properties specifies the window width and height. **Solution**
Example: Import the **@ohos.window** module, obtain a **Window** object, and use **getWindowProperties\(\)** of the object to obtain the window properties. The **windowRect** field in the properties specifies the window width and height.
**Example**
```ts
let promise = windowClass.getProperties();
promise.then((data)=> {
console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data.windowRect));
}).catch((err)=>{
console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
});
``` ```
import window from '@ohos.window';
## How do I set the color of the system bar? let windowClass = null;
try {
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 let promise = window.getLastWindow(this.context);
promise.then((data)=> {
Refer to the following code: // Obtain a Window object.
windowClass = data;
try {
```ts // Obtain the window properties.
window.getTopWindow(globalThis.mainContext).then(win => { let properties = windowClass.getWindowProperties();
var systemBarProperties = { let rect = properties.windowRect;
statusBarColor: '#19B6FF', // Set the background color of the status bar. // rect.width: window width; rect.height: window height.
navigationBarColor: '#19B6FF', // Set the background color of the navigation bar. } catch (exception) {
isStatusBarLightIcon: false, // Set the icon on the status bar not to be highlighted. console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
isNavigationBarLightIcon: true, // Set the icon on the navigation bar to be highlighted. }
statusBarContentColor: '#0D0500', // Set the text color of the status bar. console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
navigationBarContentColor: '#FFA500' // Set the text color of the navigation bar. }).catch((err)=>{
}; console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
win.setSystemBarProperties(systemBarProperties).catch(err => { });} catch (exception) {
INDEX_LOGGER.info(`set System Bar Properties failed:${err}`) console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}) }
})
.catch(err => {
INDEX_LOGGER.info(`get top window failed:${err}`)
})
``` ```
# IDE Usage
## What should I do if the error message "npm ERR! code SELF_SIGNED_CERT_IN_CHAIN" is displayed?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
1. Run **npm config set strict-ssl=false** on the DevEco Studio terminal.
2. Run **npm install** on the DevEco Studio terminal.
## After manual updating of a DevEco Studio SDK, the error message "Cannot find module 'xxx\ets\x.x.x.x\build-tools\ArkTS-loader\node_modules\webpack\bin\webpack.js'" is displayed during HAP building. What should I do?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
1. Run **npm install** in the **ets\x.x.x.x\build-tools\ets-loader** directory of the SDK.
2. Run **npm install** in the **js\x.x.x.x\build-tools\ace-loader** directory of the SDK. Perform HAP building again.
## How do I pack a HAP file through the command line?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
Method 1: Run **hvigor assembleHap**.
Method 2: In **scripts** of the project **package.json** file, define the build task script and run **npm buildOhosHaps**. The **buildOhosHaps** field can be customized.
```
"scripts": {
"buildOhosHaps": "hvigor assembleHap"
},
```
## How do I select API version 9 when creating a project in DevEco Studio?
Applicable to: DevEco Studio 3.0 Beta4 3.0.0.993(B06)
When creating a project in DevEco Studio, make sure you are on the **OpenHarmony** tab page.
## What should I do if no callback is received and no error code is returned for downloads?
Applicable to: all versions
1. Re-install hdc_std and set up the device connection again.
2. Run **hdc_std shell hilog -Q pidoff** to disable log log flow control.
## What should I do if the "error: unknow option. usage: aa start \<options>" message is displayed after I click Run in DevEco Studio?
Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9
This issue occurs when the parameter in the **aa** command is invalid and therefore the target application fails to be opened.
To fix this issue, use either of the following methods:
1. Make sure the SDK version and the OS version are the same.
2. Touch the application icon on the device to manually open the application.
## What should I do if "The hdc_std version of the SDK does not match the hdcd version of the device." message is displayed when I run an application in DevEco Studio?
Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9
This issue occurs when the hdc and hdcd versions do not match. Update Dev Eco Studio to 3.0.1.993 or later.
After the update, Dev Eco Studio will still indicate the version mismatch, but will not block the running.
## How do I add a custom .d.ts file to the OpenHarmony SDK?
Applicable to: OpenHarmony SDK 3.1.7.7, FA model of API version 8
Name the .d.ts file **@ohos.xxxx.d.ts**, save it to the SDK path, and restart Dev Eco Studio.
A code notification is displayed when the file is imported.
## How do I switch to the full SDK?
Applicable to: OpenHarmony SDK 3.2.7.5
Follow the instructions in [Guide to Switching to Full SDK](../quick-start/full-sdk-switch-guide.md).
# Programming Languages
## What are the restrictions on using generator functions in TypeScript?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
Below are the restrictions on using generator functions in TypeScript:
- Expressions can be used only in character strings (in the ${expression} format), **if** conditions, **ForEach** parameters, and component parameters.
- No expressions should cause any application state variables (including **@State**, **@Link**, and **@Prop**) to change. Otherwise, undefined and potentially unstable framework behavior may occur.
- The generator function cannot contain local variables.
None of the above restrictions apply to anonymous function implementations of event handlers (such as **onClick**).
Negative example:
```
build() {
let a: number = 1 // invalid: variable declaration not allowed
Column() {
Text('Hello ${this.myName.toUpperCase()}') // ok.
ForEach(this.arr.reverse(), ..., ...) // invalid: Array.reverse modifies the @State array variable in place
}
buildSpecial() // invalid: no function calls
Text(this.calcTextValue()) // this function call is ok.
}
```
## How do I dynamically replace the %s placeholder in a resource file?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
In an application, you can replace the %s placeholder by using the second parameter in **$r('app.string.xx')**, which is used to reference application resources.
Example:
```
build() {
//do something
// The second parameter indicates the referenced string resource, which can be used to replace the %s placeholder.
Text($r('app.string.entry_desc','aaa'))
.fontSize(100)
.fontColor(Color.Black)
//do something
}
```
## How do I read an XML file in Resource and convert data in it to the string type?
Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
1. Obtain Uint8Array data by calling the **RawFile** API of **resourceManager**.
2. Convert the Uint8Array data to strings by calling the **String.fromCharCode** API.
Reference: [Resource Manager](../reference/apis/js-apis-resource-manager.md)
Example:
```
resourceManager.getRawFile(path, (error, value) => {
if (error != null) {
console.log("error is " + error);
} else {
let rawFile = value;
let xml = String.fromCharCode.apply(null, rawFile)
}
});
```
## How do I convert a Resource object to the string type?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
Use the **resourceManager.getString()** API of the **@ohos.resourceManager** module.
Reference: [Resource Manager](../reference/apis/js-apis-resource-manager.md#getstring)
## What should I do if the global static variables of a class do not work?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
Objects imported to abilities and pages are packaged into two different closures, that is, two global objects. In this case, a static variable referenced by the abilities is not the same object as that referenced by the pages. Therefore, global variables cannot be defined by defining static variables in the class. You are advised to use AppStorage to manage global variables.
## How do I obtain resources in the stage model?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
The stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This method, however, is not applicable to the FA model.
Example:
```
const context = getContext(this) as any
context
.resourceManager
.getString($r('app.string.entry_desc').id)
.then(value => {
this.message = value.toString()
})
```
## How do I obtain data through an API before page loading?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
In the **aboutToAppear** function, use an asynchronous API to obtain page data and **@State** to decorate related variables. After the data is obtained, the page is automatically refreshed based on the variables.
```
@Entry
@Component
struct Test6Page {
// After the data is obtained, the page is automatically refreshed.
@State message: string = 'loading.....'
aboutToAppear(){
// Simulate an asynchronous API to obtain data.
setTimeout(()=>{
this.message = 'new msg'
},3000)
}
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
```
## Do the worker thread and the main thread run in the same global context?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
No. The worker thread and the main thread are not in the same global context. They interact with each other in data communication mode.
## Which API is used for URL encoding in OpenHarmony?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
The global function **encodeURI** is used for URI encoding, and **decodeURI** is used for URI decoding. For example, a space character is encoded as %20.
## Does OpenHarmony provide any API for parsing XML files?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
Yes. The **convert** API of the **convertxml** module can be used to convert XML text into JavaScript objects.
Reference: [@ohos.convertxml](../reference/apis/js-apis-convertxml.md)
## How do I configure application icons to be used across devices?
Applicable to: OpenHarmony SDK 3.0, stage model of API version 9
Use resource qualifiers to configure application icons to be used across devices.
## Can placeholders be configured in the string.json file of the stage model?
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9
The **string.json** file does not support placeholders. As an alternative, you can define variables on the target page and combine these variables and **Resource** objects.
## Is there any difference between the OpenHarmony API systemTime.getCurrentTime() and the JS API new Date().getTime() API?
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9
Similar to **new Date().getTime()**, **systemTime.getCurrentTime(false)** returns the number of milliseconds that have elapsed since the Unix epoch. **systemTime.getCurrentTime(true)** returns the number of nanoseconds that have elapsed since the Unix epoch. The system time is used in both APIs.
## How do I define @BuilderParam decorated attributes based on the value assigned to them?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
If no parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, **content: this.specificParam**), define the type of the attribute as a function without a return value (for example, **@BuilderParam content: () =&gt; voi**). If any parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, **callContent: this.specificParam1("111")**), define the type of the attribute as **any** (for example, **@BuilderParam callContent: any**).
## How does ArkTS convert a string into a byte array?
Applicable to: all versions
Refer to the following code:
```
function stringToByte(str) {
var bytes = new Array();
var len,c;
len = str.length;
for(var i = 0;i<len;i++) {
c = str.charCodeAt(i);
if( c >= 0x010000 && c<= 0x10FFFF) {
bytes.push(((c>>18) & 0x07) | 0xf0);
bytes.push(((c>>12) & 0x3F) | 0x80);
bytes.push(((c>>6) & 0x3f) | 0x80);
bytes.push((c & 0x3F) | 0x80);
} else if(c >= 0x000800 && c<= 0x00FFF){
bytes.push(((c>>12) & 0x07) | 0xf0);
bytes.push(((c>>6) & 0x3F) | 0x80);
bytes.push((c & 0x3F) | 0x80);
} else if(c >= 0x000800 && c<= 0x0007FF) {
bytes.push(((c>>6) & 0x3F) | 0x80);
bytes.push((c & 0x3F) | 0x80);
} else {
bytes.push(c & 0xFF)
}
}
return bytes;
}
```
## What do I do if the "Too many wokers, the number of worker exceeds the maximum" message is displayed during worker creation?
Applicable to: OpenHarmony SDK 3.2.6.5
An application allows for a maximum of seven workers. Therefore, use the **termiate** API to release workers when they are not needed.
Reference: [@ohos.worker](../reference/apis/js-apis-worker.md#terminate)
## What is the recommended multithreading solution on OpenHarmony?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
OpenHarmony recommends that worker threads be used for multithreading.
Reference: [@ohos.worker](../reference/apis/js-apis-worker.md)
## What is the difference between a @Builder decorated method and other methods?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
If the **@Builder** decorated method uses a custom component, this component is re-created each time the method is called.
## Why is the callback registered through @Watch not triggered when the object attributes of an array change?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
As with **@State**, the callback registered through **@Watch** can be used to listen for only one layer of data changes. If the object attributes of the array changes at the inner layer, the callback will not be triggered.
## How do I listen for in-depth changes of @State decorated variables?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
To listen for in-depth changes of **@State** decorated variables, you can use **@Observed** and **@ObjectLink** decorators.
## How do I implement character string encoding and decoding?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
You can use **TextEncoder** and **TextDecoder** provided by the **util** module.
Reference: [TextEncoder](../reference/apis/js-apis-util.md#textencoder) and [TextDecoder](../reference/apis/js-apis-util.md#textdecoder)
## How do i import and export namespaces?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
- Exporting namespaces
```
namespace Util{
export function getTime(){
return Date.now()
}
}
export default Util
```
- Importing namespaces
```
import Util from './util'
Util.getTime()
```
## Can relational database operations be performed in the worker thread?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
No. Relational database operations cannot be performed in the worker thread.
<!--no_check-->
\ No newline at end of file
# Media Development
## How do I set a front camera?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
1. Set the camera position to **camera.CameraPosition.CAMERA_POSITION_FRONT**.
2. Create a **CameraInput** instance based on the camera position and type.
Reference: [Camera Management](../reference/apis/js-apis-camera.md)
Example:
```
// The rear camera is set by default. You can use **isFrontCamera** to switch to the rear camera.
let cameraId
let cameraInput
for(let cameraIndex = 0; cameraIndex < this.cameraArray.length; cameraIndex++) {
let faceType = this.cameraArray[cameraIndex].cameraPosition
switch(faceType) {
case camera.CameraPosition.CAMERA_POSITION_FRONT: // Front camera
if(this.isFrontCamera){
cameraId = this.cameraArray[cameraIndex].cameraId
}
break
case camera.CameraPosition.CAMERA_POSITION_BACK: // Rear camera
if(!this.isFrontCamera){
cameraId = this.cameraArray[cameraIndex].cameraId
}
break
case camera.CameraPosition.CAMERA_POSITION_UNSPECIFIED:
default:
break
}
}
cameraInput = await this.cameraManager.createCameraInput(cameraId)
```
## How do I crop an image?
Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9
1. Create an **ImageSource** instance based on the input URI.
```
let path = this.context.getApplicationContext().fileDirs + "test.jpg";
const imageSourceApi = image.createImageSource(path);
```
2. Set decoding parameters and decode the image to obtain a **PixelMap** object. Image processing is supported during decoding.
- Set **desiredSize** to specify the target size after scaling. If the values are all set to **0**, scaling will not be performed.
- Set **desiredRegion** to specify the target rectangular area after cropping. If the values are all set to **0**, cropping will not be performed.
- Set **rotateDegrees** to specify the rotation angle. The image will be rotated clockwise at the center.
```
const decodingOptions = {
desiredSize: {
height:0,
width:0
},
// Crop a rectangular area.
desiredRegion: {
size: {
height:100,
width:100
},
x:0,
y:0
},
// Rotate the image by 90 degrees.
rotate:90
}
imageSourceApi.createPixelMap(decodingOptions).then(pixelMap => {
this.handlePixelMap(pixelMap)
})
```
3. Process the obtained **PixelMap** object. For example, render and display the image.
## How do I apply for the media read/write permission on a device?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
1. Configure the permissions **ohos.permission.READ_MEDIA** and **ohos.permission.WRITE_MEDIA** in the **module.json5** file.
Example:
```
{
"module" : {
"requestPermissions":[
{
"name" : "ohos.permission.READ_MEDIA",
"reason": "$string:reason"
},
{
"name" : "ohos.permission.WRITE_MEDIA",
"reason": "$string:reason"
}
]
}
}
```
2. Call **requestPermissionsFromUser** to request the permissions from end users in the form of a dialog box. This operation is required because the grant mode of both permissions is **user_grant**.
```
import abilityAccessCtrl from '@ohos.abilityAccessCtrl.d.ts';
let permissions: Array<string> = ['ohos.permission.READ_MEDIA','ohos.permission.WRITE_MEDIA']
let atManager = abilityAccessCtrl.createAtManager();
// context is the ability-level context of the initiator UIAbility.
atManager.requestPermissionsFromUser(context, permissions).then((data) => {
console.log("Succeed to request permission from user with data: " + JSON.stringify(data))
}).catch((error) => {
console.log("Failed to request permission from user with error: " + JSON.stringify(error))
})
```
## Why can't I play MP4 videos?
Applicable to: OpenHarmony SDK 3.2.7.5, stage model of API version 9
Currently, the system does not support the playback of MP4 videos in H.265 format.
## Why can't I play a new video or even encounters a crash after creating more than 10 videos?
Applicable to: OpenHarmony SDK 3.2.7.5, stage model of API version 9
A maximum of 13 media player instances can be created.
# Multimedia Development
## How do I obtain the frame data of a camera when using the XComponent to display the preview output stream of the camera?
Applicable to: OpenHarmony 3.2 (API version 9, stage model)
**Symptom**
Currently, the API does not support real-time preview of the camera frame data. To obtain the frame data, you must bind an action, for example, photographing.
**Solution**
Create a dual-channel preview to obtain the frame data.
1. Use the XComponent to create a preview stream.
```
// Obtain a PreviewOutput instance.
const surfaceId = globalThis.mxXComponentController.getXComponentSurfaceld();
this.mPreviewOutput = await Camera.createPreviewOutput(surfaceld) ;
```
2. Use imageReceiver to listen for image information.
```
// Add dual-channel preview.
const fullWidth = this.mFullScreenSize.width;
const fullHeight = this.mFullScreenSize.height;
const imageReceiver = await image.createImageReceiver(fullwidth, fullHeight,
formatImage, capacityImage) ;
const photoSurfaceId = await imageReceiver.getReceivingSurfaceld();
this.mPreviewOutputDouble = await Camera.createPreviewOutput ( photoSurfaceld)
```
## How do I obtain the preview image of the front camera?
Applicable to: OpenHarmony 3.2 (API version 9, stage model)
**Solution**
1. Use the **@ohos.multimedia.camera** module to obtain the physical camera information.
```
let cameraManager = await camera.getCameraManager(context);
let camerasInfo = await cameraManager.getSupportedCameras();
let cameraDevice = this.camerasInfo[0];
```
2. Create and start the input stream channel of the physical camera.
```
let cameraInput = await cameraManager.createCameraInput(cameraDevice);
await this.cameraInput.open();
```
3. Obtain the output formats supported by the camera, and create a preview output channel based on the surface ID provided by the XComponent.
```
let outputCapability = await this.cameraManager.getSupportedOutputCapability(cameraDevice);
let previewProfile = this.outputCapability.previewProfiles[0];
let previewOutput = await cameraManager.createPreviewOutput(previewProfile, previewId);
```
4. Create a camera session, add the camera input stream and preview output stream to the session, and start the session. The preview image is displayed on the XComponent.
```
let captureSession = await cameraManager.createCaptureSession();
await captureSession.beginConfig();
await captureSession.addInput(cameraInput);
await captureSession.addOutput(previewOutput);
await this.captureSession.commitConfig()
await this.captureSession.start();
```
## How do I set the camera focal length?
Applicable to: OpenHarmony 3.2 (API version 9, stage model)
**Solution**
1. Check whether the camera is a front camera. A front camera does not support focal length setting.
2. Use **captureSession.getZoomRatioRange\(\)** to obtain the focal length range supported by the device.
3. Check whether the target focal length is within the range obtained. If yes, call **captureSession.setZoomRatio\(\)** to set the focal length.
## How do I play music in the background?
Applicable to: OpenHarmony 3.2 (API version 9, stage model)
**Symptom**
Music cannot be played in the background.
**Solution**
**AVSession** controls media playback. When a third-party application switches to the background or encounters a screen lock event, media playback is forcibly paused and the application is unaware of the pause. To enable the application to continue the playback in the background, request a continuous task and access the AVSession capability, which allows Control Panel to control the playback behavior of third-party applications.
**Reference**
[Continuous Task Development](../task-management/continuous-task-dev-guide.md)
[AVSession Development](../media/using-avsession-developer.md)
## What should I do when multiple video components cannot be used for playback?
Applicable to: OpenHarmony 3.2 (API version 9, stage model)
**Symptom**
A large number of video components are created. They cannot play media normally or even crash.
**Solution**
A maximum of 13 media player instances can be created.
## How do I invoke the image library directly?
Applicable to: OpenHarmony 3.2 (API version 9, stage model)
**Solution**
```
let want = {
bundleName: 'com.ohos.photos',
abilityName: 'com.ohos.photos.MainAbility',
parameters: {
uri: 'detail'
}
};
let context = getContext(this) as common.UIAbilityContext;
context.startAbility(want);
```
# Native API Usage
## Is there a native API that provides functions similar to Canvas?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
Yes. The native API **Drawing** provides similar functions. It can be used for 2D drawing.
## When a native HAP is running, the error message "Obj is not a valid object" is displayed for the imported namespace. What should I do?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
Check the **abiFilters** parameter value in the **build-profile.json5** file in the root directory of the module (not the root directory of the project). If the device is 32-bit, the value must be **armeabi-v7a**. If the device is 64-bit, the value must be **arm64-v8a**.
## What should I do when the error message "install parse profile prop check error" is displayed during the running of a native HAP?
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9
Check the **abiFilters** parameter value in the **build-profile.json5** file in the root directory of the module (not the root directory of the project). If the device is 32-bit, the value must be **armeabi-v7a**. If the device is 64-bit, the value must be **arm64-v8a**.
## What should I do when the error message "undefined symbol: OH_LOG_Print" is displayed during log printing by **OH_LOG_Print**?
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9
Modify the **CMakeLists.txt** file by adding **libhilog_ndk.z.so** to the end of **target_link_libraries**.
## How do I obtain the value of version in the package.json file of a module?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
1. In the script file **hvigorfile.js** of Hvigor, use **subModule.getPackageJsonPath** to obtain the location of the **package.json** file in the module.
2. Use Node.js to read the **version** field in the **package.json** file and write the value to the **buildOption.cppFlags** field in the **build-profile.json5** file.
Example
```
// Module-level hvigorfile.js
const subModule = require('@ohos/hvigor')(__filename)
const fs = require("fs-extra")
const path = require("path")
const packageJsonPath = subModule.getPackageJsonPath()
const buildProfilePath = path.resolve(packageJsonPath, '../build-profile.json5')
const packageJsonData = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
let buildProfileData = fs.readFileSync(buildProfilePath, 'utf8')
buildProfileData = buildProfileData.replace(/\"cppFlags\"\:(.*)\,/, `"cppFlags": "-D NWEBEX_VERSION=${packageJsonData.version}",`)
fs.writeFileSync(buildProfilePath, buildProfileData, 'utf8')
const ohosPlugin = require('@ohos/hvigor-ohos-plugin').hapTasks(subModule) // The plug-in executes the C++ build task and reads the build-profile.json5 file.
module.exports = {
ohos: ohosPlugin
}
```
```
// Read the hello.cpp file.
#define _NWEBEX_VERSION(v) #v
#define _NWEBEX_VER2STR(v) _NWEBEX_VERSION(v)
static napi_value Add(napi_env env, napi_callback_info info)
{
napi_value fixed_version_value = nullptr;
napi_create_string_utf8(env, _NWEBEX_VER2STR(NWEBEX_VERSION), NAPI_AUTO_LENGTH, &fixed_version_value);
return fixed_version_value;
}
```
## How do I traverse files in rawfile?
Applicable to: OpenHarmony SDK 3.2 or later, stage model of API version 9
Use the native API **OH_ResourceManager_OpenRawDir()** to obtain the root directory of **rawfile** and traverse the root directory.
# Pan-Sensor Development
## Are the APIs used for obtaining PPG and ECG sensor data open to individual developers?
Applicable to: OpenHarmony 3.1 Beta 5 (API version 9)
Data collected by the PPG and ECG sensors of wearable devices is personal privacy data. Therefore, relative APIs are not open to individual developers.
# Usage of Third- and Fourth-Party Libraries
## How do I obtain available third-party libraries?
Applicable to: OpenHarmony 3.1 Beta 5 (API version 9)
The three-party and four-party libraries that can be obtained through ohpm are summarized in the [OpenHarmony-TPC/tpc_resource repository](https://gitee.com/openharmony-tpc/tpc_resource). You can access this repository, and find the desired component based on the directory index.
## Which third-party libraries are related to network requests?
Applicable to: OpenHarmony 3.1 Beta 5 (API version 9)
The following third-party libraries are related to network requests: [Axios](https://gitee.com/openharmony-sig/axios), httpclient, and okdownload. For details, see the [OpenHarmony-TPC/tpc_resource repository](https://gitee.com/openharmony-tpc/tpc_resource).
## How do I use ohpm to import third- and fourth-party libraries?
Applicable to: OpenHarmony 3.1 Beta 5 (API version 9)
**Solution**
- Method 1:
1. Open the **Terminal** window and run the following command to go to the **entry** directory:
```
cd entry
```
2. Run the following command to install a third-party library, for example, **dayjs**:
```
ohpm install dayjs
```
3. Add the following statement in the .js file to import the third-party library:
```
import dayjs from 'dayjs';
```
- Method 2:
1. Enter the **entry** directory of the project and open the **oh-package.json5** file.
2. Write the third-party library to be installed (for example, **dayjs**) in the **oh-package.json5** file.
```
{
"dependencies": {
"dayjs": "^1.10.4",
}
}
```
3. Open the **Terminal** window and run the following command to go to the **entry** directory:
```
cd entry
```
4. Run the following command to install the third-party library:
```
ohpm install
```
5. Add the following statement in the .js file to import the third-party library:
```
import dayjs from 'dayjs';
```
# Usage of Third- and Fourth-Party Libraries
## What does the following error message mean: "Stage model module... does not support including OpenHarmony npm packages or modules in FA model. OpenHarmony build tasks will not be executed, and OpenHarmony resources will not be packed."
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
The third- and fourth-party libraries are not yet compatible with the stage model of API version 9 and cannot be used.
## Can I transfer project-level dependencies?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
For example, if project A depends on project B and project B depends on project C, can project A directly use the APIs provided by project C?
No. Project A cannot directly use the APIs provided by project C. The project packing tool NPM does not support dependency transfer. To use the APIs provided by project C, you can add the dependency of project C to project A.
## How do I obtain available third-party libraries?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
For details, see [Third-Party Components That Can Be Directly Used on OpenHarmony](https://gitee.com/openharmony-sig/third_party_app_libs).
## Which third-party libraries are related to network requests?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
The [Axios](https://gitee.com/openharmony-sig/axios) library is related to network requests.
## How do I use NPM to import third- and fourth-party libraries?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
- Method 1:
1. Open the **Terminal** window and run the following command to go to the **entry** directory:
```
cd entry
```
2. Run the following command to install a third-party package, for example, **dayjs**:
```
npm install dayjs --save
```
3. Add the following statement in the .js file to import the package:
```
import dayjs from 'dayjs';
```
- Method 2:
1. Enter the **entry** directory of the project and open the **package.json** file.
2. Write the third-party NPM package to be installed (for example, **dayjs**) in the **package.json** file.
```
{
"dependencies": {
"dayjs": "^1.10.4",
}
}
```
3. Open the **Terminal** window and run the following command to go to the **entry** directory:
```
cd entry
```
4. Run the following command to install NPM:
```
npm install
```
5. Add the following statement in the .js file to import the package:
```
import dayjs from 'dayjs';
```
此差异已折叠。
# ArkUI (JavaScript) Development
## How do I convert the fields in an XML file into JavaScript objects?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
To convert fields in an XML file into JavaScript objects, call the **convert** API in the **convertxml** module.
Example:
```
import convertxml from '@ohos.convertxml';
// XML strings
let xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
let conv = new convertxml.ConvertXML();
// Options for conversion. For details, see the reference document.
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
}
let result: any = conv.convert(xml, options) // Convert fields in the XML file into JavaScript objects.
console.log('Test: ' + JSON.stringify(result))
console.log('Test: ' + result._declaration._attributes.version) // version field in the XML file
console.log('Test: ' + result._elements[0]._elements[0]._elements[0]._text) // title field in the XML file
```
For details, see [XML-to-JavaScript Conversion](../reference/apis/js-apis-convertxml.md).
## How do I convert the time to the HHMMSS format?
Example:
```
export default class DateTimeUtil{
/**
* HHMMSS
*/
getTime() {
const DATETIME = new Date()
return this.concatTime(DATETIME.getHours(),DATETIME.getMinutes(),DATETIME.getSeconds())
}
/**
* YYYYMMDD
*/
getDate() {
const DATETIME = new Date()
return this.concatDate(DATETIME.getFullYear(),DATETIME.getMonth()+1,DATETIME.getDate())
}
/**
* If the date is less than 10, add a leading zero, for example, **07**.
* @param value Indicates the value.
*/
fill(value:number) {
return (value> 9 ? '' : '0') + value
}
/**
* Concatenate year, month, and date fields.
* @param year
* @param month
* @param date
*/
concatDate(year: number, month: number, date: number){
return `${year}${this.fill(month)}${this.fill(date)}`
}
/**
Concatenate hours, minutes, and seconds fields.
* @param hours
* @param minutes
* @param seconds
*/
concatTime(hours:number,minutes:number,seconds:number){
return `${this.fill(hours)}${this.fill(minutes)}${this.fill(seconds)}`
}
}
```
# ArkUI Web Component (ArkTS) Development
## What is the domStorageAccess attribute of the \<Web> component used for?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
The **domStorageAccess** attribute specifies whether to enable the DOM Storage API, which is disabled by default and provides **localStorage**, but not **sessionStorage**.
## How do I check the online status on the HTML page loaded by the \<Web> component?
Applicable to: OpenHarmony SDK 3.2.7.5, stage model of API version 9
1. Configure the **ohos.permission.INTERNET** and **ohos.permission.GET_NETWORK_INFO** application permissions.
2. Obtain the online status through **window.navigator.onLine** on the HTML page.
## What should I do if the UserAgent string cannot be used in concatenation before the initial HTML5 page loading by the \<Web> component?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
By default, the **UserAgent** string is obtained through the **WebController**. A **WebController** object can control only one **\<Web>** component, and methods on the **WebController** can only be called by the **\<Web>** component bound to it. To concatenate the default **UserAgent** string and a custom string before the initial page loading, perform the following:
1. Use **@State** to define the initial **userAgent** and bind it to the **\<Web>** component.
2. In the **onUrlLoadIntercept** callback of the **\<Web>** component, use **WebController** to obtain the default **userAgent** string and modify the **userAgent** bound to the **\<Web>** component.
The code snippet is as follows:
```
@Entry
@Component
struct Index {
private controller: WebController = new WebController()
@State userAgentPa: string = ''
build() {
Row() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.width('100%')
.userAgent(this.userAgentPa)
.onUrlLoadIntercept((event) => {
let userAgent = this.controller.getDefaultUserAgent();
this.userAgentPa = userAgent + ' 111111111'
console.log("userAgent onUrlLoadIntercept: " + userAgent);
return false;
})
}
.width('100%').alignItems(HorizontalAlign.Start).backgroundColor(Color.Green)
}
.height('100%')
}
}
```
## Should the logic for loading the lottie animation be written in the onAppear or onReady function?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
The logic for loading the lottie animation must be written in the **onReady** function. The **onReady** function is triggered when the canvas is ready, while the **onAppear** function is triggered when the canvas is displayed.
## Do I need to invoke the refresh API after invoking deleteJavaScriptRegister?
Applicable to: all versions
No. This operation is not needed.
## How do I pass data from a page to the \<Web> component?
Applicable to: OpenHarmony SDK 3.2.7.5, stage model of API version 9
1. Use **WebController** to create two message ports: message port 1 and message port 0.
2. Send message port 1 to the HTML side, which can then save and use the port.
3. Register a callback for message port 0 on the application side.
4. Use message port 0 on the application side to send messages to message port 1 on the HTML side.
Reference: [Web](../reference/arkui-ts/ts-basic-components-web.md)
# Window Management Development
## How do I obtain the height of the status bar and navigation bar?
Applicable to: OpenHarmony 3.2 Beta 5 (API version 9)
**Solution**
Before the window content is loaded, enable listening for the **systemAvoidAreaChange** event.
**Example**
```
// MainAbility.ts
import window from '@ohos.window';
/**
* Set the immersive window and obtain the height of the status bar and navigation bar.
* @param mainWindow Indicates the main window.
*/
async function enterImmersion(mainWindow: window.Window) {
mainWindow.on("systemBarTintChange", (data) => {
let avoidAreaRect = data.regionTint[0].region; // data.regionTint is an array that contains the rectangle coordinates of the status bar and navigation bar.
})
await mainWindow.setFullScreen(true)
await mainWindow.setSystemBarEnable(["status", "navigation"])
await mainWindow.systemBarProperties({
navigationBarColor: "#00000000",
statusBarColor: "#00000000",
navigationBarContentColor: "#FF0000",
statusBarContentColor: "#FF0000"
})
}
export default class MainAbility extends Ability {
// Do something.
async onWindowStageCreate(windowStage: window.WindowStage) {
let mainWindow = await windowStage.getMainWindow()
await enterImmersion(mainWindow)
windowStage.loadContent('pages/index')
}
// Do something.
}
```
## How do I hide the status bar on the top of an application?
Applicable to: OpenHarmony 3.2 Beta 5 (API version 9)
**Solution**
Use **setWindowSystemBarEnable** in the **onWindowStageCreate** lifecycle callback of UIAbility.
**Example**
```
onWindowStageCreate(windowStage){
windowStage.getMainWindowSync().setWindowSystemBarEnable([])
......
}
```
**Reference**
[Window](../reference/apis/js-apis-window.md)
...@@ -88,7 +88,7 @@ To enable an audio and video application to access the AVSession service as a pr ...@@ -88,7 +88,7 @@ To enable an audio and video application to access the AVSession service as a pr
```ts ```ts
// It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet above. // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet above.
let session: AVSessionManager.AVSession = ALLREADY_CREATE_A_SESSION; let session: AVSessionManager.AVSession = ALLREADY_CREATE_A_SESSION;
let wantAgentInfo: { let wantAgentInfo = {
wants: [ wants: [
{ {
bundleName: "com.example.musicdemo", bundleName: "com.example.musicdemo",
......
# app.json5 Configuration File # app.json5 Configuration File
This document gives an overview of the **app.json5** configuration file. To start with, let's go through an example of what this file contains. This topic gives an overview of the **app.json5** configuration file. To start with, let's go through an example of what this file contains.
```json ```json
{ {
...@@ -35,7 +35,7 @@ As shown above, the **app.json5** file contains several tags. ...@@ -35,7 +35,7 @@ As shown above, the **app.json5** file contains several tags.
| Name| Description| Data Type| Initial Value Allowed| | Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bundleName | Bundle name, which uniquely identifies an application. The value must comply with the following rules:<br>- Consists of letters, digits, underscores (_), and periods (.).<br>- Starts with a letter.<br>- Contains 7 to 127 bytes.<br>You are advised to use the reverse domain name notation, for example, *com.example.demo*, where the first part is the domain suffix **com**, the second part is the vendor/individual name, and the third part is the application name, which can be of multiple levels.<br>If an application is built with the system source code, you are advised to name it in *com.ohos.demo* notation, where **ohos** signifies that the application is an OpenHarmony system application.| String| No| | bundleName | Bundle name, which uniquely identifies an application. The value must comply with the following rules:<br>- Consists of letters, digits, underscores (_), and periods (.).<br>- Starts with a letter.<br>- Contains 7 to 127 bytes.<br>You are advised to use the reverse domain name notation, for example, *com.example.demo*, where the first part is the domain suffix **com**, the second part is the vendor/individual name, and the third part is the application name, which can be of multiple levels.<br>If an application is built with the system source code, you are advised to name it in *com.ohos.demo* notation, where **ohos** signifies that the application is an OpenHarmony system application.| String| No|
| bundleType| Bundle type, which is used to distinguish applications and atomic services.<br>- **app**: The bundle is a common application.<br>- **atomicService**: The bundle is an atomic service.<br>- **shared**: The bundle is a shared object application. | String| Yes (initial value: **"app"**)| | bundleType| Bundle type, which is used to distinguish applications and atomic services.<br>- **app**: The bundle is a common application.<br>- **atomicService**: The bundle is an atomic service.<br>- **shared**: The bundle is a shared object application.| String| Yes (initial value: **"app"**)|
| debug | Whether the application can be debugged. This tag is generated during compilation and building in DevEco Studio.<br>- **true**: The application can be debugged.<br>- **false**: The application cannot be debugged.| Boolean| Yes (initial value: **false**)| | debug | Whether the application can be debugged. This tag is generated during compilation and building in DevEco Studio.<br>- **true**: The application can be debugged.<br>- **false**: The application cannot be debugged.| Boolean| Yes (initial value: **false**)|
| icon | [Icon of the application](../application-models/application-component-configuration-stage.md). The value is an icon resource index.| String| No| | icon | [Icon of the application](../application-models/application-component-configuration-stage.md). The value is an icon resource index.| String| No|
| label | [Name of the application](../application-models/application-component-configuration-stage.md). The value is a string resource index.| String| No| | label | [Name of the application](../application-models/application-component-configuration-stage.md). The value is a string resource index.| String| No|
...@@ -49,10 +49,11 @@ As shown above, the **app.json5** file contains several tags. ...@@ -49,10 +49,11 @@ As shown above, the **app.json5** file contains several tags.
| apiReleaseType | Type of the target API version required for running the application. The value can be **"CanaryN"**, **"BetaN"**, or **"Release"**, where **N** represents a positive integer.<br>- **Canary**: indicates a restricted release.<br>- **Beta**: indicates a publicly released beta version.<br>- **Release**: indicates a publicly released official version.<br>The value is set by DevEco Studio reading the stage of the SDK in use.| String| Yes (initial value: set by DevEco Studio)| | apiReleaseType | Type of the target API version required for running the application. The value can be **"CanaryN"**, **"BetaN"**, or **"Release"**, where **N** represents a positive integer.<br>- **Canary**: indicates a restricted release.<br>- **Beta**: indicates a publicly released beta version.<br>- **Release**: indicates a publicly released official version.<br>The value is set by DevEco Studio reading the stage of the SDK in use.| String| Yes (initial value: set by DevEco Studio)|
| multiProjects | Whether the application supports joint development of multiple projects.<br>- **true**: The application supports joint development of multiple projects.<br>- **false**: The application does not support joint development of multiple projects. For details about multi-project development, see [Multi-Project Build](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/ohos-building-overview-0000001263360495-V3#section71471033104216).| Boolean| Yes (initial value: **false**)| | multiProjects | Whether the application supports joint development of multiple projects.<br>- **true**: The application supports joint development of multiple projects.<br>- **false**: The application does not support joint development of multiple projects. For details about multi-project development, see [Multi-Project Build](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/ohos-building-overview-0000001263360495-V3#section71471033104216).| Boolean| Yes (initial value: **false**)|
| assanEnabled | Whether to enable AddressSanitizer (ASan) to detect memory corruption issues such as buffer overflows.<br>- **true**: ASan is enabled.<br>- **false**: ASan is disabled. Note that ASan is not available in the Release version.| Boolean| Yes (initial value: **false**)| | assanEnabled | Whether to enable AddressSanitizer (ASan) to detect memory corruption issues such as buffer overflows.<br>- **true**: ASan is enabled.<br>- **false**: ASan is disabled. Note that ASan is not available in the Release version.| Boolean| Yes (initial value: **false**)|
| tablet | Tablet-specific configuration, which includes **minAPIVersion** and **distributedNotificationEnabled** attributes.<br>When running on tablets, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)| | tablet | Tablet-specific configuration, which includes the **minAPIVersion** attribute.<br>When running on tablets, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)|
| tv | TV-specific configuration, which includes **minAPIVersion** and **distributedNotificationEnabled** attributes.<br>When running on TVs, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)| | tv | TV-specific configuration, which includes the **minAPIVersion** attribute.<br>When running on TVs, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)|
| wearable | Wearable-specific configuration, which includes **minAPIVersion** and **distributedNotificationEnabled** attributes.<br>When running on wearables, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)| | wearable | Wearable-specific configuration, which includes the **minAPIVersion** attribute.<br>When running on wearables, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)|
| car | Head unit–specific configuration, which includes **minAPIVersion** and **distributedNotificationEnabled** attributes.<br>When running on head units, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)| | car | Head unit–specific configuration, which includes the **minAPIVersion** attribute.<br>When running on head units, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)|
| default | Default device–specific configuration, which includes **minAPIVersion** and **distributedNotificationEnabled** attributes.<br>When running on default devices, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)| | default | Default device–specific configuration, which includes the **minAPIVersion** attribute.<br>When running on default devices, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)|
|targetBundleName|Target application name of the bundle. The value rule and range are the same as those of **bundleName**.|String|Yes (if the initial value is used, the target application is not an application with the overlay feature)| |targetBundleName|Target application name of the bundle. The value rule and range are the same as those of **bundleName**.|String|Yes (if the initial value is used, the target application is not an application with the overlay feature)|
|targetPriority|Priority of the application. When **targetBundleName** is set, the application is an application with the overlay feature. The value ranges from 1 to 100.|Number|Yes (initial value: **1**)| |targetPriority|Priority of the application. When **targetBundleName** is set, the application is an application with the overlay feature. The value ranges from 1 to 100.|Number|Yes (initial value: **1**)|
|generateBuildHash |Whether the hash values of all HAP and HSP files of the application are generated by the packaging tool. The hash values (if any) are used to determine whether the application needs to be updated when the system is updated in OTA mode but the **versionCode** value of the application remains unchanged.<br>If this tag is set to **true**, the packaging tool generates hash values for all HAP and HSP files of the application.<br>**NOTE**<br>This tag applies only to system applications.|Boolean|Yes (initial value: **false**)|
...@@ -23,9 +23,9 @@ In this example, the basic composition of ArkTS is as follows. ...@@ -23,9 +23,9 @@ In this example, the basic composition of ArkTS is as follows.
- [Custom component](arkts-create-custom-components.md): reusable UI unit, which can be combined with other components, such as the struct **Hello** decorated by @Component. - [Custom component](arkts-create-custom-components.md): reusable UI unit, which can be combined with other components, such as the struct **Hello** decorated by @Component.
- Built-in component: default basic or container component preset in ArkTS, which can be directly invoked, such as** \<Column>**,** \<Text>**, **\<Divider>**, and **\<Button>** components in the sample code. - Built-in component: default basic or container component preset in ArkTS, which can be directly invoked, such as **\<Column>**, **\<Text>**, **\<Divider>**, and **\<Button>** components in the sample code.
- Attribute method: method used to configure component attributes, such as **fontSize()**, **width()**, **height()**, and **color()**. You can configure multiple attributes of a component in method chaining mode. - Attribute method: method used to configure component attributes, such as **fontSize()**, **width()**, **height()**, and **backgroundColor()**. You can configure multiple attributes of a component in method chaining mode.
- Event method: method used to add the logic for a component to respond to an event. In the sample code, **onClick()** following **Button** is an event method. You can configure response logic for multiple events in method chaining mode. - Event method: method used to add the logic for a component to respond to an event. In the sample code, **onClick()** following **Button** is an event method. You can configure response logic for multiple events in method chaining mode.
......
...@@ -44,7 +44,6 @@ Note that you must set the **bundleType** field to **atomicService** in the [app ...@@ -44,7 +44,6 @@ Note that you must set the **bundleType** field to **atomicService** in the [app
"versionName": "1.0.0", "versionName": "1.0.0",
"icon": "$media:app_icon", "icon": "$media:app_icon",
"label": "$string:app_name", "label": "$string:app_name",
"distributedNotificationEnabled": true,
"targetAPIVersion": 9 "targetAPIVersion": 9
} }
} }
...@@ -78,7 +77,7 @@ Pre-loading is triggered after the first frame of the newly accessed module is r ...@@ -78,7 +77,7 @@ Pre-loading is triggered after the first frame of the newly accessed module is r
"module": { "module": {
"name": "entry", "name": "entry",
"type": "entry", "type": "entry",
"srcEntrance": "./ets/Application/MyAbilityStage.ts", "srcEntry": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_desc", "description": "$string:entry_desc",
"mainElement": "MainAbility", "mainElement": "MainAbility",
"deviceTypes": [ "deviceTypes": [
...@@ -98,13 +97,13 @@ Pre-loading is triggered after the first frame of the newly accessed module is r ...@@ -98,13 +97,13 @@ Pre-loading is triggered after the first frame of the newly accessed module is r
"abilities": [ "abilities": [
{ {
"name": "MainAbility", "name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts", "srcEntry": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc", "description": "$string:MainAbility_desc",
"icon": "$media:icon", "icon": "$media:icon",
"label": "$string:MainAbility_label", "label": "$string:MainAbility_label",
"startWindowIcon": "$media:icon", "startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white", "startWindowBackground": "$color:white",
"visible": true, "exported": true,
"skills": [ "skills": [
{ {
"entities": [ "entities": [
...@@ -170,7 +169,7 @@ import router from '@ohos.router'; ...@@ -170,7 +169,7 @@ import router from '@ohos.router';
@Entry @Entry
@Component @Component
struct Index { struct Index {
@State message: string = 'Hello World' @State message: string = 'Hello World';
build() { build() {
Row() { Row() {
...@@ -200,19 +199,20 @@ struct Index { ...@@ -200,19 +199,20 @@ struct Index {
}).catch(err => { }).catch(err => {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
}) })
} })
.width('100%') .width('100%')
} }
.height('100%') .height('100%')
} }
}
} }
``` ```
The input parameter **url** of the **router.pushUrl** API is as follows: The input parameter **url** of the **router.pushUrl** API is as follows:
```ets ```ts
'@bundle:com.example.hmservice/library/ets/pages/menu' '@bundle:com.example.hmservice/library/ets/pages/menu'
``` ```
The **url** content template is as follows: The **url** content template is as follows:
```ets ```ts
'@bundle:bundle name/module name/path/page file name (without the extension .ets)' '@bundle:bundle name/module name/path/page file name (without the extension .ets)'
``` ```
# In-Application HSP Development # 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. 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. The in-application HSP is released with the Application Package (App Pack) of the host application, shares a process with the host application, and has the same bundle name and lifecycle as the host application.
## Developing an In-Application HSP ## Developing an In-Application HSP
...@@ -151,3 +151,59 @@ struct Index { ...@@ -151,3 +151,59 @@ struct Index {
} }
} }
``` ```
### Redirecting to a Page in Another Bundle
If you want to add a button in the **entry** module to jump to the menu page (**library/src/main/ets/pages/menu.ets**) in the **library** module, you can write the following code in the **entry/src/main/ets/MainAbility/Index.ets** file of the **entry** module:
```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)
// Add a button to respond to user clicks.
Button() {
Text('click to menu')
.fontSize(30)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('40%')
.height('5%')
// Bind click events.
.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%')
}
}
}
```
The input parameter **url** of the **router.pushUrl** API is as follows:
```ets
'@bundle:com.example.hmservice/library/ets/pages/menu'
```
The **url** content template is as follows:
```ets
'@bundle:bundle name/module name/path/page file name (without the extension .ets)'
```
# module.json5 Configuration File # module.json5 Configuration File
This document gives an overview of the **module.json5** configuration file. To start with, let's go through an example of what this file contains. This topic gives an overview of the **module.json5** configuration file. To start with, let's go through an example of what this file contains.
```json ```json
{ {
...@@ -61,7 +61,8 @@ This document gives an overview of the **module.json5** configuration file. To s ...@@ -61,7 +61,8 @@ This document gives an overview of the **module.json5** configuration file. To s
] ]
}, },
"targetModuleName": "feature", "targetModuleName": "feature",
"targetPriority": 50 "targetPriority": 50,
"isolationMode": "nonisolationFirst"
} }
``` ```
...@@ -93,6 +94,9 @@ As shown above, the **module.json5** file contains several tags. ...@@ -93,6 +94,9 @@ As shown above, the **module.json5** file contains several tags.
| [dependencies](#dependencies)| List of shared libraries on which the current module depends during running.| Object array| Yes (initial value: left empty) | | [dependencies](#dependencies)| List of shared libraries on which the current module depends during running.| Object array| Yes (initial value: left empty) |
| targetModuleName | Target module of the bundle. The value is a string with a maximum of 31 bytes. It must be unique in the entire application.|String|Yes (if the initial value is used, the target module is not a module with the overlay feature)| | targetModuleName | Target module of the bundle. The value is a string with a maximum of 31 bytes. It must be unique in the entire application.|String|Yes (if the initial value is used, the target module is not a module with the overlay feature)|
| targetPriority | Priority of the module. When **targetModuleName** is set, the module is a module with the overlay feature. The value ranges from 1 to 100.|Number|Yes (initial value: **1**)| | targetPriority | Priority of the module. When **targetModuleName** is set, the module is a module with the overlay feature. The value ranges from 1 to 100.|Number|Yes (initial value: **1**)|
| [proxyDatas](#proxydatas) | List of data proxies provided by the module.| Object array| Yes (initial value: left empty)|
| isolationMode | Multi-process configuration of the module. The options are as follows:<br>- **nonisolationFirst**: The module preferentially runs in a non-independent process.<br>- **isolationFirst**: The module preferentially runs in an independent process.<br>- **isolationOnly**: The module runs only in an independent process.<br>- **nonisolationOnly**: The module runs only in non-independent processes.|String|Yes (initial value: **nonisolationFirst**)|
| generateBuildHash |Whether the hash value of the HAP or HSP file is generated by the packaging tool. The hash value (if any) is used to determine whether the application needs to be updated when the system is updated in OTA mode but the **versionCode** value of the application remains unchanged.<br>This tag is enabled only when the **generateBuildHash** tag in the [app.json5](./app-configuration-file.md) file is **false**.<br>**NOTE**<br>This tag applies only to system applications.|Boolean|Yes (initial value: **false**)|
## deviceTypes ## deviceTypes
...@@ -300,7 +304,7 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json ...@@ -300,7 +304,7 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json
| [launchType](../application-models/uiability-launch-type.md) | Launch type of the UIAbility component. The options are as follows:<br>- **multiton**: A new UIAbility instance is created each time the UIAbility component is started.<br>- **singleton**: A new UIAbility instance is created only when the UIAbility component is started for the first time.<br>- **specified**: You can determine whether to create a new UIAbility instance when the application is running.| String| Yes (initial value: **"singleton"**)| | [launchType](../application-models/uiability-launch-type.md) | Launch type of the UIAbility component. The options are as follows:<br>- **multiton**: A new UIAbility instance is created each time the UIAbility component is started.<br>- **singleton**: A new UIAbility instance is created only when the UIAbility component is started for the first time.<br>- **specified**: You can determine whether to create a new UIAbility instance when the application is running.| String| Yes (initial value: **"singleton"**)|
| description | Description of the UIAbility component. The value is a string with a maximum of 255 bytes or a resource index to the description in multiple languages.| String| Yes (initial value: left empty)| | description | Description of the UIAbility component. The value is a string with a maximum of 255 bytes or a resource index to the description in multiple languages.| String| Yes (initial value: left empty)|
| icon | Icon of the UIAbility component. The value is an icon resource index.| String| Yes (initial value: left empty)<br>If **UIAbility** is set to **MainElement**, this attribute is mandatory.| | icon | Icon of the UIAbility component. The value is an icon resource index.| String| Yes (initial value: left empty)<br>If **UIAbility** is set to **MainElement**, this attribute is mandatory.|
| label | Name of the UIAbility component displayed to users. The value is a string resource index.<br>If **UIAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| No| | label | Name of the UIAbility component displayed to users. The value is a string resource index.| String| Yes (initial value: left empty)<br>If **UIAbility** is set to **MainElement**, this attribute is mandatory.|
| permissions | Permissions required for another application to access the UIAbility component.<br>The value is an array of permission names predefined by the system, generally in the reverse domain name notation. It contains a maximum of 255 bytes.| String array| Yes (initial value: left empty)| | permissions | Permissions required for another application to access the UIAbility component.<br>The value is an array of permission names predefined by the system, generally in the reverse domain name notation. It contains a maximum of 255 bytes.| String array| Yes (initial value: left empty)|
| [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)| | [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)|
| exported | Whether the UIAbility component can be called by other applications.<br>- **true**: The UIAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)| | exported | Whether the UIAbility component can be called by other applications.<br>- **true**: The UIAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
...@@ -440,7 +444,7 @@ The **extensionAbilities** tag represents the configuration of extensionAbilitie ...@@ -440,7 +444,7 @@ The **extensionAbilities** tag represents the configuration of extensionAbilitie
| type | Type of the ExtensionAbility component. The options are as follows:<br>- **form**: ExtensionAbility of a widget.<br>- **workScheduler**: ExtensionAbility of a Work Scheduler task.<br>- **inputMethod**: ExtensionAbility of an input method.<br>- **service**: service component running in the background.<br>- **accessibility**: ExtensionAbility of an accessibility feature.<br>- **dataShare**: ExtensionAbility for data sharing.<br>- **fileShare**: ExtensionAbility for file sharing.<br>- **staticSubscriber**: ExtensionAbility for static broadcast.<br>- **wallpaper**: ExtensionAbility of the wallpaper.<br>- **backup**: ExtensionAbility for data backup.<br>- **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**.<br>- **thumbnail**: ExtensionAbility for obtaining file thumbnails. You can provide thumbnails for files of customized file types.<br>- **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.<br>- **print**: ExtensionAbility for the print framework.<br>- **driver**: ExtensionAbility for the driver framework.<br>**NOTE**<br>The **service** and **dataShare** types apply only to system applications and do not take effect for third-party applications.| String| No| | type | Type of the ExtensionAbility component. The options are as follows:<br>- **form**: ExtensionAbility of a widget.<br>- **workScheduler**: ExtensionAbility of a Work Scheduler task.<br>- **inputMethod**: ExtensionAbility of an input method.<br>- **service**: service component running in the background.<br>- **accessibility**: ExtensionAbility of an accessibility feature.<br>- **dataShare**: ExtensionAbility for data sharing.<br>- **fileShare**: ExtensionAbility for file sharing.<br>- **staticSubscriber**: ExtensionAbility for static broadcast.<br>- **wallpaper**: ExtensionAbility of the wallpaper.<br>- **backup**: ExtensionAbility for data backup.<br>- **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**.<br>- **thumbnail**: ExtensionAbility for obtaining file thumbnails. You can provide thumbnails for files of customized file types.<br>- **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.<br>- **print**: ExtensionAbility for the print framework.<br>- **driver**: ExtensionAbility for the driver framework.<br>**NOTE**<br>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.<br>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)| | permissions | Permissions required for another application to access the ExtensionAbility component.<br>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.<br>**NOTE**<br>This attribute is mandatory when the type of the ExtensionAbility component is set to **dataShare**.| String| 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.<br>**NOTE**<br>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.<br>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.<br>**NOTE**<br>The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application, but not for an OpenHarmony service. | Array| Yes (initial value: left empty)| |skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.<br>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.<br>**NOTE**<br>The **skills** attribute with the entry capability can be configured for the feature 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)| | [metadata](#metadata)| Metadata of the ExtensionAbility component.| Object| Yes (initial value: left empty)|
| exported | Whether the ExtensionAbility component can be called by other applications. <br>- **true**: The ExtensionAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)| | exported | Whether the ExtensionAbility component can be called by other applications. <br>- **true**: The ExtensionAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
...@@ -595,7 +599,7 @@ The **shortcut** information is identified in **metadata**, where: ...@@ -595,7 +599,7 @@ The **shortcut** information is identified in **metadata**, where:
## distributionFilter ## distributionFilter
The **distributionFilter** tag 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 five factors: API version, screen shape, screen size, screen resolution, and country code. During distribution, a unique HAP is determined based on the mapping between **deviceType** and these five factors. This tag must be configured in the **/resource/profile resource** directory. Its sub-tags are optional. The **distributionFilter** tag 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 the following factors: screen shape, screen size, screen resolution, and country/region code. During distribution, a unique HAP is determined based on the mapping between **deviceType** and these five factors. This tag must be configured in the **/resource/profile resource** directory. Its sub-tags are optional.
**Table 12** distributionFilter **Table 12** distributionFilter
...@@ -797,3 +801,35 @@ Example of the **dependencies** structure: ...@@ -797,3 +801,35 @@ Example of the **dependencies** structure:
} }
} }
``` ```
## proxyDatas
The **proxyDatas** tag provides the list of data proxies provided by the module. It can be configured only for entry and feature modules.
**Table 21** proxyDatas
| Name | Description | Data Type| Initial Value Allowed|
| ----------- | ------------------------------ | -------- | ---------- |
| uri | URI of the data proxy. The URIs configured for different data proxies must be unique and must be in the *datashareproxy://Current application package name/xxx* format. | String | No|
| requiredReadPermission | Permission required for reading data from the data proxy. For non-system applications, this field is mandatory, and the permission level must be system_basic or system_core. For system applications, this field is optional, and the permission level is not limited. For details about the permission level, see [Application Permission List](../security/permission-list.md).| String | Yes (initial value: left empty)|
| requiredWritePermission | Permission required for writing data to the data proxy. For non-system applications, this field is mandatory, and the permission level must be system_basic or system_core. For system applications, this field is optional, and the permission level is not limited. For details about the permission level, see [Application Permission List](../security/permission-list.md).| String | Yes (initial value: left empty)|
| [metadata](#metadata)| Metadata of the data proxy. Only the **name** and **resource** fields can be configured.| Object| Yes (initial value: left empty)|
Example of the **proxyDatas** structure:
```json
{
"module": {
"proxyDatas": [
{
"uri":"datashareproxy://com.ohos.datashare/event/Meeting",
"requiredReadPermission": "ohos.permission.GET_BUNDLE_INFO",
"requiredWritePermission": "ohos.permission.GET_BUNDLE_INFO",
"metadata": {
"name": "datashare_metadata",
"resource": "$profile:datashare"
}
}
]
}
}
```
...@@ -20,10 +20,11 @@ The **module** tag contains the HAP configuration. ...@@ -20,10 +20,11 @@ The **module** tag contains the HAP configuration.
| shortcuts | Shortcuts of the application. The value is an array of objects, each of which represents a shortcut object.| Object array| Yes (initial value: left empty)| | shortcuts | Shortcuts of the application. The value is an array of objects, each of which represents a shortcut object.| Object array| Yes (initial value: left empty)|
| reqPermissions | Permissions that the application requests from the system when it is running.| Object array| Yes (initial value: left empty)| | 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:<br>- **dark**: Resources applicable for the dark mode are used.<br>- **light**: Resources applicable for the light mode are used.<br>- **auto**: Resources are used based on the color mode of the system.| String| Yes (initial value: **auto**)| | colorMode | Color mode of the application. The options are as follows:<br>- **dark**: Resources applicable for the dark mode are used.<br>- **light**: Resources applicable for the light mode are used.<br>- **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.| | distributionFilter | 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 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)| |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)| | 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)| |testRunner | Test runner configuration.| Object| Yes (initial value: left empty)|
|generateBuildHash |Whether the hash value of the HAP or HSP file is generated by the packaging tool. The hash value (if any) is used to determine whether the application needs to be updated when the system is updated in OTA mode but the value of [code](#internal-structure-of-the-apiversion-attribute) in **version** of the application remains unchanged.<br>**NOTE**<br>This tag applies only to system applications.|Boolean|Yes (initial value: **false**)|
Example of the **module** tag structure: Example of the **module** tag structure:
...@@ -268,7 +269,7 @@ Note: The label displayed on the application details screen may be different fro ...@@ -268,7 +269,7 @@ Note: The label displayed on the application details screen may be different fro
| 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"**.<br>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| | 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"**.<br>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)| | 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.<br>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)| | 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.<br>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.<br>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)| | label | Ability name displayed to users. The value can be a name string or a resource index to names in multiple languages, for example, **$string:ability_label**. 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.<br>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)|
| uri | Uniform Resource Identifier (URI) of the ability. The value can contain a maximum of 255 bytes.| String| Yes (No for abilities using the Data template)| | uri | Uniform Resource Identifier (URI) of the ability. The value can contain a maximum of 255 bytes.| String| Yes (No for abilities using the Data template)|
| launchType | Launch type of the ability. The value can be **standard** or **singleton**.<br>**standard**: Multiple **Ability** instances can be created during startup. Most abilities can use this type.<br>**singleton**: Only a single **Ability** instance can be created across all task stacks during startup. For example, a globally unique incoming call screen uses the singleton launch type. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String| Yes (initial value: **"singleton"**)| | launchType | Launch type of the ability. The value can be **standard** or **singleton**.<br>**standard**: Multiple **Ability** instances can be created during startup. Most abilities can use this type.<br>**singleton**: Only a single **Ability** instance can be created across all task stacks during startup. For example, a globally unique incoming call screen uses the singleton launch type. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String| Yes (initial value: **"singleton"**)|
| visible | Whether the ability can be called by other applications.<br>**true**: The ability can be called by other applications.<br>**false**: The ability cannot be called by other applications.| Boolean| Yes (initial value: **false**)| | visible | Whether the ability can be called by other applications.<br>**true**: The ability can be called by other applications.<br>**false**: The ability cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
...@@ -380,7 +381,7 @@ Example of the **abilities** attribute structure: ...@@ -380,7 +381,7 @@ Example of the **abilities** attribute structure:
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| actions | Actions of the **want** that can be accepted by the ability. Generally, the value is an **action** value predefined in the system.| String array| Yes (initial value: left empty)| | actions | Actions of the **want** that can be accepted by the ability. Generally, the value is an **action** value predefined in the system.| String array| Yes (initial value: left empty)|
| entities | Entities of the **want** that can be accepted by the ability, such as video and home applications.| String array| Yes (initial value: left empty)| | entities | Entities of the **want** that can be accepted by the ability, such as video and home applications.| String array| Yes (initial value: left empty)|
| uris | Data specifications to be added to the want filter. The specification can be of data type only (**mimeType** attribute), URI only, or both.<br>The URI is specified by separate attributes of each part: &lt;scheme&gt;://&lt;host&gt;:&lt;port&gt;[&lt;path&gt;\|&lt;pathStartWith&gt;\|&lt;pathRegex&gt;]. <br>**scheme** is mandatory when the specification is of the URI type and is optional when the specification is of data type only.| Object array| Yes (initial value: left empty)| | uris | Data specifications to be added to the want filter. The specification is a data type (using the **mimeType** attribute), a URI, or both a data type and a URI.<br>The URI is specified by separate attributes of each part: &lt;scheme&gt;://&lt;host&gt;:&lt;port&gt;[&lt;path&gt;\|&lt;pathStartWith&gt;\|&lt;pathRegex&gt;]. <br>**scheme** is mandatory when the specification is of the URI type and is optional when the specification is a data type. | Object array| Yes (initial value: left empty)|
## Internal Structure of the uris Attribute ## Internal Structure of the uris Attribute
...@@ -614,9 +615,9 @@ Example of the **forms** attribute structure: ...@@ -614,9 +615,9 @@ Example of the **forms** attribute structure:
] ]
``` ```
## Internal Structure of the distroFilter Attribute ## Internal Structure of the distributionFilter Attribute
**Table 21** Internal structure of the distroFilter attribute **Table 21** Internal structure of the distributionFilter attribute
| Name| Description| Data Type| Initial Value Allowed| | Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -672,10 +673,10 @@ Example of the **forms** attribute structure: ...@@ -672,10 +673,10 @@ Example of the **forms** attribute structure:
| value | Country code of the area to which the application is to be distributed. The value is a string array, of which each substring indicates a country or region. The substring consists of two uppercase letters.| String array| No| | value | Country code of the area to which the application is to be distributed. The value is a string array, of which each substring indicates a country or region. The substring consists of two uppercase letters.| String array| No|
Example of the **distroFilter** attribute structure: Example of the **distributionFilter** attribute structure:
```json ```json
"distroFilter": { "distributionFilter": {
"apiVersion": { "apiVersion": {
"policy": "include", "policy": "include",
"value": [4,5] "value": [4,5]
......
...@@ -6,5 +6,3 @@ ...@@ -6,5 +6,3 @@
- Flexible deployment: You can flexibly combine HAP files for device-specific deployment. Assume that an application contains one entry-type HAP file (**entry.hap**) and two feature-type HAP files (**Feature1.hap** and **Feature2.hap**). The **Entry.hap** file can be deployed on device A and device B, the **Feature1.hap** file can be deployed only on device A, and the **Feature2.hap** can be deployed only on device B. This means that you can combine the **Entry.hap** and **Feature1.hap** files and deploy them on device A, and combine the **Entry.hap** and **Feature2.hap** files and deploy them on device B. - Flexible deployment: You can flexibly combine HAP files for device-specific deployment. Assume that an application contains one entry-type HAP file (**entry.hap**) and two feature-type HAP files (**Feature1.hap** and **Feature2.hap**). The **Entry.hap** file can be deployed on device A and device B, the **Feature1.hap** file can be deployed only on device A, and the **Feature2.hap** can be deployed only on device B. This means that you can combine the **Entry.hap** and **Feature1.hap** files and deploy them on device A, and combine the **Entry.hap** and **Feature2.hap** files and deploy them on device B.
- On-demand loading: You can load modules only when they are needed, reducing the package size. Specifically, you can configure some HAP files of your application to be loaded on demand. For example, if some features are not used during application startup, you can configure them to be loaded only when they are needed, rather than being loaded at startup. This can reduce the size of the application package to some extent. - On-demand loading: You can load modules only when they are needed, reducing the package size. Specifically, you can configure some HAP files of your application to be loaded on demand. For example, if some features are not used during application startup, you can configure them to be loaded only when they are needed, rather than being loaded at startup. This can reduce the size of the application package to some extent.
- Easier resource sharing: The resources (including public resource files and public pages) and shared objects (.so library files) required by multiple HAP files can be stored in an independent HAP file. In this way, other HAP files can obtain the resources and files by accessing the HAP, which also reduces the size of the application package to some extent.
...@@ -46,7 +46,7 @@ The command contains the following options: ...@@ -46,7 +46,7 @@ The command contains the following options:
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: 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 ```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 $ java -jar app_packing_tool.jar --mode hqf --json-path patch.json --lib-path libs --ets-path patchs --out-path entry-default-unsigned.hqf --force true
``` ```
The command contains the following options. The command contains the following options.
......
...@@ -8,13 +8,11 @@ Both the HAR and HSP are used to share code and resources and can contain code, ...@@ -8,13 +8,11 @@ Both the HAR and HSP are used to share code and resources and can contain code,
![in-app-hsp-har](figures/in-app-hsp-har.png) ![in-app-hsp-har](figures/in-app-hsp-har.png)
The HSP is designed to solve the following issues with the HAR: The HSP aims to resolve the App Pack bloat resulting from multiple HAP files referencing the same 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: Restrictions on the HSP:
- The HSP and its invoking modules must be in the stage model. - 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 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 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. 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.
...@@ -41,6 +41,6 @@ To help you better understand the preceding basic concepts and application devel ...@@ -41,6 +41,6 @@ To help you better understand the preceding basic concepts and application devel
1. Download the latest version of [DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio). 1. Download the latest version of [DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio).
2. Install DevEco Studio and configure the development environment. For details, see [Setting Up the Development Environment](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-setting-up-environment-0000001263160443). 2. Install DevEco Studio and configure the development environment. For details, see [Setting Up the Development Environment](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/environment_config-0000001052902427-V3).
When you are done, follow the instructions in [Getting Started with ArkTS in Stage Model](start-with-ets-stage.md), [Getting Started with ArkTS in FA Model](start-with-ets-fa.md), and [Getting Started with JavaScript in FA Model](start-with-js-fa.md). When you are done, follow the instructions in [Getting Started with ArkTS in Stage Model](start-with-ets-stage.md), [Getting Started with ArkTS in FA Model](start-with-ets-fa.md), and [Getting Started with JavaScript in FA Model](start-with-js-fa.md).
...@@ -5,18 +5,18 @@ ...@@ -5,18 +5,18 @@
> >
> To use ArkTS, your DevEco Studio must be V3.0.0.601 Beta1 or later. > To use ArkTS, your DevEco Studio must be V3.0.0.601 Beta1 or later.
> >
> For best possible results, use [DevEco Studio 3.1 Beta1](https://developer.harmonyos.com/cn/develop/deveco-studio) for your development. > For best possible results, use [DevEco Studio 3.1 Beta2](https://developer.harmonyos.com/cn/develop/deveco-studio) for your development.
## Creating an ArkTS Project ## Creating an ArkTS Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **OpenHarmony** tab of the **Choose Your Ability Template** page, select **Empty Ability** and click **Next**. 1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next.
![01](figures/01.png) ![createProject](figures/createProject.png)
2. In the project configuration page, set **Compile SDK** to **8** or **9** (in the latter case, you also need to set **Model** to **FA**) and **Language** to **ArkTS** and retain the default values for other parameters. 2. In the project configuration page, set **Compile SDK** to **8** or **9** (in the latter case, you also need to set **Model** to **FA**) and **Language** to **ArkTS** and retain the default values for other parameters.
![02](figures/02.png) ![chooseFAModel_ets](figures/chooseFAModel_ets.png)
> **NOTE** > **NOTE**
> >
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
> To use the low-code development mode, turn on **Enable Super Visual** on the page shown above. > To use the low-code development mode, turn on **Enable Super Visual** on the page shown above.
3. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created. 3. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created.
4. After the project is created, in the **entry** > **build-profile.json5** file, change **runtimeOS** under **targets** to **OpenHarmony**, and click **Sync Now** in the upper right corner to start development.
## ArkTS Project Directory Structure (FA Model) ## ArkTS Project Directory Structure (FA Model)
...@@ -41,11 +42,9 @@ ...@@ -41,11 +42,9 @@
- **src > main > ets > MainAbility > app.ets**: ability lifecycle file. - **src > main > ets > MainAbility > app.ets**: ability lifecycle file.
- **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). - **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).
- **src > main > config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. For details, see [Application Configuration File Overview (FA Model)](application-configuration-file-overview-fa.md). - **src > main > config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. For details, see [Application Configuration File Overview (FA Model)](application-configuration-file-overview-fa.md).
- **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**. - **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**. Under **targets**, you can set **runtimeOS** to **HarmonyOS** (default) or **OpenHarmony**, depending on the OS of your application.
- **hvigorfile.ts**: module-level build script. You can customize related tasks and code implementation. - **hvigorfile.ts**: module-level build script. You can customize related tasks and code implementation.
- **build-profile.json5**: application-level configuration information, including the signature and product configuration. - **build-profile.json5**: application-level configuration information, including the signature and product configuration.
- **hvigorfile.ts**: application-level build script. - **hvigorfile.ts**: application-level build script.
...@@ -291,7 +290,7 @@ You can implement page redirection through the [page router](../reference/apis/j ...@@ -291,7 +290,7 @@ You can implement page redirection through the [page router](../reference/apis/j
2. Choose **File** > **Project Structure...** > **Project** > **SigningConfigs**, and select **Automatically generate signature**. Wait until the automatic signing is complete, and click **OK**. See the following figure. 2. Choose **File** > **Project Structure...** > **Project** > **SigningConfigs**, and select **Automatically generate signature**. Wait until the automatic signing is complete, and click **OK**. See the following figure.
![06](figures/06.png) ![signConfig](figures/signConfig.png)
3. On the toolbar in the upper right corner of the editing window, click ![en-us_image_0000001364054485](figures/en-us_image_0000001364054485.png). The display effect is shown in the figure below. 3. On the toolbar in the upper right corner of the editing window, click ![en-us_image_0000001364054485](figures/en-us_image_0000001364054485.png). The display effect is shown in the figure below.
......
...@@ -5,18 +5,18 @@ ...@@ -5,18 +5,18 @@
> >
> To use ArkTS, your DevEco Studio must be V3.0.0.900 Beta3 or later. > To use ArkTS, your DevEco Studio must be V3.0.0.900 Beta3 or later.
> >
> For best possible results, use [DevEco Studio 3.1 Beta1](https://developer.harmonyos.com/cn/develop/deveco-studio) for your development. > For best possible results, use [DevEco Studio 3.1 Beta2](https://developer.harmonyos.com/cn/develop/deveco-studio) for your development.
## Creating an ArkTS Project ## Creating an ArkTS Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **OpenHarmony** tab of the **Choose Your Ability Template** page, select **Empty Ability** and click **Next**. 1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next.
![01](figures/01.png) ![createProject](figures/createProject.png)
2. On the project configuration page, set **Compile SDK** to **9**, **Model** to **Stage**, and retain the default values for other parameters. 2. On the project configuration page, set **Compile SDK** to **9**, **Model** to **Stage**, and retain the default values for other parameters.
![07](figures/07.png) ![chooseStageModel](figures/chooseStageModel.png)
> **NOTE** > **NOTE**
> >
...@@ -28,22 +28,24 @@ ...@@ -28,22 +28,24 @@
3. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created. 3. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created.
4. After the project is created, in the **entry** > **build-profile.json5** file, change **runtimeOS** under **targets** to **OpenHarmony**, and click **Sync Now** in the upper right corner to start development.
## ArkTS Project Directory Structure (Stage Model) ## ArkTS Project Directory Structure (Stage Model)
![en-us_image_0000001364054489](figures/en-us_image_0000001364054489.png) ![en-us_image_0000001364054489](figures/en-us_image_0000001364054489.png)
- **AppScope** > **app.json5**: global configuration of your application.
- **entry**: OpenHarmony project module, which can be built into an OpenHarmony Ability Package ([HAP](../../glossary.md#hap)). - **entry**: OpenHarmony project module, which can be built into an OpenHarmony Ability Package ([HAP](../../glossary.md#hap)).
- **oh_modules**: third-party library dependency information. For details about how to adapt a historical npm project to ohpm, see [Manually Migrating Historical Projects](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/project_overview-0000001053822398-V3#section108143331212).
- **src > main > ets**: a collection of ArkTS source code. - **src > main > ets**: a collection of ArkTS source code.
- **src > main > ets > entryability**: entry to your application/service. - **src > main > ets > entryability**: entry to your application/service.
- **src > main > ets > pages**: pages included in 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). - **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).
- **src > main > module.json5**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. For details, see [module.json5 Configuration File](module-configuration-file.md). - **src > main > module.json5**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. For details, see [module.json5 Configuration File](module-configuration-file.md).
- **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**. - **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**. Under **targets**, you can set **runtimeOS** to **HarmonyOS** (default) or **OpenHarmony**, depending on the OS of your application.
- **hvigorfile.ts**: module-level build script. You can customize related tasks and code implementation. - **hvigorfile.ts**: module-level build script. You can customize related tasks and code implementation.
- **build-profile.json5**: application-level configuration information, including the signature and product configuration. - **build-profile.json5**: application-level configuration information, including the signature and product configuration.
- **hvigorfile.ts**: application-level build script. - **hvigorfile.ts**: application-level build script.
...@@ -123,7 +125,7 @@ ...@@ -123,7 +125,7 @@
- Create the second page file: In the **Project** window, choose **entry** > **src** > **main** > **ets**. Right-click the **pages** folder, choose **New** > **ArkTS File**, name the page **Second**, and click **Finish**. Below is the structure of the **Second** folder. - Create the second page file: In the **Project** window, choose **entry** > **src** > **main** > **ets**. Right-click the **pages** folder, choose **New** > **ArkTS File**, name the page **Second**, and click **Finish**. Below is the structure of the **Second** folder.
![09](figures/09.png) ![secondPage](figures/secondPage.png)
> **NOTE** > **NOTE**
> >
...@@ -281,7 +283,7 @@ You can implement page redirection through the [page router](../reference/apis/j ...@@ -281,7 +283,7 @@ You can implement page redirection through the [page router](../reference/apis/j
2. Choose **File** > **Project Structure...** > **Project** > **SigningConfigs**, and select **Automatically generate signature**. Wait until the automatic signing is complete, and click **OK**. See the following figure. 2. Choose **File** > **Project Structure...** > **Project** > **SigningConfigs**, and select **Automatically generate signature**. Wait until the automatic signing is complete, and click **OK**. See the following figure.
![06](figures/06.png) ![signConfig](figures/signConfig.png)
3. On the toolbar in the upper right corner of the editing window, click ![en-us_image_0000001364054485](figures/en-us_image_0000001364054485.png). The display effect is shown in the figure below. 3. On the toolbar in the upper right corner of the editing window, click ![en-us_image_0000001364054485](figures/en-us_image_0000001364054485.png). The display effect is shown in the figure below.
......
...@@ -3,18 +3,18 @@ ...@@ -3,18 +3,18 @@
> **NOTE** > **NOTE**
> >
> For best possible results, use [DevEco Studio 3.1 Beta1](https://developer.harmonyos.com/cn/develop/deveco-studio#download) for your development. > For best possible results, use [DevEco Studio 3.1 Beta2](https://developer.harmonyos.com/cn/develop/deveco-studio#download) for your development.
## Creating a JavaScript Project ## Creating a JavaScript Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **OpenHarmony** tab of the **Choose Your Ability Template** page, select **Empty Ability** and click **Next**. 1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next.
![01](figures/01.png) ![createProject](figures/createProject.png)
2. In the project configuration page, set **Compile SDK** to **8** or **9** (in the latter case, you also need to set **Model** to **FA**) and **Language** to **JS** and retain the default values for other parameters. 2. In the project configuration page, set **Compile SDK** to **8** or **9** (in the latter case, you also need to set **Model** to **FA**) and **Language** to **JS** and retain the default values for other parameters.
![04](figures/04.png) ![chooseFAModel_js](figures/chooseFAModel_js.png)
> **NOTE** > **NOTE**
> >
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
3. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created. 3. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created.
4. After the project is created, in the **entry** > **build-profile.json5** file, change **runtimeOS** under **targets** to **OpenHarmony**, and click **Sync Now** in the upper right corner to start development.
## JavaScript Project Directory Structure ## JavaScript Project Directory Structure
...@@ -40,7 +42,7 @@ ...@@ -40,7 +42,7 @@
- **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 Limitations and Access](../ui/js-framework-resource-restriction.md). - **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 Limitations and Access](../ui/js-framework-resource-restriction.md).
- **src > main > config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. For details, see [Application Configuration File Overview (FA Model)](application-configuration-file-overview-fa.md). - **src > main > config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. For details, see [Application Configuration File Overview (FA Model)](application-configuration-file-overview-fa.md).
- **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**. - **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**. Under **targets**, you can set **runtimeOS** to **HarmonyOS** (default) or **OpenHarmony**, depending on the OS of your application.
- **hvigorfile.ts**: module-level build script. You can customize related tasks and code implementation. - **hvigorfile.ts**: module-level build script. You can customize related tasks and code implementation.
- **build-profile.json5**: application-level configuration information, including the signature and product configuration. - **build-profile.json5**: application-level configuration information, including the signature and product configuration.
...@@ -226,7 +228,7 @@ You can implement page redirection through the [page router](../reference/apis/j ...@@ -226,7 +228,7 @@ You can implement page redirection through the [page router](../reference/apis/j
2. Choose **File** > **Project Structure...** > **Project** > **Signing Configs**, and select **Automatically generate signature**. Wait until the automatic signing is complete, and click **OK**. See the following figure. 2. Choose **File** > **Project Structure...** > **Project** > **Signing Configs**, and select **Automatically generate signature**. Wait until the automatic signing is complete, and click **OK**. See the following figure.
![06](figures/06.png) ![signConfig](figures/signConfig.png)
3. On the toolbar in the upper right corner of the editing window, click ![en-us_image_0000001364054485](figures/en-us_image_0000001364054485.png). The display effect is shown in the figure below. 3. On the toolbar in the upper right corner of the editing window, click ![en-us_image_0000001364054485](figures/en-us_image_0000001364054485.png). The display effect is shown in the figure below.
......
...@@ -152,6 +152,7 @@ ...@@ -152,6 +152,7 @@
- bundleManager - bundleManager
- [abilityInfo](js-apis-bundleManager-abilityInfo.md) - [abilityInfo](js-apis-bundleManager-abilityInfo.md)
- [applicationInfo](js-apis-bundleManager-applicationInfo.md) - [applicationInfo](js-apis-bundleManager-applicationInfo.md)
- [AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo.md)
- [bundleInfo](js-apis-bundleManager-bundleInfo.md) - [bundleInfo](js-apis-bundleManager-bundleInfo.md)
- [BundlePackInfo](js-apis-bundleManager-BundlePackInfo.md) - [BundlePackInfo](js-apis-bundleManager-BundlePackInfo.md)
- [dispatchInfo](js-apis-bundleManager-dispatchInfo.md) - [dispatchInfo](js-apis-bundleManager-dispatchInfo.md)
...@@ -166,6 +167,7 @@ ...@@ -166,6 +167,7 @@
- UI Page - UI Page
- [@ohos.animator (Animator)](js-apis-animator.md) - [@ohos.animator (Animator)](js-apis-animator.md)
- [@ohos.arkui.drawableDescriptor (DrawableDescriptor)](js-apis-arkui-drawableDescriptor.md)
- [@ohos.curves (Interpolation Calculation)](js-apis-curve.md) - [@ohos.curves (Interpolation Calculation)](js-apis-curve.md)
- [@ohos.matrix4 (Matrix Transformation)](js-apis-matrix4.md) - [@ohos.matrix4 (Matrix Transformation)](js-apis-matrix4.md)
- [@ohos.mediaquery (Media Query)](js-apis-mediaquery.md) - [@ohos.mediaquery (Media Query)](js-apis-mediaquery.md)
...@@ -312,8 +314,6 @@ ...@@ -312,8 +314,6 @@
- [Timer](js-apis-timer.md) - [Timer](js-apis-timer.md)
- application - application
- [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md) - [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md)
- imf
- [InputMethodCommon](js-apis-inputmethod-InputMethodCommon.md)
- Device Management - Device Management
- [@ohos.batteryInfo (Battery Information)](js-apis-battery-info.md) - [@ohos.batteryInfo (Battery Information)](js-apis-battery-info.md)
...@@ -354,8 +354,8 @@ ...@@ -354,8 +354,8 @@
- Customization - Customization
- [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md) - [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md)
- [@ohos.enterprise.accountManager (Account Management)](js-apis-enterprise-accountManager.md) - [@ohos.enterprise.accountManager (Account Management)](js-apis-enterprise-accountManager.md)
- [@ohos.enterprise.bundleManager (Bundle Management)](js-apis-enterprise-bundleManager.md)
- [@ohos.enterprise.adminManager (Enterprise Device Management)](js-apis-enterprise-adminManager.md) - [@ohos.enterprise.adminManager (Enterprise Device Management)](js-apis-enterprise-adminManager.md)
- [@ohos.enterprise.bundleManager (Bundle Management)](js-apis-enterprise-bundleManager.md)
- [@ohos.enterprise.dateTimeManager (System Time Management)](js-apis-enterprise-dateTimeManager.md) - [@ohos.enterprise.dateTimeManager (System Time Management)](js-apis-enterprise-dateTimeManager.md)
- [@ohos.enterprise.deviceControl (Device Control Management)](js-apis-enterprise-deviceControl.md) - [@ohos.enterprise.deviceControl (Device Control Management)](js-apis-enterprise-deviceControl.md)
- [@ohos.enterprise.deviceInfo (Device Information Management)](js-apis-enterprise-deviceInfo.md) - [@ohos.enterprise.deviceInfo (Device Information Management)](js-apis-enterprise-deviceInfo.md)
......
...@@ -486,8 +486,8 @@ Enumerates the audio channels. ...@@ -486,8 +486,8 @@ Enumerates the audio channels.
| Name | Value | Description | | Name | Value | Description |
| --------- | -------- | -------- | | --------- | -------- | -------- |
| CHANNEL_1 | 0x1 << 0 | Mono.| | CHANNEL_1 | 0x1 << 0 | Channel 1. |
| CHANNEL_2 | 0x1 << 1 | Dual-channel.| | CHANNEL_2 | 0x1 << 1 | Channel 2. |
## AudioSamplingRate<sup>8+</sup> ## AudioSamplingRate<sup>8+</sup>
......
# AppProvisionInfo
The **AppProvisionInfo** module provides information in the [HarmonyAppProvision configuration file](../../security/app-provision-structure.md). The information can be obtained through [getAppProvisionInfo](js-apis-bundleManager.md#bundlemanagergetappprovisioninfo10).
> **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.
## AppProvisionInfo
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
**System API**: This is a system API.
| Name | Type | Readable| Writable| Description |
| ------------------------- | ------ | ---- | ---- | -------------------- |
| versionCode | number | Yes | No | Version number of the configuration file.|
| versionName | string | Yes | No | Version name of the configuration file. |
| uuid | string | Yes | No | UUID in the configuration file.|
| type | string | Yes | No | Type of the configuration file, which can be **debug** or **release**.|
| appDistributionType | string | Yes | No | Distribution type in the configuration file, which can be **app_gallery**, **enterprise**, **os_integration**, or **crowdtesting**.|
| validity | [Validity](#validity) | Yes | No | Validity period in the configuration file.|
| developerId | string | Yes | No | Developer ID in the configuration file.|
| certificate | string | Yes | No | Certificate public key in the configuration file.|
| apl | string | Yes | No | APL in the configuration file, which can be **normal**, **system_basic**, or **system_core**.|
| issuer | string | Yes | No | Issuer name in the configuration file.|
## Validity
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
**System API**: This is a system API.
| Name | Type | Readable| Writable| Description |
| ------------------------- | ------ | ---- | ---- | -------------------- |
| notBefore | number | Yes | No | Earliest validity date of the configuration file.|
| notAfter | number | Yes | No | Latest validity date of the configuration file.|
...@@ -401,7 +401,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc ...@@ -401,7 +401,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message | | ID| Error Message |
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700004 | The specified user ID is not found. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**Example** **Example**
...@@ -446,7 +445,7 @@ No permission is required for obtaining the caller's own information. ...@@ -446,7 +445,7 @@ No permission is required for obtaining the caller's own information.
| ----------- | ------ | ---- | ---------------------------- | | ----------- | ------ | ---- | ---------------------------- |
| bundleName | string | Yes | Bundle name.| | bundleName | string | Yes | Bundle name.|
| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain. | | bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain. |
| userId | number | No | User ID. | | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
**Return value** **Return value**
...@@ -587,7 +586,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc ...@@ -587,7 +586,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message | | ID| Error Message |
| -------- | --------------------------------------| | -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700004 | The specified user ID is not found. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**Example** **Example**
...@@ -631,7 +629,7 @@ No permission is required for obtaining the caller's own information. ...@@ -631,7 +629,7 @@ No permission is required for obtaining the caller's own information.
| ---------- | ------ | ---- | ---------------------------- | | ---------- | ------ | ---- | ---------------------------- |
| bundleName | string | Yes | Bundle name.| | bundleName | string | Yes | Bundle name.|
| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | | appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. |
| userId | number | No | User ID.| | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
**Return value** **Return value**
...@@ -737,14 +735,6 @@ Obtains the information about all bundles based on the given bundle flags. This ...@@ -737,14 +735,6 @@ Obtains the information about all bundles based on the given bundle flags. This
| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain. | | bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain. |
| callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of bundle information obtained. Otherwise, **err** is an error object.| | callback | AsyncCallback<Array\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of bundle information 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 |
| -------- | ---------------------------------- |
| 17700004 | The specified user ID is not found. |
**Example** **Example**
```ts ```ts
...@@ -782,7 +772,7 @@ Obtains the information about all bundles based on the given bundle flags and us ...@@ -782,7 +772,7 @@ Obtains the information about all bundles based on the given bundle flags and us
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | -------------------------------------------------- | | ----------- | ------ | ---- | -------------------------------------------------- |
| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain. | | bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain. |
| userId | number | No | User ID. | | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
**Return value** **Return value**
...@@ -884,14 +874,6 @@ Obtains the information about all applications based on the given application fl ...@@ -884,14 +874,6 @@ Obtains the information about all applications based on the given application fl
| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | | appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. |
| callback | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of application information obtained. Otherwise, **err** is an error object.| | callback | AsyncCallback<Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of application information 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 |
| -------- | ---------------------------------- |
| 17700004 | The specified user ID is not found. |
**Example** **Example**
```ts ```ts
...@@ -929,7 +911,7 @@ Obtains the information about all applications based on the given application fl ...@@ -929,7 +911,7 @@ Obtains the information about all applications based on the given application fl
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---------------------------------------------------------- | | -------- | ------ | ---- | ---------------------------------------------------------- |
| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | | appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. |
| userId | number | No | User ID. | | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
**Return value** **Return value**
...@@ -1050,7 +1032,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc ...@@ -1050,7 +1032,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700003 | The specified ability is not found. | | 17700003 | The specified ability is not found. |
| 17700004 | The specified userId is invalid. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
| 17700029 | The specified ability is disabled. | | 17700029 | The specified ability is disabled. |
...@@ -1096,7 +1077,7 @@ Obtains the ability information based on the given want, ability flags, and user ...@@ -1096,7 +1077,7 @@ Obtains the ability information based on the given want, ability flags, and user
| ------------ | ------ | ---- | ------------------------------------------------------- | | ------------ | ------ | ---- | ------------------------------------------------------- |
| want | Want | Yes | Want containing the bundle name to query. | | want | Want | Yes | Want containing the bundle name to query. |
| abilityFlags | [number](#abilityflag) | Yes | Type of the ability information to obtain.| | abilityFlags | [number](#abilityflag) | Yes | Type of the ability information to obtain.|
| userId | number | No | User ID. | | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
**Return value** **Return value**
...@@ -1247,7 +1228,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc ...@@ -1247,7 +1228,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700003 | The specified extensionAbility is not found. | | 17700003 | The specified extensionAbility is not found. |
| 17700004 | The specified userId is invalid. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**Example** **Example**
...@@ -1294,7 +1274,7 @@ Obtains the Extension ability information based on the given want, Extension abi ...@@ -1294,7 +1274,7 @@ Obtains the Extension ability information based on the given want, Extension abi
| want | Want | Yes | Want containing the bundle name to query. | | want | Want | Yes | Want containing the bundle name to query. |
| extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | Yes | Type of the Extension ability. | | extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | Yes | Type of the Extension ability. |
| extensionAbilityFlags | [number](#extensionabilityflag) | Yes | Type of the Extension ability information to obtain.| | extensionAbilityFlags | [number](#extensionabilityflag) | Yes | Type of the Extension ability information to obtain.|
| userId | number | No | User ID. | | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
**Return value** **Return value**
...@@ -2171,7 +2151,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc ...@@ -2171,7 +2151,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message | | ID| Error Message |
| -------- | --------------------------------------| | -------- | --------------------------------------|
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700004 | The specified user ID is not found. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
**Example** **Example**
...@@ -2211,7 +2190,7 @@ Obtains the Want used to launch the bundle based on the given bundle name and us ...@@ -2211,7 +2190,7 @@ Obtains the Want used to launch the bundle based on the given bundle name and us
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ------------------------- | | ---------- | ------ | ---- | ------------------------- |
| bundleName | string | Yes | Bundle name.| | bundleName | string | Yes | Bundle name.|
| userId | number | No | User ID. | | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
**Return value** **Return value**
...@@ -2313,7 +2292,7 @@ Obtains the JSON strings of the configuration file based on the given module ame ...@@ -2313,7 +2292,7 @@ Obtains the JSON strings of the configuration file based on the given module ame
| ------------ | ------ | ---- | -------------------------- | | ------------ | ------ | ---- | -------------------------- |
| moduleName | string | Yes | Module name. | | moduleName | string | Yes | Module name. |
| abilityName | string | Yes | Ability name. | | abilityName | string | Yes | Ability name. |
| metadataName | string | No | Metadata name.| | metadataName | string | No | Metadata name. By default, no value is passed.|
**Return value** **Return value**
...@@ -2433,7 +2412,7 @@ Obtains the JSON strings of the configuration file based on the given module ame ...@@ -2433,7 +2412,7 @@ Obtains the JSON strings of the configuration file based on the given module ame
| -------------------- | ------ | ---- | ---------------------------------- | | -------------------- | ------ | ---- | ---------------------------------- |
| moduleName | string | Yes | Module name. | | moduleName | string | Yes | Module name. |
| extensionAbilityName | string | Yes | Extension ability name.| | extensionAbilityName | string | Yes | Extension ability name.|
| metadataName | string | No | Metadata name. | | metadataName | string | No | Metadata name. By default, no value is passed. |
**Return value** **Return value**
...@@ -2948,7 +2927,7 @@ try { ...@@ -2948,7 +2927,7 @@ try {
### bundleManager.getSharedBundleInfo<sup>10+</sup> ### bundleManager.getSharedBundleInfo<sup>10+</sup>
function getSharedBundleInfo(bundleName: string, moduleName: string): Promise\<Array\<SharedBundleInfo\>\>; getSharedBundleInfo(bundleName: string, moduleName: string): Promise\<Array\<SharedBundleInfo\>\>;
Obtains the shared bundle information based on the given bundle name. This API uses a promise to return the result. Obtains the shared bundle information based on the given bundle name. This API uses a promise to return the result.
...@@ -3038,7 +3017,7 @@ try { ...@@ -3038,7 +3017,7 @@ try {
### bundleManager.getAllSharedBundleInfo<sup>10+</sup> ### bundleManager.getAllSharedBundleInfo<sup>10+</sup>
function getAllSharedBundleInfo(): Promise\<Array\<SharedBundleInfo\>\>; getAllSharedBundleInfo(): Promise\<Array\<SharedBundleInfo\>\>;
Obtains the information about all shared bundles. This API uses a promise to return the result. Obtains the information about all shared bundles. This API uses a promise to return the result.
...@@ -3186,7 +3165,7 @@ Obtains the provision configuration file information based on the given bundle n ...@@ -3186,7 +3165,7 @@ Obtains the provision configuration file information based on the given bundle n
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| bundleName | string | Yes| Bundle name.| | bundleName | string | Yes| Bundle name.|
| userId | number | No| User ID, which can be obtained by calling [getOsAccountLocalId](js-apis-osAccount.md#getosaccountlocalid9).| | userId | number | No| User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. You can call [getOsAccountLocalId](js-apis-osAccount.md#getosaccountlocalid9) to obtain the user ID on the current device.|
**Return value** **Return value**
...@@ -3232,5 +3211,3 @@ try { ...@@ -3232,5 +3211,3 @@ try {
hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message);
} }
``` ```
<!--no_check-->
\ No newline at end of file
...@@ -203,7 +203,7 @@ Curves.responsiveSpringMotion() // Create a responsive spring animation curve wi ...@@ -203,7 +203,7 @@ Curves.responsiveSpringMotion() // Create a responsive spring animation curve wi
``` ```
## Curves.interpolatingSpringCurve<sup>10+</sup> ## Curves.interpolatingSpring<sup>10+</sup>
interpolatingSpring(velocity: number, mass: number, stiffness: number, damping: number): ICurve interpolatingSpring(velocity: number, mass: number, stiffness: number, damping: number): ICurve
......
...@@ -496,10 +496,10 @@ Defines the axis type of an input device. ...@@ -496,10 +496,10 @@ Defines the axis type of an input device.
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| --------- | ------ | ---- | ---- | ------- | | --------- | ------ | ---- | ---- | ------- |
| touchMajor | string | Yes| No| touchMajor axis. | | touchmajor | string | Yes| No| touchmajor axis. |
| touchMinor | string | Yes| No| touchMinor axis. | | touchminor | string | Yes| No| touchminor axis. |
| toolMinor | string | Yes| No| toolMinor axis. | | toolminor | string | Yes| No| toolminor axis. |
| toolMajor | string | Yes| No| toolMajor axis. | | toolmajor | string | Yes| No| toolmajor axis. |
| orientation | string | Yes| No| Orientation axis.| | orientation | string | Yes| No| Orientation axis.|
| pressure | string | Yes| No| Pressure axis. | | pressure | string | Yes| No| Pressure axis. |
| x | string | Yes| No| X axis. | | x | string | Yes| No| X axis. |
......
...@@ -15,7 +15,7 @@ import measure from '@ohos.measure' ...@@ -15,7 +15,7 @@ import measure from '@ohos.measure'
## measure.measureText ## measure.measureText
measureText(options: MeasureOptions): double measureText(options: MeasureOptions): number
Measures the width of the given single-line text. Measures the width of the given single-line text.
...@@ -31,7 +31,7 @@ Measures the width of the given single-line text. ...@@ -31,7 +31,7 @@ Measures the width of the given single-line text.
| Type | Description | | Type | Description |
| ------------ | --------- | | ------------ | --------- |
| double | Text width.<br>The unit is px.| | number | Text width.<br>The unit is px.|
**Example** **Example**
......
...@@ -40,9 +40,13 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -40,9 +40,13 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
| 1600012 | No memory space. |
**Example** **Example**
...@@ -92,9 +96,13 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -92,9 +96,13 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
| 1600012 | No memory space. |
**Example** **Example**
...@@ -142,9 +150,13 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -142,9 +150,13 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
| 1600012 | No memory space. |
**Example** **Example**
...@@ -187,6 +199,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -187,6 +199,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -234,6 +249,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -234,6 +249,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -279,6 +297,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -279,6 +297,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -334,6 +355,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -334,6 +355,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -372,7 +396,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu ...@@ -372,7 +396,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| hashCode | string | Yes | Unique notification ID. It is the value of **hashCode** in the [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) object of [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) in the [onConsume](#onconsume) callback. | | hashCode | string | Yes | Unique notification ID. It is the value of **hashCode** in the [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) object of [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) in the [onConsume](#onconsume) callback.|
| reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. | | reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
...@@ -382,6 +406,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -382,6 +406,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -428,6 +455,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -428,6 +455,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -468,6 +498,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -468,6 +498,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -513,6 +546,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -513,6 +546,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -555,6 +591,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -555,6 +591,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -594,6 +633,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -594,6 +633,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -639,6 +681,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -639,6 +681,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -662,7 +707,7 @@ notificationSubscribe.removeAll(userId, removeAllCallback); ...@@ -662,7 +707,7 @@ notificationSubscribe.removeAll(userId, removeAllCallback);
## NotificationSubscriber ## NotificationSubscriber
Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribe). Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribesubscribe).
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
...@@ -670,7 +715,7 @@ Provides callbacks for receiving or removing notifications and serves as the inp ...@@ -670,7 +715,7 @@ Provides callbacks for receiving or removing notifications and serves as the inp
onConsume?: (data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void onConsume?: (data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
Callback for receiving notifications. Called when a notification is received.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
...@@ -710,7 +755,7 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -710,7 +755,7 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback);
onCancel?:(data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void onCancel?:(data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
Callback for canceling notifications. Called when a notification is canceled.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
...@@ -750,7 +795,7 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -750,7 +795,7 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback);
onUpdate?:(data: [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) => void onUpdate?:(data: [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) => void
Callback for notification sorting updates. Called when the notification sorting list is updated.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
...@@ -788,7 +833,7 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -788,7 +833,7 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback);
onConnect?:() => void onConnect?:() => void
Callback for subscription. Called when subscription is complete.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
...@@ -820,7 +865,7 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -820,7 +865,7 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback);
onDisconnect?:() => void onDisconnect?:() => void
Callback for unsubscription. Called when unsubscription is complete.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
...@@ -898,7 +943,7 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -898,7 +943,7 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback);
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notificationManager.md#donotdisturbdate)) => void onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notificationManager.md#donotdisturbdate)) => void
Callback for DND time setting updates. Called when the DND time setting is updated.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
...@@ -935,7 +980,7 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -935,7 +980,7 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback);
### onEnabledNotificationChanged ### onEnabledNotificationChanged
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata)) => void onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata8)) => void
Listens for the notification enabled status changes. This API uses an asynchronous callback to return the result. Listens for the notification enabled status changes. This API uses an asynchronous callback to return the result.
...@@ -947,7 +992,7 @@ Listens for the notification enabled status changes. This API uses an asynchrono ...@@ -947,7 +992,7 @@ Listens for the notification enabled status changes. This API uses an asynchrono
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata)\> | Yes| Callback used to return the result.| | callback | AsyncCallback\<[EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata8)\> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -975,7 +1020,7 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -975,7 +1020,7 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback);
### onBadgeChanged<sup>10+</sup> ### onBadgeChanged<sup>10+</sup>
onBadgeChanged?:(data: [BadgeNumberCallbackData](#badgenumbercallbackdata)) => void onBadgeChanged?:(data: [BadgeNumberCallbackData](#badgenumbercallbackdata10)) => void
Listens for the change of the notification badge number. Listens for the change of the notification badge number.
...@@ -987,7 +1032,7 @@ Listens for the change of the notification badge number. ...@@ -987,7 +1032,7 @@ Listens for the change of the notification badge number.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------- | | -------- | ------------------------------------------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[BadgeNumberCallbackData](#badgenumbercallbackdata)\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<[BadgeNumberCallbackData](#badgenumbercallbackdata10)\> | Yes | Callback used to return the result.|
**Example** **Example**
......
...@@ -660,7 +660,7 @@ import router from '@ohos.router' ...@@ -660,7 +660,7 @@ import router from '@ohos.router'
struct Second { struct Second {
private content: string = "This is the second page." private content: string = "This is the second page."
@State text: string = router.getParams()['text'] @State text: string = router.getParams()['text']
@State data: any = router.getParams()['data'] @State data: object = router.getParams()['data']
@State secondData : string = '' @State secondData : string = ''
build() { build() {
...@@ -671,7 +671,7 @@ struct Second { ...@@ -671,7 +671,7 @@ struct Second {
Text(this.text) Text(this.text)
.fontSize(30) .fontSize(30)
.onClick(()=>{ .onClick(()=>{
this.secondData = (this.data.array[1]).toString() this.secondData = (this.data.['array'][1]).toString()
}) })
.margin({top:20}) .margin({top:20})
Text(`This is the data passed from the first page: ${this.secondData}`) Text(`This is the data passed from the first page: ${this.secondData}`)
......
...@@ -123,7 +123,7 @@ Unsubscribes from the device status. ...@@ -123,7 +123,7 @@ Unsubscribes from the device status.
| -------------------- | -------------------------------------------------- | ---- | ---------------------------- | | -------------------- | -------------------------------------------------- | ---- | ---------------------------- |
| activity | [ActivityType](#activitytype) | Yes | Device status type. | | activity | [ActivityType](#activitytype) | Yes | Device status type. |
| event | [ActivityEvent](#activityevent) | Yes | Event type. | | event | [ActivityEvent](#activityevent) | Yes | Event type. |
| callback | Callback<[ActivityResponse](#activityresponse)\> | No | Callback used to receive reported data. | | callback | Callback<[ActivityResponse](#activityresponse)\> | No | Callback used to receive reported data, if the callback parameter is not passed, all callbacks subscribed to this type under this process will be removed. |
**Example** **Example**
......
...@@ -4,7 +4,7 @@ The **uiAppearance** module provides basic capabilities for managing the system ...@@ -4,7 +4,7 @@ The **uiAppearance** module provides basic capabilities for managing the system
> **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. > The APIs of this module are supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version.
> >
> The APIs provided by this module are system APIs. > The APIs provided by this module are system APIs.
......
...@@ -209,8 +209,8 @@ Removes the permission for the application to access a USB device. ...@@ -209,8 +209,8 @@ Removes the permission for the application to access a USB device.
**Example** **Example**
```js ```js
let devicesName="1-1"; let devicesName= "1-1";
if usb.removeRight(devicesName) { if (usb.removeRight(devicesName)) {
console.log(`Succeed in removing right`); console.log(`Succeed in removing right`);
} }
``` ```
...@@ -245,7 +245,7 @@ Adds the permission for the application to access a USB device. ...@@ -245,7 +245,7 @@ Adds the permission for the application to access a USB device.
```js ```js
let devicesName = "1-1"; let devicesName = "1-1";
let bundleName = "com.example.hello"; let bundleName = "com.example.hello";
if usb.addRight(bundleName, devicesName) { if (usb.addRight(bundleName, devicesName)) {
console.log(`Succeed in adding right`); console.log(`Succeed in adding right`);
} }
``` ```
...@@ -454,7 +454,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -454,7 +454,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**Example** **Example**
```js ```js
let param = new usb.USBControlParams(); let param = {
request: 0,
reqType: 0,
target:0,
value: 0,
index: 0,
data: null
};
usb.controlTransfer(devicepipe, param).then((ret) => { usb.controlTransfer(devicepipe, param).then((ret) => {
console.log(`controlTransfer = ${ret}`); console.log(`controlTransfer = ${ret}`);
}) })
...@@ -579,7 +586,7 @@ Converts the USB function list in the numeric mask format to a string in Device ...@@ -579,7 +586,7 @@ Converts the USB function list in the numeric mask format to a string in Device
**Example** **Example**
```js ```js
let funcs = usb.ACM | usb.ECM; let funcs = usb.FunctionType.ACM | usb.FunctionType.ECM;
let ret = usb.usbFunctionsToString(funcs); let ret = usb.usbFunctionsToString(funcs);
``` ```
...@@ -608,7 +615,7 @@ Sets the current USB function list in Device mode. ...@@ -608,7 +615,7 @@ Sets the current USB function list in Device mode.
**Example** **Example**
```js ```js
let funcs = usb.HDC; let funcs = usb.FunctionType.HDC;
usb.setCurrentFunctions(funcs).then(() => { usb.setCurrentFunctions(funcs).then(() => {
console.info('usb setCurrentFunctions successfully.'); console.info('usb setCurrentFunctions successfully.');
}).catch(err => { }).catch(err => {
......
...@@ -52,7 +52,7 @@ try { ...@@ -52,7 +52,7 @@ try {
usage: 'alarm' usage: 'alarm'
}, (error) => { }, (error) => {
if (error) { if (error) {
console.error('vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message); console.error('Vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message);
return; return;
} }
console.log('Callback returned to indicate a successful vibration.'); console.log('Callback returned to indicate a successful vibration.');
...@@ -145,7 +145,7 @@ try { ...@@ -145,7 +145,7 @@ try {
usage: 'alarm' usage: 'alarm'
}, (error) => { }, (error) => {
if (error) { if (error) {
console.error('vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message); console.error('Vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message);
return; return;
} }
console.log('Callback returned to indicate a successful vibration.'); console.log('Callback returned to indicate a successful vibration.');
...@@ -253,7 +253,7 @@ try { ...@@ -253,7 +253,7 @@ try {
usage: 'alarm' usage: 'alarm'
}, (error) => { }, (error) => {
if (error) { if (error) {
console.error('vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message); console.error('Vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message);
return; return;
} }
console.log('Callback returned to indicate a successful vibration.'); console.log('Callback returned to indicate a successful vibration.');
...@@ -338,7 +338,7 @@ Checks whether the passed effect ID is supported. This API uses an asynchronous ...@@ -338,7 +338,7 @@ Checks whether the passed effect ID is supported. This API uses an asynchronous
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ------------------------------------------------------ | | -------- | ---------------------------- | ---- | ------------------------------------------------------ |
| effectId | string | Yes | Vibration effect ID. | | effectId | string | Yes | Vibration effect ID. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite. | | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite.|
**Example** **Example**
...@@ -395,7 +395,7 @@ Checks whether the passed effect ID is supported. This API uses a promise to ret ...@@ -395,7 +395,7 @@ Checks whether the passed effect ID is supported. This API uses a promise to ret
| Type | Description | | Type | Description |
| ---------------------- | --------------------------------------------------------- | | ---------------------- | --------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise that returns the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite. | | Promise&lt;boolean&gt; | Promise that returns the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite.|
**Example** **Example**
...@@ -419,7 +419,7 @@ try { ...@@ -419,7 +419,7 @@ try {
console.error('Promise returned to indicate a failed vibration:' + JSON.stringify(error)); console.error('Promise returned to indicate a failed vibration:' + JSON.stringify(error));
}); });
} catch (error) { } catch (error) {
console.error('exception in, error:' + JSON.stringify(error)); console.error('Exception in, error:' + JSON.stringify(error));
} }
} }
}, (error) => { }, (error) => {
......
...@@ -20,18 +20,16 @@ Functions of the files are as follows: ...@@ -20,18 +20,16 @@ Functions of the files are as follows:
Functions of the folders are as follows: Functions of the folders are as follows:
- The **app.js** file manages global JS logics and application lifecycle. - The **app.js** file manages global JS logics and application lifecycle.
- The **pages** directory stores all component pages. - The **pages** directory stores all component pages.
- The **common** directory stores public resource files, such as media resources and **.js** files.
- The **common** directory stores public resource files, such as media resources and JavaScript files. - The **i18n** folder stores resources in different languages, for example, UI strings and image paths.
> **NOTE** > **NOTE**
> - The following reserved folders cannot be renamed:
> >
> - The **i18n** folder is a reserved one and cannot be renamed.
> >
> >
> > - The folders marked as optional in the directory structure can be created as needed after you create the project in DevEco Studio.
> - The folders marked as optional in the directory structure can be created as needed after you create the project in DevEco Studio.
## File Access Rules ## File Access Rules
...@@ -60,8 +58,16 @@ Application resources can be accessed via an absolute or relative path. In this ...@@ -60,8 +58,16 @@ Application resources can be accessed via an absolute or relative path. In this
**Table 1** Supported image formats **Table 1** Supported image formats
| Format| Supported Version| File Name Extension| | Format | Supported Version | File Name Extension|
| -------- | -------- | -------- | | ---- | ------------------------ | ------- |
| BMP | API Version 3+ | .bmp | | BMP | API version 4+ | .bmp |
| JPEG | API Version 3+ | .jpg | | JPEG | API version 4+ | .jpg |
| PNG | API Version 3+ | .png | | PNG | API version 4+ | .png |
## Storage Directory
Since API version 5, the [\<image>](js-components-basic-image.md) component supports access to images in the private directory of an application.
| Directory Type | Prefix | Access Visibility | Description |
| ------ | --------------- | ------ | --------------------------- |
| Private directory of the application| internal://app/ | Current application only| The directory is deleted when the application is uninstalled. Access to the parent directory using **../** is prohibited.|
# app.js # app.js
## Application Lifecycle<sup>4+</sup>
You can implement lifecycle logic specific to your application in the **app.js** file. Available application lifecycle functions are as follows: You can implement lifecycle logic specific to your application in the **app.js** file. Available application lifecycle functions are as follows:
...@@ -11,7 +12,9 @@ You can implement lifecycle logic specific to your application in the **app.js** ...@@ -11,7 +12,9 @@ You can implement lifecycle logic specific to your application in the **app.js**
In the following example, logs are printed only in the lifecycle functions. In the following example, logs are printed only in the lifecycle functions.
```
```js
// app.js // app.js
export default { export default {
onCreate() { onCreate() {
...@@ -22,3 +25,63 @@ export default { ...@@ -22,3 +25,63 @@ export default {
}, },
} }
``` ```
## Application Object<sup>10+</sup>
| Attribute | Type | Description |
| ------ | -------- | ---------------------------------------- |
| getApp | Function | Obtains the data object exposed in **app.js** from the page JS file. This API works globally.|
> **NOTE**
>
> The application object is global data and occupies JS memory before the application exits. Although it facilitates data sharing between different pages, exercise caution when using it on small-system devices, whose memory is small. If they are overused, exceptions may occur due to insufficient memory when the application displays complex pages.
The following is an example:
Declare the application object in **app.js**.
```javascript
// app.js
export default {
data: {
test: "by getAPP"
},
onCreate() {
console.info('Application onCreate');
},
onDestroy() {
console.info('Application onDestroy');
},
};
```
Access the application object on a specific page.
```javascript
// index.js
export default {
data: {
title: ""
},
onInit() {
if (typeof getApp !== 'undefined') {
var appData = getApp().data;
if (typeof appData !== 'undefined') {
this.title = appData.name; // read from app data
}
}
},
clickHandler() {
if (typeof getApp !== 'undefined') {
var appData = getApp().data;
if (typeof appData !== 'undefined') {
appData.name = this.title; // write to app data
}
}
}
}
```
> **NOTE**
>
> To ensure that the application can run properly on an earlier version that does not support **getApp**, compatibility processing must be performed in the code. That is, before using **getApp**, check whether it is available.
...@@ -137,4 +137,4 @@ The [universal methods](../arkui-js/js-components-common-methods.md) are support ...@@ -137,4 +137,4 @@ The [universal methods](../arkui-js/js-components-common-methods.md) are support
``` ```
![en-us_image_0000001167823076](figures/text.png) ![en-us_image_0000001167823076](figures/js-text.png)
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
- Anti-aliasing enabled - Anti-aliasing enabled
![screenshot-8](figures/screenshot-8.png) ![en-us_image_0000001127125162](figures/en-us_image_0000001127125162.png)
## Attributes ## Attributes
...@@ -558,7 +558,7 @@ export default { ...@@ -558,7 +558,7 @@ export default {
} }
``` ```
![smoothoff](figures/smoothoff.png) ![en-us_image_0000001167952236](figures/en-us_image_0000001167952236.png)
...@@ -863,10 +863,10 @@ Moves a drawing path to a target position on the canvas. ...@@ -863,10 +863,10 @@ Moves a drawing path to a target position on the canvas.
**Parameters** **Parameters**
| Name | Type | Description | | Name | Type | Description |
| ---- | ------ | --------- | | ---- | ------ | ------------------ |
| x | number | X-coordinate of the target position.| | x | number | X-coordinate of the target position.<br>Unit: vp|
| y | number | Y-coordinate of the target position.| | y | number | Y-coordinate of the target position.<br>Unit: vp|
**Example** **Example**
```html ```html
...@@ -902,8 +902,8 @@ Connects the current point to a target position using a straight line. ...@@ -902,8 +902,8 @@ Connects the current point to a target position using a straight line.
| Name | Type | Description | | Name | Type | Description |
| ---- | ------ | --------- | | ---- | ------ | --------- |
| x | number | X-coordinate of the target position.| | x | number | X-coordinate of the target position.<br>Unit: vp|
| y | number | Y-coordinate of the target position.| | y | number | Y-coordinate of the target position.<br>Unit: vp|
**Example** **Example**
```html ```html
...@@ -1026,7 +1026,7 @@ Draws a cubic bezier curve on the canvas. ...@@ -1026,7 +1026,7 @@ Draws a cubic bezier curve on the canvas.
```html ```html
<!-- xxx.hml --> <!-- xxx.hml -->
<div> <div>
<canvas ref="canvas" style="width: 200px; height: 150px; background-color: #ffff00;"></canvas> <canvas ref="canvas" style="width: 200px; height: 150px;"></canvas>
</div> </div>
``` ```
...@@ -1204,7 +1204,7 @@ Draws an ellipse in the specified rectangular region on the canvas. ...@@ -1204,7 +1204,7 @@ Draws an ellipse in the specified rectangular region on the canvas.
} }
``` ```
![ellipse](figures/ellipse.png) ![en-us_image_0000001214823665](figures/en-us_image_0000001214823665.png)
### rect ### rect
......
...@@ -26,9 +26,9 @@ ScrollBar(value: { scroller: Scroller, direction?: ScrollBarDirection, state?: B ...@@ -26,9 +26,9 @@ ScrollBar(value: { scroller: Scroller, direction?: ScrollBarDirection, state?: B
> **NOTE** > **NOTE**
> >
> The **\<ScrollBar>** component defines the behavior style of the scrollable area, and its subnodes define the behavior style of the scrollbar. > The **\<ScrollBar>** component defines the behavior style of the scrollable area, and its subnodes define the behavior style of the scrollbar.
> >
> This component is bound to a scrollable component through **scroller**, and can be used to scroll the scrollable component only when their directions are the same. The **\<ScrollBar>** component can be bound to only one scrollable component, and vice versa. > This component is bound to a scrollable component through **scroller**, and can be used to scroll the scrollable component only when their directions are the same. The **\<ScrollBar>** component can be bound to only one scrollable component, and vice versa.
## ScrollBarDirection ## ScrollBarDirection
...@@ -46,7 +46,7 @@ ScrollBar(value: { scroller: Scroller, direction?: ScrollBarDirection, state?: B ...@@ -46,7 +46,7 @@ ScrollBar(value: { scroller: Scroller, direction?: ScrollBarDirection, state?: B
@Component @Component
struct ScrollBarExample { struct ScrollBarExample {
private scroller: Scroller = new Scroller() private scroller: Scroller = new Scroller()
private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
build() { build() {
Column() { Column() {
...@@ -56,8 +56,8 @@ struct ScrollBarExample { ...@@ -56,8 +56,8 @@ struct ScrollBarExample {
ForEach(this.arr, (item) => { ForEach(this.arr, (item) => {
Row() { Row() {
Text(item.toString()) Text(item.toString())
.width('90%') .width('80%')
.height(100) .height(60)
.backgroundColor('#3366CC') .backgroundColor('#3366CC')
.borderRadius(15) .borderRadius(15)
.fontSize(16) .fontSize(16)
...@@ -65,17 +65,18 @@ struct ScrollBarExample { ...@@ -65,17 +65,18 @@ struct ScrollBarExample {
.margin({ top: 5 }) .margin({ top: 5 })
} }
}, item => item) }, item => item)
}.margin({ right: 52 }) }.margin({ right: 15 })
} }
.width('90%')
.scrollBar(BarState.Off) .scrollBar(BarState.Off)
.scrollable(ScrollDirection.Vertical) .scrollable(ScrollDirection.Vertical)
ScrollBar({ scroller: this.scroller, direction: ScrollBarDirection.Vertical,state: BarState.Auto }) { ScrollBar({ scroller: this.scroller, direction: ScrollBarDirection.Vertical,state: BarState.Auto }) {
Text() Text()
.width(30) .width(20)
.height(100) .height(100)
.borderRadius(10) .borderRadius(10)
.backgroundColor('#C0C0C0') .backgroundColor('#C0C0C0')
}.width(30).backgroundColor('#ededed') }.width(20).backgroundColor('#ededed')
} }
} }
} }
...@@ -83,4 +84,4 @@ struct ScrollBarExample { ...@@ -83,4 +84,4 @@ struct ScrollBarExample {
``` ```
![en-us_image_0000001256978369](figures/en-us_image_0000001256978369.gif) ![en-us_image_0000001232775585](figures/en-us_image_0000001232775585.gif)
...@@ -16,12 +16,12 @@ Search(options?: { value?: string; placeholder?: ResourceStr; icon?: string; con ...@@ -16,12 +16,12 @@ Search(options?: { value?: string; placeholder?: ResourceStr; icon?: string; con
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ---------------- | ---- | ------------------------------------------------------------ | | ----------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
| value | string | No | Text input in the search text box. | | value | string | No | Text input in the search text box.<br>Since API version 10, this parameter supports two-way binding through [$$](../../quick-start/arkts-two-way-sync.md).|
| placeholder | [ResourceStr](ts-types.md#resourcestr)<sup>10+</sup> | No | Text displayed when there is no input. | | placeholder | [ResourceStr](ts-types.md#resourcestr)<sup>10+</sup> | No | Text displayed when there is no input. |
| icon | string | No | Path to the search icon. By default, the system search icon is used. The supported icon formats are .svg, .jpg, and .png.| | icon | string | No | Path to the search icon. By default, the system search icon is used.<br>For details about the supported image types, see [Image](ts-basic-components-image.md).|
| controller | SearchController | No | Controller of the **\<Search>** component. | | controller | SearchController | No | Controller of the **\<Search>** component. |
## Attributes ## Attributes
...@@ -74,13 +74,13 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -74,13 +74,13 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
In addition to the [universal events](ts-universal-events-click.md), the following events are supported. In addition to the [universal events](ts-universal-events-click.md), the following events are supported.
| Name | Description | | Name | Description |
| ------------------------------------------- | ------------------------------------------------------------ | | ---------------------------------------- | ---------------------------------------- |
| onSubmit(callback: (value: string) => void) | Invoked when users click the search icon or the search button, or touch the search button on a soft keyboard.<br> - **value**: current text input. | | onSubmit(callback: (value: string) => void) | Invoked when users click the search icon or the search button, or touch the search button on a soft keyboard.<br> - **value**: current text input.|
| onChange(callback: (value: string) => void) | Invoked when the input in the text box changes.<br> - **value**: current text input. | | onChange(callback: (value: string) => void) | Invoked when the input in the text box changes.<br> - **value**: current text input. |
| onCopy(callback: (value: string) => void) | Invoked when data is copied to the pasteboard, which is displayed when the search text box is long pressed.<br> - **value**: text copied. | | onCopy(callback: (value: string) => void) | Invoked when data is copied to the pasteboard, which is displayed when the search text box is long pressed.<br> - **value**: text copied. |
| onCut(callback: (value: string) => void) | Invoked when data is cut from the pasteboard, which is displayed when the search text box is long pressed.<br> - **value**: text cut. | | onCut(callback: (value: string) => void) | Invoked when data is cut from the pasteboard, which is displayed when the search text box is long pressed.<br> - **value**: text cut. |
| onPaste(callback: (value: string) => void) | Invoked when data is pasted from the pasteboard, which is displayed when the search text box is long pressed.<br> -**value**: text pasted. | | onPaste(callback: (value: string) => void) | Invoked when data is pasted from the pasteboard, which is displayed when the search text box is long pressed.<br> -**value**: text pasted. |
## SearchController ## SearchController
......
...@@ -5,6 +5,8 @@ The **\<Span>** component is used to display inline text in the **\<Text>** comp ...@@ -5,6 +5,8 @@ The **\<Span>** component is used to display inline text in the **\<Text>** comp
> **NOTE** > **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.
>
> Since API version 10, this component can inherit the attributes of the **\<Text>** parent component. That is, if no attribute is set for this component, it inherits the attributes (if set) of its parent component. The following attributes can be inherited: **fontColor**, **fontSize**, **fontStyle**, **fontWeight**, **decoration**, **letterSpacing**, **textCase**, **lineHeight**, and **fontfamily**.
## Child Components ## Child Components
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册