ability和extension添加进程标签

Signed-off-by: jiangminsen <jiangminsen@huawei.com>
This commit is contained in:
jiangminsen 2024-11-09 16:45:24 +08:00
parent 63f4da87da
commit a29099707a
4 changed files with 30 additions and 2 deletions

View File

@ -180,6 +180,7 @@ struct ExtensionAbilityInfo : public Parcelable {
bool needCreateSandbox = false;
std::vector<std::string> dataGroupIds;
std::vector<std::string> validDataGroupIds;
std::string customProcess;
bool ReadFromParcel(Parcel &parcel);
virtual bool Marshalling(Parcel &parcel) const override;

View File

@ -59,6 +59,7 @@ const char* SKILLS = "skills";
const char* NEED_CREATE_SANDBOX = "needCreateSandbox";
const char* DATA_GROUP_IDS = "dataGroupIds";
const char* JSON_KEY_VALID_DATA_GROUP_IDS = "validDataGroupIds";
const char* JSON_KEY_CUSTOM_PROCESS = "customProcess";
const std::unordered_map<std::string, ExtensionAbilityType> EXTENSION_TYPE_MAP = {
{ "form", ExtensionAbilityType::FORM },
@ -259,6 +260,7 @@ bool ExtensionAbilityInfo::ReadFromParcel(Parcel &parcel)
for (auto i = 0; i < validDataGroupIdsSize; i++) {
dataGroupIds.emplace_back(Str16ToStr8(parcel.ReadString16()));
}
customProcess = Str16ToStr8(parcel.ReadString16());
return true;
}
@ -343,6 +345,7 @@ bool ExtensionAbilityInfo::Marshalling(Parcel &parcel) const
for (auto &dataGroupId : validDataGroupIds) {
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(dataGroupId));
}
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(customProcess));
return true;
}
@ -380,7 +383,8 @@ void to_json(nlohmann::json &jsonObject, const ExtensionAbilityInfo &extensionIn
{JSON_KEY_SKILLS, extensionInfo.skills},
{NEED_CREATE_SANDBOX, extensionInfo.needCreateSandbox},
{DATA_GROUP_IDS, extensionInfo.dataGroupIds},
{JSON_KEY_VALID_DATA_GROUP_IDS, extensionInfo.validDataGroupIds}
{JSON_KEY_VALID_DATA_GROUP_IDS, extensionInfo.validDataGroupIds},
{JSON_KEY_CUSTOM_PROCESS, extensionInfo.customProcess}
};
}
@ -603,6 +607,12 @@ void from_json(const nlohmann::json &jsonObject, ExtensionAbilityInfo &extension
false,
parseResult,
ArrayType::STRING);
BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
jsonObjectEnd,
JSON_KEY_CUSTOM_PROCESS,
extensionInfo.customProcess,
false,
parseResult);
if (parseResult != ERR_OK) {
APP_LOGE("ExtensionAbilityInfo from_json error : %{public}d", parseResult);
}

View File

@ -199,6 +199,7 @@ struct Ability {
std::string preferMultiWindowOrientation = "default";
std::vector<std::string> continueType;
std::vector<std::string> continueBundleNames;
std::string process;
};
struct Extension {
@ -221,6 +222,7 @@ struct Extension {
std::vector<Metadata> metadata;
std::string extensionProcessMode;
std::vector<std::string> dataGroupIds;
std::string customProcess;
};
struct MultiAppMode {
@ -642,6 +644,12 @@ void from_json(const nlohmann::json &jsonObject, Ability &ability)
false,
g_parseResult,
ArrayType::STRING);
BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
jsonObjectEnd,
MODULE_PROCESS,
ability.process,
false,
g_parseResult);
}
void from_json(const nlohmann::json &jsonObject, Extension &extension)
@ -795,6 +803,12 @@ void from_json(const nlohmann::json &jsonObject, Extension &extension)
false,
g_parseResult,
ArrayType::STRING);
BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
jsonObjectEnd,
MODULE_PROCESS,
extension.customProcess,
false,
g_parseResult);
}
void from_json(const nlohmann::json &jsonObject, DeviceConfig &deviceConfig)
@ -2136,6 +2150,7 @@ bool ToAbilityInfo(
abilityInfo.continueType = ability.continueType;
}
abilityInfo.orientationId = ability.orientationId;
abilityInfo.process = ability.process;
return true;
}
@ -2194,6 +2209,7 @@ void ToExtensionInfo(
for (const std::string &dataGroup : extension.dataGroupIds) {
extensionInfo.dataGroupIds.emplace_back(dataGroup);
}
extensionInfo.customProcess = extension.customProcess;
}
bool GetPermissions(

View File

@ -865,7 +865,8 @@ protected:
"continueType": [],
"continueBundleName": [],
"appIndex": 0,
"orientationId": 0
"orientationId": 0,
"process": ""
},
"com.ohos.launcher.com.ohos.launcher.recents.com.ohos.launcher.recents.MainAbility": {
"applicationName": "com.ohos.launcher",