Merge remote-tracking branch 'upstream/master' into 062102

This commit is contained in:
sunjiakun 2024-07-02 09:20:17 +08:00
commit 562669909c
300 changed files with 5048 additions and 2106 deletions

View File

@ -70,7 +70,6 @@ declare_args() {
bms_device_info_manager_part_enabled = true
app_domain_verify_enabled = true
device_usage_statistics_enabled = true
pend_sign_screenlock_mgr_enable = false
if (defined(global_parts_info) &&
!defined(global_parts_info.resourceschedule_device_usage_statistics)) {
@ -182,11 +181,6 @@ declare_args() {
!defined(global_parts_info.bundlemanager_app_domain_verify)) {
app_domain_verify_enabled = false
}
if (defined(global_parts_info) &&
defined(global_parts_info.theme_screenlock_mgr)) {
pend_sign_screenlock_mgr_enable = true
}
}
print("bundle_framework_power_mgr_enable = " +

View File

@ -67,7 +67,6 @@
"safwk",
"resource_management",
"samgr",
"screenlock_mgr",
"selinux_adapter",
"syscap_codec",
"storage_service",

View File

@ -65,11 +65,11 @@ bool BundleFileUtil::CheckFilePath(const std::string &bundlePath, std::string &r
return false;
}
if (access(realPath.c_str(), F_OK) != 0) {
APP_LOGE("can not access the bundle file path: %{public}s, errno:%{public}d", realPath.c_str(), errno);
APP_LOGE("access failed path: %{public}s errno %{public}d", realPath.c_str(), errno);
return false;
}
if (!CheckFileSize(realPath, MAX_HAP_SIZE)) {
APP_LOGE("file size is larger than max hap size Max size is: %{public}" PRId64, MAX_HAP_SIZE);
APP_LOGE("file size larger than max hap size: %{public}" PRId64, MAX_HAP_SIZE);
return false;
}
return true;
@ -98,7 +98,7 @@ bool BundleFileUtil::CheckFilePath(const std::vector<std::string> &bundlePaths,
return true;
}
if (!GetHapFilesFromBundlePath(bundlePath, realPaths)) {
APP_LOGE("GetHapFilesFromBundlePath failed with bundlePath:%{public}s", bundlePaths.front().c_str());
APP_LOGE("GetHapFilesFromBundlePath failed :%{public}s", bundlePaths.front().c_str());
return false;
}
return true;
@ -139,7 +139,7 @@ bool BundleFileUtil::CheckFileName(const std::string &fileName)
return false;
}
if (fileName.size() > PATH_MAX_SIZE) {
APP_LOGE("bundle file path length %{public}zu too long", fileName.size());
APP_LOGE("path length %{public}zu too long", fileName.size());
return false;
}
return true;
@ -169,7 +169,7 @@ bool BundleFileUtil::GetHapFilesFromBundlePath(const std::string &currentBundleP
if (dir == nullptr) {
char errMsg[256] = {0};
strerror_r(errno, errMsg, sizeof(errMsg));
APP_LOGE("GetHapFilesFromBundlePath open bundle dir:%{public}s is failure due to %{public}s, errno:%{public}d",
APP_LOGE("open %{public}s failure due to %{public}s errno %{public}d",
currentBundlePath.c_str(), errMsg, errno);
return false;
}
@ -185,7 +185,7 @@ bool BundleFileUtil::GetHapFilesFromBundlePath(const std::string &currentBundleP
const std::string hapFilePath = bundlePath + entry->d_name;
std::string realPath = "";
if (!CheckFilePath(hapFilePath, realPath)) {
APP_LOGE("find invalid hap path %{public}s", hapFilePath.c_str());
APP_LOGE("invalid hap path %{public}s", hapFilePath.c_str());
closedir(dir);
return false;
}
@ -193,7 +193,7 @@ bool BundleFileUtil::GetHapFilesFromBundlePath(const std::string &currentBundleP
APP_LOGD("find hap path %{public}s", realPath.c_str());
if (hapFileList.size() > MAX_HAP_NUMBER) {
APP_LOGE("reach the max hap number %{public}hhu, stop to add more.", MAX_HAP_NUMBER);
APP_LOGE("max hap number %{public}hhu, stop add.", MAX_HAP_NUMBER);
closedir(dir);
return false;
}
@ -223,7 +223,7 @@ bool BundleFileUtil::IsExistFile(const std::string &filePath)
struct stat result = {};
if (stat(filePath.c_str(), &result) != 0) {
APP_LOGE("fail to stat errno:%{public}d", errno);
APP_LOGE("fail stat errno:%{public}d", errno);
return false;
}
@ -238,7 +238,7 @@ bool BundleFileUtil::IsExistDir(const std::string &dirPath)
struct stat result = {};
if (stat(dirPath.c_str(), &result) != 0) {
APP_LOGE("fail to stat errno:%{public}d", errno);
APP_LOGE("fail stat errno %{public}d", errno);
return false;
}

View File

@ -301,6 +301,8 @@ struct ApplicationInfo : public Parcelable {
MultiAppModeData multiAppMode;
int32_t maxChildProcess = 0;
std::string installSource;
bool ReadFromParcel(Parcel &parcel);
bool ReadMetaDataFromParcel(Parcel &parcel);
virtual bool Marshalling(Parcel &parcel) const override;

View File

@ -100,7 +100,8 @@ enum class ExtensionAbilityType {
AUTO_FILL_PASSWORD = 501,
VPN = 502,
AUTO_FILL_SMART = 503,
SYSPICKER_PHOTOEDITOR = 504
SYSPICKER_PHOTOEDITOR = 504,
SYS_VISUAL = 505
};
enum class CompileMode {

View File

@ -92,7 +92,8 @@ struct RouterItem : public Parcelable {
std::string name;
std::string pageSourceFile;
std::string buildFunction;
std::string data;
std::map<std::string, std::string> data;
std::string customData;
std::string ohmurl;
std::string bundleName;
std::string moduleName;

View File

@ -56,7 +56,7 @@ void CheckArrayType(
case ArrayType::STRING:
for (const auto &array : arrays) {
if (!array.is_string()) {
APP_LOGE("array %{public}s is not string type", key.c_str());
APP_LOGE("%{public}s not string", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
}
}
@ -67,7 +67,7 @@ void CheckArrayType(
case ArrayType::OBJECT:
for (const auto &array : arrays) {
if (!array.is_object()) {
APP_LOGE("array %{public}s is not object type", key.c_str());
APP_LOGE("%{public}s not object", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
break;
}
@ -79,7 +79,7 @@ void CheckArrayType(
case ArrayType::NUMBER:
for (const auto &array : arrays) {
if (!array.is_number()) {
APP_LOGE("array %{public}s is not number type", key.c_str());
APP_LOGE("%{public}s not number", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
}
}
@ -88,10 +88,10 @@ void CheckArrayType(
}
break;
case ArrayType::NOT_ARRAY:
APP_LOGE("array %{public}s is not string type", key.c_str());
APP_LOGE("%{public}s not string", key.c_str());
break;
default:
APP_LOGE("array %{public}s type error", key.c_str());
APP_LOGE("%{public}s error", key.c_str());
break;
}
}
@ -108,7 +108,7 @@ void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail:
switch (jsonType) {
case JsonType::BOOLEAN:
if (!jsonObject.at(key).is_boolean()) {
APP_LOGE("type is error %{public}s is not boolean", key.c_str());
APP_LOGE("type error %{public}s not boolean", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
break;
}
@ -116,7 +116,7 @@ void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail:
break;
case JsonType::NUMBER:
if (!jsonObject.at(key).is_number()) {
APP_LOGE("type is error %{public}s is not number", key.c_str());
APP_LOGE("type error %{public}s not number", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
break;
}
@ -124,7 +124,7 @@ void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail:
break;
case JsonType::OBJECT:
if (!jsonObject.at(key).is_object()) {
APP_LOGE("type is error %{public}s is not object", key.c_str());
APP_LOGE("type error %{public}s not object", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
break;
}
@ -132,7 +132,7 @@ void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail:
break;
case JsonType::ARRAY:
if (!jsonObject.at(key).is_array()) {
APP_LOGE("type is error %{public}s is not array", key.c_str());
APP_LOGE("type error %{public}s not array", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
break;
}
@ -140,7 +140,7 @@ void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail:
break;
case JsonType::STRING:
if (!jsonObject.at(key).is_string()) {
APP_LOGE("type is error %{public}s is not string", key.c_str());
APP_LOGE("type error %{public}s not string", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
break;
}
@ -150,16 +150,16 @@ void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail:
}
break;
case JsonType::NULLABLE:
APP_LOGE("type is error %{public}s is nullable", key.c_str());
APP_LOGE("type error %{public}s nullable", key.c_str());
break;
default:
APP_LOGE("type is error %{public}s is not jsonType", key.c_str());
APP_LOGE("type error %{public}s not jsonType", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
}
return;
}
if (isNecessary) {
APP_LOGE("profile prop %{public}s is mission", key.c_str());
APP_LOGE("profile prop %{public}s mission", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_MISSING_PROP;
}
}
@ -175,13 +175,13 @@ template<typename T>
bool ParseInfoFromJsonStr(const char *data, T &t)
{
if (data == nullptr) {
APP_LOGE("%{public}s failed due to data is nullptr", __func__);
APP_LOGE("%{public}s failed nullptr", __func__);
return false;
}
nlohmann::json jsonObject = nlohmann::json::parse(data, nullptr, false);
if (jsonObject.is_discarded()) {
APP_LOGE("%{public}s failed due to data is discarded", __func__);
APP_LOGE("%{public}s failed discarded", __func__);
return false;
}

View File

@ -28,10 +28,10 @@ public:
~MimeTypeMgr() = default;
static bool GetMimeTypeByUri(const std::string &uri, std::vector<std::string> &mimeTypes);
static bool GetMimeTypeByUri(const std::string &uri, std::string &mimeType);
static bool GetUriSuffix(const std::string &uri, std::string &suffix);
static bool GetUtdByUri(const std::string &uri, std::string &utd);
private:
static std::multimap<std::string, std::string> mimeTypeMap_;
static bool GetUriSuffix(const std::string &uri, std::string &suffix);
};
}
}

View File

@ -496,7 +496,7 @@ void AbilityInfo::Dump(std::string prefix, int fd)
}
int flags = fcntl(fd, F_GETFL);
if (flags < 0) {
APP_LOGE("dump Abilityinfo fcntl error, errno : %{public}d", errno);
APP_LOGE("dump Abilityinfo fcntl error : %{public}d", errno);
return;
}
uint uflags = static_cast<uint>(flags);
@ -508,7 +508,7 @@ void AbilityInfo::Dump(std::string prefix, int fd)
result.append(jsonObject.dump(Constants::DUMP_INDENT));
int ret = TEMP_FAILURE_RETRY(write(fd, result.c_str(), result.size()));
if (ret < 0) {
APP_LOGE("dump Abilityinfo write error, errno : %{public}d", errno);
APP_LOGE("dump Abilityinfo write error : %{public}d", errno);
}
}
return;
@ -704,7 +704,7 @@ void from_json(const nlohmann::json &jsonObject, Metadata &metadata)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read Ability Metadata from database error, error code : %{public}d", parseResult);
APP_LOGE("read database error : %{public}d", parseResult);
}
}
@ -1314,7 +1314,7 @@ void from_json(const nlohmann::json &jsonObject, AbilityInfo &abilityInfo)
parseResult,
ArrayType::OBJECT);
if (parseResult != ERR_OK) {
APP_LOGE("AbilityInfo from_json error, error code : %{public}d", parseResult);
APP_LOGE("AbilityInfo from_json error : %{public}d", parseResult);
}
}

View File

@ -131,6 +131,7 @@ const std::string APP_ENVIRONMENTS_NAME = "name";
const std::string APP_ENVIRONMENTS_VALUE = "value";
const std::string APPLICATION_APP_INDEX = "appIndex";
const std::string APPLICATION_MAX_CHILD_PROCESS = "maxChildProcess";
const std::string APPLICATION_INSTALL_SOURCE = "installSource";
}
bool MultiAppModeData::ReadFromParcel(Parcel &parcel)
@ -350,7 +351,7 @@ void from_json(const nlohmann::json &jsonObject, ApplicationEnvironment &applica
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read ApplicationEnvironment from database error, error code : %{public}d", parseResult);
APP_LOGE("read database error : %{public}d", parseResult);
}
}
@ -578,6 +579,7 @@ bool ApplicationInfo::ReadFromParcel(Parcel &parcel)
appIndex = parcel.ReadInt32();
maxChildProcess = parcel.ReadInt32();
installSource = Str16ToStr8(parcel.ReadString16());
return true;
}
@ -747,6 +749,7 @@ bool ApplicationInfo::Marshalling(Parcel &parcel) const
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &multiAppMode);
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, appIndex);
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, maxChildProcess);
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(installSource));
return true;
}
@ -759,7 +762,7 @@ void ApplicationInfo::Dump(std::string prefix, int fd)
}
int flags = fcntl(fd, F_GETFL);
if (flags < 0) {
APP_LOGE("dump ApplicationInfo fcntl error, errno : %{public}d", errno);
APP_LOGE("dump fcntl error : %{public}d", errno);
return;
}
uint uflags = static_cast<uint>(flags);
@ -771,7 +774,7 @@ void ApplicationInfo::Dump(std::string prefix, int fd)
result.append(jsonObject.dump(Constants::DUMP_INDENT));
int ret = TEMP_FAILURE_RETRY(write(fd, result.c_str(), result.size()));
if (ret < 0) {
APP_LOGE("dump ApplicationInfo write error, errno : %{public}d", errno);
APP_LOGE("dump write error : %{public}d", errno);
}
}
return;
@ -845,7 +848,7 @@ void from_json(const nlohmann::json &jsonObject, Resource &resource)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read Resource from database error, error code : %{public}d", parseResult);
APP_LOGE("read Resource error : %{public}d", parseResult);
}
}
@ -866,7 +869,7 @@ void from_json(const nlohmann::json &jsonObject, MultiAppModeData &multiAppMode)
GetValueIfFindKey<int32_t>(jsonObject, jsonObjectEnd, APPLICATION_MULTI_APP_MODE_MAX_ADDITIONAL_NUMBER,
multiAppMode.maxCount, JsonType::NUMBER, false, parseResult, ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("from_json error, error code : %{public}d", parseResult);
APP_LOGE("from_json error : %{public}d", parseResult);
}
}
@ -899,7 +902,7 @@ void from_json(const nlohmann::json &jsonObject, HnpPackage &hnpPackage)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read Resource from database error, error code : %{public}d", parseResult);
APP_LOGE("read Resource error %{public}d", parseResult);
}
}
@ -995,7 +998,8 @@ void to_json(nlohmann::json &jsonObject, const ApplicationInfo &applicationInfo)
{APPLICATION_APP_ENVIRONMENTS, applicationInfo.appEnvironments},
{APPLICATION_MULTI_APP_MODE, applicationInfo.multiAppMode},
{APPLICATION_APP_INDEX, applicationInfo.appIndex},
{APPLICATION_MAX_CHILD_PROCESS, applicationInfo.maxChildProcess}
{APPLICATION_MAX_CHILD_PROCESS, applicationInfo.maxChildProcess},
{APPLICATION_INSTALL_SOURCE, applicationInfo.installSource}
};
}
@ -1187,8 +1191,10 @@ void from_json(const nlohmann::json &jsonObject, ApplicationInfo &applicationInf
applicationInfo.appIndex, JsonType::NUMBER, false, parseResult, ArrayType::NOT_ARRAY);
GetValueIfFindKey<int32_t>(jsonObject, jsonObjectEnd, APPLICATION_MAX_CHILD_PROCESS,
applicationInfo.maxChildProcess, JsonType::NUMBER, false, parseResult, ArrayType::NOT_ARRAY);
GetValueIfFindKey<std::string>(jsonObject, jsonObjectEnd, APPLICATION_INSTALL_SOURCE,
applicationInfo.installSource, JsonType::STRING, false, parseResult, ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("from_json error, error code : %{public}d", parseResult);
APP_LOGE("from_json error : %{public}d", parseResult);
}
}

View File

@ -553,7 +553,7 @@ void from_json(const nlohmann::json &jsonObject, RequestPermissionUsedScene &use
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read RequestPermissionUsedScene from database error, error code : %{public}d", parseResult);
APP_LOGE("read RequestPermissionUsedScene error : %{public}d", parseResult);
}
}
@ -602,7 +602,7 @@ void from_json(const nlohmann::json &jsonObject, RequestPermission &requestPermi
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read RequestPermission from database error, error code : %{public}d", parseResult);
APP_LOGE("read RequestPermission error : %{public}d", parseResult);
}
}
@ -635,7 +635,7 @@ void from_json(const nlohmann::json &jsonObject, SignatureInfo &signatureInfo)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read SignatureInfo from database error, error code : %{public}d", parseResult);
APP_LOGE("read SignatureInfo error : %{public}d", parseResult);
}
}
@ -1070,7 +1070,7 @@ void from_json(const nlohmann::json &jsonObject, BundleInfo &bundleInfo)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("BundleInfo from_json error, error code : %{public}d", parseResult);
APP_LOGE("BundleInfo from_json error %{public}d", parseResult);
}
}
} // namespace AppExecFwk

View File

@ -123,7 +123,7 @@ void from_json(const nlohmann::json &jsonObject, Version &version)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read version from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read version error %{public}d", parseResult);
}
}
@ -156,7 +156,7 @@ void from_json(const nlohmann::json &jsonObject, PackageApp &app)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read package app from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read package app error %{public}d", parseResult);
}
}
@ -189,7 +189,7 @@ void from_json(const nlohmann::json &jsonObject, ExtensionAbilities &extensionAb
parseResult,
ArrayType::OBJECT);
if (parseResult != ERR_OK) {
APP_LOGE("read module abilityinfo from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read abilityinfo error %{public}d", parseResult);
}
}
@ -240,7 +240,7 @@ void from_json(const nlohmann::json &jsonObject, ModuleAbilityInfo &abilityinfo)
parseResult,
ArrayType::OBJECT);
if (parseResult != ERR_OK) {
APP_LOGE("read module abilityinfo from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read abilityinfo error %{public}d", parseResult);
}
}
@ -276,7 +276,7 @@ void from_json(const nlohmann::json &jsonObject, AbilityFormInfo &abilityFormInf
GetValueIfFindKey<std::string>(jsonObject, jsonObjectEnd, PACK_SUMMARY_MODULE_ABILITY_FORMS_DEFAULT_DIMENSION,
abilityFormInfo.defaultDimension, JsonType::STRING, false, parseResult, ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read BundleConfigInfo from database error, error code : %{public}d", parseResult);
APP_LOGE("read BundleConfigInfo error %{public}d", parseResult);
}
}
@ -327,7 +327,7 @@ void from_json(const nlohmann::json &jsonObject, ModuleDistro &distro)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read module abilityinfo from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read abilityinfo error %{public}d", parseResult);
}
}
@ -369,7 +369,7 @@ void from_json(const nlohmann::json &jsonObject, ApiVersion &apiVersion)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read module abilityinfo from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read abilityinfo error %{public}d", parseResult);
}
}
@ -438,7 +438,7 @@ void from_json(const nlohmann::json &jsonObject, PackageModule &packageModule)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read module abilityinfo from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read abilityinfo error %{public}d", parseResult);
}
}
@ -471,7 +471,7 @@ void from_json(const nlohmann::json &jsonObject, Summary &summary)
parseResult,
ArrayType::OBJECT);
if (parseResult != ERR_OK) {
APP_LOGE("read module abilityinfo from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read abilityinfo error %{public}d", parseResult);
}
}
@ -522,7 +522,7 @@ void from_json(const nlohmann::json &jsonObject, Packages &packages)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read module abilityinfo from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read abilityinfo error %{public}d", parseResult);
}
}
@ -555,7 +555,7 @@ void from_json(const nlohmann::json &jsonObject, BundlePackInfo &bundlePackInfo)
parseResult,
ArrayType::OBJECT);
if (parseResult != ERR_OK) {
APP_LOGE("read module abilityinfo from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read abilityinfo error %{public}d", parseResult);
}
}
@ -573,7 +573,7 @@ bool BundlePackInfo::ReadFromParcel(Parcel &parcel)
}
const char *data = reinterpret_cast<const char *>(messageParcel->ReadRawData(length));
if (!data) {
APP_LOGE("Fail to read raw data, length = %{public}d", length);
APP_LOGE("Fail read raw length = %{public}d", length);
return false;
}
nlohmann::json jsonObject = nlohmann::json::parse(data, nullptr, false);

View File

@ -76,7 +76,7 @@ bool BundleSystemState::FromString(const std::string &systemState)
{
nlohmann::json jsonObject = nlohmann::json::parse(systemState, nullptr, false);
if (jsonObject.is_discarded()) {
APP_LOGE("failed to parse SystemState: %{public}s.", systemState.c_str());
APP_LOGE("failed parse SystemState: %{public}s.", systemState.c_str());
return false;
}
const auto &jsonObjectEnd = jsonObject.end();
@ -99,7 +99,7 @@ bool BundleSystemState::FromString(const std::string &systemState)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read systemState from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read systemState jsonObject error : %{public}d", parseResult);
return false;
}
return true;

View File

@ -90,7 +90,7 @@ void BundleUserInfo::Dump(const std::string &prefix, int fd)
}
int flags = fcntl(fd, F_GETFL);
if (flags < 0) {
APP_LOGE("dump BundleUserInfo fcntl error %{public}s", strerror(errno));
APP_LOGE("BundleUserInfo fcntl error %{public}s", strerror(errno));
return;
}
uint uflags = static_cast<uint>(flags);
@ -102,7 +102,7 @@ void BundleUserInfo::Dump(const std::string &prefix, int fd)
result.append(jsonObject.dump(Constants::DUMP_INDENT));
int ret = TEMP_FAILURE_RETRY(write(fd, result.c_str(), result.size()));
if (ret < 0) {
APP_LOGE("dump BundleUserInfo write error %{public}s", strerror(errno));
APP_LOGE("BundleUserInfo write error %{public}s", strerror(errno));
}
}
}
@ -165,7 +165,7 @@ void from_json(const nlohmann::json& jsonObject, BundleUserInfo& bundleUserInfo)
parseResult,
ArrayType::STRING);
if (parseResult != ERR_OK) {
APP_LOGE("read module bundleUserInfo from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("module bundleUserInfo jsonObject error : %{public}d", parseResult);
}
}
} // namespace AppExecFwk

View File

@ -172,7 +172,7 @@ void from_json(const nlohmann::json &jsonObject, CommonEventInfo &commonEvent)
parseResult,
ArrayType::STRING);
if (parseResult != ERR_OK) {
APP_LOGE("read module commonEvent from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("module commonEvent jsonObject error : %{public}d", parseResult);
}
}
} // namespace AppExecFwk

View File

@ -120,7 +120,7 @@ void from_json(const nlohmann::json &jsonObject, DataGroupInfo &dataGroupInfo)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read dataGroupInfo error, error code : %{public}d", parseResult);
APP_LOGE("read dataGroupInfo error : %{public}d", parseResult);
}
}

View File

