From 478ba8a080b613db604f82c60368a4e2f4f7a7c7 Mon Sep 17 00:00:00 2001 From: savior-xzh Date: Mon, 15 Jul 2024 21:07:58 +0800 Subject: [PATCH] web Signed-off-by: savior-xzh Change-Id: I82d8d7d5abef2324f342024ac5012af031cfd4e8 --- .../include/appmgr/ams_mgr_interface.h | 12 ++++++++ .../include/appmgr/ams_mgr_proxy.h | 8 ++++++ .../app_manager/include/appmgr/ams_mgr_stub.h | 1 + .../include/appmgr/app_mgr_client.h | 9 ++++++ .../app_manager/src/appmgr/ams_mgr_proxy.cpp | 22 +++++++++++++++ .../app_manager/src/appmgr/ams_mgr_stub.cpp | 19 +++++++++++++ .../app_manager/src/appmgr/app_mgr_client.cpp | 16 +++++++++++ services/abilitymgr/include/app_scheduler.h | 2 ++ .../src/ability_bundle_event_callback.cpp | 9 +++++- .../src/ability_connect_manager.cpp | 4 +++ .../src/ability_manager_service.cpp | 1 + services/abilitymgr/src/app_scheduler.cpp | 9 ++++++ services/appmgr/include/ams_mgr_scheduler.h | 8 ++++++ .../appmgr/include/app_mgr_service_inner.h | 3 ++ .../include/exit_resident_process_manager.h | 3 +- services/appmgr/src/ams_mgr_scheduler.cpp | 9 ++++++ services/appmgr/src/app_mgr_service.cpp | 4 +-- services/appmgr/src/app_mgr_service_inner.cpp | 28 ++++++++++++++----- .../src/exit_resident_process_manager.cpp | 21 ++++++++++++-- .../common/include/permission_constants.h | 1 + .../common/include/permission_verification.h | 2 ++ .../common/src/permission_verification.cpp | 10 +++++++ 22 files changed, 188 insertions(+), 13 deletions(-) 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 053f69c1f9..4722f8e2c0 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 @@ -321,6 +321,17 @@ public: */ virtual void BlockProcessCacheByPids(const std::vector &pids) {} + /** + * whether killed for upgrade web. + * + * @param bundleName the bundle name is killed for upgrade web. + * @return Returns true is killed for upgrade web, others return false. + */ + virtual bool IsKilledForUpgradeWeb(const std::string &bundleName) + { + return true; + } + enum class Message { LOAD_ABILITY = 0, TERMINATE_ABILITY, @@ -367,6 +378,7 @@ public: NOTIFY_APP_MGR_RECORD_EXIT_REASON, ATTACHED_TO_STATUS_BAR, BLOCK_PROCESS_CACHE_BY_PIDS, + IS_KILLED_FOR_UPGRADE_WEB, }; }; } // namespace AppExecFwk 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 bf355d8f86..c8fa0f935d 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 @@ -290,6 +290,14 @@ public: */ virtual void BlockProcessCacheByPids(const std::vector &pids) override; + /** + * whether killed for upgrade web. + * + * @param bundleName the bundle name is killed for upgrade web. + * @return Returns true is killed for upgrade web, others return false. + */ + virtual bool IsKilledForUpgradeWeb(const std::string &bundleName) override; + private: bool WriteInterfaceToken(MessageParcel &data); int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 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 0929905745..0029a71a1c 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 @@ -93,6 +93,7 @@ private: int32_t OnRemoteRequestInnerThird(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); int32_t HandleBlockProcessCacheByPids(MessageParcel &data, MessageParcel &reply); + int32_t HandleIsKilledForUpgradeWeb(MessageParcel &data, MessageParcel &reply); DISALLOW_COPY_AND_MOVE(AmsMgrStub); }; } // namespace AppExecFwk 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 31b16178a9..851916c62b 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 @@ -775,6 +775,15 @@ public: * @param pids the pids of the processes that should be blocked. */ virtual AppMgrResultCode BlockProcessCacheByPids(const std::vector &pids); + + /** + * whether killed for upgrade web. + * + * @param bundleName the bundle name is killed for upgrade web. + * @return Returns true is killed for upgrade web, others return false. + */ + bool IsKilledForUpgradeWeb(const std::string &bundleName); + private: void SetServiceManager(std::unique_ptr serviceMgr); /** 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 03abc5d716..29a7922d0e 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 @@ -1170,5 +1170,27 @@ void AmsMgrProxy::BlockProcessCacheByPids(const std::vector &pids) } TAG_LOGD(AAFwkTag::APPMGR, "end"); } + +bool AmsMgrProxy::IsKilledForUpgradeWeb(const std::string &bundleName) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!WriteInterfaceToken(data)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); + return false; + } + if (!data.WriteString(bundleName)) { + TAG_LOGE(AAFwkTag::APPMGR, "parcel WriteString failed"); + return false; + } + + auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::IS_KILLED_FOR_UPGRADE_WEB), 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(); +} } // namespace AppExecFwk } // namespace OHOS 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 55ef69bd31..d4645197ae 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 @@ -188,6 +188,8 @@ int32_t AmsMgrStub::OnRemoteRequestInnerThird(uint32_t code, MessageParcel &data return 0; case static_cast(IAmsMgr::Message::BLOCK_PROCESS_CACHE_BY_PIDS): return HandleBlockProcessCacheByPids(data, reply); + case static_cast(IAmsMgr::Message::IS_KILLED_FOR_UPGRADE_WEB): + return HandleIsKilledForUpgradeWeb(data, reply); } return AAFwk::ERR_CODE_NOT_EXIST; } @@ -747,5 +749,22 @@ ErrCode AmsMgrStub::HandleBlockProcessCacheByPids(MessageParcel &data, MessagePa BlockProcessCacheByPids(pids); return NO_ERROR; } + +int32_t AmsMgrStub::HandleIsKilledForUpgradeWeb(MessageParcel &data, MessageParcel &reply) +{ + TAG_LOGD(AAFwkTag::APPMGR, "Called."); + auto bundleName = data.ReadString(); + if (bundleName.empty()) { + TAG_LOGE(AAFwkTag::APPMGR, "Bundle name is empty."); + return ERR_INVALID_VALUE; + } + + auto result = IsKilledForUpgradeWeb(bundleName); + if (!reply.WriteBool(result)) { + TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); + return ERR_INVALID_VALUE; + } + return NO_ERROR; +} } // namespace AppExecFwk } // namespace OHOS 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 70f9a8ae70..fd8ed65d8a 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 @@ -1250,5 +1250,21 @@ AppMgrResultCode AppMgrClient::BlockProcessCacheByPids(const std::vector service = iface_cast(mgrHolder_->GetRemoteObject()); + if (service == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr."); + return false; + } + sptr amsService = service->GetAmsMgr(); + if (amsService == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "amsService is nullptr."); + return false; + } + TAG_LOGD(AAFwkTag::APPMGR, "call"); + return amsService->IsKilledForUpgradeWeb(bundleName); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/abilitymgr/include/app_scheduler.h b/services/abilitymgr/include/app_scheduler.h index 8d9280c2e9..385c921144 100644 --- a/services/abilitymgr/include/app_scheduler.h +++ b/services/abilitymgr/include/app_scheduler.h @@ -436,6 +436,8 @@ public: void BlockProcessCacheByPids(const std::vector& pids); + bool IsKilledForUpgradeWeb(const std::string &bundleName); + protected: /** * OnAbilityRequestDone, app manager service call this interface after ability request done. diff --git a/services/abilitymgr/src/ability_bundle_event_callback.cpp b/services/abilitymgr/src/ability_bundle_event_callback.cpp index 2f762c19ae..327e4af6ee 100644 --- a/services/abilitymgr/src/ability_bundle_event_callback.cpp +++ b/services/abilitymgr/src/ability_bundle_event_callback.cpp @@ -18,6 +18,7 @@ #include "ability_manager_service.h" #include "ability_util.h" #include "hilog_tag_wrapper.h" +#include "parameters.h" #include "uri_permission_manager_client.h" namespace OHOS { @@ -25,6 +26,9 @@ namespace AAFwk { namespace { constexpr const char* KEY_TOKEN = "accessTokenId"; constexpr const char* KEY_UID = "uid"; +constexpr const char* WEB_BUNDLE_NAME = "com.ohos.nweb"; +constexpr const char* ARKWEB_CORE_PACKAGE_NAME = "persist.arkwebcore.package_name"; + } AbilityBundleEventCallback::AbilityBundleEventCallback( std::shared_ptr taskHandler, std::shared_ptr abilityAutoStartupService) @@ -63,7 +67,10 @@ void AbilityBundleEventCallback::OnReceiveEvent(const EventFwk::CommonEventData // install or uninstall module/bundle HandleUpdatedModuleInfo(bundleName, uid); } else if (action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_CHANGED) { - HandleRestartResidentProcessDependedOnWeb(); + if (bundleName == WEB_BUNDLE_NAME || + bundleName == system::GetParameter(ARKWEB_CORE_PACKAGE_NAME, "false")) { + HandleRestartResidentProcessDependedOnWeb(); + } HandleUpdatedModuleInfo(bundleName, uid); HandleAppUpgradeCompleted(bundleName, uid); if (abilityAutoStartupService_ == nullptr) { diff --git a/services/abilitymgr/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index 299f58a4a4..707149be88 100644 --- a/services/abilitymgr/src/ability_connect_manager.cpp +++ b/services/abilitymgr/src/ability_connect_manager.cpp @@ -2138,6 +2138,10 @@ void AbilityConnectManager::KeepAbilityAlive(const std::shared_ptr::GetInstance()->IsKilledForUpgradeWeb(abilityInfo.bundleName)) { + TAG_LOGI(AAFwkTag::ABILITYMGR, "bundle is killed for upgrade web"); + return; + } if (DelayedSingleton::GetInstance()->IsMemorySizeSufficent() || IsLauncher(abilityRecord) || abilityRecord->IsSceneBoard() || AppUtils::GetInstance().IsAllowResidentInExtremeMemory(abilityInfo.bundleName, abilityInfo.name)) { diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 9c4b53c17f..d5aaf0c852 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -11017,6 +11017,7 @@ void AbilityManagerService::NotifyFrozenProcessByRSS(const std::vector void AbilityManagerService::HandleRestartResidentProcessDependedOnWeb() { + TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); auto appMgr = GetAppMgr(); CHECK_POINTER_LOG(appMgr, "get appMgr fail"); appMgr->RestartResidentProcessDependedOnWeb(); diff --git a/services/abilitymgr/src/app_scheduler.cpp b/services/abilitymgr/src/app_scheduler.cpp index 6cfc49c9ad..a8d8f13c41 100644 --- a/services/abilitymgr/src/app_scheduler.cpp +++ b/services/abilitymgr/src/app_scheduler.cpp @@ -607,5 +607,14 @@ void AppScheduler::BlockProcessCacheByPids(const std::vector &pids) CHECK_POINTER(appMgrClient_); appMgrClient_->BlockProcessCacheByPids(pids); } + +bool AppScheduler::IsKilledForUpgradeWeb(const std::string &bundleName) +{ + if (!appMgrClient_) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "appMgrClient is nullptr"); + return false; + } + return appMgrClient_->IsKilledForUpgradeWeb(bundleName); +} } // namespace AAFwk } // namespace OHOS diff --git a/services/appmgr/include/ams_mgr_scheduler.h b/services/appmgr/include/ams_mgr_scheduler.h index 475386674c..6707af560c 100644 --- a/services/appmgr/include/ams_mgr_scheduler.h +++ b/services/appmgr/include/ams_mgr_scheduler.h @@ -298,6 +298,14 @@ public: virtual void BlockProcessCacheByPids(const std::vector &pids) override; + /** + * whether killed for upgrade web. + * + * @param bundleName the bundle name is killed for upgrade web. + * @return Returns true is killed for upgrade web, others return false. + */ + virtual bool IsKilledForUpgradeWeb(const std::string &bundleName) override; + private: /** * @brief Judge whether the application service is ready. diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index dd6e432f3c..05b1f7a0f4 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -1137,6 +1137,9 @@ public: void RestartResidentProcessDependedOnWeb(); void BlockProcessCacheByPids(const std::vector& pids); + + bool IsKilledForUpgradeWeb(const std::string &bundleName) const; + private: std::string FaultTypeToString(FaultDataType type); diff --git a/services/appmgr/include/exit_resident_process_manager.h b/services/appmgr/include/exit_resident_process_manager.h index cbf62c37c4..557cf28ea3 100644 --- a/services/appmgr/include/exit_resident_process_manager.h +++ b/services/appmgr/include/exit_resident_process_manager.h @@ -38,12 +38,13 @@ public: ~ExitResidentProcessManager(); bool IsMemorySizeSufficent() const; bool RecordExitResidentBundleName(const std::string &bundleName); - bool RecordExitResidentBundleDependedOnWeb(const std::string &bundleName); + void RecordExitResidentBundleDependedOnWeb(const std::string &bundleName); int32_t HandleMemorySizeInSufficent(); int32_t HandleMemorySizeSufficent(std::vector& bundleNames); void HandleExitResidentBundleDependedOnWeb(std::vector& bundleNames); void QueryExitBundleInfos(const std::vector& exitBundleNames, std::vector& exitBundleInfos); + bool IsKilledForUpgradeWeb(const std::string &bundleName) const; private: ExitResidentProcessManager(); diff --git a/services/appmgr/src/ams_mgr_scheduler.cpp b/services/appmgr/src/ams_mgr_scheduler.cpp index 0d487f516e..93cddd92cb 100644 --- a/services/appmgr/src/ams_mgr_scheduler.cpp +++ b/services/appmgr/src/ams_mgr_scheduler.cpp @@ -645,5 +645,14 @@ void AmsMgrScheduler::BlockProcessCacheByPids(const std::vector &pids) }; amsHandler_->SubmitTask(blockProcCacheFunc, TASK_BLOCK_PROCESS_CACHE_BY_PIDS); } + +bool AmsMgrScheduler::IsKilledForUpgradeWeb(const std::string &bundleName) +{ + if (!IsReady()) { + TAG_LOGE(AAFwkTag::APPMGR, "AmsMgrService is not ready."); + return false; + } + return amsMgrServiceInner_->IsKilledForUpgradeWeb(bundleName); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 6238538855..e85a0916ac 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -1569,8 +1569,8 @@ int32_t AppMgrService::NotifyProcessDependedOnWeb() void AppMgrService::KillProcessDependedOnWeb() { TAG_LOGD(AAFwkTag::APPMGR, "called."); - if (!AAFwk::PermissionVerification::GetInstance()->IsSACall()) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "caller is not SA."); + if (!AAFwk::PermissionVerification::GetInstance()->VerifyKillProcessDependedOnWebPermission()) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "caller have not permission."); return; } if (!appMgrServiceInner_) { diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 4d4c4c54c2..aff538018e 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -6051,6 +6051,10 @@ void AppMgrServiceInner::ClearAppRunningDataForKeepAlive(const std::shared_ptrIsKeepAliveApp()) { + if (ExitResidentProcessManager::GetInstance().IsKilledForUpgradeWeb(appRecord->GetBundleName())) { + TAG_LOGI(AAFwkTag::APPMGR, "Is killed for upgrade web"); + return; + } if (!AAFwk::AppUtils::GetInstance().IsAllowResidentInExtremeMemory(appRecord->GetBundleName()) && ExitResidentProcessManager::GetInstance().RecordExitResidentBundleName(appRecord->GetBundleName())) { TAG_LOGI(AAFwkTag::APPMGR, "memory size is insufficent, record exit resident process info"); @@ -7074,17 +7078,17 @@ void AppMgrServiceInner::KillProcessDependedOnWeb() CHECK_POINTER_AND_RETURN_LOG(appRunningManager_, "appRunningManager_ is nullptr"); for (const auto &item : appRunningManager_->GetAppRunningRecordMap()) { const auto &appRecord = item.second; - if (!appRecord || !appRecord->GetSpawned() || !appRecord->GetPriorityObject()) { + if (!appRecord || !appRecord->GetSpawned() || + !appRecord->GetPriorityObject() || !appRecord->IsDependedOnArkWeb()) { continue; } - if (appRecord->IsDependedOnArkWeb()) { - std::string bundleName = appRecord->GetBundleName(); - pid_t pid = appRecord->GetPriorityObject()->GetPid(); - appRecord->IsKeepAliveApp() && - ExitResidentProcessManager::GetInstance().RecordExitResidentBundleDependedOnWeb(bundleName); - KillProcessByPid(pid, "KillProcessDependedOnWeb"); + std::string bundleName = appRecord->GetBundleName(); + pid_t pid = appRecord->GetPriorityObject()->GetPid(); + if (appRecord->IsKeepAliveApp()) { + ExitResidentProcessManager::GetInstance().RecordExitResidentBundleDependedOnWeb(bundleName); } + KillProcessByPid(pid, "KillProcessDependedOnWeb"); } } @@ -7120,5 +7124,15 @@ void AppMgrServiceInner::BlockProcessCacheByPids(const std::vector& pid appRecord->SetProcessCacheBlocked(true); } } + +bool AppMgrServiceInner::IsKilledForUpgradeWeb(const std::string &bundleName) const +{ + auto callerUid = IPCSkeleton::GetCallingUid(); + if (callerUid != FOUNDATION_UID) { + TAG_LOGE(AAFwkTag::APPMGR, "Not foundation call."); + return false; + } + return ExitResidentProcessManager::GetInstance().IsKilledForUpgradeWeb(bundleName); +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/services/appmgr/src/exit_resident_process_manager.cpp b/services/appmgr/src/exit_resident_process_manager.cpp index 62014d42cc..d5f3a5cada 100644 --- a/services/appmgr/src/exit_resident_process_manager.cpp +++ b/services/appmgr/src/exit_resident_process_manager.cpp @@ -52,12 +52,11 @@ bool ExitResidentProcessManager::RecordExitResidentBundleName(const std::string return true; } -bool ExitResidentProcessManager::RecordExitResidentBundleDependedOnWeb(const std::string &bundleName) +void ExitResidentProcessManager::RecordExitResidentBundleDependedOnWeb(const std::string &bundleName) { std::lock_guard lock(webMutexLock_); TAG_LOGE(AAFwkTag::APPMGR, "call"); exitResidentBundlesDependedOnWeb_.emplace_back(bundleName); - return true; } int32_t ExitResidentProcessManager::HandleMemorySizeInSufficent() @@ -119,5 +118,23 @@ void ExitResidentProcessManager::QueryExitBundleInfos(const std::vector bundleNames; + { + std::lock_guard lock(webMutexLock_); + bundleNames = exitResidentBundlesDependedOnWeb_; + } + for (const auto &innerBundleName : bundleNames) { + if (innerBundleName == bundleName) { + TAG_LOGD(AAFwkTag::APPMGR, "Is killed for upgrade web."); + return true; + } + } + TAG_LOGD(AAFwkTag::APPMGR, "Not killed for upgrade web."); + return false; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/common/include/permission_constants.h b/services/common/include/permission_constants.h index 70eb14b60c..f1f6b805d0 100644 --- a/services/common/include/permission_constants.h +++ b/services/common/include/permission_constants.h @@ -58,6 +58,7 @@ constexpr const char* PERMISSION_SET_PROCESS_CACHE_STATE = "ohos.permission.SET_ constexpr const char* PERMISSION_PRELOAD_UI_EXTENSION_ABILITY = "ohos.permission.PRELOAD_UI_EXTENSION_ABILITY"; constexpr const char* PERMISSION_PRE_START_ATOMIC_SERVICE = "ohos.permission.PRE_START_ATOMIC_SERVICE"; constexpr const char* PERMISSION_KILL_APP_PROCESSES = "ohos.permission.KILL_APP_PROCESSES"; +constexpr const char* PERMISSION_KILL_PROCESS_DEPENDED_ON_WEB = "ohos.permission.KILL_PROCESS_DEPENDED_ON_ARKWEB"; } // namespace PermissionConstants } // namespace AAFwk } // namespace OHOS diff --git a/services/common/include/permission_verification.h b/services/common/include/permission_verification.h index ed12d8b189..a6e995af01 100644 --- a/services/common/include/permission_verification.h +++ b/services/common/include/permission_verification.h @@ -101,6 +101,8 @@ struct VerificationInfo { bool VerifyPreStartAtomicServicePermission() const; + bool VerifyKillProcessDependedOnWebPermission() const; + private: DISALLOW_COPY_AND_MOVE(PermissionVerification); diff --git a/services/common/src/permission_verification.cpp b/services/common/src/permission_verification.cpp index 6eb715724f..91ed82b964 100644 --- a/services/common/src/permission_verification.cpp +++ b/services/common/src/permission_verification.cpp @@ -484,5 +484,15 @@ bool PermissionVerification::VerifyPreStartAtomicServicePermission() const PermissionConstants::PERMISSION_PRE_START_ATOMIC_SERVICE); return false; } + +bool PermissionVerification::VerifyKillProcessDependedOnWebPermission() const +{ + if (IsSACall() && VerifyCallingPermission(PermissionConstants::PERMISSION_KILL_PROCESS_DEPENDED_ON_WEB)) { + TAG_LOGD(AAFwkTag::APPMGR, "Permission verification succeeded."); + return true; + } + TAG_LOGW(AAFwkTag::APPMGR, "Permission verification failed"); + return false; +} } // namespace AAFwk } // namespace OHOS