mirror of
https://github.com/openharmony/bundlemanager_bundle_framework_lite.git
synced 2026-07-19 12:13:04 -04:00
IssueNo:#I4ECO2
Description:add GetBundleInfosNoReplication interface Sig:appexecfwk Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: wangdengjia <wangdengjia@huawei.com> Change-Id: I67dce53c28887cd12e59ba4a21baefb1c47670fc
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
namespace OHOS {
|
||||
struct BundleInfoUtils {
|
||||
static void CopyBundleInfo(int32_t flags, BundleInfo *des, BundleInfo src);
|
||||
static void CopyBundleInfoNoReplication(int32_t flags, BundleInfo *des, BundleInfo src);
|
||||
static bool SetBundleInfoBundleName(BundleInfo *bundleInfo, const char *bundleName);
|
||||
static bool SetBundleInfoVendor(BundleInfo *bundleInfo, const char *vendor);
|
||||
static bool SetBundleInfoLabel(BundleInfo *bundleInfo, const char *label);
|
||||
|
||||
@@ -53,6 +53,8 @@ public:
|
||||
|
||||
void UpdateBundleInfoList() const;
|
||||
|
||||
uint8_t GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len) const;
|
||||
|
||||
private:
|
||||
BundleMsClient() = default;
|
||||
|
||||
|
||||
@@ -84,6 +84,50 @@ void BundleInfoUtils::CopyBundleInfo(int32_t flags, BundleInfo *des, BundleInfo
|
||||
#endif
|
||||
}
|
||||
|
||||
void BundleInfoUtils::CopyBundleInfoNoReplication(int32_t flags, BundleInfo *des, BundleInfo src)
|
||||
{
|
||||
if (des == nullptr) {
|
||||
return;
|
||||
}
|
||||
des->bundleName = src.bundleName;
|
||||
des->label = src.label;
|
||||
des->versionName = src.versionName;
|
||||
des->bigIconPath = src.bigIconPath;
|
||||
des->codePath = src.codePath;
|
||||
des->dataPath = src.dataPath;
|
||||
des->vendor = src.vendor;
|
||||
if (src.numOfModule != 0) {
|
||||
des->numOfModule = src.numOfModule;
|
||||
des->moduleInfos = src.moduleInfos;
|
||||
}
|
||||
des->isSystemApp = src.isSystemApp;
|
||||
des->versionCode = src.versionCode;
|
||||
des->compatibleApi = src.compatibleApi;
|
||||
des->targetApi = src.targetApi;
|
||||
des->appId = src.appId;
|
||||
#ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER
|
||||
des->isKeepAlive = src.isKeepAlive;
|
||||
des->isNativeApp = src.isNativeApp;
|
||||
des->uid = src.uid;
|
||||
des->gid = src.gid;
|
||||
if (flags == GET_BUNDLE_WITH_ABILITIES) {
|
||||
SetBundleInfoAbilityInfos(des, src.abilityInfos, src.numOfAbility);
|
||||
} else {
|
||||
des->abilityInfos = nullptr;
|
||||
des->numOfAbility = 0;
|
||||
}
|
||||
#else
|
||||
des->smallIconPath = src.smallIconPath;
|
||||
if (flags == GET_BUNDLE_WITH_ABILITIES) {
|
||||
if (src.abilityInfo != nullptr) {
|
||||
des->abilityInfo = src.abilityInfo;
|
||||
}
|
||||
} else {
|
||||
des->abilityInfo = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool BundleInfoUtils::SetBundleInfoBundleName(BundleInfo *bundleInfo, const char *bundleName)
|
||||
{
|
||||
if (bundleInfo == nullptr || bundleName == nullptr) {
|
||||
|
||||
@@ -38,4 +38,9 @@ void UpdateBundleInfoList(void)
|
||||
{
|
||||
OHOS::BundleMsClient::GetInstance().UpdateBundleInfoList();
|
||||
}
|
||||
|
||||
uint8_t GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len)
|
||||
{
|
||||
return OHOS::BundleMsClient::GetInstance().GetBundleInfosNoReplication(flags, bundleInfos, len);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,4 +196,12 @@ void BundleMsClient::UpdateBundleInfoList () const
|
||||
}
|
||||
bmsProxy_->UpdateBundleInfoList();
|
||||
}
|
||||
|
||||
uint8_t BundleMsClient::GetBundleInfosNoReplication (const int flags, BundleInfo **bundleInfos, int32_t *len) const
|
||||
{
|
||||
if (!Initialize()) {
|
||||
return -1;
|
||||
}
|
||||
return bmsProxy_->GetBundleInfosNoReplication(flags, bundleInfos, len);
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -53,6 +53,7 @@ struct BmsSliteInterface {
|
||||
uint32_t (*GetBundleSize)(const char *bundleName);
|
||||
bool (*RegisterInstallerCallback)(InstallerCallback installerCallback);
|
||||
void (*UpdateBundleInfoList)();
|
||||
uint8_t (*GetBundleInfosNoReplication)(const int flags, BundleInfo **bundleInfos, int32_t *len);
|
||||
};
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -81,6 +81,20 @@ bool RegisterInstallerCallback(InstallerCallback installerCallback);
|
||||
*/
|
||||
void UpdateBundleInfoList(void);
|
||||
|
||||
/**
|
||||
* @brief Obtains the {@link BundleInfo} of all bundles with no replication in the system.
|
||||
*
|
||||
* @param flags Specifies whether each of the obtained {@link BundleInfo} objects can contain {@link AbilityInfo}.
|
||||
* The value <b>1</b> indicates that it can contain {@link AbilityInfo}, and <b>0</b> indicates that
|
||||
* it cannot.
|
||||
* @param bundleInfos Indicates the double pointer to the obtained {@link BundleInfo} objects.
|
||||
* @param len Indicates the pointer to the number of {@link BundleInfo} objects obtained.
|
||||
* @return Returns {@link ERR_OK} if this function is successfully called; returns another error code defined in
|
||||
* {@link AppexecfwkErrors} otherwise.
|
||||
*
|
||||
*/
|
||||
uint8_t GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
bool Update(BundleInfo *bundleInfo);
|
||||
BundleInfo *Get(const char *bundleName) const;
|
||||
uint8_t GetBundleInfos(int32_t flags, BundleInfo **bundleInfos, int32_t *len) const;
|
||||
uint8_t GetBundleInfosNoReplication(int32_t flags, BundleInfo **bundleInfos, int32_t *len) const;
|
||||
uint8_t GetBundleInfo(const char *bundleName, int32_t flags, BundleInfo &bundleInfo) const;
|
||||
void Erase(const char *bundleName);
|
||||
void EraseAll();
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
static uint32_t GetBundleSize (const char *bundleName);
|
||||
static bool RegisterInstallerCallback(InstallerCallback installerCallback);
|
||||
static void UpdateBundleInfoList();
|
||||
static uint8_t GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len);
|
||||
|
||||
static BundleMgrSliteFeature *GetInstance()
|
||||
{
|
||||
|
||||
@@ -61,6 +61,7 @@ public:
|
||||
uint8_t QueryAbilityInfo(const Want *want, AbilityInfo *abilityInfo);
|
||||
uint8_t GetBundleInfo(const char *bundleName, int32_t flags, BundleInfo& bundleInfo);
|
||||
uint8_t GetBundleInfos(const int flags, BundleInfo **bundleInfos, int32_t *len);
|
||||
uint8_t GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len);
|
||||
void ScanPackages();
|
||||
BundleInfo *QueryBundleInfo(const char *bundleName);
|
||||
void RemoveBundleInfo(const char *bundleName);
|
||||
|
||||
@@ -204,6 +204,39 @@ uint8_t BundleMap::GetBundleInfos(int32_t flags, BundleInfo **bundleInfos, int32
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
uint8_t BundleMap::GetBundleInfosNoReplication(int32_t flags, BundleInfo **bundleInfos, int32_t *len) const
|
||||
{
|
||||
if (bundleInfos == nullptr) {
|
||||
return ERR_APPEXECFWK_QUERY_PARAMETER_ERROR;
|
||||
}
|
||||
#ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER
|
||||
MutexAcquire(&g_bundleListMutex, 0);
|
||||
#else
|
||||
MutexAcquire(&g_bundleListMutex, BUNDLELIST_MUTEX_TIMEOUT);
|
||||
#endif
|
||||
if (bundleInfos_->IsEmpty()) {
|
||||
MutexRelease(&g_bundleListMutex);
|
||||
return ERR_APPEXECFWK_QUERY_NO_INFOS;
|
||||
}
|
||||
|
||||
BundleInfo *infos = reinterpret_cast<BundleInfo *>(AdapterMalloc(sizeof(BundleInfo) * bundleInfos_->Size()));
|
||||
if (infos == nullptr || memset_s(infos, sizeof(BundleInfo) * bundleInfos_->Size(), 0,
|
||||
sizeof(BundleInfo) * bundleInfos_->Size()) != EOK) {
|
||||
AdapterFree(infos);
|
||||
MutexRelease(&g_bundleListMutex);
|
||||
return ERR_APPEXECFWK_QUERY_INFOS_INIT_ERROR;
|
||||
}
|
||||
*bundleInfos = infos;
|
||||
|
||||
for (auto node = bundleInfos_->Begin(); node != bundleInfos_->End(); node = node->next_) {
|
||||
BundleInfoUtils::CopyBundleInfoNoReplication(flags, infos++, *(node->value_));
|
||||
}
|
||||
|
||||
*len = bundleInfos_->Size();
|
||||
MutexRelease(&g_bundleListMutex);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
uint8_t BundleMap::GetBundleInfo(const char *bundleName, int32_t flags, BundleInfo &bundleInfo) const
|
||||
{
|
||||
if (bundleName == nullptr) {
|
||||
|
||||
@@ -36,6 +36,7 @@ BundleMgrSliteFeatureImpl g_bmsSliteImpl = {
|
||||
.GetBundleSize = BundleMgrSliteFeature::GetBundleSize,
|
||||
.RegisterInstallerCallback = BundleMgrSliteFeature::RegisterInstallerCallback,
|
||||
.UpdateBundleInfoList = BundleMgrSliteFeature::UpdateBundleInfoList,
|
||||
.GetBundleInfosNoReplication = BundleMgrSliteFeature::GetBundleInfosNoReplication,
|
||||
DEFAULT_IUNKNOWN_ENTRY_END
|
||||
};
|
||||
|
||||
@@ -144,4 +145,9 @@ void BundleMgrSliteFeature::UpdateBundleInfoList()
|
||||
{
|
||||
OHOS::GtManagerService::GetInstance().UpdateBundleInfoList();
|
||||
}
|
||||
|
||||
uint8_t BundleMgrSliteFeature::GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len)
|
||||
{
|
||||
return OHOS::GtManagerService::GetInstance().GetBundleInfosNoReplication(flags, bundleInfos, len);
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -245,6 +245,14 @@ uint8_t GtManagerService::GetBundleInfos(const int flags, BundleInfo **bundleInf
|
||||
return bundleMap_->GetBundleInfos(flags, bundleInfos, len);
|
||||
}
|
||||
|
||||
uint8_t GtManagerService::GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len)
|
||||
{
|
||||
if (bundleMap_ == nullptr) {
|
||||
return ERR_APPEXECFWK_OBJECT_NULL;
|
||||
}
|
||||
return bundleMap_->GetBundleInfosNoReplication(flags, bundleInfos, len);
|
||||
}
|
||||
|
||||
bool GtManagerService::RegisterInstallerCallback(InstallerCallback installerCallback)
|
||||
{
|
||||
if (installerCallback == nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user