From baed1508534ba9548fb43d098a3e4afb97dc37ae Mon Sep 17 00:00:00 2001 From: kaiju Date: Tue, 5 Aug 2025 16:47:03 +0800 Subject: [PATCH] fix:revert get bundleName from config Signed-off-by: kaiju Change-Id: Ib0111796b91a445fd0650f806dc44326bb83b0c0 --- services/context/inc/widget_context.h | 1 - services/context/inc/widget_json.h | 7 +-- services/context/src/widget_context.cpp | 11 +--- services/context/src/widget_json.cpp | 67 ++++--------------------- 4 files changed, 14 insertions(+), 72 deletions(-) diff --git a/services/context/inc/widget_context.h b/services/context/inc/widget_context.h index 5f6e9d0ed..8d97a611b 100644 --- a/services/context/inc/widget_context.h +++ b/services/context/inc/widget_context.h @@ -160,7 +160,6 @@ private: WidgetAuthResultInfo authResultInfo_ {}; int32_t faceReload_ {0}; uint32_t widgetAlreadyLoad_ {0}; - nlohmann::json jsonBuf_ = {}; }; } // namespace UserAuth } // namespace UserIam diff --git a/services/context/inc/widget_json.h b/services/context/inc/widget_json.h index 4e4ac4768..8de0e20c4 100644 --- a/services/context/inc/widget_json.h +++ b/services/context/inc/widget_json.h @@ -53,11 +53,8 @@ struct WidgetNotice { }; void to_json(nlohmann::json &jsonNotice, const WidgetNotice ¬ice); void from_json(const nlohmann::json &jsonNotice, WidgetNotice ¬ice); -void LoadConfigJsonBuffer(nlohmann::json &jsonBuf); -bool GetProcessName(nlohmann::json &jsonBuf, std::vector &processName); -bool GetFollowCallerList(nlohmann::json &jsonBuf, std::vector &processName); -bool GetSceneboardBundleName(nlohmann::json &jsonBuf, std::string &processName); -bool GetSceneboardAbilityName(nlohmann::json &jsonBuf, std::string &processName); +bool GetProcessName(std::vector &processName); +bool GetFollowCallerList(std::vector &processName); // WidgetCommand struct WidgetCommand { diff --git a/services/context/src/widget_context.cpp b/services/context/src/widget_context.cpp index 521deff15..78863a5b9 100644 --- a/services/context/src/widget_context.cpp +++ b/services/context/src/widget_context.cpp @@ -77,7 +77,6 @@ WidgetContext::WidgetContext(uint64_t contextId, const ContextFactory::AuthWidge if (!para.isBackgroundApplication) { SubscribeAppState(callerCallback_, contextId_); } - LoadConfigJsonBuffer(jsonBuf_); } WidgetContext::~WidgetContext() @@ -484,7 +483,7 @@ bool WidgetContext::IsInFollowCallerList() IAM_LOGI("productName is %{public}s.", productName.c_str()); std::vector processName; - if (!GetFollowCallerList(jsonBuf_, processName)) { + if (!GetFollowCallerList(processName)) { IAM_LOGE("GetFollowCallerList error"); return false; } @@ -511,7 +510,7 @@ void WidgetContext::SetSysDialogZOrder(WidgetCmdParameters &widgetCmdParameters) IAM_LOGI("the screen is currently locked, set zOrder"); widgetCmdParameters.sysDialogZOrder = SYSDIALOG_ZORDER_UPPER; } - if (!GetProcessName(jsonBuf_, processName)) { + if (!GetProcessName(processName)) { IAM_LOGE("getProcessName error"); return; } @@ -561,12 +560,6 @@ bool WidgetContext::ConnectExtension(const WidgetRotatePara &widgetRotatePara) AAFwk::Want want; std::string bundleName = "com.ohos.systemui"; std::string abilityName = "com.ohos.systemui.dialog"; - if (!GetSceneboardBundleName(jsonBuf_, bundleName)) { - IAM_LOGI("GetSceneboardBundleName error"); - } - if (!GetSceneboardAbilityName(jsonBuf_, abilityName)) { - IAM_LOGI("GetSceneboardAbilityName error"); - } want.SetElementName(bundleName, abilityName); auto ret = ConnectExtensionAbility(want, commandData); if (ret != ERR_OK) { diff --git a/services/context/src/widget_json.cpp b/services/context/src/widget_json.cpp index 88e5dbb13..665f2c3d9 100644 --- a/services/context/src/widget_json.cpp +++ b/services/context/src/widget_json.cpp @@ -88,8 +88,6 @@ const std::string JSON_CMD_EXTRA_INFO = "extraInfo"; constexpr const char *AUTH_WIDGE_CONFIG_SUFFIX = "etc/auth_widget/auth_widget_config.json"; const std::string SHWO_WITH_LEVEL_2_WINDOW = "show_with_level_2_window"; const std::string FOLLOW_CALLER_WINDOW_WHEN_FOLDED = "follow_caller_window_when_folded"; -const std::string SCENEBOARD_BUNDLE_NAME = "sceneboard_bundle_name"; -const std::string SCENEBOARD_ABILITY_NAME = "sceneboard_ability_name"; const uint32_t DISABLE_ROTATE = 0; const uint32_t MAX_ERR_BUF_LEN = 256; @@ -197,10 +195,6 @@ bool GetStringArrayFromJson(const nlohmann::json &jsonObject, std::vector &exemptedBundleInfos, const std::string &key) { - if (jsonObject.is_null()) { - IAM_LOGE("jsonObject is null"); - return false; - } if (jsonObject.is_array() && !jsonObject.is_discarded()) { for (const auto &object : jsonObject) { if (!object.is_object()) { @@ -218,30 +212,6 @@ bool GetStringArrayFromJson(const nlohmann::json &jsonObject, IAM_LOGE("getStringArrayFromJson error"); return false; } - -bool GetStringFromJson(const nlohmann::json &jsonObject, std::string &exemptedBundleInfo, - const std::string &key) -{ - if (jsonObject.is_null()) { - IAM_LOGE("jsonObject is null"); - return false; - } - if (jsonObject.is_array() && !jsonObject.is_discarded()) { - for (const auto &object : jsonObject) { - if (!object.is_object()) { - IAM_LOGE("is not object"); - return false; - } - const auto &objectEnd = object.end(); - if (object.find(key) != objectEnd) { - exemptedBundleInfo = object.at(key).get(); - return true; - } - } - } - IAM_LOGE("getStringFromJson error"); - return false; -} } // utils @@ -442,38 +412,15 @@ std::string GetConfigRealPath() return configPath; } -void LoadConfigJsonBuffer(nlohmann::json &jsonBuf) +bool GetProcessName(std::vector &processName) { - IAM_LOGI("LoadConfig start"); + IAM_LOGI("enter"); + nlohmann::json jsonBuf; std::string configPath = GetConfigRealPath(); if (!ReadFileIntoJson(configPath, jsonBuf)) { IAM_LOGE("ReadFileIntoJson failed"); - } -} - -bool GetSceneboardBundleName(nlohmann::json &jsonBuf, std::string &processName) -{ - IAM_LOGI("enter"); - if (!GetStringFromJson(jsonBuf, processName, SCENEBOARD_BUNDLE_NAME)) { - IAM_LOGE("GetStringFromJson failed"); - return false; - } - return true; -} - -bool GetSceneboardAbilityName(nlohmann::json &jsonBuf, std::string &processName) -{ - IAM_LOGI("enter"); - if (!GetStringFromJson(jsonBuf, processName, SCENEBOARD_ABILITY_NAME)) { - IAM_LOGE("GetStringFromJson failed"); return false; } - return true; -} - -bool GetProcessName(nlohmann::json &jsonBuf, std::vector &processName) -{ - IAM_LOGI("enter"); if (!GetStringArrayFromJson(jsonBuf, processName, SHWO_WITH_LEVEL_2_WINDOW)) { IAM_LOGE("GetStringArrayFromJson failed"); return false; @@ -481,9 +428,15 @@ bool GetProcessName(nlohmann::json &jsonBuf, std::vector &processNa return true; } -bool GetFollowCallerList(nlohmann::json &jsonBuf, std::vector &processName) +bool GetFollowCallerList(std::vector &processName) { IAM_LOGI("enter"); + nlohmann::json jsonBuf; + std::string configPath = GetConfigRealPath(); + if (!ReadFileIntoJson(configPath, jsonBuf)) { + IAM_LOGE("Path to realPath failed"); + return false; + } if (!GetStringArrayFromJson(jsonBuf, processName, FOLLOW_CALLER_WINDOW_WHEN_FOLDED)) { IAM_LOGE("GetStringArrayFromJson failed"); return false; -- Gitee