diff --git a/services/context/inc/widget_context.h b/services/context/inc/widget_context.h index 5f6e9d0edce6647cb0c9adf3ac05f01834826616..8d97a611b3816f8a54a810c9a5c868f3e71083eb 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 4e4ac47688e75be04630671937e448b13403f3bd..8de0e20c4c7cdee6a691750e7f4e243dafe42b02 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 521deff1537b2705789de35f39cef0298ab7ba16..78863a5b9ffede3706e528c51530efa1263265f6 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 88e5dbb139ed6a6efef7a5042c847717848ffbdc..665f2c3d9e70c3402a10c7bb45500586506c9695 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;