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