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_SERVICE_H 17 #define OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_SERVICE_H 18 19 #include <cstdint> 20 #include <future> 21 #include <map> 22 #include <memory> 23 #include <shared_mutex> 24 #include <singleton.h> 25 #include <thread_ex.h> 26 #include <unordered_map> 27 28 #include "ability_auto_startup_service.h" 29 #include "ability_bundle_event_callback.h" 30 #include "ability_config.h" 31 #include "ability_connect_manager.h" 32 #include "ability_debug_deal.h" 33 #include "ability_event_handler.h" 34 #include "ability_info.h" 35 #include "ability_manager_event_subscriber.h" 36 #include "ability_manager_stub.h" 37 #include "ability_keep_alive_service.h" 38 #include "ability_start_with_wait_observer_utils.h" 39 #include "ams_configuration_parameter.h" 40 #include "app_debug_listener_interface.h" 41 #include "app_exit_reason_helper.h" 42 #include "app_mgr_interface.h" 43 #include "app_scheduler.h" 44 #include "auto_startup_info.h" 45 #ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE 46 #include "background_task_observer.h" 47 #endif 48 #include "bundle_constants.h" 49 #include "bundle_mgr_helper.h" 50 #include "data_ability_manager.h" 51 #include "deeplink_reserve/deeplink_reserve_config.h" 52 #include "event_report.h" 53 #include "free_install_manager.h" 54 #include "iacquire_share_data_callback_interface.h" 55 #include "interceptor/ability_interceptor_executer.h" 56 #include "iremote_object.h" 57 #include "mission_list_manager_interface.h" 58 #include "parameter.h" 59 #include "pending_want_manager.h" 60 #include "permission_verification.h" 61 #include "resident_process_manager.h" 62 #include "scene_board/ui_ability_lifecycle_manager.h" 63 #include "start_ability_handler.h" 64 #include "sub_managers_helper.h" 65 #include "system_ability.h" 66 #include "task_handler_wrap.h" 67 #include "uri.h" 68 #include "user_controller.h" 69 #include "intent_exemption_info.h" 70 #ifdef SUPPORT_GRAPHICS 71 #include "implicit_start_processor.h" 72 #include "system_dialog_scheduler.h" 73 #endif 74 #include "insight_intent_event_mgr.h" 75 #include "kiosk_manager.h" 76 77 namespace OHOS { 78 namespace AbilityRuntime { 79 class IStatusBarDelegate; 80 struct ExtractInsightIntentGenericInfo; 81 struct LinkIntentParamMapping; 82 } 83 namespace Rosen { 84 class FocusChangeInfo; 85 class WindowVisibilityInfo; 86 } 87 88 namespace AAFwk { 89 using AutoStartupInfo = AbilityRuntime::AutoStartupInfo; 90 enum class ServiceRunningState { STATE_NOT_START, STATE_RUNNING }; 91 constexpr int32_t BASE_USER_RANGE = 200000; 92 constexpr int32_t INVALID_USER_ID = -1; 93 constexpr const char* KEY_SESSION_ID = "com.ohos.param.sessionId"; 94 constexpr const char* KEY_REQUEST_ID = "com.ohos.param.requestId"; 95 using OHOS::AppExecFwk::IAbilityController; 96 struct StartAbilityInfo; 97 class WindowFocusChangedListener; 98 class WindowVisibilityChangedListener; 99 class PreloadManagerService; 100 class StartOptionsUtils; 101 102 /** 103 * @class AbilityManagerService 104 * AbilityManagerService provides a facility for managing ability life cycle. 105 */ 106 class AbilityManagerService : public SystemAbility, 107 public AbilityManagerStub, 108 public AppStateCallback, 109 public std::enable_shared_from_this<AbilityManagerService> { 110 DECLARE_DELAYED_SINGLETON(AbilityManagerService) 111 DECLEAR_SYSTEM_ABILITY(AbilityManagerService) 112 public: 113 friend class PreloadManagerService; 114 friend class StartOptionsUtils; 115 static std::shared_ptr<AbilityManagerService> GetPubInstance(); 116 117 void OnStart() override; 118 void OnStop() override; 119 120 virtual void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 121 122 virtual void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 123 124 ServiceRunningState QueryServiceState() const; 125 126 /** 127 * StartSelfUIAbility with want, start self uiability only on 2-in-1 devices. 128 * 129 * @param want, the want of the ability to start. 130 * @return Returns ERR_OK on success, others on failure. 131 */ 132 virtual int StartSelfUIAbility(const Want &want) override; 133 134 /** 135 * StartSelfUIAbility with want and startOptions, start self uiability only on 2-in-1 devices. 136 * 137 * @param want, the want of the ability to start. 138 * @param options, the startOptions of the ability to start. 139 * @return Returns ERR_OK on success, others on failure. 140 */ 141 virtual int StartSelfUIAbilityWithStartOptions(const Want &want, 142 const StartOptions &options) override; 143 144 /** 145 * StartAbility with want, send want to ability manager service. 146 * 147 * @param want, the want of the ability to start. 148 * @param requestCode, Ability request code. 149 * @param userId, Designation User ID. 150 * @return Returns ERR_OK on success, others on failure. 151 */ 152 virtual int StartAbility( 153 const Want &want, int32_t userId = DEFAULT_INVAL_VALUE, int requestCode = DEFAULT_INVAL_VALUE) override; 154 155 /** 156 * StartAbility with want, send want to ability manager service. 157 * 158 * @param want, the want of the ability to start. 159 * @param callerToken, caller ability token. 160 * @param userId, Designation User ID. 161 * @param requestCode the resultCode of the ability to start. 162 * @return Returns ERR_OK on success, others on failure. 163 */ 164 virtual int StartAbility( 165 const Want &want, 166 const sptr<IRemoteObject> &callerToken, 167 int32_t userId = DEFAULT_INVAL_VALUE, 168 int requestCode = DEFAULT_INVAL_VALUE) override; 169 170 /** 171 * StartAbilityWithSpecifyTokenIdInner with want and specialId, send want to ability manager service. 172 * 173 * @param want, the want of the ability to start. 174 * @param callerToken, caller ability token. 175 * @param specialId the caller Id. 176 * @param userId, Designation User ID. 177 * @param requestCode the resultCode of the ability to start. 178 * @return Returns ERR_OK on success, others on failure. 179 */ 180 int StartAbilityWithSpecifyTokenIdInner( 181 const Want &want, 182 const sptr<IRemoteObject> &callerToken, 183 uint32_t specifyTokenId, 184 bool isPendingWantCaller, 185 int32_t userId = DEFAULT_INVAL_VALUE, 186 int requestCode = DEFAULT_INVAL_VALUE); 187 188 /** 189 * Starts a new ability with specific start options and specialId, send want to ability manager service. 190 * 191 * @param want the want of the ability to start. 192 * @param startOptions Indicates the options used to start. 193 * @param callerToken caller ability token. 194 * @param userId Designation User ID. 195 * @param requestCode the resultCode of the ability to start. 196 * @param specifyTokenId The Caller ID. 197 * @return Returns ERR_OK on success, others on failure. 198 */ 199 int StartAbilityWithSpecifyTokenIdInner( 200 const Want &want, 201 const StartOptions &startOptions, 202 const sptr<IRemoteObject> &callerToken, 203 bool isPendingWantCaller, 204 int32_t userId = DEFAULT_INVAL_VALUE, 205 int requestCode = DEFAULT_INVAL_VALUE, 206 uint32_t specifyTokenId = 0); 207 208 /** 209 * StartAbilityWithSpecifyTokenId with want and specialId, send want to ability manager service. 210 * 211 * @param want, the want of the ability to start. 212 * @param callerToken, caller ability token. 213 * @param specialId the caller Id. 214 * @param userId, Designation User ID. 215 * @param requestCode the resultCode of the ability to start. 216 * @return Returns ERR_OK on success, others on failure. 217 */ 218 virtual int StartAbilityWithSpecifyTokenId( 219 const Want &want, 220 const sptr<IRemoteObject> &callerToken, 221 uint32_t specifyTokenId, 222 int32_t userId = DEFAULT_INVAL_VALUE, 223 int requestCode = DEFAULT_INVAL_VALUE) override; 224 225 /** 226 * StartAbility by insight intent, send want to ability manager service. 227 * 228 * @param want Ability want. 229 * @param callerToken caller ability token. 230 * @param intentId insight intent id. 231 * @param userId userId of target ability. 232 * @return Returns ERR_OK on success, others on failure. 233 */ 234 int32_t StartAbilityByInsightIntent( 235 const Want &want, 236 const sptr<IRemoteObject> &callerToken, 237 uint64_t intentId, 238 int32_t userId = DEFAULT_INVAL_VALUE) override; 239 240 /** 241 * Starts a new ability with specific start settings. 242 * 243 * @param want Indicates the ability to start. 244 * @param abilityStartSetting Indicates the setting ability used to start. 245 * @param callerToken, caller ability token. 246 * @param userId, Designation User ID. 247 * @param requestCode the resultCode of the ability to start. 248 * @return Returns ERR_OK on success, others on failure. 249 */ 250 virtual int StartAbility( 251 const Want &want, 252 const AbilityStartSetting &abilityStartSetting, 253 const sptr<IRemoteObject> &callerToken, 254 int32_t userId = DEFAULT_INVAL_VALUE, 255 int requestCode = DEFAULT_INVAL_VALUE) override; 256 257 /** 258 * Starts a new ability with specific start options. 259 * 260 * @param want the want of the ability to start. 261 * @param startOptions Indicates the options used to start. 262 * @param callerToken caller ability token. 263 * @param userId Designation User ID. 264 * @param requestCode the resultCode of the ability to start. 265 * @return Returns ERR_OK on success, others on failure. 266 */ 267 virtual int StartAbility( 268 const Want &want, 269 const StartOptions &startOptions, 270 const sptr<IRemoteObject> &callerToken, 271 int32_t userId = DEFAULT_INVAL_VALUE, 272 int requestCode = DEFAULT_INVAL_VALUE) override; 273 274 /** 275 * Starts a new ability using the original caller information. 276 * 277 * @param want the want of the ability to start. 278 * @param callerToken current caller ability token. 279 * @param asCallerSourceToken source caller ability token 280 * @param userId Designation User ID. 281 * @param requestCode the resultCode of the ability to start. 282 * @return Returns ERR_OK on success, others on failure. 283 */ 284 virtual int StartAbilityAsCaller( 285 const Want &want, 286 const sptr<IRemoteObject> &callerToken, 287 sptr<IRemoteObject> asCallerSourceToken, 288 int32_t userId = DEFAULT_INVAL_VALUE, 289 int requestCode = DEFAULT_INVAL_VALUE) override; 290 291 /** 292 * Starts a new ability using the original caller information. 293 * 294 * @param want the want of the ability to start. 295 * @param startOptions Indicates the options used to start. 296 * @param callerToken current caller ability token. 297 * @param asCallerSourceToken source caller ability token 298 * @param userId Designation User ID. 299 * @param requestCode the resultCode of the ability to start. 300 * @return Returns ERR_OK on success, others on failure. 301 */ 302 virtual int StartAbilityAsCaller( 303 const Want &want, 304 const StartOptions &startOptions, 305 const sptr<IRemoteObject> &callerToken, 306 sptr<IRemoteObject> asCallerSourceToken, 307 int32_t userId = DEFAULT_INVAL_VALUE, 308 int requestCode = DEFAULT_INVAL_VALUE) override; 309 310 /** 311 * Starts a new ability for result using the original caller information. 312 * 313 * @param want the want of the ability to start. 314 * @param callerToken current caller ability token. 315 * @param requestCode the resultCode of the ability to start. 316 * @param userId Designation User ID. 317 * @return Returns ERR_OK on success, others on failure. 318 */ 319 int StartAbilityForResultAsCaller( 320 const Want &want, 321 const sptr<IRemoteObject> &callerToken, 322 int requestCode = DEFAULT_INVAL_VALUE, 323 int32_t userId = DEFAULT_INVAL_VALUE) override; 324 325 /** 326 * Starts a new ability for result using the original caller information. 327 * 328 * @param want the want of the ability to start. 329 * @param startOptions Indicates the options used to start. 330 * @param callerToken current caller ability token. 331 * @param requestCode the resultCode of the ability to start. 332 * @param userId Designation User ID. 333 * @return Returns ERR_OK on success, others on failure. 334 */ 335 int StartAbilityForResultAsCaller( 336 const Want &want, 337 const StartOptions &startOptions, 338 const sptr<IRemoteObject> &callerToken, 339 int requestCode = DEFAULT_INVAL_VALUE, 340 int32_t userId = DEFAULT_INVAL_VALUE) override; 341 342 /** 343 * Start UI abilities simultaneously. 344 * 345 * @param wantList a list of want to start UI abilities. 346 * @param requestKey, The unique key of this StartUIAbilities request. 347 * @param callerToken current caller ability token. 348 * @return Returns ERR_OK if success. 349 */ 350 ErrCode StartUIAbilities(const std::vector<AAFwk::Want> &wantList, 351 const std::string &requestKey, sptr<IRemoteObject> callerToken) override; 352 353 /** 354 * Start ui session ability with extension session info, send session info to ability manager service. 355 * 356 * @param want, the want of the ability to start. 357 * @param callerToken caller ability token. 358 * @param sessionInfo the information of UIExtensionContentSession. 359 * @param userId, Designation User ID. 360 * @param requestCode, Ability request code. 361 * @return Returns ERR_OK on success, others on failure. 362 */ 363 virtual int StartAbilityByUIContentSession( 364 const Want &want, 365 const sptr<IRemoteObject> &callerToken, 366 const sptr<SessionInfo> &sessionInfo, 367 int32_t userId, 368 int requestCode) override; 369 370 /** 371 * Start ui session ability with extension session info, send session info to ability manager service. 372 * 373 * @param want, the want of the ability to start. 374 * @param startOptions Indicates the options used to start. 375 * @param callerToken, caller ability token. 376 * @param sessionInfo the information of UIExtensionContentSession. 377 * @param userId, Designation User ID. 378 * @param requestCode the resultCode of the ability to start. 379 * @return Returns ERR_OK on success, others on failure. 380 */ 381 virtual int StartAbilityByUIContentSession( 382 const Want &want, 383 const StartOptions &startOptions, 384 const sptr<IRemoteObject> &callerToken, 385 const sptr<SessionInfo> &sessionInfo, 386 int32_t userId, 387 int requestCode) override; 388 389 /** 390 * Start ui ability 391 * 392 * @param want the want of the ability to start. 393 * @param callerToken caller ability token. 394 * @param specifyTokenId The Caller ID. 395 * @return Returns ERR_OK on success, others on failure. 396 */ 397 virtual int StartAbilityOnlyUIAbility( 398 const Want &want, 399 const sptr<IRemoteObject> &callerToken, 400 uint32_t specifyTokenId) override; 401 402 /** 403 * Open link of ability and atomic service. 404 * 405 * @param want Ability want. 406 * @param callerToken Caller ability token. 407 * @param userId User ID. 408 * @param requestCode Ability request code. 409 * @return Returns ERR_OK on success, others on failure. 410 */ 411 virtual int32_t OpenLink(const Want& want, sptr<IRemoteObject> callerToken, 412 int32_t userId = DEFAULT_INVAL_VALUE, int32_t requestCode = DEFAULT_INVAL_VALUE) override; 413 414 /** 415 * Pop-up launch of full-screen atomic service. 416 * 417 * @param want The want with parameters. 418 * @param callerToken caller ability token. 419 * @param requestCode Ability request code. 420 * @param userId The User ID. 421 * @return Returns ERR_OK on success, others on failure. 422 */ 423 virtual int32_t OpenAtomicService(Want& want, const StartOptions &options, sptr<IRemoteObject> callerToken, 424 int32_t requestCode = DEFAULT_INVAL_VALUE, int32_t userId = DEFAULT_INVAL_VALUE) override; 425 426 /** 427 * @brief Querying whether to allow embedded startup of atomic service. 428 * 429 * @param token The caller UIAbility token. 430 * @param appId The ID of the application to which this bundle belongs. 431 * @return Returns true to allow ability to start, or false to reject. 432 */ 433 virtual bool IsEmbeddedOpenAllowed(sptr<IRemoteObject> callerToken, const std::string &appId) override; 434 435 /** 436 * Start extension ability with want, send want to ability manager service. 437 * 438 * @param want, the want of the ability to start. 439 * @param callerToken, caller ability token. 440 * @param userId, Designation User ID. 441 * @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started. 442 * @return Returns ERR_OK on success, others on failure. 443 */ 444 virtual int32_t StartExtensionAbility( 445 const Want &want, 446 const sptr<IRemoteObject> &callerToken, 447 int32_t userId = DEFAULT_INVAL_VALUE, 448 AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED) override; 449 450 /** 451 * Request modal UIExtension with want, send want to ability manager service. 452 * 453 * @param want, the want contains ability info about caller and called. 454 * @return Returns ERR_OK on success, others on failure. 455 */ 456 int RequestModalUIExtension(const Want &want) override; 457 458 int PreloadUIExtensionAbility(const Want &want, std::string &hostBundleName, 459 int32_t userId = DEFAULT_INVAL_VALUE, int32_t hostPid = DEFAULT_INVAL_VALUE) override; 460 461 int UnloadUIExtensionAbility(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord, std::string &bundleName); 462 463 int ChangeAbilityVisibility(sptr<IRemoteObject> token, bool isShow) override; 464 465 int ChangeUIAbilityVisibilityBySCB(sptr<SessionInfo> sessionInfo, bool isShow) override; 466 467 /** 468 * Start ui extension ability with extension session info, send extension session info to ability manager service. 469 * 470 * @param extensionSessionInfo the extension session info of the ability to start. 471 * @param userId, Designation User ID. 472 * @return Returns ERR_OK on success, others on failure. 473 */ 474 virtual int StartUIExtensionAbility( 475 const sptr<SessionInfo> &extensionSessionInfo, 476 int32_t userId = DEFAULT_INVAL_VALUE) override; 477 478 /** 479 * Start ui ability with want, send want to ability manager service. 480 * 481 * @param sessionInfo the session info of the ability to start. 482 * @param isColdStart the session info of the ability is or not cold start. 483 * @return Returns ERR_OK on success, others on failure. 484 */ 485 virtual int StartUIAbilityBySCB(sptr<SessionInfo> sessionInfo, bool &isColdStart, uint32_t sceneFlag = 0) override; 486 487 /** 488 * Stop extension ability with want, send want to ability manager service. 489 * 490 * @param want, the want of the ability to stop. 491 * @param callerToken, caller ability token. 492 * @param userId, Designation User ID. 493 * @param extensionType If an ExtensionAbilityType is set, only extension of that type can be stopped. 494 * @return Returns ERR_OK on success, others on failure. 495 */ 496 virtual int StopExtensionAbility( 497 const Want& want, 498 const sptr<IRemoteObject>& callerToken, 499 int32_t userId = DEFAULT_INVAL_VALUE, 500 AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED) override; 501 502 /** 503 * TerminateAbility, terminate the special ability. 504 * 505 * @param token, the token of the ability to terminate. 506 * @param resultCode, the resultCode of the ability to terminate. 507 * @param resultWant, the Want of the ability to return. 508 * @return Returns ERR_OK on success, others on failure. 509 */ 510 virtual int TerminateAbility(const sptr<IRemoteObject> &token, int resultCode = DEFAULT_INVAL_VALUE, 511 const Want *resultWant = nullptr) override; 512 513 /** 514 * TerminateUIServiceExtensionAbility, terminate the UIServiceExtensionAbility. 515 * 516 * @param token, the token of the ability to terminate. 517 * @return Returns ERR_OK on success, others on failure. 518 */ 519 virtual int32_t TerminateUIServiceExtensionAbility(const sptr<IRemoteObject> &token) override; 520 521 /** 522 * BackToCallerAbilityWithResult, return to the caller ability. 523 * 524 * @param token, the token of the ability to terminate. 525 * @param resultCode, the resultCode of the ability to terminate. 526 * @param resultWant, the Want of the ability to return. 527 * @param callerRequestCode, the requestCode of caller ability. 528 * @return Returns ERR_OK on success, others on failure. 529 */ 530 virtual int BackToCallerAbilityWithResult(const sptr<IRemoteObject> &token, int resultCode, 531 const Want *resultWant, int64_t callerRequestCode) override; 532 533 /** 534 * TerminateAbility, terminate the special ui extension ability. 535 * 536 * @param extensionSessionInfo the extension session info of the ability to terminate. 537 * @param resultCode, the resultCode of the ui extension ability to terminate. 538 * @param resultWant, the Want of the ui extension ability to return. 539 * @return Returns ERR_OK on success, others on failure. 540 */ 541 virtual int TerminateUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo, 542 int resultCode = DEFAULT_INVAL_VALUE, const Want *resultWant = nullptr) override; 543 544 /** 545 * CloseUIExtensionAbilityBySCB, terminate the specified ui extension ability by SCB. 546 * 547 * @param token the ability token. 548 * @return Returns ERR_OK on success, others on failure. 549 */ 550 int CloseUIExtensionAbilityBySCB(const sptr<IRemoteObject> token) override; 551 552 /** 553 * CloseUIAbilityBySCB, close the special ability by scb. 554 * 555 * @param sessionInfo the session info of the ability to terminate. 556 * @param sceneFlag the reason info of the ability to terminate. 557 * @return Returns ERR_OK on success, others on failure. 558 */ 559 virtual int CloseUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool isUserRequestedExit, 560 uint32_t sceneFlag = 0) override; 561 562 /** 563 * SendResultToAbility with want, return want from ability manager service. 564 * 565 * @param requestCode, request code. 566 * @param resultCode, resultCode to return. 567 * @param resultWant, the Want of the ability to return. 568 * @return Returns ERR_OK on success, others on failure. 569 */ 570 virtual int SendResultToAbility(int32_t requestCode, int32_t resultCode, Want& resultWant) override; 571 572 /** 573 * MoveAbilityToBackground. 574 * 575 * @param token, the token of the ability to move background. 576 * @return Returns ERR_OK on success, others on failure. 577 */ 578 virtual int MoveAbilityToBackground(const sptr<IRemoteObject> &token) override; 579 580 /** 581 * Move the UIAbility to background, called by app self. 582 * 583 * @param token the token of the ability to move. 584 * @return Returns ERR_OK on success, others on failure. 585 */ 586 virtual int32_t MoveUIAbilityToBackground(const sptr<IRemoteObject> token) override; 587 588 /** 589 * CloseAbility, close the special ability. 590 * 591 * @param token, the token of the ability to terminate. 592 * @param resultCode, the resultCode of the ability to terminate. 593 * @param resultWant, the Want of the ability to return. 594 * @return Returns ERR_OK on success, others on failure. 595 */ 596 virtual int CloseAbility(const sptr<IRemoteObject> &token, int resultCode = DEFAULT_INVAL_VALUE, 597 const Want *resultWant = nullptr) override; 598 599 /** 600 * MinimizeAbility, minimize the special ability. 601 * 602 * @param token, ability token. 603 * @param fromUser mark the minimize operation source. 604 * @return Returns ERR_OK on success, others on failure. 605 */ 606 virtual int MinimizeAbility(const sptr<IRemoteObject> &token, bool fromUser = false) override; 607 608 /** 609 * MinimizeUIExtensionAbility, minimize the special ui extension ability. 610 * 611 * @param extensionSessionInfo the extension session info of the ability to minimize. 612 * @param fromUser mark the minimize operation source. 613 * @return Returns ERR_OK on success, others on failure. 614 */ 615 virtual int MinimizeUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo, 616 bool fromUser = false) override; 617 618 /** 619 * MinimizeUIAbilityBySCB, minimize the special ability by scb. 620 * 621 * @param sessionInfo the extension session info of the ability to minimize. 622 * @param fromUser, Whether form user. 623 * @return Returns ERR_OK on success, others on failure. 624 */ 625 virtual int MinimizeUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool fromUser = false, 626 uint32_t sceneFlag = 0) override; 627 628 /** 629 * ConnectAbility, connect session with service ability. 630 * 631 * @param want, Special want for service type's ability. 632 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 633 * @param callerToken, caller ability token. 634 * @param userId, Designation User ID. 635 * @return Returns ERR_OK on success, others on failure. 636 */ 637 virtual int32_t ConnectAbility( 638 const Want &want, 639 const sptr<IAbilityConnection> &connect, 640 const sptr<IRemoteObject> &callerToken, 641 int32_t userId = DEFAULT_INVAL_VALUE) override; 642 643 virtual int32_t ConnectAbilityCommon( 644 const Want &want, 645 const sptr<IAbilityConnection> &connect, 646 const sptr<IRemoteObject> &callerToken, 647 AppExecFwk::ExtensionAbilityType extensionType, 648 int32_t userId = DEFAULT_INVAL_VALUE, 649 bool isQueryExtensionOnly = false) override; 650 651 virtual int ConnectUIExtensionAbility( 652 const Want &want, 653 const sptr<IAbilityConnection> &connect, 654 const sptr<SessionInfo> &sessionInfo, 655 int32_t userId = DEFAULT_INVAL_VALUE, 656 sptr<UIExtensionAbilityConnectInfo> connectInfo = nullptr) override; 657 658 /** 659 * ContinueMission, continue ability from mission center. 660 * 661 * @param srcDeviceId, origin deviceId. 662 * @param dstDeviceId, target deviceId. 663 * @param missionId, indicates which ability to continue. 664 * @param callBack, notify result back. 665 * @param wantParams, extended params. 666 * @return Returns ERR_OK on success, others on failure. 667 */ 668 virtual int ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId, 669 int32_t missionId, const sptr<IRemoteObject> &callBack, AAFwk::WantParams &wantParams) override; 670 671 /** 672 * ContinueMission, continue ability from mission center. 673 * 674 * @param srcDeviceId, origin deviceId. 675 * @param dstDeviceId, target deviceId. 676 * @param bundleName, indicates which ability to continue. 677 * @param callBack, notify result back. 678 * @param wantParams, extended params. 679 * @return Returns ERR_OK on success, others on failure. 680 */ 681 virtual int ContinueMission(AAFwk::ContinueMissionInfo continueMissionInfo, 682 const sptr<IRemoteObject> &callback) override; 683 684 /** 685 * ContinueAbility, continue ability to ability. 686 * 687 * @param deviceId, target deviceId. 688 * @param missionId, indicates which ability to continue. 689 * @param versionCode, target bundle version. 690 * @return Returns ERR_OK on success, others on failure. 691 */ 692 virtual int ContinueAbility(const std::string &deviceId, int32_t missionId, uint32_t versionCode) override; 693 694 /** 695 * StartContinuation, continue ability to remote. 696 * 697 * @param want, Indicates the ability to start. 698 * @param abilityToken, Caller ability token. 699 * @param status, continue status. 700 * @return Returns ERR_OK on success, others on failure. 701 */ 702 virtual int StartContinuation(const Want &want, const sptr<IRemoteObject> &abilityToken, int32_t status) override; 703 704 /** 705 * NotifyCompleteContinuation, notify continuation complete to dms. 706 * @param deviceId, source device which start a continuation. 707 * @param sessionId, represent a continuation. 708 * @param isSuccess, continuation result. 709 * @return 710 */ 711 virtual void NotifyCompleteContinuation(const std::string &deviceId, int32_t sessionId, bool isSuccess) override; 712 713 /** 714 * NotifyContinuationResult, notify continue result to ability. 715 * 716 * @param missionId, Caller mission id. 717 * @param result, continuation result. 718 * @return Returns ERR_OK on success, others on failure. 719 */ 720 virtual int NotifyContinuationResult(int32_t missionId, int32_t result) override; 721 722 /** 723 * RegisterMissionListener, register remote device mission listener. 724 * 725 * @param deviceId, Indicates the remote device Id. 726 * @param listener, listener. 727 * @return Returns ERR_OK on success, others on failure. 728 */ 729 virtual int RegisterMissionListener(const std::string &deviceId, 730 const sptr<IRemoteMissionListener> &listener) override; 731 732 /** 733 * RegisterOnListener, register on notify mission listener. 734 * 735 * @param type, Indicates the notify type. 736 * @param listener, listener. 737 * @return Returns ERR_OK on success, others on failure. 738 */ 739 virtual int RegisterOnListener(const std::string &type, 740 const sptr<IRemoteOnListener> &listener) override; 741 742 /** 743 * RegisterOffListener, register on notify mission listener. 744 * 745 * @param type, Indicates the notify type. 746 * @param listener, listener. 747 * @return Returns ERR_OK on success, others on failure. 748 */ 749 virtual int RegisterOffListener(const std::string &type, 750 const sptr<IRemoteOnListener> &listener) override; 751 752 /** 753 * UnRegisterMissionListener, unregister remote device mission listener. 754 * 755 * @param deviceId, Indicates the remote device Id. 756 * @param listener, listener. 757 * @return Returns ERR_OK on success, others on failure. 758 */ 759 virtual int UnRegisterMissionListener(const std::string &deviceId, 760 const sptr<IRemoteMissionListener> &listener)override; 761 762 virtual int DisconnectAbility(sptr<IAbilityConnection> connect) override; 763 764 virtual int32_t SuspendExtensionAbility(sptr<IAbilityConnection> connect) override; 765 766 virtual int32_t ResumeExtensionAbility(sptr<IAbilityConnection> connect) override; 767 768 /** 769 * AcquireDataAbility, acquire a data ability by its authority, if it not existed, 770 * AMS loads it synchronously. 771 * 772 * @param uri, data ability uri. 773 * @param tryBind, true: when a data ability is died, ams will kill this client, or do nothing. 774 * @param callerToken, specifies the caller ability token. 775 * @return returns the data ability ipc object, or nullptr for failed. 776 */ 777 virtual sptr<IAbilityScheduler> AcquireDataAbility( 778 const Uri &uri, bool tryBind, const sptr<IRemoteObject> &callerToken) override; 779 780 /** 781 * ReleaseDataAbility, release the data ability that referenced by 'dataAbilityToken'. 782 * 783 * @param dataAbilityToken, specifies the data ability that will be released. 784 * @param callerToken, specifies the caller ability token. 785 * @return returns ERR_OK if succeeded, or error codes for failed. 786 */ 787 virtual int ReleaseDataAbility( 788 sptr<IAbilityScheduler> dataAbilityScheduler, const sptr<IRemoteObject> &callerToken) override; 789 790 /** 791 * AttachAbilityThread, ability call this interface after loaded. 792 * 793 * @param scheduler,.the interface handler of kit ability. 794 * @param token,.ability's token. 795 * @return Returns ERR_OK on success, others on failure. 796 */ 797 virtual int AttachAbilityThread( 798 const sptr<IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token) override; 799 800 /** 801 * AbilityTransitionDone, ability call this interface after lift cycle was changed. 802 * 803 * @param token,.ability's token. 804 * @param state,.the state of ability lift cycle. 805 * @return Returns ERR_OK on success, others on failure. 806 */ 807 virtual int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData) override; 808 809 /** 810 * AbilityWindowConfigTransitionDone, ability call this interface after lift cycle was changed. 811 * 812 * @param token,.ability's token. 813 * @return Returns ERR_OK on success, others on failure. 814 */ 815 virtual int AbilityWindowConfigTransitionDone( 816 const sptr<IRemoteObject> &token, const WindowConfig &windowConfig) override; 817 818 /** 819 * ScheduleConnectAbilityDone, service ability call this interface while session was connected. 820 * 821 * @param token,.service ability's token. 822 * @param remoteObject,.the session proxy of service ability. 823 * @return Returns ERR_OK on success, others on failure. 824 */ 825 virtual int ScheduleConnectAbilityDone( 826 const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &remoteObject) override; 827 828 /** 829 * ScheduleDisconnectAbilityDone, service ability call this interface while session was disconnected. 830 * 831 * @param token,.service ability's token. 832 * @return Returns ERR_OK on success, others on failure. 833 */ 834 virtual int ScheduleDisconnectAbilityDone(const sptr<IRemoteObject> &token) override; 835 836 /** 837 * ScheduleCommandAbilityDone, service ability call this interface while session was commanded. 838 * 839 * @param token,.service ability's token. 840 * @return Returns ERR_OK on success, others on failure. 841 */ 842 virtual int ScheduleCommandAbilityDone(const sptr<IRemoteObject> &token) override; 843 844 virtual int ScheduleCommandAbilityWindowDone( 845 const sptr<IRemoteObject> &token, 846 const sptr<SessionInfo> &sessionInfo, 847 WindowCommand winCmd, 848 AbilityCommand abilityCmd) override; 849 850 /** 851 * Request to clean UIAbility from user. 852 * 853 * @param sessionInfo the session info of the ability to clean. 854 * @param sceneFlag the reason info of the ability to terminate. 855 * @return Returns ERR_OK on success, others on failure. 856 */ 857 virtual int32_t CleanUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool isUserRequestedExit, 858 uint32_t sceneFlag = 0) override; 859 GetTaskHandler()860 std::shared_ptr<TaskHandlerWrap> GetTaskHandler() const 861 { 862 return taskHandler_; 863 } 864 865 /** 866 * GetEventHandler, get the ability manager service's handler. 867 * 868 * @return Returns AbilityEventHandler ptr. 869 */ 870 std::shared_ptr<AbilityEventHandler> GetEventHandler(); 871 872 /** 873 * @brief Ability hidump. 874 * @param fd Indicates the fd. 875 * @param args Indicates the params. 876 * @return Returns the dump result. 877 */ 878 int Dump(int fd, const std::vector<std::u16string>& args) override; 879 880 /** 881 * dump ability stack info, about userID, mission stack info, 882 * mission record info and ability info. 883 * 884 * @param state Ability stack info. 885 * @return Returns ERR_OK on success, others on failure. 886 */ 887 virtual void DumpState(const std::string &args, std::vector<std::string> &info) override; 888 virtual void DumpSysState( 889 const std::string& args, std::vector<std::string>& info, bool isClient, bool isUserID, int UserID) override; 890 891 /** 892 * Destroys this Service ability by Want. 893 * 894 * @param want, Special want for service type's ability. 895 * @param token ability's token. 896 * @return Returns true if this Service ability will be destroyed; returns false otherwise. 897 */ 898 virtual int StopServiceAbility(const Want &want, int32_t userId = DEFAULT_INVAL_VALUE, 899 const sptr<IRemoteObject> &token = nullptr) override; 900 901 /** 902 * Kill the process immediately. 903 * 904 * @param bundleName. 905 * @return Returns ERR_OK on success, others on failure. 906 */ 907 virtual int KillProcess(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = 0) override; 908 909 /** 910 * Uninstall app 911 * 912 * @param bundleName bundle name of uninstalling app. 913 * @param uid uid of bundle. 914 * @return Returns ERR_OK on success, others on failure. 915 */ 916 virtual int UninstallApp(const std::string &bundleName, int32_t uid) override; 917 918 /** 919 * Uninstall app 920 * 921 * @param bundleName bundle name of uninstalling app. 922 * @param uid uid of bundle. 923 * @param appIndex the app index of app clone. 924 * @return Returns ERR_OK on success, others on failure. 925 */ 926 virtual int32_t UninstallApp(const std::string &bundleName, int32_t uid, int32_t appIndex) override; 927 928 /** 929 * Upgrade app, record exit reason and kill application 930 * 931 * @param bundleName bundle name of upgrading app. 932 * @param uid uid of bundle. 933 * @param exitMsg the exit reason message. 934 * @param appIndex the app index of app clone. 935 * @return Returns ERR_OK on success, others on failure. 936 */ 937 virtual int32_t UpgradeApp(const std::string &bundleName, const int32_t uid, const std::string &exitMsg, 938 int32_t appIndex = 0) override; 939 940 virtual sptr<IWantSender> GetWantSender( 941 const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t uid = -1) override; 942 943 virtual int SendWantSender(sptr<IWantSender> target, SenderInfo &senderInfo) override; 944 945 virtual int SendLocalWantSender(const SenderInfo &senderInfo) override; 946 947 virtual void CancelWantSender(const sptr<IWantSender> &sender) override; 948 949 virtual int GetPendingWantUid(const sptr<IWantSender> &target) override; 950 951 virtual int GetPendingWantUserId(const sptr<IWantSender> &target) override; 952 953 virtual std::string GetPendingWantBundleName(const sptr<IWantSender> &target) override; 954 955 virtual int GetPendingWantCode(const sptr<IWantSender> &target) override; 956 957 virtual int GetPendingWantType(const sptr<IWantSender> &target) override; 958 959 virtual void RegisterCancelListener(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver) override; 960 961 virtual void UnregisterCancelListener( 962 const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver) override; 963 964 virtual int GetPendingRequestWant(const sptr<IWantSender> &target, std::shared_ptr<Want> &want) override; 965 966 virtual int GetWantSenderInfo(const sptr<IWantSender> &target, std::shared_ptr<WantSenderInfo> &info) override; 967 968 virtual int RegisterObserver(const sptr<AbilityRuntime::IConnectionObserver> &observer) override; 969 970 virtual int UnregisterObserver(const sptr<AbilityRuntime::IConnectionObserver> &observer) override; 971 972 #ifdef WITH_DLP 973 virtual int GetDlpConnectionInfos(std::vector<AbilityRuntime::DlpConnectionInfo> &infos) override; 974 #endif // WITH_DLP 975 976 virtual int GetConnectionData(std::vector<AbilityRuntime::ConnectionData> &connectionData) override; 977 978 virtual void CancelWantSenderByFlags(const sptr<IWantSender> &sender, uint32_t flags) override; 979 980 virtual int LockMissionForCleanup(int32_t missionId) override; 981 982 virtual int UnlockMissionForCleanup(int32_t missionId) override; 983 984 virtual void SetLockedState(int32_t sessionId, bool lockedState) override; 985 986 virtual int RegisterMissionListener(const sptr<IMissionListener> &listener) override; 987 988 virtual int UnRegisterMissionListener(const sptr<IMissionListener> &listener) override; 989 990 virtual int GetMissionInfos(const std::string& deviceId, int32_t numMax, 991 std::vector<MissionInfo> &missionInfos) override; 992 993 virtual int GetMissionInfo(const std::string& deviceId, int32_t missionId, 994 MissionInfo &missionInfo) override; 995 996 virtual int CleanMission(int32_t missionId) override; 997 998 virtual int CleanAllMissions() override; 999 1000 virtual int MoveMissionToFront(int32_t missionId) override; 1001 1002 virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override; 1003 1004 virtual int MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId) override; 1005 1006 virtual int MoveMissionsToBackground(const std::vector<int32_t>& missionIds, 1007 std::vector<int32_t>& result) override; 1008 1009 virtual int32_t GetMissionIdByToken(const sptr<IRemoteObject> &token) override; 1010 1011 void GetAbilityTokenByCalleeObj(const sptr<IRemoteObject> &callStub, sptr<IRemoteObject> &token) override; 1012 1013 virtual int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override; 1014 1015 virtual int StopSyncRemoteMissions(const std::string& devId) override; 1016 1017 virtual int GetAppMemorySize() override; 1018 1019 virtual bool IsRamConstrainedDevice() override; 1020 1021 virtual int StartAbilityByCall(const Want &want, const sptr<IAbilityConnection> &connect, 1022 const sptr<IRemoteObject> &callerToken, int32_t accountId = DEFAULT_INVAL_VALUE, 1023 bool isSilent = false) override; 1024 1025 virtual int StartAbilityByCallWithErrMsg(const Want &want, const sptr<IAbilityConnection> &connect, 1026 const sptr<IRemoteObject> &callerToken, int32_t accountId, std::string &errMsg, 1027 bool isSilent = false) override; 1028 1029 /** 1030 * As abilityRequest is prepared, just execute starting ability procedure. 1031 * By now, this is only used by start_ability_sandbox_savefile. 1032 * @param abilityRequest, Prepared with all info for starting a ability. 1033 * @param validUserId, Valid user id. 1034 */ 1035 int StartAbilityJust(AbilityRequest &abilityRequest, int32_t validUserId); 1036 1037 /** 1038 * CallRequestDone, after invoke callRequest, ability will call this interface to return callee. 1039 * 1040 * @param token, ability's token. 1041 * @param callStub, ability's callee. 1042 */ 1043 void CallRequestDone(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &callStub) override; 1044 1045 /** 1046 * Release the call between Ability, disconnect session with common ability. 1047 * 1048 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 1049 * @param element, the element of target service. 1050 * @return Returns ERR_OK on success, others on failure. 1051 */ 1052 virtual int ReleaseCall( 1053 const sptr<IAbilityConnection> &connect, const AppExecFwk::ElementName &element) override; 1054 1055 std::list<std::shared_ptr<ConnectionRecord>> GetConnectRecordListByCallback(sptr<IAbilityConnection> callback); 1056 1057 void OnAbilityDied(std::shared_ptr<AbilityRecord> abilityRecord); 1058 void OnCallConnectDied(std::shared_ptr<CallRecord> callRecord); 1059 void HandleLoadTimeOut(int64_t abilityRecordId, bool isHalf = false, bool isExtension = false); 1060 void HandleActiveTimeOut(int64_t abilityRecordId); 1061 void HandleInactiveTimeOut(int64_t abilityRecordId); 1062 void HandleForegroundTimeOut(int64_t abilityRecordId, bool isHalf = false, bool isExtension = false); 1063 void HandleConnectTimeOut(int64_t abilityRecordId, bool isHalf = false); 1064 void HandleShareDataTimeOut(int64_t uniqueId); 1065 int32_t GetShareDataPairAndReturnData(std::shared_ptr<AbilityRecord> abilityRecord, 1066 const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam); 1067 1068 int32_t StartAbilityByFreeInstall(const Want &want, sptr<IRemoteObject> callerToken, int32_t userId, 1069 int32_t requestCode); 1070 1071 int StartAbilityWrap( 1072 const Want &want, 1073 const sptr<IRemoteObject> &callerToken, 1074 int requestCode, 1075 bool isPendingWantCaller, 1076 int32_t userId = DEFAULT_INVAL_VALUE, 1077 bool isStartAsCaller = false, 1078 uint32_t specifyTokenId = 0, 1079 bool isForegroundToRestartApp = false, 1080 bool isImplicit = false, 1081 bool isUIAbilityOnly = false); 1082 1083 int StartAbilityInner( 1084 const Want &want, 1085 const sptr<IRemoteObject> &callerToken, 1086 int requestCode, 1087 bool isPendingWantCaller, 1088 int32_t userId = DEFAULT_INVAL_VALUE, 1089 bool isStartAsCaller = false, 1090 uint32_t specifyTokenId = 0, 1091 bool isForegroundToRestartApp = false, 1092 bool isImplicit = false, 1093 bool isUIAbilityOnly = false); 1094 1095 int32_t StartExtensionAbilityInner( 1096 const Want &want, 1097 const sptr<IRemoteObject> &callerToken, 1098 int32_t userId, 1099 AppExecFwk::ExtensionAbilityType extensionType, 1100 bool checkSystemCaller = true, 1101 bool isImplicit = false, 1102 bool isDlp = false, 1103 bool isStartAsCaller = false); 1104 1105 int RequestModalUIExtensionInner(Want want); 1106 1107 int PreloadUIExtensionAbilityInner(const Want &want, std::string &bundleName, 1108 int32_t userId = DEFAULT_INVAL_VALUE, int32_t hostPid = DEFAULT_INVAL_VALUE); 1109 1110 int StartAbilityForOptionWrap( 1111 const Want &want, 1112 const StartOptions &startOptions, 1113 const sptr<IRemoteObject> &callerToken, 1114 bool isPendingWantCaller, 1115 int32_t userId = DEFAULT_INVAL_VALUE, 1116 int requestCode = DEFAULT_INVAL_VALUE, 1117 bool isStartAsCaller = false, 1118 uint32_t callerTokenId = 0, 1119 bool isImplicit = false, 1120 bool isCallByShortcut = false); 1121 1122 int StartAbilityForOptionInner( 1123 const Want &want, 1124 const StartOptions &startOptions, 1125 const sptr<IRemoteObject> &callerToken, 1126 bool isPendingWantCaller, 1127 int32_t userId = DEFAULT_INVAL_VALUE, 1128 int requestCode = DEFAULT_INVAL_VALUE, 1129 bool isStartAsCaller = false, 1130 uint32_t specifyTokenId = 0, 1131 bool isImplicit = false, 1132 bool isCallByShortcut = false); 1133 1134 int ImplicitStartAbility( 1135 const Want &want, 1136 const AbilityStartSetting &abilityStartSetting, 1137 const sptr<IRemoteObject> &callerToken, 1138 int32_t userId = DEFAULT_INVAL_VALUE, 1139 int requestCode = DEFAULT_INVAL_VALUE); 1140 1141 int StartAbilityDetails( 1142 const Want &want, 1143 const AbilityStartSetting &abilityStartSetting, 1144 const sptr<IRemoteObject> &callerToken, 1145 int32_t userId = DEFAULT_INVAL_VALUE, 1146 int requestCode = DEFAULT_INVAL_VALUE, 1147 bool isImplicit = false); 1148 1149 int ImplicitStartAbility( 1150 const Want &want, 1151 const StartOptions &startOptions, 1152 const sptr<IRemoteObject> &callerToken, 1153 int32_t userId = DEFAULT_INVAL_VALUE, 1154 int requestCode = DEFAULT_INVAL_VALUE); 1155 1156 int ImplicitStartExtensionAbility( 1157 const Want &want, 1158 const sptr<IRemoteObject> &callerToken, 1159 int32_t userId = DEFAULT_INVAL_VALUE, 1160 AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED); 1161 1162 int StartAbilityAsCallerDetails( 1163 const Want &want, 1164 const sptr<IRemoteObject> &callerToken, 1165 sptr<IRemoteObject> asCallerSourceToken, 1166 int32_t userId = DEFAULT_INVAL_VALUE, 1167 int requestCode = DEFAULT_INVAL_VALUE, 1168 bool isImplicit = false); 1169 1170 int ImplicitStartAbilityAsCaller( 1171 const Want &want, 1172 const sptr<IRemoteObject> &callerToken, 1173 sptr<IRemoteObject> asCallerSourceToken, 1174 int32_t userId = DEFAULT_INVAL_VALUE, 1175 int requestCode = DEFAULT_INVAL_VALUE); 1176 1177 void OnAcceptWantResponse(const AAFwk::Want &want, const std::string &flag, int32_t requestId); 1178 void OnStartSpecifiedAbilityTimeoutResponse(int32_t requestId); 1179 1180 void OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId = 0, 1181 const std::string &callerProcessName = ""); 1182 void OnStartSpecifiedProcessTimeoutResponse(int32_t requestId); 1183 void OnStartSpecifiedFailed(int32_t requestId); 1184 1185 virtual int GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info) override; 1186 virtual int GetExtensionRunningInfos(int upperLimit, std::vector<ExtensionRunningInfo> &info) override; 1187 virtual int GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> &info) override; 1188 virtual int GetAllIntentExemptionInfo(std::vector<AppExecFwk::IntentExemptionInfo> &info) override; 1189 int GetProcessRunningInfosByUserId(std::vector<AppExecFwk::RunningProcessInfo> &info, int32_t userId); 1190 void GetAbilityRunningInfo(std::vector<AbilityRunningInfo> &info, std::shared_ptr<AbilityRecord> &abilityRecord); 1191 void GetExtensionRunningInfo(std::shared_ptr<AbilityRecord> &abilityRecord, const int32_t userId, 1192 std::vector<ExtensionRunningInfo> &info); 1193 1194 int GetMissionSaveTime() const; 1195 1196 /** 1197 * generate ability request. 1198 * 1199 */ 1200 int GenerateAbilityRequest( 1201 const Want &want, 1202 int requestCode, 1203 AbilityRequest &request, 1204 const sptr<IRemoteObject> &callerToken, 1205 int32_t userId); 1206 1207 /** 1208 * Get mission id by target ability token. 1209 * 1210 * @param token target ability token. 1211 * @return the missionId of target mission. 1212 */ 1213 int32_t GetMissionIdByAbilityToken(const sptr<IRemoteObject> &token); 1214 1215 /** 1216 * Get ability token by target mission id. 1217 * 1218 * @param missionId target missionId. 1219 * @return the ability token of target mission. 1220 */ 1221 sptr<IRemoteObject> GetAbilityTokenByMissionId(int32_t missionId); 1222 1223 virtual int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery = false) override; 1224 1225 virtual int StopUser(int userId, const sptr<IUserCallback> &callback) override; 1226 1227 virtual int LogoutUser(int32_t userId, sptr<IUserCallback> callback) override; 1228 1229 /** 1230 * Called when client complete dump. 1231 * 1232 * @param infos The dump info. 1233 * @param callerToken The caller ability token. 1234 * @return Returns ERR_OK on success, others on failure. 1235 */ 1236 virtual int DumpAbilityInfoDone(std::vector<std::string> &infos, const sptr<IRemoteObject> &callerToken) override; 1237 1238 virtual int SetMissionContinueState(const sptr<IRemoteObject> &abilityToken, 1239 const AAFwk::ContinueState &state) override; 1240 1241 #ifdef SUPPORT_SCREEN 1242 virtual int SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label) override; 1243 1244 virtual int SetMissionIcon(const sptr<IRemoteObject> &token, 1245 const std::shared_ptr<OHOS::Media::PixelMap> &icon) override; 1246 1247 virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler, 1248 bool animationEnabled) override; 1249 1250 virtual void CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken) override; 1251 1252 virtual void CompleteFirstFrameDrawing(int32_t sessionId) override; 1253 1254 sptr<IWindowManagerServiceHandler> GetWMSHandler() const; 1255 1256 virtual int PrepareTerminateAbility(const sptr<IRemoteObject> &token, 1257 sptr<IPrepareTerminateCallback> &callback) override; 1258 1259 void HandleFocused(const sptr<OHOS::Rosen::FocusChangeInfo> &focusChangeInfo); 1260 1261 void HandleUnfocused(const sptr<OHOS::Rosen::FocusChangeInfo> &focusChangeInfo); 1262 1263 void HandleWindowVisibilityChanged( 1264 const std::vector<sptr<OHOS::Rosen::WindowVisibilityInfo>> &windowVisibilityInfos); 1265 1266 virtual int GetDialogSessionInfo(const std::string &dialogSessionId, 1267 sptr<DialogSessionInfo> &dialogSessionInfo) override; 1268 1269 virtual int SendDialogResult(const Want &want, const std::string &dialogSessionId, bool isAllowed) override; 1270 1271 int CreateCloneSelectorDialog(AbilityRequest &request, int32_t userId, const std::string &replaceWantString = ""); 1272 1273 void RemoveSelectorIdentity(int32_t tokenId); 1274 1275 virtual int RegisterAbilityFirstFrameStateObserver(const sptr<IAbilityFirstFrameStateObserver> &observer, 1276 const std::string &bundleName) override; 1277 1278 virtual int UnregisterAbilityFirstFrameStateObserver( 1279 const sptr<IAbilityFirstFrameStateObserver> &observer) override; 1280 1281 bool GetAnimationFlag(); 1282 1283 #endif 1284 1285 void ClearUserData(int32_t userId); 1286 1287 /** 1288 * notify callers disconnect abilities before clearUserData 1289 * or can not find connectManager_ by userId when onAbilityDied. 1290 * 1291 * @param userId userId. 1292 */ 1293 void DisconnectBeforeCleanupByUserId(int32_t userId); 1294 1295 virtual int RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler) override; 1296 1297 virtual int32_t GetMissionSnapshot(const std::string& deviceId, int32_t missionId, 1298 MissionSnapshot& snapshot, bool isLowResolution) override; 1299 1300 /** 1301 * Set ability controller. 1302 * 1303 * @param abilityController, The ability controller. 1304 * @return Returns ERR_OK on success, others on failure. 1305 */ 1306 virtual int SetAbilityController(const sptr<IAbilityController> &abilityController, bool imAStabilityTest) override; 1307 1308 /** 1309 * Is user a stability test. 1310 * 1311 * @return Returns true if user is a stability test. 1312 */ 1313 virtual bool IsRunningInStabilityTest() override; 1314 1315 virtual int StartUserTest(const Want &want, const sptr<IRemoteObject> &observer) override; 1316 1317 virtual int FinishUserTest( 1318 const std::string &msg, const int64_t &resultCode, const std::string &bundleName) override; 1319 1320 /** 1321 * GetTopAbility, get the token of top ability. 1322 * 1323 * @param token, the token of top ability. 1324 * @return Returns ERR_OK on success, others on failure. 1325 */ 1326 virtual int GetTopAbility(sptr<IRemoteObject> &token) override; 1327 1328 virtual int CheckUIExtensionIsFocused(uint32_t uiExtensionTokenId, bool& isFocused) override; 1329 1330 /** 1331 * The delegator calls this interface to move the ability to the foreground. 1332 * 1333 * @param token, ability's token. 1334 * @return Returns ERR_OK on success, others on failure. 1335 */ 1336 virtual int DelegatorDoAbilityForeground(const sptr<IRemoteObject> &token) override; 1337 1338 /** 1339 * The delegator calls this interface to move the ability to the background. 1340 * 1341 * @param token, ability's token. 1342 * @return Returns ERR_OK on success, others on failure. 1343 */ 1344 virtual int DelegatorDoAbilityBackground(const sptr<IRemoteObject> &token) override; 1345 1346 /** 1347 * Calls this interface to move the ability to the foreground. 1348 * 1349 * @param token, ability's token. 1350 * @param flag, use for lock or unlock flag and so on. 1351 * @return Returns ERR_OK on success, others on failure. 1352 */ 1353 virtual int DoAbilityForeground(const sptr<IRemoteObject> &token, uint32_t flag) override; 1354 1355 /** 1356 * Calls this interface to move the ability to the background. 1357 * 1358 * @param token, ability's token. 1359 * @param flag, use for lock or unlock flag and so on. 1360 * @return Returns ERR_OK on success, others on failure. 1361 */ 1362 virtual int DoAbilityBackground(const sptr<IRemoteObject> &token, uint32_t flag) override; 1363 1364 bool IsAbilityControllerStart(const Want &want, const std::string &bundleName); 1365 1366 bool IsAbilityControllerForeground(const std::string &bundleName); 1367 1368 bool IsAbilityControllerStartById(int32_t missionId); 1369 1370 #ifdef ABILITY_COMMAND_FOR_TEST 1371 /** 1372 * force timeout ability. 1373 * 1374 * @param abilityName. 1375 * @param state. 1376 * @return Returns ERR_OK on success, others on failure. 1377 */ 1378 virtual int ForceTimeoutForTest(const std::string &abilityName, const std::string &state) override; 1379 #endif 1380 1381 bool GetDataAbilityUri(const std::vector<AppExecFwk::AbilityInfo> &abilityInfos, 1382 const std::string &mainAbility, std::string &uri); 1383 1384 virtual AppExecFwk::ElementName GetTopAbility(bool isNeedLocalDeviceId = true) override; 1385 1386 virtual AppExecFwk::ElementName GetElementNameByToken(sptr<IRemoteObject> token, 1387 bool isNeedLocalDeviceId = true) override; 1388 1389 /** 1390 * AtomicServiceStatusCallback OnInstallFinished callback. 1391 * 1392 * @param resultCode FreeInstall result code. 1393 * @param want Want has been installed. 1394 * @param userId User id. 1395 */ 1396 void OnInstallFinished(int resultCode, const Want &want, int32_t userId); 1397 1398 /** 1399 * AtomicServiceStatusCallback OnRemoteInstallFinished callback. 1400 * 1401 * @param resultCode FreeInstall result code. 1402 * @param want Want has been installed. 1403 * @param userId User id. 1404 */ 1405 void OnRemoteInstallFinished(int resultCode, const Want &want, int32_t userId); 1406 1407 /** 1408 * FreeInstall form remote call. 1409 * 1410 * @param want Want need to install. 1411 * @param callback DMS callback. 1412 * @param userId User id. 1413 * @param requestCode Ability request code. 1414 * @return Returns ERR_OK on success, others on failure. 1415 */ 1416 virtual int FreeInstallAbilityFromRemote(const Want &want, const sptr<IRemoteObject> &callback, 1417 int32_t userId, int requestCode = DEFAULT_INVAL_VALUE) override; 1418 1419 /** 1420 * Add FreeInstall Observer 1421 * 1422 * @param observer the observer of ability free install start. 1423 * @return Returns ERR_OK on success, others on failure. 1424 */ 1425 virtual int AddFreeInstallObserver(const sptr<IRemoteObject> &callerToken, 1426 const sptr<AbilityRuntime::IFreeInstallObserver> &observer) override; 1427 1428 /** 1429 * Check the uid is background task uid. 1430 * 1431 * @param uid userId. 1432 * @return Returns whether the uid is background task uid. 1433 */ 1434 bool IsBackgroundTaskUid(const int uid); 1435 1436 bool GetLocalDeviceId(std::string& localDeviceId); 1437 1438 int JudgeAbilityVisibleControl(const AppExecFwk::AbilityInfo &abilityInfo); 1439 1440 /** 1441 * Called to update mission snapshot. 1442 * @param token The target ability. 1443 * @param pixelMap The snapshot. 1444 */ 1445 #ifdef SUPPORT_SCREEN 1446 virtual void UpdateMissionSnapShot(const sptr<IRemoteObject> &token, 1447 const std::shared_ptr<Media::PixelMap> &pixelMap) override; 1448 #endif // SUPPORT_SCREEN 1449 virtual void EnableRecoverAbility(const sptr<IRemoteObject>& token) override; 1450 virtual void SubmitSaveRecoveryInfo(const sptr<IRemoteObject>& token) override; 1451 virtual void ScheduleRecoverAbility(const sptr<IRemoteObject> &token, int32_t reason, 1452 const Want *want = nullptr) override; 1453 1454 virtual void ScheduleClearRecoveryPageStack() override; 1455 1456 /** 1457 * Called to verify that the MissionId is valid. 1458 * @param missionIds Query mission list. 1459 * @param results Output parameters, return results up to 20 query results. 1460 * @return Returns ERR_OK on success, others on failure. 1461 */ 1462 int32_t IsValidMissionIds( 1463 const std::vector<int32_t> &missionIds, std::vector<MissionValidResult> &results) override; 1464 1465 virtual int32_t RequestDialogService(const Want &want, const sptr<IRemoteObject> &callerToken) override; 1466 1467 int32_t ReportDrawnCompleted(const sptr<IRemoteObject> &callerToken) override; 1468 1469 virtual int32_t AcquireShareData( 1470 const int32_t &missionId, const sptr<IAcquireShareDataCallback> &shareData) override; 1471 virtual int32_t ShareDataDone(const sptr<IRemoteObject>& token, 1472 const int32_t &requestCode, const int32_t &uniqueId, WantParams &wantParam) override; 1473 1474 bool GetStartUpNewRuleFlag() const; 1475 1476 std::shared_ptr<AbilityRecord> GetFocusAbility(); 1477 1478 /** 1479 * Query whether the application of the specified PID and UID has been granted a certain permission 1480 * @param permission 1481 * @param pid Process id 1482 * @param uid 1483 * @return Returns ERR_OK if the current process has the permission, others on failure. 1484 */ 1485 virtual int VerifyPermission(const std::string &permission, int pid, int uid) override; 1486 1487 bool IsDmsAlive() const; 1488 1489 /** 1490 * Upgrade app completed event. 1491 * @param uid. 1492 */ 1493 void AppUpgradeCompleted(int32_t uid); 1494 1495 /** 1496 * Record app exit reason. 1497 * @param exitReason The reason of app exit. 1498 * @return Returns ERR_OK on success, others on failure. 1499 */ 1500 virtual int32_t RecordAppExitReason(const ExitReason &exitReason) override; 1501 1502 /** 1503 * Force app exit and record exit reason. 1504 * @param pid Process id . 1505 * @param exitReason The reason of app exit. 1506 * @return Returns ERR_OK on success, others on failure. 1507 */ 1508 virtual int32_t ForceExitApp(const int32_t pid, const ExitReason &exitReason) override; 1509 1510 /** 1511 * Record the process exit reason before the process being killed. 1512 * @param pid The process id. 1513 * @param exitReason The reason of process exit. 1514 * @return Returns ERR_OK on success, others on failure. 1515 */ 1516 virtual int32_t RecordProcessExitReason(const int32_t pid, const ExitReason &exitReason) override; 1517 1518 /** 1519 * Record the exit reason of a killed process. 1520 * @param pid The process id. 1521 * @param uid The process uid. 1522 * @param exitReason The reason of process exit. 1523 * @return Returns ERR_OK on success, others on failure. 1524 */ 1525 virtual int32_t RecordProcessExitReason(int32_t pid, int32_t uid, const ExitReason &exitReason) override; 1526 1527 int32_t GetConfiguration(AppExecFwk::Configuration& config); 1528 1529 /** 1530 * Set rootSceneSession by SCB. 1531 * 1532 * @param rootSceneSession Indicates root scene session of SCB. 1533 */ 1534 virtual void SetRootSceneSession(const sptr<IRemoteObject> &rootSceneSession) override; 1535 1536 /** 1537 * Call UIAbility by SCB. 1538 * 1539 * @param sessionInfo the session info of the ability to be called. 1540 * @param isColdStart the session of the ability is or not cold start. 1541 */ 1542 virtual void CallUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool &isColdStart) override; 1543 1544 virtual int32_t StartSpecifiedAbilityBySCB(const Want &want) override; 1545 1546 /** 1547 * Notify sandbox app the result of saving file. 1548 * @param want Result of saving file, which contains the file's uri if success. 1549 * @param resultCode Indicates the action's result. 1550 * @param requestCode Pass the requestCode to match request. 1551 * @return Returns ERR_OK on success, others on failure. 1552 */ 1553 virtual int32_t NotifySaveAsResult(const Want &want, int resultCode, int requestCode) override; 1554 1555 /** 1556 * Set sessionManagerService 1557 * @param sessionManagerService the point of sessionManagerService. 1558 * 1559 * @return Returns ERR_OK on success, others on failure. 1560 */ 1561 virtual int32_t SetSessionManagerService(const sptr<IRemoteObject> &sessionManagerService) override; 1562 1563 /** 1564 * @brief Register collaborator. 1565 * @param type collaborator type. 1566 * @param impl collaborator. 1567 * @return 0 or else. 1568 */ 1569 virtual int32_t RegisterIAbilityManagerCollaborator( 1570 int32_t type, const sptr<IAbilityManagerCollaborator> &impl) override; 1571 1572 /** 1573 * @brief Unregister collaborator. 1574 * @param type collaborator type. 1575 * @return 0 or else. 1576 */ 1577 virtual int32_t UnregisterIAbilityManagerCollaborator(int32_t type) override; 1578 1579 /** 1580 * @brief get ability manager collaborator. 1581 * @return Returns object pointer on success, others on null. 1582 */ 1583 virtual sptr<IAbilityManagerCollaborator> GetAbilityManagerCollaborator() override; 1584 1585 /** 1586 * @brief Get collaborator. 1587 * @param type collaborator type. 1588 * @return nullptr or IAbilityManagerCollaborator stpr. 1589 */ 1590 sptr<IAbilityManagerCollaborator> GetCollaborator(int32_t type); 1591 1592 /** 1593 * get the user id. 1594 * 1595 */ 1596 int32_t GetUserId() const; 1597 1598 virtual int32_t RegisterStatusBarDelegate(sptr<AbilityRuntime::IStatusBarDelegate> delegate) override; 1599 1600 virtual int32_t KillProcessWithPrepareTerminate(const std::vector<int32_t>& pids) override; 1601 1602 virtual int32_t KillProcessWithReason(int32_t pid, const ExitReason &reason) override; 1603 1604 /** 1605 * @brief Register auto start up callback for system api. 1606 * @param callback The point of JsAbilityAutoStartupCallBack. 1607 * @return Returns ERR_OK on success, others on failure. 1608 */ 1609 virtual int32_t RegisterAutoStartupSystemCallback(const sptr<IRemoteObject> &callback) override; 1610 1611 /** 1612 * @brief Unregister auto start up callback for system api. 1613 * @param callback The point of JsAbilityAutoStartupCallBack. 1614 * @return Returns ERR_OK on success, others on failure. 1615 */ 1616 virtual int32_t UnregisterAutoStartupSystemCallback(const sptr<IRemoteObject> &callback) override; 1617 1618 /** 1619 * @brief Set every application auto start up state. 1620 * @param info The auto startup info,include bundle name, module name, ability name. 1621 * @return Returns ERR_OK on success, others on failure. 1622 */ 1623 virtual int32_t SetApplicationAutoStartup(const AutoStartupInfo &info) override; 1624 1625 /** 1626 * @brief Cancel every application auto start up . 1627 * @param info The auto startup info,include bundle name, module name, ability name. 1628 * @return Returns ERR_OK on success, others on failure. 1629 */ 1630 virtual int32_t CancelApplicationAutoStartup(const AutoStartupInfo &info) override; 1631 1632 /** 1633 * @brief Query auto startup state all application. 1634 * @param infoList Output parameters, return auto startup info list. 1635 * @return Returns ERR_OK on success, others on failure. 1636 */ 1637 virtual int32_t QueryAllAutoStartupApplications(std::vector<AutoStartupInfo> &infoList) override; 1638 1639 /** 1640 * PrepareTerminateAbilityBySCB, prepare to terminate ability by scb. 1641 * 1642 * @param sessionInfo the session info of the ability to start. 1643 * @param isTerminate the result of ability onPrepareToTerminate. 1644 * @return Returns ERR_OK on success, others on failure. 1645 */ 1646 virtual int PrepareTerminateAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool &isTerminate) override; 1647 1648 /** 1649 * @brief Register app debug listener. 1650 * @param listener App debug listener. 1651 * @return Returns ERR_OK on success, others on failure. 1652 */ 1653 int32_t RegisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener) override; 1654 1655 /** 1656 * @brief Unregister app debug listener. 1657 * @param listener App debug listener. 1658 * @return Returns ERR_OK on success, others on failure. 1659 */ 1660 int32_t UnregisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener) override; 1661 1662 /** 1663 * @brief Attach app debug. 1664 * @param bundleName The application bundle name. 1665 * @return Returns ERR_OK on success, others on failure. 1666 */ 1667 int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) override; 1668 1669 /** 1670 * @brief Detach app debug. 1671 * @param bundleName The application bundle name. 1672 * @return Returns ERR_OK on success, others on failure. 1673 */ 1674 int32_t DetachAppDebug(const std::string &bundleName, bool isDebugFromLocal) override; 1675 1676 /** 1677 * @brief Execute intent. 1678 * @param key The key of intent executing client. 1679 * @param callerToken Caller ability token. 1680 * @param param The Intent execute param. 1681 * @return Returns ERR_OK on success, others on failure. 1682 */ 1683 int32_t ExecuteIntent(uint64_t key, const sptr<IRemoteObject> &callerToken, 1684 const InsightIntentExecuteParam ¶m) override; 1685 1686 /** 1687 * @brief Execute intent. 1688 * @param abilityRequest The abilityRequest. 1689 */ 1690 int32_t OnExecuteIntent(AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &targetRecord); 1691 1692 int32_t StartAbilityWithInsightIntent(const Want &want, int32_t userId = DEFAULT_INVAL_VALUE, 1693 int requestCode = DEFAULT_INVAL_VALUE); 1694 1695 int32_t StartAbilityByCallWithInsightIntent(const Want &want, const sptr<IRemoteObject> &callerToken, 1696 const InsightIntentExecuteParam ¶m); 1697 1698 /** 1699 * @brief Check if ability controller can start. 1700 * @param want The want of ability to start. 1701 * @return Return true to allow ability to start, or false to reject. 1702 */ 1703 virtual bool IsAbilityControllerStart(const Want &want) override; 1704 1705 /** 1706 * @brief Called when insight intent execute finished. 1707 * 1708 * @param token ability's token. 1709 * @param intentId insight intent id. 1710 * @param result insight intent execute result. 1711 * @return Returns ERR_OK on success, others on failure. 1712 */ 1713 int32_t ExecuteInsightIntentDone(const sptr<IRemoteObject> &token, uint64_t intentId, 1714 const InsightIntentExecuteResult &result) override; 1715 1716 /** 1717 * @brief Open file by uri. 1718 * @param uri The file uri. 1719 * @param flag Want::FLAG_AUTH_READ_URI_PERMISSION or Want::FLAG_AUTH_WRITE_URI_PERMISSION. 1720 * @return int The file descriptor. 1721 */ 1722 virtual int32_t OpenFile(const Uri& uri, uint32_t flag) override; 1723 1724 void RemoveLauncherDeathRecipient(int32_t userId); 1725 /** 1726 * @brief Set application auto start up state by EDM. 1727 * @param info The auto startup info, include bundle name, module name, ability name. 1728 * @param flag Indicate whether the application is prohibited from changing the auto start up state. 1729 * @return Returns ERR_OK on success, others on failure. 1730 */ 1731 int32_t SetApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag) override; 1732 1733 /** 1734 * @brief Cancel application auto start up state by EDM. 1735 * @param info The auto startup info, include bundle name, module name, ability name. 1736 * @param flag Indicate whether the application is prohibited from changing the auto start up state. 1737 * @return Returns ERR_OK on success, others on failure. 1738 */ 1739 int32_t CancelApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag) override; 1740 1741 /** 1742 * @brief Get foreground ui abilities. 1743 * @param list Foreground ui abilities. 1744 * @return Returns ERR_OK on success, others on failure. 1745 */ 1746 int32_t GetForegroundUIAbilities(std::vector<AppExecFwk::AbilityStateData> &list) override; 1747 1748 /** 1749 * @brief Update session info. 1750 * @param sessionInfos The vector of session info. 1751 */ 1752 virtual int32_t UpdateSessionInfoBySCB(std::list<SessionInfo> &sessionInfos, int32_t userId, 1753 std::vector<int32_t> &sessionIds) override; 1754 1755 /** 1756 * @brief Restart app self. 1757 * @param want The ability type must be UIAbility. 1758 * @param isAppRecovery True indicates that the app is restarted because of recovery. 1759 * @return Returns ERR_OK on success, others on failure. 1760 */ 1761 int32_t RestartApp(const AAFwk::Want &want, bool isAppRecovery = false) override; 1762 1763 /** 1764 * @brief Get host info of root caller. 1765 * 1766 * @param token The ability token. 1767 * @param hostInfo The host info of root caller. 1768 * @param userId The user id. 1769 * @return int32_t Returns ERR_OK on success, others on failure. 1770 */ 1771 int32_t GetUIExtensionRootHostInfo(const sptr<IRemoteObject> token, UIExtensionHostInfo &hostInfo, 1772 int32_t userId = DEFAULT_INVAL_VALUE) override; 1773 1774 /** 1775 * @brief Get ui extension session info 1776 * 1777 * @param token The ability token. 1778 * @param uiExtensionSessionInfo The ui extension session info. 1779 * @param userId The user id. 1780 * @return int32_t Returns ERR_OK on success, others on failure. 1781 */ 1782 int32_t GetUIExtensionSessionInfo(const sptr<IRemoteObject> token, UIExtensionSessionInfo &uiExtensionSessionInfo, 1783 int32_t userId = DEFAULT_INVAL_VALUE) override; 1784 1785 /** 1786 * Set the enable status for starting and stopping resident processes. 1787 * The caller application can only set the resident status of the configured process. 1788 * @param bundleName The bundle name of the resident process. 1789 * @param enable Set resident process enable status. 1790 * @return Returns ERR_OK on success, others on failure. 1791 */ 1792 int32_t SetResidentProcessEnabled(const std::string &bundleName, bool enable) override; 1793 1794 /** 1795 * @brief Request to display assert fault dialog. 1796 * @param callback Listen for user operation callbacks. 1797 * @param wantParams Assert dialog box display information. 1798 * @return Returns ERR_OK on success, others on failure. 1799 */ 1800 virtual int32_t RequestAssertFaultDialog( 1801 const sptr<IRemoteObject> &callback, const AAFwk::WantParams &wantParams) override; 1802 1803 /** 1804 * @brief Notify the operation status of the user. 1805 * @param assertFaultSessionId Indicates the request ID of AssertFault. 1806 * @param userStatus Operation status of the user. 1807 * @return Returns ERR_OK on success, others on failure. 1808 */ 1809 virtual int32_t NotifyDebugAssertResult(uint64_t assertFaultSessionId, AAFwk::UserStatus userStatus) override; 1810 1811 /** 1812 * Starts a new ability with specific start options. 1813 * 1814 * @param want, the want of the ability to start. 1815 * @param startOptions Indicates the options used to start. 1816 * @return Returns ERR_OK on success, others on failure. 1817 */ 1818 virtual int32_t StartShortcut(const Want &want, const StartOptions &startOptions) override; 1819 1820 /** 1821 * Get ability state by persistent id. 1822 * 1823 * @param persistentId, the persistentId of the session. 1824 * @param state Indicates the ability state. 1825 * @return Returns ERR_OK on success, others on failure. 1826 */ 1827 virtual int32_t GetAbilityStateByPersistentId(int32_t persistentId, bool &state) override; 1828 1829 /** 1830 * Transfer resultCode & want to ability manager service. 1831 * 1832 * @param callerToken Caller ability token. 1833 * @param requestCode The resultCode of the ability to start. 1834 * @param want Indicates the ability to start. 1835 * @return Returns ERR_OK on success, others on failure. 1836 */ 1837 virtual int32_t TransferAbilityResultForExtension(const sptr<IRemoteObject> &callerToken, int32_t resultCode, 1838 const Want &want) override; 1839 1840 std::shared_ptr<MissionListManagerInterface> GetMissionListManagerByUserId(int32_t userId); 1841 std::shared_ptr<MissionListWrap> GetMissionListWrap(); 1842 1843 /** 1844 * Notify ability manager service frozen process. 1845 * 1846 * @param pidList, the pid list of the frozen process. 1847 * @param uid, the uid of the frozen process. 1848 */ 1849 virtual void NotifyFrozenProcessByRSS(const std::vector<int32_t> &pidList, int32_t uid) override; 1850 1851 /** 1852 * Open atomic service window prior to finishing free install. 1853 * 1854 * @param bundleName, the bundle name of the atomic service. 1855 * @param moduleName, the module name of the atomic service. 1856 * @param abilityName, the ability name of the atomic service. 1857 * @param startTime, the starting time of the free install task. 1858 * @return Returns ERR_OK on success, others on failure. 1859 */ 1860 virtual int32_t PreStartMission(const std::string& bundleName, const std::string& moduleName, 1861 const std::string& abilityName, const std::string& startTime) override; 1862 1863 int32_t StartUIAbilityByPreInstall(const FreeInstallInfo &taskInfo); 1864 1865 void NotifySCBToHandleAtomicServiceException(const std::string& sessionId, int errCode, 1866 const std::string& reason); 1867 1868 void HandleRestartResidentProcessDependedOnWeb(); 1869 1870 int32_t TerminateMission(int32_t missionId) override; 1871 1872 int32_t UpdateAssociateConfigList(const std::map<std::string, std::list<std::string>>& configs, 1873 const std::list<std::string>& exportConfigs, int32_t flag) override; 1874 1875 int32_t BlockAllAppStart(bool flag) override; 1876 1877 int SetWantForSessionInfo(sptr<SessionInfo> sessionInfo); 1878 1879 int32_t StartUIAbilityBySCBDefaultCommon(AbilityRequest &abilityRequest, sptr<SessionInfo> sessionInfo, 1880 uint32_t sceneFlag, bool &isColdStart); 1881 1882 int32_t NotifySCBToRecoveryAfterInterception(const AbilityRequest &abilityRequest); 1883 1884 /** 1885 * Judge if Caller-Application is in background state. 1886 * 1887 * @param abilityRequest, abilityRequest. 1888 * @param isBackgroundCall, Indicates the Caller-Application state. 1889 * TRUE: The Caller-Application is not in focus and not in foreground state. 1890 * FALSE: The Caller-Application is in focus or in foreground state. 1891 * @return Returns ERR_OK on check success, others on check failure. 1892 */ 1893 int IsCallFromBackground(const AbilityRequest &abilityRequest, bool &isBackgroundCall, bool isData = false); 1894 1895 void EnableListForSCBRecovery(int32_t userId) const; 1896 1897 int32_t UpdateKeepAliveEnableState(const std::string &bundleName, const std::string &moduleName, 1898 const std::string &mainElement, bool updateEnable, int32_t userId); 1899 1900 bool IsInStatusBar(uint32_t accessTokenId, int32_t uid, bool isMultiInstance); 1901 1902 bool IsSupportStatusBar(int32_t uid); 1903 1904 bool IsSceneBoardReady(int32_t userId); 1905 1906 /** 1907 * Set keep-alive flag for application under a specific user. 1908 * @param bundleName Bundle name. 1909 * @param userId User Id. 1910 * @param flag Keep-alive flag. 1911 * @return Returns ERR_OK on success, others on failure. 1912 */ 1913 virtual int32_t SetApplicationKeepAlive(const std::string &bundleName, int32_t userId, bool flag) override; 1914 1915 /** 1916 * Get keep-alive applications by EDM. 1917 * @param appType Application type. 1918 * @param userId User Id. 1919 * @param list List of Keep-alive information. 1920 * @return Returns ERR_OK on success, others on failure. 1921 */ 1922 virtual int32_t QueryKeepAliveApplications(int32_t appType, int32_t userId, 1923 std::vector<KeepAliveInfo> &list) override; 1924 1925 /** 1926 * Set keep-alive flag for application under a specific user by EDM. 1927 * @param bundleName Bundle name. 1928 * @param userId User Id. 1929 * @param flag Keep-alive flag. 1930 * @return Returns ERR_OK on success, others on failure. 1931 */ 1932 virtual int32_t SetApplicationKeepAliveByEDM(const std::string &bundleName, int32_t userId, 1933 bool flag, bool isAllowUserToCancel = false) override; 1934 1935 /** 1936 * Get keep-alive applications by EDM. 1937 * @param appType Application type. 1938 * @param userId User Id. 1939 * @param list List of Keep-alive information. 1940 * @return Returns ERR_OK on success, others on failure. 1941 */ 1942 virtual int32_t QueryKeepAliveApplicationsByEDM(int32_t appType, int32_t userId, 1943 std::vector<KeepAliveInfo> &list) override; 1944 1945 /** 1946 * Add query ERMS observer. 1947 * 1948 * @param callerToken, The caller ability token. 1949 * @param observer, The observer of the ability to query ERMS. 1950 * @return Returns ERR_OK on success, others on failure. 1951 */ 1952 virtual int32_t AddQueryERMSObserver(sptr<IRemoteObject> callerToken, 1953 sptr<AbilityRuntime::IQueryERMSObserver> observer) override; 1954 1955 /** 1956 * Query atomic service ERMS rule. 1957 * 1958 * @param callerToken, The caller ability token. 1959 * @param appId, The appId of the atomic service. 1960 * @param startTime, The startTime of the query. 1961 * @param rule, The returned ERMS rule. 1962 * @return Returns ERR_OK on success, others on failure. 1963 */ 1964 virtual int32_t QueryAtomicServiceStartupRule(sptr<IRemoteObject> callerToken, 1965 const std::string &appId, const std::string &startTime, AtomicServiceStartupRule &rule) override; 1966 1967 /** 1968 * Restart atomic service. 1969 * 1970 * @param callerToken, The caller ability token. 1971 * @return Returns ERR_OK on success, others on failure. 1972 */ 1973 virtual int32_t RestartSelfAtomicService(sptr<IRemoteObject> callerToken) override; 1974 1975 int StartUIAbilityForOptionWrap(const Want &want, const StartOptions &options, sptr<IRemoteObject> callerToken, 1976 bool isPendingWantCaller, int32_t userId, int requestCode, uint32_t callerTokenId = 0, bool isImplicit = false, 1977 bool isCallByShortcut = false); 1978 1979 /** 1980 * PrepareTerminateAbilityDone, called when PrepareTerminateAbility call is done. 1981 * 1982 * @param token, the token of the ability to terminate. 1983 * @param callback callback. 1984 */ 1985 virtual void PrepareTerminateAbilityDone(const sptr<IRemoteObject> &token, bool isTerminate) override; 1986 1987 /** 1988 * KillProcessForPermissionUpdate, call KillProcessForPermissionUpdate() through proxy object, 1989 * force kill the application by accessTokenId, notify exception to SCB. 1990 * 1991 * @param accessTokenId, accessTokenId. 1992 * @return ERR_OK, return back success, others fail. 1993 */ 1994 virtual int32_t KillProcessForPermissionUpdate(uint32_t accessTokenId) override; 1995 1996 /** 1997 * KillProcessWithPrepareTerminateDone, called when KillProcessWithPrepareTerminate call is done. 1998 * 1999 * @param moduleName, the module name of the application. 2000 * @param prepareTermination, the result of prepareTermination call of the module. 2001 * @param isExist, whether the prepareTerminate functions are implemented. 2002 */ 2003 virtual void KillProcessWithPrepareTerminateDone(const std::string &moduleName, 2004 int32_t prepareTermination, bool isExist) override; GetAppExitReasonHelper()2005 std::shared_ptr<AppExitReasonHelper> GetAppExitReasonHelper() 2006 { 2007 return appExitReasonHelper_; 2008 } 2009 2010 /** 2011 * Register hidden start observer. 2012 * @param observer, ability token. 2013 * @return Returns ERR_OK on success, others on failure. 2014 */ 2015 virtual int32_t RegisterHiddenStartObserver(const sptr<IHiddenStartObserver> &observer) override; 2016 2017 /** 2018 * Unregister hidden start observer. 2019 * @param observer, ability token. 2020 * @return Returns ERR_OK on success, others on failure. 2021 */ 2022 virtual int32_t UnregisterHiddenStartObserver(const sptr<IHiddenStartObserver> &observer) override; 2023 2024 /** 2025 * Query preload uiextension record. 2026 * 2027 * @param element, The uiextension ElementName. 2028 * @param moduleName, The uiextension moduleName. 2029 * @param hostBundleName, The uiextension caller hostBundleName. 2030 * @param recordNum, The returned count of uiextension. 2031 * @param userId, The User Id. 2032 * @return Returns ERR_OK on success, others on failure. 2033 */ 2034 virtual int32_t QueryPreLoadUIExtensionRecord(const AppExecFwk::ElementName &element, 2035 const std::string &moduleName, 2036 const std::string &hostBundleName, 2037 int32_t &recordNum, 2038 int32_t userId = DEFAULT_INVAL_VALUE) override; 2039 2040 /** 2041 * Revoke delegator. 2042 * 2043 * @param token, ability token. 2044 * @return Returns ERR_OK on success, others on failure. 2045 */ 2046 virtual int32_t RevokeDelegator(sptr<IRemoteObject> token) override; 2047 2048 virtual int32_t SetOnNewWantSkipScenarios(sptr<IRemoteObject> callerToken, int32_t scenarios) override; 2049 2050 virtual int32_t StartAbilityWithWait(Want &want, sptr<IAbilityStartWithWaitObserver> &observer) override; 2051 2052 /** 2053 * Get all insight intent infos. 2054 * @param flag, the get type. 2055 * @param infos, the insight intent infos. 2056 * @return Returns ERR_OK on success, others on failure. 2057 */ 2058 virtual int32_t GetAllInsightIntentInfo( 2059 AbilityRuntime::GetInsightIntentFlag flag, 2060 std::vector<InsightIntentInfoForQuery> &infos) override; 2061 2062 /** 2063 * Get specified bundleName insight intent infos. 2064 * @param flag, the get type. 2065 * @param infos, the insight intent infos. 2066 * @param bundleName, The get insightIntent bundleName. 2067 * @return Returns ERR_OK on success, others on failure. 2068 */ 2069 virtual int32_t GetInsightIntentInfoByBundleName( 2070 AbilityRuntime::GetInsightIntentFlag flag, 2071 const std::string &bundleName, 2072 std::vector<InsightIntentInfoForQuery> &infos) override; 2073 2074 /** 2075 * Get specified intentName insight intent infos. 2076 * @param flag, the get type. 2077 * @param infos, the insight intent infos. 2078 * @param bundleName, The get insightIntent bundleName. 2079 * @param moduleName, The get insightIntent moduleName. 2080 * @param intentName, The get intent name. 2081 * @return Returns ERR_OK on success, others on failure. 2082 */ 2083 virtual int32_t GetInsightIntentInfoByIntentName( 2084 AbilityRuntime::GetInsightIntentFlag flag, 2085 const std::string &bundleName, 2086 const std::string &moduleName, 2087 const std::string &intentName, 2088 InsightIntentInfoForQuery &info) override; 2089 2090 int32_t UpdateKioskApplicationList(const std::vector<std::string> &appList) override; 2091 2092 int32_t EnterKioskMode(sptr<IRemoteObject> callerToken) override; 2093 2094 int32_t ExitKioskMode(sptr<IRemoteObject> callerToken) override; 2095 2096 int32_t GetKioskStatus(AAFwk::KioskStatus &kioskStatus) override; 2097 2098 std::shared_ptr<AbilityInterceptorExecuter> GetAbilityInterceptorExecuter(); 2099 2100 /** 2101 * Register sa interceptor. 2102 * @param interceptor, The sa interceptor. 2103 * @return Returns ERR_OK on success, others on failure. 2104 */ 2105 virtual int32_t RegisterSAInterceptor(sptr<AbilityRuntime::ISAInterceptor> interceptor) override; 2106 2107 /** 2108 * Set keep-alive flag for app service extension under u1 user. 2109 * @param bundleName Bundle name. 2110 * @param flag Keep-alive flag. 2111 * @return Returns ERR_OK on success, others on failure. 2112 */ 2113 virtual int32_t SetAppServiceExtensionKeepAlive(const std::string &bundleName, bool flag) override; 2114 2115 /** 2116 * Get keep-alive app service extensions. 2117 * @param list List of Keep-alive information. 2118 * @return Returns ERR_OK on success, others on failure. 2119 */ 2120 virtual int32_t QueryKeepAliveAppServiceExtensions(std::vector<KeepAliveInfo> &list) override; 2121 2122 virtual int32_t NotifyStartupExceptionBySCB(int32_t requestId) override; 2123 2124 /** 2125 * Preload application. 2126 * @param bundleName Name of the application. 2127 * @param userId user id. 2128 * @param appIndex app clone index. 2129 * @return Returns ERR_OK on success, others on failure. 2130 */ 2131 virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId, int32_t appIndex) override; 2132 2133 // MSG 0 - 20 represents timeout message 2134 static constexpr uint32_t LOAD_TIMEOUT_MSG = 0; 2135 static constexpr uint32_t ACTIVE_TIMEOUT_MSG = 1; 2136 static constexpr uint32_t INACTIVE_TIMEOUT_MSG = 2; 2137 static constexpr uint32_t TERMINATE_TIMEOUT_MSG = 4; 2138 static constexpr uint32_t FOREGROUND_TIMEOUT_MSG = 5; 2139 static constexpr uint32_t BACKGROUND_TIMEOUT_MSG = 6; 2140 static constexpr uint32_t SHAREDATA_TIMEOUT_MSG = 7; 2141 static constexpr uint32_t LOAD_HALF_TIMEOUT_MSG = 8; 2142 static constexpr uint32_t FOREGROUND_HALF_TIMEOUT_MSG = 9; 2143 static constexpr uint32_t CONNECT_TIMEOUT_MSG = 10; 2144 static constexpr uint32_t CONNECT_HALF_TIMEOUT_MSG = 11; 2145 2146 static constexpr uint32_t MIN_DUMP_ARGUMENT_NUM = 2; 2147 static constexpr uint32_t MAX_WAIT_SYSTEM_UI_NUM = 600; 2148 static constexpr uint32_t MAX_WAIT_SETTINGS_DATA_NUM = 300; 2149 2150 enum { 2151 ABILITY_MOVE_TO_FOREGROUND_CODE = 0, 2152 ABILITY_MOVE_TO_BACKGROUND_CODE, 2153 TERMINATE_ABILITY_CODE 2154 }; 2155 2156 friend class UserController; 2157 2158 protected: 2159 void OnAbilityRequestDone(const sptr<IRemoteObject> &token, const int32_t state) override; 2160 int GetUidByBundleName(std::string bundleName); 2161 2162 void OnAppStateChanged(const AppInfo &info) override; 2163 2164 void NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) override; 2165 2166 void NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos) override; 2167 2168 void NotifyStartKeepAliveProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos) override; 2169 2170 /** 2171 * @brief Notify abilityms app process pre cache 2172 * @param pid process pid. 2173 * @param userId userId Designation User ID. 2174 */ 2175 void NotifyAppPreCache(int32_t pid, int32_t userId) override; 2176 2177 /** 2178 * @brief Notify abilityms app process OnRemoteDied 2179 * @param abilityTokens abilities in died process. 2180 */ 2181 void OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens) override; 2182 2183 void OnStartProcessFailed(const std::vector<sptr<IRemoteObject>> &abilityTokens) override; 2184 2185 void OnCacheExitInfo(uint32_t accessTokenId, const AppExecFwk::RunningProcessInfo &exitInfo, 2186 const std::string &bundleName, const std::vector<std::string> &abilityNames, 2187 const std::vector<std::string> &uiExtensionNames) override; 2188 2189 int32_t GetCollaboratorType(const std::string &codePath) const; 2190 int32_t KillProcessForCollaborator(int32_t collaboratorType, const std::string &bundleName, int32_t userId); 2191 2192 /** 2193 * Check if Caller is allowed to start AppServiceExtension(Stage). 2194 * 2195 * @param abilityRequest, abilityRequest. 2196 * @param isVerifyAppIdentifierAllowList, isVerifyAppIdentifierAllowList 2197 * @param isFromConnect, isFromConnect 2198 * @return Returns whether the caller is allowed to start AppServiceExtension. 2199 */ 2200 int32_t CheckCallAppServiceExtensionPermission(const AbilityRequest &abilityRequest, 2201 std::shared_ptr<AbilityRecord> targetService, bool isFromConnect); 2202 private: 2203 int TerminateAbilityWithFlag(const sptr<IRemoteObject> &token, int resultCode = DEFAULT_INVAL_VALUE, 2204 const Want *resultWant = nullptr, bool flag = true); 2205 /** 2206 * initialization of ability manager service. 2207 * 2208 */ 2209 bool Init(); 2210 /** 2211 * initialization of u0 user. 2212 * 2213 */ 2214 void InitU0User(); 2215 void InitStartAbilityChain(); 2216 #ifndef DISABLE_LAUNCHER 2217 /** 2218 * start highest priority ability. 2219 * 2220 */ 2221 int StartHighestPriorityAbility(int32_t userId, bool isBoot, bool isAppRecovery = false); 2222 #endif 2223 /** 2224 * connect bms. 2225 * 2226 */ 2227 void ConnectServices(); 2228 2229 /** 2230 * Determine whether it is a system APP 2231 * 2232 */ 2233 bool IsSystemUiApp(const AppExecFwk::AbilityInfo &info) const; 2234 /** 2235 * Init parameters from the global 2236 * 2237 */ 2238 void InitGlobalConfiguration(); 2239 2240 int StartRemoteAbility(const Want &want, int requestCode, int32_t validUserId, 2241 const sptr<IRemoteObject> &callerToken); 2242 int StartUIAbilityBySCBDefault(sptr<SessionInfo> sessionInfo, uint32_t sceneFlag, bool &isColdStart); 2243 int StartUIAbilityByPreInstallInner(sptr<SessionInfo> sessionInfo, uint32_t specifyTokenId, 2244 uint32_t sceneFlag, bool &isColdStart); 2245 int32_t PreStartInner(const FreeInstallInfo& taskInfo); 2246 void RemovePreStartSession(const std::string& sessionId); 2247 2248 int32_t ConnectLocalAbility( 2249 const Want &want, 2250 const int32_t userId, 2251 const sptr<IAbilityConnection> &connect, 2252 const sptr<IRemoteObject> &callerToken, 2253 AppExecFwk::ExtensionAbilityType extensionType, 2254 const sptr<SessionInfo> &sessionInfo = nullptr, 2255 bool isQueryExtensionOnly = false, 2256 sptr<UIExtensionAbilityConnectInfo> connectInfo = nullptr); 2257 int DisconnectLocalAbility(const sptr<IAbilityConnection> &connect); 2258 int ConnectRemoteAbility(Want &want, const sptr<IRemoteObject> &callerToken, const sptr<IRemoteObject> &connect); 2259 int DisconnectRemoteAbility(const sptr<IRemoteObject> &connect); 2260 int PreLoadAppDataAbilities(const std::string &bundleName, const int32_t userId); 2261 void PreLoadAppDataAbilitiesTask(const std::string &bundleName, const int32_t userId); 2262 int StartAbilityPublicPrechainCheck(StartAbilityParams ¶ms); 2263 int StartAbilityPrechainInterceptor(StartAbilityParams ¶ms); 2264 bool StartAbilityInChain(StartAbilityParams ¶ms, int &result); 2265 void InitWindowVisibilityChangedListener(); 2266 void FreeWindowVisibilityChangedListener(); 2267 bool CheckProcessIsBackground(int32_t pid, AbilityState currentState); 2268 2269 bool CheckIfOperateRemote(const Want &want); 2270 std::string AnonymizeDeviceId(const std::string& deviceId); 2271 bool VerificationToken(const sptr<IRemoteObject> &token); 2272 void RequestPermission(const Want *resultWant); 2273 2274 bool CheckIsRemote(const std::string& deviceId); 2275 int GetRemoteMissionInfos(const std::string& deviceId, int32_t numMax, 2276 std::vector<MissionInfo> &missionInfos); 2277 int GetRemoteMissionInfo(const std::string& deviceId, int32_t missionId, 2278 MissionInfo &missionInfo); 2279 int32_t GetRemoteMissionSnapshotInfo(const std::string& deviceId, int32_t missionId, 2280 MissionSnapshot& missionSnapshot); 2281 int StartRemoteAbilityByCall(const Want &want, const sptr<IRemoteObject> &callerToken, 2282 const sptr<IRemoteObject> &connect); 2283 int ReleaseRemoteAbility(const sptr<IRemoteObject> &connect, const AppExecFwk::ElementName &element); 2284 void ForceTerminateServiceExtensionByPid(int32_t pid, int32_t userId); 2285 2286 void DumpInner(const std::string &args, std::vector<std::string> &info); 2287 void DumpMissionInner(const std::string &args, std::vector<std::string> &info); 2288 void DumpStateInner(const std::string &args, std::vector<std::string> &info); 2289 void DataDumpStateInner(const std::string &args, std::vector<std::string> &info); 2290 void DumpMissionListInner(const std::string &args, std::vector<std::string> &info); 2291 void DumpMissionInfosInner(const std::string &args, std::vector<std::string> &info); 2292 2293 bool JudgeMultiUserConcurrency(const int32_t userId); 2294 bool CheckCrossUser(const int32_t userId, AppExecFwk::ExtensionAbilityType extensionType); 2295 void SendExtensionReport(EventInfo &eventInfo, int32_t errCode, bool isService = false); 2296 void SendIntentReport(EventInfo &eventInfo, int32_t errCode, const std::string &intentName); 2297 /** 2298 * dumpsys info 2299 * 2300 */ 2301 void DumpSysInner( 2302 const std::string &args, std::vector<std::string> &info, bool isClient, bool isUserID, int userId); 2303 void DumpSysMissionListInner( 2304 const std::string &args, std::vector<std::string> &info, bool isClient, bool isUserID, int userId); 2305 void DumpSysMissionListInnerBySCB( 2306 const std::string &args, std::vector<std::string> &info, bool isClient, bool isUserID, int userId); 2307 void DumpSysAbilityInner( 2308 const std::string &args, std::vector<std::string> &info, bool isClient, bool isUserID, int userId); 2309 void DumpSysAbilityInnerBySCB( 2310 const std::string &args, std::vector<std::string> &info, bool isClient, bool isUserID, int userId); 2311 void DumpSysStateInner( 2312 const std::string &args, std::vector<std::string> &info, bool isClient, bool isUserID, int userId); 2313 void DumpSysPendingInner( 2314 const std::string &args, std::vector<std::string> &info, bool isClient, bool isUserID, int userId); 2315 void DumpSysProcess( 2316 const std::string &args, std::vector<std::string> &info, bool isClient, bool isUserID, int userId); 2317 void DumpUIExtensionRootHostRunningInfos(pid_t pid, std::vector<std::string> &info); 2318 void DumpUIExtensionProviderRunningInfos(pid_t pid, std::vector<std::string> &info); 2319 void DataDumpSysStateInner( 2320 const std::string &args, std::vector<std::string> &info, bool isClient, bool isUserID, int userId); 2321 ErrCode ProcessMultiParam(std::vector<std::string>& argsStr, std::string& result); 2322 void ShowHelp(std::string& result); 2323 void ShowIllegalInfomation(std::string& result); 2324 int Dump(const std::vector<std::u16string>& args, std::string& result); 2325 2326 // multi user 2327 void StartFreezingScreen(); 2328 void StopFreezingScreen(); 2329 void UserStarted(int32_t userId); 2330 int SwitchToUser(int32_t oldUserId, int32_t userId, sptr<IUserCallback> callback, 2331 bool isAppRecovery = false); 2332 void SwitchManagers(int32_t userId, bool switchUser = true); 2333 void StartUserApps(); 2334 void PauseOldUser(int32_t userId); 2335 void PauseOldMissionListManager(int32_t userId); 2336 void PauseOldConnectManager(int32_t userId); 2337 bool IsSystemUI(const std::string &bundleName) const; 2338 2339 bool VerificationAllToken(const sptr<IRemoteObject> &token); 2340 std::shared_ptr<DataAbilityManager> GetCurrentDataAbilityManager(); 2341 std::shared_ptr<DataAbilityManager> GetDataAbilityManager(const sptr<IAbilityScheduler> &scheduler); 2342 std::shared_ptr<DataAbilityManager> GetDataAbilityManagerByUserId(int32_t userId); 2343 std::shared_ptr<DataAbilityManager> GetDataAbilityManagerByToken(const sptr<IRemoteObject> &token); 2344 int32_t HandleExtensionAbility(sptr<IAbilityConnection> connect, 2345 std::function<int32_t(std::shared_ptr<AbilityConnectManager>, sptr<IAbilityConnection>)>); 2346 std::unordered_map<int, std::shared_ptr<AbilityConnectManager>> GetConnectManagers(); 2347 std::shared_ptr<AbilityConnectManager> GetCurrentConnectManager(); 2348 std::shared_ptr<AbilityConnectManager> GetConnectManagerByUserId(int32_t userId); 2349 std::shared_ptr<AbilityConnectManager> GetConnectManagerByToken(const sptr<IRemoteObject> &token); 2350 std::shared_ptr<AbilityConnectManager> GetConnectManagerByAbilityRecordId(const int64_t &abilityRecordId); 2351 std::shared_ptr<PendingWantManager> GetCurrentPendingWantManager(); 2352 std::shared_ptr<PendingWantManager> GetPendingWantManagerByUserId(int32_t userId); 2353 std::unordered_map<int, std::shared_ptr<MissionListManagerInterface>> GetMissionListManagers(); 2354 std::shared_ptr<MissionListManagerInterface> GetCurrentMissionListManager(); 2355 std::unordered_map<int, std::shared_ptr<UIAbilityLifecycleManager>> GetUIAbilityManagers(); 2356 std::shared_ptr<UIAbilityLifecycleManager> GetCurrentUIAbilityManager(); 2357 std::shared_ptr<UIAbilityLifecycleManager> GetUIAbilityManagerByUserId(int32_t userId) const; 2358 std::shared_ptr<UIAbilityLifecycleManager> GetUIAbilityManagerByUid(int32_t uid); 2359 bool JudgeSelfCalled(const std::shared_ptr<AbilityRecord> &abilityRecord); 2360 bool IsAppSelfCalled(const std::shared_ptr<AbilityRecord> &abilityRecord); 2361 2362 int32_t GetValidUserId(const int32_t userId); 2363 2364 int DelegatorMoveMissionToFront(int32_t missionId); 2365 2366 bool IsNeedTimeoutForTest(const std::string &abilityName, const std::string &state) const; 2367 2368 void StartResidentApps(int32_t userId); 2369 2370 void StartKeepAliveApps(int32_t userId); 2371 2372 void StartAutoStartupApps(); 2373 void StartAutoStartupApps(std::queue<AutoStartupInfo> infoList); 2374 void SubscribeScreenUnlockedEvent(); 2375 std::function<void()> GetScreenUnlockCallback(); 2376 std::function<void()> GetUserScreenUnlockCallback(); 2377 void UnSubscribeScreenUnlockedEvent(); 2378 void RetrySubscribeScreenUnlockedEvent(int32_t retryCount); 2379 void RemoveScreenUnlockInterceptor(); 2380 void RemoveUnauthorizedLaunchReasonMessage(const Want &want, AbilityRequest &abilityRequest, 2381 uint32_t callerTokenId); 2382 2383 int VerifyAccountPermission(int32_t userId); 2384 2385 int CheckStaticCfgPermissionForAbility(const AppExecFwk::AbilityInfo &abilityInfo, uint32_t tokenId); 2386 2387 int CheckStaticCfgPermissionForSkill(const AppExecFwk::AbilityRequest &abilityRequest, uint32_t tokenId); 2388 2389 bool CheckOneSkillPermission(const AppExecFwk::Skill &skill, uint32_t tokenId); 2390 2391 int CheckStaticCfgPermission(const AppExecFwk::AbilityRequest &abilityRequest, bool isStartAsCaller, 2392 uint32_t callerTokenId, bool isData = false, bool isSaCall = false, bool isImplicit = false); 2393 2394 int CheckPermissionForUIService(AppExecFwk::ExtensionAbilityType extensionType, 2395 const Want &want, const AbilityRequest &abilityRequest); 2396 2397 bool CheckPermissionForKillCollaborator(); 2398 2399 bool GetValidDataAbilityUri(const std::string &abilityInfoUri, std::string &adjustUri); 2400 2401 int GenerateExtensionAbilityRequest(const Want &want, AbilityRequest &request, 2402 const sptr<IRemoteObject> &callerToken, int32_t userId); 2403 int32_t InitialAbilityRequest(AbilityRequest &request, const StartAbilityInfo &abilityInfo) const; 2404 int CheckOptExtensionAbility(const Want &want, AbilityRequest &abilityRequest, 2405 int32_t validUserId, AppExecFwk::ExtensionAbilityType extensionType, bool isImplicit = false, 2406 bool isStartAsCaller = false); 2407 2408 void SubscribeBackgroundTask(); 2409 2410 void UnSubscribeBackgroundTask(); 2411 2412 void SubscribeBundleEventCallback(); 2413 2414 void UnsubscribeBundleEventCallback(); 2415 2416 void ReportAbilityStartInfoToRSS(const AppExecFwk::AbilityInfo &abilityInfo); 2417 2418 void ReportAbilityAssociatedStartInfoToRSS(const AppExecFwk::AbilityInfo &abilityInfo, int64_t type, 2419 const sptr<IRemoteObject> &callerToken); 2420 2421 void ReportEventToRSS(const AppExecFwk::AbilityInfo &abilityInfo, sptr<IRemoteObject> callerToken); 2422 2423 void ReportAppConnectOtherExtensionEvent(const AppExecFwk::AbilityInfo &abilityInfo, const Want &want); 2424 2425 void ReportAppRecoverResult(const int32_t appId, const AppExecFwk::ApplicationInfo &appInfo, 2426 const std::string& abilityName, const std::string& result); 2427 2428 void AppRecoverKill(pid_t pid, int32_t reason); 2429 2430 int32_t GenerateEmbeddableUIAbilityRequest(const Want &want, AbilityRequest &request, 2431 const sptr<IRemoteObject> &callerToken, int32_t userId); 2432 2433 bool GenerateDataAbilityRequestByUri(const std::string& dataAbilityUri, 2434 AbilityRequest &abilityRequest, sptr<IRemoteObject> callerToken, int32_t userId); 2435 2436 /** 2437 * Check if Caller is allowed to start ServiceAbility(FA) or ServiceExtension(Stage) or DataShareExtension(Stage). 2438 * 2439 * @param abilityRequest, abilityRequest. 2440 * @return Returns whether the caller is allowed to start Service. 2441 */ 2442 int CheckCallServicePermission(const AbilityRequest &abilityRequest); 2443 2444 /** 2445 * Check if Caller is allowed to start DataAbility(FA) 2446 * 2447 * @param abilityRequest, abilityRequest. 2448 * @return Returns whether the caller is allowed to start DataAbility. 2449 */ 2450 int CheckCallDataAbilityPermission(AbilityRequest &abilityRequest, bool isShell, bool IsSACall = false); 2451 2452 /** 2453 * Check if Caller is allowed to start ServiceExtension(Stage) or DataShareExtension(Stage). 2454 * 2455 * @param abilityRequest, abilityRequest. 2456 * @return Returns whether the caller is allowed to start ServiceExtension. 2457 */ 2458 int CheckCallServiceExtensionPermission(const AbilityRequest &abilityRequest); 2459 2460 #ifdef SUPPORT_AUTO_FILL 2461 /** 2462 * Check if Caller is allowed to start AutoFillExtension. 2463 * 2464 * @param abilityRequest, abilityRequest. 2465 * @return Returns whether the caller is allowed to start ServiceExtension. 2466 */ 2467 int CheckCallAutoFillExtensionPermission(const AbilityRequest &abilityRequest); 2468 #endif // SUPPORT_AUTO_FILL 2469 /** 2470 * Check if Caller is allowed to start other Extension(Stage). 2471 * 2472 * @param abilityRequest, abilityRequest. 2473 * @return Returns whether the caller is allowed to start OtherExtension. 2474 */ 2475 int CheckCallOtherExtensionPermission(const AbilityRequest &abilityRequest); 2476 2477 /** 2478 * Check if Caller is allowed to start ServiceAbility(FA). 2479 * 2480 * @param abilityRequest, abilityRequest. 2481 * @return Returns whether the caller is allowed to start ServiceAbility. 2482 */ 2483 int CheckCallServiceAbilityPermission(const AbilityRequest &abilityRequest); 2484 2485 /** 2486 * Check if Caller is allowed to start PageAbility(FA) or Ability(Stage). 2487 * 2488 * @param abilityRequest, abilityRequest. 2489 * @return Returns whether the caller is allowed to start Ability. 2490 */ 2491 int CheckCallAbilityPermission(const AbilityRequest &abilityRequest, uint32_t specifyTokenId = 0, 2492 bool isCallByShortcut = false); 2493 2494 /** 2495 * Check if Caller is allowed to start Ability(Stage) by call. 2496 * 2497 * @param abilityRequest, abilityRequest. 2498 * @return Returns whether the caller is allowed to start Ability by call. 2499 */ 2500 int CheckStartByCallPermission(const AbilityRequest &abilityRequest); 2501 2502 /** 2503 * @brief Check some specified uiextension type should be a system app. 2504 * Consider expanding it to table-driven in the future. 2505 * 2506 * @param abilityRequest The ability request. 2507 * @return Returns ERR_OK when allowed, others when check failed. 2508 */ 2509 int CheckUIExtensionPermission(const AbilityRequest &abilityRequest); 2510 2511 /** 2512 * @brief Check CallerInfoQueryExtension permission 2513 * 2514 * @param abilityRequest The ability request. 2515 * @return Returns ERR_OK when allowed, others when check failed. 2516 */ 2517 int CheckCallerInfoQueryExtensionPermission(const AbilityRequest &abilityRequest); 2518 2519 int CheckFileAccessExtensionPermission(const AbilityRequest &abilityRequest); 2520 2521 bool IsTargetPermission(const Want &want) const; 2522 2523 bool IsDelegatorCall(const AppExecFwk::RunningProcessInfo &processInfo, const AbilityRequest &abilityRequest) const; 2524 2525 bool CheckNewRuleSwitchState(const std::string ¶m); 2526 2527 void UpdateFocusState(std::vector<AbilityRunningInfo> &info); 2528 2529 AAFwk::PermissionVerification::VerificationInfo CreateVerificationInfo( 2530 const AbilityRequest &abilityRequest, bool isData = false, bool isShell = false, bool isSA = false); 2531 2532 int AddStartControlParam(Want &want, const sptr<IRemoteObject> &callerToken); 2533 2534 AAFwk::EventInfo BuildEventInfo(const Want &want, int32_t userId); 2535 AAFwk::EventInfo BuildEventInfoByAbilityRecord(const std::shared_ptr<AbilityRecord> &abilityRecord); 2536 2537 #ifdef WITH_DLP 2538 int CheckDlpForExtension( 2539 const Want &want, const sptr<IRemoteObject> &callerToken, 2540 int32_t userId, AAFwk::EventInfo &eventInfo, const EventName &eventName); 2541 #endif // WITH_DLP 2542 2543 void InitStartupFlag(); 2544 2545 bool IsCrossUserCall(int32_t userId) const; 2546 2547 int32_t RequestDialogServiceInner(const Want &want, const sptr<IRemoteObject> &callerToken, 2548 int requestCode, int32_t userId); 2549 2550 bool CheckCallingTokenId(const std::string &bundleName, int32_t userId = INVALID_USER_ID, int32_t appIndex = 0); 2551 bool IsCallerSceneBoard(); 2552 2553 void ReleaseAbilityTokenMap(const sptr<IRemoteObject> &token); 2554 2555 bool CheckCollaboratorType(int32_t type); 2556 2557 bool CheckUserIdActive(int32_t userId); 2558 2559 void GetConnectManagerAndUIExtensionBySessionInfo(const sptr<SessionInfo> &sessionInfo, 2560 std::shared_ptr<AbilityConnectManager> &connectManager, std::shared_ptr<AbilityRecord> &targetAbility, 2561 bool needCheck = false); 2562 2563 virtual int RegisterSessionHandler(const sptr<IRemoteObject> &object) override; 2564 2565 int32_t StartUIAbilitiesHandleWant(const Want &want, sptr<IRemoteObject> callerToken, 2566 std::vector<AbilityRequest> &abilityRequestList); 2567 int32_t StartUIAbilitiesCheckDlp(const Want &want, sptr<IRemoteObject> callerToken, int32_t userId); 2568 int32_t StartUIAbilitiesInterceptorCheck(const Want &want, AbilityRequest &abilityRequest, 2569 sptr<IRemoteObject> callerToken, int32_t appIndex); 2570 /** 2571 * Start switch user dialog Extension ability. 2572 */ 2573 void StartSwitchUserDialog(); 2574 2575 /** 2576 * Start switch user dialog inner. 2577 * @param want, The want of the dialog box to start. 2578 * @param startUserId, The userId who wants to start the dialog box. 2579 */ 2580 void StartSwitchUserDialogInner(const Want &want, int32_t startUserId); 2581 2582 /** 2583 * Stop switch user dialog Extension ability. 2584 */ 2585 void StopSwitchUserDialog(); 2586 2587 /** 2588 * Stop switch user dialog inner. 2589 * @param want, The want of the dialog box to stop. 2590 * @param stopUserId, The userId who wants to stop the dialog box. 2591 */ 2592 void StopSwitchUserDialogInner(const Want &want, const int32_t stopUserId); 2593 2594 /** 2595 * judge system params for picker 2596 * @param WantParams, The wantparams of the want. 2597 */ 2598 bool JudgeSystemParamsForPicker(const WantParams ¶meters); 2599 2600 void SetPickerElementNameAndParams(const sptr<SessionInfo> &extensionSessionInfo, int32_t userId); 2601 2602 void SetAutoFillElementName(const sptr<SessionInfo> &extensionSessionInfo); 2603 2604 /** 2605 * @brief Start extension ability with insight intent 2606 * @param want, the want of the ability to start. 2607 * @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started. 2608 * @return Returns ERR_OK on success, others on failure. 2609 */ 2610 int32_t StartExtensionAbilityWithInsightIntent(const Want &want, 2611 AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED); 2612 2613 bool IsAbilityStarted(AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &targetRecord, 2614 const int32_t oriValidUserId); 2615 2616 void InitInterceptor(); 2617 void InitInterceptorForScreenUnlock(); 2618 void InitPushTask(); 2619 void InitDeepLinkReserve(); 2620 2621 bool CheckSenderWantInfo(int32_t callerUid, const WantSenderInfo &wantSenderInfo); 2622 2623 int32_t UninstallAppInner(const std::string &bundleName, const int32_t uid, int32_t appIndex, const bool isUpgrade, 2624 const std::string &exitMsg); 2625 2626 int32_t GetMissionIdByAbilityTokenInner(const sptr<IRemoteObject> &token); 2627 bool CheckCallerIsDmsProcess(); 2628 2629 void WaitBootAnimationStart(); 2630 2631 struct SignRestartAppFlagParam { 2632 int32_t userId; 2633 int32_t uid; 2634 std::string instanceKey; 2635 AppExecFwk::MultiAppModeType type; 2636 bool isAppRecovery = false; 2637 bool isAtomicService = false; 2638 }; 2639 int32_t SignRestartAppFlag(const SignRestartAppFlagParam ¶m); 2640 int32_t CheckRestartAppWant(const AAFwk::Want &want, int32_t appIndex, int32_t userId); 2641 2642 int32_t CheckDebugAssertPermission(); 2643 bool VerifySameAppOrAppIdentifierAllowListPermission(const AbilityRequest &abilityRequest); 2644 std::shared_ptr<AbilityDebugDeal> ConnectInitAbilityDebugDeal(); 2645 2646 int32_t SetBackgroundCall(const AppExecFwk::RunningProcessInfo &processInfo, 2647 const AbilityRequest &abilityRequest, bool &isBackgroundCall) const; 2648 2649 int CheckUIExtensionUsage(AppExecFwk::UIExtensionUsage uiExtensionUsage, 2650 AppExecFwk::ExtensionAbilityType extensionType); 2651 2652 bool CheckUIExtensionCallerIsForeground(const AbilityRequest &abilityRequest); 2653 bool CheckStartCallHasFloatingWindowForUIExtension(const sptr<IRemoteObject> &callerToken); 2654 bool CheckUIExtensionCallerIsUIAbility(const AbilityRequest &abilityRequest); 2655 std::shared_ptr<AbilityRecord> GetUIExtensionRootCaller(const sptr<IRemoteObject> token, int32_t userId); 2656 2657 bool CheckUIExtensionCallerPidByHostWindowId(const AbilityRequest &abilityRequest); 2658 2659 int CheckExtensionCallPermission(const Want& want, const AbilityRequest& abilityRequest, uint32_t specifyTokenId); 2660 2661 int CheckServiceCallPermission(const AbilityRequest& abilityRequest, 2662 const AppExecFwk::AbilityInfo& abilityInfo); 2663 2664 int CheckBrokerCallPermission(const AbilityRequest& abilityRequest, 2665 const AppExecFwk::AbilityInfo& abilityInfo); 2666 2667 int CheckAbilityCallPermission(const AbilityRequest& abilityRequest, 2668 const AppExecFwk::AbilityInfo& abilityInfo, uint32_t specifyTokenId); 2669 2670 int CheckCallPermission(const Want& want, const AppExecFwk::AbilityInfo& abilityInfo, 2671 const AbilityRequest& abilityRequest, bool isForegroundToRestartApp, 2672 bool isSendDialogResult, uint32_t specifyTokenId, 2673 const std::string& callerBundleName); 2674 2675 void CheckExtensionRateLimit(); 2676 2677 int32_t CheckStartPlugin(const Want& want, sptr<IRemoteObject> callerToken); 2678 2679 int StartAbilityByConnectManager(const Want& want, const AbilityRequest& abilityRequest, 2680 const AppExecFwk::AbilityInfo& abilityInfo, int validUserId, sptr<IRemoteObject> callerToken); 2681 2682 int PreStartFreeInstall(const Want &want, sptr<IRemoteObject> callerToken, 2683 uint32_t specifyTokenId, bool isStartAsCaller, Want &localWant); 2684 2685 void ReportCleanSession(const sptr<SessionInfo> &sessionInfo, 2686 const std::shared_ptr<AbilityRecord> &abilityRecord, int32_t errCode); 2687 2688 void SendStartAbilityOtherExtensionEvent(const AppExecFwk::AbilityInfo& abilityInfo, 2689 const Want& want, uint32_t specifyTokenId); 2690 2691 void SetMinimizedDuringFreeInstall(const sptr<SessionInfo>& sessionInfo); 2692 2693 bool CheckWorkSchedulerPermission(const sptr<IRemoteObject> &callerToken, const uint32_t uid); 2694 2695 /** 2696 * @brief Check debug app in developer mode. 2697 * @param applicationInfo. The application info. 2698 * @return Returns true or false. 2699 */ 2700 bool CheckDebugAppNotInDeveloperMode(const AppExecFwk::ApplicationInfo &applicationInfo); 2701 2702 /** 2703 * @brief Prompt user that developer mode has not been turned on. 2704 * @param bundleName. The bundleName of the blocked hap. 2705 * @param abilityName. The abilityName of the blocked hap. 2706 */ 2707 void ShowDeveloperModeDialog(const std::string &bundleName, const std::string &abilityName); 2708 2709 void StartKeepAliveAppsInner(int32_t userId); 2710 2711 bool ProcessLowMemoryKill(int32_t pid, const ExitReason &reason, bool isKillPrecedeStart); 2712 2713 struct StartSelfUIAbilityParam { 2714 Want want; 2715 StartOptions options; 2716 bool hasStartOptions = false; 2717 }; 2718 int StartSelfUIAbilityInner(StartSelfUIAbilityParam param); 2719 2720 bool HandleExecuteSAInterceptor(const Want &want, sptr<IRemoteObject> callerToken, 2721 AbilityRequest &abilityRequest, int32_t &result); 2722 2723 bool controllerIsAStabilityTest_ = false; 2724 bool isParamStartAbilityEnable_ = false; 2725 // Component StartUp rule switch 2726 bool startUpNewRule_ = true; 2727 /** Indicates the criteria for judging whether the Caller-Application is in the background 2728 * TRUE: Determine the state by AAFwk::AppState::FOREGROUND. 2729 * FALSE: Determine the state by AppExecFwk::AppProcessState::APP_STATE_FOCUS. 2730 */ 2731 bool backgroundJudgeFlag_ = true; 2732 /** The applications in white list can associatedWakeUp 2733 * TRUE: white list enable. 2734 * FALSE: white list unable. 2735 */ 2736 bool whiteListassociatedWakeUpFlag_ = true; 2737 bool shouldBlockAllAppStart_ = false; 2738 2739 int32_t uniqueId_ = 0; 2740 std::unordered_set<int32_t> windowVisibleList_; 2741 2742 sptr<WindowVisibilityChangedListener> windowVisibilityChangedListener_; 2743 std::shared_ptr<TaskHandlerWrap> taskHandler_; 2744 std::shared_ptr<AbilityEventHandler> eventHandler_; 2745 ServiceRunningState state_; 2746 2747 std::shared_ptr<FreeInstallManager> freeInstallManager_; 2748 std::shared_ptr<SubManagersHelper> subManagersHelper_; 2749 std::shared_ptr<UserController> userController_; 2750 sptr<AppExecFwk::IAbilityController> abilityController_ = nullptr; 2751 2752 std::multimap<std::string, std::string> timeoutMap_; 2753 std::map<std::string, sptr<SessionInfo>> preStartSessionMap_; 2754 2755 static sptr<AbilityManagerService> instance_; 2756 std::map<int32_t, std::pair<int64_t, const sptr<IAcquireShareDataCallback>>> iAcquireShareDataMap_; 2757 // first is callstub, second is ability token 2758 std::map<sptr<IRemoteObject>, sptr<IRemoteObject>> callStubTokenMap_; 2759 #ifdef SUPPORT_GRAPHICS 2760 sptr<WindowFocusChangedListener> focusListener_; 2761 #endif // SUPPORT_GRAPHICS 2762 2763 std::shared_ptr<AbilityRuntime::AbilityManagerEventSubscriber> screenSubscriber_; 2764 2765 std::shared_ptr<AbilityAutoStartupService> abilityAutoStartupService_; 2766 2767 std::map<std::string, std::list<std::string>> whiteListMap_; 2768 2769 std::list<std::string> exportWhiteList_; 2770 2771 std::shared_ptr<AbilityRuntime::InsightIntentEventMgr> insightIntentEventMgr_; 2772 2773 bool ShouldPreventStartAbility(const AbilityRequest &abilityRequest); 2774 2775 void PrintStartAbilityInfo(AppExecFwk::AbilityInfo callerInfo, AppExecFwk::AbilityInfo calledInfo); 2776 2777 bool IsInWhiteList(const std::string &callerBundleName, const std::string &calleeBundleName, 2778 const std::string &calleeAbilityName); 2779 2780 std::string GetConfigFileAbsolutePath(const std::string &relativePath); 2781 2782 int32_t ParseJsonValueFromFile(nlohmann::json &value, const std::string& fullPath); 2783 2784 bool ConvertFullPath(const std::string& partialPath, std::string& fullPath); 2785 2786 bool ParseJsonFromBoot(const std::string &relativePath); 2787 2788 void SetReserveInfo(const std::string &linkString, AbilityRequest& abilityRequest); 2789 void CloseAssertDialog(const std::string &assertSessionId); 2790 2791 int32_t OpenLinkFreeInstallAtomicService(Want &convertedWant, const Want &originalWant, 2792 sptr<IRemoteObject> callerToken, int32_t userId, int32_t requestCode, bool removeInsightIntentFlag); 2793 2794 void ReportPreventStartAbilityResult(const AppExecFwk::AbilityInfo &callerAbilityInfo, 2795 const AppExecFwk::AbilityInfo &abilityInfo); 2796 2797 void SetAbilityRequestSessionInfo(AbilityRequest &abilityRequest, AppExecFwk::ExtensionAbilityType extensionType); 2798 2799 bool ShouldBlockAllAppStart(); 2800 2801 std::string InsightIntentGetcallerBundleName(); 2802 2803 ErrCode IntentOpenLinkInner(const std::shared_ptr<AppExecFwk::InsightIntentExecuteParam> ¶m, 2804 AbilityRuntime::ExtractInsightIntentGenericInfo &linkInfo, const int32_t userId); 2805 2806 AbilityRuntime::ExtractInsightIntentGenericInfo GetInsightIntentGenericInfo(const InsightIntentExecuteParam ¶m); 2807 2808 void CombinLinkInfo( 2809 const std::vector<AbilityRuntime::LinkIntentParamMapping> ¶mMappings, std::string &uri, AAFwk::Want &want); 2810 2811 int StartAbilityWithRemoveIntentFlag(const Want &want, const sptr<IRemoteObject> &callerToken, 2812 int32_t userId, int requestCode, bool removeInsightIntentFlag); 2813 2814 int32_t OpenLinkInner(const Want &want, sptr<IRemoteObject> callerToken, int32_t userId, int requestCode, 2815 bool removeInsightIntentFlag); 2816 int32_t KillProcessWithReasonInner(int32_t pid, const ExitReason &reason, bool isKillPrecedeStart); 2817 #ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE 2818 std::shared_ptr<BackgroundTaskObserver> bgtaskObserver_; 2819 #endif 2820 2821 sptr<AbilityBundleEventCallback> abilityBundleEventCallback_; 2822 2823 #ifdef SUPPORT_SCREEN 2824 bool isAnimationEnabled_ = true; //only use on mission list 2825 bool CheckWindowMode(int32_t windowMode, const std::vector<AppExecFwk::SupportWindowMode>& windowModes) const; 2826 int32_t ShowPickerDialog(const Want& want, int32_t userId, const sptr<IRemoteObject> &token); 2827 void InitFocusListener(); 2828 void RegisterFocusListener(); 2829 std::shared_ptr<ImplicitStartProcessor> implicitStartProcessor_; 2830 sptr<IWindowManagerServiceHandler> wmsHandler_; 2831 #endif 2832 std::shared_ptr<AbilityInterceptorExecuter> interceptorExecuter_; 2833 std::shared_ptr<AbilityInterceptorExecuter> afterCheckExecuter_; 2834 2835 std::unordered_map<int32_t, int64_t> appRecoveryHistory_; // uid:time 2836 std::multimap<int, std::shared_ptr<StartAbilityHandler>, std::greater<int>> startAbilityChain_; 2837 std::unordered_map<int32_t, sptr<IAbilityManagerCollaborator>> collaboratorMap_; 2838 2839 std::shared_ptr<AbilityDebugDeal> abilityDebugDeal_; 2840 std::shared_ptr<AppExitReasonHelper> appExitReasonHelper_; 2841 2842 ffrt::mutex globalLock_; 2843 ffrt::mutex bgtaskObserverMutex_; 2844 ffrt::mutex abilityTokenLock_; 2845 ffrt::mutex preStartSessionMapLock_; 2846 ffrt::mutex windowVisibleListLock_; 2847 ffrt::mutex iAcquireShareDataMapLock_; 2848 ffrt::mutex collaboratorMapLock_; 2849 ffrt::mutex abilityDebugDealLock_; 2850 ffrt::mutex shouldBlockAllAppStartMutex_; 2851 mutable ffrt::mutex timeoutMapLock_; 2852 std::mutex whiteListMutex_; 2853 2854 std::mutex prepareTermiationCallbackMutex_; 2855 std::map<std::string, sptr<IPrepareTerminateCallback>> prepareTermiationCallbacks_; 2856 AbilityEventUtil eventHelper_; 2857 }; 2858 } // namespace AAFwk 2859 } // namespace OHOS 2860 #endif // OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_SERVICE_H 2861