@ -140,7 +140,7 @@ void from_json(const nlohmann::json &jsonObject, ElementName &elementName)
ArrayType::NOT_ARRAY);
elementName.SetDeviceID(deviceId);
if (parseResult != ERR_OK) {
APP_LOGE("read elementName error, error code : %{public}d", parseResult);
APP_LOGE("read elementName error : %{public}d", parseResult);
}
}
@ -221,7 +221,7 @@ void from_json(const nlohmann::json &jsonObject, DisposedRule &disposedRule)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read disposedRule error, error code : %{public}d", parseResult);
APP_LOGE("read disposedRule error : %{public}d", parseResult);
}
}
@ -237,7 +237,7 @@ bool DisposedRule::FromString(const std::string &ruleString, DisposedRule &rule)
APP_LOGD("FromString %{public}s", ruleString.c_str());
nlohmann::json jsonObject = nlohmann::json::parse(ruleString, nullptr, false);
if (jsonObject.is_discarded()) {
APP_LOGE("failed to parse ruleString: %{public}s.", ruleString.c_str());
APP_LOGE("failed parse ruleString: %{public}s.", ruleString.c_str());
return false;
}
from_json(jsonObject, rule);

View File

@ -144,7 +144,7 @@ void from_json(const nlohmann::json& jsonObject, DistributedAbilityInfo& distrib
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read module distributedAbilityInfo from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read distributedAbilityInfo jsonObject error : %{public}d", parseResult);
}
}
} // namespace AppExecFwk

View File

@ -120,7 +120,7 @@ bool DistributedBundleInfo::FromJsonString(const std::string &jsonString)
{
nlohmann::json jsonObject = nlohmann::json::parse(jsonString, nullptr, false);
if (jsonObject.is_discarded()) {
APP_LOGE("failed to parse DistributedBundleInfo: %{public}s.", jsonString.c_str());
APP_LOGE("failed parse DistributedBundleInfo: %{public}s.", jsonString.c_str());
return false;
}

View File

@ -110,7 +110,7 @@ void from_json(const nlohmann::json &jsonObject, SummaryAbilityInfo &summaryAbil
parseResult,
ArrayType::STRING);
if (parseResult != ERR_OK) {
APP_LOGE("read module result from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read result jsonObject error : %{public}d", parseResult);
}
}
@ -170,7 +170,7 @@ void from_json(const nlohmann::json &jsonObject, RpcIdResult &rpcIdResult)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read module result from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read result jsonObject error : %{public}d", parseResult);
}
}

View File

@ -77,7 +77,7 @@ void DistributedModuleInfo::Dump(const std::string &prefix, int fd)
}
int flags = fcntl(fd, F_GETFL);
if (flags < 0) {
APP_LOGE("dump DistributedModuleInfo fcntl error %{public}d", errno);
APP_LOGE("fcntl error %{public}d", errno);
return;
}
uint uflags = static_cast<uint>(flags);
@ -89,7 +89,7 @@ void DistributedModuleInfo::Dump(const std::string &prefix, int fd)
result.append(jsonObject.dump(Constants::DUMP_INDENT));
int ret = TEMP_FAILURE_RETRY(write(fd, result.c_str(), result.size()));
if (ret < 0) {
APP_LOGE("dump DistributedModuleInfo write error %{public}d", errno);
APP_LOGE("write error %{public}d", errno);
}
}
}
@ -123,7 +123,7 @@ void from_json(const nlohmann::json& jsonObject, DistributedModuleInfo& distribu
parseResult,
ArrayType::OBJECT);
if (parseResult != ERR_OK) {
APP_LOGE("read module distributedModuleInfo from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read distributedModuleInfo jsonObject error : %{public}d", parseResult);
}
}
} // namespace AppExecFwk

View File

@ -117,7 +117,8 @@ const std::unordered_map<std::string, ExtensionAbilityType> EXTENSION_TYPE_MAP =
{ "autoFill/smart", ExtensionAbilityType::AUTO_FILL_SMART },
{ "liveViewLockScreen", ExtensionAbilityType::LIVEVIEW_LOCKSCREEN },
{ "photoEditor", ExtensionAbilityType::PHOTO_EDITOR },
{ "sysPicker/photoEditor", ExtensionAbilityType::SYSPICKER_PHOTOEDITOR }
{ "sysPicker/photoEditor", ExtensionAbilityType::SYSPICKER_PHOTOEDITOR },
{ "sys/visualExtension", ExtensionAbilityType::SYS_VISUAL }
};
// the new extension type does not need to be added here
@ -632,7 +633,7 @@ void from_json(const nlohmann::json &jsonObject, ExtensionAbilityInfo &extension
parseResult,
ArrayType::OBJECT);
if (parseResult != ERR_OK) {
APP_LOGE("ExtensionAbilityInfo from_json error, error code : %{public}d", parseResult);
APP_LOGE("ExtensionAbilityInfo from_json error : %{public}d", parseResult);
}
}
@ -667,7 +668,7 @@ ExtensionProcessMode ConvertToExtensionProcessMode(const std::string &extensionP
void ExtensionAbilityInfo::UpdateNeedCreateSandbox()
{
needCreateSandbox = (NOT_NEED_CREATE_SANBOX_MODE.find(extensionTypeName) == NOT_NEED_CREATE_SANBOX_MODE.end());
needCreateSandbox = false;
}
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -362,7 +362,7 @@ bool GetMetadata(const ExtensionFormProfileInfo &form, ExtensionFormInfo &info)
std::end(dimensionMap),
[&dimension](const auto &item) { return item.first == dimension; });
if (dimensionRes == dimensionMap.end()) {
APP_LOGW("dimension is invalid, form name is %{public}s", form.name.c_str());
APP_LOGW("dimension invalid form %{public}s", form.name.c_str());
continue;
}
supportDimensionSet.emplace(dimensionRes->second);
@ -372,11 +372,11 @@ bool GetMetadata(const ExtensionFormProfileInfo &form, ExtensionFormInfo &info)
std::end(dimensionMap),
[&form](const auto &item) { return item.first == form.defaultDimension; });
if (dimensionRes == dimensionMap.end()) {
APP_LOGW("defaultDimension is invalid, form name is %{public}s", form.name.c_str());
APP_LOGW("defaultDimension invalid form %{public}s", form.name.c_str());
return false;
}
if (supportDimensionSet.find(dimensionRes->second) == supportDimensionSet.end()) {
APP_LOGW("defaultDimension is not in supportDimensions, form name is %{public}s", form.name.c_str());
APP_LOGW("defaultDimension not in supportDimensions form %{public}s", form.name.c_str());
return false;
}
@ -394,7 +394,7 @@ bool GetSupportShapes(const ExtensionFormProfileInfo &form, ExtensionFormInfo &i
auto formShape = std::find_if(std::begin(shapeMap), std::end(shapeMap),
[&shape](const auto &item) { return item.first == shape; });
if (formShape == shapeMap.end()) {
APP_LOGW("shape is invalid, form name is %{public}s", form.name.c_str());
APP_LOGW("shape invalid form %{public}s", form.name.c_str());
continue;
}
supportShapeSet.emplace(formShape->second);
@ -499,7 +499,7 @@ ErrCode ExtensionFormProfile::TransformTo(
profileInfo = jsonObject.get<ExtensionFormProfileInfoStruct>();
privacyLevel = profileInfo.privacyLevel;
if (g_parseResult != ERR_OK) {
APP_LOGE("g_parseResult is %{public}d", g_parseResult);
APP_LOGE("g_parseResult %{public}d", g_parseResult);
int32_t ret = g_parseResult;
// need recover parse result to ERR_OK
g_parseResult = ERR_OK;

View File

@ -390,7 +390,7 @@ void from_json(const nlohmann::json &jsonObject, FormCustomizeData &customizeDat
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read module customizeDatas from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read customizeDatas jsonObject error : %{public}d", parseResult);
}
}
@ -415,7 +415,7 @@ void from_json(const nlohmann::json &jsonObject, FormWindow &formWindow)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read module formWindow from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read formWindow jsonObject error : %{public}d", parseResult);
}
}
@ -728,7 +728,7 @@ void from_json(const nlohmann::json &jsonObject, FormInfo &formInfo)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read module formInfo from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read formInfo jsonObject error : %{public}d", parseResult);
}
}
} // namespace AppExecFwk

View File

@ -87,6 +87,7 @@ const std::string ROUTER_ITEM_KEY_NAME = "name";
const std::string ROUTER_ITEM_KEY_PAGE_SOURCE_FILE = "pageSourceFile";
const std::string ROUTER_ITEM_KEY_BUILD_FUNCTION = "buildFunction";
const std::string ROUTER_ITEM_KEY_DATA = "data";
const std::string ROUTER_ITEM_KEY_CUSTOM_DATA = "customData";
const std::string ROUTER_ITEM_KEY_OHMURL = "ohmurl";
const std::string ROUTER_ITEM_KEY_BUNDLE_NAME = "bundleName";
const std::string ROUTER_ITEM_KEY_MODULE_NAME = "moduleName";
@ -141,7 +142,7 @@ void from_json(const nlohmann::json &jsonObject, PreloadItem &preloadItem)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read PreloadItem from database error, error code : %{public}d", parseResult);
APP_LOGE("read PreloadItem database error : %{public}d", parseResult);
}
}
@ -210,7 +211,7 @@ void from_json(const nlohmann::json &jsonObject, Dependency &dependency)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read Dependency error, error code : %{public}d", parseResult);
APP_LOGE("read Dependency error : %{public}d", parseResult);
}
}
@ -295,7 +296,7 @@ void from_json(const nlohmann::json &jsonObject, ProxyData &proxyData)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read ProxyData from database error, error code : %{public}d", parseResult);
APP_LOGE("read ProxyData error : %{public}d", parseResult);
}
}
@ -305,7 +306,15 @@ bool RouterItem::ReadFromParcel(Parcel &parcel)
pageSourceFile = Str16ToStr8(parcel.ReadString16());
buildFunction = Str16ToStr8(parcel.ReadString16());
data = Str16ToStr8(parcel.ReadString16());
int32_t dataSize;
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, dataSize);
CONTAINER_SECURITY_VERIFY(parcel, dataSize, &data);
for (int32_t i = 0; i < dataSize; ++i) {
std::string key = Str16ToStr8(parcel.ReadString16());
std::string value = Str16ToStr8(parcel.ReadString16());
data.emplace(key, value);
}
customData = Str16ToStr8(parcel.ReadString16());
ohmurl = Str16ToStr8(parcel.ReadString16());
bundleName = Str16ToStr8(parcel.ReadString16());
moduleName = Str16ToStr8(parcel.ReadString16());
@ -328,7 +337,12 @@ bool RouterItem::Marshalling(Parcel &parcel) const
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(name));
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(pageSourceFile));
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(buildFunction));
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(data));
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(data.size()));
for (const auto &dataItem : data) {
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(dataItem.first));
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(dataItem.second));
}
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(customData));
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(ohmurl));
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName));
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleName));
@ -342,6 +356,7 @@ void to_json(nlohmann::json &jsonObject, const RouterItem &routerItem)
{ROUTER_ITEM_KEY_PAGE_SOURCE_FILE, routerItem.pageSourceFile},
{ROUTER_ITEM_KEY_BUILD_FUNCTION, routerItem.buildFunction},
{ROUTER_ITEM_KEY_DATA, routerItem.data},
{ROUTER_ITEM_KEY_CUSTOM_DATA, routerItem.customData},
{ROUTER_ITEM_KEY_OHMURL, routerItem.ohmurl},
{ROUTER_ITEM_KEY_BUNDLE_NAME, routerItem.bundleName},
{ROUTER_ITEM_KEY_MODULE_NAME, routerItem.moduleName}
@ -400,8 +415,16 @@ void from_json(const nlohmann::json &jsonObject, RouterItem &routerItem)
false,
parseResult,
ArrayType::NOT_ARRAY);
GetValueIfFindKey<std::map<std::string, std::string>>(jsonObject,
jsonObjectEnd,
ROUTER_ITEM_KEY_DATA,
routerItem.data,
JsonType::OBJECT,
false,
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read module RouterItem from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read RouterItem jsonObject error : %{public}d", parseResult);
}
}
@ -459,7 +482,7 @@ void from_json(const nlohmann::json &jsonObject, AppEnvironment &appEnvironment)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read AppEnvironment from database error, error code : %{public}d", parseResult);
APP_LOGE("read AppEnvironment error : %{public}d", parseResult);
}
}
@ -1303,7 +1326,7 @@ void from_json(const nlohmann::json &jsonObject, HapModuleInfo &hapModuleInfo)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGW("HapModuleInfo from_json error, error code : %{public}d", parseResult);
APP_LOGW("HapModuleInfo from_json error : %{public}d", parseResult);
}
}
} // namespace AppExecFwk

View File

@ -26,375 +26,25 @@
namespace OHOS {
namespace AppExecFwk {
std::multimap<std::string, std::string> MimeTypeMgr::mimeTypeMap_ = {
{"323", "text/h323"},
{"3g2", "video/3gpp2"},
{"3gp", "video/3gpp"},
{"3gpp", "audio/3gpp"},
{"3gpp", "video/3gpp"},
{"3gpp2", "video/3gpp2"},
{"7z", "application/x-7z-compressed"},
{"VOB", "video/mpeg"},
{"aac", "audio/aac"},
{"aac", "audio/aac-adts"},
{"abw", "application/x-abiword"},
{"aif", "audio/x-aiff"},
{"aifc", "audio/x-aiff"},
{"aiff", "audio/x-aiff"},
{"amr", "audio/amr"},
{"asc", "text/plain"},
{"asf", "video/x-ms-asf"},
{"asx", "video/x-ms-asf"},
{"avi", "video/avi"},
{"awb", "audio/amr-wb"},
{"bcpio", "application/x-bcpio"},
{"bib", "text/x-bibtex"},
{"bmp", "image/bmp"},
{"bmp", "image/x-ms-bmp"},
{"boo", "text/x-boo"},
{"book", "application/x-maker"},
{"c", "text/x-csrc"},
{"c++", "text/x-c++src"},
{"cc", "text/x-c++src"},
{"cdf", "application/x-cdf"},
{"cdr", "image/x-coreldraw"},
{"cdt", "image/x-coreldrawtemplate"},
{"cdy", "application/vnd.cinderella"},
{"cer", "application/pkix-cert"},
{"chrt", "application/x-kchart"},
{"cls", "text/x-tex"},
{"cod", "application/vnd.rim.cod"},
{"cpio", "application/x-cpio"},
{"cpp", "text/x-c++src"},
{"cpt", "image/x-corelphotopaint"},
{"crl", "application/x-pkcs7-crl"},
{"crt", "application/x-x509-ca-cert"},
{"crt", "application/x-x509-server-cert"},
{"crt", "application/x-x509-user-cert"},
{"csh", "text/x-csh"},
{"css", "text/css"},
{"csv", "text/comma-separated-values"},
{"cur", "image/ico"},
{"cxx", "text/x-c++src"},
{"d", "text/x-dsrc"},
{"dcr", "application/x-director"},
{"deb", "application/x-debian-package"},
{"dif", "video/dv"},
{"diff", "text/plain"},
{"dir", "application/x-director"},
{"djv", "image/vnd.djvu"},
{"djvu", "image/vnd.djvu"},
{"dl", "video/dl"},
{"dmg", "application/x-apple-diskimage"},
{"dms", "application/x-dms"},
{"doc", "application/msword"},
{"docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"},
{"dot", "application/msword"},
{"dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template"},
{"dv", "video/dv"},
{"dvi", "application/x-dvi"},
{"dxr", "application/x-director"},
{"etx", "text/x-setext"},
{"ez", "application/andrew-inset"},
{"fb", "application/x-maker"},
{"fbdoc", "application/x-maker"},
{"fig", "application/x-xfig"},
{"flac", "application/x-flac"},
{"flac", "audio/flac"},
{"fli", "video/fli"},
{"frame", "application/x-maker"},
{"frm", "application/x-maker"},
{"gcd", "text/x-pcs-gcd"},
{"gcf", "application/x-graphing-calculator"},
{"gif", "image/gif"},
{"gnumeric", "application/x-gnumeric"},
{"gsf", "application/x-font"},
{"gsm", "audio/x-gsm"},
{"gtar", "application/x-gtar"},
{"h", "text/x-chdr"},
{"h++", "text/x-c++hdr"},
{"hdf", "application/x-hdf"},
{"heic", "image/heif"},
{"heif", "image/heif"},
{"hh", "text/x-c++hdr"},
{"hpp", "text/x-c++hdr"},
{"hqx", "application/mac-binhex40"},
{"hs", "text/x-haskell"},
{"hta", "application/hta"},
{"htc", "text/x-component"},
{"htm", "text/html"},
{"html", "text/html"},
{"hxx", "text/x-c++hdr"},
{"ica", "application/x-ica"},
{"ice", "x-conference/x-cooltalk"},
{"ico", "image/ico"},
{"ico", "image/x-icon"},
{"ics", "text/calendar"},
{"icz", "text/calendar"},
{"ief", "image/ief"},
{"iges", "model/iges"},
{"igs", "model/iges"},
{"iii", "application/x-iphone"},
{"imy", "audio/imelody"},
{"ins", "application/x-internet-signup"},
{"iso", "application/x-iso9660-image"},
{"isp", "application/x-internet-signup"},
{"java", "text/x-java"},
{"jmz", "application/x-jmol"},
{"jng", "image/x-jng"},
{"jpe", "image/jpeg"},
{"jpeg", "image/jpeg"},
{"jpg", "image/jpeg"},
{"kar", "audio/midi"},
{"key", "application/pgp-keys"},
{"kil", "application/x-killustrator"},
{"kpr", "application/x-kpresenter"},
{"kpt", "application/x-kpresenter"},
{"ksp", "application/x-kspread"},
{"kwd", "application/x-kword"},
{"kwt", "application/x-kword"},
{"latex", "application/x-latex"},
{"lha", "application/x-lha"},
{"lhs", "text/x-literate-haskell"},
{"lsf", "video/x-la-asf"},
{"lsx", "video/x-la-asf"},
{"ltx", "text/x-tex"},
{"lzh", "application/x-lzh"},
{"lzx", "application/x-lzx"},
{"m3u", "audio/mpegurl"},
{"m3u", "audio/x-mpegurl"},
{"m4a", "audio/mpeg"},
{"m4v", "video/m4v"},
{"maker", "application/x-maker"},
{"man", "application/x-troff-man"},
{"mdb", "application/msaccess"},
{"mesh", "model/mesh"},
{"mid", "audio/midi"},
{"midi", "audio/midi"},
{"mif", "application/x-mif"},
{"mka", "audio/x-matroska"},
{"mkv", "video/x-matroska"},
{"mm", "application/x-freemind"},
{"mmf", "application/vnd.smaf"},
{"mml", "text/mathml"},
{"mng", "video/x-mng"},
{"moc", "text/x-moc"},
{"mov", "video/quicktime"},
{"movie", "video/x-sgi-movie"},
{"mp2", "audio/mpeg"},
{"mp3", "audio/mpeg"},
{"mp4", "video/mp4"},
{"mpe", "video/mpeg"},
{"mpeg", "video/mpeg"},
{"mpega", "audio/mpeg"},
{"mpg", "video/mpeg"},
{"mpga", "audio/mpeg"},
{"msh", "model/mesh"},
{"msi", "application/x-msi"},
{"mxmf", "audio/mobile-xmf"},
{"mxu", "video/vnd.mpegurl"},
{"nb", "application/mathematica"},
{"nwc", "application/x-nwc"},
{"o", "application/x-object"},
{"oda", "application/oda"},
{"odb", "application/vnd.oasis.opendocument.database"},
{"odf", "application/vnd.oasis.opendocument.formula"},
{"odg", "application/vnd.oasis.opendocument.graphics"},
{"odi", "application/vnd.oasis.opendocument.image"},
{"ods", "application/vnd.oasis.opendocument.spreadsheet"},
{"odt", "application/vnd.oasis.opendocument.text"},
{"oga", "application/ogg"},
{"ogg", "application/ogg"},
{"ota", "audio/midi"},
{"otg", "application/vnd.oasis.opendocument.graphics-template"},
{"oth", "application/vnd.oasis.opendocument.text-web"},
{"ots", "application/vnd.oasis.opendocument.spreadsheet-template"},
{"ott", "application/vnd.oasis.opendocument.text-template"},
{"oza", "application/x-oz-application"},
{"p", "text/x-pascal"},
{"p12", "application/x-pkcs12"},
{"p7r", "application/x-pkcs7-certreqresp"},
{"pac", "application/x-ns-proxy-autoconfig"},
{"pas", "text/x-pascal"},
{"pat", "image/x-coreldrawpattern"},
{"pbm", "image/x-portable-bitmap"},
{"pcf", "application/x-font"},
{"pcf.z", "application/x-font"},
{"pcx", "image/pcx"},
{"pdf", "application/pdf"},
{"pem", "application/x-pem-file"},
{"pfa", "application/x-font"},
{"pfb", "application/x-font"},
{"pfx", "application/x-pkcs12"},
{"pgm", "image/x-portable-graymap"},
{"pgn", "application/x-chess-pgn"},
{"pgp", "application/pgp-signature"},
{"phps", "text/text"},
{"pls", "audio/x-scpls"},
{"png", "image/png"},
{"pnm", "image/x-portable-anymap"},
{"po", "text/plain"},
{"pot", "application/vnd.ms-powerpoint"},
{"potx", "application/vnd.openxmlformats-officedocument.presentationml.template"},
{"ppm", "image/x-portable-pixmap"},
{"pps", "application/vnd.ms-powerpoint"},
{"ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow"},
{"ppt", "application/vnd.ms-powerpoint"},
{"pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"},
{"prf", "application/pics-rules"},
{"psd", "image/x-photoshop"},
{"qt", "video/quicktime"},
{"qtl", "application/x-quicktimeplayer"},
{"ra", "audio/x-pn-realaudio"},
{"ra", "audio/x-realaudio"},
{"ram", "audio/x-pn-realaudio"},
{"rar", "application/rar"},
{"ras", "image/x-cmu-raster"},
{"rdf", "application/rdf+xml"},
{"rgb", "image/x-rgb"},
{"rm", "application/vnd.rn-realmedia"},
{"roff", "application/x-troff"},
{"rss", "application/rss+xml"},
{"rtf", "text/rtf"},
{"rtttl", "audio/midi"},
{"rtx", "text/richtext"},
{"sd2", "audio/x-sd2"},
{"sda", "application/vnd.stardivision.draw"},
{"sdc", "application/vnd.stardivision.calc"},
{"sdd", "application/vnd.stardivision.impress"},
{"sdp", "application/vnd.stardivision.impress"},
{"sdw", "application/vnd.stardivision.writer"},
{"sgf", "application/x-go-sgf"},
{"sgl", "application/vnd.stardivision.writer-global"},
{"shar", "application/x-shar"},
{"sid", "audio/prs.sid"},
{"silo", "model/mesh"},
{"sisx", "x-epoc/x-sisx-app"},
{"sit", "application/x-stuffit"},
{"skd", "application/x-koan"},
{"skm", "application/x-koan"},
{"skp", "application/x-koan"},
{"skt", "application/x-koan"},
{"smf", "application/vnd.stardivision.math"},
{"snd", "audio/basic"},
{"spl", "application/futuresplash"},
{"spl", "application/x-futuresplash"},
{"src", "application/x-wais-source"},
{"stc", "application/vnd.sun.xml.calc.template"},
{"std", "application/vnd.sun.xml.draw.template"},
{"sti", "application/vnd.sun.xml.impress.template"},
{"stl", "application/vnd.ms-pki.stl"},
{"stw", "application/vnd.sun.xml.writer.template"},
{"sty", "text/x-tex"},
{"sv4cpio", "application/x-sv4cpio"},
{"sv4crc", "application/x-sv4crc"},
{"svg", "image/svg+xml"},
{"svgz", "image/svg+xml"},
{"swf", "application/x-shockwave-flash"},
{"sxc", "application/vnd.sun.xml.calc"},
{"sxd", "application/vnd.sun.xml.draw"},
{"sxg", "application/vnd.sun.xml.writer.global"},
{"sxi", "application/vnd.sun.xml.impress"},
{"sxm", "application/vnd.sun.xml.math"},
{"sxw", "application/vnd.sun.xml.writer"},
{"t", "application/x-troff"},
{"tar", "application/x-tar"},
{"taz", "application/x-gtar"},
{"tcl", "text/x-tcl"},
{"tex", "text/x-tex"},
{"texi", "application/x-texinfo"},
{"texinfo", "application/x-texinfo"},
{"text", "text/plain"},
{"tgz", "application/x-gtar"},
{"tif", "image/tiff"},
{"tiff", "image/tiff"},
{"torrent", "application/x-bittorrent"},
{"ts", "video/mp2ts"},
{"tsp", "application/dsptype"},
{"tsv", "text/tab-separated-values"},
{"txt", "text/plain"},
{"udeb", "application/x-debian-package"},
{"uls", "text/iuls"},
{"ustar", "application/x-ustar"},
{"vcd", "application/x-cdlink"},
{"vcf", "text/x-vcard"},
{"vcs", "text/x-vcalendar"},
{"vor", "application/vnd.stardivision.writer"},
{"vsd", "application/vnd.visio"},
{"wad", "application/x-doom"},
{"wav", "audio/x-wav"},
{"wax", "audio/x-ms-wax"},
{"wbmp", "image/vnd.wap.wbmp"},
{"webarchive", "application/x-webarchive"},
{"webarchivexml", "application/x-webarchive-xml"},
{"webm", "video/webm"},
{"webp", "image/webp"},
{"wm", "video/x-ms-wm"},
{"wma", "audio/x-ms-wma"},
{"wmd", "application/x-ms-wmd"},
{"wmv", "video/x-ms-wmv"},
{"wmx", "video/x-ms-wmx"},
{"wmz", "application/x-ms-wmz"},
{"wrf", "video/x-webex"},
{"wvx", "video/x-ms-wvx"},
{"wz", "application/x-wingz"},
{"xbm", "image/x-xbitmap"},
{"xcf", "application/x-xcf"},
{"xhtml", "application/xhtml+xml"},
{"xls", "application/vnd.ms-excel"},
{"xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},
{"xlt", "application/vnd.ms-excel"},
{"xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"},
{"xmf", "audio/midi"},
{"xml", "text/xml"},
{"xpm", "image/x-xpixmap"},
{"xwd", "image/x-xwindowdump"},
{"zip", "application/zip"},
{"eddx", "application-x-eddx"},
{"caj", "application/caj"},
{"kdh", "application/kdh"},
{"nh", "application/nh"},
{"teb", "application/teb"},
{"epub", "application/epub+zip"},
{"xlam", "application/vnd.ms-excel.addin.macroEnabled.12"},
{"xlsb", "application/vnd.ms-excel.sheet.binary.macroEnabled.12"},
{"xlsm", "application/vnd.ms-excel.sheet.macroEnabled.12"},
{"xltm", "application/vnd.ms-excel.template.macroEnabled.12"},
{"ppam", "application/vnd.ms-powerpoint.addin.macroEnabled.12"},
{"pptm", "application/vnd.ms-powerpoint.presentation.macroEnabled.12"},
{"ppsm", "application/vnd.ms-powerpoint.slideshow.macroEnabled.12"},
{"potm", "application/vnd.ms-powerpoint.template.macroEnabled.12"},
{"docm", "application/vnd.ms-word.document.macroEnabled.12"},
{"dotm", "application/vnd.ms-word.template.macroEnabled.12"},
{"odc", "application/vnd.oasis.opendocument.chart"},
{"odp", "application/vnd.oasis.opendocument.presentation"},
{"odm", "application/vnd.oasis.opendocument.text-master"},
{"odw", "application/vnd.oasis.opendocument.text-web"},
{"otp", "application/vnd.oasis.opendocument.presentation-template"},
{"m3u8", "application/vnd.apple.mpegurl"},
{"sds", "application/vnd.stardivision.chart"},
{"sdm", "application/vnd.stardivision.mail"},
{"pub", "application/x-mspublisher"},
{"wpl", "application/vnd.ms-wpl"},
};
bool MimeTypeMgr::GetMimeTypeByUri(const std::string &uri, std::vector<std::string> &mimeTypes)
{
std::string suffix;
if (!GetUriSuffix(uri, suffix)) {
APP_LOGE("Get suffix failed, uri is %{public}s", uri.c_str());
#ifdef BUNDLE_FRAMEWORK_UDMF_ENABLED
std::string utd;
if (!GetUtdByUri(uri, utd)) {
APP_LOGD("Get utd by uri %{private}s failed", uri.c_str());
return false;
}
auto range = mimeTypeMap_.equal_range(suffix);
for (auto it = range.first; it != range.second; ++it) {
mimeTypes.push_back(it->second);
}
if (mimeTypes.empty()) {
APP_LOGD("Suffix %{public}s has no corresponding type", suffix.c_str());
std::shared_ptr<UDMF::TypeDescriptor> typeDescriptor;
auto ret = UDMF::UtdClient::GetInstance().GetTypeDescriptor(utd, typeDescriptor);
if (ret != ERR_OK || typeDescriptor == nullptr) {
APP_LOGE("GetTypeDescriptor failed");
return false;
}
return true;
mimeTypes = typeDescriptor->GetMimeTypes();
return !mimeTypes.empty();
#else
return false;
#endif
}
bool MimeTypeMgr::GetMimeTypeByUri(const std::string &uri, std::string &mimeType)
@ -412,13 +62,32 @@ bool MimeTypeMgr::GetUriSuffix(const std::string &uri, std::string &suffix)
{
auto suffixIndex = uri.rfind('.');
if (suffixIndex == std::string::npos) {
APP_LOGE("Get suffix failed, uri is %{public}s", uri.c_str());
APP_LOGD("Get suffix failed %{private}s", uri.c_str());
return false;
}
suffix = uri.substr(suffixIndex + 1);
suffix = uri.substr(suffixIndex);
std::transform(suffix.begin(), suffix.end(), suffix.begin(),
[](unsigned char c) { return std::tolower(c); });
return true;
}
bool MimeTypeMgr::GetUtdByUri(const std::string &uri, std::string &utd)
{
#ifdef BUNDLE_FRAMEWORK_UDMF_ENABLED
std::string suffix;
if (!GetUriSuffix(uri, suffix)) {
APP_LOGD("Get suffix failed %{private}s", uri.c_str());
return false;
}
auto ret = UDMF::UtdClient::GetInstance().GetUniformDataTypeByFilenameExtension(suffix, utd);
if (ret != ERR_OK) {
APP_LOGD("Get utd by suffix %{public}s failed. err %{public}d", suffix.c_str(), ret);
return false;
}
return true;
#else
return false;
#endif
}
}
}

View File

@ -101,7 +101,7 @@ void from_json(const nlohmann::json &jsonObject, ModuleInfo &moduleInfo)
parseResult,
ArrayType::STRING);
if (parseResult != ERR_OK) {
APP_LOGE("read module moduleInfo from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read moduleInfo jsonObject error : %{public}d", parseResult);
}
}
} // namespace AppExecFwk

