mirror of
https://github.com/openharmony/appexecfwk_standard.git
synced 2026-07-20 14:33:41 -04:00
Description:add GetBackgroundModes Sig:appexecfwk Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: wangtiantian <wangtiantian19@huawei.com>
This commit is contained in:
@@ -115,6 +115,7 @@ struct ApplicationInfo : public Parcelable {
|
||||
std::string cpuAbi;
|
||||
bool isCompressNativeLibs = true;
|
||||
bool debug = false;
|
||||
bool singleUser = false;
|
||||
bool systemApp = false;
|
||||
std::map<std::string, std::vector<CustomizeData>> metaData;
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ bool ApplicationInfo::ReadFromParcel(Parcel &parcel)
|
||||
isLauncherApp = parcel.ReadBool();
|
||||
enabled = parcel.ReadBool();
|
||||
debug = parcel.ReadBool();
|
||||
singleUser = parcel.ReadBool();
|
||||
removable = parcel.ReadBool();
|
||||
supportedModes = parcel.ReadInt32();
|
||||
labelId = parcel.ReadInt32();
|
||||
@@ -197,6 +198,7 @@ bool ApplicationInfo::Marshalling(Parcel &parcel) const
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isLauncherApp);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, enabled);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, debug);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, singleUser);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, removable);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, supportedModes);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, labelId);
|
||||
@@ -276,6 +278,7 @@ void to_json(nlohmann::json &jsonObject, const ApplicationInfo &applicationInfo)
|
||||
{APPLICATION_IS_LAUNCHER_APP, applicationInfo.isLauncherApp},
|
||||
{APPLICATION_ENABLED, applicationInfo.enabled},
|
||||
{APPLICATION_DEBUG, applicationInfo.debug},
|
||||
{"singleUser", applicationInfo.singleUser},
|
||||
{APPLICATION_REMOVABLE, applicationInfo.removable},
|
||||
{APPLICATION_SUPPORTED_MODES, applicationInfo.supportedModes},
|
||||
{APPLICATION_PROCESS, applicationInfo.process},
|
||||
@@ -416,6 +419,14 @@ void from_json(const nlohmann::json &jsonObject, ApplicationInfo &applicationInf
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<bool>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
"singleUser",
|
||||
applicationInfo.singleUser,
|
||||
JsonType::BOOLEAN,
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
// To be compatible with the data of the old image.
|
||||
// if the app is a system app and is not configured with removable,
|
||||
// the application cannot be uninstalled.
|
||||
|
||||
@@ -66,6 +66,17 @@ const std::map<std::string, FormsColorMode> formColorModeMap = {
|
||||
{"dark", FormsColorMode::DARK_MODE},
|
||||
{"light", FormsColorMode::LIGHT_MODE}
|
||||
};
|
||||
std::map<std::string, uint32_t> backgroundModeMap = {
|
||||
{KEY_DATA_TRANSFER, VALUE_DATA_TRANSFER},
|
||||
{KEY_AUDIO_PLAYBACK, VALUE_AUDIO_PLAYBACK},
|
||||
{KEY_AUDIO_RECORDING, VALUE_AUDIO_RECORDING},
|
||||
{KEY_LOCATION, VALUE_LOCATION},
|
||||
{KEY_BLUETOOTH_INTERACTION, VALUE_BLUETOOTH_INTERACTION},
|
||||
{KEY_MULTI_DEVICE_CONNECTION, VALUE_MULTI_DEVICE_CONNECTION},
|
||||
{KEY_WIFI_INTERACTION, VALUE_WIFI_INTERACTION},
|
||||
{KEY_VOIP, VALUE_VOIP},
|
||||
{KEY_TASK_KEEPING, VALUE_TASK_KEEPING}
|
||||
};
|
||||
|
||||
struct Version {
|
||||
int32_t code = 0;
|
||||
@@ -85,6 +96,7 @@ struct App {
|
||||
bool removable = true;
|
||||
Version version;
|
||||
ApiVersion apiVersion;
|
||||
bool singleUser = false;
|
||||
};
|
||||
|
||||
struct ReqVersion {
|
||||
@@ -398,6 +410,14 @@ void from_json(const nlohmann::json &jsonObject, App &app)
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<bool>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
BUNDLE_APP_PROFILE_KEY_SINGLE_USER,
|
||||
app.singleUser,
|
||||
JsonType::BOOLEAN,
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
if (parseResult) {
|
||||
return;
|
||||
}
|
||||
@@ -1828,6 +1848,7 @@ bool TransformToInfo(const ProfileReader::ConfigJson &configJson, ApplicationInf
|
||||
applicationInfo.debug = configJson.deveicConfig.defaultDevice.debug;
|
||||
applicationInfo.enabled = true;
|
||||
applicationInfo.removable = configJson.app.removable;
|
||||
applicationInfo.singleUser = configJson.app.singleUser;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1848,6 +1869,7 @@ bool TransformToInfo(const ProfileReader::ConfigJson &configJson, BundleInfo &bu
|
||||
bundleInfo.targetVersion = configJson.app.apiVersion.target;
|
||||
bundleInfo.releaseType = configJson.app.apiVersion.releaseType;
|
||||
bundleInfo.isKeepAlive = configJson.deveicConfig.defaultDevice.keepAlive;
|
||||
bundleInfo.singleUser = configJson.app.singleUser;
|
||||
if (configJson.module.abilities.size() > 0) {
|
||||
bundleInfo.label = configJson.module.abilities[0].label;
|
||||
}
|
||||
@@ -1870,6 +1892,17 @@ void GetMetaData(MetaData &metaData, const ProfileReader::MetaData &profileMetaD
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t GetBackgroundModes(const std::vector<std::string>& backgroundModes)
|
||||
{
|
||||
uint32_t backgroundMode = 0;
|
||||
for (const auto& item : backgroundModes) {
|
||||
if (ProfileReader::backgroundModeMap.find(item) != ProfileReader::backgroundModeMap.end()) {
|
||||
backgroundMode |= ProfileReader::backgroundModeMap[item];
|
||||
}
|
||||
}
|
||||
return backgroundMode;
|
||||
}
|
||||
|
||||
bool TransformToInfo(const ProfileReader::ConfigJson &configJson, InnerModuleInfo &innerModuleInfo)
|
||||
{
|
||||
innerModuleInfo.modulePackage = configJson.module.package;
|
||||
@@ -1968,6 +2001,7 @@ bool TransformToInfo(
|
||||
abilityInfo.defaultFormWidth = ability.form.defaultWidth;
|
||||
GetMetaData(abilityInfo.metaData, ability.metaData);
|
||||
abilityInfo.formEnabled = ability.formsEnabled;
|
||||
abilityInfo.backgroundModes = GetBackgroundModes(ability.backgroundModes);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user