From 3a73e8f1382d2b4dcb459f76f0c5049ccee7bc74 Mon Sep 17 00:00:00 2001 From: lanhaoyu Date: Fri, 20 Jun 2025 10:40:04 +0800 Subject: [PATCH] overlay_manager_idl Signed-off-by: lanhaoyu --- frameworks/src/bundle_command.cpp | 29 +++++++++--------------- frameworks/src/bundle_command_common.cpp | 4 ++++ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/frameworks/src/bundle_command.cpp b/frameworks/src/bundle_command.cpp index 312d624..c4810a7 100644 --- a/frameworks/src/bundle_command.cpp +++ b/frameworks/src/bundle_command.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -26,6 +26,7 @@ #include "bundle_command_common.h" #include "bundle_death_recipient.h" #include "bundle_mgr_client.h" +#include "overlay_manager_client.h" #include "bundle_mgr_proxy.h" #include "clean_cache_callback_host.h" #include "json_serializer.h" @@ -990,6 +991,7 @@ ErrCode BundleManagerShellCommand::RunAsUninstallCommand() InstallParam installParam; installParam.userId = userId; installParam.isKeepData = isKeepData; + installParam.parameters.emplace(Constants::VERIFY_UNINSTALL_RULE_KEY, Constants::VERIFY_UNINSTALL_RULE_VALUE); int32_t uninstallResult = UninstallOperation(bundleName, moduleName, installParam); if (uninstallResult == OHOS::ERR_OK) { resultReceiver_ = STRING_UNINSTALL_BUNDLE_OK + "\n"; @@ -2479,25 +2481,21 @@ std::string BundleManagerShellCommand::DumpOverlayInfo(const std::string &bundle return res; } - auto overlayManagerProxy = bundleMgrProxy_->GetOverlayManagerProxy(); - if (overlayManagerProxy == nullptr) { - APP_LOGE("overlayManagerProxy is null"); - return res; - } std::vector overlayModuleInfos; OverlayModuleInfo overlayModuleInfo; ErrCode ret = ERR_OK; userId = BundleCommandCommon::GetCurrentUserId(userId); if (moduleName.empty() && targetModuleName.empty()) { - ret = overlayManagerProxy->GetAllOverlayModuleInfo(bundleName, overlayModuleInfos, userId); + ret = OverlayManagerClient::GetInstance().GetAllOverlayModuleInfo(bundleName, overlayModuleInfos, userId); if (overlayModuleInfos.empty()) { ret = ERR_BUNDLEMANAGER_OVERLAY_QUERY_FAILED_NO_OVERLAY_MODULE_INFO; } } else if (!moduleName.empty()) { - ret = overlayManagerProxy->GetOverlayModuleInfo(bundleName, moduleName, overlayModuleInfo, userId); + ret = OverlayManagerClient::GetInstance().GetOverlayModuleInfo(bundleName, moduleName, + overlayModuleInfo, userId); } else { - ret = overlayManagerProxy->GetOverlayModuleInfoForTarget(bundleName, targetModuleName, overlayModuleInfos, - userId); + ret = OverlayManagerClient::GetInstance().GetOverlayModuleInfoForTarget(bundleName, targetModuleName, + overlayModuleInfos, userId); if (overlayModuleInfos.empty()) { ret = ERR_BUNDLEMANAGER_OVERLAY_QUERY_FAILED_NO_OVERLAY_MODULE_INFO; } @@ -2524,18 +2522,12 @@ std::string BundleManagerShellCommand::DumpTargetOverlayInfo(const std::string & APP_LOGE("error value of the dump-target-overlay command options"); return res; } - auto overlayManagerProxy = bundleMgrProxy_->GetOverlayManagerProxy(); - if (overlayManagerProxy == nullptr) { - APP_LOGE("overlayManagerProxy is null"); - return res; - } - userId = BundleCommandCommon::GetCurrentUserId(userId); ErrCode ret = ERR_OK; nlohmann::json overlayInfoJson; if (moduleName.empty()) { std::vector overlayBundleInfos; - ret = overlayManagerProxy->GetOverlayBundleInfoForTarget(bundleName, overlayBundleInfos, userId); + ret = OverlayManagerClient::GetInstance().GetOverlayBundleInfoForTarget(bundleName, overlayBundleInfos, userId); if (ret != ERR_OK || overlayBundleInfos.empty()) { APP_LOGE("dump-target-overlay failed due to errcode %{public}d", ret); return res; @@ -2543,7 +2535,8 @@ std::string BundleManagerShellCommand::DumpTargetOverlayInfo(const std::string & overlayInfoJson = nlohmann::json {{OVERLAY_BUNDLE_INFOS, overlayBundleInfos}}; } else { std::vector overlayModuleInfos; - ret = overlayManagerProxy->GetOverlayModuleInfoForTarget(bundleName, moduleName, overlayModuleInfos, userId); + ret = OverlayManagerClient::GetInstance().GetOverlayModuleInfoForTarget(bundleName, moduleName, + overlayModuleInfos, userId); if (ret != ERR_OK || overlayModuleInfos.empty()) { APP_LOGE("dump-target-overlay failed due to errcode %{public}d", ret); return res; diff --git a/frameworks/src/bundle_command_common.cpp b/frameworks/src/bundle_command_common.cpp index 986cba0..6534d5b 100644 --- a/frameworks/src/bundle_command_common.cpp +++ b/frameworks/src/bundle_command_common.cpp @@ -703,6 +703,10 @@ std::map BundleCommandCommon::bundleMessageMap_ = { IStatusReceiver::ERR_INSTALL_ENCRYPTED_BUNDLE_NOT_ALLOWED_FOR_SHELL, "error: Encrypted bundle cannot be installed." }, + { + IStatusReceiver::ERR_UNINSTALL_DISPOSED_RULE_DENIED, + "error: Failed to uninstall the app because the app is locked." + }, { IStatusReceiver::ERR_INSTALL_APPID_NOT_SAME_WITH_PREINSTALLED, "error: Bundle cannot be installed because the appId is not same with preinstalled bundle." -- Gitee