View File

@ -106,7 +106,7 @@ void from_json(const nlohmann::json &jsonObject, OverlayBundleInfo &overlayBundl
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("overlayBundleInfo from_json error, error code : %{public}d", parseResult);
APP_LOGE("overlayBundleInfo from_json error : %{public}d", parseResult);
}
}
} // AppExecFwk

View File

@ -131,7 +131,7 @@ void from_json(const nlohmann::json &jsonObject, OverlayModuleInfo &overlayModul
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("overlayModuleInfo from_json error, error code : %{public}d", parseResult);
APP_LOGE("overlayModuleInfo from_json error : %{public}d", parseResult);
}
}
} // AppExecFwk

View File

@ -110,7 +110,7 @@ void from_json(const nlohmann::json &jsonObject, SharedBundleInfo &sharedBundleI
parseResult,
ArrayType::OBJECT);
if (parseResult != ERR_OK) {
APP_LOGE("read SharedBundleInfo error, error code : %{public}d", parseResult);
APP_LOGE("read SharedBundleInfo error : %{public}d", parseResult);
}
}
} // AppExecFwk

View File

@ -146,7 +146,7 @@ void from_json(const nlohmann::json &jsonObject, SharedModuleInfo &sharedModuleI
sharedModuleInfo.nativeLibraryFileNames, JsonType::ARRAY, false, parseResult,
ArrayType::STRING);
if (parseResult != ERR_OK) {
APP_LOGE("read SharedModuleInfo error, error code : %{public}d", parseResult);
APP_LOGE("read SharedModuleInfo error : %{public}d", parseResult);
}
}
} // AppExecFwk

View File

@ -194,7 +194,7 @@ void from_json(const nlohmann::json &jsonObject, ShortcutIntent &shortcutIntent)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read module shortcutIntent from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read shortcutIntent jsonObject error : %{public}d", parseResult);
}
}
@ -307,7 +307,7 @@ void from_json(const nlohmann::json &jsonObject, ShortcutInfo &shortcutInfo)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read module shortcutInfo from jsonObject error, error code : %{public}d", parseResult);
APP_LOGE("read shortcutInfo jsonObject error : %{public}d", parseResult);
}
}
@ -348,7 +348,7 @@ void from_json(const nlohmann::json &jsonObject, ShortcutWant &shortcutWant)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
APP_LOGE("read shortcutWant from module.json error, error code : %{public}d", parseResult);
APP_LOGE("read shortcutWant module.json error : %{public}d", parseResult);
}
}
@ -405,7 +405,7 @@ void from_json(const nlohmann::json &jsonObject, Shortcut &shortcut)
parseResult,
ArrayType::OBJECT);
if (parseResult != ERR_OK) {
APP_LOGE("read Shortcut from module.json error, error code : %{public}d", parseResult);
APP_LOGE("read Shortcut module.json error : %{public}d", parseResult);
}
}
@ -423,7 +423,7 @@ void from_json(const nlohmann::json &jsonObject, ShortcutJson &shortcutJson)
parseResult,
ArrayType::OBJECT);
if (parseResult != ERR_OK) {
APP_LOGE("read ShortcutJson from module.json error, error code : %{public}d", parseResult);
APP_LOGE("read ShortcutJson module.json error : %{public}d", parseResult);
}
}
} // namespace AppExecFwk

View File

@ -54,6 +54,7 @@ constexpr const char* TYPE_WILDCARD = "*/*";
const char WILDCARD = '*';
constexpr const char* TYPE_ONLY_MATCH_WILDCARD = "reserved/wildcard";
const std::string LINK_FEATURE = "linkFeature";
const std::string GENERAL_OBJECT = "general.object";
}; // namespace
bool Skill::Match(const OHOS::AAFwk::Want &want) const
@ -267,17 +268,15 @@ bool Skill::MatchLinkFeature(const std::string &linkFeature, const OHOS::AAFwk::
if (!onlyUri) {
continue;
}
std::vector<std::string> mimeTypes;
if (!MimeTypeMgr::GetMimeTypeByUri(paramUriString, mimeTypes)) {
std::string paramUtd;
if (!MimeTypeMgr::GetUtdByUri(paramUriString, paramUtd)) {
continue;
}
for (const auto &mimeType : mimeTypes) {
if ((MatchUri(paramUriString, skillUri) ||
(skillUri.scheme.empty() && paramUriString.find(SCHEME_SEPARATOR) == std::string::npos)) &&
MatchType(mimeType, skillUri.type)) {
matchUriIndex = uriIndex;
return true;
}
if ((MatchUri(paramUriString, skillUri) ||
(skillUri.scheme.empty() && paramUriString.find(SCHEME_SEPARATOR) == std::string::npos)) &&
MatchType(paramUtd, skillUri.type)) {
matchUriIndex = uriIndex;
return true;
}
}
return false;
@ -433,16 +432,17 @@ bool Skill::MatchType(const std::string &type, const std::string &skillUriType)
return false;
}
// only match */* or general.object
if (type == TYPE_ONLY_MATCH_WILDCARD) {
return skillUriType == TYPE_WILDCARD || skillUriType == GENERAL_OBJECT;
}
bool containsUtd = false;
bool matchUtdRet = MatchUtd(type, skillUriType, containsUtd);
if (containsUtd) {
return matchUtdRet;
}
// only match */*
if (type == TYPE_ONLY_MATCH_WILDCARD) {
return skillUriType == TYPE_WILDCARD;
}
if (type == TYPE_WILDCARD || skillUriType == TYPE_WILDCARD) {
// param is */* or config is */*
return true;
@ -532,18 +532,15 @@ bool Skill::IsUtd(const std::string &param) const
bool Skill::MatchMimeType(const std::string & uriString) const
{
std::vector<std::string> mimeTypes;
bool ret = MimeTypeMgr::GetMimeTypeByUri(uriString, mimeTypes);
if (!ret) {
std::string paramUtd;
if (!MimeTypeMgr::GetUtdByUri(uriString, paramUtd)) {
return false;
}
for (const SkillUri &skillUri : uris) {
for (const auto &mimeType : mimeTypes) {
if ((MatchUri(uriString, skillUri) ||
(skillUri.scheme.empty() && uriString.find(SCHEME_SEPARATOR) == std::string::npos)) &&
MatchType(mimeType, skillUri.type)) {
return true;
}
if ((MatchUri(uriString, skillUri) ||
(skillUri.scheme.empty() && uriString.find(SCHEME_SEPARATOR) == std::string::npos)) &&
MatchType(paramUtd, skillUri.type)) {
return true;
}
}
return false;
@ -552,20 +549,17 @@ bool Skill::MatchMimeType(const std::string & uriString) const
bool Skill::MatchMimeType(const std::string & uriString, size_t &matchUriIndex) const
{
std::vector<std::string> mimeTypes;
bool ret = MimeTypeMgr::GetMimeTypeByUri(uriString, mimeTypes);
if (!ret) {
std::string paramUtd;
if (!MimeTypeMgr::GetUtdByUri(uriString, paramUtd)) {
return false;
}
for (size_t uriIndex = 0; uriIndex < uris.size(); ++uriIndex) {
const SkillUri &skillUri = uris[uriIndex];
for (const auto &mimeType : mimeTypes) {
if ((MatchUri(uriString, skillUri) ||
(skillUri.scheme.empty() && uriString.find(SCHEME_SEPARATOR) == std::string::npos)) &&
MatchType(mimeType, skillUri.type)) {
matchUriIndex = uriIndex;
return true;
}
if ((MatchUri(uriString, skillUri) ||
(skillUri.scheme.empty() && uriString.find(SCHEME_SEPARATOR) == std::string::npos)) &&
MatchType(paramUtd, skillUri.type)) {
matchUriIndex = uriIndex;
return true;
}
}
return false;
@ -668,7 +662,7 @@ void Skill::Dump(std::string prefix, int fd)
}
int flags = fcntl(fd, F_GETFL);
if (flags < 0) {
APP_LOGE("dump Skill fcntl error, errno : %{public}d", errno);
APP_LOGE("dump Skill fcntl error : %{public}d", errno);
return;
}
uint uflags = static_cast<uint>(flags);
@ -680,7 +674,7 @@ void Skill::Dump(std::string prefix, int fd)
result.append(jsonObject.dump(Constants::DUMP_INDENT));
int ret = TEMP_FAILURE_RETRY(write(fd, result.c_str(), result.size()));
if (ret < 0) {
APP_LOGE("dump Abilityinfo write error, errno : %{public}d", errno);
APP_LOGE("dump Abilityinfo write error : %{public}d", errno);
}
}
return;

View File

@ -693,11 +693,12 @@ public:
* @param bundleName Indicates the bundle name of the application whose cache data is to be cleared.
* @param cleanCacheCallback Indicates the callback to be invoked for returning the operation result.
* @param userId description the user id.
* @param appIndex Indicates the app index.
* @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise.
*/
virtual ErrCode CleanBundleCacheFiles(
const std::string &bundleName, const sptr<ICleanCacheCallback> cleanCacheCallback,
int32_t userId = Constants::UNSPECIFIED_USERID)
int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0)
{
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
}
@ -714,9 +715,10 @@ public:
* @brief Clears application running data of a specified application.
* @param bundleName Indicates the bundle name of the application whose data is to be cleared.
* @param userId Indicates the user id.
* @param appIndex Indicates the app index.
* @return Returns true if the data cleared successfully; returns false otherwise.
*/
virtual bool CleanBundleDataFiles(const std::string &bundleName, const int userId = 0)
virtual bool CleanBundleDataFiles(const std::string &bundleName, const int userId = 0, const int appIndex = 0)
{
return false;
}

View File

@ -520,18 +520,21 @@ public:
* @param bundleName Indicates the bundle name of the application whose cache data is to be cleared.
* @param cleanCacheCallback Indicates the callback to be invoked for returning the operation result.
* @param userId description the user id.
* @param appIndex Indicates the app index.
* @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise.
*/
virtual ErrCode CleanBundleCacheFiles(
const std::string &bundleName, const sptr<ICleanCacheCallback> cleanCacheCallback,
int32_t userId = Constants::UNSPECIFIED_USERID) override;
int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0) override;
/**
* @brief Clears application running data of a specified application through the proxy object.
* @param bundleName Indicates the bundle name of the application whose data is to be cleared.
* @param userId Indicates the user id.
* @param appIndex Indicates the app index.
* @return Returns true if the data cleared successfully; returns false otherwise.
*/
virtual bool CleanBundleDataFiles(const std::string &bundleName, const int userId = 0) override;
virtual bool CleanBundleDataFiles(const std::string &bundleName, const int userId = 0,
const int appIndex = 0) override;
/**
* @brief Register the specific bundle status callback through the proxy object.
* @param bundleStatusCallback Indicates the callback to be invoked for returning the bundle status changed result.

View File

@ -43,12 +43,24 @@ public:
* @param userId Indicates the id of the bundle whose state has been installed.
*/
virtual void OnBundleAdded(const std::string &bundleName, const int userId) = 0;
virtual void OnBundleAdded(const std::string &bundleName, const int userId, const int32_t appIndex)
{
OnBundleAdded(bundleName, userId);
}
/**
* @brief Called when a new application package has been Updated on the device.
* @param bundleName Indicates the name of the bundle whose state has been Updated.
* @param userId Indicates the id of the bundle whose state has been Updated.
*/
virtual void OnBundleUpdated(const std::string &bundleName, const int userId) = 0;
virtual void OnBundleUpdated(const std::string &bundleName, const int userId, const int32_t appIndex)
{
OnBundleUpdated(bundleName, userId);
}
/**
* @brief Called when a new application package has been Removed on the device.
* @param bundleName Indicates the name of the bundle whose state has been Removed.
@ -56,6 +68,11 @@ public:
*/
virtual void OnBundleRemoved(const std::string &bundleName, const int userId) = 0;
virtual void OnBundleRemoved(const std::string &bundleName, const int userId, const int32_t appIndex)
{
OnBundleRemoved(bundleName, userId);
}
std::string GetBundleName()
{
return bundleName_;

View File

@ -45,18 +45,21 @@ public:
* @param userId Indicates the id of the bundle whose state has been installed.
*/
virtual void OnBundleAdded(const std::string &bundleName, const int userId) override {};
virtual void OnBundleAdded(const std::string &bundleName, const int userId, const int32_t appIndex) override {};
/**
* @brief Called when a new application package has been Updated on the device.
* @param bundleName Indicates the name of the bundle whose state has been Updated.
* @param userId Indicates the id of the bundle whose state has been Updated.
*/
virtual void OnBundleUpdated(const std::string &bundleName, const int userId) override {};
virtual void OnBundleUpdated(const std::string &bundleName, const int userId, const int32_t appIndex) override {};
/**
* @brief Called when a new application package has been Removed on the device.
* @param bundleName Indicates the name of the bundle whose state has been Removed.
* @param userId Indicates the id of the bundle whose state has been Removed.
*/
virtual void OnBundleRemoved(const std::string &bundleName, const int userId) override {};
virtual void OnBundleRemoved(const std::string &bundleName, const int userId, const int32_t appIndex) override {};
private:
void InitResultMap();

View File

@ -58,7 +58,7 @@ int32_t BundleResourceHost::OnRemoteRequest(uint32_t code, MessageParcel &data,
if (funcMap_.find(code) != funcMap_.end() && funcMap_[code] != nullptr) {
errCode = (this->*funcMap_[code])(data, reply);
} else {
APP_LOGW("bundle resource host receives unknown code, code = %{public}u", code);
APP_LOGW("bundle resource host receives unknown %{public}u", code);
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
APP_LOGD("bundle resource host finish to process message, errCode: %{public}d", errCode);

View File

@ -169,13 +169,13 @@ ErrCode BundleResourceProxy::GetParcelInfo(BundleResourceInterfaceCode code, Mes
}
ErrCode ret = reply.ReadInt32();
if (ret != ERR_OK) {
APP_LOGE("host reply ErrCode : %{public}d", ret);
APP_LOGE("host reply err: %{public}d", ret);
return ret;
}
size_t dataSize = reply.ReadUint32();
void *buffer = nullptr;
if (!GetData(buffer, dataSize, reply.ReadRawData(dataSize))) {
APP_LOGE("GetData failed, dataSize : %{public}zu", dataSize);
APP_LOGE("GetData failed dataSize: %{public}zu", dataSize);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -206,7 +206,7 @@ ErrCode BundleResourceProxy::GetVectorParcelInfo(
ErrCode res = reply.ReadInt32();
if (res != ERR_OK) {
APP_LOGE("failed, ErrCode : %{public}d", res);
APP_LOGE("failed err %{public}d", res);
return res;
}
@ -218,7 +218,7 @@ ErrCode BundleResourceProxy::GetVectorParcelInfo(
void *buffer = nullptr;
if (!GetData(buffer, dataSize, reply.ReadRawData(dataSize))) {
APP_LOGE("Fail to read raw data, length = %{public}zu", dataSize);
APP_LOGE("read raw data fail, length %{public}zu", dataSize);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -250,12 +250,12 @@ bool BundleResourceProxy::SendRequest(BundleResourceInterfaceCode code,
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
APP_LOGE("fail to send transact cmd %{public}d due to remote object", code);
APP_LOGE("fail send transact cmd %{public}d due to remote object", code);
return false;
}
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
if (result != NO_ERROR) {
APP_LOGE("receive error transact code %{public}d in transact cmd %{public}d", result, code);
APP_LOGE("receive error %{public}d in transact cmd %{public}d", result, code);
return false;
}
return true;

View File

@ -56,7 +56,7 @@ void BundleEventCallbackProxy::OnReceiveEvent(const EventFwk::CommonEventData ev
int32_t ret = remote->SendRequest(
static_cast<int32_t>(BundleEventCallbackInterfaceCode::ON_RECEIVE_EVENT), data, reply, option);
if (ret != ERR_OK) {
APP_LOGW("failed to SendRequest, errorCode : %{public}d", ret);
APP_LOGW("SendRequest failed err %{public}d", ret);
}
}
} // namespace AppExecFwk

View File

@ -37,7 +37,9 @@ namespace AppExecFwk {
namespace {
const std::string BUNDLE_MAP_CODE_PATH = "/data/storage/el1/bundle";
const std::string DATA_APP_PATH = "/data/app";
#ifdef GLOBAL_RESMGR_ENABLE
constexpr const char* PROFILE_FILE_PREFIX = "$profile:";
#endif
const std::string PATH_SEPARATOR = "/";
} // namespace
@ -49,6 +51,7 @@ BundleMgrClientImpl::BundleMgrClientImpl()
BundleMgrClientImpl::~BundleMgrClientImpl()
{
APP_LOGD("destroy bundleMgrClientImpl");
std::lock_guard<std::mutex> lock(mutex_);
if (bundleMgr_ != nullptr && deathRecipient_ != nullptr) {
bundleMgr_->AsObject()->RemoveDeathRecipient(deathRecipient_);
}
@ -60,6 +63,7 @@ ErrCode BundleMgrClientImpl::GetNameForUid(const int uid, std::string &name)
APP_LOGE("failed to connect");
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
}
std::lock_guard<std::mutex> lock(mutex_);
return bundleMgr_->GetNameForUid(uid, name);
}
@ -74,6 +78,7 @@ bool BundleMgrClientImpl::GetBundleInfo(const std::string &bundleName, const Bun
return false;
}
std::lock_guard<std::mutex> lock(mutex_);
return bundleMgr_->GetBundleInfo(bundleName, flag, bundleInfo, userId);
}
@ -86,6 +91,7 @@ ErrCode BundleMgrClientImpl::GetBundlePackInfo(
APP_LOGE("failed to connect");
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
}
std::lock_guard<std::mutex> lock(mutex_);
return bundleMgr_->GetBundlePackInfo(bundleName, flag, bundlePackInfo, userId);
}
@ -97,6 +103,7 @@ ErrCode BundleMgrClientImpl::CreateBundleDataDir(int32_t userId)
APP_LOGE("failed to connect");
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
}
std::lock_guard<std::mutex> lock(mutex_);
return bundleMgr_->CreateBundleDataDir(userId);
}
@ -112,6 +119,7 @@ bool BundleMgrClientImpl::GetHapModuleInfo(const std::string &bundleName, const
AbilityInfo info;
info.bundleName = bundleName;
info.package = hapName;
std::lock_guard<std::mutex> lock(mutex_);
return bundleMgr_->GetHapModuleInfo(info, hapModuleInfo);
}
@ -327,7 +335,7 @@ bool BundleMgrClientImpl::GetResFromResMgr(const std::string &resName, const std
size_t pos = resName.rfind(PROFILE_FILE_PREFIX);
if ((pos == std::string::npos) || (pos == resName.length() - strlen(PROFILE_FILE_PREFIX))) {
APP_LOGE("GetResFromResMgr res name %{public}s is invalid", resName.c_str());
APP_LOGE("GetResFromResMgr res name %{public}s invalid", resName.c_str());
return false;
}
std::string profileName = resName.substr(pos + strlen(PROFILE_FILE_PREFIX));
@ -377,7 +385,7 @@ bool BundleMgrClientImpl::IsFileExisted(const std::string &filePath) const
}
if (access(filePath.c_str(), F_OK) != 0) {
APP_LOGE("can not access the file: %{private}s, errno:%{public}d", filePath.c_str(), errno);
APP_LOGE("not access file: %{private}s errno: %{public}d", filePath.c_str(), errno);
return false;
}
return true;
@ -395,13 +403,13 @@ bool BundleMgrClientImpl::TransformFileToJsonString(const std::string &resPath,
in.open(resPath, std::ios_base::in | std::ios_base::binary);
if (!in.is_open()) {
strerror_r(errno, errBuf, sizeof(errBuf));
APP_LOGE("the file cannot be open due to %{public}s, errno:%{public}d", errBuf, errno);
APP_LOGE("file open fail due to %{public}s errno:%{public}d", errBuf, errno);
return false;
}
in.seekg(0, std::ios::end);
int64_t size = in.tellg();
if (size <= 0) {
APP_LOGE("the file is an empty file, errno:%{public}d", errno);
APP_LOGE("file empty err %{public}d", errno);
in.close();
return false;
}
@ -431,6 +439,7 @@ ErrCode BundleMgrClientImpl::InstallSandboxApp(const std::string &bundleName, in
return ERR_APPEXECFWK_SANDBOX_INSTALL_INTERNAL_ERROR;
}
std::lock_guard<std::mutex> lock(mutex_);
return bundleInstaller_->InstallSandboxApp(bundleName, dlpType, userId, appIndex);
}
@ -447,6 +456,7 @@ ErrCode BundleMgrClientImpl::UninstallSandboxApp(const std::string &bundleName,
return ERR_APPEXECFWK_SANDBOX_INSTALL_INTERNAL_ERROR;
}
std::lock_guard<std::mutex> lock(mutex_);
return bundleInstaller_->UninstallSandboxApp(bundleName, appIndex, userId);
}
@ -464,6 +474,7 @@ ErrCode BundleMgrClientImpl::GetSandboxBundleInfo(
APP_LOGE("failed to connect");
return ERR_APPEXECFWK_SANDBOX_INSTALL_INTERNAL_ERROR;
}
std::lock_guard<std::mutex> lock(mutex_);
return bundleMgr_->GetSandboxBundleInfo(bundleName, appIndex, userId, info);
}
@ -481,6 +492,7 @@ ErrCode BundleMgrClientImpl::GetSandboxAbilityInfo(const Want &want, int32_t app
return ERR_APPEXECFWK_SANDBOX_INSTALL_INTERNAL_ERROR;
}
std::lock_guard<std::mutex> lock(mutex_);
return bundleMgr_->GetSandboxAbilityInfo(want, appIndex, flags, userId, abilityInfo);
}
@ -498,6 +510,7 @@ ErrCode BundleMgrClientImpl::GetSandboxExtAbilityInfos(const Want &want, int32_t
return ERR_APPEXECFWK_SANDBOX_INSTALL_INTERNAL_ERROR;
}
std::lock_guard<std::mutex> lock(mutex_);
return bundleMgr_->GetSandboxExtAbilityInfos(want, appIndex, flags, userId, extensionInfos);
}
@ -515,6 +528,7 @@ ErrCode BundleMgrClientImpl::GetSandboxHapModuleInfo(const AbilityInfo &abilityI
return ERR_APPEXECFWK_SANDBOX_INSTALL_INTERNAL_ERROR;
}
std::lock_guard<std::mutex> lock(mutex_);
return bundleMgr_->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo);
}

