mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2024-11-23 07:09:53 +00:00
fms support sandbox frs
Signed-off-by: ZhuGangQiang <zhugangqiang3@huawei.com>
This commit is contained in:
parent
1ff9814357
commit
266b6e04e8
@ -48,6 +48,7 @@ const std::string METADATA_VALUE = "value";
|
||||
const std::string DATA_PROXY_ENABLED = "dataProxyEnabled";
|
||||
const std::string IS_DYNAMIC = "isDynamic";
|
||||
const std::string TRANSPARENCY_ENABLED = "transparencyEnabled";
|
||||
const std::string PRIVACY_LEVEL = "privacyLevel";
|
||||
}
|
||||
|
||||
class ExtensionFormProfile {
|
||||
@ -55,10 +56,12 @@ public:
|
||||
/**
|
||||
* @brief Transform the form profile to ExtensionFormInfos.
|
||||
* @param formProfile Indicates the string of the form profile.
|
||||
* @param info Indicates the obtained ExtensionFormProfileInfo.
|
||||
* @param infos Indicates the obtained ExtensionFormProfileInfo.
|
||||
* @param privacyLevel Indicates the form data privacy level.
|
||||
* @return Returns ERR_OK if the information transformed successfully; returns error code otherwise.
|
||||
*/
|
||||
static ErrCode TransformTo(const std::string &formProfile, std::vector<ExtensionFormInfo> &infos);
|
||||
static ErrCode TransformTo(
|
||||
const std::string &formProfile, std::vector<ExtensionFormInfo> &infos, int32_t &privacyLevel);
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -56,6 +56,7 @@ struct FormInfo : public Parcelable {
|
||||
bool dataProxyEnabled = false;
|
||||
bool isDynamic = true;
|
||||
bool transparencyEnabled = false;
|
||||
int32_t privacyLevel = 0;
|
||||
|
||||
FormInfo() = default;
|
||||
explicit FormInfo(const ExtensionAbilityInfo &abilityInfo, const ExtensionFormInfo &formInfo);
|
||||
|
@ -83,7 +83,8 @@ struct ExtensionFormProfileInfo {
|
||||
bool transparencyEnabled = false;
|
||||
};
|
||||
|
||||
struct ExtensionFormProfileInfoVec {
|
||||
struct ExtensionFormProfileInfoStruct {
|
||||
int32_t privacyLevel = 0;
|
||||
std::vector<ExtensionFormProfileInfo> forms {};
|
||||
};
|
||||
|
||||
@ -286,13 +287,21 @@ void from_json(const nlohmann::json &jsonObject, ExtensionFormProfileInfo &exten
|
||||
ArrayType::NOT_ARRAY);
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json &jsonObject, ExtensionFormProfileInfoVec &infos)
|
||||
void from_json(const nlohmann::json &jsonObject, ExtensionFormProfileInfoStruct &profileInfo)
|
||||
{
|
||||
const auto &jsonObjectEnd = jsonObject.end();
|
||||
GetValueIfFindKey<int32_t>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
ExtensionFormProfileReader::PRIVACY_LEVEL,
|
||||
profileInfo.privacyLevel,
|
||||
JsonType::NUMBER,
|
||||
false,
|
||||
g_parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<std::vector<ExtensionFormProfileInfo>>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
ExtensionFormProfileReader::FORMS,
|
||||
infos.forms,
|
||||
profileInfo.forms,
|
||||
JsonType::ARRAY,
|
||||
false,
|
||||
g_parseResult,
|
||||
@ -395,10 +404,10 @@ bool TransformToExtensionFormInfo(const ExtensionFormProfileInfo &form, Extensio
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TransformToInfos(const ExtensionFormProfileInfoVec &forms, std::vector<ExtensionFormInfo> &infos)
|
||||
bool TransformToInfos(const ExtensionFormProfileInfoStruct &profileInfo, std::vector<ExtensionFormInfo> &infos)
|
||||
{
|
||||
APP_LOGD("transform ExtensionFormProfileInfo to ExtensionFormInfo");
|
||||
for (const auto &form: forms.forms) {
|
||||
for (const auto &form: profileInfo.forms) {
|
||||
ExtensionFormInfo info;
|
||||
if (!TransformToExtensionFormInfo(form, info)) {
|
||||
return false;
|
||||
@ -409,7 +418,8 @@ bool TransformToInfos(const ExtensionFormProfileInfoVec &forms, std::vector<Exte
|
||||
}
|
||||
} // namespace
|
||||
|
||||
ErrCode ExtensionFormProfile::TransformTo(const std::string &formProfile, std::vector<ExtensionFormInfo> &infos)
|
||||
ErrCode ExtensionFormProfile::TransformTo(
|
||||
const std::string &formProfile, std::vector<ExtensionFormInfo> &infos, int32_t &privacyLevel)
|
||||
{
|
||||
APP_LOGD("transform profile to extension form infos");
|
||||
nlohmann::json jsonObject = nlohmann::json::parse(formProfile, nullptr, false);
|
||||
@ -418,11 +428,12 @@ ErrCode ExtensionFormProfile::TransformTo(const std::string &formProfile, std::v
|
||||
return ERR_APPEXECFWK_PARSE_BAD_PROFILE;
|
||||
}
|
||||
|
||||
ExtensionFormProfileInfoVec forms;
|
||||
ExtensionFormProfileInfoStruct profileInfo;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(g_mutex);
|
||||
g_parseResult = ERR_OK;
|
||||
forms = jsonObject.get<ExtensionFormProfileInfoVec>();
|
||||
profileInfo = jsonObject.get<ExtensionFormProfileInfoStruct>();
|
||||
privacyLevel = profileInfo.privacyLevel;
|
||||
if (g_parseResult != ERR_OK) {
|
||||
APP_LOGE("g_parseResult is %{public}d", g_parseResult);
|
||||
int32_t ret = g_parseResult;
|
||||
@ -432,7 +443,7 @@ ErrCode ExtensionFormProfile::TransformTo(const std::string &formProfile, std::v
|
||||
}
|
||||
}
|
||||
|
||||
if (!TransformToInfos(forms, infos)) {
|
||||
if (!TransformToInfos(profileInfo, infos)) {
|
||||
return ERR_APPEXECFWK_PARSE_PROFILE_PROP_CHECK_ERROR;
|
||||
}
|
||||
return ERR_OK;
|
||||
|
@ -62,6 +62,7 @@ const std::string JSON_KEY_IS_STATIC = "isStatic";
|
||||
const std::string JSON_KEY_DATA_PROXY_ENABLED = "dataProxyEnabled";
|
||||
const std::string JSON_KEY_IS_DYNAMIC = "isDynamic";
|
||||
const std::string JSON_KEY_TRANSPARENCY_ENABLED = "transparencyEnabled";
|
||||
const std::string JSON_KEY_PRIVACY_LEVEL = "privacyLevel";
|
||||
} // namespace
|
||||
|
||||
FormInfo::FormInfo(const ExtensionAbilityInfo &abilityInfo, const ExtensionFormInfo &formInfo)
|
||||
@ -185,6 +186,7 @@ bool FormInfo::ReadFromParcel(Parcel &parcel)
|
||||
dataProxyEnabled = parcel.ReadBool();
|
||||
isDynamic = parcel.ReadBool();
|
||||
transparencyEnabled = parcel.ReadBool();
|
||||
privacyLevel = parcel.ReadInt32();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -254,6 +256,7 @@ bool FormInfo::Marshalling(Parcel &parcel) const
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, dataProxyEnabled);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isDynamic);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, transparencyEnabled);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, privacyLevel);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -313,7 +316,8 @@ void to_json(nlohmann::json &jsonObject, const FormInfo &formInfo)
|
||||
{JSON_KEY_WINDOW, formInfo.window},
|
||||
{JSON_KEY_DATA_PROXY_ENABLED, formInfo.dataProxyEnabled},
|
||||
{JSON_KEY_IS_DYNAMIC, formInfo.isDynamic},
|
||||
{JSON_KEY_TRANSPARENCY_ENABLED, formInfo.transparencyEnabled}
|
||||
{JSON_KEY_TRANSPARENCY_ENABLED, formInfo.transparencyEnabled},
|
||||
{JSON_KEY_PRIVACY_LEVEL, formInfo.privacyLevel}
|
||||
};
|
||||
}
|
||||
|
||||
@ -619,6 +623,14 @@ void from_json(const nlohmann::json &jsonObject, FormInfo &formInfo)
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<int32_t>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
JSON_KEY_PRIVACY_LEVEL,
|
||||
formInfo.privacyLevel,
|
||||
JsonType::NUMBER,
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
if (parseResult != ERR_OK) {
|
||||
APP_LOGE("read module formInfo from jsonObject error, error code : %{public}d", parseResult);
|
||||
}
|
||||
|
@ -2468,7 +2468,8 @@ ErrCode BundleMgrHostImpl::GetSandboxAbilityInfo(const Want &want, int32_t appIn
|
||||
return ERR_APPEXECFWK_SANDBOX_QUERY_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (!dataMgr->QueryAbilityInfo(want, flags, userId, info, appIndex)) {
|
||||
if (!(dataMgr->QueryAbilityInfo(want, flags, userId, info, appIndex)
|
||||
|| dataMgr->QueryAbilityInfo(want, flags, Constants::DEFAULT_USERID, info, appIndex))) {
|
||||
APP_LOGE("query ability info failed");
|
||||
return ERR_APPEXECFWK_SANDBOX_QUERY_INTERNAL_ERROR;
|
||||
}
|
||||
@ -2498,7 +2499,8 @@ ErrCode BundleMgrHostImpl::GetSandboxExtAbilityInfos(const Want &want, int32_t a
|
||||
return ERR_APPEXECFWK_SANDBOX_QUERY_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (!dataMgr->QueryExtensionAbilityInfos(want, flags, userId, infos, appIndex)) {
|
||||
if (!(dataMgr->QueryExtensionAbilityInfos(want, flags, userId, infos, appIndex)
|
||||
|| dataMgr->QueryExtensionAbilityInfos(want, flags, Constants::DEFAULT_USERID, infos, appIndex))) {
|
||||
APP_LOGE("query extension ability info failed");
|
||||
return ERR_APPEXECFWK_SANDBOX_QUERY_INTERNAL_ERROR;
|
||||
}
|
||||
|
@ -35,9 +35,10 @@ namespace {
|
||||
std::vector<ExtensionFormInfo> infos(1);
|
||||
infos[0].name = "com.ohos.contactsdataability";
|
||||
infos[0].description = "dataability_description";
|
||||
int32_t level = 0;
|
||||
for (auto _ : state) {
|
||||
/* @tc.steps: step1.call TransformTo in loop */
|
||||
info.TransformTo(formProfile, infos);
|
||||
info.TransformTo(formProfile, infos, level);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user