diff --git a/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h b/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h index c87a19c60f50d44d2fdd39d45f011f4be7b4a9d7..be1975cb71eb21d98bf71b8d97046e17b93388b7 100644 --- a/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h +++ b/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h @@ -450,8 +450,6 @@ private: void HandleForegroundCollaborate(const AbilityRequest &abilityRequest, std::shared_ptr abilityRecord); - void NotifyStartSpecifiedAbility(AbilityRequest &request, const AAFwk::Want &want); - void NotifyRestartSpecifiedAbility(const AbilityRequest &request, const sptr &token); int32_t MoveAbilityToFront(const SpecifiedRequest &specifiedRequest, const std::shared_ptr abilityRecord, std::shared_ptr callerAbility); int SendSessionInfoToSCB(std::shared_ptr &callerAbility, sptr &sessionInfo); diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 110082ba9ef95d60af8f5ee4ce073dccd2bd2c94..b69764e9456788210ecf46cc19b29d7992275f0f 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -2943,10 +2943,7 @@ bool AbilityManagerService::IsCallerSceneBoard() auto connectManager = GetConnectManagerByUserId(userId); CHECK_POINTER_AND_RETURN(connectManager, false); auto sceneBoardTokenId = connectManager->GetSceneBoardTokenId(); - if (sceneBoardTokenId != 0 && IPCSkeleton::GetCallingTokenID() == sceneBoardTokenId) { - return true; - } - return false; + return sceneBoardTokenId != 0 && IPCSkeleton::GetCallingTokenID() == sceneBoardTokenId; } bool AbilityManagerService::IsBackgroundTaskUid(const int uid) diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index eda793dbf60344cfb01cd082804a41fb07fb21b3..590bb0a7f2375d975a2b890747b9972b50eb53e4 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -502,42 +502,33 @@ void AbilityRecord::ProcessForegroundAbility( GrantUriPermission(want_, abilityInfo_.applicationInfo.bundleName, false, tokenId); } #endif // SUPPORT_UPMS - - if (isReady_) { - PostForegroundTimeoutTask(); - if (IsAbilityState(AbilityState::FOREGROUND)) { - TAG_LOGD(AAFwkTag::ABILITYMGR, "Activate %{public}s", element.c_str()); - if (IsFrozenByPreload()) { - SetFrozenByPreload(false); - auto ret = - DelayedSingleton::GetInstance()->NotifyPreloadAbilityStateChanged(token_, false); - TAG_LOGI(AAFwkTag::ABILITYMGR, "NotifyPreloadAbilityStateChanged by start, ret: %{public}d", ret); - } - ForegroundAbility(sceneFlag); - } else { - // background to active state - TAG_LOGD(AAFwkTag::ABILITYMGR, "MoveToForeground, %{public}s", element.c_str()); - lifeCycleStateInfo_.sceneFlagBak = sceneFlag; - std::string bundleName = GetAbilityInfo().bundleName; - int32_t uid = GetUid(); - auto pid = GetPid(); - if (pid > 0) { - auto callerPid = GetCallerRecord() ? GetCallerRecord()->GetPid() : -1; - TAG_LOGD(AAFwkTag::ABILITYMGR, - "ReportEventToRSS---%{public}d_%{public}s_%{public}d callerPid=%{public}d", - uid, bundleName.c_str(), pid, callerPid); - ResSchedUtil::GetInstance().ReportEventToRSS(uid, bundleName, "THAW_BY_FOREGROUND_ABILITY", pid, - callerPid); - } - SendAppStartupTypeEvent(AppExecFwk::AppStartType::HOT); - SetAbilityStateInner(AbilityState::FOREGROUNDING); - DelayedSingleton::GetInstance()->MoveToForeground(token_); - } - } else { + if (!isReady_) { TAG_LOGD(AAFwkTag::ABILITYMGR, "To load ability."); lifeCycleStateInfo_.sceneFlagBak = sceneFlag; LoadAbility(isShellCall, isStartupHide); + return; + } + + PostForegroundTimeoutTask(); + if (IsAbilityState(AbilityState::FOREGROUND)) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "Activate %{public}s", element.c_str()); + if (IsFrozenByPreload()) { + SetFrozenByPreload(false); + auto ret = + DelayedSingleton::GetInstance()->NotifyPreloadAbilityStateChanged(token_, false); + TAG_LOGI(AAFwkTag::ABILITYMGR, "NotifyPreloadAbilityStateChanged by start, ret: %{public}d", ret); + } + ForegroundAbility(sceneFlag); + return; } + // background to active state + TAG_LOGD(AAFwkTag::ABILITYMGR, "MoveToForeground, %{public}s", element.c_str()); + lifeCycleStateInfo_.sceneFlagBak = sceneFlag; + ResSchedUtil::GetInstance().ReportEventToRSS(GetUid(), GetAbilityInfo().bundleName, + "THAW_BY_FOREGROUND_ABILITY", GetPid(), GetCallerRecord() ? GetCallerRecord()->GetPid() : -1); + SendAppStartupTypeEvent(AppExecFwk::AppStartType::HOT); + SetAbilityStateInner(AbilityState::FOREGROUNDING); + DelayedSingleton::GetInstance()->MoveToForeground(token_); } void AbilityRecord::PostForegroundTimeoutTask() diff --git a/services/abilitymgr/src/sa_interceptor_manager.cpp b/services/abilitymgr/src/sa_interceptor_manager.cpp index ff45b1ae904d134ef07a35a2e4c7820d4b8fc477..83f8f6931bdeee55527f89e8445348113a08f3af 100644 --- a/services/abilitymgr/src/sa_interceptor_manager.cpp +++ b/services/abilitymgr/src/sa_interceptor_manager.cpp @@ -85,6 +85,7 @@ int32_t SAInterceptorManager::ExecuteSAInterceptor(const std::string ¶ms, Ru HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); auto result = interceptor->OnCheckStarting(params, rule); if (result != ERR_OK || rule.type != RuleType::ALLOW) { + TAG_LOGW(AAFwkTag::SA_INTERCEPTOR, "OnCheckStarting error: %{public}d", result); return result; } } diff --git a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp index 2077539a409268705505c764fd7850ba3fb3f5e5..bc8182027013fdab24a885a4168b0a52a78d6d0d 100644 --- a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp +++ b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp @@ -2340,11 +2340,9 @@ void UIAbilityLifecycleManager::HandleLegacyAcceptWantDone(SpecifiedRequest &spe CHECK_POINTER_LOG(abilityRecord, "OnAcceptWantResponse abilityRecord null"); UpdateAbilityRecordLaunchReason(abilityRequest, abilityRecord); MoveAbilityToFront(specifiedRequest, abilityRecord, callerAbility); - NotifyRestartSpecifiedAbility(abilityRequest, abilityRecord->GetToken()); return; } } - NotifyStartSpecifiedAbility(abilityRequest, want); StartAbilityBySpecifed(specifiedRequest, callerAbility); } @@ -2507,7 +2505,7 @@ int32_t UIAbilityLifecycleManager::StartSpecifiedProcessRequest(const AbilityReq int32_t UIAbilityLifecycleManager::StartSpecifiedAbilityBySCB(AbilityRequest &abilityRequest) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); + TAG_LOGD(AAFwkTag::ABILITYMGR, "StartSpecifiedAbilityBySCB"); abilityRequest.isFromIcon = true; std::lock_guard guard(sessionLock_); // support specified process mode @@ -2518,47 +2516,6 @@ int32_t UIAbilityLifecycleManager::StartSpecifiedAbilityBySCB(AbilityRequest &ab return ERR_OK; } -void UIAbilityLifecycleManager::NotifyRestartSpecifiedAbility(const AbilityRequest &request, - const sptr &token) -{ - if (request.abilityInfoCallback == nullptr) { - return; - } - sptr abilityInfoCallback - = iface_cast (request.abilityInfoCallback); - if (abilityInfoCallback != nullptr) { - TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); - abilityInfoCallback->NotifyRestartSpecifiedAbility(token); - } -} - -void UIAbilityLifecycleManager::NotifyStartSpecifiedAbility(AbilityRequest &abilityRequest, const AAFwk::Want &want) -{ - if (abilityRequest.abilityInfoCallback == nullptr) { - return; - } - - sptr abilityInfoCallback - = iface_cast (abilityRequest.abilityInfoCallback); - if (abilityInfoCallback != nullptr) { - Want newWant = want; - int32_t type = static_cast(abilityRequest.abilityInfo.type); - newWant.SetParam("abilityType", type); - sptr extraParam = new (std::nothrow) Want(); - CHECK_POINTER(extraParam); - abilityInfoCallback->NotifyStartSpecifiedAbility(abilityRequest.callerToken, newWant, - abilityRequest.requestCode, extraParam); - int32_t procCode = extraParam->GetIntParam(Want::PARAM_RESV_REQUEST_PROC_CODE, 0); - if (procCode != 0) { - abilityRequest.want.SetParam(Want::PARAM_RESV_REQUEST_PROC_CODE, procCode); - } - int32_t tokenCode = extraParam->GetIntParam(Want::PARAM_RESV_REQUEST_TOKEN_CODE, 0); - if (tokenCode != 0) { - abilityRequest.want.SetParam(Want::PARAM_RESV_REQUEST_TOKEN_CODE, tokenCode); - } - } -} - int32_t UIAbilityLifecycleManager::MoveAbilityToFront(const SpecifiedRequest &specifiedRequest, std::shared_ptr abilityRecord, std::shared_ptr callerAbility) { diff --git a/services/common/src/res_sched_util.cpp b/services/common/src/res_sched_util.cpp index 5b2df1149b7843dc8e0c75b2dea8a4d9350e1475..ff7c9ab6bf1a19875ad943dbd62aa95e81fa0b7f 100644 --- a/services/common/src/res_sched_util.cpp +++ b/services/common/src/res_sched_util.cpp @@ -147,6 +147,8 @@ void ResSchedUtil::ReportAbilityIntentExemptionInfoToRSS(int32_t callerUid, int3 void ResSchedUtil::ReportEventToRSS(const int32_t uid, const std::string &bundleName, const std::string &reason, const int32_t pid, const int32_t callerPid) { + TAG_LOGD(AAFwkTag::DEFAULT, "ReportEventToRSS---%{public}d_%{public}s_%{public}d callerPid=%{public}d", + uid, bundleName.c_str(), pid, callerPid); #ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE uint32_t resType = ResourceSchedule::ResType::SYNC_RES_TYPE_THAW_ONE_APP; nlohmann::json payload; diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_ui_ability_lifecycle_manager.cpp b/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_ui_ability_lifecycle_manager.cpp index d66f86a5a272741da64232f83e864aefb7a4321b..bb8f883cc7b529bc0ab8c287ed3e227e614697aa 100644 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_ui_ability_lifecycle_manager.cpp +++ b/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_ui_ability_lifecycle_manager.cpp @@ -418,15 +418,6 @@ int32_t UIAbilityLifecycleManager::StartSpecifiedAbilityBySCB(AbilityRequest &ab return 0; } -void UIAbilityLifecycleManager::NotifyRestartSpecifiedAbility(const AbilityRequest &request, - const sptr &token) -{ -} - -void UIAbilityLifecycleManager::NotifyStartSpecifiedAbility(AbilityRequest &abilityRequest, const AAFwk::Want &want) -{ -} - int UIAbilityLifecycleManager::MoveAbilityToFront(const SpecifiedRequest &specifiedRequest, const std::shared_ptr abilityRecord, std::shared_ptr callerAbility) { diff --git a/test/unittest/ability_manager_service_thirteenth_test/mock/src/mock_ui_ability_lifecycle_manager.cpp b/test/unittest/ability_manager_service_thirteenth_test/mock/src/mock_ui_ability_lifecycle_manager.cpp index 10a12975ccd419dba6c9c78631f38ef5e1a9f496..7362d702c451183dd6ad7fa19a9c5ee8ab946ff7 100644 --- a/test/unittest/ability_manager_service_thirteenth_test/mock/src/mock_ui_ability_lifecycle_manager.cpp +++ b/test/unittest/ability_manager_service_thirteenth_test/mock/src/mock_ui_ability_lifecycle_manager.cpp @@ -427,15 +427,6 @@ int32_t UIAbilityLifecycleManager::StartSpecifiedAbilityBySCB(AbilityRequest &ab return 0; } -void UIAbilityLifecycleManager::NotifyRestartSpecifiedAbility(const AbilityRequest &request, - const sptr &token) -{ -} - -void UIAbilityLifecycleManager::NotifyStartSpecifiedAbility(AbilityRequest &abilityRequest, const AAFwk::Want &want) -{ -} - int UIAbilityLifecycleManager::MoveAbilityToFront(const SpecifiedRequest &specifiedRequest, const std::shared_ptr abilityRecord, std::shared_ptr callerAbility) { diff --git a/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp b/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp index 0bee20422da63c8ea8221c8308d7b3a7e827bedb..c88cbeb4de3bcbedaa807870a16477df6d60b44c 100644 --- a/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp +++ b/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp @@ -2605,39 +2605,6 @@ HWTEST_F(UIAbilityLifecycleManagerTest, IsStartSpecifiedProcessRequest_007, Test EXPECT_EQ(ret, true); } -/** - * @tc.name: UIAbilityLifecycleManager_NotifyRestartSpecifiedAbility_0100 - * @tc.desc: NotifyRestartSpecifiedAbility - * @tc.type: FUNC - */ -HWTEST_F(UIAbilityLifecycleManagerTest, NotifyRestartSpecifiedAbility_001, TestSize.Level1) -{ - auto uiAbilityLifecycleManager = std::make_shared(); - EXPECT_NE(uiAbilityLifecycleManager, nullptr); - AbilityRequest request; - std::shared_ptr abilityRecord = InitAbilityRecord(); - sptr token = abilityRecord->GetToken(); - request.abilityInfoCallback = new MockAbilityInfoCallbackStub(); - uiAbilityLifecycleManager->NotifyRestartSpecifiedAbility(request, token); - uiAbilityLifecycleManager.reset(); -} - -/** - * @tc.name: UIAbilityLifecycleManager_NotifyStartSpecifiedAbility_0100 - * @tc.desc: NotifyStartSpecifiedAbility - * @tc.type: FUNC - */ -HWTEST_F(UIAbilityLifecycleManagerTest, NotifyStartSpecifiedAbility_001, TestSize.Level1) -{ - auto uiAbilityLifecycleManager = std::make_shared(); - EXPECT_NE(uiAbilityLifecycleManager, nullptr); - AbilityRequest request; - Want want; - request.abilityInfoCallback = new MockAbilityInfoCallbackStub(); - uiAbilityLifecycleManager->NotifyStartSpecifiedAbility(request, want); - uiAbilityLifecycleManager.reset(); -} - /** * @tc.name: UIAbilityLifecycleManager_MoveAbilityToFront_0100 * @tc.desc: MoveAbilityToFront