View File

@ -404,7 +404,7 @@ int BundleMgrHost::OnRemoteRequest(uint32_t code, MessageParcel &data, MessagePa
if (funcMap_.find(code) != funcMap_.end() && funcMap_[code] != nullptr) {
errCode = (this->*funcMap_[code])(data, reply);
} else {
APP_LOGW("bundleMgr host receives unknown code, code = %{public}u", code);
APP_LOGW("bundleMgr host receives unknown code %{public}u", code);
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
APP_LOGD("bundleMgr host finish to process message, errCode: %{public}d", errCode);
@ -1440,8 +1440,9 @@ ErrCode BundleMgrHost::HandleCleanBundleCacheFiles(MessageParcel &data, MessageP
}
sptr<ICleanCacheCallback> cleanCacheCallback = iface_cast<ICleanCacheCallback>(object);
int32_t userId = data.ReadInt32();
int32_t appIndex = data.ReadInt32();
ErrCode ret = CleanBundleCacheFiles(bundleName, cleanCacheCallback, userId);
ErrCode ret = CleanBundleCacheFiles(bundleName, cleanCacheCallback, userId, appIndex);
if (!reply.WriteInt32(ret)) {
APP_LOGE("write failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
@ -1454,8 +1455,9 @@ ErrCode BundleMgrHost::HandleCleanBundleDataFiles(MessageParcel &data, MessagePa
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::string bundleName = data.ReadString();
int userId = data.ReadInt32();
int appIndex = data.ReadInt32();
bool ret = CleanBundleDataFiles(bundleName, userId);
bool ret = CleanBundleDataFiles(bundleName, userId, appIndex);
if (!reply.WriteBool(ret)) {
APP_LOGE("write failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
@ -1564,9 +1566,9 @@ ErrCode BundleMgrHost::HandleCompileProcessAOT(MessageParcel &data, MessageParce
bool isAllBundle = data.ReadBool();
std::vector<std::string> compileResults;
APP_LOGI("compile info name %{public}s", bundleName.c_str());
APP_LOGI("compile info %{public}s", bundleName.c_str());
ErrCode ret = CompileProcessAOT(bundleName, compileMode, isAllBundle, compileResults);
APP_LOGI("ret is %{public}d", ret);
APP_LOGI("ret %{public}d", ret);
if (!reply.WriteInt32(ret)) {
APP_LOGE("write failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
@ -1586,9 +1588,9 @@ ErrCode BundleMgrHost::HandleCompileReset(MessageParcel &data, MessageParcel &re
std::string bundleName = data.ReadString();
bool isAllBundle = data.ReadBool();
APP_LOGI("reset info name %{public}s", bundleName.c_str());
APP_LOGI("reset info %{public}s", bundleName.c_str());
ErrCode ret = CompileReset(bundleName, isAllBundle);
APP_LOGI("ret is %{public}d", ret);
APP_LOGI("ret %{public}d", ret);
if (!reply.WriteInt32(ret)) {
APP_LOGE("write failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
@ -1603,7 +1605,7 @@ ErrCode BundleMgrHost::HandleCopyAp(MessageParcel &data, MessageParcel &reply)
bool isAllBundle = data.ReadBool();
std::vector<std::string> results;
ErrCode ret = CopyAp(bundleName, isAllBundle, results);
APP_LOGI("ret is %{public}d", ret);
APP_LOGI("ret %{public}d", ret);
if (!reply.WriteInt32(ret)) {
APP_LOGE("HandleCopyAp write failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
@ -1623,7 +1625,7 @@ ErrCode BundleMgrHost::HandleDumpInfos(MessageParcel &data, MessageParcel &reply
int32_t userId = data.ReadInt32();
std::string result;
APP_LOGI("dump info name %{public}s", bundleName.c_str());
APP_LOGI("dump info %{public}s", bundleName.c_str());
bool ret = DumpInfos(flag, bundleName, userId, result);
(void)reply.SetMaxCapacity(MAX_PARCEL_CAPACITY);
if (!reply.WriteBool(ret)) {
@ -3424,7 +3426,7 @@ ErrCode BundleMgrHost::WriteBigParcelable(T &parcelable, const char *ashmemName,
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (useAshMem) {
APP_LOGI("reply size %{public}lu, writing into ashmem", static_cast<unsigned long>(size));
APP_LOGI("reply size %{public}lu, writing ashmem", static_cast<unsigned long>(size));
if (!WriteParcelableIntoAshmem(parcelable, ashmemName, reply)) {
APP_LOGE("write failed");
return ERR_APPEXECFWK_PARCEL_ERROR;

View File

@ -436,7 +436,7 @@ ErrCode BundleMgrProxy::BatchGetBundleInfo(const std::vector<std::string> &bundl
}
for (size_t i = 0; i < newBundleNames.size(); i++) {
if (!data.WriteString(newBundleNames[i])) {
APP_LOGE("fail to BatchGetBundleInfo due to write bundle name %{public}zu fail", i);
APP_LOGE("write bundleName %{public}zu failed", i);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
}
@ -769,7 +769,9 @@ bool BundleMgrProxy::GetBundleNameForUid(const int uid, std::string &bundleName)
return false;
}
if (!reply.ReadBool()) {
APP_LOGE("reply result false");
if (uid > Constants::BASE_APP_UID) {
APP_LOGE("reply result false");
}
return false;
}
bundleName = reply.ReadString();
@ -1404,7 +1406,7 @@ ErrCode BundleMgrProxy::GetAbilityLabel(const std::string &bundleName, const std
const std::string &abilityName, std::string &label)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
APP_LOGI("begin to GetAbilityLabel of %{public}s", bundleName.c_str());
APP_LOGI("GetAbilityLabel begin %{public}s", bundleName.c_str());
if (bundleName.empty() || moduleName.empty() || abilityName.empty()) {
APP_LOGE("fail to GetAbilityLabel due to params empty");
return ERR_BUNDLE_MANAGER_PARAM_ERROR;
@ -1657,10 +1659,11 @@ ErrCode BundleMgrProxy::CleanBundleCacheFilesAutomatic(uint64_t cacheSize)
}
ErrCode BundleMgrProxy::CleanBundleCacheFiles(
const std::string &bundleName, const sptr<ICleanCacheCallback> cleanCacheCallback, int32_t userId)
const std::string &bundleName, const sptr<ICleanCacheCallback> cleanCacheCallback, int32_t userId, int32_t appIndex)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
APP_LOGD("begin to CleanBundleCacheFiles of %{public}s", bundleName.c_str());
APP_LOGD("begin to CleanBundleCacheFiles of %{public}s, userId:%{public}d, appIndex:%{public}d",
bundleName.c_str(), userId, appIndex);
if (bundleName.empty()) {
APP_LOGE("fail to CleanBundleCacheFiles due to bundleName empty");
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
@ -1687,6 +1690,10 @@ ErrCode BundleMgrProxy::CleanBundleCacheFiles(
APP_LOGE("fail to CleanBundleCacheFiles due to write userId fail");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteInt32(appIndex)) {
APP_LOGE("fail to CleanBundleDataFiles due to write appIndex fail");
return false;
}
MessageParcel reply;
if (!SendTransactCmd(BundleMgrInterfaceCode::CLEAN_BUNDLE_CACHE_FILES, data, reply)) {
@ -1696,10 +1703,11 @@ ErrCode BundleMgrProxy::CleanBundleCacheFiles(
return reply.ReadInt32();
}
bool BundleMgrProxy::CleanBundleDataFiles(const std::string &bundleName, const int userId)
bool BundleMgrProxy::CleanBundleDataFiles(const std::string &bundleName, const int userId, const int appIndex)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
APP_LOGD("begin to CleanBundleDataFiles of %{public}s", bundleName.c_str());
APP_LOGD("begin to CleanBundleDataFiles of %{public}s, userId:%{public}d, appIndex:%{public}d",
bundleName.c_str(), userId, appIndex);
if (bundleName.empty()) {
APP_LOGE("fail to CleanBundleDataFiles due to params empty");
return false;
@ -1718,6 +1726,10 @@ bool BundleMgrProxy::CleanBundleDataFiles(const std::string &bundleName, const i
APP_LOGE("fail to CleanBundleDataFiles due to write userId fail");
return false;
}
if (!data.WriteInt32(appIndex)) {
APP_LOGE("fail to CleanBundleDataFiles due to write appIndex fail");
return false;
}
MessageParcel reply;
if (!SendTransactCmd(BundleMgrInterfaceCode::CLEAN_BUNDLE_DATA_FILES, data, reply)) {
@ -4240,7 +4252,7 @@ ErrCode BundleMgrProxy::GetUninstalledBundleInfo(const std::string bundleName, B
auto res = GetParcelableInfoWithErrCode<BundleInfo>(
BundleMgrInterfaceCode::GET_UNINSTALLED_BUNDLE_INFO, data, bundleInfo);
if (res != ERR_OK) {
APP_LOGE("fail to GetUninstalledBundleInfo from server, error code: %{public}d", res);
APP_LOGE("GetUninstalledBundleInfo from server failed error %{public}d", res);
return res;
}
return ERR_OK;
@ -4324,7 +4336,7 @@ ErrCode BundleMgrProxy::GetAllBundleInfoByDeveloperId(const std::string &develop
std::vector<BundleInfo> &bundleInfos, int32_t userId)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
APP_LOGI("begin to GetAllBundleInfoByDeveloperId, developerId: %{public}s, userId :%{public}d",
APP_LOGI("begin GetAllBundleInfoByDeveloperId, developerId: %{public}s, userId :%{public}d",
developerId.c_str(), userId);
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
@ -4369,7 +4381,7 @@ ErrCode BundleMgrProxy::GetDeveloperIds(const std::string &appDistributionType,
}
ErrCode res = reply.ReadInt32();
if (res != ERR_OK) {
APP_LOGE("GetParcelableInfosWithErrCode ErrCode : %{public}d", res);
APP_LOGE("host reply err %{public}d", res);
return res;
}
if (!reply.ReadStringVector(&developerIdList)) {
@ -4498,7 +4510,7 @@ ErrCode BundleMgrProxy::GetParcelInfoIntelligent(
size_t dataSize = reply.ReadUint32();
void *buffer = nullptr;
if (!GetData(buffer, dataSize, reply.ReadRawData(dataSize))) {
APP_LOGE("GetData failed, dataSize : %{public}zu", dataSize);
APP_LOGE("GetData failed dataSize : %{public}zu", dataSize);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -4552,7 +4564,7 @@ ErrCode BundleMgrProxy::GetVectorFromParcelIntelligentWithErrCode(
ErrCode res = reply.ReadInt32();
if (res != ERR_OK) {
APP_LOGE("GetParcelableInfosWithErrCode ErrCode : %{public}d", res);
APP_LOGE("GetParcelableInfosWithErrCode: %{public}d", res);
return res;
}
@ -4571,7 +4583,7 @@ ErrCode BundleMgrProxy::InnerGetVectorFromParcelIntelligent(
void *buffer = nullptr;
if (!SendData(buffer, dataSize, reply.ReadRawData(dataSize))) {
APP_LOGE("Fail to read raw data, length = %{public}zu", dataSize);
APP_LOGE("Fail read raw data length %{public}zu", dataSize);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -4601,7 +4613,7 @@ bool BundleMgrProxy::SendTransactCmd(BundleMgrInterfaceCode code, MessageParcel
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
APP_LOGE("fail to send transact cmd %{public}d due to remote object", code);
APP_LOGE("fail send transact cmd %{public}d due remote object", code);
return false;
}
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
@ -4618,13 +4630,13 @@ bool BundleMgrProxy::SendTransactCmdWithLog(BundleMgrInterfaceCode code, Message
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
APP_LOGE("fail to send transact cmd %{public}d due to remote object", code);
APP_LOGE("fail send transact cmd %{public}d due remote object", code);
return false;
}
int32_t sptrRefCount = remote->GetSptrRefCount();
int32_t wptrRefCount = remote->GetWptrRefCount();
if (sptrRefCount <= 0 || wptrRefCount <= 0) {
APP_LOGI("SendTransactCmd SendRequest before sptrRefCount: %{public}d wptrRefCount: %{public}d",
APP_LOGI("SendRequest before sptrRefCount: %{public}d wptrRefCount: %{public}d",
sptrRefCount, wptrRefCount);
}
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
@ -4664,7 +4676,7 @@ ErrCode BundleMgrProxy::GetParcelInfo(BundleMgrInterfaceCode code, MessageParcel
}
ErrCode ret = reply.ReadInt32();
if (ret != ERR_OK) {
APP_LOGE("host reply ErrCode : %{public}d", ret);
APP_LOGE("host reply err : %{public}d", ret);
return ret;
}
return InnerGetParcelInfo<T>(reply, parcelInfo);
@ -4705,7 +4717,7 @@ ErrCode BundleMgrProxy::GetBigString(BundleMgrInterfaceCode code, MessageParcel
}
ErrCode ret = reply.ReadInt32();
if (ret != ERR_OK) {
APP_LOGE("host reply ErrCode : %{public}d", ret);
APP_LOGE("host reply err %{public}d", ret);
return ret;
}
return InnerGetBigString(reply, result);
@ -4720,7 +4732,7 @@ ErrCode BundleMgrProxy::InnerGetBigString(MessageParcel &reply, std::string &res
}
const char *data = reinterpret_cast<const char *>(reply.ReadRawData(dataSize));
if (!data) {
APP_LOGE("Fail to read raw data, length = %{public}zu", dataSize);
APP_LOGE("Fail read raw data length %{public}zu", dataSize);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
result = data;
@ -4817,7 +4829,7 @@ ErrCode BundleMgrProxy::CopyAp(const std::string &bundleName, bool isAllBundle,
}
ErrCode res = reply.ReadInt32();
if (res != ERR_OK) {
APP_LOGE("host reply ErrCode : %{public}d", res);
APP_LOGE("host reply err: %{public}d", res);
return res;
}
if (!reply.ReadStringVector(&results)) {
@ -4849,7 +4861,7 @@ ErrCode BundleMgrProxy::CanOpenLink(
}
ErrCode res = reply.ReadInt32();
if (res != ERR_OK) {
APP_LOGE("host reply ErrCode : %{public}d", res);
APP_LOGE("host reply err: %{public}d", res);
return res;
}
canOpen = reply.ReadBool();

View File

@ -59,17 +59,18 @@ void BundleMonitor::OnReceiveEvent(const EventFwk::CommonEventData &eventData)
std::string action = want.GetAction();
std::string bundleName = want.GetElement().GetBundleName();
int userId = want.GetIntParam(Constants::USER_ID, Constants::INVALID_USERID);
APP_LOGI("OnReceiveEvent action = %{public}s, bundle = %{public}s, userId = %{public}d",
action.c_str(), bundleName.c_str(), userId);
int32_t appIndex = want.GetIntParam(Constants::APP_INDEX, Constants::DEFAULT_APP_INDEX);
APP_LOGI("OnReceiveEvent action = %{public}s, bundle = %{public}s, userId = %{public}d, appIndex = %{public}d",
action.c_str(), bundleName.c_str(), userId, appIndex);
std::lock_guard<std::mutex> lock(mutex_);
if ((action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED) && (callback_ != nullptr)) {
callback_->OnBundleAdded(bundleName, userId);
callback_->OnBundleAdded(bundleName, userId, appIndex);
} else if ((action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_CHANGED) && (callback_ != nullptr)) {
callback_->OnBundleUpdated(bundleName, userId);
callback_->OnBundleUpdated(bundleName, userId, appIndex);
} else if ((action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED) && (callback_ != nullptr)) {
callback_->OnBundleRemoved(bundleName, userId);
callback_->OnBundleRemoved(bundleName, userId, appIndex);
} else {
APP_LOGI("OnReceiveEvent action = %{public}s not support", action.c_str());
APP_LOGI("%{public}s not support", action.c_str());
}
}
} // namespace AppExecFwk

View File

@ -228,7 +228,7 @@ void BundleStatusCallbackProxy::OnBundleStateChanged(
int32_t ret = remote->SendRequest(
static_cast<int32_t>(BundleStatusCallbackInterfaceCode::ON_BUNDLE_STATE_CHANGED), data, reply, option);
if (ret != NO_ERROR) {
APP_LOGW("fail to call OnBundleStateChanged, for transact is failed, error code is: %{public}d", ret);
APP_LOGW("call OnBundleStateChanged fail for transact failed, error code: %{public}d", ret);
}
}
} // namespace AppExecFwk

View File

@ -67,7 +67,7 @@ ErrCode BundleUserMgrHost::HandleCreateNewUser(Parcel &data, Parcel &reply)
const int32_t userId = data.ReadInt32();
const int32_t vectorSize = data.ReadInt32();
if (vectorSize > DISALLOWLISTMAXSIZE) {
APP_LOGE("Abnormal data size reading form parcel, size is %{public}d", vectorSize);
APP_LOGE("Abnormal data size reading form parcel, size %{public}d", vectorSize);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
std::vector<std::string> disallowList;

View File

@ -70,7 +70,7 @@ ErrCode BundleUserMgrProxy::CreateNewUser(int32_t userId, const std::vector<std:
ErrCode ret = reply.ReadInt32();
if (ret != ERR_OK) {
APP_LOGE("host reply errCode : %{public}d", ret);
APP_LOGE("host reply err %{public}d", ret);
return ret;
}
return ERR_OK;
@ -97,7 +97,7 @@ ErrCode BundleUserMgrProxy::RemoveUser(int32_t userId)
ErrCode ret = reply.ReadInt32();
if (ret != ERR_OK) {
APP_LOGE("host reply errCode : %{public}d", ret);
APP_LOGE("host reply err %{public}d", ret);
return ret;
}
return ERR_OK;
@ -109,7 +109,7 @@ bool BundleUserMgrProxy::SendTransactCmd(BundleUserMgrInterfaceCode code, Messag
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
APP_LOGE("fail to send transact cmd %{public}d due to remote object", code);
APP_LOGE("fail send transact cmd %{public}d due to remote object", code);
return false;
}
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);

View File

@ -58,7 +58,7 @@ void CleanCacheCallbackProxy::OnCleanCacheFinished(bool succeeded)
int32_t ret = remote->SendRequest(
static_cast<int32_t>(CleanCacheCallbackInterfaceCode::ON_CLEAN_CACHE_CALLBACK), data, reply, option);
if (ret != NO_ERROR) {
APP_LOGW("fail to call OnCleanCacheFinished, for transact is failed, error code is: %{public}d", ret);
APP_LOGW("call OnCleanCacheFinished fail, for transact failed, error code: %{public}d", ret);
}
}
} // namespace AppExecFwk

View File

@ -65,7 +65,7 @@ int ExtendResourceManagerHost::OnRemoteRequest(uint32_t code, MessageParcel& dat
case static_cast<uint32_t>(ExtendResourceManagerInterfaceCode::CREATE_FD):
return HandleCreateFd(data, reply);
default:
APP_LOGW("ExtendResourceManagerHost receive unknown code, code = %{public}d", code);
APP_LOGW("ExtendResourceManagerHost receive unknown code %{public}d", code);
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
}

View File

@ -356,7 +356,7 @@ bool ExtendResourceManagerProxy::SendRequest(
}
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
if (result != NO_ERROR) {
APP_LOGE("receive error code %{public}d in transact %{public}d", result, code);
APP_LOGE("receive error %{public}d in transact %{public}d", result, code);
return false;
}
return true;

View File

@ -74,7 +74,7 @@ int OverlayManagerHost::OnRemoteRequest(uint32_t code, MessageParcel& data,
if (funcMap_.find(code) != funcMap_.end() && funcMap_[code] != nullptr) {
errCode = (this->*funcMap_[code])(data, reply);
} else {
APP_LOGW("overlayMgr host receives unknown code, code = %{public}u", code);
APP_LOGW("overlayMgr host receives unknown code %{public}u", code);
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
APP_LOGD("overlayMgr host finish to process message");

View File

@ -256,7 +256,7 @@ ErrCode OverlayManagerProxy::SetOverlayEnabledForSelf(const std::string &moduleN
}
auto res = reply.ReadInt32();
if (res != ERR_OK) {
APP_LOGE("failed to SetOverlayEnabledForSelf due to error %{public}d", res);
APP_LOGE("SetOverlayEnabledForSelf failed %{public}d", res);
}
return res;
}
@ -300,7 +300,7 @@ ErrCode OverlayManagerProxy::SetOverlayEnabled(const std::string &bundleName, co
}
auto res = reply.ReadInt32();
if (res != ERR_OK) {
APP_LOGE("failed to SetOverlayEnabled due to error %{public}d", res);
APP_LOGE("failed SetOverlayEnabled %{public}d", res);
}
return res;
}
@ -395,12 +395,12 @@ bool OverlayManagerProxy::SendTransactCmd(OverlayManagerInterfaceCode code, Mess
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
APP_LOGE("fail to send transact cmd %{public}d due to remote object", code);
APP_LOGE("fail send transact cmd %{public}d due to remote object", code);
return false;
}
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
if (result != NO_ERROR) {
APP_LOGE("receive error transact code %{public}d in transact cmd %{public}d", result, code);
APP_LOGE("receive error code %{public}d in transact cmd %{public}d", result, code);
return false;
}
return true;

View File

@ -55,7 +55,7 @@ int VerifyManagerHost::OnRemoteRequest(uint32_t code, MessageParcel& data,
case static_cast<uint32_t>(VerifyManagerInterfaceCode::DELETE_ABC):
return HandleDeleteAbc(data, reply);
default:
APP_LOGW("VerifyManagerHost receive unknown code, code = %{public}d", code);
APP_LOGW("VerifyManagerHost receive unknown code %{public}d", code);
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
}

View File

@ -120,7 +120,7 @@ bool VerifyManagerProxy::SendRequest(
MessageOption option(MessageOption::TF_SYNC);
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
APP_LOGE("failed to send request %{public}d due to remote object null.", code);
APP_LOGE("send request %{public}d failed due to remote object null.", code);
return false;
}
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);

View File

@ -42,7 +42,7 @@ ErrCode BmsExtensionDataMgr::Init()
BmsExtensionProfile bmsExtensionProfile;
auto res = bmsExtensionProfile.ParseBmsExtension(BMS_EXTENSION_PATH, bmsExtension_);
if (res != ERR_OK) {
APP_LOGW("ParseBmsExtension failed, errCode is %{public}d", res);
APP_LOGW("ParseBmsExtension failed %{public}d", res);
return ERR_APPEXECFWK_PARSE_UNEXPECTED;
}
APP_LOGD("parse bms-extension.json success, which is: %{public}s", bmsExtension_.ToString().c_str());
@ -66,11 +66,11 @@ bool BmsExtensionDataMgr::OpenHandler()
auto lib64Path = bmsExtension_.bmsExtensionBundleMgr.lib64Path.c_str();
*handle = dlopen(lib64Path, RTLD_NOW | RTLD_GLOBAL);
if (*handle == nullptr) {
APP_LOGW("failed to open %{public}s, err:%{public}s", lib64Path, dlerror());
APP_LOGW("open %{public}s failed %{public}s", lib64Path, dlerror());
*handle = dlopen(libPath, RTLD_NOW | RTLD_GLOBAL);
}
if (*handle == nullptr) {
APP_LOGE("failed to open %{public}s, err:%{public}s", libPath, dlerror());
APP_LOGE("open %{public}s failed %{public}s", libPath, dlerror());
return false;
}
APP_LOGD("OpenHandler end");

View File

@ -47,7 +47,7 @@ ErrCode BmsExtensionProfile::ParseBmsExtension(
bool BmsExtensionProfile::ReadFileIntoJson(const std::string &filePath, nlohmann::json &jsonBuf) const
{
if (access(filePath.c_str(), F_OK) != 0) {
APP_LOGE("can not access the file: %{public}s, errno:%{public}d", filePath.c_str(), errno);
APP_LOGE("access failed %{public}s errno:%{public}d", filePath.c_str(), errno);
return false;
}
@ -57,14 +57,14 @@ bool BmsExtensionProfile::ReadFileIntoJson(const std::string &filePath, nlohmann
in.open(filePath, std::ios_base::in);
if (!in.is_open()) {
strerror_r(errno, errBuf, sizeof(errBuf));
APP_LOGE("the file cannot be open due to %{public}s, errno:%{public}d", errBuf, errno);
APP_LOGE("file open failed due to %{public}s, errno:%{public}d", errBuf, errno);
return false;
}
in.seekg(0, std::ios::end);
int64_t size = in.tellg();
if (size <= 0) {
APP_LOGE("the file is an empty file, errno:%{public}d", errno);
APP_LOGE("file is empty err %{public}d", errno);
in.close();
return false;
}

View File

@ -60,14 +60,14 @@ std::shared_ptr<Media::PixelMap> BundleGraphicsClientImpl::LoadImageFile(const u
Media::SourceOptions opts;
std::unique_ptr<Media::ImageSource> imageSource = Media::ImageSource::CreateImageSource(data, len, opts, errorCode);
if ((errorCode != 0) || (imageSource == nullptr)) {
APP_LOGE("failed to create image source err is %{public}d", errorCode);
APP_LOGE("create image source failed err %{public}d", errorCode);
return nullptr;
}
Media::DecodeOptions decodeOpts;
auto pixelMapPtr = imageSource->CreatePixelMap(decodeOpts, errorCode);
if (errorCode != 0) {
APP_LOGE("failed to create pixelmap err %{public}d", errorCode);
APP_LOGE("create pixelmap failed err %{public}d", errorCode);
return nullptr;
}
APP_LOGI("end");

View File

@ -67,6 +67,7 @@ constexpr const char* ROUTER_MAP = "routerMap";
constexpr const char* PAGE_SOURCE_FILE = "pageSourceFile";
constexpr const char* BUILD_FUNCTION = "buildFunction";
constexpr const char* DATA = "data";
constexpr const char* CUSTOM_DATA = "customData";
constexpr const char* KEY = "key";
constexpr const char* VALUE = "value";
constexpr const char* CODE_PATH = "codePath";
@ -1480,7 +1481,16 @@ void CommonFunc::ConvertApplicationInfo(napi_env env, napi_value objAppInfo, con
NAPI_CALL_RETURN_VOID(env, napi_create_int32(env, appInfo.multiAppMode.maxCount, &nMaxCount));
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, nMultiAppMode, MAX_ADDITIONAL_NUMBER, nMaxCount));
if (nMultiAppModeType == nullptr || nMaxCount == nullptr || nMultiAppMode == nullptr) {
APP_LOGW("napi_value is nullptr");
}
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objAppInfo, MULTI_APP_MODE, nMultiAppMode));
napi_value nInstallSource;
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, appInfo.installSource.c_str(), NAPI_AUTO_LENGTH,
&nInstallSource));
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objAppInfo, "installSource", nInstallSource));
}
void CommonFunc::ConvertPermissionDef(napi_env env, napi_value result, const PermissionDef &permissionDef)
@ -1750,10 +1760,37 @@ void CommonFunc::ConvertRouterItem(napi_env env, const RouterItem &routerItem, n
env, routerItem.buildFunction.c_str(), NAPI_AUTO_LENGTH, &nBuildFunction));
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, BUILD_FUNCTION, nBuildFunction));
napi_value nData;
napi_value nDataArray;
NAPI_CALL_RETURN_VOID(env, napi_create_array(env, &nDataArray));
ConvertRouterDataInfos(env, routerItem.data, nDataArray);
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, DATA, nDataArray));
napi_value nCustomData;
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(
env, routerItem.data.c_str(), NAPI_AUTO_LENGTH, &nData));
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, DATA, nData));
env, routerItem.customData.c_str(), NAPI_AUTO_LENGTH, &nCustomData));
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, CUSTOM_DATA, nCustomData));
}
void CommonFunc::ConvertRouterDataInfos(napi_env env,
const std::map<std::string, std::string> &data, napi_value objInfos)
{
size_t index = 0;
for (const auto &item : data) {
napi_value objInfo = nullptr;
napi_create_object(env, &objInfo);
napi_value nKey;
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(
env, item.first.c_str(), NAPI_AUTO_LENGTH, &nKey));
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objInfo, KEY, nKey));
napi_value nValue;
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(
env, item.second.c_str(), NAPI_AUTO_LENGTH, &nValue));
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objInfo, VALUE, nValue));
NAPI_CALL_RETURN_VOID(env, napi_set_element(env, objInfos, index++, objInfo));
}
}
void CommonFunc::ConvertDependency(napi_env env, const Dependency &dependency, napi_value value)

View File

@ -176,6 +176,7 @@ static void ConvertRecoverableApplicationInfos(napi_env env, napi_value value,
const std::vector<RecoverableApplicationInfo> &recoverableApplications);
static void ConvertRouterItem(napi_env env, const RouterItem &routerItem, napi_value value);
static void ConvertRouterDataInfos(napi_env env, const std::map<std::string, std::string> &data, napi_value objInfos);
static void ConvertAbilitySkillUri(napi_env env, const SkillUri &skillUri, napi_value value, bool isExtension);
static void ConvertAbilitySkill(napi_env env, const Skill &skill, napi_value value, bool isExtension);

View File

@ -435,9 +435,9 @@ ohos_shared_library("libbms") {
defines += [ "APP_DOMAIN_VERIFY_ENABLED" ]
}
if (code_signature_enable && pend_sign_screenlock_mgr_enable) {
defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ]
external_deps += [ "screenlock_mgr:screenlock_client" ]
if (code_signature_enable) {
sources += [ "src/aot/aot_sign_data_cache_mgr.cpp" ]
defines += [ "CODE_SIGNATURE_ENABLE" ]
}
subsystem_name = "bundlemanager"
@ -498,6 +498,11 @@ ohos_shared_library("installs") {
defines += [ "CODE_ENCRYPTION_ENABLE" ]
}
if (configpolicy_enable) {
external_deps += [ "config_policy:configpolicy_util" ]
defines += [ "CONFIG_POLOCY_ENABLE" ]
}
if (build_selinux) {
external_deps += [ "selinux_adapter:libhap_restorecon" ]
cflags += [ "-DWITH_SELINUX" ]

View File

@ -29,9 +29,9 @@ public:
};
static bool UninstallApplicationProcesses(
const std::string &bundleName, const int uid, bool isUpgradeApp = false);
static int IsRunning(const std::string bundleName, const int bundleUid);
static int IsRunning(const std::string bundleName);
const std::string &bundleName, const int uid, bool isUpgradeApp = false, int32_t appIndex = 0);
static int32_t IsRunning(const std::string &bundleName, const int bundleUid);
static int32_t IsRunning(const std::string &bundleName);
};
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -22,7 +22,7 @@ namespace OHOS {
namespace AppExecFwk {
class AccountHelper {
public:
static int IsOsAccountExists(const int id, bool &isOsAccountExists);
static int32_t IsOsAccountExists(const int32_t id, bool &isOsAccountExists);
static int32_t GetCurrentActiveUserId();

View File

@ -46,17 +46,17 @@ public:
void UpdateTotalDataBytesAfterUninstalled(const int64_t dataBytes)
{
tatalDataBytes_ -= dataBytes;
totalDataBytes_ -= dataBytes;
};
int64_t GetTotalDataBytes() const
{
return tatalDataBytes_;
return totalDataBytes_;
};
void SetTotalDataBytes(const int64_t allBundleDataBytes)
{
tatalDataBytes_ = allBundleDataBytes;
totalDataBytes_ = allBundleDataBytes;
};
void SetAgingCleanType(const AgingCleanType agingCleanType)
@ -85,7 +85,7 @@ private:
void InitAgingOneDayTimeMs();
std::vector<AgingBundleInfo> agingBundles_;
int64_t tatalDataBytes_ = 0;
int64_t totalDataBytes_ = 0;
AgingCleanType agingCleanType_ = AgingCleanType::CLEAN_CACHE;
static int64_t totalDataBytesThreshold_;

View File

@ -28,22 +28,16 @@
#include "nocopyable.h"
#include "serial_queue.h"
#ifdef PEND_SIGN_SCREENLOCK_MGR_ENABLED
#include "common_event_manager.h"
#include "common_event_support.h"
#include "iservice_registry.h"
#endif
namespace OHOS {
namespace AppExecFwk {
class AOTHandler final {
public:
static AOTHandler& GetInstance();
void HandleInstall(const std::unordered_map<std::string, InnerBundleInfo> &infos);
void HandleInstall(const std::unordered_map<std::string, InnerBundleInfo> &infos) const;
void HandleOTA();
void HandleIdle();
void HandleIdle() const;
ErrCode HandleCompile(const std::string &bundleName, const std::string &compileMode, bool isAllBundle,
std::vector<std::string> &compileResults);
std::vector<std::string> &compileResults) const;
void HandleResetAOT(const std::string &bundleName, bool isAllBundle) const;
ErrCode HandleCopyAp(const std::string &bundleName, bool isAllBundle, std::vector<std::string> &results) const;
private:
@ -59,25 +53,25 @@ private:
std::string GetArkProfilePath(const std::string &bundleName, const std::string &moduleName) const;
std::optional<AOTArgs> BuildAOTArgs(const InnerBundleInfo &info, const std::string &moduleName,
const std::string &compileMode, bool isEnanleBaselinePgo = false) const;
void HandleInstallWithSingleHap(const InnerBundleInfo &info, const std::string &compileMode);
void HandleInstallWithSingleHap(const InnerBundleInfo &info, const std::string &compileMode) const;
ErrCode HandleCompileWithSingleHap(const InnerBundleInfo &info, const std::string &moduleName,
const std::string &compileMode, bool isEnanleBaselinePgo = false);
const std::string &compileMode, bool isEnanleBaselinePgo = false) const;
EventInfo HandleCompileWithBundle(const std::string &bundleName, const std::string &compileMode,
std::shared_ptr<BundleDataMgr> dataMgr);
std::shared_ptr<BundleDataMgr> dataMgr) const;
ErrCode HandleCompileBundles(const std::vector<std::string> &bundleNames, const std::string &compileMode,
std::shared_ptr<BundleDataMgr> &dataMgr, std::vector<std::string> &compileResults);
std::shared_ptr<BundleDataMgr> &dataMgr, std::vector<std::string> &compileResults) const;
ErrCode HandleCompileModules(const std::vector<std::string> &moduleNames, const std::string &compileMode,
InnerBundleInfo &info, std::string &compileResult);
InnerBundleInfo &info, std::string &compileResult) const;
void ClearArkCacheDir() const;
void ResetAOTFlags() const;
void HandleIdleWithSingleHap(
const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode);
const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) const;
bool CheckDeviceState() const;
ErrCode AOTInternal(std::optional<AOTArgs> aotArgs, uint32_t versionCode);
ErrCode AOTInternal(std::optional<AOTArgs> aotArgs, uint32_t versionCode) const;
void HandleOTACompile();
void BeforeOTACompile();
void OTACompile();
void OTACompileInternal();
void OTACompile() const;
void OTACompileInternal() const;
bool GetOTACompileList(std::vector<std::string> &bundleNames) const;
bool GetUserBehaviourAppList(std::vector<std::string> &bundleNames, int32_t size) const;
bool IsOTACompileSwitchOn() const;
@ -88,35 +82,6 @@ private:
mutable std::mutex compileMutex_;
std::atomic<bool> OTACompileDeadline_ { false };
std::shared_ptr<SerialQueue> serialQueue_;
#ifdef PEND_SIGN_SCREENLOCK_MGR_ENABLED
public:
void RegisterScreenUnlockListener();
private:
bool StartPendingSignEvent();
bool ExecutePendingSign();
ErrCode FinishPendingSign();
bool WaitForCommonEventManager() const;
bool RegisterScreenUnlockEvent();
void UnregisterScreenUnlockEvent();
void FinishWaiting();
class UnlockEventSubscriber : public OHOS::EventFwk::CommonEventSubscriber {
public:
UnlockEventSubscriber(const OHOS::EventFwk::CommonEventSubscribeInfo &info) : CommonEventSubscriber(info) {}
~UnlockEventSubscriber() override = default;
void OnReceiveEvent(const OHOS::EventFwk::CommonEventData &event) override;
};
private:
struct PendingData {
uint32_t versionCode {0};
std::vector<uint8_t> signData;
};
mutable std::mutex unlockMutex_;
std::condition_variable unlockConVar_;
std::atomic<bool> hasUnlocked_ { false };
std::shared_ptr<UnlockEventSubscriber> unlockEventSubscriber_;
std::unordered_map<std::string, std::unordered_map<std::string, PendingData>> pendingSignData_;
#endif
};
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_BUNDLE_FRAMEWORK_AOT_AOT_SIGN_DATA_CACHE_MGR
#define FOUNDATION_BUNDLE_FRAMEWORK_AOT_AOT_SIGN_DATA_CACHE_MGR
#include <mutex>
#include <optional>
#include <string>
#include <unordered_map>
#include "aot/aot_args.h"
#include "bundle_mgr_service.h"
#include "common_event_manager.h"
#include "common_event_support.h"
#include "inner_bundle_info.h"
#include "iservice_registry.h"
#include "nocopyable.h"
namespace OHOS {
namespace AppExecFwk {
class AOTSignDataCacheMgr final {
public:
static AOTSignDataCacheMgr& GetInstance();
void RegisterScreenUnlockListener();
void AddPendSignData(const AOTArgs &aotArgs, const uint32_t versionCode,
const std::vector<uint8_t> &pendSignData, const ErrCode ret);
private:
AOTSignDataCacheMgr() = default;
~AOTSignDataCacheMgr() = default;
DISALLOW_COPY_AND_MOVE(AOTSignDataCacheMgr);
bool RegisterScreenUnlockEvent();
void UnregisterScreenUnlockEvent();
void HandleUnlockEvent();
ErrCode ExecutePendSign();
class UnlockEventSubscriber : public OHOS::EventFwk::CommonEventSubscriber {
public:
UnlockEventSubscriber(const OHOS::EventFwk::CommonEventSubscribeInfo &info) : CommonEventSubscriber(info) {}
~UnlockEventSubscriber() override = default;
void OnReceiveEvent(const OHOS::EventFwk::CommonEventData &event) override;
};
private:
struct PendingData {
uint32_t versionCode {0};
std::vector<uint8_t> signData;
};
mutable std::mutex mutex_;
std::atomic<bool> isLocked_ { true };
std::shared_ptr<UnlockEventSubscriber> unlockEventSubscriber_;
std::unordered_map<std::string, std::unordered_map<std::string, PendingData>> pendingSignData_;
};
} // namespace AppExecFwk
} // namespace OHOS
#endif // FOUNDATION_BUNDLE_FRAMEWORK_AOT_AOT_SIGN_DATA_CACHE_MGR

View File

@ -92,6 +92,7 @@ private:
void KillRunningApp(const std::vector<AppRunningControlRule> &rules, int32_t userId) const;
void DeleteAppRunningRuleCache(std::string &key);
void DeleteAbilityRunningRuleCache(std::string &key);
bool CheckCanDispose(const std::string &appId, int32_t userId);
bool isAppInstallControlEnabled_ = false;
std::shared_ptr<IAppControlManagerDb> appControlManagerDb_;
@ -101,6 +102,7 @@ private:
std::mutex appRunningControlMutex_;
std::unordered_map<std::string, std::vector<DisposedRule>> abilityRunningControlRuleCache_;
std::mutex abilityRunningControlRuleMutex_;
std::vector<std::string> noControllingList_;
};
} // AppExecFwk
} // OHOS

