1 /* 2 * Copyright (c) 2023-2024 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 #ifndef OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_CLIENT_H 17 #define OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_CLIENT_H 18 19 #include <mutex> 20 21 #include "ability_connect_callback_interface.h" 22 #include "ability_manager_errors.h" 23 #include "ability_manager_interface.h" 24 #include "ability_scheduler_interface.h" 25 #include "auto_startup_info.h" 26 #include "iremote_object.h" 27 #include "mission_info.h" 28 #include "snapshot.h" 29 #include "system_memory_attr.h" 30 #include "ui_extension_window_command.h" 31 #include "want.h" 32 33 namespace OHOS { 34 namespace AAFwk { 35 using AutoStartupInfo = AbilityRuntime::AutoStartupInfo; 36 /** 37 * @class AbilityManagerClient 38 * AbilityManagerClient is used to access ability manager services. 39 */ 40 class AbilityManagerClient { 41 public: 42 virtual ~AbilityManagerClient(); 43 static std::shared_ptr<AbilityManagerClient> GetInstance(); 44 void RemoveDeathRecipient(); 45 46 /** 47 * AttachAbilityThread, ability call this interface after loaded. 48 * 49 * @param scheduler,.the interface handler of kit ability. 50 * @param token,.ability's token. 51 * @return Returns ERR_OK on success, others on failure. 52 */ 53 ErrCode AttachAbilityThread(sptr<IAbilityScheduler> scheduler, sptr<IRemoteObject> token); 54 55 /** 56 * AbilityTransitionDone, ability call this interface after lift cycle was changed. 57 * 58 * @param token,.ability's token. 59 * @param state,.the state of ability lift cycle. 60 * @return Returns ERR_OK on success, others on failure. 61 */ 62 ErrCode AbilityTransitionDone(sptr<IRemoteObject> token, int state, const PacMap &saveData); 63 64 /** 65 * ScheduleConnectAbilityDone, service ability call this interface while session was connected. 66 * 67 * @param token,.service ability's token. 68 * @param remoteObject,.the session proxy of service ability. 69 * @return Returns ERR_OK on success, others on failure. 70 */ 71 ErrCode ScheduleConnectAbilityDone(sptr<IRemoteObject> token, sptr<IRemoteObject> remoteObject); 72 73 /** 74 * ScheduleDisconnectAbilityDone, service ability call this interface while session was disconnected. 75 * 76 * @param token,.service ability's token. 77 * @return Returns ERR_OK on success, others on failure. 78 */ 79 ErrCode ScheduleDisconnectAbilityDone(sptr<IRemoteObject> token); 80 81 /** 82 * ScheduleCommandAbilityDone, service ability call this interface while session was commanded. 83 * 84 * @param token,.service ability's token. 85 * @return Returns ERR_OK on success, others on failure. 86 */ 87 ErrCode ScheduleCommandAbilityDone(sptr<IRemoteObject> token); 88 89 ErrCode ScheduleCommandAbilityWindowDone( 90 sptr<IRemoteObject> token, 91 sptr<SessionInfo> sessionInfo, 92 WindowCommand winCmd, 93 AbilityCommand abilityCmd); 94 95 /** 96 * Get top ability. 97 * 98 * @param isNeedLocalDeviceId is need local device id. 99 * @return Returns front desk focus ability elementName. 100 */ 101 AppExecFwk::ElementName GetTopAbility(bool isNeedLocalDeviceId = true); 102 103 /** 104 * Get element name by token. 105 * 106 * @param token ability's token. 107 * @param isNeedLocalDeviceId is need local device id. 108 * @return Returns front desk focus ability elementName by token. 109 */ 110 AppExecFwk::ElementName GetElementNameByToken(sptr<IRemoteObject> token, bool isNeedLocalDeviceId = true); 111 112 /** 113 * StartAbility with want, send want to ability manager service. 114 * 115 * @param want Ability want. 116 * @param requestCode Ability request code. 117 * @return Returns ERR_OK on success, others on failure. 118 */ 119 ErrCode StartAbility(const Want &want, int requestCode = DEFAULT_INVAL_VALUE, 120 int32_t userId = DEFAULT_INVAL_VALUE); 121 122 /** 123 * StartAbility with want, send want to ability manager service. 124 * 125 * @param want Ability want. 126 * @param callerToken caller ability token. 127 * @param requestCode Ability request code. 128 * @return Returns ERR_OK on success, others on failure. 129 */ 130 ErrCode StartAbility( 131 const Want &want, 132 sptr<IRemoteObject> callerToken, 133 int requestCode = DEFAULT_INVAL_VALUE, 134 int32_t userId = DEFAULT_INVAL_VALUE); 135 136 /** 137 * StartAbility by insight intent, send want to ability manager service. 138 * 139 * @param want Ability want. 140 * @param callerToken caller ability token. 141 * @param intentId insight intent id. 142 * @param userId userId of target ability. 143 * @return Returns ERR_OK on success, others on failure. 144 */ 145 ErrCode StartAbilityByInsightIntent( 146 const Want &want, 147 sptr<IRemoteObject> callerToken, 148 uint64_t intentId, 149 int32_t userId = DEFAULT_INVAL_VALUE); 150 151 /** 152 * Starts a new ability with specific start settings. 153 * 154 * @param want Indicates the ability to start. 155 * @param requestCode the resultCode of the ability to start. 156 * @param abilityStartSetting Indicates the setting ability used to start. 157 * @return Returns ERR_OK on success, others on failure. 158 */ 159 ErrCode StartAbility( 160 const Want &want, 161 const AbilityStartSetting &abilityStartSetting, 162 sptr<IRemoteObject> callerToken, 163 int requestCode = DEFAULT_INVAL_VALUE, 164 int32_t userId = DEFAULT_INVAL_VALUE); 165 166 /** 167 * Starts a new ability with specific start options. 168 * 169 * @param want, the want of the ability to start. 170 * @param startOptions Indicates the options used to start. 171 * @param callerToken caller ability token. 172 * @param requestCode the resultCode of the ability to start. 173 * @return Returns ERR_OK on success, others on failure. 174 */ 175 ErrCode StartAbility( 176 const Want &want, 177 const StartOptions &startOptions, 178 sptr<IRemoteObject> callerToken, 179 int requestCode = DEFAULT_INVAL_VALUE, 180 int32_t userId = DEFAULT_INVAL_VALUE); 181 182 /** 183 * Starts a new ability using the original caller information. 184 * 185 * @param want Ability want. 186 * @param callerToken current caller ability token. 187 * @param asCallerSourceToken source caller ability token. 188 * @param requestCode Ability request code. 189 * @param userId Ability userId 190 * @return Returns ERR_OK on success, others on failure. 191 */ 192 ErrCode StartAbilityAsCaller( 193 const Want &want, 194 sptr<IRemoteObject> callerToken, 195 sptr<IRemoteObject> asCallerSourceToken, 196 int requestCode = DEFAULT_INVAL_VALUE, 197 int32_t userId = DEFAULT_INVAL_VALUE); 198 199 /** 200 * Starts a new ability using the original caller information. 201 * 202 * @param want Indicates the ability to start. 203 * @param startOptions current Indicates the options used to start. 204 * @param callerToken caller ability token. 205 * @param asCallerSourceToken source caller ability token. 206 * @param requestCode the resultCode of the ability to start. 207 * @param userId Ability userId 208 * @return Returns ERR_OK on success, others on failure. 209 */ 210 ErrCode StartAbilityAsCaller( 211 const Want &want, 212 const StartOptions &startOptions, 213 sptr<IRemoteObject> callerToken, 214 sptr<IRemoteObject> asCallerSourceToken, 215 int requestCode = DEFAULT_INVAL_VALUE, 216 int32_t userId = DEFAULT_INVAL_VALUE); 217 218 /** 219 * Starts a new ability for result using the original caller information. 220 * 221 * @param want the want of the ability to start. 222 * @param callerToken current caller ability token. 223 * @param requestCode the resultCode of the ability to start. 224 * @param userId Designation User ID. 225 * @return Returns ERR_OK on success, others on failure. 226 */ 227 ErrCode StartAbilityForResultAsCaller( 228 const Want &want, 229 sptr<IRemoteObject> callerToken, 230 int requestCode = DEFAULT_INVAL_VALUE, 231 int32_t userId = DEFAULT_INVAL_VALUE); 232 233 /** 234 * Starts a new ability for result using the original caller information. 235 * 236 * @param want the want of the ability to start. 237 * @param startOptions Indicates the options used to start. 238 * @param callerToken current caller ability token. 239 * @param requestCode the resultCode of the ability to start. 240 * @param userId Designation User ID. 241 * @return Returns ERR_OK on success, others on failure. 242 */ 243 ErrCode StartAbilityForResultAsCaller( 244 const Want &want, 245 const StartOptions &startOptions, 246 sptr<IRemoteObject> callerToken, 247 int requestCode = DEFAULT_INVAL_VALUE, 248 int32_t userId = DEFAULT_INVAL_VALUE); 249 250 /** 251 * Start ui session ability with extension session info, send session info to ability manager service. 252 * 253 * @param want Ability want. 254 * @param callerToken caller ability token. 255 * @param sessionInfo the information of UIExtensionContentSession. 256 * @param requestCode Ability request code. 257 * @return Returns ERR_OK on success, others on failure. 258 */ 259 ErrCode StartAbilityByUIContentSession( 260 const Want &want, 261 sptr<IRemoteObject> callerToken, 262 sptr<AAFwk::SessionInfo> sessionInfo, 263 int requestCode = DEFAULT_INVAL_VALUE, 264 int32_t userId = DEFAULT_INVAL_VALUE); 265 266 /** 267 * Start ui session ability with extension session info, send session info to ability manager service. 268 * 269 * @param want, the want of the ability to start. 270 * @param startOptions Indicates the options used to start. 271 * @param callerToken caller ability token. 272 * @param sessionInfo the information of UIExtensionContentSession. 273 * @param requestCode the resultCode of the ability to start. 274 * @return Returns ERR_OK on success, others on failure. 275 */ 276 ErrCode StartAbilityByUIContentSession( 277 const Want &want, 278 const StartOptions &startOptions, 279 sptr<IRemoteObject> callerToken, 280 sptr<AAFwk::SessionInfo> sessionInfo, 281 int requestCode = DEFAULT_INVAL_VALUE, 282 int32_t userId = DEFAULT_INVAL_VALUE); 283 284 /** 285 * Start ui ability 286 * 287 * @param want the want of the ability to start. 288 * @param callerToken caller ability token. 289 * @param specifyTokenId The Caller ID. 290 * @return Returns ERR_OK on success, others on failure. 291 */ 292 ErrCode StartAbilityOnlyUIAbility( 293 const Want &want, 294 sptr<IRemoteObject> callerToken, 295 uint32_t specifyTokenId); 296 297 /** 298 * Start extension ability with want, send want to ability manager service. 299 * 300 * @param want, the want of the ability to start. 301 * @param callerToken, caller ability token. 302 * @param userId, Designation User ID. 303 * @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started. 304 * @return Returns ERR_OK on success, others on failure. 305 */ 306 ErrCode StartExtensionAbility( 307 const Want &want, 308 sptr<IRemoteObject> callerToken, 309 int32_t userId = DEFAULT_INVAL_VALUE, 310 AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED); 311 312 /** 313 * Create UIExtension with want, send want to ability manager service. 314 * 315 * @param want, the want of the ability to start. 316 * @return Returns ERR_OK on success, others on failure. 317 */ 318 ErrCode RequestModalUIExtension(const Want &want); 319 320 /** 321 * Preload UIExtension with want, send want to ability manager service. 322 * 323 * @param want, the want of the ability to start. 324 * @param hostBundleName, the caller application bundle name. 325 * @param userId, the extension runs in. 326 * @return Returns ERR_OK on success, others on failure. 327 */ 328 ErrCode PreloadUIExtensionAbility(const Want &want, std::string &hostBundleName, 329 int32_t userId = DEFAULT_INVAL_VALUE); 330 331 ErrCode ChangeAbilityVisibility(sptr<IRemoteObject> token, bool isShow); 332 333 ErrCode ChangeUIAbilityVisibilityBySCB(sptr<SessionInfo> sessionInfo, bool isShow); 334 335 /** 336 * Start ui extension ability with extension session info, send extension session info to ability manager service. 337 * 338 * @param extensionSessionInfo the extension session info of the ability to start. 339 * @param userId, Designation User ID. 340 * @return Returns ERR_OK on success, others on failure. 341 */ 342 ErrCode StartUIExtensionAbility( 343 sptr<SessionInfo> extensionSessionInfo, 344 int32_t userId = DEFAULT_INVAL_VALUE); 345 346 /** 347 * Start ui ability with want, send want to ability manager service. 348 * 349 * @param sessionInfo the session info of the ability to start. 350 * @param isColdStart the session info of the ability is or not cold start. 351 * @return Returns ERR_OK on success, others on failure. 352 */ 353 ErrCode StartUIAbilityBySCB(sptr<SessionInfo> sessionInfo, bool &isColdStart, uint32_t sceneFlag = 0); 354 355 /** 356 * Stop extension ability with want, send want to ability manager service. 357 * 358 * @param want, the want of the ability to stop. 359 * @param callerToken, caller ability token. 360 * @param userId, Designation User ID. 361 * @param extensionType If an ExtensionAbilityType is set, only extension of that type can be stopped. 362 * @return Returns ERR_OK on success, others on failure. 363 */ 364 ErrCode StopExtensionAbility( 365 const Want& want, 366 sptr<IRemoteObject> callerToken, 367 int32_t userId = DEFAULT_INVAL_VALUE, 368 AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED); 369 370 /** 371 * TerminateAbility with want, return want from ability manager service. 372 * 373 * @param token Ability token. 374 * @param resultCode resultCode. 375 * @param Want Ability want returned. 376 * @return Returns ERR_OK on success, others on failure. 377 */ 378 ErrCode TerminateAbility(sptr<IRemoteObject> token, int resultCode, const Want *resultWant); 379 380 /** 381 * BackToCallerAbilityWithResult, return to the caller ability. 382 * 383 * @param token, the token of the ability to terminate. 384 * @param resultCode, the resultCode of the ability to terminate. 385 * @param resultWant, the Want of the ability to return. 386 * @param callerRequestCode, the requestCode of caller ability. 387 * @return Returns ERR_OK on success, others on failure. 388 */ 389 ErrCode BackToCallerAbilityWithResult(const sptr<IRemoteObject> &token, int resultCode, 390 const Want *resultWant, int64_t callerRequestCode); 391 392 /** 393 * TerminateUIExtensionAbility with want, return want from ability manager service. 394 * 395 * @param extensionSessionInfo the extension session info of the ability to terminate. 396 * @param resultCode resultCode. 397 * @param Want Ability want returned. 398 * @return Returns ERR_OK on success, others on failure. 399 */ 400 ErrCode TerminateUIExtensionAbility(sptr<SessionInfo> extensionSessionInfo, 401 int resultCode = DEFAULT_INVAL_VALUE, const Want *resultWant = nullptr); 402 403 /** 404 * CloseUIAbilityBySCB, close the special ability by scb. 405 * 406 * @param sessionInfo the session info of the ability to terminate. 407 * @return Returns ERR_OK on success, others on failure. 408 */ 409 ErrCode CloseUIAbilityBySCB(sptr<SessionInfo> sessionInfo); 410 411 /** 412 * SendResultToAbility with want, return resultWant from ability manager service. 413 * 414 * @param requestCode requestCode. 415 * @param resultCode resultCode. 416 * @param resultWant Ability want returned. 417 * @return Returns ERR_OK on success, others on failure. 418 */ 419 ErrCode SendResultToAbility(int requestCode, int resultCode, Want& resultWant); 420 421 /** 422 * MoveAbilityToBackground. 423 * 424 * @param token Ability token. 425 * @return Returns ERR_OK on success, others on failure. 426 */ 427 ErrCode MoveAbilityToBackground(sptr<IRemoteObject> token); 428 429 /** 430 * Move the UIAbility to background, called by app self. 431 * 432 * @param token the token of the ability to move. 433 * @return Returns ERR_OK on success, others on failure. 434 */ 435 ErrCode MoveUIAbilityToBackground(const sptr<IRemoteObject> token); 436 437 /** 438 * CloseAbility with want, return want from ability manager service. 439 * 440 * @param token Ability token. 441 * @param resultCode resultCode. 442 * @param Want Ability want returned. 443 * @return Returns ERR_OK on success, others on failure. 444 */ 445 ErrCode CloseAbility(sptr<IRemoteObject> token, int resultCode = DEFAULT_INVAL_VALUE, 446 const Want *resultWant = nullptr); 447 448 /** 449 * MinimizeAbility, minimize the special ability. 450 * 451 * @param token, ability token. 452 * @param fromUser mark the minimize operation source. 453 * @return Returns ERR_OK on success, others on failure. 454 */ 455 ErrCode MinimizeAbility(sptr<IRemoteObject> token, bool fromUser = false); 456 457 /** 458 * MinimizeUIExtensionAbility, minimize the special ui extension ability. 459 * 460 * @param extensionSessionInfo the extension session info of the ability to minimize. 461 * @param fromUser mark the minimize operation source. 462 * @return Returns ERR_OK on success, others on failure. 463 */ 464 ErrCode MinimizeUIExtensionAbility(sptr<SessionInfo> extensionSessionInfo, bool fromUser = false); 465 466 /** 467 * MinimizeUIAbilityBySCB, minimize the special ability by scb. 468 * 469 * @param sessionInfo the session info of the ability to minimize. 470 * @param fromUser, Whether form user. 471 * @return Returns ERR_OK on success, others on failure. 472 */ 473 ErrCode MinimizeUIAbilityBySCB(sptr<SessionInfo> sessionInfo, bool fromUser = false, uint32_t sceneFlag = 0); 474 475 /** 476 * ConnectAbility, connect session with service ability. 477 * 478 * @param want, Special want for service type's ability. 479 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 480 * @return Returns ERR_OK on success, others on failure. 481 */ 482 ErrCode ConnectAbility(const Want &want, sptr<IAbilityConnection> connect, int32_t userId); 483 484 /** 485 * ConnectAbility, connect session with service ability. 486 * 487 * @param want, Special want for service type's ability. 488 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 489 * @param callerToken, caller ability token. 490 * @return Returns ERR_OK on success, others on failure. 491 */ 492 ErrCode ConnectAbility( 493 const Want &want, 494 sptr<IAbilityConnection> connect, 495 sptr<IRemoteObject> callerToken, 496 int32_t userId = DEFAULT_INVAL_VALUE); 497 498 /** 499 * Connect data share extension ability. 500 * 501 * @param want, special want for the data share extension ability. 502 * @param connect, callback used to notify caller the result of connecting or disconnecting. 503 * @param userId, the extension runs in. 504 * @return Returns ERR_OK on success, others on failure. 505 */ 506 ErrCode ConnectDataShareExtensionAbility(const Want &want, sptr<IAbilityConnection> connect, 507 int32_t userId = DEFAULT_INVAL_VALUE); 508 509 /** 510 * Connect extension ability. 511 * 512 * @param want, special want for the extension ability. 513 * @param connect, callback used to notify caller the result of connecting or disconnecting. 514 * @param userId, the extension runs in. 515 * @return Returns ERR_OK on success, others on failure. 516 */ 517 ErrCode ConnectExtensionAbility(const Want &want, sptr<IAbilityConnection> connect, 518 int32_t userId = DEFAULT_INVAL_VALUE); 519 520 /** 521 * Connect ui extension ability. 522 * 523 * @param want, special want for the ui extension ability. 524 * @param connect, callback used to notify caller the result of connecting or disconnecting. 525 * @param sessionInfo the extension session info of the ability to connect. 526 * @param userId, the extension runs in. 527 * @param connectInfo the connect info. 528 * @return Returns ERR_OK on success, others on failure. 529 */ 530 ErrCode ConnectUIExtensionAbility(const Want &want, sptr<IAbilityConnection> connect, 531 sptr<SessionInfo> sessionInfo, int32_t userId = DEFAULT_INVAL_VALUE, 532 sptr<UIExtensionAbilityConnectInfo> connectInfo = nullptr); 533 534 /** 535 * DisconnectAbility, disconnect session with service ability. 536 * 537 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 538 * @return Returns ERR_OK on success, others on failure. 539 */ 540 ErrCode DisconnectAbility(sptr<IAbilityConnection> connect); 541 542 /** 543 * AcquireDataAbility, acquire a data ability by its authority, if it not existed, 544 * AMS loads it synchronously. 545 * 546 * @param uri, data ability uri. 547 * @param tryBind, true: when a data ability is died, ams will kill this client, or do nothing. 548 * @param callerToken, specifies the caller ability token. 549 * @return returns the data ability ipc object, or nullptr for failed. 550 */ 551 sptr<IAbilityScheduler> AcquireDataAbility(const Uri &uri, bool tryBind, sptr<IRemoteObject> callerToken); 552 553 /** 554 * ReleaseDataAbility, release the data ability that referenced by 'dataAbilityToken'. 555 * 556 * @param dataAbilityToken, specifies the data ability that will be released. 557 * @param callerToken, specifies the caller ability token. 558 * @return returns ERR_OK if succeeded, or error codes for failed. 559 */ 560 ErrCode ReleaseDataAbility(sptr<IAbilityScheduler> dataAbilityScheduler, sptr<IRemoteObject> callerToken); 561 562 /** 563 * dump ability stack info, about userID, mission stack info, 564 * mission record info and ability info. 565 * 566 * @param state Ability stack info. 567 * @return Returns ERR_OK on success, others on failure. 568 */ 569 ErrCode DumpState(const std::string &args, std::vector<std::string> &state); 570 ErrCode DumpSysState( 571 const std::string& args, std::vector<std::string>& state, bool isClient, bool isUserID, int UserID); 572 /** 573 * Connect ability manager service. 574 * 575 * @return Returns ERR_OK on success, others on failure. 576 */ 577 ErrCode Connect(); 578 579 /** 580 * Destroys this Service ability by Want. 581 * 582 * @param want, Special want for service type's ability. 583 * @param token ability's token. 584 * @return Returns true if this Service ability will be destroyed; returns false otherwise. 585 */ 586 ErrCode StopServiceAbility(const Want &want, sptr<IRemoteObject> token = nullptr); 587 588 /** 589 * Kill the process immediately. 590 * 591 * @param bundleName. 592 * @return Returns ERR_OK on success, others on failure. 593 */ 594 ErrCode KillProcess(const std::string &bundleName); 595 596 #ifdef ABILITY_COMMAND_FOR_TEST 597 /** 598 * Force ability timeout. 599 * 600 * @param abilityName. 601 * @param state. ability lifecycle state. 602 * @return Returns ERR_OK on success, others on failure. 603 */ 604 ErrCode ForceTimeoutForTest(const std::string &abilityName, const std::string &state); 605 #endif 606 607 /** 608 * ContinueMission, continue ability from mission center. 609 * 610 * @param srcDeviceId, origin deviceId. 611 * @param dstDeviceId, target deviceId. 612 * @param missionId, indicates which ability to continue. 613 * @param callBack, notify result back. 614 * @param wantParams, extended params. 615 * @return Returns ERR_OK on success, others on failure. 616 */ 617 ErrCode ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId, int32_t missionId, 618 sptr<IRemoteObject> callback, AAFwk::WantParams &wantParams); 619 620 /** 621 * ContinueMission, continue ability from mission center. 622 * 623 * @param srcDeviceId, origin deviceId. 624 * @param dstDeviceId, target deviceId. 625 * @param bundleName, indicates which bundleName to continue. 626 * @param callBack, notify result back. 627 * @param wantParams, extended params. 628 * @return Returns ERR_OK on success, others on failure. 629 */ 630 ErrCode ContinueMission(AAFwk::ContinueMissionInfo continueMissionInfo, const sptr<IRemoteObject> &callback); 631 632 /** 633 * start continuation. 634 * @param want, used to start a ability. 635 * @param abilityToken, ability token. 636 * @param status, continue status. 637 * @return Returns ERR_OK on success, others on failure. 638 */ 639 ErrCode StartContinuation(const Want &want, sptr<IRemoteObject> abilityToken, int32_t status); 640 641 /** 642 * notify continuation complete to dms. 643 * @param deviceId, source device which start a continuation. 644 * @param sessionId, represent a continuaion. 645 * @param isSuccess, continuation result. 646 * @return 647 */ 648 void NotifyCompleteContinuation(const std::string &deviceId, int32_t sessionId, bool isSuccess); 649 650 /** 651 * ContinueMission, continue ability from mission center. 652 * @param deviceId, target deviceId. 653 * @param missionId, indicates which ability to continue. 654 * @param versionCode, version of the remote target ability. 655 * @return Returns ERR_OK on success, others on failure. 656 */ 657 ErrCode ContinueAbility(const std::string &deviceId, int32_t missionId, uint32_t versionCode); 658 659 /** 660 * notify continuation result to application. 661 * @param missionId, indicates which ability to notify. 662 * @param result, continuation result. 663 * @return 664 */ 665 ErrCode NotifyContinuationResult(int32_t missionId, int32_t result); 666 667 /** 668 * @brief Lock specified mission. 669 * @param missionId The id of target mission. 670 * 671 * @return Returns ERR_OK on success, others on failure. 672 */ 673 ErrCode LockMissionForCleanup(int32_t missionId); 674 675 /** 676 * @brief Unlock specified mission. 677 * @param missionId The id of target mission. 678 * 679 * @return Returns ERR_OK on success, others on failure. 680 */ 681 ErrCode UnlockMissionForCleanup(int32_t missionId); 682 683 /** 684 * @brief change specified AbilityRecord lockState. 685 * @param sessionId The id of target AbilityRecord. 686 * @param lockState The lockState of target AbilityRecord. 687 * 688 * @return Returns ERR_OK on success, others on failure. 689 */ 690 void SetLockedState(int32_t sessionId, bool lockedState); 691 692 /** 693 * @brief Register mission listener to ams. 694 * @param listener The handler of listener. 695 * 696 * @return Returns ERR_OK on success, others on failure. 697 */ 698 ErrCode RegisterMissionListener(sptr<IMissionListener> listener); 699 700 /** 701 * @brief UnRegister mission listener from ams. 702 * @param listener The handler of listener. 703 * 704 * @return Returns ERR_OK on success, others on failure. 705 */ 706 ErrCode UnRegisterMissionListener(sptr<IMissionListener> listener); 707 708 /** 709 * @brief Register mission listener to ability manager service. 710 * @param deviceId The remote device Id. 711 * @param listener The handler of listener. 712 * 713 * @return Returns ERR_OK on success, others on failure. 714 */ 715 ErrCode RegisterMissionListener(const std::string &deviceId, sptr<IRemoteMissionListener> listener); 716 717 /** 718 * @brief Register mission listener to ability manager service. 719 * @param deviceId The remote device Id. 720 * @param listener The handler of listener. 721 * 722 * @return Returns ERR_OK on success, others on failure. 723 */ 724 ErrCode RegisterOnListener(const std::string &type, sptr<IRemoteOnListener> listener); 725 726 /** 727 * @brief Register mission listener to ability manager service. 728 * @param deviceId The remote device Id. 729 * @param listener The handler of listener. 730 * 731 * @return Returns ERR_OK on success, others on failure. 732 */ 733 ErrCode RegisterOffListener(const std::string &type, sptr<IRemoteOnListener> listener); 734 735 /** 736 * @brief UnRegister mission listener from ability manager service. 737 * @param deviceId The remote device Id. 738 * @param listener The handler of listener. 739 * 740 * @return Returns ERR_OK on success, others on failure. 741 */ 742 ErrCode UnRegisterMissionListener(const std::string &deviceId, sptr<IRemoteMissionListener> listener); 743 744 /** 745 * @brief Get mission infos from ams. 746 * @param deviceId local or remote deviceid. 747 * @param numMax max number of missions. 748 * @param missionInfos mission info result. 749 * 750 * @return Returns ERR_OK on success, others on failure. 751 */ 752 ErrCode GetMissionInfos(const std::string &deviceId, int32_t numMax, std::vector<MissionInfo> &missionInfos); 753 754 /** 755 * @brief Get mission info by id. 756 * @param deviceId local or remote deviceid. 757 * @param missionId Id of target mission. 758 * @param missionInfo mision info of target mission. 759 * 760 * @return Returns ERR_OK on success, others on failure. 761 */ 762 ErrCode GetMissionInfo(const std::string &deviceId, int32_t missionId, MissionInfo &missionInfo); 763 764 /** 765 * @brief Get the Mission Snapshot Info object 766 * @param deviceId local or remote deviceid. 767 * @param missionId Id of target mission. 768 * @param snapshot snapshot of target mission. 769 * @param isLowResolution get low resolution snapshot. 770 * @return Returns ERR_OK on success, others on failure. 771 */ 772 ErrCode GetMissionSnapshot(const std::string& deviceId, int32_t missionId, 773 MissionSnapshot& snapshot, bool isLowResolution = false); 774 775 /** 776 * @brief Clean mission by id. 777 * @param missionId Id of target mission. 778 * 779 * @return Returns ERR_OK on success, others on failure. 780 */ 781 ErrCode CleanMission(int32_t missionId); 782 783 /** 784 * @brief Clean all missions in system. 785 * 786 * @return Returns ERR_OK on success, others on failure. 787 */ 788 ErrCode CleanAllMissions(); 789 790 /** 791 * @brief Move a mission to front. 792 * @param missionId Id of target mission. 793 * @param startOptions Special startOptions for target mission. 794 * 795 * @return Returns ERR_OK on success, others on failure. 796 */ 797 ErrCode MoveMissionToFront(int32_t missionId); 798 ErrCode MoveMissionToFront(int32_t missionId, const StartOptions &startOptions); 799 800 /** 801 * Move missions to front 802 * @param missionIds Ids of target missions 803 * @param topMissionId Indicate which mission will be moved to top, if set to -1, missions' order won't change 804 * @return Returns ERR_OK on success, others on failure. 805 */ 806 ErrCode MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId); 807 808 /** 809 * Move missions to background 810 * @param missionIds Ids of target missions 811 * @param result The result of move missions to background, and the array is sorted by zOrder 812 * @return Returns ERR_OK on success, others on failure. 813 */ 814 ErrCode MoveMissionsToBackground(const std::vector<int32_t>& missionIds, std::vector<int32_t>& result); 815 816 /** 817 * @brief Get mission id by ability token. 818 * 819 * @param token ability token. 820 * @param missionId output mission id. 821 * @return Returns ERR_OK on success, others on failure. 822 */ 823 ErrCode GetMissionIdByToken(sptr<IRemoteObject> token, int32_t &missionId); 824 825 /** 826 * Start Ability, connect session with common ability. 827 * 828 * @param want, Special want for service type's ability. 829 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 830 * @return Returns ERR_OK on success, others on failure. 831 */ 832 ErrCode StartAbilityByCall(const Want &want, sptr<IAbilityConnection> connect); 833 834 /** 835 * Start Ability, connect session with common ability. 836 * 837 * @param want, Special want for service type's ability. 838 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 839 * @param accountId Indicates the account to start. 840 * @return Returns ERR_OK on success, others on failure. 841 */ 842 ErrCode StartAbilityByCall(const Want &want, sptr<IAbilityConnection> connect, 843 sptr<IRemoteObject> callToken, int32_t accountId = DEFAULT_INVAL_VALUE); 844 845 /** 846 * CallRequestDone, after invoke callRequest, ability will call this interface to return callee. 847 * 848 * @param token, ability's token. 849 * @param callStub, ability's callee. 850 */ 851 void CallRequestDone(sptr<IRemoteObject> token, sptr<IRemoteObject> callStub); 852 853 /** 854 * Get ability token by connect. 855 * 856 * @param token The token of ability. 857 * @param callStub The callee object. 858 */ 859 void GetAbilityTokenByCalleeObj(sptr<IRemoteObject> callStub, sptr<IRemoteObject> &token); 860 861 /** 862 * Release the call between Ability, disconnect session with common ability. 863 * 864 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 865 * @return Returns ERR_OK on success, others on failure. 866 */ 867 ErrCode ReleaseCall(sptr<IAbilityConnection> connect, const AppExecFwk::ElementName &element); 868 869 /** 870 * @brief Get the ability running information. 871 * 872 * @param info Ability running information. 873 * @return Returns ERR_OK on success, others on failure. 874 */ 875 ErrCode GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info); 876 877 /** 878 * @brief Get the extension running information. 879 * 880 * @param upperLimit The maximum limit of information wish to get. 881 * @param info Extension running information. 882 * @return Returns ERR_OK on success, others on failure. 883 */ 884 ErrCode GetExtensionRunningInfos(int upperLimit, std::vector<ExtensionRunningInfo> &info); 885 886 /** 887 * @brief Get running process information. 888 * 889 * @param info Running process information. 890 * @return Returns ERR_OK on success, others on failure. 891 */ 892 ErrCode GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> &info); 893 894 /** 895 * Start synchronizing remote device mission 896 * @param devId, deviceId. 897 * @param fixConflict, resolve synchronizing conflicts flag. 898 * @param tag, call tag. 899 * @return Returns ERR_OK on success, others on failure. 900 */ 901 ErrCode StartSyncRemoteMissions(const std::string &devId, bool fixConflict, int64_t tag); 902 903 /** 904 * Stop synchronizing remote device mission 905 * @param devId, deviceId. 906 * @return Returns ERR_OK on success, others on failure. 907 */ 908 ErrCode StopSyncRemoteMissions(const std::string &devId); 909 910 /** 911 * @brief start user. 912 * @param accountId accountId. 913 * 914 * @return Returns ERR_OK on success, others on failure. 915 */ 916 ErrCode StartUser(int accountId, sptr<IUserCallback> callback); 917 918 /** 919 * @brief stop user. 920 * @param accountId accountId. 921 * @param callback callback. 922 * 923 * @return Returns ERR_OK on success, others on failure. 924 */ 925 ErrCode StopUser(int accountId, sptr<IUserCallback> callback); 926 927 /** 928 * @brief logout user. 929 * @param accountId accountId. 930 * 931 * @return Returns ERR_OK on success, others on failure. 932 */ 933 ErrCode LogoutUser(int32_t accountId); 934 935 /** 936 * @brief Register the snapshot handler 937 * @param handler snapshot handler 938 * @return ErrCode Returns ERR_OK on success, others on failure. 939 */ 940 ErrCode RegisterSnapshotHandler(sptr<ISnapshotHandler> handler); 941 942 /** 943 * PrepareTerminateAbility with want, if terminate, return want from ability manager service. 944 * 945 * @param token Ability token. 946 * @param callback callback. 947 * @return Returns ERR_OK on success, others on failure. 948 */ 949 ErrCode PrepareTerminateAbility(sptr<IRemoteObject> token, sptr<IPrepareTerminateCallback> callback); 950 951 ErrCode RegisterStatusBarDelegate(sptr<AbilityRuntime::IStatusBarDelegate> delegate); 952 953 ErrCode KillProcessWithPrepareTerminate(const std::vector<int32_t>& pids); 954 955 /** 956 * @brief Register auto start up callback for system api. 957 * @param callback The point of JsAbilityAutoStartupCallBack. 958 * @return Returns ERR_OK on success, others on failure. 959 */ 960 ErrCode RegisterAutoStartupSystemCallback(sptr<IRemoteObject> callback); 961 962 /** 963 * @brief Unregister auto start up callback for system api. 964 * @param callback The point of JsAbilityAutoStartupCallBack. 965 * @return Returns ERR_OK on success, others on failure. 966 */ 967 ErrCode UnregisterAutoStartupSystemCallback(sptr<IRemoteObject> callback); 968 969 /** 970 * @brief Set every application auto start up state. 971 * @param info The auto startup info,include bundle name, module name, ability name. 972 * @return Returns ERR_OK on success, others on failure. 973 */ 974 ErrCode SetApplicationAutoStartup(const AutoStartupInfo &info); 975 976 /** 977 * @brief Cancel every application auto start up . 978 * @param info The auto startup info,include bundle name, module name, ability name. 979 * @return Returns ERR_OK on success, others on failure. 980 */ 981 ErrCode CancelApplicationAutoStartup(const AutoStartupInfo &info); 982 983 /** 984 * @brief Query auto startup state all application. 985 * @param infoList Output parameters, return auto startup info list. 986 * @return Returns ERR_OK on success, others on failure. 987 */ 988 ErrCode QueryAllAutoStartupApplications(std::vector<AutoStartupInfo> &infoList); 989 990 /** 991 * PrepareTerminateAbilityBySCB, prepare to terminate ability by scb. 992 * 993 * @param sessionInfo the session info of the ability to terminate. 994 * @param isPrepareTerminate the result of ability onPrepareToTermiante. 995 * @return Returns ERR_OK on success, others on failure. 996 */ 997 ErrCode PrepareTerminateAbilityBySCB(sptr<SessionInfo> sessionInfo, bool &isPrepareTerminate); 998 999 /** 1000 * Set mission continue state of this ability. 1001 * 1002 * @param token Indidate token of ability. 1003 * @param state the mission continuation state of this ability. 1004 * @return Returns ERR_OK if success. 1005 */ 1006 ErrCode SetMissionContinueState(sptr<IRemoteObject> token, const AAFwk::ContinueState &state, 1007 sptr<IRemoteObject> sessionToken); 1008 1009 #ifdef SUPPORT_GRAPHICS 1010 /** 1011 * Set mission label of this ability. 1012 * 1013 * @param abilityToken Indidate token of ability. 1014 * @param label Indidate the label showed of the ability in recent missions. 1015 * @return Returns ERR_OK on success, others on failure. 1016 */ 1017 ErrCode SetMissionLabel(sptr<IRemoteObject> abilityToken, const std::string &label); 1018 1019 /** 1020 * Set mission icon of this ability. 1021 * 1022 * @param abilityToken Indidate token of ability. 1023 * @param icon Indidate the icon showed of the ability in recent missions. 1024 * @return Returns ERR_OK on success, others on failure. 1025 */ 1026 ErrCode SetMissionIcon(sptr<IRemoteObject> abilityToken, 1027 std::shared_ptr<OHOS::Media::PixelMap> icon); 1028 1029 /** 1030 * Register the WindowManagerService handler 1031 * 1032 * @param handler Indidate handler of WindowManagerService. 1033 * @return ErrCode Returns ERR_OK on success, others on failure. 1034 */ 1035 ErrCode RegisterWindowManagerServiceHandler(sptr<IWindowManagerServiceHandler> handler, 1036 bool animationEnabled = true); 1037 1038 /** 1039 * WindowManager notification AbilityManager after the first frame is drawn. 1040 * 1041 * @param abilityToken Indidate token of ability. 1042 */ 1043 void CompleteFirstFrameDrawing(sptr<IRemoteObject> abilityToken); 1044 1045 /** 1046 * WindowManager notification AbilityManager after the first frame is drawn. 1047 * 1048 * @param sessionId Indidate session id. 1049 */ 1050 void CompleteFirstFrameDrawing(int32_t sessionId); 1051 1052 /** 1053 * Called to update mission snapshot. 1054 * @param token The target ability. 1055 * @param pixelMap The snapshot. 1056 */ 1057 void UpdateMissionSnapShot(sptr<IRemoteObject> token, 1058 std::shared_ptr<OHOS::Media::PixelMap> pixelMap); 1059 1060 ErrCode GetDialogSessionInfo(const std::string &dialogSessionId, sptr<DialogSessionInfo> &info); 1061 ErrCode SendDialogResult(const Want &want, const std::string &dialogSessionId, bool isAllow); 1062 #endif 1063 1064 /** 1065 * @brief start user test. 1066 * @param want the want of the ability user test to start. 1067 * @param observer test observer callback. 1068 * 1069 * @return Returns ERR_OK on success, others on failure. 1070 */ 1071 ErrCode StartUserTest(const Want &want, sptr<IRemoteObject> observer); 1072 1073 /** 1074 * @brief Finish user test. 1075 * @param msg user test message. 1076 * @param resultCode user test result Code. 1077 * @param bundleName user test bundleName. 1078 * 1079 * @return Returns ERR_OK on success, others on failure. 1080 */ 1081 ErrCode FinishUserTest(const std::string &msg, const int64_t &resultCode, const std::string &bundleName); 1082 1083 /** 1084 * GetTopAbility, get the token of top ability. 1085 * 1086 * @param token, the token of top ability. 1087 * @return Returns ERR_OK on success, others on failure. 1088 */ 1089 ErrCode GetTopAbility(sptr<IRemoteObject> &token); 1090 1091 ErrCode CheckUIExtensionIsFocused(uint32_t uiExtensionTokenId, bool& isFocused); 1092 1093 /** 1094 * DelegatorDoAbilityForeground, the delegator calls this interface to move the ability to the foreground. 1095 * 1096 * @param token, ability's token. 1097 * @return Returns ERR_OK on success, others on failure. 1098 */ 1099 ErrCode DelegatorDoAbilityForeground(sptr<IRemoteObject> token); 1100 1101 /** 1102 * DelegatorDoAbilityBackground, the delegator calls this interface to move the ability to the background. 1103 * 1104 * @param token, ability's token. 1105 * @return Returns ERR_OK on success, others on failure. 1106 */ 1107 ErrCode DelegatorDoAbilityBackground(sptr<IRemoteObject> token); 1108 1109 /** 1110 * Calls this interface to move the ability to the foreground. 1111 * 1112 * @param token, ability's token. 1113 * @param flag, use for lock or unlock flag and so on. 1114 * @return Returns ERR_OK on success, others on failure. 1115 */ 1116 ErrCode DoAbilityForeground(sptr<IRemoteObject> token, uint32_t flag); 1117 1118 /** 1119 * Calls this interface to move the ability to the background. 1120 * 1121 * @param token, ability's token. 1122 * @param flag, use for lock or unlock flag and so on. 1123 * @return Returns ERR_OK on success, others on failure. 1124 */ 1125 ErrCode DoAbilityBackground(sptr<IRemoteObject> token, uint32_t flag); 1126 1127 /** 1128 * Set ability controller. 1129 * 1130 * @param abilityController, The ability controller. 1131 * @return Returns ERR_OK on success, others on failure. 1132 */ 1133 virtual int SetAbilityController(sptr<AppExecFwk::IAbilityController> abilityController, 1134 bool imAStabilityTest); 1135 1136 /** 1137 * Free install ability from remote DMS. 1138 * 1139 * @param want Ability want. 1140 * @param callback Callback used to notify free install result. 1141 * @param userId User ID. 1142 * @param requestCode Ability request code. 1143 * @return Returns ERR_OK on success, others on failure. 1144 */ 1145 ErrCode FreeInstallAbilityFromRemote(const Want &want, sptr<IRemoteObject> callback, int32_t userId, 1146 int requestCode = DEFAULT_INVAL_VALUE); 1147 1148 /** 1149 * Called when client complete dump. 1150 * 1151 * @param infos The dump info. 1152 * @param callerToken The caller ability token. 1153 * @return Returns ERR_OK on success, others on failure. 1154 */ 1155 ErrCode DumpAbilityInfoDone(std::vector<std::string> &infos, sptr<IRemoteObject> callerToken); 1156 1157 /** 1158 * @brief Enable recover ability. 1159 * 1160 * @param token Ability identify. 1161 */ 1162 void EnableRecoverAbility(sptr<IRemoteObject> token); 1163 1164 /** 1165 * @brief Schedule recovery ability. 1166 * 1167 * @param token Ability identify. 1168 * @param reason See AppExecFwk::StateReason. 1169 * @param want Want information. 1170 */ 1171 void ScheduleRecoverAbility(sptr<IRemoteObject> token, int32_t reason, const Want *want = nullptr); 1172 1173 /** 1174 * @brief Add free install observer. 1175 * 1176 * @param callerToken The caller ability token. 1177 * @param observer Free install observer. 1178 * @return Returns ERR_OK on success, others on failure. 1179 */ 1180 ErrCode AddFreeInstallObserver(const sptr<IRemoteObject> callToken, 1181 const sptr<AbilityRuntime::IFreeInstallObserver> observer); 1182 1183 /** 1184 * Called to verify that the MissionId is valid. 1185 * @param missionIds Query mission list. 1186 * @param results Output parameters, return results up to 20 query results. 1187 * @return Returns ERR_OK on success, others on failure. 1188 */ 1189 int32_t IsValidMissionIds(const std::vector<int32_t> &missionIds, std::vector<MissionValidResult> &results); 1190 1191 /** 1192 * Query whether the application of the specified PID and UID has been granted a certain permission 1193 * @param permission 1194 * @param pid Process id 1195 * @param uid 1196 * @return Returns ERR_OK if the current process has the permission, others on failure. 1197 */ 1198 ErrCode VerifyPermission(const std::string &permission, int pid, int uid); 1199 1200 /** 1201 * Acquire the shared data. 1202 * @param missionId The missionId of Target ability. 1203 * @param The IAcquireShareDataCallback object. 1204 * @return Returns ERR_OK on success, others on failure. 1205 */ 1206 ErrCode AcquireShareData(int32_t missionId, sptr<IAcquireShareDataCallback> shareData); 1207 1208 /** 1209 * Notify sharing data finished. 1210 * @param resultCode The result of sharing data. 1211 * @param uniqueId The uniqueId from request object. 1212 * @param wantParam The params of acquiring sharing data from target ability. 1213 * @return Returns ERR_OK on success, others on failure. 1214 */ 1215 ErrCode ShareDataDone( 1216 sptr<IRemoteObject> token, int32_t resultCode, int32_t uniqueId, WantParams &wantParam); 1217 1218 /** 1219 * Request dialog service with want, send want to ability manager service. 1220 * 1221 * @param want target component. 1222 * @param callerToken caller ability token. 1223 * @return Returns ERR_OK on success, others on failure. 1224 */ 1225 ErrCode RequestDialogService( 1226 const Want &want, 1227 sptr<IRemoteObject> callerToken); 1228 1229 /** 1230 * Force app exit and record exit reason. 1231 * @param pid Process id . 1232 * @param exitReason The reason of app exit. 1233 * @return Returns ERR_OK on success, others on failure. 1234 */ 1235 ErrCode ForceExitApp(const int32_t pid, const ExitReason &exitReason); 1236 1237 /** 1238 * Record app exit reason. 1239 * @param exitReason The reason of app exit. 1240 * @return Returns ERR_OK on success, others on failure. 1241 */ 1242 ErrCode RecordAppExitReason(const ExitReason &exitReason); 1243 1244 /** 1245 * Record the process exit reason before the process being killed. 1246 * @param pid The process id. 1247 * @param exitReason The reason of process exit. 1248 * @return Returns ERR_OK on success, others on failure. 1249 */ 1250 int32_t RecordProcessExitReason(const int32_t pid, const ExitReason &exitReason); 1251 1252 /** 1253 * Set rootSceneSession by SCB. 1254 * 1255 * @param rootSceneSession Indicates root scene session of SCB. 1256 */ 1257 void SetRootSceneSession(sptr<IRemoteObject> rootSceneSession); 1258 1259 /** 1260 * Call UIAbility by SCB. 1261 * 1262 * @param sessionInfo the session info of the ability to be called. 1263 * @param isColdStart the session of the ability is or not cold start. 1264 */ 1265 void CallUIAbilityBySCB(sptr<SessionInfo> sessionInfo, bool &isColdStart); 1266 1267 /** 1268 * Start specified ability by SCB. 1269 * 1270 * @param want Want information. 1271 */ 1272 void StartSpecifiedAbilityBySCB(const Want &want); 1273 1274 /** 1275 * Notify sandbox app the result of saving file. 1276 * @param want Result of saving file, which contains the file's uri if success. 1277 * @param resultCode Indicates the action's result. 1278 * @param requestCode Pass the requestCode to match request. 1279 * @return Returns ERR_OK on success, others on failure. 1280 */ 1281 ErrCode NotifySaveAsResult(const Want &want, int resultCode, int requestCode); 1282 1283 /** 1284 * Set sessionManagerService 1285 * @param sessionManagerService the point of sessionManagerService. 1286 * 1287 * @return Returns ERR_OK on success, others on failure. 1288 */ 1289 ErrCode SetSessionManagerService(sptr<IRemoteObject> sessionManagerService); 1290 1291 ErrCode ReportDrawnCompleted(sptr<IRemoteObject> token); 1292 1293 /** 1294 * @brief Register collaborator. 1295 * @param type collaborator type. 1296 * @param impl collaborator. 1297 * @return Returns ERR_OK on success, others on failure. 1298 */ 1299 ErrCode RegisterIAbilityManagerCollaborator( 1300 int32_t type, sptr<IAbilityManagerCollaborator> impl); 1301 1302 /** 1303 * @brief Unregister collaborator. 1304 * @param type collaborator type. 1305 * @return Returns ERR_OK on success, others on failure. 1306 */ 1307 ErrCode UnregisterIAbilityManagerCollaborator(int32_t type); 1308 1309 /** 1310 * @brief Register session handler. 1311 * @param object The handler. 1312 * 1313 * @return Returns ERR_OK on success, others on failure. 1314 */ 1315 ErrCode RegisterSessionHandler(sptr<IRemoteObject> object); 1316 1317 /** 1318 * @brief Register app debug listener. 1319 * @param listener App debug listener. 1320 * @return Returns ERR_OK on success, others on failure. 1321 */ 1322 ErrCode RegisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener); 1323 1324 /** 1325 * @brief Unregistering app debug listener. 1326 * @param listener App debug listener. 1327 * @return Returns ERR_OK on success, others on failure. 1328 */ 1329 ErrCode UnregisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener); 1330 1331 /** 1332 * @brief Attach app debug. 1333 * @param bundleName The application bundle name. 1334 * @return Returns ERR_OK on success, others on failure. 1335 */ 1336 ErrCode AttachAppDebug(const std::string &bundleName); 1337 1338 /** 1339 * @brief Detach app debug. 1340 * @param bundleName The application bundle name. 1341 * @return Returns ERR_OK on success, others on failure. 1342 */ 1343 ErrCode DetachAppDebug(const std::string &bundleName); 1344 1345 /** 1346 * @brief Check if ability controller can start. 1347 * @param want The want of ability to start. 1348 * @return Return true to allow ability to start, or false to reject. 1349 */ 1350 bool IsAbilityControllerStart(const Want &want); 1351 1352 /** 1353 * @brief Open file by uri. 1354 * @param uri The file uri. 1355 * @param flag Want::FLAG_AUTH_READ_URI_PERMISSION or Want::FLAG_AUTH_WRITE_URI_PERMISSION. 1356 * @return int The file descriptor. 1357 */ 1358 int32_t OpenFile(const Uri& uri, uint32_t flag); 1359 1360 /** 1361 * @brief Execute intent. 1362 * @param key The key of intent executing client. 1363 * @param callerToken Caller ability token. 1364 * @param param The Intent execute param. 1365 * @return Returns ERR_OK on success, others on failure. 1366 */ 1367 ErrCode ExecuteIntent(uint64_t key, sptr<IRemoteObject> callerToken, 1368 const InsightIntentExecuteParam ¶m); 1369 1370 /** 1371 * @brief Called when insight intent execute finished. 1372 * 1373 * @param token ability's token. 1374 * @param intentId insight intent id. 1375 * @param result insight intent execute result. 1376 * @return Returns ERR_OK on success, others on failure. 1377 */ 1378 ErrCode ExecuteInsightIntentDone(sptr<IRemoteObject> token, uint64_t intentId, 1379 const InsightIntentExecuteResult &result); 1380 1381 /** 1382 * @brief Get foreground ui abilities. 1383 * @param list Foreground ui abilities. 1384 * @return Returns ERR_OK on success, others on failure. 1385 */ 1386 int32_t GetForegroundUIAbilities(std::vector<AppExecFwk::AbilityStateData> &list); 1387 1388 /** 1389 * @brief Update session info. 1390 * @param sessionInfos The vector of session info. 1391 */ 1392 int32_t UpdateSessionInfoBySCB(std::list<SessionInfo> &sessionInfos, int32_t userId, 1393 std::vector<int32_t> &sessionIds); 1394 1395 /** 1396 * @brief Restart app self. 1397 * @param want The ability type must be UIAbility. 1398 * @return Returns ERR_OK on success, others on failure. 1399 */ 1400 int32_t RestartApp(const AAFwk::Want &want); 1401 1402 /** 1403 * @brief Get host info of root caller. 1404 * 1405 * @param token The ability token. 1406 * @param hostInfo The host info of root caller. 1407 * @param userId The user id. 1408 * @return ErrCode Returns ERR_OK on success, others on failure. 1409 */ 1410 ErrCode GetUIExtensionRootHostInfo(const sptr<IRemoteObject> token, UIExtensionHostInfo &hostInfo, 1411 int32_t userId = DEFAULT_INVAL_VALUE); 1412 1413 /** 1414 * @brief Get ui extension session info 1415 * 1416 * @param token The ability token. 1417 * @param uiExtensionSessionInfo The ui extension session info. 1418 * @param userId The user id. 1419 * @return int32_t Returns ERR_OK on success, others on failure. 1420 */ 1421 ErrCode GetUIExtensionSessionInfo(const sptr<IRemoteObject> token, UIExtensionSessionInfo &uiExtensionSessionInfo, 1422 int32_t userId = DEFAULT_INVAL_VALUE); 1423 1424 /** 1425 * Pop-up launch of full-screen atomic service. 1426 * 1427 * @param want The want with parameters. 1428 * @param callerToken caller ability token. 1429 * @param requestCode Ability request code. 1430 * @param userId The User ID. 1431 * @return Returns ERR_OK on success, others on failure. 1432 */ 1433 int32_t OpenAtomicService(Want& want, const StartOptions &options, sptr<IRemoteObject> callerToken, 1434 int32_t requestCode = DEFAULT_INVAL_VALUE, int32_t userId = DEFAULT_INVAL_VALUE); 1435 1436 /** 1437 * @brief Querying whether to allow embedded startup of atomic service. 1438 * 1439 * @param token The caller UIAbility token. 1440 * @param appId The ID of the application to which this bundle belongs. 1441 * @return Returns true to allow ability to start, or false to reject. 1442 */ 1443 bool IsEmbeddedOpenAllowed(sptr<IRemoteObject> callerToken, const std::string &appId); 1444 1445 /** 1446 * @brief Request to display assert fault dialog. 1447 * @param callback Listen for user operation callbacks. 1448 * @param wantParams Assert dialog box display information. 1449 * @return Returns ERR_OK on success, others on failure. 1450 */ 1451 int32_t RequestAssertFaultDialog(const sptr<IRemoteObject> &callback, const AAFwk::WantParams &wantParams); 1452 1453 /** 1454 * @brief Notify the operation status of the user. 1455 * @param assertFaultSessionId Indicates the request ID of AssertFault. 1456 * @param userStatus Operation status of the user. 1457 * @return Returns ERR_OK on success, others on failure. 1458 */ 1459 int32_t NotifyDebugAssertResult(uint64_t assertFaultSessionId, AAFwk::UserStatus userStatus); 1460 1461 /** 1462 * Set the enable status for starting and stopping resident processes. 1463 * The caller application can only set the resident status of the configured process. 1464 * @param bundleName The bundle name of the resident process. 1465 * @param enable Set resident process enable status. 1466 * @return Returns ERR_OK on success, others on failure. 1467 */ 1468 int32_t SetResidentProcessEnabled(const std::string &bundleName, bool enable); 1469 1470 /** 1471 * Starts a new ability with specific start options. 1472 * 1473 * @param want, the want of the ability to start. 1474 * @param startOptions Indicates the options used to start. 1475 * @return Returns ERR_OK on success, others on failure. 1476 */ 1477 int32_t StartShortcut(const Want &want, const StartOptions &startOptions); 1478 1479 /** 1480 * Get ability state by persistent id. 1481 * 1482 * @param persistentId, the persistentId of the session. 1483 * @param state Indicates the ability state. 1484 * @return Returns ERR_OK on success, others on failure. 1485 */ 1486 int32_t GetAbilityStateByPersistentId(int32_t persistentId, bool &state); 1487 1488 /** 1489 * Transfer resultCode & want to abms. 1490 * 1491 * @param callerToken caller ability token. 1492 * @param requestCode the resultCode of the ability to start. 1493 * @param want Indicates the ability to start. 1494 * @return Returns ERR_OK on success, others on failure. 1495 */ 1496 int32_t TransferAbilityResultForExtension(const sptr<IRemoteObject> &callerToken, int32_t resultCode, 1497 const Want &want); 1498 1499 /** 1500 * Notify ability manager service frozen process. 1501 * 1502 * @param pidList, the pid list of the frozen process. 1503 * @param uid, the uid of the frozen process. 1504 */ 1505 void NotifyFrozenProcessByRSS(const std::vector<int32_t> &pidList, int32_t uid); 1506 1507 /** 1508 * Open atomic service window prior to finishing free install. 1509 * 1510 * @param bundleName, the bundle name of the atomic service. 1511 * @param moduleName, the module name of the atomic service. 1512 * @param abilityName, the ability name of the atomic service. 1513 * @param startTime, the starting time of the free install task. 1514 * @return Returns ERR_OK on success, others on failure. 1515 */ 1516 int32_t PreStartMission(const std::string& bundleName, const std::string& moduleName, 1517 const std::string& abilityName, const std::string& startTime); 1518 1519 /** 1520 * Request to clean UIAbility from user. 1521 * 1522 * @param sessionInfo the session info of the ability to clean. 1523 * @return Returns ERR_OK on success, others on failure. 1524 */ 1525 ErrCode CleanUIAbilityBySCB(sptr<SessionInfo> sessionInfo); 1526 1527 /** 1528 * Open link of ability and atomic service. 1529 * 1530 * @param want Ability want. 1531 * @param callerToken Caller ability token. 1532 * @param userId User ID. 1533 * @param requestCode Ability request code. 1534 * @return Returns ERR_OK on success, others on failure. 1535 */ 1536 int32_t OpenLink(const Want& want, sptr<IRemoteObject> callerToken, int32_t userId, int requestCode); 1537 1538 /** 1539 * Terminate process by bundleName. 1540 * 1541 * @param missionId, The mission id of the UIAbility need to be terminated. 1542 * @return Returns ERR_OK on success, others on failure. 1543 */ 1544 ErrCode TerminateMission(int32_t missionId); 1545 1546 /** 1547 * update associate config list by rss. 1548 * 1549 * @param configs The rss config info. 1550 * @param exportConfigs The rss export config info. 1551 * @param flag UPDATE_CONFIG_FLAG_COVER is cover config, UPDATE_CONFIG_FLAG_APPEND is append config. 1552 */ 1553 ErrCode UpdateAssociateConfigList(const std::map<std::string, std::list<std::string>>& configs, 1554 const std::list<std::string>& exportConfigs, int32_t flag); 1555 1556 private: 1557 AbilityManagerClient(); 1558 DISALLOW_COPY_AND_MOVE(AbilityManagerClient); 1559 1560 class AbilityMgrDeathRecipient : public IRemoteObject::DeathRecipient { 1561 public: 1562 AbilityMgrDeathRecipient() = default; 1563 ~AbilityMgrDeathRecipient() = default; 1564 void OnRemoteDied(const wptr<IRemoteObject>& remote) override; 1565 private: 1566 DISALLOW_COPY_AND_MOVE(AbilityMgrDeathRecipient); 1567 }; 1568 1569 sptr<IAbilityManager> GetAbilityManager(); 1570 void ResetProxy(wptr<IRemoteObject> remote); 1571 void HandleDlpApp(Want &want); 1572 1573 static std::once_flag singletonFlag_; 1574 std::recursive_mutex mutex_; 1575 std::mutex topAbilityMutex_; 1576 static std::shared_ptr<AbilityManagerClient> instance_; 1577 sptr<IAbilityManager> proxy_; 1578 sptr<IRemoteObject::DeathRecipient> deathRecipient_; 1579 }; 1580 } // namespace AAFwk 1581 } // namespace OHOS 1582 #endif // OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_CLIENT_H 1583