modify review problems

Signed-off-by: shilei <shilei91@huawei.com>
Change-Id: Ide47939b861cb77a8c3303616dd4139b694e2103
This commit is contained in:
shilei 2022-05-19 09:52:43 +08:00
parent 34d66c9963
commit d91d552088
6 changed files with 164 additions and 293 deletions

View File

@ -196,19 +196,19 @@ constexpr int64_t MAX_HAP_SIZE = ONE_GB * 4; // 4GB
const std::string UID = "uid";
const std::string USER_ID = "userId";
const std::string BUNDLE_NAME = "bundleName";
const int32_t MAX_LIMIT_SIZE = 4;
constexpr int32_t MAX_LIMIT_SIZE = 4;
const std::string DATA_ABILITY_URI_PREFIX = "dataability://";
const char DATA_ABILITY_URI_SEPARATOR = '/';
const std::string PARAM_URI_SEPARATOR = ":///";
const uint32_t PARAM_URI_SEPARATOR_LEN = 4;
constexpr uint32_t PARAM_URI_SEPARATOR_LEN = 4;
const std::string URI_SEPARATOR = "://";
const uint32_t URI_SEPARATOR_LEN = 3;
constexpr uint32_t URI_SEPARATOR_LEN = 3;
const std::string SEPARATOR = "/";
const int MAX_DIMENSION_SIZE = 10;
const int MAX_DEVICETYPE_SIZE = 50;
constexpr int MAX_DIMENSION_SIZE = 10;
constexpr int MAX_DEVICETYPE_SIZE = 50;
// appFeature
const std::string HOS_NORMAL_APP = "hos_normal_app";
@ -216,10 +216,10 @@ const std::string HOS_SYSTEM_APP = "hos_system_app";
const std::string OHOS_SYSTEM_APP = "ohos_system_app";
// ipc
const int32_t MAX_CAPACITY_BUNDLES = 5 * 1024 * 1000; // 5M
constexpr int32_t MAX_CAPACITY_BUNDLES = 5 * 1024 * 1000; // 5M
// file size
const int32_t INVALID_FILE_SIZE = -1;
constexpr int32_t INVALID_FILE_SIZE = -1;
// permission
const std::string LISTEN_BUNDLE_CHANGE = "ohos.permission.LISTEN_BUNDLE_CHANGE";
@ -238,8 +238,8 @@ const std::string PREINSTALL_ABILITY_CONFIG = "/preinstall_ability_config.json";
// sandbox application
const std::string SANDBOX_APP_INDEX = "sandbox_app_index";
const int32_t INITIAL_APP_INDEX = 0;
const int32_t MAX_APP_INDEX = 100;
constexpr int32_t INITIAL_APP_INDEX = 0;
constexpr int32_t MAX_APP_INDEX = 100;
} // namespace Constants
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -395,7 +395,7 @@ void from_json(const nlohmann::json &jsonObject, PackageModule &packageModule)
PACK_SUMMARY_MODULE_MAIN_ABILITY,
packageModule.mainAbility,
JsonType::STRING,
true,
false,
parseResult,
ArrayType::NOT_ARRAY);
GetValueIfFindKey<std::vector<std::string>>(jsonObject,
@ -403,7 +403,7 @@ void from_json(const nlohmann::json &jsonObject, PackageModule &packageModule)
PACK_SUMMARY_MODULE_DEVICE_TYPE,
packageModule.deviceType,
JsonType::ARRAY,
true,
false,
parseResult,
ArrayType::STRING);
GetValueIfFindKey<std::vector<ModuleAbilityInfo>>(jsonObject,
@ -411,7 +411,7 @@ void from_json(const nlohmann::json &jsonObject, PackageModule &packageModule)
PACK_SUMMARY_MODULE_ABILITIES,
packageModule.abilities,
JsonType::ARRAY,
true,
false,
parseResult,
ArrayType::OBJECT);
GetValueIfFindKey<std::vector<ExtensionAbilities>>(jsonObject,
@ -419,7 +419,7 @@ void from_json(const nlohmann::json &jsonObject, PackageModule &packageModule)
PACK_SUMMARY_MODULE_EXTENSION_ABILITIES,
packageModule.extensionAbilities,
JsonType::ARRAY,
true,
false,
parseResult,
ArrayType::OBJECT);
GetValueIfFindKey<ModuleDistro>(jsonObject,
@ -427,7 +427,7 @@ void from_json(const nlohmann::json &jsonObject, PackageModule &packageModule)
PACK_SUMMARY_MODULE_DISTRO,
packageModule.distro,
JsonType::OBJECT,
true,
false,
parseResult,
ArrayType::NOT_ARRAY);
GetValueIfFindKey<ApiVersion>(jsonObject,
@ -460,7 +460,7 @@ void from_json(const nlohmann::json &jsonObject, Summary &summary)
PACK_SUMMARY_APP,
summary.app,
JsonType::OBJECT,
true,
false,
parseResult,
ArrayType::NOT_ARRAY);
GetValueIfFindKey<std::vector<PackageModule>>(jsonObject,
@ -468,7 +468,7 @@ void from_json(const nlohmann::json &jsonObject, Summary &summary)
PACK_SUMMARY_MODULE,
summary.modules,
JsonType::ARRAY,
true,
false,
parseResult,
ArrayType::OBJECT);
if (parseResult != ERR_OK) {

View File

@ -29,7 +29,7 @@ namespace OHOS {
namespace AppExecFwk {
class BundleMgrHost : public IRemoteStub<IBundleMgr> {
public:
BundleMgrHost() = default;
BundleMgrHost();
virtual ~BundleMgrHost() = default;
int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
@ -574,6 +574,10 @@ private:
* @return Returns ashmem num.
*/
int32_t AllocatAshmemNum();
void init();
using BundleMgrHostFunc = ErrCode (BundleMgrHost::*)(Parcel &, Parcel &);
std::unordered_map<uint32_t, BundleMgrHostFunc> funcMap_;
std::mutex bundleAshmemMutex_;
int32_t ashmemNum_ = 0;

View File

@ -53,6 +53,129 @@ inline void ClearAshmem(sptr<Ashmem> &optMem)
}
} // namespace
BundleMgrHost::BundleMgrHost()
{
APP_LOGD("create bundle manager host ");
init();
}
void BundleMgrHost::init()
{
funcMap_.emplace(IBundleMgr::Message::GET_APPLICATION_INFO, &BundleMgrHost::HandleGetApplicationInfo);
funcMap_.emplace(IBundleMgr::Message::GET_APPLICATION_INFO_WITH_INT_FLAGS,
&BundleMgrHost::HandleGetApplicationInfoWithIntFlags);
funcMap_.emplace(IBundleMgr::Message::GET_APPLICATION_INFOS, &BundleMgrHost::HandleGetApplicationInfos);
funcMap_.emplace(IBundleMgr::Message::GET_APPLICATION_INFOS_WITH_INT_FLAGS,
&BundleMgrHost::HandleGetApplicationInfosWithIntFlags);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_INFO, &BundleMgrHost::HandleGetBundleInfo);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_INFO_WITH_INT_FLAGS,
&BundleMgrHost::HandleGetBundleInfoWithIntFlags);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_PACK_INFO, &BundleMgrHost::HandleGetBundlePackInfo);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_PACK_INFO_WITH_INT_FLAGS,
&BundleMgrHost::HandleGetBundlePackInfoWithIntFlags);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_INFOS, &BundleMgrHost::HandleGetBundleInfos);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_INFOS_WITH_INT_FLAGS,
&BundleMgrHost::HandleGetBundleInfosWithIntFlags);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_NAME_FOR_UID, &BundleMgrHost::HandleGetBundleNameForUid);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLES_FOR_UID, &BundleMgrHost::HandleGetBundlesForUid);
funcMap_.emplace(IBundleMgr::Message::GET_NAME_FOR_UID, &BundleMgrHost::HandleGetNameForUid);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_GIDS, &BundleMgrHost::HandleGetBundleGids);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_GIDS_BY_UID, &BundleMgrHost::HandleGetBundleGidsByUid);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_INFOS_BY_METADATA,
&BundleMgrHost::HandleGetBundleInfosByMetaData);
funcMap_.emplace(IBundleMgr::Message::QUERY_ABILITY_INFO, &BundleMgrHost::HandleQueryAbilityInfo);
funcMap_.emplace(IBundleMgr::Message::QUERY_ABILITY_INFO_MUTI_PARAM,
&BundleMgrHost::HandleQueryAbilityInfoMutiparam);
funcMap_.emplace(IBundleMgr::Message::QUERY_ABILITY_INFOS, &BundleMgrHost::HandleQueryAbilityInfos);
funcMap_.emplace(IBundleMgr::Message::QUERY_ABILITY_INFOS_MUTI_PARAM,
&BundleMgrHost::HandleQueryAbilityInfosMutiparam);
funcMap_.emplace(IBundleMgr::Message::QUERY_ABILITY_INFOS_FOR_CLONE,
&BundleMgrHost::HandleQueryAbilityInfosForClone);
funcMap_.emplace(IBundleMgr::Message::QUERY_ALL_ABILITY_INFOS, &BundleMgrHost::HandleQueryAllAbilityInfos);
funcMap_.emplace(IBundleMgr::Message::QUERY_ABILITY_INFO_BY_URI, &BundleMgrHost::HandleQueryAbilityInfoByUri);
funcMap_.emplace(IBundleMgr::Message::QUERY_ABILITY_INFOS_BY_URI, &BundleMgrHost::HandleQueryAbilityInfosByUri);
funcMap_.emplace(IBundleMgr::Message::QUERY_ABILITY_INFO_BY_URI_FOR_USERID,
&BundleMgrHost::HandleQueryAbilityInfoByUriForUserId);
funcMap_.emplace(IBundleMgr::Message::QUERY_KEEPALIVE_BUNDLE_INFOS,
&BundleMgrHost::HandleQueryKeepAliveBundleInfos);
funcMap_.emplace(IBundleMgr::Message::GET_ABILITY_LABEL, &BundleMgrHost::HandleGetAbilityLabel);
funcMap_.emplace(IBundleMgr::Message::GET_ABILITY_LABEL_WITH_MODULE_NAME,
&BundleMgrHost::HandleGetAbilityLabelWithModuleName);
funcMap_.emplace(IBundleMgr::Message::CHECK_IS_SYSTEM_APP_BY_UID, &BundleMgrHost::HandleCheckIsSystemAppByUid);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_ARCHIVE_INFO, &BundleMgrHost::HandleGetBundleArchiveInfo);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_ARCHIVE_INFO_WITH_INT_FLAGS,
&BundleMgrHost::HandleGetBundleArchiveInfoWithIntFlags);
funcMap_.emplace(IBundleMgr::Message::GET_HAP_MODULE_INFO, &BundleMgrHost::HandleGetHapModuleInfo);
funcMap_.emplace(IBundleMgr::Message::GET_LAUNCH_WANT_FOR_BUNDLE, &BundleMgrHost::HandleGetLaunchWantForBundle);
funcMap_.emplace(IBundleMgr::Message::CHECK_PUBLICKEYS, &BundleMgrHost::HandleCheckPublicKeys);
funcMap_.emplace(IBundleMgr::Message::GET_PERMISSION_DEF, &BundleMgrHost::HandleGetAbilityLabel);
funcMap_.emplace(IBundleMgr::Message::HAS_SYSTEM_CAPABILITY, &BundleMgrHost::HandleHasSystemCapability);
funcMap_.emplace(IBundleMgr::Message::GET_SYSTEM_AVAILABLE_CAPABILITIES,
&BundleMgrHost::HandleGetSystemAvailableCapabilities);
funcMap_.emplace(IBundleMgr::Message::IS_SAFE_MODE, &BundleMgrHost::HandleIsSafeMode);
funcMap_.emplace(IBundleMgr::Message::CLEAN_BUNDLE_CACHE_FILES, &BundleMgrHost::HandleCleanBundleCacheFiles);
funcMap_.emplace(IBundleMgr::Message::CLEAN_BUNDLE_DATA_FILES, &BundleMgrHost::HandleCleanBundleDataFiles);
funcMap_.emplace(IBundleMgr::Message::REGISTER_BUNDLE_STATUS_CALLBACK,
&BundleMgrHost::HandleRegisterBundleStatusCallback);
funcMap_.emplace(IBundleMgr::Message::CLEAR_BUNDLE_STATUS_CALLBACK,
&BundleMgrHost::HandleClearBundleStatusCallback);
funcMap_.emplace(IBundleMgr::Message::UNREGISTER_BUNDLE_STATUS_CALLBACK,
&BundleMgrHost::HandleUnregisterBundleStatusCallback);
funcMap_.emplace(IBundleMgr::Message::IS_APPLICATION_ENABLED, &BundleMgrHost::HandleIsApplicationEnabled);
funcMap_.emplace(IBundleMgr::Message::SET_APPLICATION_ENABLED, &BundleMgrHost::HandleSetApplicationEnabled);
funcMap_.emplace(IBundleMgr::Message::IS_ABILITY_ENABLED, &BundleMgrHost::HandleIsAbilityEnabled);
funcMap_.emplace(IBundleMgr::Message::SET_ABILITY_ENABLED, &BundleMgrHost::HandleSetAbilityEnabled);
funcMap_.emplace(IBundleMgr::Message::GET_ABILITY_INFO, &BundleMgrHost::HandleGetAbilityInfo);
funcMap_.emplace(IBundleMgr::Message::GET_ABILITY_INFO_WITH_MODULE_NAME,
&BundleMgrHost::HandleGetAbilityInfoWithModuleName);
#ifdef BUNDLE_FRAMEWORK_GRAPHICS
funcMap_.emplace(IBundleMgr::Message::GET_ABILITY_PIXELMAP_ICON, &BundleMgrHost::HandleGetAbilityPixelMapIcon);
funcMap_.emplace(IBundleMgr::Message::GET_ABILITY_PIXELMAP_ICON_WITH_MODULE_NAME,
&BundleMgrHost::HandleGetAbilityPixelMapIconWithModuleName);
#endif
funcMap_.emplace(IBundleMgr::Message::DUMP_INFOS, &BundleMgrHost::HandleDumpInfos);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_INSTALLER, &BundleMgrHost::HandleGetBundleInstaller);
funcMap_.emplace(IBundleMgr::Message::GET_ALL_FORMS_INFO, &BundleMgrHost::HandleGetAllFormsInfo);
funcMap_.emplace(IBundleMgr::Message::GET_FORMS_INFO_BY_APP, &BundleMgrHost::HandleGetFormsInfoByApp);
funcMap_.emplace(IBundleMgr::Message::GET_FORMS_INFO_BY_MODULE, &BundleMgrHost::HandleGetFormsInfoByModule);
funcMap_.emplace(IBundleMgr::Message::GET_SHORTCUT_INFO, &BundleMgrHost::HandleGetShortcutInfos);
funcMap_.emplace(IBundleMgr::Message::GET_ALL_COMMON_EVENT_INFO, &BundleMgrHost::HandleGetAllCommonEventInfo);
funcMap_.emplace(IBundleMgr::Message::CHECK_BUNDLE_NAME_IN_ALLOWLIST,
&BundleMgrHost::HandleCheckBundleNameInAllowList);
funcMap_.emplace(IBundleMgr::Message::BUNDLE_CLONE, &BundleMgrHost::HandleBundleClone);
funcMap_.emplace(IBundleMgr::Message::REMOVE_CLONED_BUNDLE, &BundleMgrHost::HandleRemoveClonedBundle);
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_USER_MGR, &BundleMgrHost::HandleGetBundleUserMgr);
funcMap_.emplace(IBundleMgr::Message::GET_DISTRIBUTE_BUNDLE_INFO, &BundleMgrHost::HandleGetDistributedBundleInfo);
funcMap_.emplace(IBundleMgr::Message::GET_APPLICATION_PRIVILEGE_LEVEL, &BundleMgrHost::HandleGetAppPrivilegeLevel);
funcMap_.emplace(IBundleMgr::Message::QUERY_EXTENSION_INFO_WITHOUT_TYPE,
&BundleMgrHost::HandleQueryExtAbilityInfosWithoutType);
funcMap_.emplace(IBundleMgr::Message::QUERY_EXTENSION_INFO, &BundleMgrHost::HandleQueryExtAbilityInfos);
funcMap_.emplace(IBundleMgr::Message::QUERY_EXTENSION_INFO_BY_TYPE,
&BundleMgrHost::HandleQueryExtAbilityInfosByType);
funcMap_.emplace(IBundleMgr::Message::VERIFY_CALLING_PERMISSION, &BundleMgrHost::HandleVerifyCallingPermission);
funcMap_.emplace(IBundleMgr::Message::GET_ACCESSIBLE_APP_CODE_PATH,
&BundleMgrHost::HandleGetAccessibleAppCodePaths);
funcMap_.emplace(IBundleMgr::Message::QUERY_EXTENSION_ABILITY_INFO_BY_URI,
&BundleMgrHost::HandleQueryExtensionAbilityInfoByUri);
funcMap_.emplace(IBundleMgr::Message::GET_APPID_BY_BUNDLE_NAME, &BundleMgrHost::HandleGetAppIdByBundleName);
funcMap_.emplace(IBundleMgr::Message::GET_APP_TYPE, &BundleMgrHost::HandleGetAppType);
funcMap_.emplace(IBundleMgr::Message::GET_UID_BY_BUNDLE_NAME, &BundleMgrHost::HandleGetUidByBundleName);
funcMap_.emplace(IBundleMgr::Message::IS_MODULE_REMOVABLE, &BundleMgrHost::HandleIsModuleRemovable);
funcMap_.emplace(IBundleMgr::Message::SET_MODULE_REMOVABLE, &BundleMgrHost::HandleSetModuleRemovable);
funcMap_.emplace(IBundleMgr::Message::QUERY_ABILITY_INFO_WITH_CALLBACK,
&BundleMgrHost::HandleQueryAbilityInfoWithCallback);
funcMap_.emplace(IBundleMgr::Message::UPGRADE_ATOMIC_SERVICE, &BundleMgrHost::HandleUpgradeAtomicService);
funcMap_.emplace(IBundleMgr::Message::IS_MODULE_NEED_UPDATE, &BundleMgrHost::HandleGetModuleUpgradeFlag);
funcMap_.emplace(IBundleMgr::Message::SET_MODULE_NEED_UPDATE, &BundleMgrHost::HandleSetModuleUpgradeFlag);
funcMap_.emplace(IBundleMgr::Message::GET_HAP_MODULE_INFO_WITH_USERID,
&BundleMgrHost::HandleGetHapModuleInfoWithUserId);
funcMap_.emplace(IBundleMgr::Message::IMPLICIT_QUERY_INFO_BY_PRIORITY,
&BundleMgrHost::HandleImplicitQueryInfoByPriority);
funcMap_.emplace(IBundleMgr::Message::GET_ALL_DEPENDENT_MODULE_NAMES,
&BundleMgrHost::HandleGetAllDependentModuleNames);
funcMap_.emplace(IBundleMgr::Message::GET_SANDBOX_APP_BUNDLE_INFO, &BundleMgrHost::HandleGetSandboxBundleInfo);
}
int BundleMgrHost::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
APP_LOGD("bundle mgr host onReceived message, the message code is %{public}u", code);
@ -64,262 +187,13 @@ int BundleMgrHost::OnRemoteRequest(uint32_t code, MessageParcel &data, MessagePa
}
ErrCode errCode = ERR_OK;
switch (code) {
case IBundleMgr::Message::GET_APPLICATION_INFO:
errCode = HandleGetApplicationInfo(data, reply);
break;
case IBundleMgr::Message::GET_APPLICATION_INFO_WITH_INT_FLAGS:
errCode = HandleGetApplicationInfoWithIntFlags(data, reply);
break;
case IBundleMgr::Message::GET_APPLICATION_INFOS:
errCode = HandleGetApplicationInfos(data, reply);
break;
case IBundleMgr::Message::GET_APPLICATION_INFOS_WITH_INT_FLAGS:
errCode = HandleGetApplicationInfosWithIntFlags(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLE_INFO:
errCode = HandleGetBundleInfo(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLE_INFO_WITH_INT_FLAGS:
errCode = HandleGetBundleInfoWithIntFlags(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLE_PACK_INFO:
errCode = HandleGetBundlePackInfo(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLE_PACK_INFO_WITH_INT_FLAGS:
errCode = HandleGetBundlePackInfoWithIntFlags(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLE_INFOS:
errCode = HandleGetBundleInfos(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLE_INFOS_WITH_INT_FLAGS:
errCode = HandleGetBundleInfosWithIntFlags(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLE_NAME_FOR_UID:
errCode = HandleGetBundleNameForUid(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLES_FOR_UID:
errCode = HandleGetBundlesForUid(data, reply);
break;
case IBundleMgr::Message::GET_NAME_FOR_UID:
errCode = HandleGetNameForUid(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLE_GIDS:
errCode = HandleGetBundleGids(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLE_GIDS_BY_UID:
errCode = HandleGetBundleGidsByUid(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLE_INFOS_BY_METADATA:
errCode = HandleGetBundleInfosByMetaData(data, reply);
break;
case IBundleMgr::Message::QUERY_ABILITY_INFO:
errCode = HandleQueryAbilityInfo(data, reply);
break;
case IBundleMgr::Message::QUERY_ABILITY_INFO_MUTI_PARAM:
errCode = HandleQueryAbilityInfoMutiparam(data, reply);
break;
case IBundleMgr::Message::QUERY_ABILITY_INFOS:
errCode = HandleQueryAbilityInfos(data, reply);
break;
case IBundleMgr::Message::QUERY_ABILITY_INFOS_MUTI_PARAM:
errCode = HandleQueryAbilityInfosMutiparam(data, reply);
break;
case IBundleMgr::Message::QUERY_ABILITY_INFOS_FOR_CLONE:
errCode = HandleQueryAbilityInfosForClone(data, reply);
break;
case IBundleMgr::Message::QUERY_ALL_ABILITY_INFOS:
errCode = HandleQueryAllAbilityInfos(data, reply);
break;
case IBundleMgr::Message::QUERY_ABILITY_INFO_BY_URI:
errCode = HandleQueryAbilityInfoByUri(data, reply);
break;
case IBundleMgr::Message::QUERY_ABILITY_INFOS_BY_URI:
errCode = HandleQueryAbilityInfosByUri(data, reply);
break;
case IBundleMgr::Message::QUERY_ABILITY_INFO_BY_URI_FOR_USERID:
errCode = HandleQueryAbilityInfoByUriForUserId(data, reply);
break;
case IBundleMgr::Message::QUERY_KEEPALIVE_BUNDLE_INFOS:
errCode = HandleQueryKeepAliveBundleInfos(data, reply);
break;
case IBundleMgr::Message::GET_ABILITY_LABEL:
errCode = HandleGetAbilityLabel(data, reply);
break;
case IBundleMgr::Message::GET_ABILITY_LABEL_WITH_MODULE_NAME:
errCode = HandleGetAbilityLabelWithModuleName(data, reply);
break;
case IBundleMgr::Message::CHECK_IS_SYSTEM_APP_BY_UID:
errCode = HandleCheckIsSystemAppByUid(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLE_ARCHIVE_INFO:
errCode = HandleGetBundleArchiveInfo(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLE_ARCHIVE_INFO_WITH_INT_FLAGS:
errCode = HandleGetBundleArchiveInfoWithIntFlags(data, reply);
break;
case IBundleMgr::Message::GET_HAP_MODULE_INFO:
errCode = HandleGetHapModuleInfo(data, reply);
break;
case IBundleMgr::Message::GET_LAUNCH_WANT_FOR_BUNDLE:
errCode = HandleGetLaunchWantForBundle(data, reply);
break;
case IBundleMgr::Message::CHECK_PUBLICKEYS:
errCode = HandleCheckPublicKeys(data, reply);
break;
case IBundleMgr::Message::GET_PERMISSION_DEF:
errCode = HandleGetPermissionDef(data, reply);
break;
case IBundleMgr::Message::HAS_SYSTEM_CAPABILITY:
errCode = HandleHasSystemCapability(data, reply);
break;
case IBundleMgr::Message::GET_SYSTEM_AVAILABLE_CAPABILITIES:
errCode = HandleGetSystemAvailableCapabilities(data, reply);
break;
case IBundleMgr::Message::IS_SAFE_MODE:
errCode = HandleIsSafeMode(data, reply);
break;
case IBundleMgr::Message::CLEAN_BUNDLE_CACHE_FILES:
errCode = HandleCleanBundleCacheFiles(data, reply);
break;
case IBundleMgr::Message::CLEAN_BUNDLE_DATA_FILES:
errCode = HandleCleanBundleDataFiles(data, reply);
break;
case IBundleMgr::Message::REGISTER_BUNDLE_STATUS_CALLBACK:
errCode = HandleRegisterBundleStatusCallback(data, reply);
break;
case IBundleMgr::Message::CLEAR_BUNDLE_STATUS_CALLBACK:
errCode = HandleClearBundleStatusCallback(data, reply);
break;
case IBundleMgr::Message::UNREGISTER_BUNDLE_STATUS_CALLBACK:
errCode = HandleUnregisterBundleStatusCallback(data, reply);
break;
case IBundleMgr::Message::IS_APPLICATION_ENABLED:
errCode = HandleIsApplicationEnabled(data, reply);
break;
case IBundleMgr::Message::SET_APPLICATION_ENABLED:
errCode = HandleSetApplicationEnabled(data, reply);
break;
case IBundleMgr::Message::IS_ABILITY_ENABLED:
errCode = HandleIsAbilityEnabled(data, reply);
break;
case IBundleMgr::Message::SET_ABILITY_ENABLED:
errCode = HandleSetAbilityEnabled(data, reply);
break;
case IBundleMgr::Message::GET_ABILITY_INFO:
errCode = HandleGetAbilityInfo(data, reply);
break;
case IBundleMgr::Message::GET_ABILITY_INFO_WITH_MODULE_NAME:
errCode = HandleGetAbilityInfoWithModuleName(data, reply);
break;
#ifdef BUNDLE_FRAMEWORK_GRAPHICS
case IBundleMgr::Message::GET_ABILITY_PIXELMAP_ICON:
errCode = HandleGetAbilityPixelMapIcon(data, reply);
break;
case IBundleMgr::Message::GET_ABILITY_PIXELMAP_ICON_WITH_MODULE_NAME:
errCode = HandleGetAbilityPixelMapIconWithModuleName(data, reply);
break;
#endif
case IBundleMgr::Message::DUMP_INFOS:
errCode = HandleDumpInfos(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLE_INSTALLER:
errCode = HandleGetBundleInstaller(data, reply);
break;
case IBundleMgr::Message::GET_ALL_FORMS_INFO:
errCode = HandleGetAllFormsInfo(data, reply);
break;
case IBundleMgr::Message::GET_FORMS_INFO_BY_APP:
errCode = HandleGetFormsInfoByApp(data, reply);
break;
case IBundleMgr::Message::GET_FORMS_INFO_BY_MODULE:
errCode = HandleGetFormsInfoByModule(data, reply);
break;
case IBundleMgr::Message::GET_SHORTCUT_INFO:
errCode = HandleGetShortcutInfos(data, reply);
break;
case IBundleMgr::Message::GET_ALL_COMMON_EVENT_INFO:
errCode = HandleGetAllCommonEventInfo(data, reply);
break;
case IBundleMgr::Message::CHECK_BUNDLE_NAME_IN_ALLOWLIST:
errCode = HandleCheckBundleNameInAllowList(data, reply);
break;
case IBundleMgr::Message::BUNDLE_CLONE:
errCode = HandleBundleClone(data, reply);
break;
case IBundleMgr::Message::REMOVE_CLONED_BUNDLE:
errCode = HandleRemoveClonedBundle(data, reply);
break;
case IBundleMgr::Message::GET_BUNDLE_USER_MGR:
errCode = HandleGetBundleUserMgr(data, reply);
break;
case IBundleMgr::Message::GET_DISTRIBUTE_BUNDLE_INFO:
errCode = HandleGetDistributedBundleInfo(data, reply);
break;
case IBundleMgr::Message::GET_APPLICATION_PRIVILEGE_LEVEL:
errCode = HandleGetAppPrivilegeLevel(data, reply);
break;
case IBundleMgr::Message::QUERY_EXTENSION_INFO_WITHOUT_TYPE:
errCode = HandleQueryExtAbilityInfosWithoutType(data, reply);
break;
case IBundleMgr::Message::QUERY_EXTENSION_INFO:
errCode = HandleQueryExtAbilityInfos(data, reply);
break;
case IBundleMgr::Message::QUERY_EXTENSION_INFO_BY_TYPE:
errCode = HandleQueryExtAbilityInfosByType(data, reply);
break;
case IBundleMgr::Message::VERIFY_CALLING_PERMISSION:
errCode = HandleVerifyCallingPermission(data, reply);
break;
case IBundleMgr::Message::GET_ACCESSIBLE_APP_CODE_PATH:
errCode = HandleGetAccessibleAppCodePaths(data, reply);
break;
case IBundleMgr::Message::QUERY_EXTENSION_ABILITY_INFO_BY_URI:
errCode = HandleQueryExtensionAbilityInfoByUri(data, reply);
break;
case IBundleMgr::Message::GET_APPID_BY_BUNDLE_NAME:
errCode = HandleGetAppIdByBundleName(data, reply);
break;
case IBundleMgr::Message::GET_APP_TYPE:
errCode = HandleGetAppType(data, reply);
break;
case IBundleMgr::Message::GET_UID_BY_BUNDLE_NAME:
errCode = HandleGetUidByBundleName(data, reply);
break;
case IBundleMgr::Message::IS_MODULE_REMOVABLE:
errCode = HandleIsModuleRemovable(data, reply);
break;
case IBundleMgr::Message::SET_MODULE_REMOVABLE:
errCode = HandleSetModuleRemovable(data, reply);
break;
case IBundleMgr::Message::QUERY_ABILITY_INFO_WITH_CALLBACK:
errCode = HandleQueryAbilityInfoWithCallback(data, reply);
break;
case IBundleMgr::Message::UPGRADE_ATOMIC_SERVICE:
errCode = HandleUpgradeAtomicService(data, reply);
break;
case IBundleMgr::Message::IS_MODULE_NEED_UPDATE:
errCode = HandleGetModuleUpgradeFlag(data, reply);
break;
case IBundleMgr::Message::SET_MODULE_NEED_UPDATE:
errCode = HandleSetModuleUpgradeFlag(data, reply);
break;
case IBundleMgr::Message::GET_HAP_MODULE_INFO_WITH_USERID:
errCode = HandleGetHapModuleInfoWithUserId(data, reply);
break;
case IBundleMgr::Message::IMPLICIT_QUERY_INFO_BY_PRIORITY:
errCode = HandleImplicitQueryInfoByPriority(data, reply);
break;
case IBundleMgr::Message::GET_ALL_DEPENDENT_MODULE_NAMES:
errCode = HandleGetAllDependentModuleNames(data, reply);
break;
case IBundleMgr::Message::GET_SANDBOX_APP_BUNDLE_INFO:
errCode = HandleGetSandboxBundleInfo(data, reply);
break;
default:
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
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);
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
// if ERR_OK return ipc NO_ERROR, else return ipc UNKNOW_ERROR
APP_LOGD("bundlemgr host finish to process message");
return (errCode == ERR_OK) ? NO_ERROR : UNKNOWN_ERROR;
}

View File

@ -256,8 +256,8 @@ void BundleInstallerHost::HandleCreateStreamInstaller(Parcel &data, Parcel &repl
if (streamInstaller == nullptr) {
if (!reply.WriteBool(false)) {
APP_LOGE("write result failed");
return;
}
return;
}
if (!reply.WriteBool(true)) {
APP_LOGE("write result failed");

View File

@ -29,8 +29,6 @@ BundleSandboxDataMgr::BundleSandboxDataMgr()
BundleSandboxDataMgr::~BundleSandboxDataMgr()
{
APP_LOGI("BundleSandboxDataMgr instance is destroyed");
sandboxAppInfos_.clear();
sandboxAppIndexMap_.clear();
}
void BundleSandboxDataMgr::SaveSandboxAppInfo(const InnerBundleInfo &info, const int32_t &appIndex)
@ -43,11 +41,6 @@ void BundleSandboxDataMgr::SaveSandboxAppInfo(const InnerBundleInfo &info, const
}
std::string key = bundleName + Constants::FILE_UNDERLINE + std::to_string(appIndex);
std::unique_lock<std::shared_mutex> lock(sandboxAppMutex_);
if (sandboxAppInfos_.find(key) == sandboxAppInfos_.end()) {
sandboxAppInfos_.emplace(key, info);
APP_LOGD("save sandbox app %{public}s info successfully", key.c_str());
return;
}
sandboxAppInfos_[key] = info;
APP_LOGD("save sandbox app %{public}s info successfully", key.c_str());
}
@ -61,12 +54,11 @@ void BundleSandboxDataMgr::DeleteSandboxAppInfo(const std::string &bundleName, c
}
auto key = bundleName + Constants::FILE_UNDERLINE + std::to_string(appIndex);
std::unique_lock<std::shared_mutex> lock(sandboxAppMutex_);
auto it = sandboxAppInfos_.find(key);
if (it == sandboxAppInfos_.end()) {
auto ret = sandboxAppInfos_.erase(key);
if (ret == 0) {
APP_LOGE("delete sandbox app info failed due to no sandbox app in the dataMgr");
return;
}
sandboxAppInfos_.erase(it);
APP_LOGD("delete sandbox app %{public}s info successfully", key.c_str());
}
@ -144,23 +136,24 @@ int32_t BundleSandboxDataMgr::GenerateSandboxAppIndex(const std::string &bundleN
return Constants::INITIAL_APP_INDEX;
}
std::unique_lock<std::mutex> lock(sandboxAppIndexMapMutex_);
auto it = sandboxAppIndexMap_.find(bundleName);
if (it == sandboxAppIndexMap_.end()) {
auto firstIterator = sandboxAppIndexMap_.find(bundleName);
if (firstIterator == sandboxAppIndexMap_.end()) {
std::set<int32_t> innerSet { Constants::INITIAL_APP_INDEX + 1 };
sandboxAppIndexMap_.emplace(bundleName, innerSet);
APP_LOGD("GenerateSandboxAppIndex successfully");
return Constants::INITIAL_APP_INDEX + 1;
}
if (it->second.empty()) {
it->second.insert(Constants::INITIAL_APP_INDEX + 1);
if (firstIterator->second.empty()) {
firstIterator->second.insert(Constants::INITIAL_APP_INDEX + 1);
APP_LOGD("GenerateSandboxAppIndex successfully");
return Constants::INITIAL_APP_INDEX + 1;
}
int32_t pre = Constants::INITIAL_APP_INDEX;
for (auto index = it->second.begin(); index != it->second.end(); ++index) {
if (*index == pre + 1) {
for (auto secondIterator = firstIterator->second.begin(); secondIterator != firstIterator->second.end();
++secondIterator) {
if (*secondIterator == pre + 1) {
pre++;
continue;
}
@ -172,7 +165,7 @@ int32_t BundleSandboxDataMgr::GenerateSandboxAppIndex(const std::string &bundleN
APP_LOGE("GenerateSandboxAppIndex failed due to exceed limitation of maximum appIndex");
return Constants::INITIAL_APP_INDEX;
}
it->second.insert(newAppIndex);
firstIterator->second.insert(newAppIndex);
APP_LOGD("GenerateSandboxAppIndex successfully with appIndex %{public}d", newAppIndex);
return newAppIndex;
}
@ -190,13 +183,13 @@ bool BundleSandboxDataMgr::DeleteSandboxAppIndex(const std::string &bundleName,
APP_LOGE("no sandbox app can be found %{public}s", bundleName.c_str());
return false;
}
auto itt = it->second.find(appIndex);
if (itt == it->second.end()) {
auto ret = it->second.erase(appIndex);
if (ret == 0) {
APP_LOGE("no sandbox app index can be found %{public}d", appIndex);
return false;
}
it->second.erase(itt);
if (it->second.empty()) {
sandboxAppIndexMap_.erase(bundleName);
}