View File

@ -43,4 +43,4 @@ public:
};
} // namespace AppExecFwk
} // namespace OHOS
#endif // FOUNDATION_BUNDLE_FRAMEWORK_SERVICE_INCLUDE_APP_CONTROL_MANAGER_DB_INTERFACE_H
#endif // FOUNDATION_BUNDLE_FRAMEWORK_SERVICE_INCLUDE_APP_JUMP_INTERCEPTOR_MANAGER_DB_INTERFACE_H

View File

@ -512,8 +512,6 @@ private:
ErrCode CreateBundleCodeDir(InnerBundleInfo &info) const;
ErrCode CreateBundleDataDir(InnerBundleInfo &info) const;
ErrCode RemoveModuleDataDir(const InnerBundleInfo &info, const std::string &modulePackage,
int32_t userId) const;
ErrCode RemoveBundleCodeDir(const InnerBundleInfo &info) const;
ErrCode RemoveBundleDataDir(const InnerBundleInfo &info, bool forException = false) const;
void RemoveEmptyDirs(const std::unordered_map<std::string, InnerBundleInfo> &infos) const;
@ -552,7 +550,7 @@ private:
void MarkPreInstallState(const std::string &bundleName, bool isUninstalled);
ErrCode UninstallAllSandboxApps(const std::string &bundleName, int32_t userId = Constants::INVALID_USERID);
ErrCode CheckAppLabel(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo) const;
ErrCode CheckDebugType(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo) const;
bool CheckReleaseTypeIsCompatible(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo) const;
ErrCode CheckMaxCountForClone(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo) const;
void SendBundleSystemEvent(const std::string &bundleName, BundleEventType bundleEventType,
const InstallParam &installParam, InstallScene preBundleScene, ErrCode errCode);
@ -639,7 +637,7 @@ private:
ErrCode CreateGroupDirs() const;
void CreateDataGroupDir(InnerBundleInfo &info) const;
ErrCode GetDataGroupCreateInfos(const InnerBundleInfo &newInfo);
ErrCode RemoveDataGroupDirs(const std::string &bundleName, int32_t userId) const;
ErrCode RemoveDataGroupDirs(const std::string &bundleName, int32_t userId, bool isKeepData = false) const;
void DeleteGroupDirsForException() const;
ErrCode CreateDataGroupDirs(
const std::unordered_map<std::string, InnerBundleInfo> &newInfos, const InnerBundleInfo &oldInfo);
@ -682,6 +680,8 @@ private:
#ifdef APP_DOMAIN_VERIFY_ENABLED
void PrepareSkillUri(const std::vector<Skill> &skills, std::vector<AppDomainVerify::SkillUri> &skillUris) const;
#endif
void PrepareBundleDirQuota(const std::string &bundleName, const int32_t uid,
const std::string &bundleDataDirPath, const int32_t limitSize) const;
void VerifyDomain();
void ClearDomainVerifyStatus(const std::string &appIdentifier, const std::string &bundleName) const;
ErrCode CreateShaderCache(const std::string &bundleName, int32_t uid, int32_t gid) const;
@ -702,6 +702,9 @@ private:
void RemoveCreatedExtensionDirsForException() const;
void RemoveOldExtensionDirs() const;
ErrCode InnerProcessUpdateHapToken(const bool isOldSystemApp);
std::string GetInstallSource(const InstallParam &installParam) const;
void SetInstallSourceToAppInfo(std::unordered_map<std::string, InnerBundleInfo> &infos,
const InstallParam &installParam) const;
InstallerState state_ = InstallerState::INSTALL_START;
std::shared_ptr<BundleDataMgr> dataMgr_ = nullptr; // this pointer will get when public functions called

