diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 37bf36f22b5089789f6315e37a18947918501ff4..95713286ff3115e23e4733f63e84d77d3fecdc94 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -86,8 +86,10 @@ - [AppStateData](js-apis-inner-application-appStateData.md) - [BaseContext](js-apis-inner-application-baseContext.md) - [Context](js-apis-inner-application-context.md) + - [ContinuableInfo](js-apis-inner-application-continuableInfo.md) - [ContinueCallback](js-apis-inner-application-continueCallback.md) - [ContinueDeviceInfo](js-apis-inner-application-continueDeviceInfo.md) + - [ContinueMissionInfo](js-apis-inner-application-continueMissionInfo.md) - [ErrorObserver](js-apis-inner-application-errorObserver.md) - [ExtensionContext](js-apis-inner-application-extensionContext.md) - [ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md) @@ -194,8 +196,7 @@ - [@ohos.router (Page Routing)](js-apis-router.md) - [@ohos.measure (Text Measurement)](js-apis-measure.md) - [@ohos.uiAppearance (UI Appearance)](js-apis-uiappearance.md) - -- Graphics +- Graphics - [@ohos.animation.windowAnimationManager (Window Animation Management)](js-apis-windowAnimationManager.md) - [@ohos.application.WindowExtensionAbility (WindowExtensionAbility)](js-apis-application-windowExtensionAbility.md) - [@ohos.display (Display)](js-apis-display.md) @@ -207,7 +208,6 @@ - webgl - [WebGL](js-apis-webgl.md) - [WebGL2](js-apis-webgl2.md) - - Multimedia - [@ohos.multimedia.audio (Audio Management)](js-apis-audio.md) - [@ohos.multimedia.avsession (AVSession Management)](js-apis-avsession.md) @@ -347,6 +347,7 @@ - [@ohos.brightness (Screen Brightness)](js-apis-brightness.md) - [@ohos.charger (Charging Type)](js-apis-charger.md) - [@ohos.cooperate (Screen Hopping)](js-apis-devicestatus-cooperate.md) + - [@ohos.deviceAttest (Device Attestation)](js-apis-deviceAttest.md) - [@ohos.deviceInfo (Device Information)](js-apis-device-info.md) - [@ohos.distributedHardware.deviceManager (Device Management)](js-apis-device-manager.md) - [@ohos.geoLocationManager (Geolocation Manager)](js-apis-geoLocationManager.md) @@ -356,6 +357,7 @@ - [@ohos.multimodalInput.inputEvent (Input Event)](js-apis-inputevent.md) - [@ohos.multimodalInput.inputEventClient (Key Event Injection)](js-apis-inputeventclient.md) - [@ohos.multimodalInput.inputMonitor (Input Monitor)](js-apis-inputmonitor.md) + - [@ohos.multimodalInput.intentionCode (Intention Code)](js-apis-intentioncode.md) - [@ohos.multimodalInput.keyCode (Key Code)](js-apis-keycode.md) - [@ohos.multimodalInput.keyEvent (Key Event)](js-apis-keyevent.md) - [@ohos.multimodalInput.mouseEvent (Mouse Event)](js-apis-mouseevent.md) @@ -364,6 +366,7 @@ - [@ohos.multimodalInput.shortKey (Shortcut Key)](js-apis-shortKey.md) - [@ohos.power (System Power Management)](js-apis-power.md) - [@ohos.runningLock (Runninglock)](js-apis-runninglock.md) + - [@ohos.resourceschedule.deviceStandby (Device Standby)](js-apis-resourceschedule-deviceStandby.md) - [@ohos.sensor (Sensor)](js-apis-sensor.md) - [@ohos.settings (Data Item Settings)](js-apis-settings.md) - [@ohos.stationary (Device Status Awareness Framework)](js-apis-stationary.md) @@ -378,7 +381,7 @@ - [@ohos.account.appAccount (App Account Management)](js-apis-appAccount.md) - [@ohos.account.distributedAccount (Distributed Account Management)](js-apis-distributed-account.md) - [@ohos.account.osAccount (OS Account Management)](js-apis-osAccount.md) - + - Customization - [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md) @@ -421,7 +424,6 @@ - Test - [@ohos.application.testRunner (TestRunner)](js-apis-application-testRunner.md) - - [@ohos.deviceAttest (Device Attestation)](js-apis-deviceAttest.md) - [@ohos.uitest (UiTest)](js-apis-uitest.md) - APIs No Longer Maintained diff --git a/en/application-dev/reference/apis/js-apis-reminderAgent.md b/en/application-dev/reference/apis/js-apis-reminderAgent.md index 0c7fa19432c45e801f82b2892d47fa9ed384ea4e..a817d3bc82a541c9937c05aec30b2ecd0bb830ff 100644 --- a/en/application-dev/reference/apis/js-apis-reminderAgent.md +++ b/en/application-dev/reference/apis/js-apis-reminderAgent.md @@ -371,7 +371,7 @@ reminderAgent.addNotificationSlot(mySlot).then(() => { ## reminderAgent.removeNotificationSlot(deprecated) -removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback): void +removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\): void Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result. @@ -401,7 +401,7 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, ## reminderAgent.removeNotificationSlot(deprecated) -removeNotificationSlot(slotType: notification.SlotType): Promise +removeNotificationSlot(slotType: notification.SlotType): Promise\ Removes a notification slot of a specified type. This API uses a promise to return the result. diff --git a/en/application-dev/reference/apis/js-apis-reminderAgentManager.md b/en/application-dev/reference/apis/js-apis-reminderAgentManager.md index 87a8ea3167b1cc125eb8e2bf5e30b4cfe54cc5a3..644759435975c722de9fd274b704ecd01804d2fd 100644 --- a/en/application-dev/reference/apis/js-apis-reminderAgentManager.md +++ b/en/application-dev/reference/apis/js-apis-reminderAgentManager.md @@ -611,7 +611,7 @@ Defines the reminder to publish. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.| -| actionButton10+ | [ActionButton](#actionbutton) | No| Button displayed for the reminder in the notification panel. For common applications, a maximum of two buttons are supported. For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions.| +| actionButton | [ActionButton](#actionbutton) | No| Buttons displayed for the reminder in the notification panel.
- For common applications, a maximum of two buttons are supported.
- For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions.| | wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the reminder is clicked.| | maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is automatically started when the reminder arrives. If the device is in use, a notification will be displayed.| | ringDuration | number | No| Ringing duration, in seconds. The default value is **1**.| diff --git a/en/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md b/en/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md new file mode 100644 index 0000000000000000000000000000000000000000..116d4af987fb061f516d6ec37053794737f65c84 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md @@ -0,0 +1,382 @@ +# @ohos.resourceschedule.deviceStandby (Device Standby) +A device enters standby mode if it is unused for a long period of time or after the Power button is pressed. The standby mode prolongs the battery life without affecting the use of applications. The **deviceStandby** module provides APIs for you to check whether a device is in standby mode and request or cancel standby resource control for an application. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```js +import deviceStandby from '@ohos.resourceschedule.deviceStandby'; +``` + +## deviceStandby.isDeviceInStandby + +isDeviceInStandby(callback: AsyncCallback<boolean>): void; + +Checks whether the device is in standby mode. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the device is standby mode.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +try{ +deviceStandby.isDeviceInStandby((err, res) => { + if (err) { + console.log('DEVICE_STANDBY isDeviceInStandby callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('DEVICE_STANDBY isDeviceInStandby callback succeeded, result: ' + JSON.stringify(res)); + } + }); +} catch(error) { +console.log('DEVICE_STANDBY isDeviceInStandby throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.isDeviceInStandby + +isDeviceInStandby(): Promise<boolean> + +Checks whether the device is in standby mode. This API uses a promise to return the result. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**Return value** + +| Type | Description | +| --------------------- | ---------------------------------------- | +| Promise<boolean> | Promise used to return whether the device is in standby mode.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +try{ +deviceStandby.isDeviceInStandby().then( res => { + console.log('DEVICE_STANDBY isDeviceInStandby promise succeeded, result: ' + JSON.stringify(res)); +}).catch( err => { + console.log('DEVICE_STANDBY isDeviceInStandby promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); +} catch (error) { +console.log('DEVICE_STANDBY isDeviceInStandby throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.getExemptedApps + +getExemptedApps(resourceTypes: number, callback: AsyncCallback): void; + +Obtains the list of applications that can still use resources of the specified types when the device is in standby mode. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| [ResourceTypes](#resourcetype)|number | Yes | Types of resources that can be used.| +| callback | AsyncCallback | Yes |Callback used to return the exempted application information.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +try{ +deviceStandby.getExemptedApps(resourceTypes, (err, res) => { + if (err) { + console.log('DEVICE_STANDBY getExemptedApps callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('DEVICE_STANDBY getExemptedApps callback success.'); + for (let i = 0; i < res.length; i++) { + console.log('DEVICE_STANDBY getExemptedApps callback result ' + JSON.stringify(res[i])); + } + } +}); +} catch (error) { +console.log('DEVICE_STANDBY getExemptedApps throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.getExemptedApps + +getExemptedApps(resourceTypes: number): Promise; + +Obtains the list of applications that can still use resources of the specified type when the device is in standby mode. This API uses a promise to return the result. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| [ResourceTypes](#resourcetype)|number | Yes |Types of resources that can be used.| + +**Return value** + +| Type | Description | +| --------------------- | ---------------------------------------- | +| Promise | Promise used to return the exempted application information.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 201 | Permission denied. | +| 202 | Not System App. | +| 401 | Parameter error. | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +try{ +deviceStandby.getExemptedApps(resourceTypes).then( res => { + console.log('DEVICE_STANDBY getExemptedApps promise success.'); + for (let i = 0; i < res.length; i++) { + console.log('DEVICE_STANDBY getExemptedApps promise result ' + JSON.stringify(res[i])); + } +}).catch( err => { + console.log('DEVICE_STANDBY getExemptedApps promise failed. code is: ' + err.code + ',message is: ' + err.message); +}); +} catch (error) { +console.log('DEVICE_STANDBY getExemptedApps throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.requestExemptionResource + +requestExemptionResource(request: ResourceRequest): void; + +Requests exemption, so that the application can use restricted resources when the device is in standby mode. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby.Exemption + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| request |[ResourceRequest](#resourcerequest)| Yes | Request body.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +let resRequest = { + resourceTypes: 1, + uid:10003, + name:"com.example.app", + duration:10, + reason:"apply", +}; +// Promise mode +try{ +deviceStandby.requestExemptionResource(resRequest).then( () => { + console.log('DEVICE_STANDBY requestExemptionResource promise succeeded.'); +}).catch( err => { + console.log('DEVICE_STANDBY requestExemptionResource promise failed. code is: ' + err.code + ',message is: ' + err.message); +}); +} catch (error) { +console.log('DEVICE_STANDBY requestExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message); +} + +// Asynchronous callback mode +try{ +deviceStandby.requestExemptionResource(resRequest, (err) => { + if (err) { + console.log('DEVICE_STANDBY requestExemptionResource callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('DEVICE_STANDBY requestExemptionResource callback succeeded.'); + } +}); +} catch (error) { +console.log('DEVICE_STANDBY requestExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.releaseExemptionResource + +releaseExemptionResource(request: ResourceRequest): void; + +Cancels exemption for the application. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby.Exemption + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| request |[ResourceRequest](#resourcerequest)| Yes | Request body.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +let resRequest = { + resourceTypes: 1, + uid:10003, + name:"com.demo.app", + duration:10, + reason:"unapply", +}; +// Promise mode +try{ +deviceStandby.releaseExemptionResource(resRequest).then( () => { + console.log('DEVICE_STANDBY releaseExemptionResource promise succeeded.'); +}).catch( err => { + console.log('DEVICE_STANDBY releaseExemptionResource promise failed. code is: ' + err.code + ',message is: ' + err.message); +}); +} catch (error) { +console.log('DEVICE_STANDBY releaseExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message); +} + +// Asynchronous callback mode +try{ +deviceStandby.releaseExemptionResource(resRequest, (err) => { + if (err) { + console.log('DEVICE_STANDBY releaseExemptionResource callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('DEVICE_STANDBY releaseExemptionResource callback succeeded.'); + } +}); +} catch (error) { +console.log('DEVICE_STANDBY releaseExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## ResourceType + +Enumerates the types of resources that can be used by exempted applications. + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +|Name |Value |Description| +| ------------ | ------------ |--------------| +|NETWORK |1 |Network access resource.| +|RUNNING_LOCK |2 |CPU running lock resource.| +|TIMER |4 | Timer task resource.| +|WORK_SCHEDULER |8 | Work task resource.| +|AUTO_SYNC |16 | Automatic synchronization resource.| +|PUSH |32 | Push kit resource.| +|FREEZE |64 | Freezing application resource.| + +## ExemptedAppInfo + +Defines the information about an exempted application. + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +|Name |Type | Mandatory |Description | +| ------------ | ------------ |------------ | ------------ | +|[resourceTypes](#resourcetype) | number | Yes |Types of resources that can be used. | +|name |string | Yes | Name of the application. | +|duration | number | Yes | Exemption duration.| + +## ResourceRequest + +Defines the message used to request to be an exempted application. + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +|Name |Type | Mandatory |Description | +| ------------ | ------------ |------------| ------------ | +|[resourceTypes](#resourcetype) | number | Yes |Types of resources that can be used. | +|uid | number | Yes |UID of the application. | +|name |string | Yes | Name of the application. | +|duration | number | Yes | Exemption duration.| +|reason |string | Yes | Reason for the request. |