mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2024-11-27 09:20:49 +00:00
Merge remote-tracking branch 'upstream/master' into master001
This commit is contained in:
commit
034ab56123
@ -80,6 +80,16 @@ enum class MultiAppModeType : uint8_t {
|
||||
|
||||
enum class ApplicationInfoFlag {
|
||||
FLAG_INSTALLED = 0x00000001,
|
||||
/**
|
||||
* Indicates the installation source of pre-installed applications
|
||||
* App upgrades will not change installation source
|
||||
* FLAG_BOOT_INSTALLED App installed during first boot
|
||||
* FLAG_OTA_INSTALLED App installed during OTA
|
||||
* FLAG_RECOVER_INSTALLED App recover
|
||||
*/
|
||||
FLAG_BOOT_INSTALLED = 0x00000002,
|
||||
FLAG_OTA_INSTALLED = 0x00000004,
|
||||
FLAG_RECOVER_INSTALLED = 0x00000008,
|
||||
};
|
||||
|
||||
struct MultiAppModeData : public Parcelable {
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "application_info.h"
|
||||
#include "bundle_constants.h"
|
||||
#include "parcel.h"
|
||||
namespace OHOS {
|
||||
@ -92,6 +93,7 @@ struct InstallParam : public Parcelable {
|
||||
std::string additionalInfo = "";
|
||||
// utilizing for code-signature
|
||||
std::map<std::string, std::string> verifyCodeParams;
|
||||
ApplicationInfoFlag preinstallSourceFlag = ApplicationInfoFlag::FLAG_INSTALLED;
|
||||
// the parcel object function is not const.
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
@ -38,6 +38,7 @@ config("bundlemgr_common_config") {
|
||||
"include/navigation",
|
||||
"include/shared",
|
||||
"include/quick_fix/state/include",
|
||||
"include/utd",
|
||||
"include/verify",
|
||||
"../../interfaces/inner_api/appexecfwk_base/include",
|
||||
"../../interfaces/inner_api/bundlemgr_extension/include",
|
||||
|
@ -72,6 +72,7 @@ bundle_install_sources = [
|
||||
"${services_path}/bundlemgr/src/shared/shared_bundle_installer.cpp",
|
||||
"${services_path}/bundlemgr/src/status_receiver_proxy.cpp",
|
||||
"${services_path}/bundlemgr/src/system_bundle_installer.cpp",
|
||||
"${services_path}/bundlemgr/src/utd/utd_handler.cpp",
|
||||
"${services_path}/bundlemgr/src/xcollie_helper.cpp",
|
||||
]
|
||||
|
||||
|
@ -186,6 +186,8 @@ protected:
|
||||
|
||||
ErrCode RollbackHmpCommonInfo(const std::string &bundleName);
|
||||
|
||||
bool HasDriverExtensionAbility(const std::string &bundleName);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief The real procedure for system and normal bundle install.
|
||||
@ -724,6 +726,8 @@ private:
|
||||
std::string GetInstallSource(const InstallParam &installParam) const;
|
||||
void SetInstallSourceToAppInfo(std::unordered_map<std::string, InnerBundleInfo> &infos,
|
||||
const InstallParam &installParam) const;
|
||||
void SetApplicationFlagsForPreinstallSource(std::unordered_map<std::string, InnerBundleInfo> &infos,
|
||||
const InstallParam &installParam) const;
|
||||
bool IsAppInBlocklist(const std::string &bundleName, const int32_t userId) const;
|
||||
bool CheckWhetherCanBeUninstalled(const std::string &bundleName) const;
|
||||
void CheckSystemFreeSizeAndClean() const;
|
||||
|
@ -1052,7 +1052,7 @@ private:
|
||||
std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex = 0) const;
|
||||
void GetAllExtensionInfosByExtensionTypeName(const std::string &typeName, uint32_t flags, int32_t userId,
|
||||
const InnerBundleInfo &info, std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex = 0) const;
|
||||
bool MatchUtd(Skill &skill, const std::string &utd, int32_t count) const;
|
||||
bool MatchUtd(const Skill &skill, const std::string &utd, int32_t count) const;
|
||||
bool MatchUtd(const std::string &skillUtd, const std::string &wantUtd) const;
|
||||
bool MatchTypeWithUtd(const std::string &mimeType, const std::string &wantUtd) const;
|
||||
std::vector<int32_t> GetCloneAppIndexesNoLock(const std::string &bundleName, int32_t userId) const;
|
||||
@ -1176,7 +1176,8 @@ private:
|
||||
int32_t originalUserId, BundleInfo &bundleInfo) const;
|
||||
void GetExtensionAbilityInfoByTypeName(uint32_t flags, int32_t userId,
|
||||
std::vector<ExtensionAbilityInfo> &infos, const std::string &typeName) const;
|
||||
|
||||
bool GetShortcutInfosByInnerBundleInfo(
|
||||
const InnerBundleInfo &info, std::vector<ShortcutInfo> &shortcutInfos) const;
|
||||
private:
|
||||
mutable std::shared_mutex bundleInfoMutex_;
|
||||
mutable std::mutex stateMutex_;
|
||||
|
@ -113,8 +113,6 @@ private:
|
||||
|
||||
void RecoverDriverForAllUsers(const std::string &bundleName, const InstallParam &installParam);
|
||||
|
||||
bool HasDriverExtensionAbility(const std::string &bundleName);
|
||||
|
||||
private:
|
||||
const int64_t installerId_ = 0;
|
||||
const sptr<IStatusReceiver> statusReceiver_;
|
||||
|
@ -527,6 +527,8 @@ private:
|
||||
void ProcessCheckRecoverableApplicationInfo();
|
||||
void InnerProcessCheckRecoverableApplicationInfo();
|
||||
|
||||
bool InnerProcessUninstallForExistPreBundle(const BundleInfo &installedInfo);
|
||||
|
||||
void PrepareBundleDirQuota(const std::string &bundleName, const int32_t uid,
|
||||
const std::string &bundleDataDirPath, const int32_t limitSize) const;
|
||||
void RefreshQuotaForAllUid();
|
||||
@ -627,6 +629,7 @@ private:
|
||||
const std::unordered_map<std::string, InnerBundleInfo> &innerBundleInfos);
|
||||
void InnerProcessRebootUninstallWrongBundle();
|
||||
void ProcessCheckAppEl1Dir();
|
||||
void static ProcessCheckAppEl1DirTask();
|
||||
void CleanAllBundleShaderCache() const;
|
||||
// Used to save the information parsed by Hap in the scanned directory.
|
||||
std::map<std::string, std::unordered_map<std::string, InnerBundleInfo>> hapParseInfoMap_;
|
||||
|
@ -38,6 +38,7 @@ constexpr const char* DIR_EL1 = "el1";
|
||||
constexpr const char* DIR_EL2 = "el2";
|
||||
constexpr const char* DIR_EL3 = "el3";
|
||||
constexpr const char* DIR_EL4 = "el4";
|
||||
constexpr const char* DIR_EL5 = "el5";
|
||||
const std::vector<std::string> BUNDLE_EL = {DIR_EL1, DIR_EL2, DIR_EL3, DIR_EL4};
|
||||
constexpr const char* ARM_EABI = "armeabi";
|
||||
constexpr const char* ARM_EABI_V7A = "armeabi-v7a";
|
||||
|
@ -2102,6 +2102,8 @@ public:
|
||||
baseApplicationInfo_->installSource = installSource;
|
||||
}
|
||||
|
||||
void SetApplicationFlags(ApplicationInfoFlag flag);
|
||||
|
||||
void UpdateExtensionSandboxInfo(const std::vector<std::string> &typeList);
|
||||
std::vector<std::string> GetAllExtensionDirsInSpecifiedModule(const std::string &moduleName) const;
|
||||
std::vector<std::string> GetAllExtensionDirs() const;
|
||||
@ -2225,6 +2227,7 @@ public:
|
||||
ErrCode UpdateAppEncryptedStatus(const std::string &bundleName, bool isExisted, int32_t appIndex);
|
||||
std::set<int32_t> GetCloneBundleAppIndexes() const;
|
||||
static uint8_t GetSanitizerFlag(GetInnerModuleInfoFlag flag);
|
||||
void InnerProcessShortcut(const Shortcut &oldShortcut, ShortcutInfo &shortcutInfo) const;
|
||||
|
||||
private:
|
||||
bool IsExistLauncherAbility() const;
|
||||
@ -2245,7 +2248,6 @@ private:
|
||||
void GetBundleWithExtensionAbilitiesV9(int32_t flags, HapModuleInfo &hapModuleInfo, int32_t appIndex = 0) const;
|
||||
IsolationMode GetIsolationMode(const std::string &isolationMode) const;
|
||||
void UpdateIsCompressNativeLibs();
|
||||
void InnerProcessShortcut(const Shortcut &oldShortcut, ShortcutInfo &shortcutInfo) const;
|
||||
void InnerProcessRequestPermissions(
|
||||
const std::unordered_map<std::string, std::string> &moduleNameMap,
|
||||
std::vector<RequestPermission> &requestPermissions) const;
|
||||
|
@ -138,7 +138,7 @@ public:
|
||||
std::vector<int64_t> &bundleStats, const int32_t uid = Constants::INVALID_UID,
|
||||
const int32_t appIndex = 0) override;
|
||||
|
||||
virtual ErrCode GetAllBundleStats(const std::vector<std::string> &bundleNames, const int32_t userId,
|
||||
virtual ErrCode GetAllBundleStats(const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const std::vector<int32_t> &uids) override;
|
||||
/**
|
||||
* @brief Set dir apl.
|
||||
|
@ -117,7 +117,7 @@ public:
|
||||
ErrCode GetBundleStats(const std::string &bundleName, const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const int32_t uid = Constants::INVALID_UID, const int32_t appIndex = 0);
|
||||
|
||||
ErrCode GetAllBundleStats(const std::vector<std::string> &bundleNames, const int32_t userId,
|
||||
ErrCode GetAllBundleStats(const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const std::vector<int32_t> &uids);
|
||||
|
||||
/**
|
||||
|
@ -200,7 +200,7 @@ public:
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
virtual ErrCode GetAllBundleStats(const std::vector<std::string> &bundleNames, const int32_t userId,
|
||||
virtual ErrCode GetAllBundleStats(const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const std::vector<int32_t> &uids)
|
||||
{
|
||||
return ERR_OK;
|
||||
|
@ -140,7 +140,7 @@ public:
|
||||
std::vector<int64_t> &bundleStats, const int32_t uid = Constants::INVALID_UID,
|
||||
const int32_t appIndex = 0) override;
|
||||
|
||||
virtual ErrCode GetAllBundleStats(const std::vector<std::string> &bundleNames, const int32_t userId,
|
||||
virtual ErrCode GetAllBundleStats(const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const std::vector<int32_t> &uids) override;
|
||||
/**
|
||||
* @brief Set dir apl.
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include "quick_fix_manager_db_interface.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
|
||||
#include "quick_fix_status_callback_interface.h"
|
||||
@ -46,7 +45,6 @@ public:
|
||||
private:
|
||||
void InitStatesMap();
|
||||
|
||||
mutable std::mutex mutex_;
|
||||
std::shared_ptr<IQuickFixManagerDb> quickFixManagerDb_ = nullptr;
|
||||
std::multimap<QuickFixStatus, QuickFixStatus> statesMap_;
|
||||
};
|
||||
|
34
services/bundlemgr/include/utd/utd_handler.h
Normal file
34
services/bundlemgr/include/utd/utd_handler.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 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_UTD_UTD_HANDLER
|
||||
#define FOUNDATION_BUNDLE_FRAMEWORK_UTD_UTD_HANDLER
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class UtdHandler final {
|
||||
public:
|
||||
static void InstallUtdAsync(const std::string &bundleName, const int32_t userId);
|
||||
static void UninstallUtdAsync(const std::string &bundleName, const int32_t userId);
|
||||
private:
|
||||
static std::string GetEntryHapPath(const std::string &bundleName, const int32_t userId);
|
||||
static std::string GetUtdProfileFromHap(const std::string &hapPath);
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // FOUNDATION_BUNDLE_FRAMEWORK_UTD_UTD_HANDLER
|
@ -549,7 +549,7 @@ ErrCode AppServiceFwkInstaller::InnerProcessInstall(
|
||||
if (result != ERR_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
newInfo.SetApplicationFlags(installParam.preinstallSourceFlag);
|
||||
MergeBundleInfos(newInfo);
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include "parameters.h"
|
||||
#include "perf_profile.h"
|
||||
#include "scope_guard.h"
|
||||
#include "utd_handler.h"
|
||||
#ifdef BUNDLE_FRAMEWORK_OVERLAY_INSTALLATION
|
||||
#include "bundle_overlay_data_manager.h"
|
||||
#include "bundle_overlay_install_checker.h"
|
||||
@ -215,7 +216,7 @@ ErrCode BaseBundleInstaller::InstallBundle(
|
||||
.abilityName = mainAbility_,
|
||||
.appDistributionType = appDistributionType_,
|
||||
};
|
||||
if (installParam.allUser) {
|
||||
if (installParam.allUser || HasDriverExtensionAbility(bundleName_)) {
|
||||
AddBundleStatus(installRes);
|
||||
} else if (NotifyBundleStatus(installRes) != ERR_OK) {
|
||||
LOG_W(BMS_TAG_INSTALLER, "notify status failed for installation");
|
||||
@ -339,6 +340,14 @@ ErrCode BaseBundleInstaller::UninstallBundle(const std::string &bundleName, cons
|
||||
isUninstalledFromBmsExtension = true;
|
||||
result = ERR_OK;
|
||||
}
|
||||
|
||||
if (result == ERR_OK) {
|
||||
UtdHandler::UninstallUtdAsync(bundleName, userId_);
|
||||
#ifdef BUNDLE_FRAMEWORK_DEFAULT_APP
|
||||
DefaultAppMgr::GetInstance().HandleUninstallBundle(userId_, bundleName);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (installParam.needSendEvent && dataMgr_) {
|
||||
NotifyBundleEvents installRes = {
|
||||
.isAgingUninstall = installParam.isAgingUninstall,
|
||||
@ -359,12 +368,6 @@ ErrCode BaseBundleInstaller::UninstallBundle(const std::string &bundleName, cons
|
||||
}
|
||||
}
|
||||
|
||||
if (result == ERR_OK) {
|
||||
#ifdef BUNDLE_FRAMEWORK_DEFAULT_APP
|
||||
DefaultAppMgr::GetInstance().HandleUninstallBundle(userId_, bundleName);
|
||||
#endif
|
||||
}
|
||||
|
||||
SendBundleSystemEvent(
|
||||
bundleName,
|
||||
BundleEventType::UNINSTALL,
|
||||
@ -883,6 +886,7 @@ ErrCode BaseBundleInstaller::InnerProcessBundleInstall(std::unordered_map<std::s
|
||||
LOG_I(BMS_TAG_INSTALLER, "SetIsFreeInstallApp(%{public}d)",
|
||||
InstallFlag::FREE_INSTALL == installParam.installFlag);
|
||||
newInfo.SetIsFreeInstallApp(InstallFlag::FREE_INSTALL == installParam.installFlag);
|
||||
SetApplicationFlagsForPreinstallSource(newInfos, installParam);
|
||||
result = ProcessBundleInstallStatus(newInfo, uid);
|
||||
CHECK_RESULT(result, "ProcessBundleInstallStatus failed %{public}d");
|
||||
|
||||
@ -1334,6 +1338,7 @@ ErrCode BaseBundleInstaller::ProcessBundleInstall(const std::vector<std::string>
|
||||
BundleResourceHelper::AddResourceInfoByBundleName(bundleName_, userId_);
|
||||
VerifyDomain();
|
||||
MarkInstallFinish();
|
||||
UtdHandler::InstallUtdAsync(bundleName_, userId_);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1944,6 +1949,7 @@ ErrCode BaseBundleInstaller::InnerProcessInstallByPreInstallInfo(
|
||||
userGuard.Dismiss();
|
||||
uid = oldInfo.GetUid(userId_);
|
||||
GetInstallEventInfo(oldInfo, sysEventInfo_);
|
||||
UtdHandler::InstallUtdAsync(bundleName, userId_);
|
||||
return ERR_OK;
|
||||
}
|
||||
}
|
||||
@ -2215,8 +2221,9 @@ ErrCode BaseBundleInstaller::ProcessNewModuleInstall(InnerBundleInfo &newInfo, I
|
||||
return ERR_APPEXECFWK_INSTALL_CHECK_PROXY_DATA_URI_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
oldInfo.SetInstallMark(bundleName_, modulePackage_, InstallExceptionStatus::UPDATING_NEW_START);
|
||||
if (isAppExist_) {
|
||||
oldInfo.SetInstallMark(bundleName_, modulePackage_, InstallExceptionStatus::UPDATING_NEW_START);
|
||||
}
|
||||
if (!dataMgr_->SaveInnerBundleInfo(oldInfo)) {
|
||||
LOG_E(BMS_TAG_INSTALLER, "save install mark failed");
|
||||
return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR;
|
||||
@ -3927,6 +3934,15 @@ void BaseBundleInstaller::SetInstallSourceToAppInfo(std::unordered_map<std::stri
|
||||
}
|
||||
}
|
||||
|
||||
void BaseBundleInstaller::SetApplicationFlagsForPreinstallSource(
|
||||
std::unordered_map<std::string, InnerBundleInfo> &infos, const InstallParam &installParam) const
|
||||
{
|
||||
std::string installSource = GetInstallSource(installParam);
|
||||
for (auto &info : infos) {
|
||||
info.second.SetApplicationFlags(installParam.preinstallSourceFlag);
|
||||
}
|
||||
}
|
||||
|
||||
void BaseBundleInstaller::SetAppDistributionType(const std::unordered_map<std::string, InnerBundleInfo> &infos)
|
||||
{
|
||||
if (infos.empty()) {
|
||||
@ -6125,5 +6141,28 @@ void BaseBundleInstaller::MarkInstallFinish()
|
||||
LOG_W(BMS_TAG_INSTALLER, "save mark failed");
|
||||
}
|
||||
}
|
||||
|
||||
bool BaseBundleInstaller::HasDriverExtensionAbility(const std::string &bundleName)
|
||||
{
|
||||
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
|
||||
if (dataMgr == nullptr) {
|
||||
APP_LOGE("Get dataMgr shared_ptr nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
InnerBundleInfo info;
|
||||
bool isAppExist = dataMgr->FetchInnerBundleInfo(bundleName, info);
|
||||
if (isAppExist) {
|
||||
const auto extensions = info.GetInnerExtensionInfos();
|
||||
for (const auto &item : extensions) {
|
||||
if (item.second.type == ExtensionAbilityType::DRIVER) {
|
||||
APP_LOGI("find driver extension ability, bundleName: %{public}s, moduleName: %{public}s",
|
||||
item.second.bundleName.c_str(), item.second.moduleName.c_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -90,9 +90,10 @@ constexpr const char* PROFILE_PATH = "resources/base/profile/";
|
||||
constexpr const char* PROFILE_PREFIX = "$profile:";
|
||||
constexpr const char* JSON_SUFFIX = ".json";
|
||||
constexpr const char* SCHEME_HTTPS = "https";
|
||||
const char* BMS_EVENT_ADDITIONAL_INFO_CHANGED = "bms.event.ADDITIONAL_INFO_CHANGED";
|
||||
const char* ENTRY = "entry";
|
||||
const char* CLONE_BUNDLE_PREFIX = "clone_";
|
||||
constexpr const char* META_DATA_SHORTCUTS_NAME = "ohos.ability.shortcuts";
|
||||
constexpr const char* BMS_EVENT_ADDITIONAL_INFO_CHANGED = "bms.event.ADDITIONAL_INFO_CHANGED";
|
||||
constexpr const char* ENTRY = "entry";
|
||||
constexpr const char* CLONE_BUNDLE_PREFIX = "clone_";
|
||||
|
||||
const std::map<ProfileType, const char*> PROFILE_TYPE_MAP = {
|
||||
{ ProfileType::INTENT_PROFILE, INTENT_PROFILE_PATH },
|
||||
@ -110,6 +111,7 @@ constexpr int8_t INVALID_BUNDLEID = -1;
|
||||
constexpr int32_t DATA_GROUP_UID_OFFSET = 100000;
|
||||
constexpr int32_t MAX_APP_UID = 65535;
|
||||
constexpr int16_t DATA_GROUP_DIR_MODE = 02770;
|
||||
constexpr int8_t ONLY_ONE_USER = 1;
|
||||
}
|
||||
|
||||
BundleDataMgr::BundleDataMgr()
|
||||
@ -1773,40 +1775,39 @@ bool BundleDataMgr::MatchShare(const Want &want, const std::vector<Skill> &skill
|
||||
}
|
||||
auto shareSummary = pickerSummary.GetWantParams(WANT_PARAM_SUMMARY);
|
||||
auto utds = shareSummary.KeySet();
|
||||
for (auto &skill : shareActionSkills) {
|
||||
bool match = true;
|
||||
for (const auto &utd : utds) {
|
||||
int32_t count = shareSummary.GetIntParam(utd, DEFAULT_SUMMARY_COUNT);
|
||||
if (count <= DEFAULT_SUMMARY_COUNT) {
|
||||
LOG_W(BMS_TAG_QUERY, "invalid utd count");
|
||||
return false;
|
||||
}
|
||||
if (!MatchUtd(skill, utd, count)) {
|
||||
match = false;
|
||||
for (const auto &utd : utds) {
|
||||
int32_t count = shareSummary.GetIntParam(utd, DEFAULT_SUMMARY_COUNT);
|
||||
if (count <= DEFAULT_SUMMARY_COUNT) {
|
||||
LOG_W(BMS_TAG_QUERY, "invalid utd count");
|
||||
return false;
|
||||
}
|
||||
bool match = false;
|
||||
for (const auto &skill : shareActionSkills) {
|
||||
if (MatchUtd(skill, utd, count)) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
return true;
|
||||
if (!match) {
|
||||
LOG_D(BMS_TAG_QUERY, "match failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BundleDataMgr::MatchUtd(Skill &skill, const std::string &utd, int32_t count) const
|
||||
bool BundleDataMgr::MatchUtd(const Skill &skill, const std::string &utd, int32_t count) const
|
||||
{
|
||||
for (SkillUri &skillUri : skill.uris) {
|
||||
for (const SkillUri &skillUri : skill.uris) {
|
||||
if (skillUri.maxFileSupported < count) {
|
||||
continue;
|
||||
}
|
||||
if (!skillUri.utd.empty()) {
|
||||
if (MatchUtd(skillUri.utd, utd)) {
|
||||
skillUri.maxFileSupported -= count;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (MatchTypeWithUtd(skillUri.type, utd)) {
|
||||
skillUri.maxFileSupported -= count;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -2673,6 +2674,13 @@ bool BundleDataMgr::GetBundleInfo(
|
||||
bundleName.c_str(), requestUserId);
|
||||
return false;
|
||||
}
|
||||
// for only one user, bundle info can not be obtained during installation
|
||||
if ((innerBundleInfo.GetInnerBundleUserInfos().size() <= ONLY_ONE_USER) &&
|
||||
(innerBundleInfo.GetInstallMark().status == InstallExceptionStatus::INSTALL_START)) {
|
||||
LOG_NOFUNC_W(BMS_TAG_QUERY, "GetBundleInfo failed -n %{public}s -u %{public}d, not ready",
|
||||
bundleName.c_str(), requestUserId);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t responseUserId = innerBundleInfo.GetResponseUserId(requestUserId);
|
||||
innerBundleInfo.GetBundleInfo(flags, bundleInfo, responseUserId);
|
||||
@ -2720,6 +2728,13 @@ ErrCode BundleDataMgr::GetBundleInfoV9(
|
||||
ret, bundleName.c_str());
|
||||
return ret;
|
||||
}
|
||||
// for only one user, bundle info can not be obtained during installation
|
||||
if ((innerBundleInfo.GetInnerBundleUserInfos().size() <= ONLY_ONE_USER) &&
|
||||
(innerBundleInfo.GetInstallMark().status == InstallExceptionStatus::INSTALL_START)) {
|
||||
LOG_NOFUNC_W(BMS_TAG_QUERY, "GetBundleInfo failed -n %{public}s -u %{public}d, not ready",
|
||||
bundleName.c_str(), requestUserId);
|
||||
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
|
||||
}
|
||||
|
||||
int32_t responseUserId = innerBundleInfo.GetResponseUserId(requestUserId);
|
||||
innerBundleInfo.GetBundleInfoV9(flags, bundleInfo, responseUserId, appIndex);
|
||||
@ -3569,7 +3584,7 @@ bool BundleDataMgr::GetAllBundleStats(const int32_t userId, std::vector<int64_t>
|
||||
uids.emplace_back(uid);
|
||||
}
|
||||
}
|
||||
if (InstalldClient::GetInstance()->GetAllBundleStats(bundleNames, responseUserId, bundleStats, uids) != ERR_OK) {
|
||||
if (InstalldClient::GetInstance()->GetAllBundleStats(responseUserId, bundleStats, uids) != ERR_OK) {
|
||||
APP_LOGW("GetAllBundleStats failed, userId: %{public}d", responseUserId);
|
||||
return false;
|
||||
}
|
||||
@ -3577,20 +3592,6 @@ bool BundleDataMgr::GetAllBundleStats(const int32_t userId, std::vector<int64_t>
|
||||
APP_LOGE("bundle stats is empty");
|
||||
return true;
|
||||
}
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(bundleInfoMutex_);
|
||||
for (const auto &bundleName : bundleNames) {
|
||||
auto infoItem = bundleInfos_.find(bundleName);
|
||||
if (infoItem == bundleInfos_.end()) {
|
||||
return false;
|
||||
}
|
||||
if (infoItem->second.IsPreInstallApp()) {
|
||||
for (const auto &innerModuleInfo : infoItem->second.GetInnerModuleInfos()) {
|
||||
bundleStats[0] += BundleUtil::GetFileSize(innerModuleInfo.second.hapPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -4822,7 +4823,55 @@ bool BundleDataMgr::GetShortcutInfos(
|
||||
bundleName.c_str(), requestUserId);
|
||||
return false;
|
||||
}
|
||||
innerBundleInfo.GetShortcutInfos(shortcutInfos);
|
||||
GetShortcutInfosByInnerBundleInfo(innerBundleInfo, shortcutInfos);
|
||||
return true;
|
||||
}
|
||||
bool BundleDataMgr::GetShortcutInfosByInnerBundleInfo(
|
||||
const InnerBundleInfo &info, std::vector<ShortcutInfo> &shortcutInfos) const
|
||||
{
|
||||
if (!info.GetIsNewVersion()) {
|
||||
info.GetShortcutInfos(shortcutInfos);
|
||||
return true;
|
||||
}
|
||||
AbilityInfo abilityInfo;
|
||||
info.GetMainAbilityInfo(abilityInfo);
|
||||
if (abilityInfo.hapPath.empty() || abilityInfo.metadata.size() <= 0) {
|
||||
return false;
|
||||
}
|
||||
std::string rawData;
|
||||
for (const auto &meta : abilityInfo.metadata) {
|
||||
if (meta.name.compare(META_DATA_SHORTCUTS_NAME) == 0) {
|
||||
std::string resName = meta.resource;
|
||||
std::string hapPath = abilityInfo.hapPath;
|
||||
size_t pos = resName.rfind(PROFILE_PREFIX);
|
||||
bool posValid = (pos != std::string::npos) && (pos != resName.length() - strlen(PROFILE_PREFIX));
|
||||
if (!posValid) {
|
||||
APP_LOGE("resName invalid %{public}s", resName.c_str());
|
||||
return false;
|
||||
}
|
||||
std::string profileName = PROFILE_PATH + resName.substr(pos + strlen(PROFILE_PREFIX)) + JSON_SUFFIX;
|
||||
GetJsonProfileByExtractor(hapPath, profileName, rawData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rawData.empty()) {
|
||||
APP_LOGE("shortcutinfo is empty");
|
||||
return false;
|
||||
}
|
||||
nlohmann::json jsonObject = nlohmann::json::parse(rawData, nullptr, false);
|
||||
if (jsonObject.is_discarded()) {
|
||||
APP_LOGE("shortcuts json invalid");
|
||||
return false;
|
||||
}
|
||||
ShortcutJson shortcutJson = jsonObject.get<ShortcutJson>();
|
||||
for (const Shortcut &item : shortcutJson.shortcuts) {
|
||||
ShortcutInfo shortcutInfo;
|
||||
shortcutInfo.bundleName = abilityInfo.bundleName;
|
||||
shortcutInfo.moduleName = abilityInfo.moduleName;
|
||||
info.InnerProcessShortcut(item, shortcutInfo);
|
||||
shortcutInfo.sourceType = 1;
|
||||
shortcutInfos.emplace_back(shortcutInfo);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -4844,7 +4893,7 @@ ErrCode BundleDataMgr::GetShortcutInfoV9(
|
||||
return ret;
|
||||
}
|
||||
|
||||
innerBundleInfo.GetShortcutInfos(shortcutInfos);
|
||||
GetShortcutInfosByInnerBundleInfo(innerBundleInfo, shortcutInfos);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
@ -119,8 +119,9 @@ void BundleExceptionHandler::InnerHandleInvalidBundle(InnerBundleInfo &info, boo
|
||||
auto moduleDataDir = info.GetBundleName() + ServiceConstants::HAPS + mark.packageName;
|
||||
|
||||
// install and update failed before service restart
|
||||
if (mark.status == InstallExceptionStatus::INSTALL_START &&
|
||||
RemoveBundleAndDataDir(appCodePath, info.GetBundleName(), info.GetUserId())) {
|
||||
if (mark.status == InstallExceptionStatus::INSTALL_START) {
|
||||
// unable to distinguish which user failed the installation
|
||||
(void)RemoveBundleAndDataDir(appCodePath, info.GetBundleName(), info.GetUserId());
|
||||
DeleteBundleInfoFromStorage(info);
|
||||
isBundleValid = false;
|
||||
} else if (mark.status == InstallExceptionStatus::UPDATING_EXISTED_START) {
|
||||
@ -149,10 +150,11 @@ void BundleExceptionHandler::InnerHandleInvalidBundle(InnerBundleInfo &info, boo
|
||||
info.SetBundleStatus(InnerBundleInfo::BundleStatus::ENABLED);
|
||||
}
|
||||
} else if (mark.status == InstallExceptionStatus::UPDATING_FINISH) {
|
||||
if (InstalldClient::GetInstance()->RenameModuleDir(
|
||||
moduleDir + ServiceConstants::TMP_SUFFIX, moduleDir) == ERR_OK) {
|
||||
info.SetInstallMark(mark.bundleName, mark.packageName, InstallExceptionStatus::INSTALL_FINISH);
|
||||
if (InstalldClient::GetInstance()->RenameModuleDir(moduleDir + ServiceConstants::TMP_SUFFIX, moduleDir) !=
|
||||
ERR_OK) {
|
||||
APP_LOGI_NOFUNC("%{public}s rename module failed, may not exist", info.GetBundleName().c_str());
|
||||
}
|
||||
info.SetInstallMark(mark.bundleName, mark.packageName, InstallExceptionStatus::INSTALL_FINISH);
|
||||
}
|
||||
}
|
||||
} // namespace AppExecFwkConstants
|
||||
|
@ -49,8 +49,6 @@ constexpr const char* ALLOW_APP_USE_PRIVILEGE_EXTENSION = "allowAppUsePrivilegeE
|
||||
constexpr const char* ALLOW_FORM_VISIBLE_NOTIFY = "allowFormVisibleNotify";
|
||||
constexpr const char* ALLOW_APP_SHARE_LIBRARY = "allowAppShareLibrary";
|
||||
constexpr const char* ALLOW_ENABLE_NOTIFICATION = "allowEnableNotification";
|
||||
constexpr const char* APP_TEST_BUNDLE_NAME = "com.OpenHarmony.app.test";
|
||||
constexpr const char* BUNDLE_NAME_XTS_TEST = "com.acts.";
|
||||
constexpr const char* APL_NORMAL = "normal";
|
||||
constexpr const char* SLASH = "/";
|
||||
constexpr const char* DOUBLE_SLASH = "//";
|
||||
@ -1072,13 +1070,6 @@ void BundleInstallChecker::ParseAppPrivilegeCapability(
|
||||
iter->second(appPrivilegeCapability);
|
||||
}
|
||||
}
|
||||
if ((provisionInfo.bundleInfo.bundleName != APP_TEST_BUNDLE_NAME) &&
|
||||
(provisionInfo.bundleInfo.bundleName.find(BUNDLE_NAME_XTS_TEST) != 0)) {
|
||||
appPrivilegeCapability.allowMultiProcess = false;
|
||||
appPrivilegeCapability.allowUsePrivilegeExtension = false;
|
||||
appPrivilegeCapability.formVisibleNotify = false;
|
||||
}
|
||||
|
||||
LOG_D(BMS_TAG_INSTALLER, "AppPrivilegeCapability %{public}s",
|
||||
appPrivilegeCapability.ToString().c_str());
|
||||
#ifndef USE_PRE_BUNDLE_PROFILE
|
||||
|
@ -276,29 +276,6 @@ void BundleInstaller::RecoverDriverForAllUsers(const std::string &bundleName, co
|
||||
}
|
||||
}
|
||||
|
||||
bool BundleInstaller::HasDriverExtensionAbility(const std::string &bundleName)
|
||||
{
|
||||
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
|
||||
if (dataMgr == nullptr) {
|
||||
APP_LOGE("Get dataMgr shared_ptr nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
InnerBundleInfo info;
|
||||
bool isAppExist = dataMgr->FetchInnerBundleInfo(bundleName, info);
|
||||
if (isAppExist) {
|
||||
const auto extensions = info.GetInnerExtensionInfos();
|
||||
for (const auto &item : extensions) {
|
||||
if (item.second.type == ExtensionAbilityType::DRIVER) {
|
||||
APP_LOGI("find driver extension ability, bundleName: %{public}s, moduleName: %{public}s",
|
||||
item.second.bundleName.c_str(), item.second.moduleName.c_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void BundleInstaller::UninstallAndRecover(const std::string &bundleName, const InstallParam &installParam)
|
||||
{
|
||||
ErrCode resultCode = ERR_OK;
|
||||
|
@ -146,6 +146,7 @@ void BundleInstallerHost::HandleRecoverMessage(MessageParcel &data)
|
||||
}
|
||||
sptr<IStatusReceiver> statusReceiver = iface_cast<IStatusReceiver>(object);
|
||||
|
||||
installParam->preinstallSourceFlag = ApplicationInfoFlag::FLAG_RECOVER_INSTALLED;
|
||||
Recover(bundleName, *installParam, statusReceiver);
|
||||
LOG_D(BMS_TAG_INSTALLER, "handle install message by bundleName finished");
|
||||
}
|
||||
|
@ -101,10 +101,11 @@ constexpr const char* QUICK_FIX_APP_PATH = "/data/update/quickfix/app/temp/cold"
|
||||
constexpr const char* SYSTEM_BUNDLE_PATH = "/internal";
|
||||
constexpr const char* RESTOR_BUNDLE_NAME_LIST = "list";
|
||||
constexpr const char* QUICK_FIX_APP_RECOVER_FILE = "/data/update/quickfix/app/temp/quickfix_app_recover.json";
|
||||
|
||||
constexpr const char* INNER_UNDER_LINE = "_";
|
||||
constexpr char SEPARATOR = '/';
|
||||
constexpr const char* SYSTEM_RESOURCES_APP = "ohos.global.systemres";
|
||||
constexpr const char* FOUNDATION_PROCESS_NAME = "foundation";
|
||||
constexpr int32_t SCENE_ID_OTA_INSTALL = 3;
|
||||
|
||||
std::set<PreScanInfo> installList_;
|
||||
std::set<PreScanInfo> systemHspList_;
|
||||
@ -288,6 +289,7 @@ void BMSEventHandler::AfterBmsStart()
|
||||
RemoveUnreservedSandbox();
|
||||
BundleResourceHelper::RegisterCommonEventSubscriber();
|
||||
BundleResourceHelper::RegisterConfigurationObserver();
|
||||
ProcessCheckAppEl1Dir();
|
||||
LOG_I(BMS_TAG_DEFAULT, "BMSEventHandler AfterBmsStart end");
|
||||
}
|
||||
|
||||
@ -312,6 +314,7 @@ bool BMSEventHandler::LoadInstallInfosFromDb()
|
||||
|
||||
void BMSEventHandler::BundleBootStartEvent()
|
||||
{
|
||||
EventReport::SendCpuSceneEvent(FOUNDATION_PROCESS_NAME, SCENE_ID_OTA_INSTALL);
|
||||
OnBundleBootStart(Constants::DEFAULT_USERID);
|
||||
#ifdef CHECK_ELDIR_ENABLED
|
||||
UpdateOtaFlag(OTAFlag::CHECK_ELDIR);
|
||||
@ -335,6 +338,7 @@ void BMSEventHandler::BundleRebootStartEvent()
|
||||
#endif
|
||||
|
||||
if (IsSystemUpgrade()) {
|
||||
EventReport::SendCpuSceneEvent(FOUNDATION_PROCESS_NAME, SCENE_ID_OTA_INSTALL);
|
||||
OnBundleRebootStart();
|
||||
SaveSystemFingerprint();
|
||||
AOTHandler::GetInstance().HandleOTA();
|
||||
@ -926,6 +930,7 @@ void BMSEventHandler::ProcessSystemHspInstall(const PreScanInfo &preScanInfo)
|
||||
installParam.removable = false;
|
||||
installParam.copyHapToInstallPath = false;
|
||||
installParam.needSavePreInstallInfo = true;
|
||||
installParam.preinstallSourceFlag = ApplicationInfoFlag::FLAG_BOOT_INSTALLED;
|
||||
AppServiceFwkInstaller installer;
|
||||
SavePreInstallExceptionAppService(preScanInfo.bundleDir);
|
||||
ErrCode ret = installer.Install({preScanInfo.bundleDir}, installParam);
|
||||
@ -943,6 +948,7 @@ bool BMSEventHandler::ProcessSystemHspInstall(const std::string &systemHspDir)
|
||||
installParam.removable = false;
|
||||
installParam.copyHapToInstallPath = false;
|
||||
installParam.needSavePreInstallInfo = true;
|
||||
installParam.preinstallSourceFlag = ApplicationInfoFlag::FLAG_BOOT_INSTALLED;
|
||||
AppServiceFwkInstaller installer;
|
||||
ErrCode ret = installer.Install({systemHspDir}, installParam);
|
||||
if (ret != ERR_OK) {
|
||||
@ -1054,6 +1060,7 @@ void BMSEventHandler::ProcessSystemBundleInstall(
|
||||
installParam.removable = preScanInfo.removable;
|
||||
installParam.needSavePreInstallInfo = true;
|
||||
installParam.copyHapToInstallPath = false;
|
||||
installParam.preinstallSourceFlag = ApplicationInfoFlag::FLAG_BOOT_INSTALLED;
|
||||
SystemBundleInstaller installer;
|
||||
ErrCode ret = installer.InstallSystemBundle(preScanInfo.bundleDir, installParam, appType);
|
||||
if (ret != ERR_OK && ret != ERR_APPEXECFWK_INSTALL_ZERO_USER_WITH_NO_SINGLETON) {
|
||||
@ -1074,6 +1081,7 @@ void BMSEventHandler::ProcessSystemBundleInstall(
|
||||
installParam.removable = false;
|
||||
installParam.needSavePreInstallInfo = true;
|
||||
installParam.copyHapToInstallPath = false;
|
||||
installParam.preinstallSourceFlag = ApplicationInfoFlag::FLAG_BOOT_INSTALLED;
|
||||
SystemBundleInstaller installer;
|
||||
ErrCode ret = installer.InstallSystemBundle(bundleDir, installParam, appType);
|
||||
if (ret != ERR_OK && ret != ERR_APPEXECFWK_INSTALL_ZERO_USER_WITH_NO_SINGLETON) {
|
||||
@ -1092,6 +1100,7 @@ void BMSEventHandler::ProcessSystemSharedBundleInstall(const std::string &shared
|
||||
installParam.removable = false;
|
||||
installParam.needSavePreInstallInfo = true;
|
||||
installParam.sharedBundleDirPaths = {sharedBundlePath};
|
||||
installParam.preinstallSourceFlag = ApplicationInfoFlag::FLAG_BOOT_INSTALLED;
|
||||
SystemBundleInstaller installer;
|
||||
if (!installer.InstallSystemSharedBundle(installParam, false, appType)) {
|
||||
LOG_W(BMS_TAG_DEFAULT, "install system shared bundle: %{public}s error", sharedBundlePath.c_str());
|
||||
@ -1129,7 +1138,6 @@ void BMSEventHandler::ProcessRebootBundle()
|
||||
#ifdef CHECK_ELDIR_ENABLED
|
||||
ProcessCheckAppDataDir();
|
||||
#endif
|
||||
ProcessCheckAppEl1Dir();
|
||||
ProcessCheckAppLogDir();
|
||||
ProcessCheckAppFileManagerDir();
|
||||
ProcessCheckPreinstallData();
|
||||
@ -2098,6 +2106,7 @@ ErrCode BMSEventHandler::OTAInstallSystemHsp(const std::vector<std::string> &fil
|
||||
installParam.isOTA = true;
|
||||
installParam.copyHapToInstallPath = false;
|
||||
installParam.needSavePreInstallInfo = true;
|
||||
installParam.preinstallSourceFlag = ApplicationInfoFlag::FLAG_OTA_INSTALLED;
|
||||
AppServiceFwkInstaller installer;
|
||||
|
||||
return installer.Install(filePaths, installParam);
|
||||
@ -2646,9 +2655,15 @@ void BMSEventHandler::ProcessRebootBundleUninstall()
|
||||
|
||||
for (auto &loadIter : loadExistData_) {
|
||||
std::string bundleName = loadIter.first;
|
||||
BundleInfo hasInstalledInfo;
|
||||
auto hasBundleInstalled = dataMgr->GetBundleInfo(
|
||||
bundleName, BundleFlag::GET_BUNDLE_DEFAULT, hasInstalledInfo, Constants::ANY_USERID);
|
||||
auto listIter = hapParseInfoMap_.find(bundleName);
|
||||
if (listIter == hapParseInfoMap_.end()) {
|
||||
LOG_I(BMS_TAG_DEFAULT, "ProcessRebootBundleUninstall OTA uninstall app(%{public}s)", bundleName.c_str());
|
||||
if (InnerProcessUninstallForExistPreBundle(hasInstalledInfo)) {
|
||||
continue;
|
||||
}
|
||||
SystemBundleInstaller installer;
|
||||
if (!installer.UninstallSystemBundle(bundleName)) {
|
||||
LOG_E(BMS_TAG_DEFAULT, "OTA uninstall app(%{public}s) error", bundleName.c_str());
|
||||
@ -2661,9 +2676,6 @@ void BMSEventHandler::ProcessRebootBundleUninstall()
|
||||
continue;
|
||||
}
|
||||
|
||||
BundleInfo hasInstalledInfo;
|
||||
auto hasBundleInstalled = dataMgr->GetBundleInfo(
|
||||
bundleName, BundleFlag::GET_BUNDLE_DEFAULT, hasInstalledInfo, Constants::ANY_USERID);
|
||||
if (!hasBundleInstalled) {
|
||||
LOG_W(BMS_TAG_DEFAULT, "app(%{public}s) maybe has been uninstall", bundleName.c_str());
|
||||
continue;
|
||||
@ -2973,6 +2985,7 @@ bool BMSEventHandler::OTAInstallSystemBundle(
|
||||
installParam.needSavePreInstallInfo = true;
|
||||
installParam.copyHapToInstallPath = false;
|
||||
installParam.isOTA = true;
|
||||
installParam.preinstallSourceFlag = ApplicationInfoFlag::FLAG_OTA_INSTALLED;
|
||||
SystemBundleInstaller installer;
|
||||
ErrCode ret = installer.OTAInstallSystemBundle(filePaths, installParam, appType);
|
||||
if (ret == ERR_APPEXECFWK_INSTALL_ZERO_USER_WITH_NO_SINGLETON) {
|
||||
@ -3001,6 +3014,7 @@ bool BMSEventHandler::OTAInstallSystemBundleNeedCheckUser(
|
||||
installParam.needSavePreInstallInfo = true;
|
||||
installParam.copyHapToInstallPath = false;
|
||||
installParam.isOTA = true;
|
||||
installParam.preinstallSourceFlag = ApplicationInfoFlag::FLAG_OTA_INSTALLED;
|
||||
SystemBundleInstaller installer;
|
||||
ErrCode ret = installer.OTAInstallSystemBundleNeedCheckUser(filePaths, installParam, bundleName, appType);
|
||||
LOG_NOFUNC_I(BMS_TAG_DEFAULT, "bundle %{public}s with return code: %{public}d", bundleName.c_str(), ret);
|
||||
@ -3032,6 +3046,7 @@ bool BMSEventHandler::OTAInstallSystemSharedBundle(
|
||||
installParam.needSavePreInstallInfo = true;
|
||||
installParam.sharedBundleDirPaths = filePaths;
|
||||
installParam.isOTA = true;
|
||||
installParam.preinstallSourceFlag = ApplicationInfoFlag::FLAG_OTA_INSTALLED;
|
||||
SystemBundleInstaller installer;
|
||||
return installer.InstallSystemSharedBundle(installParam, true, appType);
|
||||
}
|
||||
@ -3845,7 +3860,14 @@ void BMSEventHandler::InnerProcessRebootUninstallWrongBundle()
|
||||
|
||||
void BMSEventHandler::ProcessCheckAppEl1Dir()
|
||||
{
|
||||
LOG_I(BMS_TAG_DEFAULT, "ProcessCheckAppEl1Dir begin");
|
||||
LOG_I(BMS_TAG_DEFAULT, "start");
|
||||
std::thread thread(ProcessCheckAppEl1DirTask);
|
||||
thread.detach();
|
||||
}
|
||||
|
||||
void BMSEventHandler::ProcessCheckAppEl1DirTask()
|
||||
{
|
||||
LOG_I(BMS_TAG_DEFAULT, "begin");
|
||||
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
|
||||
if (dataMgr == nullptr) {
|
||||
LOG_E(BMS_TAG_DEFAULT, "DataMgr is nullptr");
|
||||
@ -3856,13 +3878,13 @@ void BMSEventHandler::ProcessCheckAppEl1Dir()
|
||||
for (const auto &userId : userIds) {
|
||||
std::vector<BundleInfo> bundleInfos;
|
||||
if (!dataMgr->GetBundleInfos(BundleFlag::GET_BUNDLE_DEFAULT, bundleInfos, userId)) {
|
||||
LOG_W(BMS_TAG_DEFAULT, "ProcessCheckAppEl1Dir GetBundleInfos failed");
|
||||
LOG_W(BMS_TAG_DEFAULT, "GetBundleInfos failed");
|
||||
continue;
|
||||
}
|
||||
|
||||
UpdateAppDataMgr::ProcessUpdateAppDataDir(userId, bundleInfos, ServiceConstants::DIR_EL1);
|
||||
}
|
||||
LOG_I(BMS_TAG_DEFAULT, "ProcessCheckAppEl1Dir end");
|
||||
LOG_I(BMS_TAG_DEFAULT, "end");
|
||||
}
|
||||
|
||||
void BMSEventHandler::CleanAllBundleShaderCache() const
|
||||
@ -3891,5 +3913,23 @@ void BMSEventHandler::CleanAllBundleShaderCache() const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BMSEventHandler::InnerProcessUninstallForExistPreBundle(const BundleInfo &installedInfo)
|
||||
{
|
||||
if (installedInfo.hapModuleInfos.empty()) {
|
||||
LOG_W(BMS_TAG_DEFAULT, "app(%{public}s) moduleInfos empty", installedInfo.name.c_str());
|
||||
return false;
|
||||
}
|
||||
bool isUpdated = std::all_of(installedInfo.hapModuleInfos.begin(), installedInfo.hapModuleInfos.end(),
|
||||
[] (const HapModuleInfo &moduleInfo) {
|
||||
return moduleInfo.hapPath.find(Constants::BUNDLE_CODE_DIR) == 0;
|
||||
});
|
||||
if (isUpdated) {
|
||||
LOG_I(BMS_TAG_DEFAULT, "no need to uninstall app(%{public}s) due to update", installedInfo.name.c_str());
|
||||
std::string moduleName;
|
||||
DeletePreInfoInDb(installedInfo.name, moduleName, true);
|
||||
}
|
||||
return isUpdated;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -414,11 +414,11 @@ int32_t BundlePermissionMgr::GetHapApiVersion()
|
||||
LOG_E(BMS_TAG_DEFAULT, "getApplicationInfo failed");
|
||||
return Constants::INVALID_API_VERSION;
|
||||
}
|
||||
auto appApiVersion = applicationInfo.apiTargetVersion;
|
||||
auto appApiVersion = applicationInfo.apiTargetVersion % BASE_API_VERSION;
|
||||
LOG_D(BMS_TAG_DEFAULT, "appApiVersion is %{public}d", appApiVersion);
|
||||
auto systemApiVersion = GetSdkApiVersion();
|
||||
// api version is the minimum value of {appApiVersion, systemApiVersion}
|
||||
return (systemApiVersion < appApiVersion ? systemApiVersion :appApiVersion) % BASE_API_VERSION;
|
||||
return systemApiVersion < appApiVersion ? systemApiVersion :appApiVersion;
|
||||
}
|
||||
|
||||
// if the api has been system api since it is published, then beginSystemApiVersion can be omitted
|
||||
@ -587,7 +587,11 @@ void BundlePermissionMgr::AddPermissionUsedRecord(
|
||||
AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID();
|
||||
AccessToken::ATokenTypeEnum tokenType = AccessToken::AccessTokenKit::GetTokenTypeFlag(callerToken);
|
||||
if (tokenType == AccessToken::ATokenTypeEnum::TOKEN_HAP) {
|
||||
AccessToken::PrivacyKit::AddPermissionUsedRecord(callerToken, permission, successCount, failCount);
|
||||
int32_t ret = AccessToken::PrivacyKit::AddPermissionUsedRecord(callerToken, permission,
|
||||
successCount, failCount);
|
||||
if (ret != AccessToken::AccessTokenKitRet::RET_SUCCESS) {
|
||||
APP_LOGE("AddPermissionUsedRecord failed, ret = %{public}d", ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2467,6 +2467,9 @@ ErrCode BundleProfile::TransformTo(
|
||||
}
|
||||
if (!ParserNativeSo(configJson, bundleExtractor, innerBundleInfo)) {
|
||||
APP_LOGW("Parser native so failed");
|
||||
#ifdef X86_EMULATOR_MODE
|
||||
return ERR_APPEXECFWK_PARSE_NATIVE_SO_FAILED;
|
||||
#endif
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
@ -156,6 +156,7 @@ void BundleUserMgrHostImpl::OnCreateNewUser(int32_t userId, const std::vector<st
|
||||
installParam.userId = userId;
|
||||
installParam.isPreInstallApp = !info.GetIsNonPreDriverApp();
|
||||
installParam.installFlag = InstallFlag::NORMAL;
|
||||
installParam.preinstallSourceFlag = ApplicationInfoFlag::FLAG_BOOT_INSTALLED;
|
||||
sptr<UserReceiverImpl> userReceiverImpl(
|
||||
new (std::nothrow) UserReceiverImpl(info.GetBundleName(), needReinstall));
|
||||
userReceiverImpl->SetBundlePromise(bundlePromise);
|
||||
|
@ -101,6 +101,7 @@ ErrCode HmpBundleInstaller::InstallNormalAppInHmp(const std::string &bundleDir,
|
||||
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
|
||||
installParam.isOTA = true;
|
||||
installParam.removable = removable;
|
||||
installParam.preinstallSourceFlag = ApplicationInfoFlag::FLAG_OTA_INSTALLED;
|
||||
ErrCode ret = InstallBundle(bundleDir, installParam, Constants::AppType::SYSTEM_APP);
|
||||
ResetInstallProperties();
|
||||
if (ret == ERR_OK) {
|
||||
|
@ -97,7 +97,6 @@ constexpr const char* BUNDLE_EXTEND_RESOURCES = "extendResources";
|
||||
constexpr const char* CUR_DYNAMIC_ICON_MODULE = "curDynamicIconModule";
|
||||
constexpr const char* BUNDLE_PACK_INFO = "bundlePackInfo";
|
||||
constexpr const char* ALLOWED_ACLS = "allowedAcls";
|
||||
constexpr const char* META_DATA_SHORTCUTS_NAME = "ohos.ability.shortcuts";
|
||||
constexpr const char* APP_INDEX = "appIndex";
|
||||
constexpr const char* BUNDLE_IS_SANDBOX_APP = "isSandboxApp";
|
||||
constexpr const char* MODULE_COMPILE_MODE = "compileMode";
|
||||
@ -146,6 +145,7 @@ constexpr const char* MODULE_PACKAGE_NAME = "packageName";
|
||||
constexpr const char* MODULE_APP_STARTUP = "appStartup";
|
||||
constexpr const char* MODULE_HWASAN_ENABLED = "hwasanEnabled";
|
||||
constexpr const char* MODULE_UBSAN_ENABLED = "ubsanEnabled";
|
||||
constexpr uint32_t PREINSTALL_SOURCE_CLEAN_MASK = ~0B1110;
|
||||
|
||||
inline CompileMode ConvertCompileMode(const std::string& compileMode)
|
||||
{
|
||||
@ -2674,39 +2674,6 @@ void InnerBundleInfo::GetFormsInfoByApp(std::vector<FormInfo> &formInfos) const
|
||||
|
||||
void InnerBundleInfo::GetShortcutInfos(std::vector<ShortcutInfo> &shortcutInfos) const
|
||||
{
|
||||
if (isNewVersion_) {
|
||||
AbilityInfo abilityInfo;
|
||||
GetMainAbilityInfo(abilityInfo);
|
||||
if ((!abilityInfo.resourcePath.empty() || !abilityInfo.hapPath.empty())
|
||||
&& abilityInfo.metadata.size() > 0) {
|
||||
std::vector<std::string> rawJson;
|
||||
BundleMgrClient bundleMgrClient;
|
||||
bool ret = bundleMgrClient.GetResConfigFile(abilityInfo, META_DATA_SHORTCUTS_NAME, rawJson);
|
||||
if (!ret) {
|
||||
APP_LOGD("GetResConfigFile return false");
|
||||
return;
|
||||
}
|
||||
if (rawJson.size() == 0) {
|
||||
APP_LOGD("rawJson size 0. skip");
|
||||
return;
|
||||
}
|
||||
nlohmann::json jsonObject = nlohmann::json::parse(rawJson[0], nullptr, false);
|
||||
if (jsonObject.is_discarded()) {
|
||||
APP_LOGE("shortcuts json invalid");
|
||||
return;
|
||||
}
|
||||
ShortcutJson shortcutJson = jsonObject.get<ShortcutJson>();
|
||||
for (const Shortcut &item : shortcutJson.shortcuts) {
|
||||
ShortcutInfo shortcutInfo;
|
||||
shortcutInfo.bundleName = abilityInfo.bundleName;
|
||||
shortcutInfo.moduleName = abilityInfo.moduleName;
|
||||
InnerProcessShortcut(item, shortcutInfo);
|
||||
shortcutInfo.sourceType = 1;
|
||||
shortcutInfos.emplace_back(shortcutInfo);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (const auto &shortcut : shortcutInfos_) {
|
||||
shortcutInfos.emplace_back(shortcut.second);
|
||||
}
|
||||
@ -4349,6 +4316,14 @@ std::vector<std::string> InnerBundleInfo::GetAllExtensionDirs() const
|
||||
return dirVec;
|
||||
}
|
||||
|
||||
void InnerBundleInfo::SetApplicationFlags(ApplicationInfoFlag flag)
|
||||
{
|
||||
uint32_t applicationFlags = static_cast<uint32_t>(baseApplicationInfo_->applicationFlags);
|
||||
uint32_t installSourceFlag = static_cast<uint32_t>(flag);
|
||||
baseApplicationInfo_->applicationFlags =
|
||||
static_cast<int32_t>((applicationFlags & PREINSTALL_SOURCE_CLEAN_MASK) | installSourceFlag);
|
||||
}
|
||||
|
||||
void InnerBundleInfo::UpdateExtensionSandboxInfo(const std::vector<std::string> &typeList)
|
||||
{
|
||||
for (auto &extensionItem : baseExtensionInfos_) {
|
||||
|
@ -79,6 +79,7 @@ constexpr const char* EXTENSION_CONFIG_FILE_PATH = "/etc/ams_extension_config.js
|
||||
constexpr const char* EXTENSION_CONFIG_NAME = "ams_extension_config";
|
||||
constexpr const char* EXTENSION_TYPE_NAME = "extension_type_name";
|
||||
constexpr const char* EXTENSION_SERVICE_NEED_CREATE_SANDBOX = "need_create_sandbox";
|
||||
constexpr int32_t INSTALLS_UID = 3060;
|
||||
enum class DirType : uint8_t {
|
||||
DIR_EL1,
|
||||
DIR_EL2,
|
||||
@ -394,7 +395,7 @@ ErrCode InstalldHostImpl::AddUserDirDeleteDfx(int32_t userId)
|
||||
return ERR_APPEXECFWK_INSTALLD_PERMISSION_DENIED;
|
||||
}
|
||||
std::vector<std::string> elPath(ServiceConstants::BUNDLE_EL);
|
||||
elPath.push_back("el5");
|
||||
elPath.push_back(ServiceConstants::DIR_EL5);
|
||||
for (const auto &el : elPath) {
|
||||
std::string bundleDataDir = GetBundleDataDir(el, userId) + ServiceConstants::BASE;
|
||||
if (access(bundleDataDir.c_str(), F_OK) != 0) {
|
||||
@ -856,7 +857,9 @@ ErrCode InstalldHostImpl::CleanBundleDataDirByName(const std::string &bundleName
|
||||
return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
|
||||
}
|
||||
std::string suffixName = bundleName;
|
||||
for (const auto &el : ServiceConstants::BUNDLE_EL) {
|
||||
std::vector<std::string> elPath(ServiceConstants::BUNDLE_EL);
|
||||
elPath.push_back(ServiceConstants::DIR_EL5);
|
||||
for (const auto &el : elPath) {
|
||||
if (el == ServiceConstants::BUNDLE_EL[1]) {
|
||||
CleanBundleDataForEl2(bundleName, userid, appIndex);
|
||||
continue;
|
||||
@ -970,27 +973,20 @@ ErrCode InstalldHostImpl::GetBundleStats(const std::string &bundleName, const in
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode InstalldHostImpl::GetAllBundleStats(const std::vector<std::string> &bundleNames, const int32_t userId,
|
||||
ErrCode InstalldHostImpl::GetAllBundleStats(const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const std::vector<int32_t> &uids)
|
||||
{
|
||||
if (!InstalldPermissionMgr::VerifyCallingPermission(Constants::FOUNDATION_UID)) {
|
||||
LOG_E(BMS_TAG_INSTALLD, "installd permission denied, only used for foundation process");
|
||||
return ERR_APPEXECFWK_INSTALLD_PERMISSION_DENIED;
|
||||
}
|
||||
if (bundleNames.empty() || bundleNames.size() != uids.size()) {
|
||||
if (uids.empty()) {
|
||||
return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
|
||||
}
|
||||
int64_t totalFileSize = 0;
|
||||
int64_t totalFileSize = InstalldOperator::GetDiskUsageFromQuota(INSTALLS_UID);
|
||||
int64_t totalDataSize = 0;
|
||||
for (size_t index = 0; index < bundleNames.size(); ++index) {
|
||||
const auto &bundleName = bundleNames[index];
|
||||
for (size_t index = 0; index < uids.size(); ++index) {
|
||||
const auto &uid = uids[index];
|
||||
std::vector<std::string> bundlePath;
|
||||
bundlePath.push_back(std::string(Constants::BUNDLE_CODE_DIR) +
|
||||
ServiceConstants::PATH_SEPARATOR + bundleName); // bundle code
|
||||
int64_t fileSize = InstalldOperator::GetDiskUsageFromPath(bundlePath);
|
||||
// index 0 : bundle data size
|
||||
totalFileSize += fileSize;
|
||||
int64_t bundleDataSize = InstalldOperator::GetDiskUsageFromQuota(uid);
|
||||
// index 1 : local bundle data size
|
||||
totalDataSize += bundleDataSize;
|
||||
|
@ -190,19 +190,15 @@ ErrCode InstalldClient::GetBundleStats(const std::string &bundleName, const int3
|
||||
return CallService(&IInstalld::GetBundleStats, bundleName, userId, bundleStats, uid, appIndex);
|
||||
}
|
||||
|
||||
ErrCode InstalldClient::GetAllBundleStats(const std::vector<std::string> &bundleNames, const int32_t userId,
|
||||
ErrCode InstalldClient::GetAllBundleStats(const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const std::vector<int32_t> &uids)
|
||||
{
|
||||
if (bundleNames.empty()) {
|
||||
APP_LOGE("bundleName is empty");
|
||||
if (uids.empty()) {
|
||||
APP_LOGE("uids is empty");
|
||||
return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
|
||||
}
|
||||
|
||||
if (bundleNames.size() != uids.size()) {
|
||||
APP_LOGE("bundleNames size is not equal to uids size");
|
||||
return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
|
||||
}
|
||||
return CallService(&IInstalld::GetAllBundleStats, bundleNames, userId, bundleStats, uids);
|
||||
return CallService(&IInstalld::GetAllBundleStats, userId, bundleStats, uids);
|
||||
}
|
||||
|
||||
ErrCode InstalldClient::SetDirApl(const std::string &dir, const std::string &bundleName, const std::string &apl,
|
||||
|
@ -460,24 +460,19 @@ bool InstalldHost::HandleGetBundleStats(MessageParcel &data, MessageParcel &repl
|
||||
|
||||
bool InstalldHost::HandleGetAllBundleStats(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
auto bundleNamesSize = data.ReadInt32();
|
||||
if (bundleNamesSize == 0 || bundleNamesSize > Constants::MAX_PARCEL_CAPACITY) {
|
||||
int32_t userId = data.ReadInt32();
|
||||
auto uidSize = data.ReadInt32();
|
||||
if (uidSize == 0 || uidSize > Constants::CAPACITY_SIZE) {
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, reply, ERR_APPEXECFWK_PARCEL_ERROR);
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> bundleNames;
|
||||
std::vector<int32_t> uids;
|
||||
for (int32_t index = 0; index < bundleNamesSize; ++index) {
|
||||
std::string bundleName = Str16ToStr8(data.ReadString16());
|
||||
bundleNames.emplace_back(bundleName);
|
||||
}
|
||||
int32_t userId = data.ReadInt32();
|
||||
for (int32_t index = 0; index < bundleNamesSize; ++index) {
|
||||
for (int32_t index = 0; index < uidSize; ++index) {
|
||||
int32_t uid = data.ReadInt32();
|
||||
uids.emplace_back(uid);
|
||||
}
|
||||
std::vector<int64_t> bundleStats;
|
||||
ErrCode result = GetAllBundleStats(bundleNames, userId, bundleStats, uids);
|
||||
ErrCode result = GetAllBundleStats(userId, bundleStats, uids);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, reply, result);
|
||||
if (!reply.WriteInt64Vector(bundleStats)) {
|
||||
LOG_E(BMS_TAG_INSTALLD, "HandleGetAllBundleStats write failed");
|
||||
|
@ -307,17 +307,14 @@ ErrCode InstalldProxy::GetBundleStats(const std::string &bundleName, const int32
|
||||
return ret;
|
||||
}
|
||||
|
||||
ErrCode InstalldProxy::GetAllBundleStats(const std::vector<std::string> &bundleNames, const int32_t userId,
|
||||
ErrCode InstalldProxy::GetAllBundleStats(const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const std::vector<int32_t> &uids)
|
||||
{
|
||||
uint32_t bundleNamesSize = bundleNames.size();
|
||||
MessageParcel data;
|
||||
INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor()));
|
||||
INSTALLD_PARCEL_WRITE(data, Uint32, bundleNamesSize);
|
||||
for (const auto &bundleName : bundleNames) {
|
||||
INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(bundleName));
|
||||
}
|
||||
INSTALLD_PARCEL_WRITE(data, Int32, userId);
|
||||
uint32_t uidSize = uids.size();
|
||||
INSTALLD_PARCEL_WRITE(data, Uint32, uidSize);
|
||||
for (const auto &uid : uids) {
|
||||
INSTALLD_PARCEL_WRITE(data, Int32, uid);
|
||||
}
|
||||
|
@ -2597,6 +2597,9 @@ ErrCode ModuleProfile::TransformTo(
|
||||
}
|
||||
if (!ParserNativeSo(moduleJson, bundleExtractor, innerBundleInfo)) {
|
||||
APP_LOGW("Parser native so failed");
|
||||
#ifdef X86_EMULATOR_MODE
|
||||
return ERR_APPEXECFWK_PARSE_NATIVE_SO_FAILED;
|
||||
#endif
|
||||
}
|
||||
if (!ParserArkNativeFilePath(moduleJson, bundleExtractor, innerBundleInfo)) {
|
||||
APP_LOGW("Parser ark native file failed");
|
||||
|
@ -325,6 +325,9 @@ ErrCode PatchProfile::TransformTo(
|
||||
if ((appQuickFix.deployingAppqfInfo.type == QuickFixType::PATCH) &&
|
||||
(!ParseNativeSo(patchExtractor, appQuickFix.deployingAppqfInfo))) {
|
||||
LOG_W(BMS_TAG_DEFAULT, "ParseNativeSo failed");
|
||||
#ifdef X86_EMULATOR_MODE
|
||||
return ERR_APPEXECFWK_PARSE_NATIVE_SO_FAILED;
|
||||
#endif
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
@ -60,7 +60,6 @@ void QuickFixDataMgr::InitStatesMap()
|
||||
|
||||
bool QuickFixDataMgr::QueryAllInnerAppQuickFix(std::map<std::string, InnerAppQuickFix> &innerAppQuickFixes)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (quickFixManagerDb_ == nullptr) {
|
||||
LOG_E(BMS_TAG_DEFAULT, "error quickFixManagerDb_ is nullptr");
|
||||
return false;
|
||||
@ -70,7 +69,6 @@ bool QuickFixDataMgr::QueryAllInnerAppQuickFix(std::map<std::string, InnerAppQui
|
||||
|
||||
bool QuickFixDataMgr::QueryInnerAppQuickFix(const std::string &bundleName, InnerAppQuickFix &innerAppQuickFix)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (quickFixManagerDb_ == nullptr) {
|
||||
LOG_E(BMS_TAG_DEFAULT, "error quickFixManagerDb_ is nullptr");
|
||||
return false;
|
||||
@ -80,7 +78,6 @@ bool QuickFixDataMgr::QueryInnerAppQuickFix(const std::string &bundleName, Inner
|
||||
|
||||
bool QuickFixDataMgr::SaveInnerAppQuickFix(const InnerAppQuickFix &innerAppQuickFix)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (quickFixManagerDb_ == nullptr) {
|
||||
LOG_E(BMS_TAG_DEFAULT, "error quickFixManagerDb_ is nullptr");
|
||||
return false;
|
||||
@ -90,7 +87,6 @@ bool QuickFixDataMgr::SaveInnerAppQuickFix(const InnerAppQuickFix &innerAppQuick
|
||||
|
||||
bool QuickFixDataMgr::DeleteInnerAppQuickFix(const std::string &bundleName)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (quickFixManagerDb_ == nullptr) {
|
||||
LOG_E(BMS_TAG_DEFAULT, "error quickFixManagerDb_ is nullptr");
|
||||
return false;
|
||||
|
@ -168,6 +168,7 @@ ErrCode InnerSharedBundleInstaller::Install(const InstallParam &installParam)
|
||||
ErrCode result = ERR_OK;
|
||||
for (auto &item : parsedBundles_) {
|
||||
result = ExtractSharedBundles(item.first, item.second);
|
||||
item.second.SetApplicationFlags(installParam.preinstallSourceFlag);
|
||||
CHECK_RESULT(result, "extract shared bundles failed %{public}d");
|
||||
}
|
||||
|
||||
|
104
services/bundlemgr/src/utd/utd_handler.cpp
Normal file
104
services/bundlemgr/src/utd/utd_handler.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 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 "utd_handler.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "app_log_tag_wrapper.h"
|
||||
#include "bundle_extractor.h"
|
||||
#include "bundle_mgr_service.h"
|
||||
#ifdef BUNDLE_FRAMEWORK_UDMF_ENABLED
|
||||
#include "utd_client.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
namespace {
|
||||
constexpr const char* UTD_PROFILE_PATH = "resources/rawfile/arkdata/utd/utd.json5";
|
||||
}
|
||||
|
||||
void UtdHandler::InstallUtdAsync(const std::string &bundleName, const int32_t userId)
|
||||
{
|
||||
#ifdef BUNDLE_FRAMEWORK_UDMF_ENABLED
|
||||
auto installUtdTask = [bundleName, userId]() {
|
||||
LOG_I(BMS_TAG_INSTALLER, "install utd,%{public}s,%{public}d", bundleName.c_str(), userId);
|
||||
std::string entryHapPath = UtdHandler::GetEntryHapPath(bundleName, userId);
|
||||
std::string utdProfile = UtdHandler::GetUtdProfileFromHap(entryHapPath);
|
||||
LOG_I(BMS_TAG_INSTALLER, "utdProfile:%{public}zu", utdProfile.size());
|
||||
UDMF::UtdClient::GetInstance().InstallCustomUtds(bundleName, utdProfile, userId);
|
||||
};
|
||||
ffrt::submit(installUtdTask);
|
||||
#endif
|
||||
}
|
||||
|
||||
void UtdHandler::UninstallUtdAsync(const std::string &bundleName, const int32_t userId)
|
||||
{
|
||||
#ifdef BUNDLE_FRAMEWORK_UDMF_ENABLED
|
||||
auto uninstallUtdTask = [bundleName, userId]() {
|
||||
LOG_I(BMS_TAG_INSTALLER, "uninstall utd,%{public}s,%{public}d", bundleName.c_str(), userId);
|
||||
UDMF::UtdClient::GetInstance().UninstallCustomUtds(bundleName, userId);
|
||||
};
|
||||
ffrt::submit(uninstallUtdTask);
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string UtdHandler::GetEntryHapPath(const std::string &bundleName, const int32_t userId)
|
||||
{
|
||||
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
|
||||
if (dataMgr == nullptr) {
|
||||
LOG_W(BMS_TAG_INSTALLER, "dataMgr is null");
|
||||
return Constants::EMPTY_STRING;
|
||||
}
|
||||
BundleInfo bundleInfo;
|
||||
int32_t flags = static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE);
|
||||
ErrCode ret = dataMgr->GetBundleInfoV9(bundleName, flags, bundleInfo, userId);
|
||||
if (ret != ERR_OK) {
|
||||
LOG_W(BMS_TAG_INSTALLER, "getBundleInfo failed,%{public}s,%{public}d", bundleName.c_str(), userId);
|
||||
return Constants::EMPTY_STRING;
|
||||
}
|
||||
for (const auto &hapInfo : bundleInfo.hapModuleInfos) {
|
||||
if (hapInfo.moduleType == ModuleType::ENTRY) {
|
||||
return hapInfo.hapPath;
|
||||
}
|
||||
}
|
||||
LOG_I(BMS_TAG_INSTALLER, "no entry");
|
||||
return Constants::EMPTY_STRING;
|
||||
}
|
||||
|
||||
std::string UtdHandler::GetUtdProfileFromHap(const std::string &hapPath)
|
||||
{
|
||||
if (hapPath.empty()) {
|
||||
LOG_I(BMS_TAG_INSTALLER, "hapPath empty");
|
||||
return Constants::EMPTY_STRING;
|
||||
}
|
||||
BundleExtractor bundleExtractor(hapPath);
|
||||
if (!bundleExtractor.Init()) {
|
||||
LOG_W(BMS_TAG_INSTALLER, "extractor init failed");
|
||||
return Constants::EMPTY_STRING;
|
||||
}
|
||||
if (!bundleExtractor.HasEntry(UTD_PROFILE_PATH)) {
|
||||
LOG_I(BMS_TAG_INSTALLER, "no utd profile");
|
||||
return Constants::EMPTY_STRING;
|
||||
}
|
||||
std::ostringstream utdJsonStream;
|
||||
if (!bundleExtractor.ExtractByName(UTD_PROFILE_PATH, utdJsonStream)) {
|
||||
LOG_W(BMS_TAG_INSTALLER, "extract utd profile failed");
|
||||
return Constants::EMPTY_STRING;
|
||||
}
|
||||
return utdJsonStream.str();
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -144,8 +144,13 @@ VerifyManagerHostImpl::~VerifyManagerHostImpl()
|
||||
|
||||
ErrCode VerifyManagerHostImpl::Verify(const std::vector<std::string> &abcPaths)
|
||||
{
|
||||
if (!BundlePermissionMgr::VerifySystemApp(ServiceConstants::API_VERSION_TWELVE) ||
|
||||
!BundlePermissionMgr::VerifyCallingPermissionForAll(Constants::PERMISSION_RUN_DYN_CODE)) {
|
||||
if (!BundlePermissionMgr::IsSystemApp() &&
|
||||
!BundlePermissionMgr::VerifyCallingBundleSdkVersion(ServiceConstants::API_VERSION_TWELVE)) {
|
||||
APP_LOGE("non-system app calling system api");
|
||||
return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED;
|
||||
}
|
||||
|
||||
if (!BundlePermissionMgr::VerifyCallingPermissionForAll(Constants::PERMISSION_RUN_DYN_CODE)) {
|
||||
APP_LOGE("verify permission failed");
|
||||
return ERR_BUNDLE_MANAGER_VERIFY_PERMISSION_DENIED;
|
||||
}
|
||||
@ -483,8 +488,13 @@ void VerifyManagerHostImpl::Rollback(const std::vector<std::string> &paths)
|
||||
|
||||
ErrCode VerifyManagerHostImpl::DeleteAbc(const std::string &path)
|
||||
{
|
||||
if (!BundlePermissionMgr::VerifySystemApp(ServiceConstants::API_VERSION_TWELVE) ||
|
||||
!BundlePermissionMgr::VerifyCallingPermissionForAll(Constants::PERMISSION_RUN_DYN_CODE)) {
|
||||
if (!BundlePermissionMgr::IsSystemApp() &&
|
||||
!BundlePermissionMgr::VerifyCallingBundleSdkVersion(ServiceConstants::API_VERSION_TWELVE)) {
|
||||
APP_LOGE("non-system app calling system api");
|
||||
return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED;
|
||||
}
|
||||
|
||||
if (!BundlePermissionMgr::VerifyCallingPermissionForAll(Constants::PERMISSION_RUN_DYN_CODE)) {
|
||||
APP_LOGE("DeleteAbc failed due to permission denied");
|
||||
return ERR_BUNDLE_MANAGER_VERIFY_PERMISSION_DENIED;
|
||||
}
|
||||
|
@ -724,5 +724,10 @@ void BMSEventHandler::ProcessRebootQuickFixUnInstallAndRecover(const std::string
|
||||
void BMSEventHandler::UpdatePreinstallDBForUninstalledBundle(
|
||||
const std::string& bundleName, const std::unordered_map<std::string, InnerBundleInfo>& innerBundleInfos)
|
||||
{}
|
||||
|
||||
bool BMSEventHandler::InnerProcessUninstallForExistPreBundle(const BundleInfo &installedInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -175,19 +175,15 @@ ErrCode InstalldClient::GetBundleStats(const std::string &bundleName, const int3
|
||||
return CallService(&IInstalld::GetBundleStats, bundleName, userId, bundleStats, uid, appIndex);
|
||||
}
|
||||
|
||||
ErrCode InstalldClient::GetAllBundleStats(const std::vector<std::string> &bundleNames, const int32_t userId,
|
||||
ErrCode InstalldClient::GetAllBundleStats(const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const std::vector<int32_t> &uids)
|
||||
{
|
||||
if (bundleNames.empty()) {
|
||||
APP_LOGE("bundleName is empty");
|
||||
if (uids.empty()) {
|
||||
APP_LOGE("uids is empty");
|
||||
return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
|
||||
}
|
||||
|
||||
if (bundleNames.size() != uids.size()) {
|
||||
APP_LOGE("bundleNames size is not equal to uids size");
|
||||
return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR;
|
||||
}
|
||||
return CallService(&IInstalld::GetAllBundleStats, bundleNames, userId, bundleStats, uids);
|
||||
return CallService(&IInstalld::GetAllBundleStats, userId, bundleStats, uids);
|
||||
}
|
||||
|
||||
ErrCode InstalldClient::SetDirApl(const std::string &dir, const std::string &bundleName, const std::string &apl,
|
||||
|
@ -124,7 +124,7 @@ ErrCode InstalldClient::GetBundleStats(const std::string &bundleName, const int3
|
||||
return 0;
|
||||
}
|
||||
|
||||
ErrCode InstalldClient::GetAllBundleStats(const std::vector<std::string> &bundleNames, const int32_t userId,
|
||||
ErrCode InstalldClient::GetAllBundleStats(const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const std::vector<int32_t> &uids)
|
||||
{
|
||||
return 0;
|
||||
|
@ -114,7 +114,7 @@ ErrCode InstalldHostImpl::GetBundleStats(
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode InstalldHostImpl::GetAllBundleStats(const std::vector<std::string> &bundleNames, const int32_t userId,
|
||||
ErrCode InstalldHostImpl::GetAllBundleStats(const int32_t userId,
|
||||
std::vector<int64_t> &bundleStats, const std::vector<int32_t> &uids)
|
||||
{
|
||||
return ERR_OK;
|
||||
|
@ -465,7 +465,12 @@ HWTEST_F(BmsBundleCloneInstallerTest, BmsBundleCloneInstallerTest_017, TestSize.
|
||||
info.baseApplicationInfo_->applicationReservedFlag = static_cast<uint32_t>(
|
||||
ApplicationReservedFlag::ENCRYPTED_APPLICATION);
|
||||
DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr()->bundleInfos_[BUNDLE_NAME] = info;
|
||||
bundleCloneInstall_->GetDataMgr();
|
||||
auto res = bundleCloneInstall_->AddKeyOperation(BUNDLE_NAME, installer, userId_, uid_);
|
||||
#ifdef USE_BUNDLE_EXTENSION
|
||||
EXPECT_FALSE(res);
|
||||
#else
|
||||
EXPECT_TRUE(res);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ HWTEST_F(BmsBundleExceptionHandlerTest, HandleInvalidBundleTest_0100, TestSize.L
|
||||
info.SetInstallMark(BUNDLE_NAME, Package_NAME, InstallExceptionStatus::INSTALL_START);
|
||||
bundleExceptionHandler_->HandleInvalidBundle(info, isBundleValid);
|
||||
auto data = info.GetInstallMark();
|
||||
EXPECT_EQ(isBundleValid, true);
|
||||
EXPECT_EQ(isBundleValid, false);
|
||||
GTEST_LOG_(INFO) << "HandleInvalidBundleTest_0100 end";
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ HWTEST_F(BmsBundleExceptionHandlerTest, HandleInvalidBundleTest_0400, TestSize.L
|
||||
info.SetInstallMark(BUNDLE_NAME, Package_NAME, InstallExceptionStatus::INSTALL_START);
|
||||
bundleExceptionHandler_->HandleInvalidBundle(info, isBundleValid);
|
||||
auto data = info.GetInstallMark();
|
||||
EXPECT_EQ(isBundleValid, true);
|
||||
EXPECT_EQ(isBundleValid, false);
|
||||
GTEST_LOG_(INFO) << "HandleInvalidBundleTest_0400 end";
|
||||
}
|
||||
|
||||
|
@ -1309,19 +1309,10 @@ HWTEST_F(BmsBundleInstallerIPCTest, HandleGetAllBundleStats_0100, Function | Sma
|
||||
MessageParcel datas;
|
||||
std::u16string descriptor = InstalldHost::GetDescriptor();
|
||||
datas.WriteInterfaceToken(descriptor);
|
||||
datas.WriteBuffer(DATA, DATA_SIZE);
|
||||
datas.RewindRead(0);
|
||||
datas.WriteInt32(100);
|
||||
datas.WriteInt32(0);
|
||||
MessageParcel reply;
|
||||
reply.WriteInt32(0);
|
||||
bool res = host.HandleGetAllBundleStats(datas, reply);
|
||||
EXPECT_EQ(res, true);
|
||||
|
||||
reply.WriteInt32(Constants::MAX_PARCEL_CAPACITY + 1);
|
||||
res = host.HandleGetAllBundleStats(datas, reply);
|
||||
EXPECT_EQ(res, false);
|
||||
|
||||
reply.WriteInt32(DATA_SIZE);
|
||||
res = host.HandleGetAllBundleStats(datas, reply);
|
||||
EXPECT_EQ(res, false);
|
||||
}
|
||||
|
||||
|
@ -575,10 +575,9 @@ HWTEST_F(BmsBundleInstallerPermissionTest, CleanBundleDataDirByName_0100, Functi
|
||||
HWTEST_F(BmsBundleInstallerPermissionTest, GetAllBundleStats_0100, Function | SmallTest | Level1)
|
||||
{
|
||||
InstalldHostImpl hostImpl;
|
||||
std::vector<std::string> bundleNames;
|
||||
std::vector<int64_t> bundleStats = { 0 };
|
||||
std::vector<int32_t> uids;
|
||||
auto ret = hostImpl.GetAllBundleStats(bundleNames, 0, bundleStats, uids);
|
||||
auto ret = hostImpl.GetAllBundleStats(0, bundleStats, uids);
|
||||
EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALLD_PERMISSION_DENIED);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "bundle_installer_host.h"
|
||||
#include "bundle_mgr_service.h"
|
||||
#include "directory_ex.h"
|
||||
#include "file_ex.h"
|
||||
#include "hmp_bundle_installer.h"
|
||||
#include "install_param.h"
|
||||
#include "installd/installd_service.h"
|
||||
@ -46,8 +47,8 @@
|
||||
#include "scope_guard.h"
|
||||
#include "shared/shared_bundle_installer.h"
|
||||
#include "system_bundle_installer.h"
|
||||
#include "utd_handler.h"
|
||||
#include "want.h"
|
||||
#include "file_ex.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace std::chrono_literals;
|
||||
@ -700,7 +701,7 @@ HWTEST_F(BmsBundleInstallerTest, ParseModuleJson_0100, Function | SmallTest | Le
|
||||
EXPECT_EQ(hapModuleInfo.description, "$string:description_application");
|
||||
EXPECT_EQ(hapModuleInfo.mainAbility, "MainAbility");
|
||||
EXPECT_EQ(hapModuleInfo.process, "bba");
|
||||
EXPECT_EQ(hapModuleInfo.virtualMachine, "");
|
||||
EXPECT_EQ(hapModuleInfo.virtualMachine, "ark");
|
||||
EXPECT_EQ(hapModuleInfo.uiSyntax, "hml");
|
||||
EXPECT_EQ(hapModuleInfo.pages, "$profile:page_config");
|
||||
EXPECT_EQ(hapModuleInfo.deliveryWithInstall, true);
|
||||
@ -6149,12 +6150,10 @@ HWTEST_F(BmsBundleInstallerTest, CreateBundleDataDirWithVector_0100, Function |
|
||||
HWTEST_F(BmsBundleInstallerTest, GetAllBundleStats_0100, Function | SmallTest | Level1)
|
||||
{
|
||||
InstalldHostImpl hostImpl;
|
||||
std::vector<std::string> bundleNames;
|
||||
std::vector<int64_t> bundleStats = { 0 };
|
||||
std::vector<int32_t> uids;
|
||||
bundleNames.push_back(TEST_STRING);
|
||||
uids.push_back(EDM_UID);
|
||||
auto ret = hostImpl.GetAllBundleStats(bundleNames, EDM_UID, bundleStats, uids);
|
||||
auto ret = hostImpl.GetAllBundleStats(EDM_UID, bundleStats, uids);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
}
|
||||
|
||||
@ -6925,4 +6924,52 @@ HWTEST_F(BmsBundleInstallerTest, PreInstallBundleInfo_0100, Function | MediumTes
|
||||
preInstallBundleInfo.ToJson(jsonObject);
|
||||
EXPECT_EQ(jsonObject["bundleName"], "com.acts.example");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: UtdHandler_0100
|
||||
* @tc.name: test UtdHandler
|
||||
* @tc.desc: 1.call GetEntryHapPath, if exist entry then return entry path, otherwise return empty string
|
||||
*/
|
||||
HWTEST_F(BmsBundleInstallerTest, UtdHandler_0100, Function | SmallTest | Level0)
|
||||
{
|
||||
std::string bundlePath = RESOURCE_ROOT_PATH + BUNDLE_BACKUP_TEST;
|
||||
ErrCode installResult = InstallThirdPartyBundle(bundlePath);
|
||||
EXPECT_EQ(installResult, ERR_OK);
|
||||
|
||||
auto dataMgr = GetBundleDataMgr();
|
||||
EXPECT_NE(dataMgr, nullptr);
|
||||
|
||||
std::string entryHapPath;
|
||||
entryHapPath = UtdHandler::GetEntryHapPath(BUNDLE_BACKUP_NAME, USERID);
|
||||
EXPECT_NE(entryHapPath, EMPTY_STRING);
|
||||
|
||||
entryHapPath = UtdHandler::GetEntryHapPath(EMPTY_STRING, USERID);
|
||||
EXPECT_EQ(entryHapPath, EMPTY_STRING);
|
||||
|
||||
int32_t invalidUserId = -200;
|
||||
entryHapPath = UtdHandler::GetEntryHapPath(BUNDLE_BACKUP_NAME, invalidUserId);
|
||||
EXPECT_EQ(entryHapPath, EMPTY_STRING);
|
||||
|
||||
UnInstallBundle(BUNDLE_BACKUP_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: UtdHandler_0200
|
||||
* @tc.name: test UtdHandler
|
||||
* @tc.desc: 1.call GetUtdProfileFromHap, if exist utd.json5 then return content, otherwise return empty string
|
||||
*/
|
||||
HWTEST_F(BmsBundleInstallerTest, UtdHandler_0200, Function | SmallTest | Level0)
|
||||
{
|
||||
std::string utdProfile;
|
||||
std::string withUtdHapPath = RESOURCE_ROOT_PATH + BUNDLE_BACKUP_TEST;
|
||||
utdProfile = UtdHandler::GetUtdProfileFromHap(withUtdHapPath);
|
||||
EXPECT_NE(utdProfile, EMPTY_STRING);
|
||||
|
||||
std::string noUtdHapPath = RESOURCE_ROOT_PATH + RIGHT_BUNDLE;
|
||||
utdProfile = UtdHandler::GetUtdProfileFromHap(noUtdHapPath);
|
||||
EXPECT_EQ(utdProfile, EMPTY_STRING);
|
||||
|
||||
utdProfile = UtdHandler::GetUtdProfileFromHap(EMPTY_STRING);
|
||||
EXPECT_EQ(utdProfile, EMPTY_STRING);
|
||||
}
|
||||
} // OHOS
|
||||
|
@ -972,7 +972,7 @@ HWTEST_F(BmsExtensionDataMgrTest, BmsExtensionDetermineCloneNum_0001, Function |
|
||||
int32_t cloneNum = 0;
|
||||
auto res = bundleMgrExtTest.DetermineCloneNum(bundleName, appIdentifier, cloneNum);
|
||||
#ifdef USE_EXTENSION_DATA
|
||||
EXPECT_NE(res, false);
|
||||
EXPECT_NE(res, true);
|
||||
#else
|
||||
EXPECT_EQ(res, false);
|
||||
#endif
|
||||
|
@ -1194,6 +1194,83 @@ HWTEST_F(BmsEventHandlerTest, IsQuickfixFlagExsit_0200, Function | SmallTest | L
|
||||
EXPECT_FALSE(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: InnerProcessUninstallForExistPreBundle_0100
|
||||
* @tc.name: InnerProcessUninstallForExistPreBundle
|
||||
* @tc.desc: test InnerProcessUninstallForExistPreBundle
|
||||
*/
|
||||
HWTEST_F(BmsEventHandlerTest, InnerProcessUninstallForExistPreBundle_0100, Function | SmallTest | Level0)
|
||||
{
|
||||
std::shared_ptr<BMSEventHandler> handler = std::make_shared<BMSEventHandler>();
|
||||
EXPECT_NE(handler, nullptr);
|
||||
if (handler) {
|
||||
BundleInfo bundleInfo;
|
||||
bool ret = handler->InnerProcessUninstallForExistPreBundle(bundleInfo);
|
||||
EXPECT_FALSE(ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: InnerProcessUninstallForExistPreBundle_0200
|
||||
* @tc.name: InnerProcessUninstallForExistPreBundle
|
||||
* @tc.desc: test InnerProcessUninstallForExistPreBundle
|
||||
*/
|
||||
HWTEST_F(BmsEventHandlerTest, InnerProcessUninstallForExistPreBundle_0200, Function | SmallTest | Level0)
|
||||
{
|
||||
std::shared_ptr<BMSEventHandler> handler = std::make_shared<BMSEventHandler>();
|
||||
EXPECT_NE(handler, nullptr);
|
||||
if (handler) {
|
||||
HapModuleInfo moduleInfo_1;
|
||||
moduleInfo_1.hapPath = "/data/app/el1/bundle/public/xxx.hap";
|
||||
BundleInfo bundleInfo;
|
||||
bundleInfo.hapModuleInfos.emplace_back(moduleInfo_1);
|
||||
bool ret = handler->InnerProcessUninstallForExistPreBundle(bundleInfo);
|
||||
EXPECT_TRUE(ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: InnerProcessUninstallForExistPreBundle_0300
|
||||
* @tc.name: InnerProcessUninstallForExistPreBundle
|
||||
* @tc.desc: test InnerProcessUninstallForExistPreBundle
|
||||
*/
|
||||
HWTEST_F(BmsEventHandlerTest, InnerProcessUninstallForExistPreBundle_0300, Function | SmallTest | Level0)
|
||||
{
|
||||
std::shared_ptr<BMSEventHandler> handler = std::make_shared<BMSEventHandler>();
|
||||
EXPECT_NE(handler, nullptr);
|
||||
if (handler) {
|
||||
HapModuleInfo moduleInfo_1;
|
||||
moduleInfo_1.hapPath = "/system/app/xxx.hap";
|
||||
BundleInfo bundleInfo;
|
||||
bundleInfo.hapModuleInfos.emplace_back(moduleInfo_1);
|
||||
bool ret = handler->InnerProcessUninstallForExistPreBundle(bundleInfo);
|
||||
EXPECT_FALSE(ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: InnerProcessUninstallForExistPreBundle_0400
|
||||
* @tc.name: InnerProcessUninstallForExistPreBundle
|
||||
* @tc.desc: test InnerProcessUninstallForExistPreBundle
|
||||
*/
|
||||
HWTEST_F(BmsEventHandlerTest, InnerProcessUninstallForExistPreBundle_0400, Function | SmallTest | Level0)
|
||||
{
|
||||
std::shared_ptr<BMSEventHandler> handler = std::make_shared<BMSEventHandler>();
|
||||
EXPECT_NE(handler, nullptr);
|
||||
if (handler) {
|
||||
HapModuleInfo moduleInfo_1;
|
||||
moduleInfo_1.hapPath = "/data/app/el1/bundle/public/xxx.hap";
|
||||
HapModuleInfo moduleInfo_2;
|
||||
moduleInfo_2.hapPath = "/system/app/xxx.hap";
|
||||
|
||||
BundleInfo bundleInfo;
|
||||
bundleInfo.hapModuleInfos.emplace_back(moduleInfo_1);
|
||||
bundleInfo.hapModuleInfos.emplace_back(moduleInfo_2);
|
||||
bool ret = handler->InnerProcessUninstallForExistPreBundle(bundleInfo);
|
||||
EXPECT_FALSE(ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetValueFromJson_0100
|
||||
* @tc.name: GetValueFromJson
|
||||
|
@ -299,6 +299,9 @@ ohos_unittest("BmsInstallDaemonOperatorTest") {
|
||||
external_deps += [ "selinux_adapter:libhap_restorecon" ]
|
||||
cflags += [ "-DWITH_SELINUX" ]
|
||||
}
|
||||
if (current_cpu == "arm64") {
|
||||
defines += [ "USE_ARM64" ]
|
||||
}
|
||||
include_dirs = []
|
||||
if (code_signature_enable) {
|
||||
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
|
||||
|
@ -696,13 +696,11 @@ HWTEST_F(BmsInstallDaemonIpcTest, InstalldProxyTest_3300, Function | SmallTest |
|
||||
sptr<InstalldProxy> installdProxy = new (std::nothrow) InstalldProxy(nullptr);
|
||||
EXPECT_NE(installdProxy, nullptr);
|
||||
|
||||
std::vector<std::string> bundleNames;
|
||||
std::vector<int64_t> bundleStats;
|
||||
std::vector<int32_t> uids;
|
||||
bundleNames.push_back(TEST_STRING);
|
||||
bundleStats.push_back(LAST_MODIFY_TIME);
|
||||
uids.push_back(UID);
|
||||
auto ret = installdProxy->GetAllBundleStats(bundleNames, UID, bundleStats, uids);
|
||||
auto ret = installdProxy->GetAllBundleStats(UID, bundleStats, uids);
|
||||
EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_INSTALLD_SERVICE_ERROR);
|
||||
}
|
||||
|
||||
@ -1248,13 +1246,11 @@ HWTEST_F(BmsInstallDaemonIpcTest, InstalldProxyTest_6700, Function | SmallTest |
|
||||
auto proxy = GetInstallProxy();
|
||||
ASSERT_NE(proxy, nullptr);
|
||||
|
||||
std::vector<std::string> bundleNames;
|
||||
std::vector<int64_t> bundleStats;
|
||||
std::vector<int32_t> uids;
|
||||
bundleNames.push_back(TEST_STRING);
|
||||
bundleStats.push_back(LAST_MODIFY_TIME);
|
||||
uids.push_back(UID);
|
||||
auto ret = proxy->GetAllBundleStats(bundleNames, UID, bundleStats, uids);
|
||||
auto ret = proxy->GetAllBundleStats(UID, bundleStats, uids);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
}
|
||||
|
||||
|
@ -98,26 +98,22 @@ void BmsInstallDaemonOperatorTest::TearDown()
|
||||
|
||||
void BmsInstallDaemonOperatorTest::CreateQuickFileDir(const std::string &dir) const
|
||||
{
|
||||
bool ret = BundleUtil::CreateDir(dir);
|
||||
EXPECT_TRUE(ret);
|
||||
BundleUtil::CreateDir(dir);
|
||||
}
|
||||
|
||||
void BmsInstallDaemonOperatorTest::DeleteQuickFileDir(const std::string &dir) const
|
||||
{
|
||||
bool ret = BundleUtil::DeleteDir(dir);
|
||||
EXPECT_TRUE(ret);
|
||||
BundleUtil::DeleteDir(dir);
|
||||
}
|
||||
|
||||
void BmsInstallDaemonOperatorTest::CreateFile(const std::string &filePath, const std::string &content) const
|
||||
{
|
||||
auto ret = SaveStringToFile(filePath, content);
|
||||
EXPECT_TRUE(ret);
|
||||
SaveStringToFile(filePath, content);
|
||||
}
|
||||
|
||||
void BmsInstallDaemonOperatorTest::DeleteFile(const std::string &filePath) const
|
||||
{
|
||||
auto ret = RemoveFile(filePath);
|
||||
EXPECT_TRUE(ret);
|
||||
RemoveFile(filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1672,7 +1668,11 @@ HWTEST_F(BmsInstallDaemonOperatorTest, InstalldOperatorTest_10500, Function | Sm
|
||||
{
|
||||
CreateQuickFileDir("/test/oldPath");
|
||||
auto ret = InstalldOperator::RenameFile("/test/oldPath", "/test/newPath");
|
||||
#ifdef USE_ARM64
|
||||
EXPECT_FALSE(ret);
|
||||
#else
|
||||
EXPECT_TRUE(ret);
|
||||
#endif
|
||||
DeleteQuickFileDir("/test/newPath");
|
||||
}
|
||||
|
||||
@ -1700,9 +1700,13 @@ HWTEST_F(BmsInstallDaemonOperatorTest, InstalldOperatorTest_10700, Function | Sm
|
||||
CreateFile("/temp/test/test.ap", "test");
|
||||
std::vector<std::string> dirsToKeep;
|
||||
bool ret = InstalldOperator::DeleteFilesExceptDirs("/temp", dirsToKeep);
|
||||
#ifdef USE_ARM64
|
||||
EXPECT_FALSE(ret);
|
||||
#else
|
||||
EXPECT_TRUE(ret);
|
||||
DeleteFile("/temp/test/test.ap");
|
||||
DeleteQuickFileDir("/temp");
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1716,7 +1720,11 @@ HWTEST_F(BmsInstallDaemonOperatorTest, InstalldOperatorTest_10800, Function | Sm
|
||||
CreateFile("/temp/test.ap", "test");
|
||||
std::vector<std::string> paths;
|
||||
auto ret = InstalldOperator::ScanDir("/temp/", ScanMode::SUB_FILE_DIR, ResultMode::RELATIVE_PATH, paths);
|
||||
#ifdef USE_ARM64
|
||||
EXPECT_FALSE(ret);
|
||||
#else
|
||||
EXPECT_TRUE(ret);
|
||||
#endif
|
||||
DeleteFile("/temp/test.ap");
|
||||
DeleteQuickFileDir("/temp");
|
||||
}
|
||||
@ -1732,7 +1740,11 @@ HWTEST_F(BmsInstallDaemonOperatorTest, InstalldOperatorTest_10900, Function | Sm
|
||||
CreateFile("/temp/test.ap", "test");
|
||||
std::vector<std::string> paths;
|
||||
auto ret = InstalldOperator::ScanDir("/temp/", ScanMode::SUB_FILE_FILE, ResultMode::RELATIVE_PATH, paths);
|
||||
#ifdef USE_ARM64
|
||||
EXPECT_FALSE(ret);
|
||||
#else
|
||||
EXPECT_TRUE(ret);
|
||||
#endif
|
||||
DeleteFile("/temp/test.ap");
|
||||
DeleteQuickFileDir("/temp");
|
||||
}
|
||||
@ -1748,7 +1760,11 @@ HWTEST_F(BmsInstallDaemonOperatorTest, InstalldOperatorTest_11000, Function | Sm
|
||||
CreateFile("/temp/test.ap", "test");
|
||||
std::vector<std::string> paths;
|
||||
auto ret = InstalldOperator::ScanDir("/temp/", ScanMode::SUB_FILE_ALL, ResultMode::RELATIVE_PATH, paths);
|
||||
#ifdef USE_ARM64
|
||||
EXPECT_FALSE(ret);
|
||||
#else
|
||||
EXPECT_TRUE(ret);
|
||||
#endif
|
||||
DeleteFile("/temp/test.ap");
|
||||
DeleteQuickFileDir("/temp");
|
||||
}
|
||||
@ -1850,7 +1866,11 @@ HWTEST_F(BmsInstallDaemonOperatorTest, InstalldOperatorTest_11700, Function | Sm
|
||||
codeSignatureParam.isEnterpriseBundle = true;
|
||||
codeSignatureParam.isPreInstalledBundle = true;
|
||||
ErrCode ret = InstalldOperator::VerifyCodeSignature(codeSignatureParam);
|
||||
#ifdef USE_ARM64
|
||||
EXPECT_FALSE(ret);
|
||||
#else
|
||||
EXPECT_TRUE(ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1914,7 +1934,11 @@ HWTEST_F(BmsInstallDaemonOperatorTest, InstalldOperatorTest_12100, Function | Sm
|
||||
auto ret = InstalldOperator::MoveFile("", "");
|
||||
EXPECT_FALSE(ret);
|
||||
ret = InstalldOperator::MoveFile("/temp.ap", "/temp1.ap");
|
||||
#ifdef USE_ARM64
|
||||
EXPECT_FALSE(ret);
|
||||
#else
|
||||
EXPECT_TRUE(ret);
|
||||
#endif
|
||||
DeleteFile("/temp1.ap");
|
||||
}
|
||||
|
||||
@ -1946,6 +1970,10 @@ HWTEST_F(BmsInstallDaemonOperatorTest, InstalldOperatorTest_12300, Function | Sm
|
||||
extractParam.extractFileType = ExtractFileType::SO;
|
||||
BundleExtractor extractor("");
|
||||
auto ret = InstalldOperator::ExtractResourceFiles(extractParam, extractor);
|
||||
#ifdef USE_ARM64
|
||||
EXPECT_FALSE(ret);
|
||||
#else
|
||||
EXPECT_TRUE(ret);
|
||||
#endif
|
||||
}
|
||||
} // OHOS
|
@ -1056,11 +1056,10 @@ HWTEST_F(BmsInstallDaemonTest, GetDiskUsage_0100, Function | SmallTest | Level0)
|
||||
HWTEST_F(BmsInstallDaemonTest, GetAllBundleStats_0100, Function | SmallTest | Level0)
|
||||
{
|
||||
InstalldHostImpl hostImpl;
|
||||
std::vector<std::string> bundleNames;
|
||||
int32_t userId = 100;
|
||||
std::vector<int64_t> bundleStats;
|
||||
std::vector<int32_t> uids;
|
||||
ErrCode ret = hostImpl.GetAllBundleStats(bundleNames, userId, bundleStats, uids);
|
||||
ErrCode ret = hostImpl.GetAllBundleStats(userId, bundleStats, uids);
|
||||
EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALLD_PARAM_ERROR);
|
||||
}
|
||||
|
||||
@ -1072,15 +1071,12 @@ HWTEST_F(BmsInstallDaemonTest, GetAllBundleStats_0100, Function | SmallTest | Le
|
||||
HWTEST_F(BmsInstallDaemonTest, GetAllBundleStats_0200, Function | SmallTest | Level0)
|
||||
{
|
||||
InstalldHostImpl hostImpl;
|
||||
std::vector<std::string> bundleNames;
|
||||
bundleNames.push_back("com.acts.example1");
|
||||
bundleNames.push_back("com.acts.example2");
|
||||
int32_t userId = 100;
|
||||
std::vector<int64_t> bundleStats;
|
||||
std::vector<int32_t> uids;
|
||||
uids.push_back(101);
|
||||
uids.push_back(102);
|
||||
ErrCode ret = hostImpl.GetAllBundleStats(bundleNames, userId, bundleStats, uids);
|
||||
ErrCode ret = hostImpl.GetAllBundleStats(userId, bundleStats, uids);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
}
|
||||
|
||||
|
@ -1552,12 +1552,11 @@ HWTEST_F(BmsInstalldClientTest, BmsInstalldClientTest_CreateExtensionDataDir_020
|
||||
*/
|
||||
HWTEST_F(BmsInstalldClientTest, BmsInstalldClientTest_GetAllBundleStats_0100, TestSize.Level1)
|
||||
{
|
||||
std::vector<std::string> bundleNames;
|
||||
int32_t userId = 100;
|
||||
std::vector<int64_t> bundleStats;
|
||||
std::vector<int32_t> uids;
|
||||
ASSERT_NE(installClient_, nullptr);
|
||||
ErrCode result = installClient_->GetAllBundleStats(bundleNames, userId, bundleStats, uids);
|
||||
ErrCode result = installClient_->GetAllBundleStats(userId, bundleStats, uids);
|
||||
EXPECT_EQ(result, ERR_APPEXECFWK_INSTALLD_PARAM_ERROR);
|
||||
}
|
||||
|
||||
@ -1568,15 +1567,11 @@ HWTEST_F(BmsInstalldClientTest, BmsInstalldClientTest_GetAllBundleStats_0100, Te
|
||||
*/
|
||||
HWTEST_F(BmsInstalldClientTest, BmsInstalldClientTest_GetAllBundleStats_0200, TestSize.Level1)
|
||||
{
|
||||
std::vector<std::string> bundleNames;
|
||||
bundleNames.push_back("com.ohos.settings");
|
||||
bundleNames.push_back("com.ohos.photos");
|
||||
int32_t userId = 100;
|
||||
std::vector<int64_t> bundleStats;
|
||||
std::vector<int32_t> uids;
|
||||
uids.push_back(100);
|
||||
ASSERT_NE(installClient_, nullptr);
|
||||
ErrCode result = installClient_->GetAllBundleStats(bundleNames, userId, bundleStats, uids);
|
||||
ErrCode result = installClient_->GetAllBundleStats(userId, bundleStats, uids);
|
||||
EXPECT_EQ(result, ERR_APPEXECFWK_INSTALLD_PARAM_ERROR);
|
||||
}
|
||||
|
||||
@ -1587,16 +1582,13 @@ HWTEST_F(BmsInstalldClientTest, BmsInstalldClientTest_GetAllBundleStats_0200, Te
|
||||
*/
|
||||
HWTEST_F(BmsInstalldClientTest, BmsInstalldClientTest_GetAllBundleStats_0300, TestSize.Level1)
|
||||
{
|
||||
std::vector<std::string> bundleNames;
|
||||
bundleNames.push_back("com.ohos.settings");
|
||||
bundleNames.push_back("com.ohos.photos");
|
||||
int32_t userId = 100;
|
||||
std::vector<int64_t> bundleStats;
|
||||
std::vector<int32_t> uids;
|
||||
uids.push_back(100);
|
||||
uids.push_back(101);
|
||||
ASSERT_NE(installClient_, nullptr);
|
||||
ErrCode result = installClient_->GetAllBundleStats(bundleNames, userId, bundleStats, uids);
|
||||
ErrCode result = installClient_->GetAllBundleStats(userId, bundleStats, uids);
|
||||
EXPECT_EQ(result, ERR_APPEXECFWK_INSTALLD_GET_PROXY_ERROR);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0"
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0"
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0"
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0"
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0"
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0"
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0"
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0"
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
|
@ -8,7 +8,7 @@
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"targetAPIVersion": 14,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
|
@ -0,0 +1,28 @@
|
||||
{
|
||||
"UniformDataTypeDeclarations": [
|
||||
{
|
||||
"TypeId": "com.example.backuptest.image",
|
||||
"BelongingToTypes": ["general.image"],
|
||||
"FilenameExtensions": [".myImage", ".khImage"],
|
||||
"MIMETypes": ["application/myImage", "application/khImage"],
|
||||
"Description": "My Image.",
|
||||
"ReferenceURL": ""
|
||||
},
|
||||
{
|
||||
"TypeId": "com.example.backuptest.audio",
|
||||
"BelongingToTypes": ["general.audio"],
|
||||
"FilenameExtensions": [".myAudio", ".khAudio"],
|
||||
"MIMETypes": ["application/myAudio", "application/khAudio"],
|
||||
"Description": "My audio.",
|
||||
"ReferenceURL": ""
|
||||
},
|
||||
{
|
||||
"TypeId": "com.example.backuptest.video",
|
||||
"BelongingToTypes": ["general.video"],
|
||||
"FilenameExtensions": [".myVideo", ".khVideo"],
|
||||
"MIMETypes": ["application/myVideo", "application/khVideo"],
|
||||
"Description": "My video.",
|
||||
"ReferenceURL": ""
|
||||
}
|
||||
]
|
||||
}
|
@ -97,6 +97,7 @@ const int32_t PERMS_INDEX_FIVE = 5;
|
||||
const int32_t PERMS_INDEX_SIX = 6;
|
||||
const int32_t PERMS_INDEX_SEVEN = 7;
|
||||
const int32_t PERMS_INDEX_EIGHT = 8;
|
||||
const int32_t PERMS_INDEX_NINE = 9;
|
||||
const size_t ODID_LENGTH = 36;
|
||||
const int32_t TEST_INSTALLER_UID = 100;
|
||||
const int32_t TEST_APP_INDEX1 = 1;
|
||||
@ -301,7 +302,7 @@ void ActsBmsKitSystemTest::TearDown()
|
||||
|
||||
void ActsBmsKitSystemTest::StartProcess()
|
||||
{
|
||||
const int32_t permsNum = 9;
|
||||
const int32_t permsNum = 10;
|
||||
uint64_t tokenId;
|
||||
const char *perms[permsNum];
|
||||
perms[PERMS_INDEX_ZERO] = "ohos.permission.GET_DEFAULT_APPLICATION";
|
||||
@ -313,6 +314,7 @@ void ActsBmsKitSystemTest::StartProcess()
|
||||
perms[PERMS_INDEX_SIX] = "ohos.permission.CHANGE_BUNDLE_UNINSTALL_STATE";
|
||||
perms[PERMS_INDEX_SEVEN] = "ohos.permission.INSTALL_CLONE_BUNDLE";
|
||||
perms[PERMS_INDEX_EIGHT] = "ohos.permission.UNINSTALL_CLONE_BUNDLE";
|
||||
perms[PERMS_INDEX_NINE] = "ohos.permission.LISTEN_BUNDLE_CHANGE";
|
||||
NativeTokenInfoParams infoInstance = {
|
||||
.dcapsNum = 0,
|
||||
.permsNum = permsNum,
|
||||
@ -3257,6 +3259,7 @@ HWTEST_F(ActsBmsKitSystemTest, GetLaunchWantForBundle_0100, Function | MediumTes
|
||||
*/
|
||||
HWTEST_F(ActsBmsKitSystemTest, Callback_0100, Function | MediumTest | Level1)
|
||||
{
|
||||
StartProcess();
|
||||
std::cout << "START Callback_0100" << std::endl;
|
||||
bool result = false;
|
||||
for (int i = 1; i <= stLevel_.BMSLevel; i++) {
|
||||
@ -3311,6 +3314,7 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0100, Function | MediumTest | Level1)
|
||||
*/
|
||||
HWTEST_F(ActsBmsKitSystemTest, Callback_0300, Function | MediumTest | Level1)
|
||||
{
|
||||
StartProcess();
|
||||
std::cout << "START Callback_0300" << std::endl;
|
||||
bool result = false;
|
||||
for (int i = 1; i <= stLevel_.BMSLevel; i++) {
|
||||
@ -3370,6 +3374,7 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0300, Function | MediumTest | Level1)
|
||||
*/
|
||||
HWTEST_F(ActsBmsKitSystemTest, Callback_0400, Function | MediumTest | Level1)
|
||||
{
|
||||
StartProcess();
|
||||
std::cout << "START Callback_0400" << std::endl;
|
||||
bool result = false;
|
||||
for (int i = 1; i <= stLevel_.BMSLevel; i++) {
|
||||
@ -3429,6 +3434,7 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0400, Function | MediumTest | Level1)
|
||||
*/
|
||||
HWTEST_F(ActsBmsKitSystemTest, Callback_0500, Function | MediumTest | Level1)
|
||||
{
|
||||
StartProcess();
|
||||
std::cout << "START Callback_0500" << std::endl;
|
||||
bool result = false;
|
||||
for (int i = 1; i <= stLevel_.BMSLevel; i++) {
|
||||
@ -3486,6 +3492,7 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0500, Function | MediumTest | Level1)
|
||||
*/
|
||||
HWTEST_F(ActsBmsKitSystemTest, Callback_0600, Function | MediumTest | Level1)
|
||||
{
|
||||
StartProcess();
|
||||
std::cout << "START Callback_0600" << std::endl;
|
||||
bool result = false;
|
||||
for (int i = 1; i <= stLevel_.BMSLevel; i++) {
|
||||
@ -3538,6 +3545,7 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0600, Function | MediumTest | Level1)
|
||||
*/
|
||||
HWTEST_F(ActsBmsKitSystemTest, Callback_0700, Function | MediumTest | Level1)
|
||||
{
|
||||
StartProcess();
|
||||
std::cout << "START Callback_0700" << std::endl;
|
||||
bool result = false;
|
||||
for (int i = 1; i <= stLevel_.BMSLevel; i++) {
|
||||
@ -3597,6 +3605,7 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0700, Function | MediumTest | Level1)
|
||||
*/
|
||||
HWTEST_F(ActsBmsKitSystemTest, Callback_0800, Function | MediumTest | Level1)
|
||||
{
|
||||
StartProcess();
|
||||
std::cout << "START Callback_0800" << std::endl;
|
||||
bool result = false;
|
||||
for (int i = 1; i <= stLevel_.BMSLevel; i++) {
|
||||
@ -3659,6 +3668,7 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0800, Function | MediumTest | Level1)
|
||||
*/
|
||||
HWTEST_F(ActsBmsKitSystemTest, Callback_0900, Function | MediumTest | Level1)
|
||||
{
|
||||
StartProcess();
|
||||
std::cout << "START Callback_0900" << std::endl;
|
||||
bool result = false;
|
||||
for (int i = 1; i <= stLevel_.BMSLevel; i++) {
|
||||
@ -3714,6 +3724,7 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0900, Function | MediumTest | Level1)
|
||||
*/
|
||||
HWTEST_F(ActsBmsKitSystemTest, Callback_1000, Function | MediumTest | Level1)
|
||||
{
|
||||
StartProcess();
|
||||
sptr<IBundleStatusCallback> callBack = (new (std::nothrow) BundleStatusCallbackImpl());
|
||||
EXPECT_NE(callBack, nullptr);
|
||||
callBack->SetBundleName(BASE_BUNDLE_NAME);
|
||||
@ -3729,6 +3740,7 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_1000, Function | MediumTest | Level1)
|
||||
*/
|
||||
HWTEST_F(ActsBmsKitSystemTest, Callback_1100, Function | MediumTest | Level1)
|
||||
{
|
||||
StartProcess();
|
||||
sptr<BundleStatusCallbackImpl> firstBundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl());
|
||||
EXPECT_NE(firstBundleStatusCallback, nullptr);
|
||||
firstBundleStatusCallback->SetBundleName("");
|
||||
|
@ -41,6 +41,10 @@ ohos_systemtest("BmsLauncherServiceSystemTest") {
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libnativetoken",
|
||||
"access_token:libtoken_setproc",
|
||||
"access_token:libtokenid_sdk",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hilog:libhilog",
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "accesstoken_kit.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "bundle_constants.h"
|
||||
#include "bundle_installer_interface.h"
|
||||
@ -29,9 +30,11 @@
|
||||
#include "iservice_registry.h"
|
||||
#include "launcher_ability_info.h"
|
||||
#include "launcher_service.h"
|
||||
#include "nativetoken_kit.h"
|
||||
#include "operation_builder.h"
|
||||
#include "status_receiver_host.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "token_setproc.h"
|
||||
|
||||
namespace {
|
||||
const std::string THIRD_BUNDLE_PATH = "/data/test/bms_bundle/";
|
||||
@ -52,6 +55,16 @@ constexpr uint32_t USERID = 100;
|
||||
const unsigned int LIST_SIZE = 1;
|
||||
static const int APP_LABELID = 16777216;
|
||||
static const int APP_ICONID = 16777218;
|
||||
const int32_t PERMS_INDEX_ZERO = 0;
|
||||
const int32_t PERMS_INDEX_ONE = 1;
|
||||
const int32_t PERMS_INDEX_TWO = 2;
|
||||
const int32_t PERMS_INDEX_THREE = 3;
|
||||
const int32_t PERMS_INDEX_FORE = 4;
|
||||
const int32_t PERMS_INDEX_FIVE = 5;
|
||||
const int32_t PERMS_INDEX_SIX = 6;
|
||||
const int32_t PERMS_INDEX_SEVEN = 7;
|
||||
const int32_t PERMS_INDEX_EIGHT = 8;
|
||||
const int32_t PERMS_INDEX_NINE = 9;
|
||||
} // namespace
|
||||
using OHOS::AAFwk::Want;
|
||||
using namespace testing::ext;
|
||||
@ -77,6 +90,7 @@ public:
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
void StartProcess();
|
||||
static void Install(const std::string &bundleFilePath, const InstallFlag installFlag, std::string &installMessage);
|
||||
static void Uninstall(const std::string &bundleName, std::string &uninstallMessage);
|
||||
static sptr<IBundleMgr> GetBundleMgrProxy();
|
||||
@ -278,10 +292,42 @@ void BmsLauncherServiceSystemTest::SetUpTestCase()
|
||||
void BmsLauncherServiceSystemTest::TearDownTestCase()
|
||||
{}
|
||||
void BmsLauncherServiceSystemTest::SetUp()
|
||||
{}
|
||||
{
|
||||
StartProcess();
|
||||
}
|
||||
void BmsLauncherServiceSystemTest::TearDown()
|
||||
{}
|
||||
|
||||
void BmsLauncherServiceSystemTest::StartProcess()
|
||||
{
|
||||
const int32_t permsNum = 10;
|
||||
uint64_t tokenId;
|
||||
const char *perms[permsNum];
|
||||
perms[PERMS_INDEX_ZERO] = "ohos.permission.GET_DEFAULT_APPLICATION";
|
||||
perms[PERMS_INDEX_ONE] = "ohos.permission.INSTALL_BUNDLE";
|
||||
perms[PERMS_INDEX_TWO] = "ohos.permission.SET_DEFAULT_APPLICATION";
|
||||
perms[PERMS_INDEX_THREE] = "ohos.permission.GET_INSTALLED_BUNDLE_LIST";
|
||||
perms[PERMS_INDEX_FORE] = "ohos.permission.CHANGE_ABILITY_ENABLED_STATE";
|
||||
perms[PERMS_INDEX_FIVE] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED";
|
||||
perms[PERMS_INDEX_SIX] = "ohos.permission.CHANGE_BUNDLE_UNINSTALL_STATE";
|
||||
perms[PERMS_INDEX_SEVEN] = "ohos.permission.INSTALL_CLONE_BUNDLE";
|
||||
perms[PERMS_INDEX_EIGHT] = "ohos.permission.UNINSTALL_CLONE_BUNDLE";
|
||||
perms[PERMS_INDEX_NINE] = "ohos.permission.LISTEN_BUNDLE_CHANGE";
|
||||
NativeTokenInfoParams infoInstance = {
|
||||
.dcapsNum = 0,
|
||||
.permsNum = permsNum,
|
||||
.aclsNum = 0,
|
||||
.dcaps = NULL,
|
||||
.perms = perms,
|
||||
.acls = NULL,
|
||||
.processName = "kit_system_test",
|
||||
.aplStr = "system_core",
|
||||
};
|
||||
tokenId = GetAccessTokenId(&infoInstance);
|
||||
SetSelfTokenID(tokenId);
|
||||
OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
|
||||
}
|
||||
|
||||
class TestBundleStatusCallback : public IBundleStatusCallback {
|
||||
public:
|
||||
TestBundleStatusCallback() = default;
|
||||
|
Loading…
Reference in New Issue
Block a user