View File

@ -65,6 +65,7 @@ struct NotifyBundleEvents {
int32_t appIndex = 0;
int32_t bundleType = 0;
int32_t atomicServiceModuleUpgrade = 0;
bool isApplicationEnabled = true;
};
class BundleCommonEventMgr {

View File

@ -1028,7 +1028,7 @@ private:
void CompatibleOldBundleStateInKvDb();
void ResetBundleStateData();
bool QueryAbilityInfoWithFlags(const std::optional<AbilityInfo> &option, int32_t flags, int32_t userId,
const InnerBundleInfo &innerBundleInfo, AbilityInfo &info) const;
const InnerBundleInfo &innerBundleInfo, AbilityInfo &info, int32_t appIndex = 0) const;
ErrCode QueryAbilityInfoWithFlagsV9(const std::optional<AbilityInfo> &option, int32_t flags, int32_t userId,
const InnerBundleInfo &innerBundleInfo, AbilityInfo &info,
int32_t appIndex = 0) const;
@ -1097,6 +1097,12 @@ private:
void GetBundleNameAndIndexByName(const std::string &keyName, std::string &bundleName, int32_t &appIndex) const;
void GetCloneAbilityInfos(std::vector<AbilityInfo> &abilityInfos,
const ElementName &element, int32_t flags, int32_t userId) const;
void GetCloneAbilityInfosV9(std::vector<AbilityInfo> &abilityInfos,
const ElementName &element, int32_t flags, int32_t userId) const;
ErrCode ExplicitQueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t userId,
int32_t appIndex, AbilityInfo &abilityInfo) const;
ErrCode ExplicitQueryCloneAbilityInfoV9(const ElementName &element, int32_t flags, int32_t userId,
int32_t appIndex, AbilityInfo &abilityInfo) const;
void ImplicitQueryCloneAbilityInfos(
const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) const;
bool ImplicitQueryCurCloneAbilityInfos(const Want &want, int32_t flags, int32_t userId,

View File

@ -75,6 +75,7 @@ enum class InstalldInterfaceCode : uint32_t {
CREATE_EXTENSION_DATA_DIR,
GET_DISK_USAGE,
PEND_SIGN_AOT,
GET_EXTENSION_SANDBOX_TYPE_LIST
};
} // namespace AppExecFwk

View File

@ -240,6 +240,7 @@ private:
bool CheckProxyPermissionLevel(const std::string &permissionName) const;
bool MatchOldSignatures(const std::string &bundleName, const std::vector<std::string> &appSignatures);
bool CheckProvisionInfoIsValid(const std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes);
std::string GetValidReleaseType(const std::unordered_map<std::string, InnerBundleInfo> &infos);
std::string checkResultMsg_ = "";
};

View File

@ -499,19 +499,21 @@ public:
* @param bundleName Indicates the bundle name of the application whose cache data is to be cleared.
* @param cleanCacheCallback Indicates the callback to be invoked for returning the operation result.
* @param userId description the user id.
* @param appIndex Indicates the app index.
* @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise.
*/
virtual ErrCode CleanBundleCacheFiles(
const std::string &bundleName, const sptr<ICleanCacheCallback> cleanCacheCallback,
int32_t userId = Constants::UNSPECIFIED_USERID) override;
int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0) override;
/**
* @brief Clears application running data of a specified application.
* @param bundleName Indicates the bundle name of the application whose data is to be cleared.
* @param userId Indicates the user id.
* @param appIndex Indicates the app index.
* @return Returns true if the data cleared successfully; returns false otherwise.
*/
virtual bool CleanBundleDataFiles(const std::string &bundleName,
const int userId = Constants::UNSPECIFIED_USERID) override;
const int userId = Constants::UNSPECIFIED_USERID, const int appIndex = 0) override;
/**
* @brief Register the specific bundle status callback.
* @param bundleStatusCallback Indicates the callback to be invoked for returning the bundle status changed result.
@ -1015,7 +1017,7 @@ private:
std::set<int32_t> GetExistsCommonUserIs();
bool VerifyDependency(const std::string &sharedBundleName);
void CleanBundleCacheTask(const std::string &bundleName, const sptr<ICleanCacheCallback> cleanCacheCallback,
const std::shared_ptr<BundleDataMgr> &dataMgr, int32_t userId);
const std::shared_ptr<BundleDataMgr> &dataMgr, int32_t userId, int32_t appIndex = 0);
ErrCode CleanBundleCacheFilesGetCleanSize(const std::string &bundleName,
int32_t userId, uint64_t &cleanCacheSize);
void CleanBundleCacheTaskGetCleanSize(const std::string &bundleName,
@ -1031,6 +1033,8 @@ private:
int32_t userId);
void FilterAbilityInfos(std::vector<AbilityInfo> &abilityInfos);
void SetProvisionInfoToInnerBundleInfo(const std::string &hapPath, InnerBundleInfo &info);
bool CheckAppIndex(const std::string &bundleName, int32_t userId, int32_t appIndex);
bool CheckCanSetEnable(const std::string &bundleName);
std::atomic<bool> isBrokerServiceExisted_ = false;
};

View File

@ -28,6 +28,8 @@
namespace OHOS {
namespace AppExecFwk {
class BundleParser {
private:
bool CheckRouterData(nlohmann::json data) const;
public:
static bool ReadFileIntoJson(const std::string &filePath, nlohmann::json &jsonBuf);
/**
@ -100,6 +102,8 @@ public:
*/
ErrCode ParseRouterArray(
const std::string &configFile, std::vector<RouterItem> &routerArray) const;
static ErrCode ParseNoDisablingList(const std::string &configPath, std::vector<std::string> &noDisablingList);
};
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -29,7 +29,7 @@ public:
~BundleResourceCallback() = default;
// for userId switched
bool OnUserIdSwitched(const int32_t userId,
bool OnUserIdSwitched(const int32_t oldUserId, const int32_t newUserId,
const uint32_t type = static_cast<uint32_t>(BundleResourceChangeType::SYSTEM_USER_ID_CHANGE));
// for colorMode changed

View File

@ -35,6 +35,12 @@ public:
std::shared_ptr<Global::Resource::ResourceManager> resourceManager,
ResourceInfo &resourceInfo);
bool GetIconResourceByDrawableNoTheme(
const uint32_t iconId,
const int32_t density,
std::shared_ptr<Global::Resource::ResourceManager> resourceManager,
ResourceInfo &resourceInfo);
#ifdef BUNDLE_FRAMEWORK_GRAPHICS
bool GetBadgedIconResource(
const std::shared_ptr<Media::PixelMap> layeredPixelMap,

View File

@ -21,6 +21,7 @@
#include <string>
#include <vector>
#include "bundle_constants.h"
#include "bundle_resource_change_type.h"
#include "bundle_resource_rdb.h"
#include "bundle_system_state.h"
@ -47,7 +48,8 @@ public:
* add all resource info in system, used when system configuration changed, like:
* language, colorMode, theme, and so on
*/
bool AddAllResourceInfo(const int32_t userId, const uint32_t type);
bool AddAllResourceInfo(const int32_t userId, const uint32_t type,
const int32_t oldUserId = Constants::INVALID_USERID);
/**
* delete all resource info
*/
@ -93,11 +95,11 @@ private:
bool AddResourceInfos(std::vector<ResourceInfo> &resourceInfos);
bool AddResourceInfosByMap(std::map<std::string, std::vector<ResourceInfo>> &resourceInfosMap,
const uint32_t tempTaskNumber, const uint32_t type, const int32_t userId);
const uint32_t tempTaskNumber, const uint32_t type, const int32_t userId, const int32_t oldUserId);
void InnerProcessResourceInfoByResourceUpdateType(
std::map<std::string, std::vector<ResourceInfo>> &resourceInfosMap, const uint32_t type,
const int32_t userId, bool &needDeleteAllResource);
const int32_t userId, const int32_t oldUserId, bool &needDeleteAllResource);
void ProcessResourceInfoWhenParseFailed(ResourceInfo &resourceInfo);
@ -119,13 +121,21 @@ private:
void InnerProcessResourceInfoByUserIdChanged(
std::map<std::string, std::vector<ResourceInfo>> &resourceInfosMap,
const int32_t userId, bool &needDeleteAllResource);
const int32_t userId, const int32_t oldUserId, bool &needDeleteAllResource);
void DeleteNotExistResourceInfo(const std::map<std::string, std::vector<ResourceInfo>> &resourceInfosMap,
const std::vector<std::string> &existResourceNames);
bool InnerProcessWhetherThemeExist(const std::string &bundleName, const int32_t userId);
bool GetBundleResourceInfoForCloneBundle(const std::string &bundleName,
const int32_t appIndex, std::vector<ResourceInfo> &resourceInfos);
bool UpdateCloneBundleResourceInfo(const std::string &bundleName, const int32_t appIndex, const uint32_t type);
void DeleteNotExistResourceInfo(const std::string &bundleName,
const int32_t appIndex, const std::vector<ResourceInfo> &resourceInfos);
std::shared_ptr<BundleResourceRdb> bundleResourceRdb_;
std::mutex mutex_;
std::atomic_uint currentTaskNum_ = 0;

View File

@ -68,10 +68,7 @@ private:
bool GetMediaDataById(const std::shared_ptr<Global::Resource::ResourceManager> resourceManager,
const uint32_t iconId, const int32_t density, std::vector<uint8_t> &data);
bool ParseThemeIcon(const std::shared_ptr<Global::Resource::ResourceManager> resourceManager,
const int32_t density, ResourceInfo &resourceInfo);
void ProcessResourceInfoWhenParseFailed(const ResourceInfo &oldResourceInfo, ResourceInfo &newResourceInfo);
bool IsNeedToParseResourceInfo(const ResourceInfo &newResourceInfo, const ResourceInfo &oldResourceInfo);
};
} // AppExecFwk
} // OHOS

View File

@ -162,6 +162,10 @@ constexpr int32_t CLONE_APP_INDEX_MAX = 5;
constexpr const char* SHADER_CACHE_PATH = "/data/local/shader_cache/local/";
constexpr const char* CLOUD_SHADER_PATH = "/data/local/shader_cache/cloud/";
constexpr const char* CLOUD_SHADER_OWNER = "const.appgallery.shaderowner.bundlename";
// apiReleaseType
const std::string API_RELEASE_TYPE_RELEASE = "Release";
const std::string API_RELEASE_TYPE_BETA = "Beta";
const std::string API_RELEASE_TYPE_CANARY = "Canary";
} // namespace ServiceConstants
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -186,6 +186,8 @@ public:
static void RecursiveHash(std::string& s);
static std::string ExtractGroupIdByDevelopId(const std::string &developerId);
static std::string ToString(const std::vector<std::string> &vector);
static std::string GenerateUuidByKey(const std::string &key);
static std::string GetNoDisablingConfigPath();
private:
static std::mutex g_mutex;
};

View File

@ -219,6 +219,16 @@ public:
*/
static void SendCleanCacheSysEvent(
const std::string &bundleName, int32_t userId, bool isCleanCache, bool exception);
/**
* @brief Send clean cache system events.
* @param bundleName Indicates the bundleName.
* @param userId Indicates the userId.
* @param appIndex Indicates the appIndex.
* @param isCleanCache Indicates the isCleanCache.
* @param exception Indicates the exception.
*/
static void SendCleanCacheSysEventWithIndex(
const std::string &bundleName, int32_t userId, int32_t appIndex, bool isCleanCache, bool exception);
/**
* @brief Send system events.
* @param eventType Indicates the bms eventInfo.

View File

@ -544,6 +544,8 @@ public:
bool HasEntry() const;
bool IsReleaseHsp() const;
void InsertFormInfos(const std::string &keyName, const std::vector<FormInfo> &formInfos)
{
formInfos_.emplace(keyName, formInfos);
@ -910,9 +912,15 @@ public:
return baseApplicationInfo_->multiAppMode.multiAppModeType;
}
void SetInstallSource(const std::string &installSource)
{
baseApplicationInfo_->installSource = installSource;
}
void UpdateExtensionSandboxInfo(const std::vector<std::string> &typeList);
std::vector<std::string> GetAllExtensionDirsInSpecifiedModule(const std::string &moduleName) const;
std::vector<std::string> GetAllExtensionDirs() const;
void UpdateExtensionDataGroupInfo(const std::string &key, const std::vector<std::string>& dataGroupIds);
void UpdateExtensionDataGroupInfo(const std::string &key, const std::vector<std::string> &dataGroupIds);
void SetAppDistributionType(const std::string &appDistributionType);
std::string GetAppDistributionType() const;
void SetAppProvisionType(const std::string &appProvisionType);
@ -999,6 +1007,7 @@ public:
bool GetUninstallState() const;
void SetUninstallState(const bool &uninstallState);
void UpdateMultiAppMode(const InnerBundleInfo &newInfo);
void UpdateReleaseType(const InnerBundleInfo &newInfo);
ErrCode AddCloneBundle(const InnerBundleCloneInfo &attr);
ErrCode RemoveCloneBundle(const int32_t userId, const int32_t appIndex);
ErrCode GetAvailableCloneAppIndex(const int32_t userId, int32_t &appIndex);
@ -1009,6 +1018,8 @@ public:
BundleInfo &bundleInfo) const;
ErrCode VerifyAndAckCloneAppIndex(int32_t userId, int32_t &appIndex);
void SetkeyId(const int32_t userId, const std::string &keyId);
void AdaptMainLauncherResourceInfo(ApplicationInfo &applicationInfo) const;
private:
bool IsExistLauncherAbility() const;
void GetBundleWithAbilities(

View File

@ -20,6 +20,7 @@
#include "code_sign_helper.h"
#include "ipc/installd_host.h"
#include "installd/installd_operator.h"
#include "nlohmann/json.hpp"
namespace OHOS {
namespace AppExecFwk {
@ -121,9 +122,11 @@ public:
* @brief Clean a bundle data directory.
* @param bundleName Indicates the bundleName data directory path that to be cleaned.
* @param userid Indicates userid to be set to the directory.
* @param appIndex Indicates app index to be set to the directory.
* @return Returns ERR_OK if the bundle data directory cleaned successfully; returns error code otherwise.
*/
virtual ErrCode CleanBundleDataDirByName(const std::string &bundleName, const int userid) override;
virtual ErrCode CleanBundleDataDirByName(const std::string &bundleName, const int userid,
const int appIndex = 0) override;
/**
* @brief Get bundle Stats.
* @param bundleName Indicates the bundle name.
@ -225,6 +228,8 @@ public:
virtual ErrCode CreateExtensionDataDir(const CreateDirParam &createDirParam) override;
virtual ErrCode GetExtensionSandboxTypeList(std::vector<std::string> &typeList) override;
private:
ErrCode CreateExtensionDir(const CreateDirParam &createDirParam, const std::string& parentDir,
int32_t mode, int32_t gid, bool isLog = false);
@ -240,6 +245,10 @@ private:
const int32_t userId, const int32_t appIndex);
int64_t HandleAppDataSizeStats(const std::string &bundleName,
const int32_t userId, const int32_t appIndex, std::vector<std::string> &cachePath);
std::string GetExtensionConfigPath() const;
void LoadNeedCreateSandbox(const nlohmann::json &object, std::vector<std::string> &typeList);
bool LoadExtensionNeedCreateSandbox(const nlohmann::json &object, std::string extensionTypeName);
bool ReadFileIntoJson(const std::string &filePath, nlohmann::json &jsonBuf);
};
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -101,9 +101,10 @@ public:
* @brief Clean a bundle data directory.
* @param bundleName Indicates the bundleName data directory path that to be cleaned.
* @param userid Indicates userid to be set to the directory.
* @param appIndex Indicates app index to be set to the directory.
* @return Returns ERR_OK if the bundle data directory cleaned successfully; returns error code otherwise.
*/
ErrCode CleanBundleDataDirByName(const std::string &bundleName, const int userid);
ErrCode CleanBundleDataDirByName(const std::string &bundleName, const int userid, const int appIndex = 0);
/**
* @brief Get bundle Stats.
* @param bundleName Indicates the bundle name.
@ -228,6 +229,8 @@ public:
ErrCode CreateExtensionDataDir(const CreateDirParam &createDirParam);
ErrCode GetExtensionSandboxTypeList(std::vector<std::string> &typeList);
private:
/**
* @brief Get the installd proxy object.

View File

@ -214,6 +214,8 @@ private:
bool HandleCreateExtensionDataDir(MessageParcel &data, MessageParcel &reply);
bool HandleGetExtensionSandboxTypeList(MessageParcel &data, MessageParcel &reply);
void AddCloseInstalldTask();
void RemoveCloseInstalldTask();

View File

@ -179,9 +179,10 @@ public:
* @brief Clean a bundle data directory.
* @param bundleName Indicates the bundleName data directory path that to be cleaned.
* @param userid Indicates userid to be set to the directory.
* @param appIndex Indicates userid to be set to the directory.
* @return Returns ERR_OK if the bundle data directory cleaned successfully; returns error code otherwise.
*/
virtual ErrCode CleanBundleDataDirByName(const std::string &bundleName, const int userid)
virtual ErrCode CleanBundleDataDirByName(const std::string &bundleName, const int userid, const int appIndex = 0)
{
return ERR_OK;
}
@ -409,6 +410,11 @@ public:
{
return ERR_OK;
}
virtual ErrCode GetExtensionSandboxTypeList(std::vector<std::string> &typeList)
{
return ERR_OK;
}
};
#define INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(parcel, token) \

View File

@ -123,9 +123,11 @@ public:
* @brief Clean a bundle data directory through a proxy object.
* @param bundleName Indicates the bundleName data directory path that to be cleaned.
* @param userid Indicates userid to be set to the directory.
* @param appIndex Indicates app index to be set to the directory.
* @return Returns ERR_OK if the bundle data directory cleaned successfully; returns error code otherwise.
*/
virtual ErrCode CleanBundleDataDirByName(const std::string &bundleName, const int userid) override;
virtual ErrCode CleanBundleDataDirByName(const std::string &bundleName, const int userid,
const int appIndex = 0) override;
/**
* @brief Get bundle Stats.
* @param bundleName Indicates the bundle name.
@ -223,6 +225,8 @@ public:
virtual ErrCode CreateExtensionDataDir(const CreateDirParam &createDirParam) override;
virtual ErrCode GetExtensionSandboxTypeList(std::vector<std::string> &typeList) override;
private:
ErrCode TransactInstalldCmd(InstalldInterfaceCode code, MessageParcel &data, MessageParcel &reply,
MessageOption &option);

View File

@ -33,7 +33,7 @@ public:
std::vector<std::string> buildMeta;
std::string raw;
explicit SemVer(std::string version_string);
explicit SemVer(std::string versionString);
};
} // AppExecFwk
} // OHOS

View File

@ -48,10 +48,14 @@ public:
std::shared_ptr<NativeRdb::ResultSet> QueryByStep(
const NativeRdb::AbsRdbPredicates &absRdbPredicates);
bool UpdateOrInsertData(
const NativeRdb::ValuesBucket &valuesBucket, const NativeRdb::AbsRdbPredicates &absRdbPredicates);
private:
std::shared_ptr<NativeRdb::RdbStore> GetRdbStore();
std::mutex rdbMutex_;
std::shared_ptr<NativeRdb::RdbStore> rdbStore_;
bool isInitial_ = false;
BmsRdbConfig bmsRdbConfig_;
};

View File

@ -51,9 +51,9 @@ public:
* @param uid uid of bundle.
* @return Returns ERR_OK on success, others on failure.
*/
static int UninstallApp(const std::string &bundleName, int32_t uid);
static int UninstallApp(const std::string &bundleName, int32_t uid, int32_t appIndex);
static int UpgradeApp(const std::string &bundleName, int32_t uid);
static int UpgradeApp(const std::string &bundleName, int32_t uid, int32_t appIndex);
static bool UnloadSystemAbility(const int32_t systemAbilityId);
};

View File

