| callback | AsyncCallback<boolean> | 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).
| Promise<boolean> | 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).
| callback | AsyncCallback<boolean> | 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).
| Promise<boolean> | 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).
| 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).
# @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.
The **systemTime** 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.
...
...
@@ -29,6 +29,14 @@ Sets the system time. This API uses an asynchronous callback to return the resul
| time | number | Yes | Timestamp to set, in milliseconds. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Time and Time Zone Service Error Codes](../errorcodes/errorcode-time.md).
Obtains the time elapsed since the Unix epoch. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [systemDateTime.getCurrentTime](./js-apis-system-date-time.md#systemdatetimegetcurrenttime).
Obtains the time elapsed since the Unix epoch. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [systemDateTime.getCurrentTime](./js-apis-system-date-time.md#systemdatetimegetcurrenttime-1).
Obtains the time elapsed since the Unix epoch. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [systemDateTime.getCurrentTime](./js-apis-system-date-time.md#systemdatetimegetcurrenttime-2).
Obtains the time elapsed since system startup, excluding the deep sleep time. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [systemDateTime.getRealActiveTime](./js-apis-system-date-time.md#systemdatetimegetrealactivetime).
Obtains the time elapsed since system startup, excluding the deep sleep time. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [systemDateTime.getRealActiveTime](./js-apis-system-date-time.md#systemdatetimegetrealactivetime-1).
Obtains the time elapsed since system startup, excluding the deep sleep time. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [systemDateTime.getRealActiveTime](./js-apis-system-date-time.md#systemdatetimegetrealactivetime-2).
Obtains the time elapsed since system startup, including the deep sleep time. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [systemDateTime.getRealTime](./js-apis-system-date-time.md#systemdatetimegetrealtime).
Obtains the time elapsed since system startup, including the deep sleep time. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [systemDateTime.getRealTime](./js-apis-system-date-time.md#systemdatetimegetrealtime-1).
Obtains the time elapsed since system startup, including the deep sleep time. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [systemDateTime.getRealTime](./js-apis-system-date-time.md#systemdatetimegetrealtime-2).
Obtains the current system date. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [systemDateTime.getDate](./js-apis-system-date-time.md#systemdatetimegetdate).
| -1 | The parameter check failed or system error. |
**Example**
```js
try{
systemTime.getDate((error,date)=>{
if(error){
console.info(`Failed to get date. message:${error.message}, code:${error.code}`);
console.info(`Failed to get date. message: ${error.message}, code: ${error.code}`);
return;
}
console.info(`Succeeded in get date : ${date}`);;
});
}catch(e){
console.info(`Failed to get date. message:${e.message}, code:${e.code}`);
console.info(`Failed to get date. message: ${e.message}, code: ${e.code}`);
}
```
## systemTime.getDate<sup>(deprecated)</sup>
## systemTime.getDate<sup>8+</sup>
getDate(): Promise<Date>
Obtains the current system date. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [systemDateTime.getDate](./js-apis-system-date-time.md#systemdatetimegetdate-1).
Obtains the system time zone. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [systemDateTime.getTimezone](./js-apis-system-date-time.md#systemdatetimegettimezone).
| callback | AsyncCallback<string> | Yes | Callback used to return the system time zone. For details, see [Supported System Time Zones](#supported-system-time-zones).|
**Error codes**
For details about the error codes, see [Time and Time Zone Service Error Codes](../errorcodes/errorcode-time.md).
| -1 | The parameter check failed or system error. |
**Example**
```js
try{
systemTime.getTimezone((error,data)=>{
if(error){
console.info(`Failed to get timezone. message:${error.message}, code:${error.code}`);
console.info(`Failed to get timezone. message: ${error.message}, code: ${error.code}`);
return;
}
console.info(`Succeeded in get timezone : ${data}`);;
});
}catch(e){
console.info(`Failed to get timezone. message:${e.message}, code:${e.code}`);
console.info(`Failed to get timezone. message: ${e.message}, code: ${e.code}`);
}
```
## systemTime.getTimezone<sup>(deprecated)</sup>
## systemTime.getTimezone<sup>8+</sup>
getTimezone(): Promise<string>
Obtains the system time zone. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [systemDateTime.getTimezone](./js-apis-system-date-time.md#systemdatetimegettimezone-1).
| top | boolean | Yes | Whether to jump to the top of the page. The value **true** means to jump to the top of the page; and **false** means to scroll the page up by half the view port.|
**Error codes**
For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
| bottom | boolean | Yes | Whether to jump to the bottom of the page. The value **true** means to jump to the bottom of the page; and **false** means to scroll the page down by half the view port.|
**Error codes**
For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
@@ -4082,6 +4296,10 @@ Stores this web page. This API uses a promise to return the result.
Implements a **GeolocationPermissions** object.
### Required Permissions
**ohos.permission.LOCATION**, **ohos.permission.APPROXIMATELY_LOCATION**, and **ohos.permission.LOCATION_IN_BACKGROUND**, which are required for accessing the location information. For details about the permissions, see [@ohos.geolocation (Geolocation)](./js-apis-geolocation.md).
### allowGeolocation
static allowGeolocation(origin: string): void
...
...
@@ -4469,6 +4687,8 @@ Provides the element information of the area being clicked. For details about th
Describes the data types supported for [WebMessagePort](#webmessageport).
| currentIndex | number | Yes | No | Index of the current page in the page history stack.|
| size | number | Yes | No | Number of indexes in the history stack. The maximum value is 50. If this value is exceeded, the earliest index will be overwritten.|
| boolean | If the callback returns **false**, the default dialog box is displayed. If the callback returns **true**, a system application can use the system dialog box (allows the confirm and cancel operations) and invoke the **JsResult** API to notify the **\<Web>** component of the user's operation.|
| boolean | If the callback returns **true**, the application can use the system dialog box (allows the confirm and cancel operations) and invoke the **JsResult** API to instruct the **\<Web>** component to exit the current page based on the user operation. If the callback returns **false**, the **\<Web>** component cannot trigger the system dialog box.|
**Example**
...
...
@@ -1277,7 +1277,7 @@ Triggered when **alert()** is invoked to display an alert dialog box on the web
Triggered when this page is about to exit after the user refreshes or closes the page. This callback is triggered only when the page has obtained focus.
Called when this page is about to exit after the user refreshes or closes the page. This API takes effect only when the page has obtained focus.
**Parameters**
...
...
@@ -1291,7 +1291,7 @@ Triggered when this page is about to exit after the user refreshes or closes the
| boolean | If the callback returns **false**, the default dialog box is displayed. If the callback returns **true**, a system application can use the system dialog box (allows the confirm and cancel operations) and invoke the **JsResult** API to notify the **\<Web>** component of the user's operation.|
| boolean | If the callback returns **true**, the application can use the system dialog box (allows the confirm and cancel operations) and invoke the **JsResult** API to instruct the **\<Web>** component to exit the current page based on the user operation. If the callback returns **false**, the **\<Web>** component cannot trigger the system dialog box.|
**Example**
...
...
@@ -1338,7 +1338,7 @@ Triggered when this page is about to exit after the user refreshes or closes the
| boolean | If the callback returns **false**, the default dialog box is displayed. If the callback returns **true**, a system application can use the system dialog box (allows the confirm and cancel operations) and invoke the **JsResult** API to notify the **\<Web>** component of the user's operation.|
| boolean | If the callback returns **true**, the application can use the system dialog box (allows the confirm and cancel operations) and invoke the **JsResult** API to instruct the **\<Web>** component to exit the current page based on the user operation. If the callback returns **false**, the **\<Web>** component cannot trigger the system dialog box.|
| boolean | If the callback returns **false**, the default dialog box is displayed. If the callback returns **true**, a system application can use the system dialog box (allows the confirm and cancel operations) and invoke the **JsResult** API to notify the **\<Web>** component of the user's operation.|
| boolean | If the callback returns **true**, the application can use the system dialog box (allows the confirm and cancel operations) and invoke the **JsResult** API to instruct the **\<Web>** component to exit the current page based on the user operation. If the callback returns **false**, the **\<Web>** component cannot trigger the system dialog box.|
| boolean | The value **true** means that the pop-up window provided by the system is displayed. The value **false** means that the default web pop-up window is displayed.|
| boolean | The value **true** means that the pop-up window provided by the system is displayed. If the callback returns **false**, the **\<Web>** component cannot trigger the system dialog box.|
**Example**
...
...
@@ -1885,7 +1885,7 @@ Triggered to process an HTML form whose input type is **file**, in response to t
@@ -2398,7 +2398,7 @@ Registers a callback for receiving a request to obtain the geolocation informati
onGeolocationHide(callback: () => void)
Triggered to notify the user that the request for obtaining the geolocation information received when **[onGeolocationShow](#ongeolocationshow)** is called has been canceled.
Called to notify the user that the request for obtaining the geolocation information received when **[onGeolocationShow](#ongeolocationshow)** is called has been canceled.
**Parameters**
...
...
@@ -2430,7 +2430,7 @@ Triggered to notify the user that the request for obtaining the geolocation info
@@ -5466,6 +5466,103 @@ Enumerates the error codes returned by **onSslErrorEventReceive** API.
| On | The web dark mode is enabled. |
| Auto | The web dark mode setting follows the system settings. |
## WebAsyncController
Implements a **WebAsyncController** object, which can be used to control the behavior of a **\<Web>** component with asynchronous callbacks. A **WebAsyncController **object controls one **\<Web>** component.
### Creating an Object
```
webController: WebController = new WebController();
webAsyncController: WebAsyncController = new WebAsyncController(webController);
| baseName | string | Yes | Save path. The value cannot be null. |
| autoName | boolean | Yes | Whether to automatically generate a file name.<br/>The value **false** means not to automatically generate a file name.<br/>The value **true** means to automatically generate a file name based on the URL of current page and the **baseName** value. In this case, **baseName** is regarded as a directory. |
| callback | AsyncCallback\<string> | Yes | Callback used to return the save path if the operation is successful and null otherwise. |
| baseName | string | Yes | Save path. The value cannot be null. |
| autoName | boolean | Yes | Whether to automatically generate a file name.<br>The value **false** means not to automatically generate a file name.<br>The value **true** means to automatically generate a file name based on the URL of current page and the **baseName** value. In this case, **baseName** is regarded as a directory. |
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.