提交 59546953 编写于 作者: D dy_study

Merge branch 'monthly_20221018' of https://gitee.com/openharmony/docs into UpdateAPI9_monthly

Signed-off-by: Ndy_study <dingyao5@huawei.com>
Change-Id: Ia65192cd0d3991aeb123c57e14c2a22d7e900bdf
......@@ -65,12 +65,13 @@
- [Internationalization](internationalization/Readme-EN.md)
- [Application Test](application-test/Readme-EN.md)
- [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md)
- [Using Native APIs in Application Projects](napi/Readme-EN.md)
- [Native APIs](napi/Readme-EN.md)
- Tools
- [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md)
- [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md)
- [Debugging Tools](tools/Readme-EN.md)
- Hands-On Tutorials
- [Samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md)
- [Codelabs](https://gitee.com/openharmony/codelabs)
- [Samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md)
- [Codelabs](https://gitee.com/openharmony/codelabs)
- API References
- [SystemCapability](reference/syscap.md)
- [SystemCapability List](reference/syscap-list.md)
......
......@@ -60,13 +60,7 @@ The **module.json5** of a browser application is as follows:
} catch (error) {
console.info(`explicit start ability failed with ${error.code}`)
}
let context = getContext(this) as common.UIAbilityContext;
await context.startAbility(want)
console.info(`explicit start ability succeed`)
} catch (error) {
console.info(`explicit start ability failed with ${error.code}`)
}
}
}
```
The matching process is as follows:
......@@ -79,4 +73,5 @@ The **module.json5** of a browser application is as follows:
4. If **type** in the passed **want** parameter is specified and is included in **type** under **skills**, the matching is successful.
2. When there are multiple matching applications, a dialog box is displayed for you to select one of them.
<img src="figures/stage-want1.png" alt="stage-want1" style="zoom:80%;" />
![stage-want1](figures/stage-want1.png)
......@@ -6,10 +6,12 @@
[Context](../reference/apis/js-apis-inner-application-context.md) is the context of an object in an application. It provides basic information about the application, for example, **resourceManager**, **applicationInfo**, **dir** (application development path), and **area** (encrypted area). It also provides basic methods such as **createBundleContext()** and **getApplicationContext()**. The UIAbility component and ExtensionAbility derived class components have their own **Context** classes, for example, the base class **Context**, **ApplicationContext**, **AbilityStageContext**, **UIAbilityContext**, **ExtensionContext**, and **ServiceExtensionContext**.
- The figure below illustrates the inheritance relationship of contexts.
<img src="figures/context-inheritance.png" alt="context-inheritance" style="zoom: 50%;" />
![context-inheritance](figures/context-inheritance.png)
- The figure below illustrates the holding relationship of contexts.
<img src="figures/context-holding.png" alt="context-holding" style="zoom:50%;" />
![context-holding](figures/context-holding.png)
- The following describes the information provided by different contexts.
- [UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md): Each UIAbility has the **Context** attribute, which provides APIs to operate the ability, obtain the ability configuration, and more.
......@@ -89,7 +91,8 @@ The following table describes the application development paths obtained from co
The capability of obtaining the application development path is provided by the base class **Context**. This capability is also provided by **ApplicationContext**, **AbilityStageContext**, **UIAbilityContext**, and **ExtensionContext**. However, the paths obtained from different contexts may differ, as shown below.
**Figure 1** Application development paths obtained from context
<img src="figures/context-dir.png" alt="context-dir" style="zoom: 50%;" />
![context-dir](figures/context-dir.png)
- Obtain the application-level path through **ApplicationContext**. It is recommended that global application information be stored in this path. Files stored in this path will be deleted only when the application is uninstalled.
| Name| Path|
......@@ -174,7 +177,7 @@ The base class **Context** provides the [createBundleContext(bundleName:string)]
>
> - Request the **ohos.permission.GET_BUNDLE_INFO_PRIVILEGED** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
>
> - This is a system API and cannot be called by third-party applications.
> - This is a system API and cannot be called by third-party applications.
For example, application information displayed on the home screen includes the application name and icon. The home screen application calls the foregoing method to obtain the context information, so as to obtain the resource information including the application name and icon.
......@@ -189,7 +192,7 @@ The base class **Context** provides the [createBundleContext(bundleName:string)]
// ...
}
}
```
```
- Call **createModuleContext(bundleName:string, moduleName:string)** to obtain the context of a specified module of another application. After obtaining the context, you can obtain the resource information of that module.
> **NOTE**
......@@ -198,7 +201,7 @@ The base class **Context** provides the [createBundleContext(bundleName:string)]
>
> - Request the **ohos.permission.GET_BUNDLE_INFO_PRIVILEGED** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
>
> - This is a system API and cannot be called by third-party applications.
> - This is a system API and cannot be called by third-party applications.
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
......
......@@ -67,7 +67,7 @@ Users often need to share data (such as a text or an image) from one application
For example, when **"ability.picker.type"** is **"application/pdf"**, **"ability.picker.fileNames"** is **"["APIs.pdf"]"**, and **"ability.picker.fileSizes"** is **"[350 \* 1024]"**, the application selector is displayed as follows:
<img src="figures/stage-want2.png" alt="stage-want2" style="zoom:50%;" />
![stage-want2](figures/stage-want2.png)
In the preceding code, the **ability.want.params.INTENT** field is nested Want. In this field, **action** and **type** are used for implicit matching by the application selector. For details about implicit matching, see [Matching Rules of Implicit Want](explicit-implicit-want-mappings.md#matching-rules-of-implicit-want). After the user selects an application, the nested Want of the **ability.want.params.INTENT** field is passed to that application.
......
......@@ -61,7 +61,8 @@ The system matches the [action](../reference/apis/js-apis-ability-wantConstant.m
- If **action** in the passed **want** parameter is specified, and **actions** under **skills** of an ability is specified but does not contain **action** in the passed **want** parameter, the matching fails.
**Figure 1** Matching rules of action in the want parameter
<img src="figures/want-action.png" alt="want-action" style="zoom:80%;" />
![want-action](figures/want-action.png)
### Matching Rules of entities in the want Parameter
......@@ -78,8 +79,9 @@ The system matches the [entities](../reference/apis/js-apis-ability-wantConstant
- If **entities** in the passed **want** parameter is specified, and **entities** under **skills** of an ability is specified but does not contain **entities** in the passed **want** parameter, the matching fails.
Figure 2 Matching rule of entities in the want parameter
<img src="figures/want-entities.png" alt="want-entities" style="zoom:80%;" />
Figure 2 Matching rule of entities in the want parameter
![want-entities](figures/want-entities.png)
### Matching Rules of uri and type in the want Parameter
......@@ -87,7 +89,8 @@ The system matches the [entities](../reference/apis/js-apis-ability-wantConstant
When the **uri** and **type** parameters are specified in the **want** parameter to initiate a component startup request, the system traverses the list of installed components and matches the **uris** array under **skills** of the abilities one by one. If one of the **uris** arrays under **skills** matches the **uri** and **type** in the passed **want**, the matching is successful.
Figure 3 Matching rules when uri and type are specified in the want parameter
<img src="figures/want-uri-type1.png" alt="want-uri-type1" style="zoom: 80%;" />
![want-uri-type1](figures/want-uri-type1.png)
There are four combinations of **uri** and **type** settings. The matching rules are as follows:
......@@ -113,7 +116,8 @@ To simplify the description, **uri** and **type** passed in the **want** paramet
Figure 4 Matching rules of uri and type in the want parameter
<img src="figures/want-uri-type2.png" alt="want-uri-type2" style="zoom:80%;" />
![want-uri-type2](figures/want-uri-type2.png)
### Matching Rules of uri
......
......@@ -35,8 +35,9 @@ OpenHarmony provides a set of APIs for you to implement continuation in your app
The following figure shows the continuation architecture.
**Figure 1** Continuation architecture
<img src="figures/hop-structure.png" alt="hop-structure" style="zoom:80%;" />
**Figure 1** Continuation architecture
![hop-structure](figures/hop-structure.png)
- Cross-device migration task management: The initiator accepts a migration request from the user, provides a migration entry, and displays the migration result. (This capability is unavailable yet.)
......
......@@ -92,7 +92,8 @@ Before using EventHub, you must obtain an EventHub object, which is provided by
**globalThis** is a global object inside the [ArkTS engine instance](thread-model-stage.md) and can be used by UIAbility, ExtensionAbility, and Page inside the engine. Therefore, you can use **globalThis** for data synchronization.
**Figure 1** Using globalThis for data synchronization
<img src="figures/globalThis1.png" alt="globalThis1" style="zoom:67%;" />
![globalThis1](figures/globalThis1.png)
The following describes how to use **globalThis** in three scenarios. Precautions are provided as well.
......@@ -209,6 +210,7 @@ To implement data synchronization between the UIAbility and ExtensionAbility com
### Precautions for Using globalThis
**Figure 2** Precautions for globalThis
![globalThis2](figures/globalThis2.png)
- In the stage model, all the UIAbility components in a process share one ArkTS engine instance. When using **globalThis**, do not store objects with the same name. For example, if AbilityA and AbilityB use **globalThis** to store two objects with the same name, the object stored earlier will be overwritten.
......
......@@ -197,7 +197,7 @@ This section describes how to start the UIAbility of another application through
The following figure shows the effect. When you click **Open PDF**, a dialog box is displayed for you to select.
<img src="figures/uiability-intra-device-interaction.png" alt="uiability-intra-device-interaction" style="zoom:50%;" />
![uiability-intra-device-interaction](figures/uiability-intra-device-interaction.png)
3. To stop the **UIAbility** instance after the document application is used, call **terminateSelf()**.
......@@ -445,7 +445,7 @@ The following figure shows the ability call process.
**Figure 1** Ability call process
<img src="figures/call.png" alt="call" style="zoom:67%;" />
![call](figures/call.png)
- The caller ability uses **startAbilityByCall** to obtain a caller object and uses **call()** of the caller object to send data to the callee ability.
......
......@@ -19,7 +19,7 @@ Each time [startAbility()](../reference/apis/js-apis-inner-application-uiAbility
**Figure 1** Demonstration effect in singleton mode
<img src="figures/uiability-launch-type1.png" alt="uiability-launch-type1" width="40%;" />
![uiability-launch-type1](figures/uiability-launch-type1.png)
> **NOTE**
>
......@@ -49,7 +49,7 @@ In standard mode, each time [startAbility()](../reference/apis/js-apis-inner-app
**Figure 2** Demonstration effect in standard mode
<img src="figures/standard-mode.png" alt="standard-mode" width="40%;" />
![standard-mode](figures/standard-mode.png)
To use the standard mode, set **launchType** in the [module.json5 configuration file](../quick-start/module-configuration-file.md) to **standard**.
......@@ -75,7 +75,7 @@ The **specified** mode is used in some special scenarios. For example, in a docu
**Figure 3** Demonstration effect in specified mode
<img src="figures/uiability-launch-type2.png" alt="uiability-launch-type2" style="zoom:50%;" />
![uiability-launch-type2](figures/uiability-launch-type2.png)
For example, there are EntryAbility and SpecifiedAbility, and the launch type of SpecifiedAbility is set to **specified**. You are required to start SpecifiedAbility from EntryAbility.
......
......@@ -7,8 +7,9 @@ When a user opens, switches, and returns to an application, the UIAbility instan
The lifecycle of UIAbility has four states: **Create**, **Foreground**, **Background**, and **Destroy**, as shown in the figure below.
**Figure 1** UIAbility lifecycle states
<img src="figures/Ability-Life-Cycle.png" alt="Ability-Life-Cycle" style="zoom:50%;" />
**Figure 1** UIAbility lifecycle states
![Ability-Life-Cycle](figures/Ability-Life-Cycle.png)
## Description of Lifecycle States
......@@ -36,8 +37,9 @@ export default class EntryAbility extends UIAbility {
After the UIAbility instance is created but before it enters the **Foreground** state, the system creates a WindowStage instance and triggers the **onWindowStageCreate()** callback. You can set UI loading and WindowStage event subscription in the callback.
**Figure 2** WindowStageCreate and WindowStageDestory
<img src="figures/Ability-Life-Cycle-WindowStage.png" alt="Ability-Life-Cycle-WindowStage" style="zoom:50%;" />
**Figure 2** WindowStageCreate and WindowStageDestory
![Ability-Life-Cycle-WindowStage](figures/Ability-Life-Cycle-WindowStage.png)
In the **onWindowStageCreate()** callback, use [loadContent()](../reference/apis/js-apis-window.md#loadcontent9-2) to set the page to be loaded, and call [on('windowStageEvent')](../reference/apis/js-apis-window.md#onwindowstageevent9) to subscribe to [WindowStage events](../reference/apis/js-apis-window.md#windowstageeventtype9), for example, having or losing focus, or becoming visible or invisible.
......
......@@ -5,8 +5,9 @@
[Want](../reference/apis/js-apis-app-ability-want.md) is used as the carrier to transfer information between application components. It is used as a parameter of **startAbility()** to specify the startup target and information that needs to be carried during startup, for example, **bundleName** and **abilityName**, which respectively indicate the bundle name of the target ability and the ability name in the bundle. For example, when UIAbilityA starts UIAbilityB and needs to transfer some data to UIAbilityB, it can use Want to transfer the data.
**Figure 1** Want usage
<img src="figures/usage-of-want.png" alt="usage-of-want" style="zoom:80%;" />
**Figure 1** Want usage
![usage-of-want](figures/usage-of-want.png)
## Types of Want
......
......@@ -26,7 +26,7 @@ The following table lists the USB APIs currently available. For details, see the
| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. |
| getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. |
| getRawDescriptor(pipe: USBDevicePipe): Uint8Array | Obtains the raw USB descriptor. |
| controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout ?: number): Promise\<number> | Performs control transfer. |
| controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise\<number> | Performs control transfer. |
## How to Develop
......@@ -118,11 +118,11 @@ You can set a USB device as the USB host to connect to other USB devices for dat
4. Perform data transfer.
```js
/*
Read data. Select the corresponding RX endpoint from deviceList for data transfer.
(endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array.
*/
```js
/*
Read data. Select the corresponding RX endpoint from deviceList for data transfer.
(endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array.
*/
let inEndpoint = interface1.endpoints[2];
let outEndpoint = interface1.endpoints[1];
let dataUint8Array = new Uint8Array(1024);
......@@ -147,7 +147,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat
}).catch(error => {
console.info("usb writeData error : " + JSON.stringify(error));
});
```
```
5. Release the USB interface, and close the USB device.
......
......@@ -187,7 +187,7 @@ currentSession.on('playNext', () => {
});
console.log ("Call AudioPlayer.play.");
// Set the playback state information.
let time = (new Data()).getTime();
let time = (new Date()).getTime();
currentSession.setAVPlaybackState({state: avSession.PlaybackState.PLAYBACK_STATE_PLAY, position: {elapsedTime: 0, updateTime: time}, bufferedTime:2000}).then(() => {
console.info('setAVPlaybackState successfully');
}).catch((err) => {
......@@ -282,7 +282,7 @@ currentSession.off('outputDeviceChange');
// Deactivate the session and destroy the object.
currentSession.deactivate().then(() => {
currentSession.destory();
currentSession.destroy();
});
```
......
......@@ -118,9 +118,9 @@ The following steps describe how to use the canvas and brush of the Native Drawi
// Draw a pentagram on the canvas. The outline of the pentagram is drawn by the pen, and the color is filled in by the brush.
OH_Drawing_CanvasDrawPath(cCanvas, cPath);
// Destroy the created objects when they are no longer needed.
OH_Drawing_BrushDestory(cBrush);
OH_Drawing_PenDestory(cPen);
OH_Drawing_PathDestory(cPath);
OH_Drawing_BrushDestroy(cBrush);
OH_Drawing_PenDestroy(cPen);
OH_Drawing_PathDestroy(cPath);
```
6. **Obtain pixel data.** Use `OH_Drawing_BitmapGetPixels` in `drawing_bitmap.h` to obtain the pixel address of the bitmap bound to the canvas. The memory to which the address points contains the pixel data of the drawing on the canvas.
......@@ -133,9 +133,9 @@ The following steps describe how to use the canvas and brush of the Native Drawi
LOGI("memcpy_s failed");
}
// Destroy the canvas object.
OH_Drawing_CanvasDestory(cCanvas);
OH_Drawing_CanvasDestroy(cCanvas);
// Destroy the bitmap object.
OH_Drawing_BitmapDestory(cBitmap);
OH_Drawing_BitmapDestroy(cBitmap);
```
## Development Procedure for Text Drawing
......
......@@ -29,20 +29,72 @@ The following scenarios are common for native window development:
| OH_NativeWindow_NativeWindowSetMetaDataSet(OHNativeWindow \*window, uint32_t sequence, OHHDRMetadataKey key, int32_t size, const uint8_t \*metaData) | Sets the HDR static metadata set of the native window.|
| OH_NativeWindow_NativeWindowSetTunnelHandle(OHNativeWindow \*window, const OHExtDataHandle \*handle) | Sets the tunnel handle to the native window.|
## How to Develop
The following describes how to use the NAPI provided by **NativeWindow** to request a graphics buffer, write the produced graphics content to the buffer, and flush the buffer to the graphics queue.
1. Obtain a **NativeWindow** instance. For example, use **Surface** to create a **NativeWindow** instance.
```c++
sptr<OHOS::Surface> cSurface = Surface::CreateSurfaceAsConsumer();
sptr<IBufferConsumerListener> listener = new BufferConsumerListenerTest();
cSurface->RegisterConsumerListener(listener);
sptr<OHOS::IBufferProducer> producer = cSurface->GetProducer();
sptr<OHOS::Surface> pSurface = Surface::CreateSurfaceAsProducer(producer);
OHNativeWindow* nativeWindow = OH_NativeWindow_CreateNativeWindow(&pSurface);
```
1. Obtain a **NativeWindow** instance, which can be obtained by running the APIs provided by **OH_NativeXComponent_Callback**.
1. Define **XComponent** in an .ets file.
```ts
XComponent({ id: 'xcomponentId', type: 'surface', libraryname: 'nativerender'})
.onLoad((context) => {
this.context = context;
})
.onDestroy(() => {
})
```
2. Obtain **NativeXComponent** at the native C++ layer.
```c++
napi_value exportInstance = nullptr;
napi_get_named_property(env, exports, OH_NATIVE_XCOMPONENT_OBJ, &exportInstance);
OH_NativeXComponent *nativeXComponent = nullptr;
napi_unwrap(env, exportInstance, reinterpret_cast<void**>(&nativeXComponent));
char idStr[OH_XCOMPONENT_ID_LEN_MAX + 1] = { };
uint64_t idSize = OH_XCOMPONENT_ID_LEN_MAX + 1;
OH_NativeXComponent_GetXComponentId(nativeXComponent, idStr, &idSize);
```
3. Define **OH_NativeXComponent_Callback**.
```c++
// Define the callback.
void OnSurfaceCreatedCB(OH_NativeXComponent* component, void* window)
{
// Obtain a NativeWindow instance.
OHNativeWindow* nativeWindow = window;
// ...
}
void OnSurfaceChangedCB(OH_NativeXComponent* component, void* window)
{
// Obtain a NativeWindow instance.
OHNativeWindow* nativeWindow = window;
// ...
}
void OnSurfaceDestroyedCB(OH_NativeXComponent* component, void* window)
{
// Obtain a NativeWindow instance.
OHNativeWindow* nativeWindow = window;
// ...
}
void DispatchTouchEventCB(OH_NativeXComponent* component, void* window)
{
// Obtain a NativeWindow instance.
OHNativeWindow* nativeWindow = window;
// ...
}
```
```c++
// Initialize OH_NativeXComponent_Callback.
OH_NativeXComponent_Callback callback_;
callback_->OnSurfaceCreated = OnSurfaceCreatedCB;
callback_->OnSurfaceChanged = OnSurfaceChangedCB;
callback_->OnSurfaceDestroyed = OnSurfaceDestroyedCB;
callback_->DispatchTouchEvent = DispatchTouchEventCB;
```
4. Register **OH_NativeXComponent_Callback** with **NativeXComponent**.
```c++
OH_NativeXComponent_RegisterCallback(nativeXComponent, &callback_);
```
2. Set the attributes of a native window buffer by using **OH_NativeWindow_NativeWindowHandleOpt**.
```c++
......@@ -90,7 +142,6 @@ The following describes how to use the NAPI provided by **NativeWindow** to requ
```
5. Flush the native window buffer to the graphics queue.
```c++
// Set the refresh region. If Rect in Region is a null pointer or rectNumber is 0, all contents in the native window buffer are changed.
Region region{nullptr, 0};
......
......@@ -30,21 +30,21 @@ This document gives an overview of the **app.json5** configuration file. To star
As shown above, the **app.json5** file contains several tags.
**Table 1** Tags in the app.json5 file
**Table 1** Tags in the app.json5 file
| 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|
| 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|
| label | [Name of the application](../application-models/application-component-configuration-stage.md). The value is a string resource index. | String| No|
| description | Description of the application. The value is a string with a maximum of 255 bytes or a resource index to the description. | String| Yes (initial value: left empty)|
| 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|
| description | Description of the application. The value is a string with a maximum of 255 bytes or a resource index to the description.| String| Yes (initial value: left empty)|
| vendor | Vendor of the application. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)|
| versionCode | Version number of the application. The value is a 32-bit non-negative integer less than 2 to the power of 31. It is used only to determine whether a version is later than another version. A larger value indicates a later version. Ensure that a new version of the application uses a value greater than any of its predecessors. | Number| No|
| versionName | Version number of the application displayed to users.<br>The value consists of only digits and dots. The four-part format *A.B.C.D* is recommended, wherein:<br>Part 1 (*A*): major version number, which ranges from 0 to 99. A major version consists of major new features or large changes.<br>Part 2 (*B*): minor version number, which ranges from 0 to 99. A minor version consists of some new features and large bug fixes.<br>Part 3 (*C*): feature version number, which ranges from 0 to 99. A feature version consists of scheduled new features.<br>Part 4 (*D*): maintenance release number or patch number, which ranges from 0 to 999. A maintenance release or patch consists of resolution to security flaws or minor bugs.<br>The value contains a maximum of 127 bytes.| String| No|
| minCompatibleVersionCode | Minimum compatible version of the application. It is used to check whether the application is compatible with a version on other devices in the cross-device scenario.| Number| Yes (initial value: value of **versionCode**)|
| minAPIVersion | Minimum API version required for running the application.| Number| Yes (initial value: value of **compatibleSdkVersion** in **bundle-profile.json5**)|
| targetAPIVersion | Target API version required for running the application.| Number| Yes (initial value: value of **compileSdkVersion** in **bundle-profile.json5**)|
| minAPIVersion | Minimum API version required for running the application.| Number| Yes (initial value: value of **compatibleSdkVersion** in **build-profile.json5**)|
| targetAPIVersion | Target API version required for running the application.| Number| Yes (initial value: value of **compileSdkVersion** in **build-profile.json5**)|
| 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)|
| distributedNotificationEnabled | Whether distributed notification is enabled for the application. When distributed notification is enabled and device A and device B where the application is installed are on the same distributed network, the devices behave in this way: If device A receives a message, device B will receive a distributed notification prompting the user to check the message received on device A.<br>- **true**: Distributed notification is enabled.<br>- **false**: Distributed notification is not enabled.| Boolean| Yes (initial value: **false**)|
| entityType | Type of the application. The options are as follows:<br>- game<br>- media<br>- communication<br>- news<br>- travel<br>- utility<br>- shopping<br>- education<br>- kids<br>- business<br>- photography<br>- unspecified| String| Yes (initial value: **"unspecified"**)|
......
# Application Installation and Uninstallation Process
## Developers
Developers can install and uninstall applications by running debug commands. For details, see [Multi-HAP Development, Debugging, Release, and Deployment Process](multi-hap-release-deployment.md#debugging).
The OpenHarmony bundle manager service module provides APIs for installing, updating, and uninstalling applications. You can call these APIs when needed. After you release your application to the application market, users can install and uninstall it on their device.
**Figure 1** Process of installing and uninstalling an application (applicable to developers)
![hap-intall-uninstall](figures/hap-install-uninstall-developer.png)
## Consumers
When an application has been released to the application market, consumers can install or uninstall the application on their device through the application market.
**Figure 1** Process of installing and uninstalling an application
![hap-intall-uninstall](figures/hap-intall-uninstall.png)
**Figure 2** Process of installing and uninstalling an application (applicable to consumers)
![hap-intall-uninstall](figures/hap-install-uninstall-user.png)
\ No newline at end of file
......@@ -28,12 +28,12 @@ You can use DevEco Studio to build code into one or more HAP files. Then, you ca
uninstall bundle successfully.
```
* Using Bundle Manager (bm) for debugging
* Using [Bundle Manager (bm)](../../application-dev/tools/bm-tool.md) for debugging
When using bm to install or update an HAP file, the HAP file path is the one on the real device. The command reference is as follows:
```
// Installation and update: Multiple file paths can be specified.
bm install -p /data/app/entry.hap /data/app/ feature.hap
bm install -p /data/app/entry.hap /data/app/feature.hap
// The execution result is as follows:
install bundle successfully.
// Uninstall
......
......@@ -223,7 +223,10 @@ You can implement page redirection through the [page router](../reference/apis/j
.height('5%')
// Bind the onClick event to the Next button so that clicking the button redirects the user to the second page.
.onClick(() => {
router.pushUrl({ url: 'pages/second' })
router.push({ url: 'pages/second' })
// In a project of API version 9, you can use the API below instead:
// router.pushUrl({ url: 'pages/second' })
})
}
.width('100%')
......
# @ohos.application.AccessibilityExtensionAbility
# @ohos.application.AccessibilityExtensionAbility (AccessibilityExtensionAbility)
The **AccessibilityExtensionAbility** module provides accessibility extension capabilities based on the ExtensionAbility framework.
......
......@@ -2771,6 +2771,7 @@ try {
### bundleManager.getApplicationInfoSync
getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md);
getApplicationInfoSync(bundleName: string, applicationFlags: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md);
Synchronously obtains the application information based on the given bundle name, application flags, and user ID.
......@@ -2786,7 +2787,7 @@ Synchronously obtains the application information based on the given bundle name
| ----------- | ------ | ---- | ----------------------------------------------------------|
| bundleName | string | Yes | Bundle name. |
| applicationFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. |
| userId | number | No | User ID. |
| userId | number | Yes | User ID. |
**Return value**
......@@ -2838,6 +2839,7 @@ try {
### bundleManager.getBundleInfoSync
getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId: number): [BundleInfo](js-apis-bundleManager-bundleInfo.md);
getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [BundleInfo](js-apis-bundleManager-bundleInfo.md);
Synchronously obtains the bundle information based on the given bundle name, bundle flags, and user ID.
......
# @ohos.util.Deque (Linear Container Deque)
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Double-ended queue (deque) is a sequence container implemented based on the queue data structure that follows the principles of First In First Out (FIFO) and Last In First Out (LIFO). It allows insertion and removal of elements at both the ends. **Deque** can dynamically adjust the capacity based on project requirements. It doubles the capacity each time. **Deque** differs from **[Queue](js-apis-queue.md)** and **[Vector](js-apis-vector.md)** mainly in the following aspects:
......
# @ohos.deviceUsageStatistics (Device Usage Statistics)
# @ohos.bundleState (Device Usage Statistics)
This module provides APIs for collecting statistics on device usage.
......@@ -454,6 +454,20 @@ Provides the usage duration information of an application.
| infosBeginTime | number | No | Time logged in the first application usage record in the **BundleActiveInfo** object.|
| infosEndTime | number | No | Time logged in the last application usage record in the **BundleActiveInfo** object.|
### merge<sup>(deprecated)</sup>
merge(toMerge: BundleStateInfo): void
Merges the device usage statistics of applications with the same bundle name.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| toMerge | [BundleStateInfo](#bundlestateinfo) | Yes| Device usage statistics to merge.|
## BundleActiveState
Provides information about an application event.
......
# File Interaction
# @ohos.document (File Interaction)
> **NOTE**<br/>
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
# @ohos.fileExtensionInfo
# @ohos.file.fileExtensionInfo (User File Extension Information)
The **fileExtensionInfo** module defines attributes in **RootInfo** and **FileInfo** of the user file access and management module.
......@@ -10,7 +10,7 @@ The **fileExtensionInfo** module defines attributes in **RootInfo** and **FileIn
## Modules to Import
```js
import fileExtensionInfo from '@ohos.fileExtensionInfo';
import fileExtensionInfo from '@ohos.file.fileExtensionInfo';
```
## fileExtensionInfo.DeviceType
......@@ -40,7 +40,7 @@ Defines the values of **deviceFlags** used in **RootInfo**. **deviceFlags** is u
| Name| Type | Readable| Writable| Description |
| ------ | ------ | ---- | ---- | -------- |
| SUPPORTS_READ | number | Yes | No | The device supports read.|
| SUPPORTS_WRITE | number | Yes | No | This device supports write.|
| SUPPORTS_WRITE | number | Yes | No | The device supports write.|
## fileExtensionInfo.DocumentFlag
......
# File Management
# @ohos.fileio (File Management)
The **fileio** module provides APIs for file storage and management, including basic file management, directory management, file information statistics, and stream read and write.
......@@ -40,7 +40,7 @@ FA Model
let pathDir = data;
})
```
For details about how to obtain the context of the FA model, see [FA Model](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-Context.md#context).
## fileio.stat
......
# InputMethodExtensionAbility
# @ohos.InputMethodExtensionAbility (InputMethodExtensionAbility)
The **InputMethodExtensionAbility** module provides APIs for developing input methods and managing their lifecycles.
......@@ -9,7 +9,7 @@ The **InputMethodExtensionAbility** module provides APIs for developing input me
## Modules to Import
```js
import InputMethodExtensionAbility from '@ohos.inputmethodextensionability';
import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
```
## Attributes
......
# @ohos.inputmethodextensioncontext (InputMethodExtensionContext)
# @ohos.InputMethodExtensionContext (InputMethodExtensionContext)
The **InputMethodExtensionContext** module, inherited from **ExtensionContext**, provides context for **InputMethodExtension** abilities.
......@@ -11,7 +11,7 @@ You can use the APIs of this module to start, terminate, connect, and disconnect
## Modules to Import
```
import InputMethodExtensionContext from '@ohos.inputmethodextensioncontext';
import InputMethodExtensionContext from '@ohos.InputMethodExtensionContext';
```
## Usage
......@@ -19,7 +19,7 @@ import InputMethodExtensionContext from '@ohos.inputmethodextensioncontext';
Before using the **InputMethodExtensionContext** module, you must define a child class that inherits from **InputMethodExtensionAbility**.
```js
import InputMethodExtensionAbility from '@ohos.inputmethodextensionability';
import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
class EntryAbility extends InputMethodExtensionAbility {
onCreate() {
let context = this.context;
......@@ -66,9 +66,9 @@ Terminates this ability. This API uses a promise to return the result.
**Example**
```js
this.context.destroy().then((data) => {
console.log('success:' + JSON.stringify(data));
this.context.destroy().then(() => {
console.log('Succeed in destroying context.');
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
console.log('Failed to destroy context: ' + JSON.stringify(error));
});
```
# @ohos.inputmethodsubtype
# @ohos.InputMethodSubtype (Input Method Subtype)
The **inputMethodSubtype** module provides APIs for managing the attributes of input method subtypes. Different attribute settings result in different subtypes.
The **InputMethodSubtype** module provides APIs for managing the attributes of input method subtypes. Different attribute settings result in different subtypes.
> **NOTE**
>
......@@ -9,7 +9,7 @@ The **inputMethodSubtype** module provides APIs for managing the attributes of i
## Modules to Import
```
import inputMethodEngine from '@ohos.inputMethodSubtype';
import InputMethodSubtype from '@ohos.InputMethodSubtype';
```
## Attributes
......
# @ohos.inputmethod
# @ohos.inputMethod (Input Method Framework)
The **inputMethod** module provides an input method framework, which can be used to hide the keyboard, obtain the list of installed input methods, display the dialog box for input method selection, and more.
......@@ -10,7 +10,7 @@ The **inputMethod** module provides an input method framework, which can be used
## Modules to Import
```js
import inputMethod from '@ohos.inputmethod';
import inputMethod from '@ohos.inputMethod';
```
## Constants<sup>8+</sup>
......@@ -111,7 +111,7 @@ Switches to another input method. This API uses an asynchronous callback to retu
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| target | [InputMethodProperty](#inputmethodproperty8) | Yes| Input method to switch to.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object. |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -160,15 +160,15 @@ Switches to another input method. This API uses a promise to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
|target | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
|target | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
**Return value**
| Type | Description |
| ----------------------------------------- | ---------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the switching is successful, and **false** means the opposite.|
| Type | Description |
| ----------------------------------------- | ---------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the switching is successful, and **false** means the opposite.|
**Error codes**
......@@ -240,7 +240,7 @@ Switches to another subtype of the current input method. This API uses an asynch
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| target | [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)| Yes| Input method subtype to switch to.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object. |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -376,7 +376,7 @@ Switches to a specified subtype of a specified input method. This API uses an as
| -------- | -------- | -------- | -------- |
|inputMethodProperty | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
|inputMethodSubtype | [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)| Yes| Input method subtype to switch to.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object. |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -557,7 +557,7 @@ Ends this input session. The invoking of this API takes effect only after the in
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object. |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -643,7 +643,7 @@ Shows this soft keyboard. This API must be used with the input text box and work
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -715,7 +715,7 @@ Hides this soft keyboard. This API must be used with the input text box and work
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -789,7 +789,7 @@ Ends this input session. The invoking of this API takes effect only after the in
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object. |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
**Example**
......@@ -1157,7 +1157,7 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object. |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -1291,7 +1291,7 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
......
# @ohos.inputmethodengine
# @ohos.inputMethodEngine (Input Method Service)
The **inputMethodEngine** module streamlines the interaction between input methods and applications. By calling APIs of this module, applications can be bound to input method services to accept text input through the input methods, request the keyboard to display or hide, listen for the input method status, and much more.
The **inputMethodEngine** module streamlines the interactions between input methods and applications. By calling APIs of this module, applications can be bound to input method services to accept text input, request the keyboard to display or hide, listen for the input method status, and much more.
> **NOTE**
>
......@@ -9,7 +9,7 @@ The **inputMethodEngine** module streamlines the interaction between input metho
## Modules to Import
```
import inputMethodEngine from '@ohos.inputmethodengine';
import inputMethodEngine from '@ohos.inputMethodEngine';
```
## Constants
......@@ -203,7 +203,7 @@ Enables listening for a keyboard event. This API uses an asynchronous callback t
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>- The value **'keyboardShow'** indicates the keyboard display event.<br>- The value **'keyboardHide'** indicates the keyboard hiding event. |
| type | string | Yes | Listening type.<br>- The value **'keyboardShow'** indicates the keyboard display event.<br>- The value **'keyboardHide'** indicates the keyboard hiding event.|
| callback | () => void | Yes | Callback used to return the result. |
**Example**
......@@ -418,7 +418,7 @@ Disables listening for a keyboard event. This API uses an asynchronous callback
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>The value **'keyboardShow'** indicates the keyboard display event.<br>The value **'keyboardHide'** indicates the keyboard hiding event.|
| type | string | Yes | Listening type.<br>- The value **'keyboardShow'** indicates the keyboard display event.<br>- The value **'keyboardHide'** indicates the keyboard hiding event.|
| callback | () => void | No | Callback used to return the result. |
**Example**
......
# @ohos.bundle.launcherBundleManager
# @ohos.bundle.launcherBundleManager (launcherBundleManager)
The **bundle.launcherBundleManager** module providers APIs for the **Home Screen** application to obtain the launcher ability information and shortcut information.
......
......@@ -389,7 +389,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeFirst method cannot be bound. |
| 10200010 | The container is empty. |
| 10200010 | Container is empty. |
**Example**
......@@ -424,7 +424,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeLast method cannot be bound. |
| 10200010 | The container is empty. |
| 10200010 | Container is empty. |
**Example**
......@@ -504,7 +504,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeFirstFound method cannot be bound. |
| 10200010 | The container is empty. |
| 10200010 | Container is empty. |
**Example**
......@@ -544,7 +544,7 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
| ID| Error Message|
| -------- | -------- |
| 10200011 | The removeLastFound method cannot be bound. |
| 10200010 | The container is empty. |
| 10200010 | Container is empty. |
**Example**
......
# @ohos.reminderAgent (reminderAgent)
# @ohos.reminderAgent (Reminder Agent)
The **reminderAgent** module provides APIs for publishing scheduled reminders through the reminder agent.
......
# @ohos.reminderAgentManager (reminderAgentManager)
# @ohos.reminderAgentManager (Reminder Agent Management)
The **reminderAgentManager** module provides APIs for publishing scheduled reminders through the reminder agent.
......
......@@ -2,7 +2,8 @@
The **request** module provides applications with basic upload, download, and background transmission agent capabilities.
> **NOTE**<br>
> **NOTE**
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -35,7 +36,6 @@ The **cleartextTraffic** attribute is not involved during application developmen
The download server must support the HTTP HEAD method so that the size of the data to download can be obtained through **Content-length**. Otherwise, the download task fails. If this is the case, you can check the failure cause through [on('fail')<sup>7+</sup>](#onfail7).
Only HTTP requests are supported. HTTPS requests are not supported.
## Constants
......@@ -77,7 +77,7 @@ The table below lists the causes of download pause that may be returned by [getT
| PAUSED_QUEUED_FOR_WIFI<sup>7+</sup> | number | 0 | Download paused and queuing for a WLAN connection, because the file size exceeds the maximum value allowed by a mobile network session.|
| PAUSED_WAITING_FOR_NETWORK<sup>7+</sup> | number | 1 | Download paused due to a network connection problem, for example, network disconnection.|
| PAUSED_WAITING_TO_RETRY<sup>7+</sup> | number | 2 | Download paused and then retried.|
| PAUSED_BY_USER<sup>9+</sup> | number | 3 | The user paused the session. |
| PAUSED_BY_USER<sup>9+</sup> | number | 3 | The user paused the session.|
| PAUSED_UNKNOWN<sup>7+</sup> | number | 4 | Download paused due to unknown reasons.|
### Download Task Status Codes
......@@ -128,7 +128,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
```js
let uploadTask;
let uploadConfig = {
url: 'http://patch',
url: 'https://patch',
header: { key1: "value1", key2: "value2" },
method: "POST",
files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }],
......@@ -176,7 +176,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
```js
let uploadTask;
let uploadConfig = {
url: 'http://patch',
url: 'https://patch',
header: { key1: "value1", key2: "value2" },
method: "POST",
files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }],
......@@ -228,7 +228,7 @@ Uploads files. This API uses a promise to return the result.
```js
let uploadTask;
let uploadConfig = {
url: 'http://patch',
url: 'https://patch',
header: { key1: "value1", key2: "value2" },
method: "POST",
files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }],
......@@ -270,7 +270,7 @@ Uploads files. This API uses an asynchronous callback to return the result.
```js
let uploadTask;
let uploadConfig = {
url: 'http://patch',
url: 'https://patch',
header: { key1: "value1", key2: "value2" },
method: "POST",
files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }],
......@@ -318,7 +318,7 @@ Uploads files. This API uses a promise to return the result.
```js
let uploadTask;
let uploadConfig = {
url: 'http://patch',
url: 'https://patch',
header: { key1: "value1", key2: "value2" },
method: "POST",
files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }],
......@@ -359,7 +359,7 @@ Uploads files. This API uses an asynchronous callback to return the result.
```js
let uploadTask;
let uploadConfig = {
url: 'http://patch',
url: 'https://patch',
header: { key1: "value1", key2: "value2" },
method: "POST",
files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }],
......@@ -376,7 +376,7 @@ Uploads files. This API uses an asynchronous callback to return the result.
## UploadTask
Implements file uploads. Before using any APIs of this class, you must obtain an **UploadTask** object through [request.uploadFile<sup>9+</sup>](#requestuploadfile9) in promise mode or [request.uploadFile<sup>9+</sup>](#requestuploadfile9-1) in callback mode.
Implements file uploads. Before using any APIs of this class, you must obtain an **UploadTask** object.
### on('progress')
......@@ -399,8 +399,8 @@ Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes| Size of the uploaded files, in bytes. |
| totalSize | number | Yes| Total size of the files to upload, in bytes. |
| uploadedSize | number | Yes| Size of the uploaded files, in bits. |
| totalSize | number | Yes| Total size of the files to upload, in bits. |
**Example**
......@@ -504,12 +504,12 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).|
| callback | function | No| Callback for the upload progress event.|
Parameters of the callback function
Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes| Size of the uploaded files, in bytes. |
| totalSize | number | Yes| Total size of the files to upload, in bytes. |
| uploadedSize | number | Yes| Size of the uploaded files, in bits. |
| totalSize | number | Yes| Total size of the files to upload, in bits. |
**Example**
......@@ -764,7 +764,7 @@ Removes this upload task. This API uses an asynchronous callback to return the r
| -------- | -------- | -------- | -------- |
| filename | string | Yes| File name in the header when **multipart** is used.|
| name | string | Yes| Name of a form item when **multipart** is used. The default value is **file**.|
| uri | string | Yes| Local path for storing files.<br>The **dataability** and **internal** protocol types are supported. However, the **internal** protocol type supports only temporary directories. Below are examples:<br>dataability:///com.domainname.dataability.persondata/person/10/file.txt<br><br>internal://cache/path/to/file.txt |
| uri | string | Yes| Local path for storing files.<br>Only the **internal** protocol type is supported. In the value, **internal://cache/** is mandatory. Example:<br>internal://cache/path/to/file.txt |
| type | string | Yes| Type of the file content. By default, the type is obtained based on the extension of the file name or URI.|
......@@ -1027,7 +1027,7 @@ Downloads files. This API uses an asynchronous callback to return the result.
## DownloadTask
Implements file downloads. Before using any APIs of this class, you must obtain a **DownloadTask** object through [request.downloadFile<sup>9+</sup>](#requestdownloadfile9) in promise mode or [request.downloadFile<sup>9+</sup>](#requestdownloadfile9-1) in callback mode.
Implements file downloads. Before using any APIs of this class, you must obtain a **DownloadTask** object.
### on('progress')
......@@ -1047,12 +1047,12 @@ Subscribes to a download event. This API uses an asynchronous callback to return
| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).|
| callback | function | Yes| Callback for the download progress event.|
Parameters of the callback function
Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| receivedSize | number | Yes| Size of the downloaded files, in bytes. |
| totalSize | number | Yes| Total size of the files to download, in bytes. |
| receivedSize | number | Yes| Size of the downloaded files, in bits. |
| totalSize | number | Yes| Total size of the files to download, in bits. |
**Example**
......@@ -1085,8 +1085,8 @@ Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| receivedSize | number | Yes| Size of the downloaded files, in bytes. |
| totalSize | number | Yes| Total size of the files to download, in bytes. |
| receivedSize | number | Yes| Size of the downloaded files, in bits. |
| totalSize | number | Yes| Total size of the files to download, in bits. |
**Example**
......@@ -1252,7 +1252,7 @@ Removes this download task. This API uses a promise to return the result.
delete(callback: AsyncCallback&lt;boolean&gt;): void
Removes this download task. This API uses an asynchronous callback to return the result.
Deletes this download task. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.INTERNET
......@@ -1262,7 +1262,7 @@ Removes this download task. This API uses an asynchronous callback to return the
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the task removal result.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the task deletion result. |
**Example**
......
# @ohos.resourceschedule.workScheduler (workScheduler)
# @ohos.resourceschedule.workScheduler (Work Scheduler)
The **workScheduler** module provides the APIs for registering, canceling, and querying Work Scheduler tasks, which do not have real-time constraints.
......
......@@ -100,14 +100,6 @@ Unlocks the screen. This API uses an asynchronous callback to return the result.
| -------- | --------------------- | ---- | ------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. The value **true** means that the screen is unlocked successfully, and **false** means the opposite.|
**Error codes**
For details about the error codes, see [Screen Lock Management Error Codes](../errorcodes/errorcode-screenlock.md).
| ID| Error Message|
| -------- | ---------------------------------------- |
| 13200002 | The screenlock management service is abnormal. |
**Example**
```js
......@@ -134,14 +126,6 @@ Unlocks the screen. This API uses a promise to return the result.
| ------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means that the screen is unlocked successfully, and **false** means the opposite.|
**Error codes**
For details about the error codes, see [Screen Lock Management Error Codes](../errorcodes/errorcode-screenlock.md).
| ID| Error Message|
| -------- | ---------------------------------------- |
| 13200002 | The screenlock management service is abnormal. |
**Example**
```js
......@@ -168,14 +152,6 @@ Locks the screen. This API uses an asynchronous callback to return the result.
| -------- | ---------------------- | ---- | ---------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. The value **true** means that the screen is locked successfully, and **false** means the opposite.|
**Error codes**
For details about the error codes, see [Screen Lock Management Error Codes](../errorcodes/errorcode-screenlock.md).
| ID| Error Message|
| -------- | ---------------------------------------- |
| 13200002 | The screenlock management service is abnormal. |
**Example**
```js
......@@ -204,13 +180,6 @@ Locks the screen. This API uses a promise to return the result.
| ---------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means that the screen is locked successfully, and **false** means the opposite.|
**Error codes**
For details about the error codes, see [Screen Lock Management Error Codes](../errorcodes/errorcode-screenlock.md).
| ID| Error Message|
| -------- | ---------------------------------------- |
| 13200002 | The screenlock management service is abnormal. |
**Example**
......@@ -226,7 +195,7 @@ screenlock.lock().then((data) => {
onSystemEvent(callback: Callback&lt;SystemEvent&gt;): boolean
Registers a callback for system events related to screen locking.
Registers a callback for system events related to screen locking. This API can be called only by system screen lock applications.
**System capability**: SystemCapability.MiscServices.ScreenLock
......@@ -244,13 +213,6 @@ Registers a callback for system events related to screen locking.
| ------- | ------------------------------------------------- |
| boolean | Returns **true** if the callback is registered successfully; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Screen Lock Management Error Codes](../errorcodes/errorcode-screenlock.md).
| ID| Error Message|
| -------- | ---------------------------------------- |
| 13200002 | The screenlock management service is abnormal. |
**Example**
......@@ -282,13 +244,6 @@ Sends an event to the screen lock service. This API uses an asynchronous callbac
| parameter | number | Yes | Result.<br>- **0**: The operation is successful. For example, the screen is locked or unlocked successfully.<br>- **1**, the operation fails. For example, screen locking or unlocking fails.<br>- **2**: The operation is canceled. For example, screen locking or unlocking is canceled.|
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The **value** true means that the event is sent successfully, and **false** means the opposite. |
**Error codes**
For details about the error codes, see [Screen Lock Management Error Codes](../errorcodes/errorcode-screenlock.md).
| ID| Error Message|
| -------- | ---------------------------------------- |
| 13200002 | The screenlock management service is abnormal. |
**Example**
......
# @ohos.screenshot
# @ohos.screenshot (Screenshot)
The **Screenshot** module provides APIs for you to set information such as the region to capture and the size of the screen region when capturing a screen.
......
# statfs
# @ohos.statfs (statfs)
The statfs module provides APIs for obtaining file system information, including the total number of bytes and the number of idle bytes of the file system.
......
......@@ -5,6 +5,8 @@ The **stationary** module provides APIs to report the device status, including a
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> This module does not support x86 emulators.
## Modules to Import
......
# Bluetooth
# @system.bluetooth (Bluetooth)
> **NOTE**<br/>
......
# Application Configuration
# @system.configuration (Application Configuration)
> **NOTE**<br>
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.i18n`](js-apis-i18n.md) and [`@ohos.intl`](js-apis-intl.md) instead.
......
# @ohos.systemDateTime
# @ohos.systemDateTime (System Time and Time Zone)
The **systemDateTime** module provides system time and time zone features. You can use the APIs of this module to set and obtain the system time and time zone.
......
# Data Request
# @system.fetch (Data Request)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**
>
> - The APIs of this module are no longer maintained since API version 6. You are advised to use [`@ohos.net.http`](js-apis-http.md) instead.
>
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
# File Storage
# @system.file (File Storage)
> **NOTE**<br>
> - The APIs of this module are no longer maintained since API version 6. You are advised to use [`@ohos.fileio`](js-apis-fileio.md).
......
# Geographic Location
# @system.geolocation (Geographic Location)
> **NOTE**
>
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.geolocation`](js-apis-geolocation.md).
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
# @system.request
# @system.request (Upload and Download)
The **system.request** module provides applications with basic upload and download capabilities.
> **NOTE**
> - The APIs of this module are deprecated since API version 9. You are advised to use [`@ohos.request`](js-apis-request.md) instead.
> - The APIs of this module are deprecated since API version 9. You are advised to use [@ohos.request](js-apis-request.md) instead.
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -25,9 +25,9 @@ Uploads a file. This API returns no value.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [UploadRequestOptions](#uploadrequestoptions) | Yes| Upload configurations.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [UploadRequestOptions](#uploadrequestoptions) | Yes| Upload configurations.|
**Example**
......@@ -61,27 +61,27 @@ Uploads a file. This API returns no value.
**System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| url | string | Yes| URL of the upload server.|
| data | Array&lt;[RequestData](#requestdata)&gt; | No| Form data in the request body.|
| files | Array&lt;[RequestFile](#requestfile)&gt; | Yes| List of files to upload, which is submitted through **multipart/form-data**.|
| header | Object | No| Request header.|
| method | string | No| Request method, which can be **'POST'** or **'PUT'**. The default value is **POST**.|
| success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| url | string | Yes| URL of the upload server.|
| data | Array&lt;[RequestData](#requestdata)&gt; | No| Form data in the request body.|
| files | Array&lt;[RequestFile](#requestfile)&gt; | Yes| List of files to upload, which is submitted through **multipart/form-data**.|
| header | Object | No| Request header.|
| method | string | No| Request method, which can be **'POST'** or **'PUT'**. The default value is **POST**.|
| success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
**success parameter**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | [UploadResponse](#uploadresponse) | Yes| Information returned when the upload task is successful.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | [UploadResponse](#uploadresponse) | Yes| Information returned when the upload task is successful.|
**fail parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the upload task fails.|
| code | number | Yes| HTTP status code returned when the upload task fails.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the upload task fails.|
| code | number | Yes| HTTP status code returned when the upload task fails.|
......@@ -89,33 +89,33 @@ Uploads a file. This API returns no value.
**System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Description|
| -------- | -------- | -------- |
| code | number | HTTP status code returned by the server.|
| data | string | Content returned by the server. The value type is determined by the type in the returned headers.|
| headers | Object | Headers returned by the server.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| code | number | Yes| HTTP status code returned by the server.|
| data | string | Yes| Content returned by the server. The value type is determined by the type in the returned headers.|
| headers | Object | Yes| Headers returned by the server.|
## RequestFile
**System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| filename | string | No| File name in the header when **multipart** is used.|
| name | string | No| Name of a form item when **multipart** is used. The default value is **file**.|
| uri | string | Yes| Local path for storing files.|
| type | string | No| Type of the file content. By default, the type is obtained based on the extension of the file name or URI.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| filename | string | No| File name in the header when **multipart** is used.|
| name | string | No| Name of a form item when **multipart** is used. The default value is **file**.|
| uri | string | Yes| Local path for storing files.|
| type | string | No| Type of the file content. By default, the type is obtained based on the extension of the file name or URI.|
## RequestData
**System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the form element.|
| value | string | Yes| Value of the form element.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the form element.|
| value | string | Yes| Value of the form element.|
......@@ -129,9 +129,9 @@ Downloads a file. This API returns no value.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [DownloadRequestOptions](#downloadrequestoptions) | Yes| Download configurations.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [DownloadRequestOptions](#downloadrequestoptions) | Yes| Download configurations.|
**Example**
......@@ -164,34 +164,34 @@ Downloads a file. This API returns no value.
**System capability**: SystemCapability.MiscServices.Download
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| url | string | Yes| Resource URL.|
| filename | string | No| Name of the file to download. The value is obtained from the current request or resource URL by default.|
| header | Object | No| Request header.|
| description | string | No| Download description. The default value is the file name.|
| success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| url | string | Yes| Resource URL.|
| filename | string | No| Name of the file to download. The value is obtained from the current request or resource URL by default.|
| header | Object | No| Request header.|
| description | string | No| Download description. The default value is the file name.|
| success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
**success parameter**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | [DownloadResponse](#downloadresponse) | Yes| Information returned when the download task is successful.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | [DownloadResponse](#downloadresponse) | Yes| Information returned when the download task is successful.|
**fail parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the download task fails.|
| code | number | Yes| HTTP status code returned when the download task fails.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the download task fails.|
| code | number | Yes| HTTP status code returned when the download task fails.|
## DownloadResponse
**System capability**: SystemCapability.MiscServices.Download
| Name| Type| Description|
| -------- | -------- | -------- |
| token | string | Download token, which is used to obtain the download status|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | string | Yes| Download token, which is used to obtain the download status|
## request.onDownloadComplete
......@@ -204,9 +204,9 @@ Listens for download task status. This API returns no value.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [OnDownloadCompleteOptions](#ondownloadcompleteoptions) | Yes| Configurations of the download task.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [OnDownloadCompleteOptions](#ondownloadcompleteoptions) | Yes| Configurations of the download task.|
**Example**
......@@ -231,29 +231,29 @@ Listens for download task status. This API returns no value.
**System capability**: SystemCapability.MiscServices.Download
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | string | Yes| Result token returned by the download API.|
| success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | string | Yes| Result token returned by the download API.|
| success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
**success parameter**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | [OnDownloadCompleteResponse](#ondownloadcompleteresponse) | Yes| Information returned when the download task is successful.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | [OnDownloadCompleteResponse](#ondownloadcompleteresponse) | Yes| Information returned when the download task is successful.|
**fail parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the download task fails.|
| code | number | Yes| HTTP status code returned when the download task fails.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the download task fails.|
| code | number | Yes| HTTP status code returned when the download task fails.|
## OnDownloadCompleteResponse
**System capability**: SystemCapability.MiscServices.Download
| Name| Type| Description|
| -------- | -------- | -------- |
| uri | string | URI of the download file.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| uri | string | Yes| URI of the download file.|
# Data Storage
# @system.storage (Data Storage)
> **NOTE**<br/>
> **NOTE**
>
> - The APIs of this module are no longer maintained since API Version 6, and you are advised to use [`@ohos.data.storage`](js-apis-data-storage.md). From API Version 9, you are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md).
> - The APIs of this module are no longer maintained since API version 6, and you are advised to use [`@ohos.data.storage`](js-apis-data-storage.md). From API version 9, you are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md).
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module can be used only in the FA model.
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module can be used only in the FA model.
## Modules to Import
```js
import storage from '@system.storage';
```
## storage.get
get(Object): void
get(options: GetStorageOptions): void
Reads the value stored in the cache based on the specified key.
......@@ -25,13 +24,9 @@ Reads the value stored in the cache based on the specified key.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to read.|
| default | string | No| Default value returned when the **key** does not exist.|
| success | Function | No| Called to return the value obtained when **storage.get()** is successful.|
| fail | Function | No| Called when **storage.get()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
| complete | Function | No| Called when **storage.get()** is complete.|
| Name | Type | Mandatory| Description |
| ------- | -------------------- | ---- | ---------- |
| options | [GetStorageOptions](#getstorageoptions) | Yes | API configuration.|
**Example**
......@@ -54,10 +49,9 @@ export default {
}
```
## storage.set
set(Object): void
get(options: SetStorageOptions): void
Sets the value in the cache based on the specified key.
......@@ -65,13 +59,9 @@ Sets the value in the cache based on the specified key.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to set.|
| value | string | Yes| New value to set. The length must be less than 128 bytes.|
| success | Function | No| Called when **storage.set()** is successful.|
| fail | Function | No| Called when **storage.set()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
| complete | Function | No| Called when **storage.set()** is complete.|
| Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ---------- |
| options | [SetStorageOptions](#setstorageoptions) | Yes | API configuration.|
**Example**
......@@ -92,10 +82,9 @@ export default {
}
```
## storage.clear
clear(Object): void
clear(options?: ClearStorageOptions): void
Clears the key-value pairs from the cache.
......@@ -103,11 +92,9 @@ Clears the key-value pairs from the cache.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| success | Function | No| Called when **storage.clear()** is successful.|
| fail | Function | No| Called when **storage.clear()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
| complete | Function | No| Called when **storage.clear()** is complete.|
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------- | ---- | -------------- |
| options | [ClearStorageOptions](#clearstorageoptions) | No | API configuration.|
**Example**
......@@ -126,10 +113,9 @@ export default {
}
```
## storage.delete
delete(Object): void
delete(options: DeleteStorageOptions): void
Deletes the key-value pair based on the specified key.
......@@ -137,12 +123,9 @@ Deletes the key-value pair based on the specified key.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to delete.|
| success | Function | No| Called when **storage.delete()** is successful.|
| fail | Function | No| Called when **storage.delete()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
| complete | Function | No| Called when **storage.delete()** is complete.|
| Name | Type | Mandatory| Description |
| ------- | --------------------------------------------- | ---- | -------------- |
| options | [DeleteStorageOptions](#deletestorageoptions) | Yes | API configuration.|
**Example**
......@@ -161,3 +144,52 @@ export default {
}
}
```
## GetStorageOptions
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
| Name | Type | Mandatory| Description |
| -------- | ---------------- | ---- | ------------------- |
| key | string | Yes | Key of the target data. |
| default | string | No | Default value returned when the specified key does not exist. |
| success | (data: any) => void | No | Called to return the result when **storage.get()** is called successfully. **data** is the value indexed by the specified key. |
| fail | (data: string, code: number) => void | No | Called to return the result when **storage.get()** fails to be called. **data** is the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when **storage.get()** is complete. |
## SetStorageOptions
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | -------------------- |
| key | string | Yes | Key of the data to set. |
| value | string | Yes | New value to set. The length must be less than 128 bytes. |
| success | () => void | No | Called when **storage.set()** is called successfully. |
| fail | (data: string, code: number) => void | No | Called to return the result when **storage.get()** fails to be called. **data** is the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when **storage.get()** is complete. |
## ClearStorageOptions
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | -------------------- |
| success | () => void | No | Called when **storage.clear()** is called successfully. |
| fail | (data: string, code: number) => void | No | Called to return the result when **storage.clear()** fails to be called. **data** is the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when **storage.clear()** is complete. |
## DeleteStorageOptions
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------ |
| key | string | Yes | Key of the data to delete. |
| success | () => void | No | Called when **storage.delete()** is called successfully. |
| fail | (data: string, code: number) => void | No | Called to return the result when **storage.delete()** fails to be called. **data** is the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when **storage.delete()** is complete. |
# @ohos.systemTimer
# @ohos.systemTimer (System Timer)
The **systemTimer** module provides system timer features. You can use the APIs of this module to implement the alarm clock and other timer services.
......@@ -48,8 +48,6 @@ createTimer(options: TimerOptions, callback: AsyncCallback&lt;number&gt;): void
Creates a timer. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.MiscServices.Time
**Parameters**
......@@ -63,23 +61,23 @@ Creates a timer. This API uses an asynchronous callback to return the result.
```js
export default {
systemTimer () {
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false
};
try {
systemTimer.createTimer(options, (error) => {
if (error) {
console.info(`Failed to create timer. message:${error.message}, code:${error.code}`);
return;
}
console.info(`Succeeded in creating timer.`);
});
} catch(e) {
console.info(`Failed to create timer. message:${e.message}, code:${e.code}`);
systemTimer () {
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false
};
try {
systemTimer.createTimer(options, (error, timerId) => {
if (error) {
console.info(`Failed to create timer. message: ${error.message}, code: ${error.code}`);
return;
}
console.info(`Succeeded in creating timer. timerId: ${timerId}`);
});
} catch(e) {
console.info(`Failed to create timer. message: ${e.message}, code: ${e.code}`);
}
}
}
```
......@@ -89,8 +87,6 @@ createTimer(options: TimerOptions): Promise&lt;number&gt;
Creates a timer. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.MiscServices.Time
**Parameters**
......@@ -109,21 +105,21 @@ Creates a timer. This API uses a promise to return the result.
```js
export default {
systemTimer () {
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false
};
try {
systemTimer.createTimer(options).then(() => {
console.info(`Succeeded in creating timer.`);
}).catch((error) => {
console.info(`Failed to create timer. message:${error.message}, code:${error.code}`);
});
} catch(e) {
console.info(`Failed to create timer. message:${e.message}, code:${e.code}`);
}
systemTimer () {
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false
};
try {
systemTimer.createTimer(options).then((timerId) => {
console.info(`Succeeded in creating timer. timerId: ${timerId}`);
}).catch((error) => {
console.info(`Failed to create timer. message: ${error.message}, code: ${error.code}`);
});
} catch(e) {
console.info(`Failed to create timer. message: ${e.message}, code: ${e.code}`);
}
}
}
```
......@@ -133,8 +129,6 @@ startTimer(timer: number, triggerTime: number, callback: AsyncCallback&lt;void&g
Starts a timer. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.MiscServices.Time
**Parameters**
......@@ -149,26 +143,26 @@ Starts a timer. This API uses an asynchronous callback to return the result.
```js
export default {
async systemTimer () {
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false
async systemTimer () {
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false
}
let timerId = await systemTimer.createTimer(options);
let triggerTime = new Date().getTime();
triggerTime += 3000;
try {
systemTimer.startTimer(timerId, triggerTime, (error) => {
if (error) {
console.info(`Failed to start timer. message: ${error.message}, code: ${error.code}`);
return;
}
let timerId = await systemTimer.createTimer(options)
let triggerTime = new Date().getTime()
triggerTime += 3000
try {
systemTimer.startTimer(timerId, triggerTime, (error) => {
if (error) {
console.info(`Failed to start timer. message:${error.message}, code:${error.code}`);
return;
}
console.info(`Succeeded in starting timer.`);
});
} catch(e) {
console.info(`Failed to start timer. message:${e.message}, code:${e.code}`);
}
console.info(`Succeeded in starting timer.`);
});
} catch(e) {
console.info(`Failed to start timer. message: ${e.message}, code: ${e.code}`);
}
}
}
```
......@@ -178,8 +172,6 @@ startTimer(timer: number, triggerTime: number): Promise&lt;void&gt;
Starts a timer. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.MiscServices.Time
**Parameters**
......@@ -199,24 +191,24 @@ Starts a timer. This API uses a promise to return the result.
```js
export default {
async systemTimer (){
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false
}
let timerId = await systemTimer.createTimer(options)
let triggerTime = new Date().getTime()
triggerTime += 3000
try {
systemTimer.startTimer(timerId, triggerTime).then(() => {
console.info(`Succeeded in starting timer.`);
}).catch((error) => {
console.info(`Failed to start timer. message:${error.message}, code:${error.code}`);
});
} catch(e) {
console.info(`Failed to start timer. message:${e.message}, code:${e.code}`);
}
async systemTimer (){
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false
}
let timerId = await systemTimer.createTimer(options);
let triggerTime = new Date().getTime();
triggerTime += 3000;
try {
systemTimer.startTimer(timerId, triggerTime).then(() => {
console.info(`Succeeded in starting timer.`);
}).catch((error) => {
console.info(`Failed to start timer. message: ${error.message}, code: ${error.code}`);
});
} catch(e) {
console.info(`Failed to start timer. message: ${e.message}, code: ${e.code}`);
}
}
}
```
......@@ -226,8 +218,6 @@ stopTimer(timer: number, callback: AsyncCallback&lt;void&gt;): void
Stops a timer. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.MiscServices.Time
**Parameters**
......@@ -241,27 +231,27 @@ Stops a timer. This API uses an asynchronous callback to return the result.
```js
export default {
async systemTimer () {
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false
}
let timerId = await systemTimer.createTimer(options)
let triggerTime = new Date().getTime()
triggerTime += 3000
systemTimer.startTimer(timerId, triggerTime)
try {
systemTimer.stopTimer(timerId, (error) => {
if (error) {
console.info(`Failed to stop timer. message:${error.message}, code:${error.code}`);
return;
}
console.info(`Succeeded in stopping timer.`);
});
} catch(e) {
console.info(`Failed to stop timer. message:${e.message}, code:${e.code}`);
async systemTimer () {
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false
}
let timerId = await systemTimer.createTimer(options);
let triggerTime = new Date().getTime();
triggerTime += 3000;
systemTimer.startTimer(timerId, triggerTime);
try {
systemTimer.stopTimer(timerId, (error) => {
if (error) {
console.info(`Failed to stop timer. message: ${error.message}, code: ${error.code}`);
return;
}
}
console.info(`Succeeded in stopping timer.`);
});
} catch(e) {
console.info(`Failed to stop timer. message: ${e.message}, code: ${e.code}`);
}
}
}
```
......@@ -271,8 +261,6 @@ stopTimer(timer: number): Promise&lt;void&gt;
Stops a timer. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.MiscServices.Time
**Parameters**
......@@ -291,25 +279,25 @@ Stops a timer. This API uses a promise to return the result.
```js
export default {
async systemTimer (){
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false
}
let timerId = await systemTimer.createTimer(options)
let triggerTime = new Date().getTime()
triggerTime += 3000
systemTimer.startTimer(timerId, triggerTime)
try {
systemTimer.stopTimer(timerId).then(() => {
console.info(`Succeeded in stopping timer.`);
}).catch((error) => {
console.info(`Failed to stop timer. message:${error.message}, code:${error.code}`);
});
} catch(e) {
console.info(`Failed to stop timer. message:${e.message}, code:${e.code}`);
}
async systemTimer (){
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false
}
let timerId = await systemTimer.createTimer(options);
let triggerTime = new Date().getTime();
triggerTime += 3000;
systemTimer.startTimer(timerId, triggerTime);
try {
systemTimer.stopTimer(timerId).then(() => {
console.info(`Succeeded in stopping timer.`);
}).catch((error) => {
console.info(`Failed to stop timer. message: ${error.message}, code: ${error.code}`);
});
} catch(e) {
console.info(`Failed to stop timer. message: ${e.message}, code: ${e.code}`);
}
}
}
```
......@@ -319,8 +307,6 @@ destroyTimer(timer: number, callback: AsyncCallback&lt;void&gt;): void
Destroys a timer. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.MiscServices.Time
**Parameters**
......@@ -334,28 +320,28 @@ Destroys a timer. This API uses an asynchronous callback to return the result.
```js
export default {
async systemTimer () {
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false
}
let timerId = await systemTimer.createTimer(options)
let triggerTime = new Date().getTime()
triggerTime += 3000
systemTimer.startTimer(timerId, triggerTime)
systemTimer.stopTimer(timerId)
try {
systemTimer.destroyTimer(timerId, (error) => {
if (error) {
console.info(`Failed to destroy timer. message:${error.message}, code:${error.code}`);
return;
}
console.info(`Succeeded in destroying timer.`);
});
} catch(e) {
console.info(`Failed to destroying timer. message:${e.message}, code:${e.code}`);
async systemTimer () {
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false
}
let timerId = await systemTimer.createTimer(options);
let triggerTime = new Date().getTime();
triggerTime += 3000;
systemTimer.startTimer(timerId, triggerTime);
systemTimer.stopTimer(timerId);
try {
systemTimer.destroyTimer(timerId, (error) => {
if (error) {
console.info(`Failed to destroy timer. message: ${error.message}, code: ${error.code}`);
return;
}
console.info(`Succeeded in destroying timer.`);
});
} catch(e) {
console.info(`Failed to destroying timer. message: ${e.message}, code: ${e.code}`);
}
}
}
```
......@@ -365,8 +351,6 @@ destroyTimer(timer: number): Promise&lt;void&gt;
Destroys a timer. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.MiscServices.Time
**Parameters**
......@@ -385,25 +369,25 @@ Destroys a timer. This API uses a promise to return the result.
```js
export default {
async systemTimer (){
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false
}
let timerId = await systemTimer.createTimer(options)
let triggerTime = new Date().getTime()
triggerTime += 3000
systemTimer.startTimer(timerId, triggerTime)
systemTimer.stopTimer(timerId)
try {
systemTimer.destroyTimer(timerId).then(() => {
console.info(`Succeeded in destroying timer.`);
}).catch((error) => {
console.info(`Failed to destroy timer. message:${error.message}, code:${error.code}`);
});
} catch(e) {
console.info(`Failed to destroying timer. message:${e.message}, code:${e.code}`);
}
async systemTimer (){
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false
}
let timerId = await systemTimer.createTimer(options);
let triggerTime = new Date().getTime();
triggerTime += 3000;
systemTimer.startTimer(timerId, triggerTime);
systemTimer.stopTimer(timerId);
try {
systemTimer.destroyTimer(timerId).then(() => {
console.info(`Succeeded in destroying timer.`);
}).catch((error) => {
console.info(`Failed to destroy timer. message: ${error.message}, code: ${error.code}`);
});
} catch(e) {
console.info(`Failed to destroying timer. message: ${e.message}, code: ${e.code}`);
}
}
}
```
# @ohos.taskpool (Using the Task Pool)
The task pool provides a multi-thread running environment for applications. It helps reduce resource consumption and improve system performance. It also frees you from caring about the lifecycle of thread instances. You can use the **TaskPool** APIs to create background tasks and perform operations on them, for example, executing or canceling a task. Theoretically, you can create an unlimited number of tasks, but this is not recommended for memory considerations. In addition, you are not advised performing blocking operations in a task, especially indefinite blocking. Long-time blocking operations occupy worker threads and may block other task scheduling, adversely affecting your application performance.
You can determine the execution sequence of tasks with the same priority. They are executed in the same sequence as you call the task execution APIs. The default task priority is **MEDIUM**. (The task priority mechanism is not supported yet.)
If the number of tasks to be executed is greater than the number of worker threads in the task pool, the task pool scales out based on load balancing to minimize the waiting duration. Similarly, when the number of tasks to be executed falls below the number of worker threads, the task pool scales in to reduce the number of worker threads. (The load balancing mechanism is not supported yet.)
The **TaskPool** APIs return error codes in numeric format. For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
> **NOTE**<br>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import taskpool from '@ohos.taskpool';
```
## Priority
Enumerates the priorities available for created tasks. (This enum is not supported yet.)
**System capability**: SystemCapability.Utils.Lang
| Name| Value| Description|
| -------- | -------- | -------- |
| HIGH | 0 | The task has a high priority.|
| MEDIUM | 1 | The task has a medium priority.|
| LOW | 2 | The task has a low priority.|
## Task
Implements a task. Before using any of the following APIs, you must create a **Task** instance.
### constructor
constructor(func: Function, ...args: unknown[])
A constructor used to create a **Task** instance.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | --------- | ---- | -------------------------------------------------------------------- |
| func | Function | Yes | Function to be passed in for task execution. For details about the supported return value types of the function, see [Sequenceable Data Types](#sequenceable-data-types). |
| args | unknown[] | No | Arguments of the function. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
**Error codes**
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message |
| -------- | --------------------------------------- |
| 10200014 | The function is not mark as concurrent. |
**Example**
```js
function func(args) {
"use concurrent"
console.log("func: " + args);
return args;
}
let task = new taskpool.Task(func, "this is my first Task");
```
### Attributes
**System capability**: SystemCapability.Utils.Lang
| Name | Type | Readable| Writable| Description |
| --------- | --------- | ---- | ---- | ------------------------------------------------------------------------- |
| function | Function | Yes | Yes | Function to be passed in during task creation. For details about the supported return value types of the function, see [Sequenceable Data Types](#sequenceable-data-types). |
| arguments | unknown[] | Yes | Yes | Arguments of the function. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
## taskpool.execute
execute(func: Function, ...args: unknown[]): Promise\<unknown>
Executes a task in the task pool. You must pass in a function and arguments to execute the task, and the task executed in this mode cannot be canceled.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | --------- | ---- | ---------------------------------------------------------------------- |
| func | Function | Yes | Function used to execute the task. For details about the supported return value types of the function, see [Sequenceable Data Types](#sequenceable-data-types). |
| args | unknown[] | No | Arguments of the function. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
**Return value**
| Type | Description |
| ----------------- | ------------------------------------ |
| Promise\<unknown> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message |
| -------- | ----------------------------------------- |
| 10200003 | Worker initialization failure. |
| 10200006 | Serializing an uncaught exception failed. |
| 10200014 | The function is not mark as concurrent. |
**Example**
```js
function func(args) {
"use concurrent"
console.log("func: " + args);
return args;
}
let value = taskpool.execute(func, 100);
```
## taskpool.execute
execute(task: Task, priority?: Priority): Promise\<unknown>
Executes a task in the task pool. You must pass in a created task, and the task executed in this mode can be canceled.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------------------ |
| task | [Task](#task) | Yes | Task to be executed. |
| priority | [Priority](#priority) | No | Priority of the task (not supported yet).|
**Return value**
| Type | Description |
| ---------------- | ------------------------------ |
| Promise\<unknown> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message |
| -------- | ----------------------------------------- |
| 10200003 | Worker initialization failure. |
| 10200006 | Serializing an uncaught exception failed. |
| 10200014 | The function is not mark as concurrent. |
**Example**
```js
function func(args) {
"use concurrent"
console.log("func: " + args);
return args;
}
let task = new taskpool.Task(func, "this is my first Task");
let value = taskpool.execute(task);
```
## taskpool.cancel
cancel(task: Task): void
Cancels a task in the task pool.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------------- | ---- | -------------------- |
| task | [Task](#task) | Yes | Task to cancel.|
**Error codes**
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message |
| -------- | ------------------------- |
| 10200015 | If the task is not exist. |
| 10200016 | If the task is running. |
**Example**
```js
function func(args) {
"use concurrent"
console.log("func: " + args);
return args;
}
let task = new taskpool.Task(func, "this is first Task");
let value = taskpool.execute(task);
taskpool.cancel(task);
```
## Additional Information
### Sequenceable Data Types
The following sequenceable data types are supported: All Primitive Type (excluding symbol), Date, String, RegExp, Array, Map, Set, Object, ArrayBuffer, and TypedArray.
### Precautions
A task in the task pool can reference only variables passed in by input parameters or imported variables. It does not support closure variables.
```js
// 1. Reference a variable passed in by the input parameter.
function func(args) {
"use concurrent"
console.log("func: " + args);
return args;
}
let task = new taskpool.Task(func, "create task, then execute");
let val1 = taskpool.execute(task);
let val2 = taskpool.execute(func, "execute task by func");
```
```js
// 2. Reference an imported variable.
// b.ts
export var c = 2000;
// a.ts
import { c } from './b'
function test(a) {
"use concurrent"
console.log(a);
console.log(c);
return a;
}
let task = new taskpool.Task(test, "create task, then execute");
let val1 = taskpool.execute(task);
let val2 = taskpool.execute(test, "execute task by func");
```
......@@ -35,7 +35,7 @@ Naming format:
A standard URI consists of the following parts:
[scheme:]scheme-specific-part[#fragment]
- Scheme: scheme component, which is mandatory. Example values: **http**, **https**, **ftp**, **datashare**, and **dataability**.
- scheme: scheme component. Set this parameter as required. Example values: **http**, **https**, **ftp**, **datashare**, and **dataability**.
- scheme-specific-part: specific part of the URI decoding scheme. The value consists of [//][authority][path][?query]. Set this parameter as required.
- authority: decoding authority component of the URI. The value consists of [userinfo@]host[:port]. Set this parameter as required.
- userinfo: user information. Set this parameter as required.
......@@ -226,7 +226,9 @@ Checks whether this URI is an absolute URI (whether the scheme component is defi
```js
const uriInstance = new uri.URI('https://username:password@www.qwer.com:8080?query=pppppp');
uriInstance.checkIsAbsolute();
console.log(uriInstance.checkIsAbsolute()); // true
const uriInstance1 = new uri.URI('xxx.com/suppliers.htm');
console.log(uriInstance1.checkIsAbsolute()); // false
```
......@@ -248,6 +250,7 @@ Normalizes the path of this URI.
```js
const uriInstance = new uri.URI('https://username:password@www.qwer.com:8080/path/path1/../path2/./path3?query=pppppp');
console.log(uriInstance.path); // /path/path1/../path2/./path3
let uriInstance1 = uriInstance.normalize();
uriInstance1.path;
console.log(uriInstance1.path); // /path/path2/path3
```
......@@ -87,7 +87,7 @@ paramsObject.delete('fod');
getAll(name: string): string[]
Obtains all the key-value pairs based on the specified name.
Obtains all the values based on the specified key.
**System capability**: SystemCapability.Utils.Lang
......@@ -95,13 +95,13 @@ Obtains all the key-value pairs based on the specified name.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to obtain all key-value pairs.|
| name | string | Yes| Target key.|
**Return value**
| Type| Description|
| -------- | -------- |
| string[] | Key-value pairs obtained.|
| string[] | All the values obtained.|
**Example**
......@@ -432,7 +432,7 @@ A no-argument constructor used to create a URL. It returns a **URL** object afte
**System capability**: SystemCapability.Utils.Lang
### parseURL<sup>9+</sup>
static parseURL(url : string, base?: string | URL): URL
Parses a URL.
......@@ -514,7 +514,7 @@ A constructor used to create a **URLSearchParams** instance.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>](#constructor9) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.constructor<sup>9+</sup>](#constructor9) instead.
**System capability**: SystemCapability.Utils.Lang
......@@ -542,7 +542,7 @@ Appends a key-value pair into the query string.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.append<sup>9+</sup>](#append9) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.append<sup>9+</sup>](#append9) instead.
**System capability**: SystemCapability.Utils.Lang
......@@ -569,7 +569,7 @@ Deletes key-value pairs of the specified key.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.delete<sup>9+</sup>](#delete9) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.delete<sup>9+</sup>](#delete9) instead.
**System capability**: SystemCapability.Utils.Lang
......@@ -595,7 +595,7 @@ Obtains all the key-value pairs based on the specified key.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.getAll<sup>9+</sup>](#getall9) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.getAll<sup>9+</sup>](#getall9) instead.
**System capability**: SystemCapability.Utils.Lang
......@@ -603,7 +603,7 @@ Obtains all the key-value pairs based on the specified key.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to obtain all key-value pairs.|
| name | string | Yes| Target key.|
**Return value**
......@@ -628,7 +628,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.entries<sup>9+</sup>](#entries9) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.entries<sup>9+</sup>](#entries9) instead.
**System capability**: SystemCapability.Utils.Lang
......@@ -656,7 +656,7 @@ Traverses the key-value pairs in the **URLSearchParams** instance by using a cal
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.forEach<sup>9+</sup>](#foreach9) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.forEach<sup>9+</sup>](#foreach9) instead.
**System capability**: SystemCapability.Utils.Lang
......@@ -693,7 +693,7 @@ Obtains the value of the first key-value pair based on the specified key.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.get<sup>9+</sup>](#get9) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.get<sup>9+</sup>](#get9) instead.
**System capability**: SystemCapability.Utils.Lang
......@@ -727,7 +727,7 @@ Checks whether a key has a value.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.has<sup>9+</sup>](#has9) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.has<sup>9+</sup>](#has9) instead.
**System capability**: SystemCapability.Utils.Lang
......@@ -760,7 +760,7 @@ Sets the value for a key. If key-value pairs matching the specified key exist, t
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.set<sup>9+</sup>](#set9) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.set<sup>9+</sup>](#set9) instead.
**System capability**: SystemCapability.Utils.Lang
......@@ -788,7 +788,7 @@ Sorts all key-value pairs contained in this object based on the Unicode code poi
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.sort<sup>9+</sup>](#sort9) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.sort<sup>9+</sup>](#sort9) instead.
**System capability**: SystemCapability.Utils.Lang
......@@ -809,7 +809,7 @@ Obtains an ES6 iterator that contains the keys of all the key-value pairs.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.keys<sup>9+</sup>](#keys9) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.keys<sup>9+</sup>](#keys9) instead.
**System capability**: SystemCapability.Utils.Lang
......@@ -837,7 +837,7 @@ Obtains an ES6 iterator that contains the values of all the key-value pairs.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams<sup>9+</sup>.values<sup>9+</sup>](#values9) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.values<sup>9+</sup>](#values9) instead.
**System capability**: SystemCapability.Utils.Lang
......@@ -865,7 +865,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [Symbol.iterator]<sup>9+</sup>](#symboliterator9) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.[Symbol.iterator]<sup>9+</sup>](#symboliterator9) instead.
**System capability**: SystemCapability.Utils.Lang
......@@ -892,7 +892,7 @@ Obtains search parameters that are serialized as a string and, if necessary, per
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tostring<sup>9+</sup>](#tostring9) instead.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [URLParams.tostring<sup>9+</sup>](#tostring9) instead.
**System capability**: SystemCapability.Utils.Lang
......
# @ohos.wantAgent
# @ohos.wantAgent (wantAgent)
The **WantAgent** module provides APIs for creating and comparing **WantAgent** objects, and obtaining the user ID and bundle name of a **WantAgent** object.
......
......@@ -107,7 +107,7 @@ In the FA model:
"buildOption": {
"sourceOption": {
"workers": [
"./src/main/ets/entryability/workers/worker.ts"
"./src/main/ets/MainAbility/workers/worker.ts"
]
}
}
......@@ -1192,7 +1192,7 @@ In the FA model:
"buildOption": {
"sourceOption": {
"workers": [
"./src/main/ets/entryability/workers/worker.ts"
"./src/main/ets/MainAbility/workers/worker.ts"
]
}
}
......@@ -2114,7 +2114,7 @@ Configuration of the **build-profile.json5** file:
"buildOption": {
"sourceOption": {
"workers": [
"./src/main/ets/entryability/workers/worker.ts"
"./src/main/ets/MainAbility/workers/worker.ts"
]
}
}
......
......@@ -24,7 +24,7 @@ DataPanel(options:{values: number[], max?: number, type?: DataPanelType})
| ----------------- | -------- | ----- | -------- |
| values | number[] | Yes | Data value list. A maximum of nine values are supported. If more than nine values are set, only the first nine ones are used. If the value is less than 0, the value 0 is used.|
| max | number | No | - When set to a value greater than 0, this parameter indicates the maximum value in the **values** list.<br>- When set to a value equal to or smaller than 0, this parameter indicates the sum of values in the **values** list. The values are displayed in proportion.<br>Default value: **100**|
| type<sup>8+</sup> | [DataPanelType](#datapaneltype) | No| Type of the data panel.<br>Default value: **DataPanelType.Circle**|
| type<sup>8+</sup> | [DataPanelType](#datapaneltype) | No| Type of the data panel (dynamic modification is not supported).<br>Default value: **DataPanelType.Circle**|
## DataPanelType
......
......@@ -21,7 +21,7 @@ ScrollBar(value: { scroller: Scroller, direction?: ScrollBarDirection, state?: B
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| scroller | [Scroller](ts-container-scroll.md#scroller) | Yes| Scroller, which can be bound to scrollable components.|
| direction | ScrollBarDirection | No| Scrollbar direction in which scrollable components scroll.<br>Default value: **ScrollBarDirection.Vertical**|
| direction | [ScrollBarDirection](#scrollbardirection) | No| Scrollbar direction in which scrollable components scroll.<br>Default value: **ScrollBarDirection.Vertical**|
| state | [BarState](ts-appendix-enums.md#barstate) | No| Scrollbar state.<br>Default value: **BarState.Auto**|
> **NOTE**
......
......@@ -35,9 +35,9 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| selectedBackgroundColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of the selected item.<br>Default value: **0x1F0A59F7** |
| popupBackground | [ResourceColor](ts-types.md#resourcecolor) | Background color of the pop-up text.<br>Default value: **0xFFF1F3F5** |
| usingPopup | boolean | Whether to use pop-up text.<br>Default value: **false** |
| selectedFont | [Font](ts-types.md#font) | Font style of the selected text.<br>Default value:<br>{<br>fontSize:10,<br> fontStyle:FontStyle.Normal,<br> fontWeight:FontWeight.Normal,<br> fontFamily:HarmonyOS Sans<br>} |
| popupFont | [Font](ts-types.md#font) | Font style of the pop-up text.<br>Default value:<br>{<br>fontSize:10,<br> fontStyle:FontStyle.Normal,<br> fontWeight:FontWeight.Normal,<br> fontFamily:HarmonyOS Sans<br>} |
| font | [Font](ts-types.md#font) | Default font style of the alphabetic index bar.<br>Default value:<br>{<br>fontSize:10,<br> fontStyle:FontStyle.Normal,<br> fontWeight:FontWeight.Normal,<br> fontFamily:HarmonyOS Sans<br>} |
| selectedFont | [Font](ts-types.md#font) | Font style of the selected text.<br>Default value:<br>{<br>size:10,<br> style:FontStyle.Normal,<br> weight:FontWeight.Normal,<br> family:'HarmonyOS Sans'<br>} |
| popupFont | [Font](ts-types.md#font) | Font style of the pop-up text.<br>Default value:<br>{<br>size:10,<br> style:FontStyle.Normal,<br> weight:FontWeight.Normal,<br> family:'HarmonyOS Sans'<br>} |
| font | [Font](ts-types.md#font) | Default font style of the alphabetic index bar.<br>Default value:<br>{<br>size:10,<br> style:FontStyle.Normal,<br> weight:FontWeight.Normal,<br> family:'HarmonyOS Sans'<br>} |
| itemSize | string \| number | Size of an item in the alphabetic index bar. The item is a square, and the side length needs to be set. This attribute cannot be set to a percentage.<br>Default value: **24.0** |
| alignStyle | IndexerAlign | Alignment style of the alphabetic index bar. Left alignment and right alignment are supported.<br>Default value: **IndexerAlign.Right**|
| selected | number | Index of the selected item.<br>Default value: **0**|
......
......@@ -33,6 +33,8 @@
- Security
- [Ability Access Control Error Codes](errorcode-access-token.md)
- [HUKS Error Codes](errorcode-huks.md)
- [Crypto Framework Error Codes](errorcode-crypto-framework.md)
- [Certificate Error Codes](errorcode-cert.md)
- [User Authentication Error Codes](errorcode-useriam.md)
- Data Management
- [RDB Error Codes](errorcode-data-rdb.md)
......@@ -55,6 +57,7 @@
- [HiDebug Error Codes](errorcode-hiviewdfx-hidebug.md)
- [Input Method Framework Error Codes](errorcode-inputmethod-framework.md)
- [Pasteboard Error Codes](errorcode-pasteboard.md)
- [Time and Time Zone Service Error Codes](errorcode-time.md)
- [Webview Error Codes](errorcode-webview.md)
- Account Management
- [Account Error Codes](errorcode-account.md)
......
# Time and Time Zone Service Error Codes
## -1 Screen Unlock Error
**Error Message**
The parameter check failed or permission denied or system error.
**Description**
This error code is reported when a parameter check failure, permission verification failure, or system operation error occurs.
**Possible Cause**
1. The input parameter is invalid.
2. The required permission is not configured. For example, **ohos.permission.SET_TIME** is not configured for setting the time or **ohos.permission.SET_TIME_ZONE** is not configured for setting the time zone.
3. The system is not running properly due to a common kernel error, such as a memory allocation and multi-thread processing error.
**Solution**
1. Make sure input parameters are passed in as required.
2. Configure the **ohos.permission.SET_TIME** permission for setting the time and the **ohos.permission.SET_TIME_ZONE** permission for setting the time zone.
3. Make sure the memory is sufficient.
......@@ -52,7 +52,7 @@ You can create a subwindow, such as a dialog box, and set its properties.
let windowClass = null;
// Method 1: Create a subwindow.
let config = {name: "subWindow", windowType: window.WindowType.TYPE_APP, ctx: this.context};
let config = {name: "subWindow", windowType: window.WindowType.TYPE_APP};
window.createWindow(config, (err, data) => {
if (err.code) {
console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
......
......@@ -390,4 +390,3 @@ A floating window is created based on an existing task. It is always displayed i
};
```
<!--no_check-->
\ No newline at end of file
......@@ -476,7 +476,7 @@ Check whether xDevice runs properly.
The COM port whose **type** is **cmd** corresponds to the AT command serial port on the board. The port is used to send commands to the device. In the example, the **ChA(COM20)** serial port is used.
<img src="figures/L0-1.PNG" alt="L0-1" style="zoom:67%;" />
![L0-1](figures/L0-1.PNG)
IP camera devices have two connection modes. One is to connect through the local serial port, and the other is to connect through the IP address of the local area network.
......@@ -492,7 +492,7 @@ Check whether xDevice runs properly.
Add an NFS sharing path, for example, **D:\HS\NFS_Share_File -public –alldirs**. Note that the FTP IP address 192.168.1.10 is the IP address of the development board.
<img src="figures/NFS-2.PNG" style="zoom:75%;" />
![](figures/NFS-2.PNG)
3. Stop the NFS server and restart the NFS server to make the added sharing path take effect.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册