1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit BackgroundTasksKit 19 */ 20 21import { AsyncCallback, Callback } from './@ohos.base'; 22import { WantAgent } from './@ohos.wantAgent'; 23import Context from './application/BaseContext'; 24import type notificationManager from './@ohos.notificationManager'; 25 26/** 27 * Manages background tasks. 28 * 29 * @namespace backgroundTaskManager 30 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.Core 31 * @since 9 32 */ 33/** 34 * Manages background tasks. 35 * 36 * @namespace backgroundTaskManager 37 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.Core 38 * @atomicservice 39 * @since 12 40 */ 41declare namespace backgroundTaskManager { 42 /** 43 * The info of delay suspend. 44 * 45 * @interface DelaySuspendInfo 46 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 47 * @since 9 48 */ 49 interface DelaySuspendInfo { 50 /** 51 * The unique identifier of the delay request. 52 * 53 * @type { number } 54 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 55 * @since 9 56 */ 57 requestId: number; 58 /** 59 * The actual delay duration (ms). 60 * 61 * @type { number } 62 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 63 * @since 9 64 */ 65 actualDelayTime: number; 66 } 67 68 /** 69 * The info of continuous task notification. 70 * 71 * @interface ContinuousTaskNotification 72 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 73 * @atomicservice 74 * @since 12 75 */ 76 interface ContinuousTaskNotification { 77 /** 78 * The notification slot type. 79 * 80 * @type { notificationManager.SlotType } 81 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 82 * @atomicservice 83 * @since 12 84 */ 85 slotType: notificationManager.SlotType; 86 /** 87 * The notification content type. 88 * 89 * @type { notificationManager.ContentType } 90 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 91 * @atomicservice 92 * @since 12 93 */ 94 contentType: notificationManager.ContentType; 95 /** 96 * The notification id. 97 * 98 * @type { number } 99 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 100 * @atomicservice 101 * @since 12 102 */ 103 notificationId: number; 104 } 105 106 /** 107 * Cancels delayed transition to the suspended state. 108 * 109 * @param { number } requestId - The identifier of the delay request. 110 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 111 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 112 * @throws { BusinessError } 9800001 - Memory operation failed. 113 * @throws { BusinessError } 9800002 - Parcel operation failed. 114 * @throws { BusinessError } 9800003 - Internal transaction failed. 115 * @throws { BusinessError } 9800004 - System service operation failed. 116 * @throws { BusinessError } 9900001 - Caller information verification failed for a transient task. 117 * @throws { BusinessError } 9900002 - Transient task verification failed. 118 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 119 * @since 9 120 */ 121 function cancelSuspendDelay(requestId: number): void; 122 123 /** 124 * Obtains the remaining time before an application enters the suspended state. 125 * 126 * @param { number } requestId - The identifier of the delay request. 127 * @param { AsyncCallback<number> } callback - The callback of the remaining delay time. 128 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 129 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 130 * @throws { BusinessError } 9800001 - Memory operation failed. 131 * @throws { BusinessError } 9800002 - Parcel operation failed. 132 * @throws { BusinessError } 9800003 - Internal transaction failed. 133 * @throws { BusinessError } 9800004 - System service operation failed. 134 * @throws { BusinessError } 9900001 - Caller information verification failed for a transient task. 135 * @throws { BusinessError } 9900002 - Transient task verification failed. 136 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 137 * @since 9 138 */ 139 function getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>): void; 140 141 /** 142 * Obtains the remaining time before an application enters the suspended state. 143 * 144 * @param { number } requestId - The identifier of the delay request. 145 * @returns { Promise<number> } The promise returns the remaining delay time. 146 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 147 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 148 * @throws { BusinessError } 9800001 - Memory operation failed. 149 * @throws { BusinessError } 9800002 - Parcel operation failed. 150 * @throws { BusinessError } 9800003 - Internal transaction failed. 151 * @throws { BusinessError } 9800004 - System service operation failed. 152 * @throws { BusinessError } 9900001 - Caller information verification failed for a transient task. 153 * @throws { BusinessError } 9900002 - Transient task verification failed. 154 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 155 * @since 9 156 */ 157 function getRemainingDelayTime(requestId: number): Promise<number>; 158 159 /** 160 * Requests delayed transition to the suspended state. 161 * 162 * @param { string } reason - Indicates the reason for delayed transition to the suspended state. 163 * @param { Callback<void> } callback - The callback delay time expired. 164 * @returns { DelaySuspendInfo } Info of delay request. 165 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 166 * <br> 2. Incorrect parameters types. 167 * @throws { BusinessError } 9800001 - Memory operation failed. 168 * @throws { BusinessError } 9800002 - Parcel operation failed. 169 * @throws { BusinessError } 9800003 - Internal transaction failed. 170 * @throws { BusinessError } 9800004 - System service operation failed. 171 * @throws { BusinessError } 9900001 - Caller information verification failed for a transient task. 172 * @throws { BusinessError } 9900002 - Transient task verification failed. 173 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask 174 * @since 9 175 */ 176 function requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspendInfo; 177 178 /** 179 * Service ability uses this method to request start running in background. 180 * <p> System will publish a notification related to the this service. </p> 181 * 182 * @permission ohos.permission.KEEP_BACKGROUND_RUNNING 183 * @param { Context } context - App running context. 184 * @param { BackgroundMode } bgMode - Indicates which background mode to request. 185 * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar. 186 * @param { AsyncCallback<void> } callback - The callback of the function. 187 * @throws { BusinessError } 201 - Permission denied. 188 * @throws { BusinessError } 202 - Not System App. 189 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 190 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 191 * @throws { BusinessError } 9800001 - Memory operation failed. 192 * @throws { BusinessError } 9800002 - Parcel operation failed. 193 * @throws { BusinessError } 9800003 - Internal transaction failed. 194 * @throws { BusinessError } 9800004 - System service operation failed. 195 * @throws { BusinessError } 9800005 - Continuous task verification failed. 196 * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task. 197 * @throws { BusinessError } 9800007 - Continuous task storage failed. 198 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 199 * @since 9 200 */ 201 /** 202 * Service ability uses this method to request start running in background. 203 * <p> System will publish a notification related to the this service. </p> 204 * 205 * @permission ohos.permission.KEEP_BACKGROUND_RUNNING 206 * @param { Context } context - App running context. 207 * @param { BackgroundMode } bgMode - Indicates which background mode to request. 208 * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar. 209 * @param { AsyncCallback<void> } callback - The callback of the function. 210 * @throws { BusinessError } 201 - Permission denied. 211 * @throws { BusinessError } 202 - Not System App. 212 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 213 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 214 * @throws { BusinessError } 9800001 - Memory operation failed. 215 * @throws { BusinessError } 9800002 - Parcel operation failed. 216 * @throws { BusinessError } 9800003 - Internal transaction failed. 217 * @throws { BusinessError } 9800004 - System service operation failed. 218 * @throws { BusinessError } 9800005 - Continuous task verification failed. 219 * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task. 220 * @throws { BusinessError } 9800007 - Continuous task storage failed. 221 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 222 * @atomicservice 223 * @since 12 224 */ 225 function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback<void>): void; 226 227 /** 228 * Service ability uses this method to request start running in background. 229 * <p> System will publish a notification related to the this service. </p> 230 * 231 * @permission ohos.permission.KEEP_BACKGROUND_RUNNING 232 * @param { Context } context - App running context. 233 * @param { BackgroundMode } bgMode - Indicates which background mode to request. 234 * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar. 235 * @returns { Promise<void> } The promise returned by the function. 236 * @throws { BusinessError } 201 - Permission denied. 237 * @throws { BusinessError } 202 - Not System App. 238 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 239 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 240 * @throws { BusinessError } 9800001 - Memory operation failed. 241 * @throws { BusinessError } 9800002 - Parcel operation failed. 242 * @throws { BusinessError } 9800003 - Internal transaction failed. 243 * @throws { BusinessError } 9800004 - System service operation failed. 244 * @throws { BusinessError } 9800005 - Continuous task verification failed. 245 * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task. 246 * @throws { BusinessError } 9800007 - Continuous task storage failed. 247 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 248 * @since 9 249 */ 250 /** 251 * Service ability uses this method to request start running in background. 252 * <p> System will publish a notification related to the this service. </p> 253 * 254 * @permission ohos.permission.KEEP_BACKGROUND_RUNNING 255 * @param { Context } context - App running context. 256 * @param { BackgroundMode } bgMode - Indicates which background mode to request. 257 * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar. 258 * @returns { Promise<void> } The promise returned by the function. 259 * @throws { BusinessError } 201 - Permission denied. 260 * @throws { BusinessError } 202 - Not System App. 261 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 262 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 263 * @throws { BusinessError } 9800001 - Memory operation failed. 264 * @throws { BusinessError } 9800002 - Parcel operation failed. 265 * @throws { BusinessError } 9800003 - Internal transaction failed. 266 * @throws { BusinessError } 9800004 - System service operation failed. 267 * @throws { BusinessError } 9800005 - Continuous task verification failed. 268 * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task. 269 * @throws { BusinessError } 9800007 - Continuous task storage failed. 270 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 271 * @atomicservice 272 * @since 12 273 */ 274 function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise<void>; 275 276 /** 277 * UIAbility uses this method to request start running in background. 278 * <p> System will publish a notification related to the UIAbility. </p> 279 * 280 * @permission ohos.permission.KEEP_BACKGROUND_RUNNING 281 * @param { Context } context - App running context. 282 * @param { string[] } bgModes - Indicates which background mode to request. 283 * @param { WantAgent } wantAgent - Indicates which ability to start when user click the notification bar. 284 * @returns { Promise<ContinuousTaskNotification> } The The continuous task notification. 285 * @throws { BusinessError } 201 - Permission denied. 286 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 287 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 288 * @throws { BusinessError } 9800001 - Memory operation failed. 289 * @throws { BusinessError } 9800002 - Parcel operation failed. 290 * @throws { BusinessError } 9800003 - Internal transaction failed. 291 * @throws { BusinessError } 9800004 - System service operation failed. 292 * @throws { BusinessError } 9800005 - Continuous task verification failed. 293 * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task. 294 * @throws { BusinessError } 9800007 - Continuous task storage failed. 295 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 296 * @atomicservice 297 * @since 12 298 */ 299 function startBackgroundRunning(context: Context, bgModes: string[], wantAgent: WantAgent): Promise<ContinuousTaskNotification>; 300 301 /** 302 * UIAbility uses this method to update background mode. 303 * 304 * @permission ohos.permission.KEEP_BACKGROUND_RUNNING 305 * @param { Context } context - App running context. 306 * @param { string[] } bgModes - Indicates which background mode to request. 307 * @returns { Promise<ContinuousTaskNotification> } The continuous task notification. 308 * @throws { BusinessError } 201 - Permission denied. 309 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 310 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 311 * @throws { BusinessError } 9800001 - Memory operation failed. 312 * @throws { BusinessError } 9800002 - Parcel operation failed. 313 * @throws { BusinessError } 9800003 - Internal transaction failed. 314 * @throws { BusinessError } 9800004 - System service operation failed. 315 * @throws { BusinessError } 9800005 - Continuous task verification failed. 316 * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task. 317 * @throws { BusinessError } 9800007 - Continuous task storage failed. 318 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 319 * @atomicservice 320 * @since 12 321 */ 322 function updateBackgroundRunning(context: Context, bgModes: string[]): Promise<ContinuousTaskNotification>; 323 324 /** 325 * Service ability uses this method to request stop running in background. 326 * 327 * @param { Context } context - App running context. 328 * @param { AsyncCallback<void> } callback - The callback of the function. 329 * @throws { BusinessError } 201 - Permission denied. 330 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 331 * @throws { BusinessError } 9800001 - Memory operation failed. 332 * @throws { BusinessError } 9800002 - Parcel operation failed. 333 * @throws { BusinessError } 9800003 - Internal transaction failed. 334 * @throws { BusinessError } 9800004 - System service operation failed. 335 * @throws { BusinessError } 9800005 - Continuous task verification failed. 336 * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task. 337 * @throws { BusinessError } 9800007 - Continuous task storage failed. 338 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 339 * @since 9 340 */ 341 /** 342 * Service ability uses this method to request stop running in background. 343 * 344 * @param { Context } context - App running context. 345 * @param { AsyncCallback<void> } callback - The callback of the function. 346 * @throws { BusinessError } 201 - Permission denied. 347 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 348 * @throws { BusinessError } 9800001 - Memory operation failed. 349 * @throws { BusinessError } 9800002 - Parcel operation failed. 350 * @throws { BusinessError } 9800003 - Internal transaction failed. 351 * @throws { BusinessError } 9800004 - System service operation failed. 352 * @throws { BusinessError } 9800005 - Continuous task verification failed. 353 * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task. 354 * @throws { BusinessError } 9800007 - Continuous task storage failed. 355 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 356 * @atomicservice 357 * @since 12 358 */ 359 function stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): void; 360 361 /** 362 * Service ability uses this method to request stop running in background. 363 * 364 * @param { Context } context - App running context. 365 * @returns { Promise<void> } The promise returned by the function. 366 * @throws { BusinessError } 201 - Permission denied. 367 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 368 * @throws { BusinessError } 9800001 - Memory operation failed. 369 * @throws { BusinessError } 9800002 - Parcel operation failed. 370 * @throws { BusinessError } 9800003 - Internal transaction failed. 371 * @throws { BusinessError } 9800004 - System service operation failed. 372 * @throws { BusinessError } 9800005 - Continuous task verification failed. 373 * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task. 374 * @throws { BusinessError } 9800007 - Continuous task storage failed. 375 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 376 * @since 9 377 */ 378 /** 379 * Service ability uses this method to request stop running in background. 380 * 381 * @param { Context } context - App running context. 382 * @returns { Promise<void> } The promise returned by the function. 383 * @throws { BusinessError } 201 - Permission denied. 384 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 385 * @throws { BusinessError } 9800001 - Memory operation failed. 386 * @throws { BusinessError } 9800002 - Parcel operation failed. 387 * @throws { BusinessError } 9800003 - Internal transaction failed. 388 * @throws { BusinessError } 9800004 - System service operation failed. 389 * @throws { BusinessError } 9800005 - Continuous task verification failed. 390 * @throws { BusinessError } 9800006 - Notification verification failed for a continuous task. 391 * @throws { BusinessError } 9800007 - Continuous task storage failed. 392 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 393 * @atomicservice 394 * @since 12 395 */ 396 function stopBackgroundRunning(context: Context): Promise<void>; 397 398 /** 399 * Apply or unapply efficiency resources. 400 * 401 * @param { EfficiencyResourcesRequest } request - The request of apply or unapply efficiency resources. 402 * @throws { BusinessError } 201 - Permission denied. 403 * @throws { BusinessError } 202 - Not System App. 404 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 405 * <br> 2. Incorrect parameters types; 3. Parameter verification failed. 406 * @throws { BusinessError } 9800001 - Memory operation failed. 407 * @throws { BusinessError } 9800002 - Parcel operation failed. 408 * @throws { BusinessError } 9800003 - Internal transaction failed. 409 * @throws { BusinessError } 9800004 - System service operation failed. 410 * @throws { BusinessError } 18700001 - Caller information verification failed for an energy resource request. 411 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 412 * @systemapi Hide this for inner system use. 413 * @since 9 414 */ 415 function applyEfficiencyResources(request: EfficiencyResourcesRequest): void; 416 417 /** 418 * Reset all efficiency resources apply. 419 * 420 * @throws { BusinessError } 201 - Permission denied. 421 * @throws { BusinessError } 202 - Not System App. 422 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Parameter verification failed. 423 * @throws { BusinessError } 9800001 - Memory operation failed. 424 * @throws { BusinessError } 9800002 - Parcel operation failed. 425 * @throws { BusinessError } 9800003 - Internal transaction failed. 426 * @throws { BusinessError } 9800004 - System service operation failed. 427 * @throws { BusinessError } 18700001 - Caller information verification failed for an energy resource request. 428 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 429 * @systemapi Hide this for inner system use. 430 * @since 9 431 */ 432 function resetAllEfficiencyResources(): void; 433 434 /** 435 * Supported background mode. 436 * 437 * @enum { number } 438 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 439 * @since 9 440 */ 441 /** 442 * Supported background mode. 443 * 444 * @enum { number } 445 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 446 * @atomicservice 447 * @since 12 448 */ 449 export enum BackgroundMode { 450 /** 451 * data transfer mode 452 * 453 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 454 * @since 9 455 */ 456 DATA_TRANSFER = 1, 457 458 /** 459 * audio playback mode 460 * 461 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 462 * @since 9 463 */ 464 /** 465 * audio playback mode 466 * 467 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 468 * @atomicservice 469 * @since 12 470 */ 471 AUDIO_PLAYBACK = 2, 472 473 /** 474 * audio recording mode 475 * 476 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 477 * @since 9 478 */ 479 AUDIO_RECORDING = 3, 480 481 /** 482 * location mode 483 * 484 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 485 * @since 9 486 */ 487 LOCATION = 4, 488 489 /** 490 * bluetooth interaction mode 491 * 492 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 493 * @since 9 494 */ 495 BLUETOOTH_INTERACTION = 5, 496 497 /** 498 * multi-device connection mode 499 * 500 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 501 * @since 9 502 */ 503 /** 504 * multi-device connection mode 505 * 506 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 507 * @atomicservice 508 * @since 12 509 */ 510 MULTI_DEVICE_CONNECTION = 6, 511 512 /** 513 * wifi interaction mode 514 * 515 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 516 * @systemapi Hide this for inner system use. 517 * @since 9 518 */ 519 WIFI_INTERACTION = 7, 520 521 /** 522 * Voice over Internet Phone mode 523 * 524 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 525 * @since 13 526 */ 527 VOIP = 8, 528 529 /** 530 * background continuous calculate mode, for example 3D render. 531 * only supported in particular device 532 * 533 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 534 * @since 9 535 */ 536 TASK_KEEPING = 9, 537 } 538 539 /** 540 * The type of resource. 541 * 542 * @enum { number } 543 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 544 * @systemapi Hide this for inner system use. 545 * @since 9 546 */ 547 export enum ResourceType { 548 /** 549 * The cpu resource for not being suspended. 550 * 551 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 552 * @systemapi Hide this for inner system use. 553 * @since 9 554 */ 555 CPU = 1, 556 557 /** 558 * The resource for not being proxyed common_event. 559 * 560 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 561 * @systemapi Hide this for inner system use. 562 * @since 9 563 */ 564 COMMON_EVENT = 1 << 1, 565 566 /** 567 * The resource for not being proxyed timer. 568 * 569 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 570 * @systemapi Hide this for inner system use. 571 * @since 9 572 */ 573 TIMER = 1 << 2, 574 575 /** 576 * The resource for not being proxyed workscheduler. 577 * 578 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 579 * @systemapi Hide this for inner system use. 580 * @since 9 581 */ 582 WORK_SCHEDULER = 1 << 3, 583 584 /** 585 * The resource for not being proxyed bluetooth. 586 * 587 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 588 * @systemapi Hide this for inner system use. 589 * @since 9 590 */ 591 BLUETOOTH = 1 << 4, 592 593 /** 594 * The resource for not being proxyed gps. 595 * 596 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 597 * @systemapi Hide this for inner system use. 598 * @since 9 599 */ 600 GPS = 1 << 5, 601 602 /** 603 * The resource for not being proxyed audio. 604 * 605 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 606 * @systemapi Hide this for inner system use. 607 * @since 9 608 */ 609 AUDIO = 1 << 6, 610 611 /** 612 * The resource for not being proxyed running lock. 613 * 614 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 615 * @systemapi Hide this for inner system use. 616 * @since 10 617 */ 618 RUNNING_LOCK = 1 << 7, 619 620 /** 621 * The resource for not being proxyed sensor. 622 * 623 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 624 * @systemapi Hide this for inner system use. 625 * @since 10 626 */ 627 SENSOR = 1 << 8 628 } 629 630 /** 631 * The request of efficiency resources. 632 * 633 * @interface EfficiencyResourcesRequest 634 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 635 * @systemapi Hide this for inner system use. 636 * @since 9 637 */ 638 export interface EfficiencyResourcesRequest { 639 /** 640 * The set of resource types that app wants to apply. 641 * 642 * @type { number } 643 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 644 * @systemapi Hide this for inner system use. 645 * @since 9 646 */ 647 resourceTypes: number; 648 649 /** 650 * True if the app begin to use, else false. 651 * 652 * @type { boolean } 653 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 654 * @systemapi Hide this for inner system use. 655 * @since 9 656 */ 657 isApply: boolean; 658 659 /** 660 * The duration that the resource can be used most. 661 * 662 * @type { number } 663 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 664 * @systemapi Hide this for inner system use. 665 * @since 9 666 */ 667 timeOut: number; 668 669 /** 670 * True if the apply action is persist, else false. Default value is false. 671 * 672 * @type { ?boolean } 673 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 674 * @systemapi Hide this for inner system use. 675 * @since 9 676 */ 677 isPersist?: boolean; 678 679 /** 680 * True if apply action is for process, false is for package. Default value is false. 681 * 682 * @type { ?boolean } 683 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 684 * @systemapi Hide this for inner system use. 685 * @since 9 686 */ 687 isProcess?: boolean; 688 689 /** 690 * The apply reason. 691 * 692 * @type { string } 693 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply 694 * @systemapi Hide this for inner system use. 695 * @since 9 696 */ 697 reason: string; 698 } 699} 700 701export default backgroundTaskManager; 702