From 5cdee7f740cd0448fa3c7720add8ee864d326bae Mon Sep 17 00:00:00 2001 From: hanchenZz Date: Tue, 14 Jan 2025 20:49:10 +0800 Subject: [PATCH] killproceewithreason and set rss pss Signed-off-by: hanchenZz --- .../include/ability_manager_client.h | 9 ++ .../include/ability_manager_interface.h | 5 ++ .../ability_manager_ipc_interface_code.h | 2 + .../ability_manager/include/ability_state.h | 4 +- .../ability_manager/include/exit_reason.h | 2 + interfaces/inner_api/app_manager/BUILD.gn | 1 + .../include/appmgr/app_mgr_client.h | 8 ++ .../include/appmgr/app_mgr_interface.h | 13 +++ .../appmgr/app_mgr_ipc_interface_code.h | 1 + .../include/appmgr/app_mgr_proxy.h | 9 ++ .../app_manager/include/appmgr/app_mgr_stub.h | 1 + .../include/appmgr/process_memory_state.h | 37 ++++++++ .../include/appmgr/running_process_info.h | 3 +- .../app_manager/src/appmgr/app_mgr_client.cpp | 10 +++ .../app_manager/src/appmgr/app_mgr_proxy.cpp | 33 +++++++ .../app_manager/src/appmgr/app_mgr_stub.cpp | 26 ++++++ .../src/appmgr/process_memory_state.cpp | 57 ++++++++++++ .../src/appmgr/running_process_info.cpp | 8 ++ .../include/ability_manager_proxy.h | 8 ++ .../include/ability_manager_service.h | 2 + .../abilitymgr/include/ability_manager_stub.h | 2 + .../include/app_exit_reason_data_manager.h | 6 ++ .../include/app_exit_reason_helper.h | 1 + .../abilitymgr/src/ability_manager_client.cpp | 8 ++ .../abilitymgr/src/ability_manager_proxy.cpp | 26 ++++++ .../src/ability_manager_service.cpp | 23 +++++ .../abilitymgr/src/ability_manager_stub.cpp | 19 ++++ .../src/app_exit_reason_data_manager.cpp | 87 +++++++++++++++++++ .../abilitymgr/src/app_exit_reason_helper.cpp | 8 ++ services/abilitymgr/src/exit_reason.cpp | 11 ++- services/appmgr/include/app_mgr_service.h | 8 ++ .../appmgr/include/app_mgr_service_inner.h | 9 ++ services/appmgr/include/app_running_record.h | 23 +++++ services/appmgr/src/app_mgr_service.cpp | 23 +++++ services/appmgr/src/app_mgr_service_inner.cpp | 14 +++ services/appmgr/src/app_running_manager.cpp | 2 + 36 files changed, 506 insertions(+), 3 deletions(-) create mode 100644 interfaces/inner_api/app_manager/include/appmgr/process_memory_state.h create mode 100644 interfaces/inner_api/app_manager/src/appmgr/process_memory_state.cpp diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_client.h b/interfaces/inner_api/ability_manager/include/ability_manager_client.h index e55d70aca1..b4d532caf5 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_client.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_client.h @@ -1001,6 +1001,15 @@ public: ErrCode KillProcessWithPrepareTerminate(const std::vector& pids); + /** + * kill the process with reason + * + * @param pid id of process. + * @param reason, kill process reason. + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode KillProcessWithReason(int32_t pid, const ExitReason &reason); + /** * @brief Register auto start up callback for system api. * @param callback The point of JsAbilityAutoStartupCallBack. diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h index 8cf4d74a29..641582fed9 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -1535,6 +1535,11 @@ public: return 0; } + virtual int32_t KillProcessWithReason(int32_t pid, const ExitReason &reason) + { + return 0; + } + /** * @brief Register auto start up callback for system api. * @param callback The point of JsAbilityAutoStartupCallBack. diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h b/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h index da145c8c21..456de9d139 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h @@ -517,6 +517,8 @@ enum class AbilityManagerInterfaceCode { REGISTER_STATUS_BAR_DELEGATE = 5100, KILL_PROCESS_WITH_PREPARE_TERMINATE = 5101, + KILL_PROCESS_WITH_REASON = 5200, + FORCE_EXIT_APP = 6001, RECORD_APP_EXIT_REASON = 6002, RECORD_PROCESS_EXIT_REASON = 6003, diff --git a/interfaces/inner_api/ability_manager/include/ability_state.h b/interfaces/inner_api/ability_manager/include/ability_state.h index b37b6cf158..e1dc60c851 100644 --- a/interfaces/inner_api/ability_manager/include/ability_state.h +++ b/interfaces/inner_api/ability_manager/include/ability_state.h @@ -59,7 +59,9 @@ enum Reason { REASON_PERFORMANCE_CONTROL, REASON_RESOURCE_CONTROL, REASON_UPGRADE, - REASON_MAX = REASON_UPGRADE, + REASON_USER_REQUEST, + REASON_SIGNAL, + REASON_MAX = REASON_SIGNAL, }; enum UserStatus { diff --git a/interfaces/inner_api/ability_manager/include/exit_reason.h b/interfaces/inner_api/ability_manager/include/exit_reason.h index d8f1d3f05c..25de51bc8b 100644 --- a/interfaces/inner_api/ability_manager/include/exit_reason.h +++ b/interfaces/inner_api/ability_manager/include/exit_reason.h @@ -26,8 +26,10 @@ namespace AAFwk { struct ExitReason : public Parcelable { ExitReason() = default; ExitReason(const Reason reason, const std::string &exitMsg); + ExitReason(const Reason &reason, int32_t subReason, const std::string &exitMsg); Reason reason = Reason::REASON_UNKNOWN; + int32_t subReason = -1; std::string exitMsg = ""; bool ReadFromParcel(Parcel &parcel); diff --git a/interfaces/inner_api/app_manager/BUILD.gn b/interfaces/inner_api/app_manager/BUILD.gn index 0b4152f66e..307eccd788 100644 --- a/interfaces/inner_api/app_manager/BUILD.gn +++ b/interfaces/inner_api/app_manager/BUILD.gn @@ -102,6 +102,7 @@ ohos_shared_library("app_manager") { "src/appmgr/priority_object.cpp", "src/appmgr/process_data.cpp", "src/appmgr/process_info.cpp", + "src/appmgr/process_memory_state.cpp", "src/appmgr/profile.cpp", "src/appmgr/quick_fix_callback_proxy.cpp", "src/appmgr/quick_fix_callback_stub.cpp", 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 3c06a1b4e0..4a96ae0b6a 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 @@ -200,6 +200,14 @@ public: virtual AppMgrResultCode KillApplicationSelf(const bool clearPageStack = false, const std::string& reason = "KillApplicationSelf"); + /** + * update process rss and pss value. + * + * @param procMemStates, the memory states of all apps. + * @return ERR_OK, return back success, others fail. + */ + virtual int32_t UpdateProcessMemoryState(const std::vector &procMemState); + /** * ClearUpApplicationData, call ClearUpApplicationData() through proxy project, * clear the application data. diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h index ab37f58c4f..f7a591b143 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h @@ -40,6 +40,7 @@ #include "irender_state_observer.h" #include "memory_level_info.h" #include "page_state_data.h" +#include "process_memory_state.h" #include "render_process_info.h" #include "running_process_info.h" #include "system_memory_attr.h" @@ -912,6 +913,18 @@ public: { return 0; } + + /** + * UpdateProcessMemoryState, call UpdateProcessMemoryState() through proxy object, + * update process rss and pss value. + * + * @param procMemStates, the memory states of all apps. + * @return ERR_OK, return back success, others fail. + */ + virtual int32_t UpdateProcessMemoryState(const std::vector &procMemState) + { + return 0; + } }; } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h index d9db7c82a6..6d1e93be84 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h @@ -123,6 +123,7 @@ enum class AppMgrInterfaceCode { IS_APP_RUNNING_BY_BUNDLE_NAME_AND_USER_ID = 97, HAS_APP_RECORD = 98, GET_RUNNING_PROCESS_INFO_BY_CHILD_PROCESS_PID = 99, + UPDATE_PROCESS_MEMORY_STATE = 100, }; } // AppExecFwk } // OHOS diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h index 855d320e11..5dcf7d4e42 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h @@ -782,6 +782,15 @@ public: virtual void UpdateInstanceKeyBySpecifiedId(int32_t specifiedId, std::string &instanceKey) override; int32_t HasAppRecord(const AAFwk::Want &want, const AbilityInfo &abilityInfo, bool &result) override; + + /** + * UpdateProcessMemoryState, call UpdateProcessMemoryState() through proxy object, + * update process rss and pss value. + * + * @param procMemStates, the memory states of all apps. + * @return ERR_OK, return back success, others fail. + */ + virtual int32_t UpdateProcessMemoryState(const std::vector &procMemState) override; private: bool SendTransactCmd(AppMgrInterfaceCode code, MessageParcel &data, MessageParcel &reply); bool WriteInterfaceToken(MessageParcel &data); diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h index 16a35d7a82..6d2249ab6b 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h @@ -186,6 +186,7 @@ private: int32_t OnRemoteRequestInnerSeventh(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); int32_t HandleGetSupportedProcessCachePids(MessageParcel &data, MessageParcel &reply); + int32_t HandleUpdateProcessMemoryState(MessageParcel &data, MessageParcel &reply); DISALLOW_COPY_AND_MOVE(AppMgrStub); }; } // namespace AppExecFwk diff --git a/interfaces/inner_api/app_manager/include/appmgr/process_memory_state.h b/interfaces/inner_api/app_manager/include/appmgr/process_memory_state.h new file mode 100644 index 0000000000..f33d2ff4bd --- /dev/null +++ b/interfaces/inner_api/app_manager/include/appmgr/process_memory_state.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 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_PROCESS_MEMORY_STATE_H +#define OHOS_ABILITY_RUNTIME_PROCESS_MEMORY_STATE_H + +#include + +#include "parcel.h" + +namespace OHOS { +namespace AppExecFwk { +struct ProcessMemoryState : public Parcelable { + int32_t pid = 0; + int32_t rssValue = 0; + int32_t pssValue = 0; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static ProcessMemoryState *Unmarshalling(Parcel &parcel); +}; +} // namespace AppExecFwk +} // namespace OHOS + +#endif // OHOS_ABILITY_RUNTIME_PROCESS_MEMORY_STATE_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/running_process_info.h b/interfaces/inner_api/app_manager/include/appmgr/running_process_info.h index 6491c385ab..c42fbf719f 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/running_process_info.h +++ b/interfaces/inner_api/app_manager/include/appmgr/running_process_info.h @@ -67,7 +67,8 @@ struct RunningProcessInfo : public Parcelable { std::int32_t appCloneIndex = -1; std::string instanceKey = ""; AppExecFwk::MultiAppModeType appMode = AppExecFwk::MultiAppModeType::UNSPECIFIED; - + std::int32_t rssValue = 0; + std::int32_t pssValue = 0; bool ReadFromParcel(Parcel &parcel); virtual bool Marshalling(Parcel &parcel) const override; static RunningProcessInfo *Unmarshalling(Parcel &parcel); 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 ca9dbb3b3d..74af4b63be 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 @@ -356,6 +356,16 @@ AppMgrResultCode AppMgrClient::KillApplicationSelf(const bool clearPageStack, co return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED; } +int32_t AppMgrClient::UpdateProcessMemoryState(const std::vector &procMemState) +{ + sptr service = iface_cast(mgrHolder_->GetRemoteObject()); + if (service == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr."); + return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED; + } + return service->UpdateProcessMemoryState(procMemState); +} + AppMgrResultCode AppMgrClient::ClearUpApplicationData(const std::string &bundleName, int32_t appCloneIndex, int32_t userId) { diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp index a3be9e2da2..235bd033c3 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp @@ -26,6 +26,7 @@ namespace OHOS { namespace AppExecFwk { constexpr int32_t CYCLE_LIMIT = 1000; +constexpr int32_t MAX_PROCESS_STATE_COUNT = 1000; AppMgrProxy::AppMgrProxy(const sptr &impl) : IRemoteProxy(impl) {} @@ -2201,5 +2202,37 @@ int32_t AppMgrProxy::HasAppRecord(const AAFwk::Want &want, const AbilityInfo &ab result = reply.ReadBool(); return ERR_OK; } + +int32_t AppMgrProxy::UpdateProcessMemoryState(const std::vector &procMemState) +{ + MessageParcel data; + MessageParcel reply; + + auto size = procMemState.size(); + if (size == 0 || size > MAX_PROCESS_STATE_COUNT) { + TAG_LOGE(AAFwkTag::APPMGR, "Invalid size"); + return ERR_FLATTEN_OBJECT; + } + if (!WriteInterfaceToken(data)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); + return IPC_PROXY_ERR; + } + if (!data.WriteUint32(size)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write size failed"); + return ERR_FLATTEN_OBJECT; + } + for (const auto &perState: procMemState) { + if (!data.WriteParcelable(&perState)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write perState failed"); + return ERR_FLATTEN_OBJECT; + } + } + int32_t ret = SendTransactCmd(AppMgrInterfaceCode::UPDATE_PROCESS_MEMORY_STATE, data, reply); + if (ret != NO_ERROR) { + TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); + return ret; + } + return reply.ReadInt32(); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp index ee7f2fccff..caa4bc93d8 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp @@ -39,6 +39,7 @@ namespace OHOS { namespace AppExecFwk { constexpr int32_t CYCLE_LIMIT = 1000; +constexpr int32_t MAX_PROCESS_STATE_COUNT = 1000; AppMgrStub::AppMgrStub() {} @@ -367,6 +368,8 @@ int32_t AppMgrStub::OnRemoteRequestInnerSeventh(uint32_t code, MessageParcel &da return HandleKillAppSelfWithInstanceKey(data, reply); case static_cast(AppMgrInterfaceCode::UPDATE_INSTANCE_KEY_BY_SPECIFIED_ID): return HandleUpdateInstanceKeyBySpecifiedId(data, reply); + case static_cast(AppMgrInterfaceCode::UPDATE_PROCESS_MEMORY_STATE): + return HandleUpdateProcessMemoryState(data, reply); } return INVALID_FD; } @@ -1810,5 +1813,28 @@ int32_t AppMgrStub::HandleHasAppRecord(MessageParcel &data, MessageParcel &reply } return ret; } + +ErrCode AppMgrStub::HandleUpdateProcessMemoryState(MessageParcel &data, MessageParcel &reply) +{ + HITRACE_METER(HITRACE_TAG_APP); + TAG_LOGD(AAFwkTag::APPMGR, "HandleUpdateProcessMemoryState,callingPid=%{public}d", IPCSkeleton::GetCallingPid()); + std::vector states; + auto size = data.ReadUint32(); + if (size <= 0 || size > MAX_PROCESS_STATE_COUNT) { + TAG_LOGE(AAFwkTag::APPMGR, "Invalid size"); + return ERR_INVALID_VALUE; + } + for (uint32_t i = 0; i < size; i++) { + std::unique_ptr tmpState(data.ReadParcelable()); + if (tmpState == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "tmpState is nullptr."); + return ERR_INVALID_VALUE; + } + states.emplace_back(*tmpState); + } + auto ret = UpdateProcessMemoryState(states); + reply.WriteInt32(ret); + return NO_ERROR; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/process_memory_state.cpp b/interfaces/inner_api/app_manager/src/appmgr/process_memory_state.cpp new file mode 100644 index 0000000000..f0a79075e4 --- /dev/null +++ b/interfaces/inner_api/app_manager/src/appmgr/process_memory_state.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 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 "process_memory_state.h" + +#include "hilog_tag_wrapper.h" +#include "parcel_macro_base.h" + +namespace OHOS { +namespace AppExecFwk { + +bool ProcessMemoryState::ReadFromParcel(Parcel &parcel) +{ + int32_t pidData; + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, pidData); + pid = static_cast(pidData); + int32_t rssValueData; + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rssValueData); + rssValue = static_cast(rssValueData); + int32_t pssValueData; + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, pssValueData); + pssValue = static_cast(pssValueData); + return true; +} + +ProcessMemoryState *ProcessMemoryState::Unmarshalling(Parcel &parcel) +{ + ProcessMemoryState *state = new (std::nothrow) ProcessMemoryState(); + if (state && !state->ReadFromParcel(parcel)) { + TAG_LOGW(AAFwkTag::APPMGR, "read from parcel failed"); + delete state; + state = nullptr; + } + return state; +} + +bool ProcessMemoryState::Marshalling(Parcel &parcel) const +{ + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(pid)); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(rssValue)); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(pssValue)); + return true; +} +} // namespace AppExecFwk +} // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/running_process_info.cpp b/interfaces/inner_api/app_manager/src/appmgr/running_process_info.cpp index 83bd203b2b..ea2f3ab844 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/running_process_info.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/running_process_info.cpp @@ -65,6 +65,12 @@ bool RunningProcessInfo::ReadFromParcel(Parcel &parcel) int32_t appModeType; READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, appModeType); appMode = static_cast(appModeType); + int32_t rssData; + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, rssData); + rssValue = static_cast(rssData); + int32_t pssData; + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, pssData); + pssValue = static_cast(pssData); return true; } @@ -101,6 +107,8 @@ bool RunningProcessInfo::Marshalling(Parcel &parcel) const WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, appCloneIndex); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(instanceKey)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(appMode)); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(rssValue)); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(pssValue)); return true; } } // namespace AppExecFwk diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index 7c7f572bcc..e5b8707abf 100644 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -1199,6 +1199,14 @@ public: virtual int32_t KillProcessWithPrepareTerminate(const std::vector& pids) override; + /** + * @brief the process with reason + * @param pid id of process. + * @param reason, kill process reason. + * @return Returns ERR_OK on success, others on failure. + */ + virtual int32_t KillProcessWithReason(int32_t pid, const ExitReason &reason) override; + /** * @brief Register auto start up callback for system api. * @param callback The point of JsAbilityAutoStartupCallBack. diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index 90493360a9..39a9551060 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -1546,6 +1546,8 @@ public: virtual int32_t KillProcessWithPrepareTerminate(const std::vector& pids) override; + virtual int32_t KillProcessWithReason(int32_t pid, const ExitReason &reason) override; + /** * @brief Register auto start up callback for system api. * @param callback The point of JsAbilityAutoStartupCallBack. diff --git a/services/abilitymgr/include/ability_manager_stub.h b/services/abilitymgr/include/ability_manager_stub.h index 6cbd065c7e..436a451ea5 100644 --- a/services/abilitymgr/include/ability_manager_stub.h +++ b/services/abilitymgr/include/ability_manager_stub.h @@ -262,6 +262,8 @@ private: int32_t RegisterStatusBarDelegateInner(MessageParcel &data, MessageParcel &reply); int32_t KillProcessWithPrepareTerminateInner(MessageParcel &data, MessageParcel &reply); + int32_t KillProcessWithReasonInner(MessageParcel &data, MessageParcel &reply); + int32_t RegisterAutoStartupSystemCallbackInner(MessageParcel &data, MessageParcel &reply); int32_t UnregisterAutoStartupSystemCallbackInner(MessageParcel &data, MessageParcel &reply); int32_t SetApplicationAutoStartupInner(MessageParcel &data, MessageParcel &reply); diff --git a/services/abilitymgr/include/app_exit_reason_data_manager.h b/services/abilitymgr/include/app_exit_reason_data_manager.h index dfcf53414c..1ea45f7aa5 100644 --- a/services/abilitymgr/include/app_exit_reason_data_manager.h +++ b/services/abilitymgr/include/app_exit_reason_data_manager.h @@ -63,6 +63,9 @@ public: bool GetUIExtensionAbilityExitReason(const std::string &keyEx, AAFwk::ExitReason &exitReason); + int32_t SetProcessExitDetailInfo(const AAFwk::ExitReason &exitReason, + const AppExecFwk::RunningProcessInfo &processInfo); + private: DistributedKv::Status GetKvStore(); bool CheckKvStore(); @@ -71,6 +74,8 @@ private: void ConvertAppExitReasonInfoFromValue(const DistributedKv::Value &value, AAFwk::ExitReason &exitReason, int64_t &time_stamp, std::vector &abilityList); void ConvertAccessTokenIdFromValue(const DistributedKv::Value &value, uint32_t &accessTokenId); + DistributedKv::Value ConvertProcessExitDetailInfoToValue(const AAFwk::ExitReason &exitReason, + const AppExecFwk::RunningProcessInfo &processInfo); void UpdateAppExitReason(uint32_t accessTokenId, const std::vector &abilityList, const AAFwk::ExitReason &exitReason); void InnerDeleteAppExitReason(const std::string &keyName); @@ -90,6 +95,7 @@ private: DistributedKv::Key GetSessionIdKey(const int32_t sessionId); DistributedKv::Value ConvertAccessTokenIdToValue(uint32_t accessTokenId); + DistributedKv::Status RestoreKvStore(DistributedKv::Status status); const DistributedKv::AppId appId_ { "app_exit_reason_storage" }; const DistributedKv::StoreId storeId_ { "app_exit_reason_infos" }; diff --git a/services/abilitymgr/include/app_exit_reason_helper.h b/services/abilitymgr/include/app_exit_reason_helper.h index 4d12c4c091..77cec23487 100644 --- a/services/abilitymgr/include/app_exit_reason_helper.h +++ b/services/abilitymgr/include/app_exit_reason_helper.h @@ -31,6 +31,7 @@ public: ~AppExitReasonHelper() = default; int32_t RecordAppExitReason(const ExitReason &exitReason); + int32_t RecordAppExitReason(const ExitReason &exitReason, int32_t pid); int32_t RecordAppExitReason(const std::string &bundleName, int32_t uid, int32_t appIndex, const ExitReason &exitReason); int32_t RecordProcessExtensionExitReason( diff --git a/services/abilitymgr/src/ability_manager_client.cpp b/services/abilitymgr/src/ability_manager_client.cpp index bf0db947e0..ac974ff807 100644 --- a/services/abilitymgr/src/ability_manager_client.cpp +++ b/services/abilitymgr/src/ability_manager_client.cpp @@ -1748,6 +1748,14 @@ ErrCode AbilityManagerClient::KillProcessWithPrepareTerminate(const std::vector< return abms->KillProcessWithPrepareTerminate(pids); } +ErrCode AbilityManagerClient::KillProcessWithReason(int32_t pid, const ExitReason &reason) +{ + TAG_LOGI(AAFwkTag::ABILITYMGR, "call, pid:%{public}d", pid); + auto abms = GetAbilityManager(); + CHECK_POINTER_RETURN_NOT_CONNECTED(abms); + return abms->KillProcessWithReason(pid, reason); +} + ErrCode AbilityManagerClient::RegisterAutoStartupSystemCallback(sptr callback) { TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index 4a59708e65..70acabfa1f 100644 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -4669,6 +4669,32 @@ int32_t AbilityManagerProxy::KillProcessWithPrepareTerminate(const std::vector &callback) { MessageParcel data; diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index d255edb0e3..415055ca7a 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -10742,6 +10742,29 @@ int32_t AbilityManagerService::KillProcessWithPrepareTerminate(const std::vector return uiAbilityManager->TryPrepareTerminateByPids(pids); } +int32_t AbilityManagerService::KillProcessWithReason(int32_t pid, const ExitReason &reason) +{ + auto isShellCall = PermissionVerification::GetInstance()->IsShellCall(); + auto isCallingPerm = PermissionVerification::GetInstance()->VerifyCallingPermission( + AAFwk::PermissionConstants::PERMISSION_KILL_APP_PROCESSES); + if (!isCallingPerm && !isShellCall) { + TAG_LOGE(AAFwkTag::APPMGR, "permission verification fail"); + return ERR_PERMISSION_DENIED; + } + + TAG_LOGI(AAFwkTag::ABILITYMGR, "pid:%{public}d, reason:%{public}d, subReason:%{public}d, killMsg:%{public}s", + pid, reason.reason, reason.subReason, reason.exitMsg.c_str()); + CHECK_POINTER_AND_RETURN(appExitReasonHelper_, ERR_NULL_OBJECT); + auto ret = appExitReasonHelper_->RecordAppExitReason(reason, pid); + if (ret != ERR_OK) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "RecordAppExitReason failed, ret:%{public}d", ret); + return ret; + } + std::vector pidToBeKilled = { pid }; + IN_PROCESS_CALL_WITHOUT_RET(DelayedSingleton::GetInstance()->KillProcessesByPids(pidToBeKilled)); + return ERR_OK; +} + int32_t AbilityManagerService::RegisterAutoStartupSystemCallback(const sptr &callback) { if (abilityAutoStartupService_ == nullptr) { diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index b5a7a57e93..b146dc7042 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -666,6 +666,9 @@ int AbilityManagerStub::OnRemoteRequestInnerSeventeenth(uint32_t code, MessagePa if (interfaceCode == AbilityManagerInterfaceCode::KILL_PROCESS_WITH_PREPARE_TERMINATE) { return KillProcessWithPrepareTerminateInner(data, reply); } + if (interfaceCode == AbilityManagerInterfaceCode::KILL_PROCESS_WITH_REASON) { + return KillProcessWithReasonInner(data, reply); + } if (interfaceCode == AbilityManagerInterfaceCode::REGISTER_AUTO_STARTUP_SYSTEM_CALLBACK) { return RegisterAutoStartupSystemCallbackInner(data, reply); } @@ -3462,6 +3465,22 @@ int32_t AbilityManagerStub::KillProcessWithPrepareTerminateInner(MessageParcel & return NO_ERROR; } +int32_t AbilityManagerStub::KillProcessWithReasonInner(MessageParcel &data, MessageParcel &reply) +{ + int32_t pid = data.ReadInt32(); + std::unique_ptr reason(data.ReadParcelable()); + if (reason == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "reason null"); + return ERR_INVALID_VALUE; + } + int32_t result = KillProcessWithReason(pid, *reason); + if (!reply.WriteInt32(result)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail"); + return ERR_INVALID_VALUE; + } + return NO_ERROR; +} + int32_t AbilityManagerStub::RegisterAutoStartupSystemCallbackInner(MessageParcel &data, MessageParcel &reply) { sptr callback = data.ReadRemoteObject(); diff --git a/services/abilitymgr/src/app_exit_reason_data_manager.cpp b/services/abilitymgr/src/app_exit_reason_data_manager.cpp index c0831d2ad7..513d0cf438 100644 --- a/services/abilitymgr/src/app_exit_reason_data_manager.cpp +++ b/services/abilitymgr/src/app_exit_reason_data_manager.cpp @@ -36,6 +36,16 @@ const std::string JSON_KEY_SESSION_ID_LIST = "session_id_list"; const std::string JSON_KEY_EXTENSION_NAME = "extension_name"; const std::string JSON_KEY_ACCESSTOKENId = "access_token_id"; const std::string SEPARATOR = ":"; +const std::string JSON_KEY_PROCESS_EXIT_DETAIL_INFO_LIST = "process_exit_detail_info_list"; +const std::string KEY_KILL_PROCESS_REASON_PREFIX = "process_exit_detail_info"; +const std::string JSON_KEY_KILL_REASON = "kill_reason"; +const std::string JSON_KEY_SUB_KILL_REASON = "sub_kill_reason"; +const std::string JSON_KEY_KILL_MSG = "kill_msg"; +const std::string JSON_KEY_PID = "pid"; +const std::string JSON_KEY_UID = "uid"; +const std::string JSON_KEY_PROCESS_NAME = "process_name"; +const std::string JSON_KEY_PSS_VALUE = "pss_value"; +const std::string JSON_KEY_RSS_VALUE = "rss_value"; } // namespace AppExitReasonDataManager::AppExitReasonDataManager() {} @@ -816,5 +826,82 @@ DistributedKv::Value AppExitReasonDataManager::ConvertAppExitReasonInfoToValueOf DistributedKv::Value value(jsonObject.dump()); return value; } + +DistributedKv::Value AppExitReasonDataManager::ConvertProcessExitDetailInfoToValue( + const AAFwk::ExitReason &exitReason, const AppExecFwk::RunningProcessInfo &processInfo) +{ + std::chrono::milliseconds nowMs = + std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()); + nlohmann::json jsonObject = nlohmann::json { + { JSON_KEY_PID, processInfo.pid_ }, + { JSON_KEY_UID, processInfo.uid_ }, + { JSON_KEY_KILL_REASON, exitReason.reason }, + { JSON_KEY_SUB_KILL_REASON, exitReason.subReason }, + { JSON_KEY_KILL_MSG, exitReason.exitMsg }, + { JSON_KEY_RSS_VALUE, processInfo.rssValue }, + { JSON_KEY_PSS_VALUE, processInfo.pssValue }, + { JSON_KEY_PROCESS_NAME, processInfo.processName_ }, + { JSON_KEY_TIME_STAMP, nowMs.count() }, + }; + + DistributedKv::Value value(jsonObject.dump()); + TAG_LOGI(AAFwkTag::ABILITYMGR, "value: %{public}s", value.ToString().c_str()); + return value; +} + +DistributedKv::Status AppExitReasonDataManager::RestoreKvStore(DistributedKv::Status status) +{ + if (status != DistributedKv::Status::DATA_CORRUPTED) { + return status; + } + DistributedKv::Options options = { + .createIfMissing = true, + .encrypt = false, + .autoSync = true, + .syncable = false, + .securityLevel = DistributedKv::SecurityLevel::S2, + .area = DistributedKv::EL1, + .kvStoreType = DistributedKv::KvStoreType::SINGLE_VERSION, + .baseDir = APP_EXIT_REASON_STORAGE_DIR, + }; + TAG_LOGI(AAFwkTag::ABILITYMGR, "corrupted, deleting db"); + dataManager_.DeleteKvStore(appId_, storeId_, options.baseDir); + TAG_LOGI(AAFwkTag::ABILITYMGR, "deleted corrupted db, recreating db"); + status = dataManager_.GetSingleKvStore(options, appId_, storeId_, kvStorePtr_); + TAG_LOGI(AAFwkTag::ABILITYMGR, "recreate db result:%{public}d", status); + + return status; +} + +int32_t AppExitReasonDataManager::SetProcessExitDetailInfo(const AAFwk::ExitReason &exitReason, + const AppExecFwk::RunningProcessInfo &processInfo) +{ + TAG_LOGI(AAFwkTag::ABILITYMGR, + "SetProcessExitDetailInfo processName %{public}s pid %{public}d reason %{public}d", + processInfo.processName_.c_str(), processInfo.pid_, exitReason.reason); + std::string keyStr = KEY_KILL_PROCESS_REASON_PREFIX + SEPARATOR + processInfo.processName_ + + SEPARATOR + std::to_string(processInfo.pid_); + DistributedKv::Key key(keyStr); + DistributedKv::Value value = ConvertProcessExitDetailInfoToValue(exitReason, processInfo); + DistributedKv::Status status = DistributedKv::SUCCESS; + { + std::lock_guard lock(kvStorePtrMutex_); + if (!CheckKvStore()) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "null kvStore"); + return ERR_NO_INIT; + } + status = kvStorePtr_->Put(key, value); + } + if (status != DistributedKv::Status::SUCCESS) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "error : %{public}d", status); + { + std::lock_guard lock(kvStorePtrMutex_); + status = RestoreKvStore(status); + } + return ERR_INVALID_OPERATION; + } + + return ERR_OK; +} } // namespace AbilityRuntime } // namespace OHOS diff --git a/services/abilitymgr/src/app_exit_reason_helper.cpp b/services/abilitymgr/src/app_exit_reason_helper.cpp index c73a3fcb9b..3d793c29f8 100644 --- a/services/abilitymgr/src/app_exit_reason_helper.cpp +++ b/services/abilitymgr/src/app_exit_reason_helper.cpp @@ -80,6 +80,14 @@ int32_t AppExitReasonHelper::RecordAppExitReason(const ExitReason &exitReason) accessTokenId, abilityList, exitReason); } +int32_t AppExitReasonHelper::RecordAppExitReason(const ExitReason &exitReason, int32_t pid) +{ + AppExecFwk::RunningProcessInfo processInfo; + DelayedSingleton::GetInstance()->GetRunningProcessInfoByPid(static_cast(pid), processInfo); + return DelayedSingleton::GetInstance()-> + SetProcessExitDetailInfo(exitReason, processInfo); +} + int32_t AppExitReasonHelper::RecordProcessExitReason(const int32_t pid, const ExitReason &exitReason) { AppExecFwk::ApplicationInfo application; diff --git a/services/abilitymgr/src/exit_reason.cpp b/services/abilitymgr/src/exit_reason.cpp index 565b438302..4efad91b4e 100644 --- a/services/abilitymgr/src/exit_reason.cpp +++ b/services/abilitymgr/src/exit_reason.cpp @@ -27,12 +27,20 @@ ExitReason::ExitReason(const Reason reason, const std::string &exitMsg) this->exitMsg = exitMsg; } +ExitReason::ExitReason(const Reason &reason, int32_t subReason, const std::string &exitMsg) +{ + this->reason = reason; + this->subReason = subReason; + this->exitMsg = exitMsg; +} + bool ExitReason::ReadFromParcel(Parcel &parcel) { int32_t reasonData; READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reasonData); reason = static_cast(reasonData); - + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, reasonData); + subReason = reasonData; exitMsg = Str16ToStr8(parcel.ReadString16()); return true; } @@ -55,6 +63,7 @@ ExitReason *ExitReason::Unmarshalling(Parcel &parcel) bool ExitReason::Marshalling(Parcel &parcel) const { WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(reason)); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, subReason); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(exitMsg)); return true; } diff --git a/services/appmgr/include/app_mgr_service.h b/services/appmgr/include/app_mgr_service.h index b020cdd5e9..03dc7715ce 100644 --- a/services/appmgr/include/app_mgr_service.h +++ b/services/appmgr/include/app_mgr_service.h @@ -805,6 +805,14 @@ public: virtual void UpdateInstanceKeyBySpecifiedId(int32_t specifiedId, std::string &instanceKey) override; int32_t HasAppRecord(const AAFwk::Want &want, const AbilityInfo &abilityInfo, bool &result) override; + + /** + * update process rss and pss value. + * + * @param procMemStates, the memory states of all apps. + * @return ERR_OK, return back success, others fail. + */ + virtual int32_t UpdateProcessMemoryState(const std::vector &procMemState) override; private: /** * Init, Initialize application services. diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 7b792a56f1..cbb752a31f 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -63,6 +63,7 @@ #include "istart_specified_ability_response.h" #include "kia_interceptor_interface.h" #include "kill_process_config.h" +#include "process_memory_state.h" #include "record_query_result.h" #include "refbase.h" #include "remote_client_manager.h" @@ -344,6 +345,14 @@ public: virtual int32_t KillApplicationByUserId(const std::string &bundleName, int32_t appCloneIndex, int userId, const bool clearPageStack = false, const std::string& reason = "KillApplicationByUserId"); + /** + * update process rss and pss value. + * + * @param procMemStates, the memory states of all apps. + * @return ERR_OK, return back success, others fail. + */ + virtual int32_t UpdateProcessMemoryState(const std::vector &procMemState); + /** * ClearUpApplicationData, clear the application data. * diff --git a/services/appmgr/include/app_running_record.h b/services/appmgr/include/app_running_record.h index 5b6a0ecdff..42a7845a7a 100644 --- a/services/appmgr/include/app_running_record.h +++ b/services/appmgr/include/app_running_record.h @@ -1016,6 +1016,27 @@ public: bool IsUnSetPermission(); void UnSetPolicy(); + + inline void SetRssValue(int32_t rssValue) + { + rssValue_ = rssValue; + } + + inline int32_t GetRssValue() const + { + return rssValue_; + } + + inline void SetPssValue(int32_t pssValue) + { + pssValue_ = pssValue; + } + + inline int32_t GetPssValue() const + { + return pssValue_; + } + private: /** * SearchTheModuleInfoNeedToUpdated, Get an uninitialized abilityStage data. @@ -1188,6 +1209,8 @@ private: bool isAllowedNWebPreload_ = false; bool isUnSetPermission_ = false; std::string killReason_ = ""; + int32_t rssValue_ = 0; + int32_t pssValue_ = 0; }; } // namespace AppExecFwk diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 06e9685401..945c5ab8e4 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -75,6 +75,7 @@ constexpr const char* TASK_EXIT_CHILD_PROCESS_SAFELY = "ExitChildProcessSafelyTa #endif // SUPPORT_CHILD_PROCESS constexpr const char* FOUNDATION_PROCESS = "foundation"; constexpr int32_t USER_UID = 2000; +constexpr const char* HIVIEW_PROCESS_NAME = "hiview"; } // namespace REGISTER_SYSTEM_ABILITY_BY_ID(AppMgrService, APP_MGR_SERVICE_ID, true); @@ -1776,5 +1777,27 @@ int32_t AppMgrService::HasAppRecord(const AAFwk::Want &want, const AbilityInfo & result = appMgrServiceInner_->HasAppRecord(want, abilityInfo); return ERR_OK; } + +int32_t AppMgrService::UpdateProcessMemoryState(const std::vector &procMemState) +{ + TAG_LOGI(AAFwkTag::APPMGR, "procMemState.size = %{public}zu", procMemState.size()); + if (!IsReady()) { + return ERR_INVALID_OPERATION; + } + if (!AAFwk::PermissionVerification::GetInstance()->IsSACall() && + !AAFwk::PermissionVerification::GetInstance()->IsShellCall()) { + TAG_LOGE(AAFwkTag::APPMGR, "caller is not sa or shell"); + return ERR_PERMISSION_DENIED; + } + if (!AAFwk::PermissionVerification::GetInstance()->CheckSpecificSystemAbilityAccessPermission( + HIVIEW_PROCESS_NAME)) { + TAG_LOGW(AAFwkTag::APPMGR, "caller not sa dfx"); + } + if (!appMgrServiceInner_) { + TAG_LOGE(AAFwkTag::APPMGR, "appMgrServiceInner_ is nullptr"); + return ERR_INVALID_VALUE; + } + return appMgrServiceInner_->UpdateProcessMemoryState(procMemState); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index b79fac9e82..4d144a2c76 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1668,6 +1668,20 @@ int32_t AppMgrServiceInner::KillApplicationByUid(const std::string &bundleName, return result; } +int32_t AppMgrServiceInner::UpdateProcessMemoryState(const std::vector &procMemState) +{ + for (const auto &state : procMemState) { + auto appRecord = GetAppRunningRecordByPid(state.pid); + if (!appRecord) { + TAG_LOGW(AAFwkTag::APPMGR, "no appRecord, pid:%{public}d", state.pid); + continue; + } + appRecord->SetRssValue(state.rssValue); + appRecord->SetPssValue(state.pssValue); + } + return ERR_OK; +} + void AppMgrServiceInner::SendProcessExitEventTask( const std::shared_ptr &appRecord, time_t exitTime, int32_t count) { diff --git a/services/appmgr/src/app_running_manager.cpp b/services/appmgr/src/app_running_manager.cpp index f6d41b53eb..4fcc8ee96b 100644 --- a/services/appmgr/src/app_running_manager.cpp +++ b/services/appmgr/src/app_running_manager.cpp @@ -878,6 +878,8 @@ int32_t AppRunningManager::AssignRunningProcessInfoByAppRecord( } info.appCloneIndex = appRecord->GetAppIndex(); info.instanceKey = appRecord->GetInstanceKey(); + info.rssValue = appRecord->GetRssValue(); + info.pssValue = appRecord->GetPssValue(); return ERR_OK; }