From b2bd96b32ed1f199d873e7ea456501b436ccfea7 Mon Sep 17 00:00:00 2001 From: jsjzju Date: Fri, 8 Nov 2024 14:13:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E4=BA=86=E9=98=B2=E6=AD=A2=E9=9C=B8?= =?UTF-8?q?=E5=B1=8F=EF=BC=8C=E8=A2=ABKillProcessWithAccount=E6=9D=80?= =?UTF-8?q?=E7=9A=84=E8=BF=9B=E7=A8=8B=EF=BC=8C=E4=B8=80=E6=AE=B5=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=86=85=E6=97=A0=E6=B3=95=E4=BD=9C=E4=B8=BA=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=96=B9=E5=8F=91=E8=B5=B7LoadAbility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jsjzju Change-Id: I62235670b9f0318cad847ff3422435edf47c5cf6 --- .../include/appmgr/ams_mgr_interface.h | 6 -- .../include/appmgr/ams_mgr_proxy.h | 2 - .../app_manager/include/appmgr/ams_mgr_stub.h | 1 - .../include/appmgr/app_mgr_client.h | 2 - .../app_manager/src/appmgr/ams_mgr_proxy.cpp | 22 ------ .../app_manager/src/appmgr/ams_mgr_stub.cpp | 14 ---- .../app_manager/src/appmgr/app_mgr_client.cpp | 13 ---- services/abilitymgr/include/app_scheduler.h | 2 - .../include/utils/ability_permission_util.h | 2 - services/abilitymgr/src/ability_record.cpp | 2 +- services/abilitymgr/src/app_scheduler.cpp | 9 --- .../ui_ability_lifecycle_manager.cpp | 16 +--- .../src/utils/ability_permission_util.cpp | 18 ----- .../src/utils/update_caller_info_util.cpp | 10 +-- services/appmgr/BUILD.gn | 1 + services/appmgr/include/ams_mgr_scheduler.h | 2 - .../appmgr/include/app_mgr_service_inner.h | 9 +-- services/appmgr/include/app_running_manager.h | 3 +- services/appmgr/include/kill_process_config.h | 30 ++++++++ .../appmgr/include/killing_process_manager.h | 43 +++++++++++ services/appmgr/src/ams_mgr_scheduler.cpp | 9 --- services/appmgr/src/app_mgr_service_inner.cpp | 51 ++++--------- services/appmgr/src/app_running_manager.cpp | 9 ++- .../appmgr/src/killing_process_manager.cpp | 76 +++++++++++++++++++ .../abilityappmgrapprunningmanager_fuzzer.cpp | 6 +- .../ams_ability_running_record_test/BUILD.gn | 1 + .../unittest/ams_app_life_cycle_test/BUILD.gn | 1 + test/unittest/ams_app_workflow_test/BUILD.gn | 1 + .../ams_mgr_scheduler_second_test.cpp | 68 ----------------- .../ams_recent_app_list_test/BUILD.gn | 1 + .../BUILD.gn | 1 + .../ams_service_event_drive_test/BUILD.gn | 1 + .../BUILD.gn | 1 + .../ams_service_startup_test/BUILD.gn | 1 + .../app_mgr_client_first_test.cpp | 15 ---- .../BUILD.gn | 1 + 36 files changed, 200 insertions(+), 250 deletions(-) create mode 100644 services/appmgr/include/kill_process_config.h create mode 100644 services/appmgr/include/killing_process_manager.h create mode 100644 services/appmgr/src/killing_process_manager.cpp diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h index c23ed0ee81..bf24b2f8e6 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h @@ -449,11 +449,6 @@ public: return false; } - virtual bool IsAppKilling(sptr token) - { - return false; - } - virtual void SetAppExceptionCallback(sptr callback) {} enum class Message { @@ -507,7 +502,6 @@ public: CLEAN_UIABILITY_BY_USER_REQUEST, FORCE_KILL_APPLICATION_BY_ACCESS_TOKEN_ID = 49, IS_PROCESS_ATTACHED, - IS_APP_KILLING, ENABLE_START_PROCESS_FLAG_BY_USER_ID, SET_APP_EXCEPTION_CALLBACK, SET_KEEP_ALIVE_DKV, diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h index 85c72fabd1..7926689b46 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h @@ -400,8 +400,6 @@ public: */ virtual bool IsProcessAttached(sptr token) override; - virtual bool IsAppKilling(sptr token) override; - virtual void SetAppExceptionCallback(sptr callback) override; private: diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h index f609278cd9..7d39abdb23 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h @@ -102,7 +102,6 @@ private: int32_t HandleCleanAbilityByUserRequest(MessageParcel &data, MessageParcel &reply); int32_t HandleIsProcessContainsOnlyUIAbility(MessageParcel &data, MessageParcel &reply); int32_t HandleIsProcessAttached(MessageParcel &data, MessageParcel &reply); - int32_t HandleIsAppKilling(MessageParcel &data, MessageParcel &reply); int32_t HandleSetAppExceptionCallback(MessageParcel &data, MessageParcel &reply); DISALLOW_COPY_AND_MOVE(AmsMgrStub); }; diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h index 48725af913..53371d0f83 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h @@ -899,8 +899,6 @@ public: */ bool IsProcessAttached(sptr token) const; - bool IsAppKilling(sptr token) const; - /** * Check whether the bundle is running. * diff --git a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp index bea80ee23c..475d894d87 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp @@ -1344,28 +1344,6 @@ bool AmsMgrProxy::IsProcessAttached(sptr token) return reply.ReadBool(); } -bool AmsMgrProxy::IsAppKilling(sptr token) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); - return false; - } - if (!data.WriteRemoteObject(token.GetRefPtr())) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write token"); - return false; - } - - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::IS_APP_KILLING), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request failed, error code is %{public}d.", ret); - return false; - } - return reply.ReadBool(); -} - void AmsMgrProxy::SetAppExceptionCallback(sptr callback) { MessageParcel data; diff --git a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp index 219f663855..5a99f7ecd0 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp @@ -213,8 +213,6 @@ int32_t AmsMgrStub::OnRemoteRequestInnerFourth(uint32_t code, MessageParcel &dat return HandleKillProcessesByAccessTokenId(data, reply); case static_cast(IAmsMgr::Message::IS_PROCESS_ATTACHED): return HandleIsProcessAttached(data, reply); - case static_cast(IAmsMgr::Message::IS_APP_KILLING): - return HandleIsAppKilling(data, reply); case static_cast(IAmsMgr::Message::SET_KEEP_ALIVE_DKV): return HandleSetKeepAliveDkv(data, reply); } @@ -863,18 +861,6 @@ int32_t AmsMgrStub::HandleIsProcessAttached(MessageParcel &data, MessageParcel & return NO_ERROR; } -int32_t AmsMgrStub::HandleIsAppKilling(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - sptr token = data.ReadRemoteObject(); - auto isAppKilling = IsAppKilling(token); - if (!reply.WriteBool(isAppKilling)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - int32_t AmsMgrStub::HandleSetAppExceptionCallback(MessageParcel &data, MessageParcel &reply) { sptr callback = data.ReadRemoteObject(); diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp index ee743fa96e..5927e9535e 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp @@ -1399,19 +1399,6 @@ bool AppMgrClient::IsProcessAttached(sptr token) const return amsService->IsProcessAttached(token); } -bool AppMgrClient::IsAppKilling(sptr token) const -{ - sptr service = iface_cast(mgrHolder_->GetRemoteObject()); - if (service == nullptr) { - return false; - } - sptr amsService = service->GetAmsMgr(); - if (amsService == nullptr) { - return false; - } - return amsService->IsAppKilling(token); -} - AppMgrResultCode AppMgrClient::IsAppRunning(const std::string &bundleName, int32_t appCloneIndex, bool &isRunning) { diff --git a/services/abilitymgr/include/app_scheduler.h b/services/abilitymgr/include/app_scheduler.h index 4b25198c28..0889a043aa 100644 --- a/services/abilitymgr/include/app_scheduler.h +++ b/services/abilitymgr/include/app_scheduler.h @@ -568,8 +568,6 @@ public: bool IsProcessAttached(sptr token) const; - bool IsAppKilling(sptr token) const; - protected: /** * OnAbilityRequestDone, app manager service call this interface after ability request done. diff --git a/services/abilitymgr/include/utils/ability_permission_util.h b/services/abilitymgr/include/utils/ability_permission_util.h index 85fe63dc0c..d41eaeaea4 100644 --- a/services/abilitymgr/include/utils/ability_permission_util.h +++ b/services/abilitymgr/include/utils/ability_permission_util.h @@ -85,8 +85,6 @@ public: */ int32_t CheckMultiInstanceKeyForExtension(const AbilityRequest &abilityRequest); - bool VerifyCallerToken(AbilityRequest &abilityRequest); - private: /** * AbilityPermissionUtil, the private constructor. diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index 082cd30e9a..1cde885b29 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -355,7 +355,7 @@ int AbilityRecord::LoadAbility(bool isShellCall) auto result = DelayedSingleton::GetInstance()->LoadAbility( loadParam, abilityInfo_, abilityInfo_.applicationInfo, want_); want_.RemoveParam(ABILITY_OWNER_USERID); - want_.RemoveParam(Want::PARAMS_NEED_CHECK_CALLER_IS_EXIST); + want_.RemoveParam(Want::PARAMS_REAL_CALLER_KEY); SetLoadState(AbilityLoadState::LOADING); if (DelayedSingleton::GetInstance()->IsAttachDebug(abilityInfo_.bundleName)) { SetAttachDebug(true); diff --git a/services/abilitymgr/src/app_scheduler.cpp b/services/abilitymgr/src/app_scheduler.cpp index 2dd4dc0448..ef1c86cd03 100644 --- a/services/abilitymgr/src/app_scheduler.cpp +++ b/services/abilitymgr/src/app_scheduler.cpp @@ -655,15 +655,6 @@ bool AppScheduler::IsProcessAttached(sptr token) const return appMgrClient_->IsProcessAttached(token); } -bool AppScheduler::IsAppKilling(sptr token) const -{ - if (!appMgrClient_) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "appMgrClient is nullptr"); - return false; - } - return appMgrClient_->IsAppKilling(token); -} - void AppScheduler::SetProcessCacheStatus(int32_t pid, bool isSupport) { if (!appMgrClient_) { 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 6cf6f77c26..17e708ff9c 100644 --- a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp +++ b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp @@ -133,7 +133,7 @@ std::shared_ptr UIAbilityLifecycleManager::GenerateAbilityRecord( TAG_LOGE(AAFwkTag::ABILITYMGR, "sessionToken invalid"); return nullptr; } - abilityRequest.want.RemoveParam(Want::PARAMS_NEED_CHECK_CALLER_IS_EXIST); + abilityRequest.want.RemoveParam(Want::PARAMS_REAL_CALLER_KEY); uiAbilityRecord->SetIsNewWant(sessionInfo->isNewWant); if (sessionInfo->isNewWant) { uiAbilityRecord->SetWant(abilityRequest.want); @@ -168,14 +168,6 @@ bool UIAbilityLifecycleManager::CheckSessionInfo(sptr sessionInfo) TAG_LOGE(AAFwkTag::ABILITYMGR, "token's Descriptor: %{public}s", descriptor.c_str()); return false; } - bool needCheckCallerIsExist = sessionInfo->want.GetBoolParam(Want::PARAMS_NEED_CHECK_CALLER_IS_EXIST, false); - if (needCheckCallerIsExist && sessionInfo->callerToken) { - auto callerAbility = Token::GetAbilityRecordByToken(sessionInfo->callerToken); - if (callerAbility == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "callerAbility not exist"); - return false; - } - } return true; } @@ -351,10 +343,10 @@ int UIAbilityLifecycleManager::NotifySCBToStartUIAbility(AbilityRequest &ability { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); abilityRequest.want.SetParam(IS_SHELL_CALL, AAFwk::PermissionVerification::GetInstance()->IsShellCall()); + std::string callerKey = std::to_string(IPCSkeleton::GetCallingPid()) + ":" + + std::to_string(IPCSkeleton::GetCallingUid()); + abilityRequest.want.SetParam(Want::PARAMS_REAL_CALLER_KEY, callerKey); std::lock_guard guard(sessionLock_); - if (!AbilityPermissionUtil::GetInstance().VerifyCallerToken(abilityRequest)) { - return ERR_INVALID_VALUE; - } // start ability with persistentId by dms int32_t persistentId = abilityRequest.want.GetIntParam(DMS_PERSISTENT_ID, 0); TAG_LOGD(AAFwkTag::ABILITYMGR, "NotifySCBToStartUIAbility, want with persistentId: %{public}d.", persistentId); diff --git a/services/abilitymgr/src/utils/ability_permission_util.cpp b/services/abilitymgr/src/utils/ability_permission_util.cpp index a4a0158d14..633b205fab 100644 --- a/services/abilitymgr/src/utils/ability_permission_util.cpp +++ b/services/abilitymgr/src/utils/ability_permission_util.cpp @@ -231,23 +231,5 @@ int32_t AbilityPermissionUtil::CheckMultiInstanceKeyForExtension(const AbilityRe } return ERR_OK; } - -bool AbilityPermissionUtil::VerifyCallerToken(AbilityRequest &abilityRequest) -{ - if (abilityRequest.callerToken == nullptr) { - return true; - } - if (PermissionVerification::GetInstance()->JudgeCallerIsAllowedToUseSystemAPI()) { - return true; - } - abilityRequest.want.SetParam(Want::PARAMS_NEED_CHECK_CALLER_IS_EXIST, true); - bool isAppKilling = IN_PROCESS_CALL(DelayedSingleton::GetInstance()->IsAppKilling( - abilityRequest.callerToken)); - if (isAppKilling) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "caller killing"); - return false; - } - return true; -} } // AAFwk } // OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/utils/update_caller_info_util.cpp b/services/abilitymgr/src/utils/update_caller_info_util.cpp index 22996082c9..0c3e4888d1 100644 --- a/services/abilitymgr/src/utils/update_caller_info_util.cpp +++ b/services/abilitymgr/src/utils/update_caller_info_util.cpp @@ -68,7 +68,7 @@ void UpdateCallerInfoUtil::UpdateCallerInfo(Want& want, const sptrGetCallerInfo(); @@ -229,7 +229,7 @@ bool UpdateCallerInfoUtil::UpdateAsCallerInfoFromDialog(Want& want) want.RemoveParam(Want::PARAM_RESV_CALLER_NATIVE_NAME); want.RemoveParam(WANT_PARAMS_APP_RESTART_FLAG); want.RemoveParam(IS_SHELL_CALL); - want.RemoveParam(Want::PARAMS_NEED_CHECK_CALLER_IS_EXIST); + want.RemoveParam(Want::PARAMS_REAL_CALLER_KEY); if (callerBundleName == "") { want.SetParam(Want::PARAM_RESV_CALLER_NATIVE_NAME, dialogCallerWant.GetStringParam(Want::PARAM_RESV_CALLER_NATIVE_NAME)); @@ -258,7 +258,7 @@ void UpdateCallerInfoUtil::UpdateCallerInfoFromToken(Want& want, const sptrGetAbilityInfo().bundleName; want.RemoveParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME); diff --git a/services/appmgr/BUILD.gn b/services/appmgr/BUILD.gn index 5bc74ef087..abc5501970 100644 --- a/services/appmgr/BUILD.gn +++ b/services/appmgr/BUILD.gn @@ -63,6 +63,7 @@ ohos_shared_library("libappms") { "src/cache_process_manager.cpp", "src/child_process_record.cpp", "src/exit_resident_process_manager.cpp", + "src/killing_process_manager.cpp", "src/modal_system_app_freeze_uiextension.cpp", "src/module_running_record.cpp", "src/quick_fix_callback_with_record.cpp", diff --git a/services/appmgr/include/ams_mgr_scheduler.h b/services/appmgr/include/ams_mgr_scheduler.h index 67f66b3a89..b6c82d2a06 100644 --- a/services/appmgr/include/ams_mgr_scheduler.h +++ b/services/appmgr/include/ams_mgr_scheduler.h @@ -427,8 +427,6 @@ public: */ virtual bool IsProcessAttached(sptr token) override; - virtual bool IsAppKilling(sptr token) override; - virtual void SetAppExceptionCallback(sptr callback) override; private: diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 14b931c52f..9414f9d50c 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -60,6 +60,7 @@ #include "irender_state_observer.h" #include "istart_specified_ability_response.h" #include "kia_interceptor_interface.h" +#include "kill_process_config.h" #include "record_query_result.h" #include "refbase.h" #include "remote_client_manager.h" @@ -1368,12 +1369,6 @@ public: */ bool IsProcessAttached(sptr token) const; - /** - * Is a process of a ability will be killed - * @param indicates the ability - */ - bool IsAppKilling(sptr token) const; - /** * @brief Notify abilityms app process pre cache * @param pid process pid. @@ -1515,7 +1510,7 @@ private: * @return ERR_OK, return back success, others fail. */ int32_t KillApplicationByUserIdLocked(const std::string &bundleName, int32_t appCloneIndex, int32_t userId, - const bool clearPageStack = false, const std::string& reason = "KillApplicationByUserIdLocked"); + const KillProcessConfig &config = {}); /** * WaitForRemoteProcessExit, Wait for the process to exit normally. diff --git a/services/appmgr/include/app_running_manager.h b/services/appmgr/include/app_running_manager.h index 3ff5afdfb5..b6f1d51ab4 100644 --- a/services/appmgr/include/app_running_manager.h +++ b/services/appmgr/include/app_running_manager.h @@ -32,6 +32,7 @@ #include "bundle_info.h" #include "configuration.h" #include "iremote_object.h" +#include "kill_process_config.h" #include "record_query_result.h" #include "refbase.h" #include "running_process_info.h" @@ -253,7 +254,7 @@ public: int32_t ProcessUpdateApplicationInfoInstalled(const ApplicationInfo &appInfo); bool ProcessExitByBundleNameAndUid( - const std::string &bundleName, const int uid, std::list &pids, const bool clearPageStack = false); + const std::string &bundleName, const int uid, std::list &pids, const KillProcessConfig &config = {}); bool ProcessExitByBundleNameAndAppIndex(const std::string &bundleName, int32_t appIndex, std::list &pids, bool clearPageStack); bool ProcessExitByTokenIdAndInstance(uint32_t accessTokenId, const std::string &instanceKey, std::list &pids, diff --git a/services/appmgr/include/kill_process_config.h b/services/appmgr/include/kill_process_config.h new file mode 100644 index 0000000000..76676c0cd6 --- /dev/null +++ b/services/appmgr/include/kill_process_config.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_KILL_PROCESS_CONFIG_H +#define OHOS_ABILITY_RUNTIME_KILL_PROCESS_CONFIG_H + +#include + +namespace OHOS { +namespace AppExecFwk { +struct KillProcessConfig { + bool clearPageStack = false; + bool addKillingCaller = false; + std::string reason; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_KILL_PROCESS_CONFIG_H diff --git a/services/appmgr/include/killing_process_manager.h b/services/appmgr/include/killing_process_manager.h new file mode 100644 index 0000000000..684a8b3e3b --- /dev/null +++ b/services/appmgr/include/killing_process_manager.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_KILLING_PROCESS_MANAGER_H +#define OHOS_ABILITY_RUNTIME_KILLING_PROCESS_MANAGER_H + +#include +#include + +#include "cpp/mutex.h" +#include "nocopyable.h" + +namespace OHOS { +namespace AppExecFwk { +class KillingProcessManager { +public: + static KillingProcessManager& GetInstance(); + ~KillingProcessManager() = default; + bool IsCallerKilling(std::string callerKey) const; + void AddKillingCallerKey(std::string callerKey); + void RemoveKillingCallerKey(std::string callerKey); + +private: + KillingProcessManager() = default; + mutable ffrt::mutex mutex_; + std::unordered_set killingCallerKeySet_; + DISALLOW_COPY_AND_MOVE(KillingProcessManager); +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_KILLING_PROCESS_MANAGER_H diff --git a/services/appmgr/src/ams_mgr_scheduler.cpp b/services/appmgr/src/ams_mgr_scheduler.cpp index ea4ba003a8..5628928d48 100644 --- a/services/appmgr/src/ams_mgr_scheduler.cpp +++ b/services/appmgr/src/ams_mgr_scheduler.cpp @@ -752,15 +752,6 @@ bool AmsMgrScheduler::IsProcessAttached(sptr token) return amsMgrServiceInner_->IsProcessAttached(token); } -bool AmsMgrScheduler::IsAppKilling(sptr token) -{ - if (!IsReady()) { - TAG_LOGE(AAFwkTag::APPMGR, "AmsMgrService is not ready."); - return false; - } - return amsMgrServiceInner_->IsAppKilling(token); -} - void AmsMgrScheduler::SetAppExceptionCallback(sptr callback) { if (!IsReady()) { diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index a89f42671f..d486694e4d 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -54,6 +54,7 @@ #include "iremote_object.h" #include "iservice_registry.h" #include "itest_observer.h" +#include "killing_process_manager.h" #ifdef SUPPORT_SCREEN #include "locale_config.h" #endif @@ -842,19 +843,11 @@ bool AppMgrServiceInner::CheckLoadAbilityConditions(std::shared_ptr TAG_LOGE(AAFwkTag::APPMGR, "abilityInfo and appInfo have diff appName"); return false; } - bool needCheckCallerIsExist = false; if (want) { - needCheckCallerIsExist = want->GetBoolParam(Want::PARAMS_NEED_CHECK_CALLER_IS_EXIST, false); - want->RemoveParam(Want::PARAMS_NEED_CHECK_CALLER_IS_EXIST); - } - if (needCheckCallerIsExist && loadParam->preToken) { - auto appRecord = GetAppRunningRecordByAbilityToken(loadParam->preToken); - if (appRecord == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "preToken not exist"); - return false; - } - if (appRecord->IsKilling()) { - TAG_LOGE(AAFwkTag::APPMGR, "app is killing"); + std::string callerKey = want->GetStringParam(Want::PARAMS_REAL_CALLER_KEY); + want->RemoveParam(Want::PARAMS_REAL_CALLER_KEY); + if (!callerKey.empty() && KillingProcessManager::GetInstance().IsCallerKilling(callerKey)) { + TAG_LOGE(AAFwkTag::APPMGR, "caller is killing"); return false; } } @@ -1692,7 +1685,8 @@ int32_t AppMgrServiceInner::KillApplicationSelf(const bool clearPageStack, const auto callingUid = IPCSkeleton::GetCallingUid(); TAG_LOGI(AAFwkTag::APPMGR, "uid value: %{public}d", callingUid); std::list pids; - if (!appRunningManager_->ProcessExitByBundleNameAndUid(bundleName, callingUid, pids, clearPageStack)) { + KillProcessConfig config{clearPageStack, false, reason}; + if (!appRunningManager_->ProcessExitByBundleNameAndUid(bundleName, callingUid, pids, config)) { TAG_LOGI(AAFwkTag::APPMGR, "unstart"); return ERR_OK; } @@ -1783,12 +1777,12 @@ int32_t AppMgrServiceInner::KillApplicationByUserId( return ERR_PERMISSION_DENIED; } - return KillApplicationByUserIdLocked(bundleName, appCloneIndex, userId, clearPageStack, reason); + KillProcessConfig config{clearPageStack, true, reason}; + return KillApplicationByUserIdLocked(bundleName, appCloneIndex, userId, config); } int32_t AppMgrServiceInner::KillApplicationByUserIdLocked( - const std::string &bundleName, int32_t appCloneIndex, const int userId, - const bool clearPageStack, const std::string& reason) + const std::string &bundleName, int32_t appCloneIndex, const int userId, const KillProcessConfig &config) { if (!appRunningManager_) { TAG_LOGE(AAFwkTag::APPMGR, "appRunningManager_ null"); @@ -1811,7 +1805,7 @@ int32_t AppMgrServiceInner::KillApplicationByUserIdLocked( TAG_LOGI(AAFwkTag::APPMGR, "uId value: %{public}d", userId); int uid = IN_PROCESS_CALL(bundleMgrHelper->GetUidByBundleName(bundleName, userId, appCloneIndex)); TAG_LOGI(AAFwkTag::APPMGR, "uID value: %{public}d", uid); - if (!appRunningManager_->ProcessExitByBundleNameAndUid(bundleName, uid, pids, clearPageStack)) { + if (!appRunningManager_->ProcessExitByBundleNameAndUid(bundleName, uid, pids, config)) { TAG_LOGI(AAFwkTag::APPMGR, "process corresponding package name unstart"); return result; } @@ -1820,7 +1814,7 @@ int32_t AppMgrServiceInner::KillApplicationByUserIdLocked( return result; } for (auto iter = pids.begin(); iter != pids.end(); ++iter) { - result = KillProcessByPid(*iter, reason); + result = KillProcessByPid(*iter, config.reason); if (result < 0) { TAG_LOGE(AAFwkTag::APPMGR, "killApplication fail bundleName: %{public}s pid: %{public}d", bundleName.c_str(), *iter); @@ -4380,7 +4374,8 @@ int AppMgrServiceInner::StartUserTestProcess( return ERR_INVALID_VALUE; } - if (KillApplicationByUserIdLocked(bundleName, 0, userId, false, "StartUserTestProcess")) { + KillProcessConfig config{false, false, "StartUserTestProcess"}; + if (KillApplicationByUserIdLocked(bundleName, 0, userId, config)) { TAG_LOGE(AAFwkTag::APPMGR, "kill app fail"); return ERR_INVALID_VALUE; } @@ -4532,7 +4527,8 @@ int AppMgrServiceInner::FinishUserTest( FinishUserTestLocked(msg, resultCode, appRecord); - int ret = KillApplicationByUserIdLocked(bundleName, 0, userTestRecord->userId, false, "FinishUserTest"); + KillProcessConfig config{false, false, "FinishUserTest"}; + int ret = KillApplicationByUserIdLocked(bundleName, 0, userTestRecord->userId, config); if (ret) { TAG_LOGE(AAFwkTag::APPMGR, "kill process fail"); return ret; @@ -8434,21 +8430,6 @@ bool AppMgrServiceInner::IsProcessAttached(sptr token) const return appRecord->IsProcessAttached(); } -bool AppMgrServiceInner::IsAppKilling(sptr token) const -{ - HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); - if (IPCSkeleton::GetCallingUid() != FOUNDATION_UID) { - TAG_LOGE(AAFwkTag::APPMGR, "Not foundation call."); - return false; - } - auto appRecord = GetAppRunningRecordByAbilityToken(token); - if (appRecord == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "abilityRecord is nullptr"); - return false; - } - return appRecord->IsKilling(); -} - int32_t AppMgrServiceInner::GetSupportedProcessCachePids(const std::string &bundleName, std::vector &pidList) { diff --git a/services/appmgr/src/app_running_manager.cpp b/services/appmgr/src/app_running_manager.cpp index 26ce7a01bc..4301657f4e 100644 --- a/services/appmgr/src/app_running_manager.cpp +++ b/services/appmgr/src/app_running_manager.cpp @@ -26,6 +26,7 @@ #include "freeze_util.h" #include "hilog_tag_wrapper.h" #include "hitrace_meter.h" +#include "killing_process_manager.h" #include "os_account_manager_wrapper.h" #include "perf_profile.h" #include "parameters.h" @@ -338,7 +339,7 @@ int32_t AppRunningManager::ProcessUpdateApplicationInfoInstalled(const Applicati } bool AppRunningManager::ProcessExitByBundleNameAndUid( - const std::string &bundleName, const int uid, std::list &pids, const bool clearPageStack) + const std::string &bundleName, const int uid, std::list &pids, const KillProcessConfig &config) { auto appRunningMap = GetAppRunningRecordMap(); for (const auto &item : appRunningMap) { @@ -356,9 +357,13 @@ bool AppRunningManager::ProcessExitByBundleNameAndUid( continue; } pids.push_back(pid); - if (clearPageStack) { + if (config.clearPageStack) { appRecord->ScheduleClearPageStack(); } + if (config.addKillingCaller) { + std::string callerKey = std::to_string(pid) + ":" + std::to_string(appRecord->GetUid()); + KillingProcessManager::GetInstance().AddKillingCallerKey(callerKey); + } appRecord->SetKilling(); appRecord->ScheduleProcessSecurityExit(); } diff --git a/services/appmgr/src/killing_process_manager.cpp b/services/appmgr/src/killing_process_manager.cpp new file mode 100644 index 0000000000..e42ec469f5 --- /dev/null +++ b/services/appmgr/src/killing_process_manager.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "killing_process_manager.h" + +#include + +#include "hilog_tag_wrapper.h" +#include "task_handler_wrap.h" + +namespace OHOS { +namespace AppExecFwk { +namespace { +constexpr int32_t CLEAR_CALLER_KEY_DELAY_TIME = 5 * 1000; // 5s +} +KillingProcessManager& KillingProcessManager::GetInstance() +{ + static KillingProcessManager instance; + return instance; +} + +bool KillingProcessManager::IsCallerKilling(std::string callerKey) const +{ + std::lock_guard lock(mutex_); + return killingCallerKeySet_.find(callerKey) != killingCallerKeySet_.end(); +} + +void KillingProcessManager::AddKillingCallerKey(std::string callerKey) +{ + auto taskHandler = AAFwk::TaskHandlerWrap::GetFfrtHandler(); + if (taskHandler == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "handler is null"); + return; + } + if (callerKey.empty()) { + TAG_LOGE(AAFwkTag::APPMGR, "invalid callerKey"); + return; + } + TAG_LOGI(AAFwkTag::APPMGR, "add caller:%{public}s", callerKey.c_str()); + { + std::lock_guard lock(mutex_); + auto ret = killingCallerKeySet_.insert(callerKey); + if (!ret.second) { + TAG_LOGI(AAFwkTag::APPMGR, "already inserted"); + } + } + auto task = [callerKey] () { + KillingProcessManager::GetInstance().RemoveKillingCallerKey(callerKey); + }; + taskHandler->SubmitTask(task, "clearCallerKey", CLEAR_CALLER_KEY_DELAY_TIME); +} + +void KillingProcessManager::RemoveKillingCallerKey(std::string callerKey) +{ + if (callerKey.empty()) { + TAG_LOGE(AAFwkTag::APPMGR, "invalid callerKey"); + return; + } + TAG_LOGI(AAFwkTag::APPMGR, "remove caller:%{public}s", callerKey.c_str()); + std::lock_guard lock(mutex_); + killingCallerKeySet_.erase(callerKey); +} +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/fuzztest/abilityappmgrapprunningmanager_fuzzer/abilityappmgrapprunningmanager_fuzzer.cpp b/test/fuzztest/abilityappmgrapprunningmanager_fuzzer/abilityappmgrapprunningmanager_fuzzer.cpp index 88c44318e8..8bfabe360b 100644 --- a/test/fuzztest/abilityappmgrapprunningmanager_fuzzer/abilityappmgrapprunningmanager_fuzzer.cpp +++ b/test/fuzztest/abilityappmgrapprunningmanager_fuzzer/abilityappmgrapprunningmanager_fuzzer.cpp @@ -26,6 +26,7 @@ #undef private #include "securec.h" #include "ability_record.h" +#include "kill_process_config.h" using namespace OHOS::AAFwk; @@ -82,8 +83,9 @@ void DoSomethingInterestingWithMyAPIadda(const char* data, size_t size) ApplicationInfo appInfos; manager->ProcessUpdateApplicationInfoInstalled(appInfos); std::list pids; - bool clearPageStack = *data % ENABLE; - manager->ProcessExitByBundleNameAndUid(jsonStr, uid, pids, clearPageStack); + KillProcessConfig config; + config.clearPageStack = *data % ENABLE; + manager->ProcessExitByBundleNameAndUid(jsonStr, uid, pids, config); int32_t userId = static_cast(GetU32Data(data)); manager->GetPidsByUserId(userId, pids); manager->PrepareTerminate(token, clearMissionFlag); diff --git a/test/unittest/ams_ability_running_record_test/BUILD.gn b/test/unittest/ams_ability_running_record_test/BUILD.gn index ea86ff39e6..57c1dc2bec 100644 --- a/test/unittest/ams_ability_running_record_test/BUILD.gn +++ b/test/unittest/ams_ability_running_record_test/BUILD.gn @@ -43,6 +43,7 @@ ohos_unittest("AmsAbilityRunningRecordTest") { "${ability_runtime_services_path}/appmgr/src/cache_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/child_process_record.cpp", "${ability_runtime_services_path}/appmgr/src/exit_resident_process_manager.cpp", + "${ability_runtime_services_path}/appmgr/src/killing_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/render_state_observer_manager.cpp", "${ability_runtime_services_path}/appmgr/src/user_record_manager.cpp", ] diff --git a/test/unittest/ams_app_life_cycle_test/BUILD.gn b/test/unittest/ams_app_life_cycle_test/BUILD.gn index cfa1eaecb1..8de60f30c2 100644 --- a/test/unittest/ams_app_life_cycle_test/BUILD.gn +++ b/test/unittest/ams_app_life_cycle_test/BUILD.gn @@ -38,6 +38,7 @@ ohos_unittest("AmsAppLifeCycleTest") { "${ability_runtime_services_path}/appmgr/src/app_spawn_client.cpp", "${ability_runtime_services_path}/appmgr/src/app_state_observer_manager.cpp", "${ability_runtime_services_path}/appmgr/src/cache_process_manager.cpp", + "${ability_runtime_services_path}/appmgr/src/killing_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/module_running_record.cpp", "${ability_runtime_services_path}/appmgr/src/remote_client_manager.cpp", "${ability_runtime_test_path}/mock/services_appmgr_test/src/mock_bundle_manager.cpp", diff --git a/test/unittest/ams_app_workflow_test/BUILD.gn b/test/unittest/ams_app_workflow_test/BUILD.gn index 430c126690..241479c968 100644 --- a/test/unittest/ams_app_workflow_test/BUILD.gn +++ b/test/unittest/ams_app_workflow_test/BUILD.gn @@ -39,6 +39,7 @@ ohos_unittest("AmsWorkFlowTest") { "${ability_runtime_services_path}/appmgr/src/app_spawn_client.cpp", "${ability_runtime_services_path}/appmgr/src/app_state_observer_manager.cpp", "${ability_runtime_services_path}/appmgr/src/cache_process_manager.cpp", + "${ability_runtime_services_path}/appmgr/src/killing_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/module_running_record.cpp", "${ability_runtime_services_path}/appmgr/src/remote_client_manager.cpp", "${ability_runtime_services_path}/appmgr/src/window_focus_changed_listener.cpp", diff --git a/test/unittest/ams_mgr_scheduler_second_test/ams_mgr_scheduler_second_test.cpp b/test/unittest/ams_mgr_scheduler_second_test/ams_mgr_scheduler_second_test.cpp index d6a0e8424e..e98fff9382 100644 --- a/test/unittest/ams_mgr_scheduler_second_test/ams_mgr_scheduler_second_test.cpp +++ b/test/unittest/ams_mgr_scheduler_second_test/ams_mgr_scheduler_second_test.cpp @@ -2060,74 +2060,6 @@ HWTEST_F(AmsMgrSchedulerSecondTest, AmsMgrSchedulerSecondTest_IsProcessAttached_ EXPECT_FALSE(ret); TAG_LOGI(AAFwkTag::TEST, "AmsMgrSchedulerSecondTest_IsProcessAttached_003 end"); } - -/* - * @tc.name: AmsMgrSchedulerSecondTest_IsAppKilling_001 - * @tc.desc: Test IsAppKilling - * @tc.type: FUNC - */ -HWTEST_F(AmsMgrSchedulerSecondTest, AmsMgrSchedulerSecondTest_IsAppKilling_001, TestSize.Level1) -{ - TAG_LOGI(AAFwkTag::TEST, "AmsMgrSchedulerSecondTest_IsAppKilling_001 start"); - auto appMgrServiceInner = std::make_shared(); - std::shared_ptr amsMgrScheduler = - std::make_shared(appMgrServiceInner, nullptr); - - /** - * @tc.steps: step1. amsMgrScheduler isReady false - * @tc.expected: step1. expect ERR_INVALID_OPERATION - */ - sptr token = nullptr; - auto ret = amsMgrScheduler->IsAppKilling(token); - EXPECT_FALSE(ret); - TAG_LOGI(AAFwkTag::TEST, "AmsMgrSchedulerSecondTest_IsAppKilling_001 end"); -} - -/* - * @tc.name: AmsMgrSchedulerSecondTest_IsAppKilling_002 - * @tc.desc: Test IsAppKilling - * @tc.type: FUNC - */ -HWTEST_F(AmsMgrSchedulerSecondTest, AmsMgrSchedulerSecondTest_IsAppKilling_002, TestSize.Level1) -{ - TAG_LOGI(AAFwkTag::TEST, "AmsMgrSchedulerSecondTest_IsAppKilling_002 start"); - auto appMgrServiceInner = std::make_shared(); - std::shared_ptr amsMgrScheduler = - std::make_shared(appMgrServiceInner, taskHandler_); - - /** - * @tc.steps: step1. amsMgrScheduler isReady false - * @tc.expected: step1. expect ERR_INVALID_OPERATION - */ - IPCSkeleton::SetCallingUid(-1); - sptr token = nullptr; - auto ret = amsMgrScheduler->IsAppKilling(token); - EXPECT_FALSE(ret); - TAG_LOGI(AAFwkTag::TEST, "AmsMgrSchedulerSecondTest_IsAppKilling_002 end"); -} - -/* - * @tc.name: AmsMgrSchedulerSecondTest_IsAppKilling_003 - * @tc.desc: Test IsAppKilling - * @tc.type: FUNC - */ -HWTEST_F(AmsMgrSchedulerSecondTest, AmsMgrSchedulerSecondTest_IsAppKilling_003, TestSize.Level1) -{ - TAG_LOGI(AAFwkTag::TEST, "AmsMgrSchedulerSecondTest_IsAppKilling_003 start"); - auto appMgrServiceInner = std::make_shared(); - std::shared_ptr amsMgrScheduler = - std::make_shared(appMgrServiceInner, taskHandler_); - - /** - * @tc.steps: step1. amsMgrScheduler isReady false - * @tc.expected: step1. expect ERR_INVALID_OPERATION - */ - IPCSkeleton::SetCallingUid(Constants::FOUNDATION_UID); - sptr token = nullptr; - auto ret = amsMgrScheduler->IsAppKilling(token); - EXPECT_FALSE(ret); - TAG_LOGI(AAFwkTag::TEST, "AmsMgrSchedulerSecondTest_IsAppKilling_003 end"); -} } // AppExecFwk } // OHOS diff --git a/test/unittest/ams_recent_app_list_test/BUILD.gn b/test/unittest/ams_recent_app_list_test/BUILD.gn index 93f5992024..ff2e3aed4c 100644 --- a/test/unittest/ams_recent_app_list_test/BUILD.gn +++ b/test/unittest/ams_recent_app_list_test/BUILD.gn @@ -43,6 +43,7 @@ ohos_unittest("AmsRecentAppListTest") { "${ability_runtime_services_path}/appmgr/src/cache_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/child_process_record.cpp", "${ability_runtime_services_path}/appmgr/src/exit_resident_process_manager.cpp", + "${ability_runtime_services_path}/appmgr/src/killing_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/module_running_record.cpp", "${ability_runtime_services_path}/appmgr/src/remote_client_manager.cpp", "${ability_runtime_services_path}/appmgr/src/render_state_observer_manager.cpp", diff --git a/test/unittest/ams_service_app_spawn_client_test/BUILD.gn b/test/unittest/ams_service_app_spawn_client_test/BUILD.gn index 6951ddde2b..0db41c7ad6 100644 --- a/test/unittest/ams_service_app_spawn_client_test/BUILD.gn +++ b/test/unittest/ams_service_app_spawn_client_test/BUILD.gn @@ -48,6 +48,7 @@ ohos_unittest("AmsServiceAppSpawnClientTest") { "${ability_runtime_services_path}/appmgr/src/cache_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/child_process_record.cpp", "${ability_runtime_services_path}/appmgr/src/exit_resident_process_manager.cpp", + "${ability_runtime_services_path}/appmgr/src/killing_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/render_state_observer_manager.cpp", "${ability_runtime_services_path}/appmgr/src/user_record_manager.cpp", ] diff --git a/test/unittest/ams_service_event_drive_test/BUILD.gn b/test/unittest/ams_service_event_drive_test/BUILD.gn index 3d9a33d4c7..9a84e0f1cf 100644 --- a/test/unittest/ams_service_event_drive_test/BUILD.gn +++ b/test/unittest/ams_service_event_drive_test/BUILD.gn @@ -47,6 +47,7 @@ ohos_unittest("AmsServiceEventDriveTest") { "${ability_runtime_services_path}/appmgr/src/cache_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/child_process_record.cpp", "${ability_runtime_services_path}/appmgr/src/exit_resident_process_manager.cpp", + "${ability_runtime_services_path}/appmgr/src/killing_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/render_state_observer_manager.cpp", "${ability_runtime_services_path}/appmgr/src/user_record_manager.cpp", "${ability_runtime_test_path}/mock/common/src/mock_native_token.cpp", diff --git a/test/unittest/ams_service_load_ability_process_test/BUILD.gn b/test/unittest/ams_service_load_ability_process_test/BUILD.gn index 55909de93f..49f0172280 100644 --- a/test/unittest/ams_service_load_ability_process_test/BUILD.gn +++ b/test/unittest/ams_service_load_ability_process_test/BUILD.gn @@ -44,6 +44,7 @@ ohos_unittest("AmsServiceLoadAbilityProcessTest") { "${ability_runtime_services_path}/appmgr/src/cache_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/child_process_record.cpp", "${ability_runtime_services_path}/appmgr/src/exit_resident_process_manager.cpp", + "${ability_runtime_services_path}/appmgr/src/killing_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/module_running_record.cpp", "${ability_runtime_services_path}/appmgr/src/remote_client_manager.cpp", "${ability_runtime_services_path}/appmgr/src/render_state_observer_manager.cpp", diff --git a/test/unittest/ams_service_startup_test/BUILD.gn b/test/unittest/ams_service_startup_test/BUILD.gn index 0f9c75382f..9e79d8cc45 100644 --- a/test/unittest/ams_service_startup_test/BUILD.gn +++ b/test/unittest/ams_service_startup_test/BUILD.gn @@ -45,6 +45,7 @@ ohos_unittest("AmsServiceStartupTest") { "${ability_runtime_services_path}/appmgr/src/cache_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/child_process_record.cpp", "${ability_runtime_services_path}/appmgr/src/exit_resident_process_manager.cpp", + "${ability_runtime_services_path}/appmgr/src/killing_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/render_state_observer_manager.cpp", "${ability_runtime_services_path}/appmgr/src/user_record_manager.cpp", ] diff --git a/test/unittest/app_mgr_client_first_test/app_mgr_client_first_test.cpp b/test/unittest/app_mgr_client_first_test/app_mgr_client_first_test.cpp index 2c41280025..fc433dacd1 100644 --- a/test/unittest/app_mgr_client_first_test/app_mgr_client_first_test.cpp +++ b/test/unittest/app_mgr_client_first_test/app_mgr_client_first_test.cpp @@ -194,20 +194,5 @@ HWTEST_F(AppMgrClientFirstTest, CleanAbilityByUserRequest_001, TestSize.Level0) EXPECT_TRUE(result != true); TAG_LOGI(AAFwkTag::TEST, "CleanAbilityByUserRequest_001 end"); } - -/** - * @tc.name: IsAppKilling_001 - * @tc.desc: AppMgrClient test for IsAppKilling. - * @tc.type: FUNC - */ -HWTEST_F(AppMgrClientFirstTest, IsAppKilling_001, TestSize.Level0) -{ - TAG_LOGI(AAFwkTag::TEST, "IsAppKilling_001 start"); - auto appMgrClient = std::make_unique(); - sptr token = GetTestAbilityToken(); - auto result = appMgrClient->IsAppKilling(token); - EXPECT_TRUE(result != true); - TAG_LOGI(AAFwkTag::TEST, "IsAppKilling_001 end"); -} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/app_mgr_service_event_handler_test/BUILD.gn b/test/unittest/app_mgr_service_event_handler_test/BUILD.gn index 6990c0981b..839410b456 100644 --- a/test/unittest/app_mgr_service_event_handler_test/BUILD.gn +++ b/test/unittest/app_mgr_service_event_handler_test/BUILD.gn @@ -40,6 +40,7 @@ ohos_unittest("AMSEventHandlerTest") { "${ability_runtime_services_path}/appmgr/src/cache_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/child_process_record.cpp", "${ability_runtime_services_path}/appmgr/src/exit_resident_process_manager.cpp", + "${ability_runtime_services_path}/appmgr/src/killing_process_manager.cpp", "${ability_runtime_services_path}/appmgr/src/module_running_record.cpp", "${ability_runtime_services_path}/appmgr/src/remote_client_manager.cpp", "${ability_runtime_services_path}/appmgr/src/render_state_observer_manager.cpp",