@ -30,19 +30,19 @@
namespace OHOS {
namespace AppExecFwk {
bool AbilityManagerHelper::UninstallApplicationProcesses(
const std::string &bundleName, const int uid, bool isUpgradeApp)
const std::string &bundleName, const int uid, bool isUpgradeApp, int32_t appIndex)
{
#ifdef ABILITY_RUNTIME_ENABLE
APP_LOGI("uninstall kill running processes, app name is %{public}s, isUpgradeApp : %{public}d",
bundleName.c_str(), isUpgradeApp);
int ret = 0;
if (isUpgradeApp) {
ret = SystemAbilityHelper::UpgradeApp(bundleName, uid);
ret = SystemAbilityHelper::UpgradeApp(bundleName, uid, appIndex);
} else {
ret = SystemAbilityHelper::UninstallApp(bundleName, uid);
ret = SystemAbilityHelper::UninstallApp(bundleName, uid, appIndex);
}
if (ret != 0) {
APP_LOGE("kill application process failed uid : %{public}d", uid);
APP_LOGE("kill application process failed uid: %{public}d, appIndex: %{public}d", uid, appIndex);
return false;
}
return true;
@ -52,26 +52,26 @@ bool AbilityManagerHelper::UninstallApplicationProcesses(
#endif
}
int AbilityManagerHelper::IsRunning(const std::string bundleName, const int bundleUid)
int32_t AbilityManagerHelper::IsRunning(const std::string &bundleName, const int bundleUid)
{
#ifdef BUNDLE_FRAMEWORK_FREE_INSTALL
APP_LOGI("check app is running, app name is %{public}s", bundleName.c_str());
if (bundleUid < 0) {
APP_LOGE("bundleUid is error.");
return FAILED;
}
sptr<IAppMgr> appMgrProxy = iface_cast<IAppMgr>(SystemAbilityHelper::GetSystemAbility(APP_MGR_SERVICE_ID));
if (appMgrProxy == nullptr) {
APP_LOGE("fail to find the app mgr service to check app is running");
return FAILED;
}
if (bundleUid < 0) {
APP_LOGE("bundleUid is error.");
return FAILED;
}
std::vector<RunningProcessInfo> runningList;
int result = appMgrProxy->GetAllRunningProcesses(runningList);
if (result != ERR_OK) {
APP_LOGE("GetAllRunningProcesses failed.");
return FAILED;
}
for (RunningProcessInfo info : runningList) {
for (const RunningProcessInfo &info : runningList) {
if (info.uid_ == bundleUid) {
auto res = std::any_of(info.bundleNames.begin(), info.bundleNames.end(),
[bundleName](const auto &bundleNameInRunningProcessInfo) {
@ -90,7 +90,7 @@ int AbilityManagerHelper::IsRunning(const std::string bundleName, const int bund
#endif
}
int AbilityManagerHelper::IsRunning(const std::string bundleName)
int32_t AbilityManagerHelper::IsRunning(const std::string &bundleName)
{
#ifdef BUNDLE_FRAMEWORK_FREE_INSTALL
APP_LOGD("check app is running, app name is %{public}s", bundleName.c_str());

View File

@ -26,7 +26,7 @@
namespace OHOS {
namespace AppExecFwk {
int AccountHelper::IsOsAccountExists(const int id, bool &isOsAccountExists)
int32_t AccountHelper::IsOsAccountExists(const int32_t id, bool &isOsAccountExists)
{
#ifdef ACCOUNT_ENABLE
return AccountSA::OsAccountManager::IsOsAccountCompleted(id, isOsAccountExists);

View File

@ -57,6 +57,7 @@ void AgingRequest::InitAgingDatasizeThreshold()
APP_LOGD("AgingRequest init aging data size threshold success");
}
}
void AgingRequest::InitAgingOneDayTimeMs()
{
char szOneDayTimeMs[AgingConstants::THRESHOLD_VAL_LEN] = {0};
@ -82,16 +83,16 @@ void AgingRequest::InitAgingPolicySystemParameters()
bool AgingRequest::IsReachStartAgingThreshold() const
{
APP_LOGD("tatalDataBytes: %{public}" PRId64 ", totalDataBytesThreshold: %{public}" PRId64,
tatalDataBytes_, totalDataBytesThreshold_);
return tatalDataBytes_ > totalDataBytesThreshold_;
APP_LOGD("totalDataBytes: %{public}" PRId64 ", totalDataBytesThreshold: %{public}" PRId64,
totalDataBytes_, totalDataBytesThreshold_);
return totalDataBytes_ > totalDataBytesThreshold_;
}
bool AgingRequest::IsReachEndAgingThreshold() const
{
APP_LOGD("tatalDataBytes: %{public}" PRId64 ", totalDataBytesThreshold: %{public}" PRId64,
tatalDataBytes_, totalDataBytesThreshold_);
return tatalDataBytes_ < (int64_t)(totalDataBytesThreshold_ * AgingConstants::AGING_SIZE_RATIO);
APP_LOGD("totalDataBytes: %{public}" PRId64 ", totalDataBytesThreshold: %{public}" PRId64,
totalDataBytes_, totalDataBytesThreshold_);
return totalDataBytes_ < (int64_t)(totalDataBytesThreshold_ * AgingConstants::AGING_SIZE_RATIO);
}
void AgingRequest::AddAgingBundle(AgingBundleInfo &bundleInfo)
@ -103,7 +104,7 @@ void AgingRequest::ResetRequest()
{
agingBundles_.clear();
agingCleanType_ = AgingCleanType::CLEAN_CACHE;
tatalDataBytes_ = 0;
totalDataBytes_ = 0;
}
void AgingRequest::Dump()

View File

@ -147,7 +147,7 @@ bool RecentlyUnuseBundleAgingHandler::CleanCache(const AgingBundleInfo &agingBun
APP_LOGD("cache path: %{public}s", cache.c_str());
ErrCode ret = InstalldClient::GetInstance()->CleanBundleDataDir(cache);
if (ret != ERR_OK) {
APP_LOGE("CleanBundleDataDir failed, path: %{private}s", cache.c_str());
APP_LOGE("CleanBundleDataDir failed, path %{private}s", cache.c_str());
continue;
}
@ -170,7 +170,7 @@ bool RecentlyUnuseBundleAgingHandler::GetCachePath(
std::vector<InnerBundleUserInfo> innerBundleUserInfos;
if (!dataMgr->GetInnerBundleUserInfos(agingBundle.GetBundleName(), innerBundleUserInfos)) {
APP_LOGE("GetInnerBundleUserInfos failed bundle: %{public}s",
APP_LOGE("GetInnerBundleUserInfos failed bundle %{public}s",
agingBundle.GetBundleName().c_str());
return false;
}
@ -190,7 +190,7 @@ bool RecentlyUnuseBundleAgingHandler::GetCachePath(
for (const auto &st : rootDir) {
std::vector<std::string> cache;
if (InstalldClient::GetInstance()->GetBundleCachePath(st, cache) != ERR_OK) {
APP_LOGW("GetBundleCachePath failed, path: %{public}s", st.c_str());
APP_LOGW("GetBundleCachePath failed, path %{public}s", st.c_str());
continue;
}

View File

@ -151,7 +151,7 @@ nlohmann::json AOTExecutor::GetSubjectInfo(const AOTArgs &aotArgs) const
void AOTExecutor::MapArgs(const AOTArgs &aotArgs, std::unordered_map<std::string, std::string> &argsMap)
{
APP_LOGI("ExecuteInCompilerServiceProcess, args : %{public}s", aotArgs.ToString().c_str());
APP_LOGI("ExecuteInCompilerServiceProcess, args %{public}s", aotArgs.ToString().c_str());
nlohmann::json subject = GetSubjectInfo(aotArgs);
nlohmann::json objectArray = nlohmann::json::array();

View File

@ -21,6 +21,9 @@
#include <vector>
#include "account_helper.h"
#ifdef CODE_SIGNATURE_ENABLE
#include "aot/aot_sign_data_cache_mgr.h"
#endif
#include "appexecfwk_errors.h"
#include "app_log_wrapper.h"
#include "bundle_constants.h"
@ -34,11 +37,6 @@
#include "display_power_mgr_client.h"
#endif
#ifdef PEND_SIGN_SCREENLOCK_MGR_ENABLED
#include "datetime_ex.h"
#include "screenlock_manager.h"
#endif
namespace OHOS {
namespace AppExecFwk {
namespace {
@ -60,7 +58,7 @@ constexpr const char* OTA_COMPILE_SWITCH_DEFAULT = "off";
const std::string OTA_COMPILE_SWITCH_ON = "on";
constexpr const char* OTA_COMPILE_TIME = "persist.bms.optimizing_apps.timing";
constexpr int32_t OTA_COMPILE_TIME_DEFAULT = 5 * 60; // 5min
constexpr int32_t OTA_COMPILE_TIME_DEFAULT = 4 * 60; // 4min
constexpr int32_t GAP_SECONDS = 10;
constexpr const char* OTA_COMPILE_COUNT_MANUAL = "persist.bms.optimizing_apps.counts.manual";
@ -89,14 +87,6 @@ constexpr const char* COMPILE_NONE = "none";
constexpr const char* USER_STATUS_SO_NAME = "libuser_status_client.z.so";
constexpr const char* USER_STATUS_FUNC_NAME = "GetUserPreferenceApp";
#ifdef PEND_SIGN_SCREENLOCK_MGR_ENABLED
constexpr int32_t SLEEP_TIME_FOR_COMMON_EVENT_MGR = 500 * 1000; // 500 ms
constexpr int32_t SLEEP_TIME_FOR_COMMON_EVENT_MGR_TIME_OUT = 10 * 60; // 10 min
constexpr int32_t COMMON_EVENT_MANAGER_ID = 3299;
constexpr int32_t SLEEP_TIME_FOR_WAIT_SIGN_ENABLE = 1; // 1 s
constexpr int32_t LOOP_TIMES_FOR_WAIT_SIGN_ENABLE = 5;
#endif
}
AOTHandler::AOTHandler()
@ -207,7 +197,7 @@ std::optional<AOTArgs> AOTHandler::BuildAOTArgs(const InnerBundleInfo &info, con
return aotArgs;
}
ErrCode AOTHandler::AOTInternal(std::optional<AOTArgs> aotArgs, uint32_t versionCode)
ErrCode AOTHandler::AOTInternal(std::optional<AOTArgs> aotArgs, uint32_t versionCode) const
{
if (!aotArgs) {
APP_LOGD("aotArgs empty");
@ -220,14 +210,8 @@ ErrCode AOTHandler::AOTInternal(std::optional<AOTArgs> aotArgs, uint32_t version
ret = InstalldClient::GetInstance()->ExecuteAOT(*aotArgs, pendSignData);
}
APP_LOGI("ExecuteAOT ret : %{public}d", ret);
#ifdef PEND_SIGN_SCREENLOCK_MGR_ENABLED
if (!hasUnlocked_ && !pendSignData.empty()) {
PendingData pendingData = {versionCode, pendSignData};
{
std::lock_guard<std::mutex> lock(unlockMutex_);
pendingSignData_[aotArgs->bundleName][aotArgs->moduleName] = pendingData;
}
}
#ifdef CODE_SIGNATURE_ENABLE
AOTSignDataCacheMgr::GetInstance().AddPendSignData(*aotArgs, versionCode, pendSignData, ret);
#endif
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr) {
@ -239,13 +223,13 @@ ErrCode AOTHandler::AOTInternal(std::optional<AOTArgs> aotArgs, uint32_t version
return ret;
}
void AOTHandler::HandleInstallWithSingleHap(const InnerBundleInfo &info, const std::string &compileMode)
void AOTHandler::HandleInstallWithSingleHap(const InnerBundleInfo &info, const std::string &compileMode) const
{
std::optional<AOTArgs> aotArgs = BuildAOTArgs(info, info.GetCurrentModulePackage(), compileMode, true);
(void)AOTInternal(aotArgs, info.GetVersionCode());
}
void AOTHandler::HandleInstall(const std::unordered_map<std::string, InnerBundleInfo> &infos)
void AOTHandler::HandleInstall(const std::unordered_map<std::string, InnerBundleInfo> &infos) const
{
auto task = [this, infos]() {
APP_LOGD("HandleInstall begin");
@ -314,7 +298,7 @@ ErrCode AOTHandler::MkApDestDirIfNotExist() const
bool isDirExist = false;
errCode = InstalldClient::GetInstance()->IsExistDir(COPY_AP_DEST_PATH, isDirExist);
if (errCode != ERR_OK) {
APP_LOGE("check if dir exist failed, error is %{public}d", errCode);
APP_LOGE("check if dir exist failed, err %{public}d", errCode);
}
if (isDirExist) {
APP_LOGI("Copy ap path is exist");
@ -324,7 +308,7 @@ ErrCode AOTHandler::MkApDestDirIfNotExist() const
errCode = InstalldClient::GetInstance()->Mkdir(
COPY_AP_DEST_PATH, mode, Constants::FOUNDATION_UID, ServiceConstants::SHELL_UID);
if (errCode != ERR_OK) {
APP_LOGE("fail to create dir, error is %{public}d", errCode);
APP_LOGE("fail create dir err %{public}d", errCode);
return errCode;
}
APP_LOGI("MkApDestDir path success");
@ -420,7 +404,7 @@ void AOTHandler::CopyApWithBundle(const std::string &bundleName, const BundleInf
result.append(sourceAp);
errCode = InstalldClient::GetInstance()->CopyFile(sourceAp, destAp);
if (errCode != ERR_OK) {
APP_LOGE("Copy ap dir %{public}s failed! error is %{public}d", sourceAp.c_str(), errCode);
APP_LOGE("Copy ap dir %{public}s failed err %{public}d", sourceAp.c_str(), errCode);
result.append(" copy ap failed!");
continue;
}
@ -468,12 +452,12 @@ void AOTHandler::BeforeOTACompile()
{
OTACompileDeadline_ = false;
int32_t limitSeconds = system::GetIntParameter<int32_t>(OTA_COMPILE_TIME, OTA_COMPILE_TIME_DEFAULT);
APP_LOGI("OTA compile time limit seconds : %{public}d", limitSeconds);
APP_LOGI("OTA compile time limit seconds %{public}d", limitSeconds);
auto task = [this]() {
APP_LOGI("compile timer end");
OTACompileDeadline_ = true;
ErrCode ret = InstalldClient::GetInstance()->StopAOT();
APP_LOGI("StopAOT ret : %{public}d", ret);
APP_LOGI("StopAOT ret %{public}d", ret);
};
int32_t delayTimeSeconds = limitSeconds - GAP_SECONDS;
if (delayTimeSeconds < 0) {
@ -482,7 +466,7 @@ void AOTHandler::BeforeOTACompile()
serialQueue_->ScheduleDelayTask(TASK_NAME, delayTimeSeconds * CONVERSION_FACTOR, task);
}
void AOTHandler::OTACompile()
void AOTHandler::OTACompile() const
{
auto OTACompileTask = [this]() {
OTACompileInternal();
@ -490,7 +474,7 @@ void AOTHandler::OTACompile()
std::thread(OTACompileTask).detach();
}
void AOTHandler::OTACompileInternal()
void AOTHandler::OTACompileInternal() const
{
APP_LOGI("OTACompileInternal begin");
system::SetParameter(OTA_COMPILE_STATUS, OTA_COMPILE_STATUS_BEGIN);
@ -508,7 +492,7 @@ void AOTHandler::OTACompileInternal()
std::string compileMode = system::GetParameter(OTA_COMPILE_MODE, COMPILE_NONE);
APP_LOGI("%{public}s = %{public}s", OTA_COMPILE_MODE, compileMode.c_str());
if (compileMode == COMPILE_NONE) {
APP_LOGI("%{public}s = none, no need to AOT", OTA_COMPILE_MODE);
APP_LOGI("%{public}s none, no need to AOT", OTA_COMPILE_MODE);
return;
}
@ -536,7 +520,7 @@ void AOTHandler::OTACompileInternal()
bool AOTHandler::GetOTACompileList(std::vector<std::string> &bundleNames) const
{
std::string updateType = system::GetParameter(UPDATE_TYPE, "");
APP_LOGI("updateType : %{public}s", updateType.c_str());
APP_LOGI("updateType %{public}s", updateType.c_str());
int32_t size = 0;
if (updateType == UPDATE_TYPE_MANUAL) {
size = system::GetIntParameter<int32_t>(OTA_COMPILE_COUNT_MANUAL, OTA_COMPILE_COUNT_MANUAL_DEFAULT);
@ -551,7 +535,7 @@ bool AOTHandler::GetOTACompileList(std::vector<std::string> &bundleNames) const
bool AOTHandler::GetUserBehaviourAppList(std::vector<std::string> &bundleNames, int32_t size) const
{
APP_LOGI("GetUserBehaviourAppList begin, size : %{public}d", size);
APP_LOGI("GetUserBehaviourAppList begin, size %{public}d", size);
void* handle = dlopen(USER_STATUS_SO_NAME, RTLD_NOW);
if (handle == nullptr) {
APP_LOGE("user status dlopen failed : %{public}s", dlerror());
@ -571,9 +555,9 @@ bool AOTHandler::GetUserBehaviourAppList(std::vector<std::string> &bundleNames,
}
EventInfo AOTHandler::HandleCompileWithBundle(const std::string &bundleName, const std::string &compileMode,
std::shared_ptr<BundleDataMgr> dataMgr)
std::shared_ptr<BundleDataMgr> dataMgr) const
{
APP_LOGI("handle compile bundle : %{public}s", bundleName.c_str());
APP_LOGI("handle compile bundle %{public}s", bundleName.c_str());
EventInfo eventInfo;
eventInfo.timeStamp = BundleUtil::GetCurrentTime();
eventInfo.bundleName = bundleName;
@ -649,7 +633,7 @@ void AOTHandler::ReportSysEvent(const std::map<std::string, EventInfo> &sysEvent
}
void AOTHandler::HandleIdleWithSingleHap(
const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode)
const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) const
{
APP_LOGD("HandleIdleWithSingleHap, moduleName : %{public}s", moduleName.c_str());
if (info.GetAOTCompileStatus(moduleName) == AOTCompileStatus::COMPILE_SUCCESS) {
@ -661,7 +645,7 @@ void AOTHandler::HandleIdleWithSingleHap(
}
ErrCode AOTHandler::HandleCompileWithSingleHap(const InnerBundleInfo &info, const std::string &moduleName,
const std::string &compileMode, bool isEnanleBaselinePgo)
const std::string &compileMode, bool isEnanleBaselinePgo) const
{
APP_LOGI("HandleCompileWithSingleHap, moduleName : %{public}s", moduleName.c_str());
std::optional<AOTArgs> aotArgs = BuildAOTArgs(info, moduleName, compileMode, isEnanleBaselinePgo);
@ -684,7 +668,7 @@ bool AOTHandler::CheckDeviceState() const
#endif
}
void AOTHandler::HandleIdle()
void AOTHandler::HandleIdle() const
{
APP_LOGI("HandleIdle begin");
std::unique_lock<std::mutex> lock(idleMutex_, std::defer_lock);
@ -699,7 +683,7 @@ void AOTHandler::HandleIdle()
std::string compileMode = system::GetParameter(IDLE_COMPILE_MODE, ServiceConstants::COMPILE_PARTIAL);
APP_LOGI("%{public}s = %{public}s", IDLE_COMPILE_MODE, compileMode.c_str());
if (compileMode == COMPILE_NONE) {
APP_LOGI("%{public}s = none, no need to AOT", IDLE_COMPILE_MODE);
APP_LOGI("%{public}s none, no need to AOT", IDLE_COMPILE_MODE);
return;
}
if (!CheckDeviceState()) {
@ -733,12 +717,12 @@ void AOTHandler::HandleIdle()
}
ErrCode AOTHandler::HandleCompile(const std::string &bundleName, const std::string &compileMode, bool isAllBundle,
std::vector<std::string> &compileResults)
std::vector<std::string> &compileResults) const
{
APP_LOGI("HandleCompile begin");
std::unique_lock<std::mutex> lock(compileMutex_, std::defer_lock);
if (!lock.try_lock()) {
APP_LOGI("compile task is running, skip %{public}s", bundleName.c_str());
APP_LOGI("compile task running, skip %{public}s", bundleName.c_str());
std::string compileResult = "info: compile task is running, skip.";
compileResults.emplace_back(compileResult);
return ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
@ -750,7 +734,7 @@ ErrCode AOTHandler::HandleCompile(const std::string &bundleName, const std::stri
return ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
}
if (compileMode == COMPILE_NONE) {
APP_LOGI("%{public}s = none, no need to AOT", IDLE_COMPILE_MODE);
APP_LOGI("%{public}s none, no need to AOT", IDLE_COMPILE_MODE);
std::string compileResult = "info: persist.bm.idle.arkopt = none, no need to AOT.";
compileResults.emplace_back(compileResult);
return ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
@ -777,7 +761,7 @@ ErrCode AOTHandler::HandleCompile(const std::string &bundleName, const std::stri
}
ErrCode AOTHandler::HandleCompileBundles(const std::vector<std::string> &bundleNames, const std::string &compileMode,
std::shared_ptr<BundleDataMgr> &dataMgr, std::vector<std::string> &compileResults)
std::shared_ptr<BundleDataMgr> &dataMgr, std::vector<std::string> &compileResults) const
{
ErrCode ret = ERR_OK;
std::for_each(bundleNames.cbegin(), bundleNames.cend(),
@ -785,7 +769,7 @@ ErrCode AOTHandler::HandleCompileBundles(const std::vector<std::string> &bundleN
APP_LOGD("HandleCompile bundleToCompile : %{public}s", bundleToCompile.c_str());
InnerBundleInfo info;
if (!dataMgr->QueryInnerBundleInfo(bundleToCompile, info)) {
APP_LOGE("QueryInnerBundleInfo failed. bundleToCompile: %{public}s", bundleToCompile.c_str());
APP_LOGE("QueryInnerBundleInfo failed. bundleToCompile %{public}s", bundleToCompile.c_str());
std::string compileResult = bundleToCompile + ": QueryInnerBundleInfo failed.";
compileResults.emplace_back(compileResult);
ret = ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
@ -813,7 +797,7 @@ ErrCode AOTHandler::HandleCompileBundles(const std::vector<std::string> &bundleN
}
ErrCode AOTHandler::HandleCompileModules(const std::vector<std::string> &moduleNames, const std::string &compileMode,
InnerBundleInfo &info, std::string &compileResult)
InnerBundleInfo &info, std::string &compileResult) const
{
ErrCode ret = ERR_OK;
std::for_each(moduleNames.cbegin(), moduleNames.cend(),
@ -826,9 +810,11 @@ ErrCode AOTHandler::HandleCompileModules(const std::vector<std::string> &moduleN
compileResult += " " + moduleName + ":compile-fail";
break;
case ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED:
case ERR_APPEXECFWK_INSTALLD_SIGN_AOT_DISABLE:
compileResult += " " + moduleName + ":signature-fail";
break;
case ERR_APPEXECFWK_INSTALLD_SIGN_AOT_DISABLE:
compileResult += " " + moduleName + ":signature-disable";
break;
case ERR_APPEXECFWK_AOT_ARGS_EMPTY:
compileResult += " " + moduleName + ":args-empty";
break;
@ -842,177 +828,5 @@ ErrCode AOTHandler::HandleCompileModules(const std::vector<std::string> &moduleN
});
return ret;
}
#ifdef PEND_SIGN_SCREENLOCK_MGR_ENABLED
void AOTHandler::RegisterScreenUnlockListener()
{
auto PendingSignTask = [this]() {
if (!StartPendingSignEvent()) {
APP_LOGE("pending sign AOT event error");
}
};
std::thread(PendingSignTask).detach();
}
bool AOTHandler::StartPendingSignEvent()
{
if (hasUnlocked_) {
return true;
}
{
std::unique_lock<std::mutex> lock(unlockMutex_);
bool lockStatus = false;
if (ScreenLock::ScreenLockManager::GetInstance()->IsLocked(lockStatus) == ScreenLock::E_SCREENLOCK_OK) {
APP_LOGI("screen lock status = %{public}d", lockStatus);
hasUnlocked_ = !lockStatus;
} else {
APP_LOGE("unable get lock screen status");
}
if (hasUnlocked_) {
return true;
}
if (!WaitForCommonEventManager()) {
return false;
}
if (!RegisterScreenUnlockEvent()) {
return false;
}
unlockConVar_.wait(lock, [this]() {
bool ret = this->hasUnlocked_;
return ret;
});
APP_LOGI("thread is wake up");
UnregisterScreenUnlockEvent();
}
return ExecutePendingSign();
}
bool AOTHandler::ExecutePendingSign()
{
sleep(SLEEP_TIME_FOR_WAIT_SIGN_ENABLE);
int32_t loopTimes = 0;
while (FinishPendingSign() != ERR_OK) {
if (++loopTimes > LOOP_TIMES_FOR_WAIT_SIGN_ENABLE) {
APP_LOGE("wait for enforce sign enable time out");
return false;
}
sleep(SLEEP_TIME_FOR_WAIT_SIGN_ENABLE);
}
{
std::lock_guard<std::mutex> lock(unlockMutex_);
pendingSignData_.clear();
}
APP_LOGI("pending enforce sign success");
return true;
}
ErrCode AOTHandler::FinishPendingSign()
{
std::lock_guard<std::mutex> lock(unlockMutex_);
ErrCode ret = ERR_OK;
for (auto itBundle = pendingSignData_.begin(); itBundle != pendingSignData_.end(); ++itBundle) {
auto &bundleName = itBundle->first;
auto &moduleSignData = itBundle->second;
for (auto itModule = moduleSignData.begin(); itModule != moduleSignData.end();) {
auto &moduleName = itModule->first;
auto &signData = itModule->second.signData;
std::string anFileName = ServiceConstants::ARK_CACHE_PATH + bundleName + ServiceConstants::PATH_SEPARATOR
+ ServiceConstants::ARM64 + ServiceConstants::PATH_SEPARATOR + moduleName + ServiceConstants::AN_SUFFIX;
ErrCode retCS = InstalldClient::GetInstance()->PendSignAOT(anFileName, signData);
if (retCS == ERR_APPEXECFWK_INSTALLD_SIGN_AOT_DISABLE) {
APP_LOGE("enforce sign service is disable");
ret = ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED;
++itModule;
continue;
} else if (retCS != ERR_OK) {
itModule = moduleSignData.erase(itModule);
continue;
}
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr) {
APP_LOGE("dataMgr is null");
ret = ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED;
++itModule;
continue;
}
auto versionCode = itModule->second.versionCode;
dataMgr->SetAOTCompileStatus(bundleName, moduleName, AOTCompileStatus::COMPILE_SUCCESS, versionCode);
itModule = moduleSignData.erase(itModule);
}
}
return ret;
}
bool AOTHandler::WaitForCommonEventManager() const
{
struct tm doingTime = {0};
struct tm startTime = {0};
int64_t seconds = 0;
bool ret = false;
if (!OHOS::GetSystemCurrentTime(&startTime)) {
return false;
}
while (seconds <= SLEEP_TIME_FOR_COMMON_EVENT_MGR_TIME_OUT) {
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (samgr != nullptr && samgr->CheckSystemAbility(COMMON_EVENT_MANAGER_ID) != nullptr) {
APP_LOGI("common event manager is loaded");
ret = true;
break;
}
APP_LOGD("get common event manager failed");
usleep(SLEEP_TIME_FOR_COMMON_EVENT_MGR);
if (OHOS::GetSystemCurrentTime(&doingTime)) {
seconds = OHOS::GetSecondsBetween(startTime, doingTime);
}
}
return ret;
}
bool AOTHandler::RegisterScreenUnlockEvent()
{
APP_LOGI("register screen unlock event start");
EventFwk::MatchingSkills matchingSkill;
// use COMMON_EVENT_USER_UNLOCKED if only for device with PIN
matchingSkill.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED);
EventFwk::CommonEventSubscribeInfo eventInfo(matchingSkill);
unlockEventSubscriber_ = std::make_shared<UnlockEventSubscriber>(eventInfo);
const auto result = EventFwk::CommonEventManager::SubscribeCommonEvent(unlockEventSubscriber_);
if (!result) {
APP_LOGE("register screen unlock event error");
return false;
}
APP_LOGI("register screen unlock event success");
return true;
}
void AOTHandler::UnregisterScreenUnlockEvent()
{
APP_LOGI("unregister screen unlock event start");
const auto result = EventFwk::CommonEventManager::UnSubscribeCommonEvent(unlockEventSubscriber_);
if (!result) {
APP_LOGE("unregister screen unlock event error");
return;
}
APP_LOGI("unregister screen unlock event success");
}
void AOTHandler::UnlockEventSubscriber::OnReceiveEvent(const EventFwk::CommonEventData &event)
{
const auto want = event.GetWant();
const auto action = want.GetAction();
if (action == EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED) {
APP_LOGI("receive screen unlock event");
AOTHandler::GetInstance().FinishWaiting();
}
}
void AOTHandler::FinishWaiting()
{
std::unique_lock<std::mutex> lock(unlockMutex_);
hasUnlocked_ = true;
unlockConVar_.notify_one();
}
#endif
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -0,0 +1,162 @@
/*
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "aot/aot_sign_data_cache_mgr.h"
#include <sys/stat.h>
#include <thread>
#include <vector>
#include "account_helper.h"
#include "appexecfwk_errors.h"
#include "app_log_wrapper.h"
#include "bundle_constants.h"
#include "bundle_util.h"
#include "scope_guard.h"
#include "installd_client.h"
#include "parameter.h"
#include "parameters.h"
#include "string_ex.h"
namespace OHOS {
namespace AppExecFwk {
namespace {
constexpr int32_t SLEEP_TIME_FOR_WAIT_SIGN_ENABLE = 1; // 1 s
constexpr int32_t LOOP_TIMES_FOR_WAIT_SIGN_ENABLE = 5;
}
AOTSignDataCacheMgr& AOTSignDataCacheMgr::GetInstance()
{
static AOTSignDataCacheMgr signDataCacheMgr;
return signDataCacheMgr;
}
void AOTSignDataCacheMgr::AddPendSignData(const AOTArgs &aotArgs, const uint32_t versionCode,
const std::vector<uint8_t> &pendSignData, const ErrCode ret)
{
if (isLocked_ && (ret == ERR_APPEXECFWK_INSTALLD_SIGN_AOT_DISABLE) && !pendSignData.empty()) {
if (aotArgs.bundleName.empty() || aotArgs.moduleName.empty()) {
APP_LOGE("empty bundle or/and module name error");
return;
}
PendingData pendingData = {versionCode, pendSignData};
{
std::lock_guard<std::mutex> lock(mutex_);
pendingSignData_[aotArgs.bundleName][aotArgs.moduleName] = pendingData;
}
}
}
void AOTSignDataCacheMgr::RegisterScreenUnlockListener()
{
APP_LOGI("register screen unlock event start");
EventFwk::MatchingSkills matchingSkill;
// use COMMON_EVENT_USER_UNLOCKED if only for device with PIN
matchingSkill.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED);
EventFwk::CommonEventSubscribeInfo eventInfo(matchingSkill);
unlockEventSubscriber_ = std::make_shared<UnlockEventSubscriber>(eventInfo);
const bool result = EventFwk::CommonEventManager::SubscribeCommonEvent(unlockEventSubscriber_);
if (!result) {
APP_LOGE("register screen unlock event for pending sign AOT error");
return;
}
APP_LOGI("register screen unlock event for pending sign AOT success");
}
void AOTSignDataCacheMgr::UnregisterScreenUnlockEvent()
{
APP_LOGI("unregister screen unlock event start");
const bool result = EventFwk::CommonEventManager::UnSubscribeCommonEvent(unlockEventSubscriber_);
if (!result) {
APP_LOGE("unregister screen unlock event error");
return;
}
APP_LOGI("unregister screen unlock event success");
}
void AOTSignDataCacheMgr::UnlockEventSubscriber::OnReceiveEvent(const EventFwk::CommonEventData &event)
{
const auto want = event.GetWant();
const auto action = want.GetAction();
if (action == EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED) {
APP_LOGI("receive screen unlock event");
auto task = []() {
AOTSignDataCacheMgr::GetInstance().HandleUnlockEvent();
};
std::thread(task).detach();
}
}
void AOTSignDataCacheMgr::HandleUnlockEvent()
{
APP_LOGI("pending sign thread is wake up");
UnregisterScreenUnlockEvent();
sleep(SLEEP_TIME_FOR_WAIT_SIGN_ENABLE);
isLocked_ = false;
int32_t loopTimes = 0;
while (ExecutePendSign() != ERR_OK) {
if (++loopTimes > LOOP_TIMES_FOR_WAIT_SIGN_ENABLE) {
APP_LOGE("wait for enforce sign enable time out");
return;
}
sleep(SLEEP_TIME_FOR_WAIT_SIGN_ENABLE);
}
{
std::lock_guard<std::mutex> lock(mutex_);
std::unordered_map<std::string, std::unordered_map<std::string, PendingData>>().swap(pendingSignData_);
}
APP_LOGI("pending enforce sign success");
}
ErrCode AOTSignDataCacheMgr::ExecutePendSign()
{
std::lock_guard<std::mutex> lock(mutex_);
ErrCode ret = ERR_OK;
for (auto itBundle = pendingSignData_.begin(); itBundle != pendingSignData_.end(); ++itBundle) {
auto &bundleName = itBundle->first;
auto &moduleSignData = itBundle->second;
for (auto itModule = moduleSignData.begin(); itModule != moduleSignData.end();) {
auto &moduleName = itModule->first;
auto &signData = itModule->second.signData;
std::string anFileName = ServiceConstants::ARK_CACHE_PATH + bundleName + ServiceConstants::PATH_SEPARATOR
+ ServiceConstants::ARM64 + ServiceConstants::PATH_SEPARATOR + moduleName + ServiceConstants::AN_SUFFIX;
ErrCode retCS = InstalldClient::GetInstance()->PendSignAOT(anFileName, signData);
if (retCS == ERR_APPEXECFWK_INSTALLD_SIGN_AOT_DISABLE) {
APP_LOGE("enforce sign service is disable");
ret = ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED;
++itModule;
continue;
} else if (retCS != ERR_OK) {
itModule = moduleSignData.erase(itModule);
continue;
}
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr) {
APP_LOGE("dataMgr is null");
ret = ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED;
++itModule;
continue;
}
auto versionCode = itModule->second.versionCode;
dataMgr->SetAOTCompileStatus(bundleName, moduleName, AOTCompileStatus::COMPILE_SUCCESS, versionCode);
itModule = moduleSignData.erase(itModule);
}
}
return ret;
}
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -28,7 +28,9 @@
#include "bundle_constants.h"
#include "bundle_info.h"
#include "bundle_mgr_service.h"
#include "bundle_parser.h"
#include "bundle_service_constants.h"
#include "bundle_util.h"
#include "parameters.h"
namespace OHOS {
@ -51,6 +53,11 @@ AppControlManager::AppControlManager()
LOG_I(BMS_TAG_APP_CONTROL, "App jump intercetor disabled");
}
commonEventMgr_ = std::make_shared<BundleCommonEventMgr>();
std::string configPath = BundleUtil::GetNoDisablingConfigPath();
ErrCode ret = BundleParser::ParseNoDisablingList(configPath, noControllingList_);
if (ret != ERR_OK) {
LOG_W(BMS_TAG_APP_CONTROL, "GetNoDisablingList failed");
}
}
AppControlManager::~AppControlManager()
@ -220,6 +227,10 @@ ErrCode AppControlManager::GetAppJumpControlRule(const std::string &callerBundle
ErrCode AppControlManager::SetDisposedStatus(const std::string &appId, const Want& want, int32_t userId)
{
if (!CheckCanDispose(appId, userId)) {
LOG_E(BMS_TAG_APP_CONTROL, "appid in white-list");
return ERR_BUNDLE_MANAGER_PERMISSION_DENIED;
}
auto ret = appControlManagerDb_->SetDisposedStatus(APP_MARKET_CALLING, appId, want, userId);
if (ret != ERR_OK) {
LOG_E(BMS_TAG_APP_CONTROL, "SetDisposedStatus to rdb failed");
@ -338,6 +349,10 @@ void AppControlManager::SetAppInstallControlStatus()
ErrCode AppControlManager::SetDisposedRule(const std::string &callerName, const std::string &appId,
const DisposedRule& rule, int32_t appIndex, int32_t userId)
{
if (!CheckCanDispose(appId, userId)) {
LOG_E(BMS_TAG_APP_CONTROL, "appid in white-list");
return ERR_BUNDLE_MANAGER_PERMISSION_DENIED;
}
auto ret = appControlManagerDb_->SetDisposedRule(callerName, appId, rule, appIndex, userId);
if (ret != ERR_OK) {
LOG_E(BMS_TAG_APP_CONTROL, "SetDisposedStatus to rdb failed");
@ -479,5 +494,26 @@ ErrCode AppControlManager::GetAbilityRunningControlRule(
abilityRunningControlRuleCache_[key] = disposedRules;
return ret;
}
bool AppControlManager::CheckCanDispose(const std::string &appId, int32_t userId)
{
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (dataMgr == nullptr) {
LOG_E(BMS_TAG_APP_CONTROL, "DataMgr is nullptr");
return ERR_BUNDLE_MANAGER_INTERNAL_ERROR;
}
for (const auto &bundleName : noControllingList_) {
BundleInfo bundleInfo;
ErrCode ret = dataMgr->GetBundleInfoV9(bundleName,
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_DISABLE), bundleInfo, userId);
if (ret != ERR_OK) {
continue;
}
if (appId == bundleInfo.appId) {
return false;
}
}
return true;
}
}
}

View File

@ -228,7 +228,7 @@ bool AppProvisionInfoManagerRdb::SetSpecifiedDistributionType(
NativeRdb::AbsRdbPredicates absRdbPredicates(APP_PROVISION_INFO_RDB_TABLE_NAME);
absRdbPredicates.EqualTo(BUNDLE_NAME, bundleName);
if (!rdbDataManager_->UpdateData(valuesBucket, absRdbPredicates)) {
APP_LOGE("bundleName: %{public}s SetSpecifiedDistributionType failed.", bundleName.c_str());
APP_LOGE("bundleName %{public}s SetSpecifiedDistributionType failed.", bundleName.c_str());
return false;
}
return true;
@ -245,19 +245,18 @@ bool AppProvisionInfoManagerRdb::GetSpecifiedDistributionType(
absRdbPredicates.EqualTo(BUNDLE_NAME, bundleName);
auto absSharedResultSet = rdbDataManager_->QueryData(absRdbPredicates);
if (absSharedResultSet == nullptr) {
APP_LOGW("bundleName: %{public}s, GetSpecifiedDistributionType QueryData failed.", bundleName.c_str());
APP_LOGW("bundleName %{public}s GetSpecifiedDistributionType QueryData failed.", bundleName.c_str());
return false;
}
ScopeGuard stateGuard([absSharedResultSet] { absSharedResultSet->Close(); });
auto ret = absSharedResultSet->GoToFirstRow();
if (ret != NativeRdb::E_OK) {
APP_LOGW("bundleName: %{public}s, AppProvisionInfoManagerRdb GetSpecifiedDistributionType failed.",
bundleName.c_str());
APP_LOGW("bundleName: %{public}s GetSpecifiedDistributionType failed.", bundleName.c_str());
return false;
}
ret = absSharedResultSet->GetString(INDEX_SPECIFIED_DISTRIBUTED_TYPE, specifiedDistributionType);
if (ret != NativeRdb::E_OK) {
APP_LOGE("bundleName: %{public}s GetSpecifiedDistributionType GetString failed.", bundleName.c_str());
APP_LOGE("bundleName %{public}s GetString failed.", bundleName.c_str());
return false;
}
return true;
@ -275,7 +274,7 @@ bool AppProvisionInfoManagerRdb::SetAdditionalInfo(
NativeRdb::AbsRdbPredicates absRdbPredicates(APP_PROVISION_INFO_RDB_TABLE_NAME);
absRdbPredicates.EqualTo(BUNDLE_NAME, bundleName);
if (!rdbDataManager_->UpdateData(valuesBucket, absRdbPredicates)) {
APP_LOGE("bundleName: %{public}s SetAdditionalInfo failed.", bundleName.c_str());
APP_LOGE("bundleName %{public}s SetAdditionalInfo failed.", bundleName.c_str());
return false;
}
return true;
@ -292,18 +291,18 @@ bool AppProvisionInfoManagerRdb::GetAdditionalInfo(
absRdbPredicates.EqualTo(BUNDLE_NAME, bundleName);
auto absSharedResultSet = rdbDataManager_->QueryData(absRdbPredicates);
if (absSharedResultSet == nullptr) {
APP_LOGW("bundleName: %{public}s, GetAdditionalInfo QueryData failed.", bundleName.c_str());
APP_LOGW("bundleName %{public}s, GetAdditionalInfo QueryData failed.", bundleName.c_str());
return false;
}
ScopeGuard stateGuard([absSharedResultSet] { absSharedResultSet->Close(); });
auto ret = absSharedResultSet->GoToFirstRow();
if (ret != NativeRdb::E_OK) {
APP_LOGW("bundleName: %{public}s, AppProvisionInfoManagerRdb GetAdditionalInfo failed.", bundleName.c_str());
APP_LOGW("bundleName %{public}s GetAdditionalInfo failed.", bundleName.c_str());
return false;
}
ret = absSharedResultSet->GetString(INDEX_ADDITIONAL_INFO, additionalInfo);
if (ret != NativeRdb::E_OK) {
APP_LOGE("bundleName: %{public}s, AppProvisionInfoManagerRdb GetAdditionalInfo failed.", bundleName.c_str());
APP_LOGE("bundleName %{public}s GetAdditionalInfo failed.", bundleName.c_str());
return false;
}
return true;

View File

@ -174,6 +174,7 @@ void AppServiceFwkInstaller::SavePreInstallBundleInfo(
for (const auto &innerBundleInfo : newInfos) {
auto applicationInfo = innerBundleInfo.second.GetBaseApplicationInfo();
innerBundleInfo.second.AdaptMainLauncherResourceInfo(applicationInfo);
preInstallBundleInfo.SetLabelId(applicationInfo.labelResource.id);
preInstallBundleInfo.SetIconId(applicationInfo.iconResource.id);
preInstallBundleInfo.SetModuleName(applicationInfo.labelResource.moduleName);
@ -250,7 +251,7 @@ ErrCode AppServiceFwkInstaller::CheckAndParseFiles(
GenerateOdid(newInfos, hapVerifyResults);
AddAppProvisionInfo(bundleName_, hapVerifyResults[0].GetProvisionInfo(), installParam);
APP_LOGI("CheckAndParseFiles End, newInfos size: %{public}zu", newInfos.size());
APP_LOGI("End, size %{public}zu", newInfos.size());
return result;
}
@ -310,7 +311,7 @@ ErrCode AppServiceFwkInstaller::CheckAppLabelInfo(
ErrCode ret = bundleInstallChecker_->CheckAppLabelInfo(infos);
if (ret != ERR_OK) {
APP_LOGE("CheckAppLabelInfo failed, result: %{public}d", ret);
APP_LOGE("CheckAppLabelInfo failed, ret %{public}d", ret);
return ret;
}
@ -327,20 +328,20 @@ void AppServiceFwkInstaller::AddAppProvisionInfo(
AppProvisionInfo appProvisionInfo = bundleInstallChecker_->ConvertToAppProvisionInfo(provisionInfo);
if (!DelayedSingleton<AppProvisionInfoManager>::GetInstance()->AddAppProvisionInfo(
bundleName, appProvisionInfo)) {
APP_LOGW("BundleName: %{public}s add appProvisionInfo failed.", bundleName.c_str());
APP_LOGW("BundleName %{public}s add appProvisionInfo failed.", bundleName.c_str());
}
if (!installParam.specifiedDistributionType.empty()) {
if (!DelayedSingleton<AppProvisionInfoManager>::GetInstance()->SetSpecifiedDistributionType(
bundleName, installParam.specifiedDistributionType)) {
APP_LOGW("BundleName: %{public}s SetSpecifiedDistributionType failed.", bundleName.c_str());
APP_LOGW("BundleName %{public}s SetSpecifiedDistributionType failed.", bundleName.c_str());
}
}
if (!installParam.additionalInfo.empty()) {
if (!DelayedSingleton<AppProvisionInfoManager>::GetInstance()->SetAdditionalInfo(
bundleName, installParam.additionalInfo)) {
APP_LOGW("BundleName: %{public}s SetAdditionalInfo failed.", bundleName.c_str());
APP_LOGW("BundleName %{public}s SetAdditionalInfo failed.", bundleName.c_str());
}
}
}
@ -370,7 +371,7 @@ ErrCode AppServiceFwkInstaller::InnerProcessInstall(
ErrCode AppServiceFwkInstaller::ExtractModule(
InnerBundleInfo &newInfo, const std::string &bundlePath)
{
APP_LOGI("begin to ExtractModule with %{public}s bundlePath %{public}s",
APP_LOGI("begin ExtractModule with %{public}s bundlePath %{public}s",
newInfo.GetCurrentModulePackage().c_str(), bundlePath.c_str());
ErrCode result = ERR_OK;
std::string bundleDir =
@ -433,7 +434,7 @@ ErrCode AppServiceFwkInstaller::ExtractModule(InnerBundleInfo &oldInfo,
ErrCode AppServiceFwkInstaller::MkdirIfNotExist(const std::string &dir)
{
APP_LOGI("mkdir for dir: %{public}s", dir.c_str());
APP_LOGI("mkdir %{public}s", dir.c_str());
bool isDirExist = false;
ErrCode result = InstalldClient::GetInstance()->IsExistDir(dir, isDirExist);
CHECK_RESULT(result, "Check if dir exist failed %{public}d");
@ -470,7 +471,7 @@ ErrCode AppServiceFwkInstaller::ProcessNativeLibrary(
std::string tempSoPath =
versionDir + AppExecFwk::ServiceConstants::PATH_SEPARATOR + tempNativeLibraryPath;
APP_LOGI("TempSoPath=%{public}s,cpuAbi=%{public}s, bundlePath=%{public}s",
APP_LOGI("TempSoPath %{public}s cpuAbi %{public}s bundlePath %{public}s",
tempSoPath.c_str(), cpuAbi.c_str(), bundlePath.c_str());
auto result = InstalldClient::GetInstance()->ExtractModuleFiles(
bundlePath, moduleDir, tempSoPath, cpuAbi);
@ -511,7 +512,7 @@ ErrCode AppServiceFwkInstaller::SaveBundleInfoToStorage()
if (!dataMgr_->AddInnerBundleInfo(bundleName_, newInnerBundleInfo_)) {
dataMgr_->UpdateBundleInstallState(bundleName_, InstallState::UNINSTALL_START);
dataMgr_->UpdateBundleInstallState(bundleName_, InstallState::UNINSTALL_SUCCESS);
APP_LOGE("Save bundle failed : %{public}s", bundleName_.c_str());
APP_LOGE("Save bundle failed %{public}s", bundleName_.c_str());
return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR;
}
@ -546,7 +547,7 @@ ErrCode AppServiceFwkInstaller::MoveSoToRealPath(
}
result = InstalldClient::GetInstance()->MoveFiles(tempSoPath, realSoPath);
if (result != ERR_OK) {
APP_LOGE("Move file to real path failed %{public}d", result);
APP_LOGE("Move to real path failed %{public}d", result);
return ERR_APPEXECFWK_INSTALLD_MOVE_FILE_FAILED;
}
@ -555,7 +556,7 @@ ErrCode AppServiceFwkInstaller::MoveSoToRealPath(
+ moduleName + AppExecFwk::ServiceConstants::TMP_SUFFIX;
result = InstalldClient::GetInstance()->RemoveDir(deleteTempDir);
if (result != ERR_OK) {
APP_LOGW("Remove hsp temp so dir %{public}s failed, error is %{public}d",
APP_LOGW("Remove temp dir %{public}s failed %{public}d",
deleteTempDir.c_str(), result);
}
return ERR_OK;
@ -719,7 +720,7 @@ ErrCode AppServiceFwkInstaller::UninstallLowerVersion(const std::vector<std::str
}
std::vector<std::string> moduleVec = info.GetModuleNameVec();
APP_LOGI("bundleName: %{public}s moduleVec size: %{public}zu", bundleName_.c_str(), moduleVec.size());
APP_LOGI("bundleName %{public}s moduleVec size %{public}zu", bundleName_.c_str(), moduleVec.size());
InnerBundleInfo oldInfo = info;
for (const auto &package : moduleVec) {
if (find(moduleNameList.begin(), moduleNameList.end(), package) == moduleNameList.end()) {
@ -755,7 +756,7 @@ ErrCode AppServiceFwkInstaller::RemoveBundleCodeDir(const InnerBundleInfo &info)
{
auto result = InstalldClient::GetInstance()->RemoveDir(info.GetAppCodePath());
if (result != ERR_OK) {
APP_LOGE("Fail to remove bundle code dir %{public}s, error is %{public}d",
APP_LOGE("Fail remove dir %{public}s, err %{public}d",
info.GetAppCodePath().c_str(), result);
}
return result;
@ -798,7 +799,7 @@ bool AppServiceFwkInstaller::CheckNeedInstall(const std::unordered_map<std::stri
if ((oldInfo.GetVersionCode() == versionCode_) &&
oldInfo.GetApplicationBundleType() != BundleType::APP_SERVICE_FWK) {
APP_LOGW("bundle %{public}s type is not same, existing bundle type is %{public}d",
APP_LOGW("bundle %{public}s type is not same, existing type is %{public}d",
bundleName_.c_str(), oldInfo.GetApplicationBundleType());
return false;
}

Some files were not shown because too many files have changed in this diff Show More