From 045002c5e5188415bc38bd97c1ac99532830b66b Mon Sep 17 00:00:00 2001 From: zhouxueer Date: Sat, 3 Aug 2024 22:57:40 +0800 Subject: [PATCH] add config item for form config Signed-off-by: zhouxueer --- .../appexecfwk_base/include/extension_form_info.h | 1 + .../include/extension_form_profile.h | 1 + .../inner_api/appexecfwk_base/include/form_info.h | 1 + .../appexecfwk_base/src/extension_form_profile.cpp | 10 ++++++++++ .../inner_api/appexecfwk_base/src/form_info.cpp | 13 +++++++++++++ interfaces/kits/js/bundlemgr/bundle_mgr.cpp | 5 +++++ services/bundlemgr/include/common_profile.h | 1 + services/bundlemgr/src/bundle_profile.cpp | 10 ++++++++++ 8 files changed, 42 insertions(+) diff --git a/interfaces/inner_api/appexecfwk_base/include/extension_form_info.h b/interfaces/inner_api/appexecfwk_base/include/extension_form_info.h index 270cc7dfcf..52b82e082e 100644 --- a/interfaces/inner_api/appexecfwk_base/include/extension_form_info.h +++ b/interfaces/inner_api/appexecfwk_base/include/extension_form_info.h @@ -42,6 +42,7 @@ struct ExtensionFormInfo { std::string src; FormWindow window; std::string formConfigAbility; + std::string formBindAbility; int32_t updateDuration = 0; int32_t defaultDimension = 0; std::vector supportDimensions {}; diff --git a/interfaces/inner_api/appexecfwk_base/include/extension_form_profile.h b/interfaces/inner_api/appexecfwk_base/include/extension_form_profile.h index 5f57c68a0e..46176483a5 100644 --- a/interfaces/inner_api/appexecfwk_base/include/extension_form_profile.h +++ b/interfaces/inner_api/appexecfwk_base/include/extension_form_profile.h @@ -34,6 +34,7 @@ constexpr const char* WINDOW_DESIGN_WIDTH = "designWidth"; constexpr const char* WINDOW_AUTO_DESIGN_WIDTH = "autoDesignWidth"; constexpr const char* COLOR_MODE = "colorMode"; constexpr const char* FORM_CONFIG_ABILITY = "formConfigAbility"; +constexpr const char* FORM_BIND_ABILITY = "formBindAbility"; constexpr const char* TYPE = "type"; constexpr const char* UI_SYNTAX = "uiSyntax"; constexpr const char* FORM_VISIBLE_NOTIFY = "formVisibleNotify"; diff --git a/interfaces/inner_api/appexecfwk_base/include/form_info.h b/interfaces/inner_api/appexecfwk_base/include/form_info.h index 3e847f7cb9..a83516528b 100644 --- a/interfaces/inner_api/appexecfwk_base/include/form_info.h +++ b/interfaces/inner_api/appexecfwk_base/include/form_info.h @@ -37,6 +37,7 @@ struct FormInfo : public Parcelable { std::string jsComponentName; std::string deepLink; std::string formConfigAbility; + std::string formBindAbility; std::string scheduledUpdateTime = ""; std::string src; FormWindow window; diff --git a/interfaces/inner_api/appexecfwk_base/src/extension_form_profile.cpp b/interfaces/inner_api/appexecfwk_base/src/extension_form_profile.cpp index 1a15060f56..6b9e5861a5 100644 --- a/interfaces/inner_api/appexecfwk_base/src/extension_form_profile.cpp +++ b/interfaces/inner_api/appexecfwk_base/src/extension_form_profile.cpp @@ -75,6 +75,7 @@ struct ExtensionFormProfileInfo { Window window; std::string colorMode = "auto"; std::string formConfigAbility; + std::string formBindAbility; std::string type = "JS"; std::string uiSyntax = "hml"; std::string scheduledUpdateTime = ""; @@ -198,6 +199,14 @@ void from_json(const nlohmann::json &jsonObject, ExtensionFormProfileInfo &exten false, g_parseResult, ArrayType::NOT_ARRAY); + GetValueIfFindKey(jsonObject, + jsonObjectEnd, + ExtensionFormProfileReader::FORM_BIND_ABILITY, + extensionFormProfileInfo.formBindAbility, + JsonType::STRING, + false, + g_parseResult, + ArrayType::NOT_ARRAY); GetValueIfFindKey(jsonObject, jsonObjectEnd, ExtensionFormProfileReader::TYPE, @@ -441,6 +450,7 @@ bool TransformToExtensionFormInfo(const ExtensionFormProfileInfo &form, Extensio } info.formConfigAbility = form.formConfigAbility; + info.formBindAbility = form.formBindAbility; info.formVisibleNotify = form.formVisibleNotify; info.isDefault = form.isDefault; info.updateEnabled = form.updateEnabled; diff --git a/interfaces/inner_api/appexecfwk_base/src/form_info.cpp b/interfaces/inner_api/appexecfwk_base/src/form_info.cpp index baf222fc74..011add1942 100644 --- a/interfaces/inner_api/appexecfwk_base/src/form_info.cpp +++ b/interfaces/inner_api/appexecfwk_base/src/form_info.cpp @@ -52,6 +52,7 @@ const char* JSON_KEY_TYPE = "type"; const char* JSON_KEY_UI_SYNTAX = "uiSyntax"; const char* JSON_KEY_LANDSCAPE_LAYOUTS = "landscapeLayouts"; const char* JSON_KEY_FORMCONFIG_ABILITY = "formConfigAbility"; +const char* JSON_KEY_FORMBIND_ABILITY = "formBindAbility"; const char* JSON_KEY_FORM_VISIBLE_NOTIFY = "formVisibleNotify"; const char* JSON_KEY_RELATED_BUNDLE_NAME = "relatedBundleName"; const char* JSON_KEY_DEFAULT_FLAG = "defaultFlag"; @@ -85,6 +86,7 @@ FormInfo::FormInfo(const ExtensionAbilityInfo &abilityInfo, const ExtensionFormI jsComponentName = ""; deepLink = ""; formConfigAbility = formInfo.formConfigAbility; + formBindAbility = formInfo.formBindAbility; scheduledUpdateTime = formInfo.scheduledUpdateTime; src = formInfo.src; window.designWidth = formInfo.window.designWidth; @@ -146,6 +148,7 @@ bool FormInfo::ReadFromParcel(Parcel &parcel) displayName = Str16ToStr8(parcel.ReadString16()); description = Str16ToStr8(parcel.ReadString16()); formConfigAbility = Str16ToStr8(parcel.ReadString16()); + formBindAbility = Str16ToStr8(parcel.ReadString16()); scheduledUpdateTime = Str16ToStr8(parcel.ReadString16()); jsComponentName = Str16ToStr8(parcel.ReadString16()); relatedBundleName = Str16ToStr8(parcel.ReadString16()); @@ -240,6 +243,7 @@ bool FormInfo::Marshalling(Parcel &parcel) const WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(displayName)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(description)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(formConfigAbility)); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(formBindAbility)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(scheduledUpdateTime)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(jsComponentName)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(relatedBundleName)); @@ -340,6 +344,7 @@ void to_json(nlohmann::json &jsonObject, const FormInfo &formInfo) {JSON_KEY_DEEP_LINK, formInfo.deepLink}, {JSON_KEY_SRC, formInfo.src}, {JSON_KEY_FORMCONFIG_ABILITY, formInfo.formConfigAbility}, + {JSON_KEY_FORMBIND_ABILITY, formInfo.formBindAbility}, {JSON_KEY_SCHEDULED_UPDATE_TIME, formInfo.scheduledUpdateTime}, {JSON_KEY_ORIGINAL_BUNDLE_NAME, formInfo.originalBundleName}, {JSON_KEY_DISPLAY_NAME_ID, formInfo.displayNameId}, @@ -511,6 +516,14 @@ void from_json(const nlohmann::json &jsonObject, FormInfo &formInfo) false, parseResult, ArrayType::NOT_ARRAY); + GetValueIfFindKey(jsonObject, + jsonObjectEnd, + JSON_KEY_FORMBIND_ABILITY, + formInfo.formBindAbility, + JsonType::STRING, + false, + parseResult, + ArrayType::NOT_ARRAY); GetValueIfFindKey(jsonObject, jsonObjectEnd, JSON_KEY_SCHEDULED_UPDATE_TIME, diff --git a/interfaces/kits/js/bundlemgr/bundle_mgr.cpp b/interfaces/kits/js/bundlemgr/bundle_mgr.cpp index 37086fb3e1..edbb8cc33f 100644 --- a/interfaces/kits/js/bundlemgr/bundle_mgr.cpp +++ b/interfaces/kits/js/bundlemgr/bundle_mgr.cpp @@ -1011,6 +1011,11 @@ static void ConvertFormInfo(napi_env env, napi_value objformInfo, const FormInfo env, napi_create_string_utf8(env, formInfo.formConfigAbility.c_str(), NAPI_AUTO_LENGTH, &nFormConfigAbility)); NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objformInfo, "formConfigAbility", nFormConfigAbility)); + napi_value nFormBindAbility; + NAPI_CALL_RETURN_VOID( + env, napi_create_string_utf8(env, formInfo.formBindAbility.c_str(), NAPI_AUTO_LENGTH, &nFormBindAbility)); + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objformInfo, "formBindAbility", nFormBindAbility)); + napi_value nType; NAPI_CALL_RETURN_VOID(env, napi_create_int32(env, static_cast(formInfo.type), &nType)); NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objformInfo, "type", nType)); diff --git a/services/bundlemgr/include/common_profile.h b/services/bundlemgr/include/common_profile.h index 927f736636..34ea74c566 100644 --- a/services/bundlemgr/include/common_profile.h +++ b/services/bundlemgr/include/common_profile.h @@ -212,6 +212,7 @@ constexpr const char* BUNDLE_MODULE_PROFILE_FORMS_DEEP_LINK = "deepLink"; constexpr const char* BUNDLE_MODULE_PROFILE_FORMS_JS_COMPONENT_NAME = "jsComponentName"; constexpr const char* BUNDLE_MODULE_PROFILE_FORMS_VALUE = "value"; constexpr const char* BUNDLE_MODULE_PROFILE_FORMS_FORM_CONFIG_ABILITY = "formConfigAbility"; +constexpr const char* BUNDLE_MODULE_PROFILE_FORMS_FORM_BIND_ABILITY = "formBindAbility"; constexpr const char* BUNDLE_MODULE_PROFILE_FORMS_FORM_VISIBLE_NOTIFY = "formVisibleNotify"; constexpr const char* BUNDLE_MODULE_PROFILE_FORMS_SRC = "src"; // sub BUNDLE_MODULE_PROFILE_KEY_JS diff --git a/services/bundlemgr/src/bundle_profile.cpp b/services/bundlemgr/src/bundle_profile.cpp index 9631224c63..37aac65728 100644 --- a/services/bundlemgr/src/bundle_profile.cpp +++ b/services/bundlemgr/src/bundle_profile.cpp @@ -224,6 +224,7 @@ struct Forms { int32_t updateDuration = 0; std::string deepLink; std::string formConfigAbility; + std::string formBindAbility; bool formVisibleNotify = false; std::string jsComponentName; FormsMetaData metaData; @@ -1119,6 +1120,14 @@ void from_json(const nlohmann::json &jsonObject, Forms &forms) false, g_parseResult, ArrayType::NOT_ARRAY); + GetValueIfFindKey(jsonObject, + jsonObjectEnd, + BUNDLE_MODULE_PROFILE_FORMS_FORM_BIND_ABILITY, + forms.formBindAbility, + JsonType::STRING, + false, + g_parseResult, + ArrayType::NOT_ARRAY); GetValueIfFindKey(jsonObject, jsonObjectEnd, BUNDLE_MODULE_PROFILE_FORMS_FORM_VISIBLE_NOTIFY, @@ -1991,6 +2000,7 @@ bool ConvertFormInfo(FormInfo &formInfo, const ProfileReader::Forms &form) formInfo.description = form.description; formInfo.descriptionId = form.descriptionId; formInfo.formConfigAbility = form.formConfigAbility; + formInfo.formBindAbility = form.formBindAbility; formInfo.formVisibleNotify = form.formVisibleNotify; formInfo.deepLink = form.deepLink; formInfo.defaultFlag = form.isDefault; -- Gitee