diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h index 870dfefc01a19a74c5fd96323896bb8be7865fa1..addc64f8eb427ee2a1c3b2db4d67ab52b3736798 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h @@ -978,6 +978,11 @@ enum { */ ERR_PROCESS_START_INVALID_PID = 2097386, + /** + * Result (2097387) for not expected caller native name. + */ + ERR_NOT_EXPECTED_NATIVE_CALLER_NAME = 2097387, + /** * Native error(3000000) for target bundle not exist. */ diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index f8612a2753bb41cebd23d29f0529fb5df9e61991..250c17db81a34aa1c42b51795e2e9837c22a4af2 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -2636,12 +2636,11 @@ int AbilityManagerService::StartUIAbilityBySCB(sptr sessionInfo, bo HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); XCOLLIE_TIMER_LESS(__PRETTY_FUNCTION__); TAG_LOGI(AAFwkTag::ABILITYMGR, "call, sceneFlag:%{public}u", sceneFlag); - EventInfo eventInfo = BuildEventInfo(sessionInfo->want, -1); if (sessionInfo == nullptr || sessionInfo->sessionToken == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "sessionInfo null"); - eventHelper_.SendStartAbilityErrorEvent(eventInfo, ERR_INVALID_VALUE, "sessionInfo null", true); return ERR_INVALID_VALUE; } + EventInfo eventInfo = BuildEventInfo(sessionInfo->want, -1); #ifdef MEMMGR_OVERRIDE_ENABLE WantParams wantParams = (sessionInfo->want).GetParams(); std::string bundleName = (sessionInfo->want).GetElement().GetBundleName(); diff --git a/services/abilitymgr/src/utils/update_caller_info_util.cpp b/services/abilitymgr/src/utils/update_caller_info_util.cpp index 5105b90792ce8f5742b44bf1e3c07d25c5f7bc14..f503f4e82d81eb7fbf448d4f9220da842f2080c1 100644 --- a/services/abilitymgr/src/utils/update_caller_info_util.cpp +++ b/services/abilitymgr/src/utils/update_caller_info_util.cpp @@ -15,6 +15,7 @@ #include "utils/update_caller_info_util.h" +#include "ability_event_util.h" #include "ability_util.h" #include "ability_record.h" #include "accesstoken_kit.h" @@ -335,6 +336,15 @@ void UpdateCallerInfoUtil::UpdateCallerAppCloneIndex(Want& want, int32_t appInde void UpdateCallerInfoUtil::ClearProtectedWantParam(Want &want) { + if (want.HasParameter(Want::PARAM_RESV_CALLER_NATIVE_NAME)) { + EventInfo eventInfo; + eventInfo.bundleName = want.GetElement().GetBundleName(); + eventInfo.moduleName = want.GetElement().GetModuleName(); + eventInfo.abilityName = want.GetElement().GetAbilityName(); + AbilityEventUtil eventUtil; + eventUtil.SendStartAbilityErrorEvent(eventInfo, AAFwk::ERR_NOT_EXPECTED_NATIVE_CALLER_NAME, + std::string("no expected caller native name: ") + want.GetStringParam(Want::PARAM_RESV_CALLER_NATIVE_NAME)); + } want.RemoveParam(Want::PARAM_RESV_CALLER_NATIVE_NAME); want.RemoveParam(COMPONENT_STARTUP_NEW_RULES); if (!PermissionVerification::GetInstance()->IsSystemAppCall()) { diff --git a/test/unittest/update_caller_info_util_test/update_caller_info_util_test.cpp b/test/unittest/update_caller_info_util_test/update_caller_info_util_test.cpp index 153dd98d132a389bfac529c16948ee41bbeb31a0..3c4f2557b75d525bbdfe3e40a95e5891181099cd 100644 --- a/test/unittest/update_caller_info_util_test/update_caller_info_util_test.cpp +++ b/test/unittest/update_caller_info_util_test/update_caller_info_util_test.cpp @@ -160,6 +160,21 @@ HWTEST_F(UpdateCallerInfoUtilTest, ClearProtectedWantParam_002, TestSize.Level1) EXPECT_EQ(want.GetStringParam(Want::PARAM_ABILITY_UNIFIED_DATA_KEY), ""); } +/** + * @tc.name: UpdateCallerInfoUtilTest_ClearProtectedWantParam_003 + * @tc.desc: The caller is system app, do not remove udKey. + * @tc.type: FUNC + */ +HWTEST_F(UpdateCallerInfoUtilTest, ClearProtectedWantParam_003, TestSize.Level1) +{ + std::shared_ptr updateCallerUtil = std::make_shared(); + Want want; + std::string key = "test"; + want.SetParam(Want::PARAM_RESV_CALLER_NATIVE_NAME, key); + updateCallerUtil->ClearProtectedWantParam(want); + EXPECT_EQ(want.GetStringParam(Want::PARAM_RESV_CALLER_NATIVE_NAME), ""); +} + /** * @tc.name: UpdateCallerInfoUtilTest_UpdateAsCallerInfoFromCallerRecord_0002 * @tc.desc: Test the state of QueryAllAutoStartupApplications