mirror of
https://github.com/openharmony/bundlemanager_bundle_framework_lite.git
synced 2026-07-18 17:54:39 -04:00
Merge branch 'master' of https://gitee.com/openharmony/bundlemanager_bundle_framework_lite
Change-Id: I7f412108fb0130258bc34312161f8169ceb5406e
This commit is contained in:
@@ -207,7 +207,7 @@ bool AbilityInfoUtils::SetAbilityInfoSkill(AbilityInfo *abilityInfo, Skill * con
|
||||
if (skills[i] == nullptr) {
|
||||
return false;
|
||||
}
|
||||
abilityInfo->skills[i] = (Skill *)AdapterMalloc(sizeof(Skill));
|
||||
abilityInfo->skills[i] = static_cast<Skill *>(AdapterMalloc(sizeof(Skill)));
|
||||
CopyStringArray(abilityInfo->skills[i]->entities, skills[i]->entities, MAX_SKILL_ITEM);
|
||||
CopyStringArray(abilityInfo->skills[i]->actions, skills[i]->actions, MAX_SKILL_ITEM);
|
||||
}
|
||||
|
||||
@@ -793,6 +793,7 @@ uint8_t GetBundleNameForUid(int32_t uid, char **bundleName)
|
||||
resultOfGetBundleNameForUid.bundleName, resultOfGetBundleNameForUid.length);
|
||||
AdapterFree(resultOfGetBundleNameForUid.bundleName);
|
||||
if (err != EOK) {
|
||||
AdapterFree(*bundleName);
|
||||
return ERR_APPEXECFWK_SYSTEM_INTERNAL_ERROR;
|
||||
}
|
||||
return resultOfGetBundleNameForUid.resultCode;
|
||||
|
||||
@@ -60,9 +60,6 @@ bool BundleMsClient::Initialize() const
|
||||
bool BundleMsClient::Install(const char *hapPath, const InstallParam *installParam,
|
||||
InstallerCallback installerCallback) const
|
||||
{
|
||||
if (g_bmsbuff == nullptr) {
|
||||
g_bmsbuff = reinterpret_cast<Bmsbuff *>(OhosMalloc(MEM_TYPE_APPFMK_LSRAM, sizeof(Bmsbuff)));
|
||||
}
|
||||
BundleMgrService *service = BundleMgrService::GetInstance();
|
||||
if (service == nullptr) {
|
||||
return false;
|
||||
@@ -70,22 +67,23 @@ bool BundleMsClient::Install(const char *hapPath, const InstallParam *installPar
|
||||
if (hapPath == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (memset_s(g_bmsbuff->bundleParameter, MAX_PATH_LEN, 0, MAX_PATH_LEN) != 0) {
|
||||
return false;
|
||||
}
|
||||
int len = strlen(hapPath);
|
||||
if (len >= MAX_PATH_LEN) {
|
||||
return false;
|
||||
}
|
||||
if (memcpy_s(g_bmsbuff->bundleParameter, MAX_PATH_LEN, hapPath, len + 1) != 0) {
|
||||
Bmsbuff *data = static_cast<Bmsbuff *>(AdapterMalloc(sizeof(Bmsbuff)));
|
||||
if (data == nullptr) {
|
||||
return false;
|
||||
}
|
||||
g_bmsbuff->bundleInstallerCallback = installerCallback;
|
||||
if (memcpy_s(data->bundleParameter, MAX_PATH_LEN, hapPath, len + 1) != 0) {
|
||||
AdapterFree(data);
|
||||
return false;
|
||||
}
|
||||
data->bundleInstallerCallback = installerCallback;
|
||||
Request request = {
|
||||
.msgId = BMS_INSTALL_MSG,
|
||||
.len = 0,
|
||||
.data = nullptr,
|
||||
.len = sizeof(Bmsbuff),
|
||||
.data = data,
|
||||
.msgValue = 0,
|
||||
};
|
||||
|
||||
@@ -103,24 +101,23 @@ bool BundleMsClient::Uninstall (const char *bundleName, const InstallParam *inst
|
||||
if (bundleName == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (g_bmsbuff == nullptr) {
|
||||
g_bmsbuff = reinterpret_cast<Bmsbuff *>(OhosMalloc(MEM_TYPE_APPFMK_LSRAM, sizeof(Bmsbuff)));
|
||||
}
|
||||
if (memset_s(g_bmsbuff->bundleParameter, MAX_PATH_LEN, 0, MAX_PATH_LEN) != 0) {
|
||||
return false;
|
||||
}
|
||||
int len = strlen(bundleName);
|
||||
if (len >= MAX_PATH_LEN) {
|
||||
return false;
|
||||
}
|
||||
if (memcpy_s(g_bmsbuff->bundleParameter, MAX_PATH_LEN, bundleName, len + 1) != 0) {
|
||||
Bmsbuff *data = static_cast<Bmsbuff *>(AdapterMalloc(sizeof(Bmsbuff)));
|
||||
if (data == nullptr) {
|
||||
return false;
|
||||
}
|
||||
g_bmsbuff->bundleInstallerCallback = installerCallback;
|
||||
if (memcpy_s(data->bundleParameter, MAX_PATH_LEN, bundleName, len + 1) != 0) {
|
||||
AdapterFree(data);
|
||||
return false;
|
||||
}
|
||||
data->bundleInstallerCallback = installerCallback;
|
||||
Request request = {
|
||||
.msgId = BMS_UNINSTALL_MSG,
|
||||
.len = 0,
|
||||
.data = nullptr,
|
||||
.len = sizeof(Bmsbuff),
|
||||
.data = data,
|
||||
.msgValue = 0,
|
||||
};
|
||||
int32_t ret = SAMGR_SendRequest(service->GetIdentity(), &request, nullptr);
|
||||
|
||||
@@ -48,12 +48,16 @@ uint8_t BundleInfoCreator::SaveBundleInfo(const BundleProfile &bundleProfile, Bu
|
||||
size_t index = std::string(info->codePath).find_last_of(PATH_SEPARATOR);
|
||||
if (index == std::string::npos) {
|
||||
HILOG_ERROR(HILOG_MODULE_APP, "codePath is invalid!");
|
||||
BundleInfoUtils::FreeBundleInfo(*bundleInfo);
|
||||
*bundleInfo = nullptr;
|
||||
return ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR;
|
||||
}
|
||||
installDirPath = std::string(info->codePath).substr(0, index);
|
||||
index = std::string(info->dataPath).find_last_of(PATH_SEPARATOR);
|
||||
if (index == std::string::npos) {
|
||||
HILOG_ERROR(HILOG_MODULE_APP, "dataPath is invalid!");
|
||||
BundleInfoUtils::FreeBundleInfo(*bundleInfo);
|
||||
*bundleInfo = nullptr;
|
||||
return ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR;
|
||||
}
|
||||
dataDirPath = std::string(info->dataPath).substr(0, index);
|
||||
|
||||
@@ -86,12 +86,20 @@ BOOL BundleMgrService::ServiceMessageHandle(Service *service, Request *request)
|
||||
if (request == nullptr) {
|
||||
return FALSE;
|
||||
}
|
||||
if (request->msgId == BMS_INSTALL_MSG && g_bmsbuff != nullptr) {
|
||||
OHOS::GtManagerService::GetInstance().Install(g_bmsbuff->bundleParameter, nullptr,
|
||||
g_bmsbuff->bundleInstallerCallback);
|
||||
} else if (request->msgId == BMS_UNINSTALL_MSG && g_bmsbuff != nullptr) {
|
||||
OHOS::GtManagerService::GetInstance().Uninstall(g_bmsbuff->bundleParameter, nullptr,
|
||||
g_bmsbuff->bundleInstallerCallback);
|
||||
if (request->msgId == BMS_INSTALL_MSG) {
|
||||
Bmsbuff *data = static_cast<Bmsbuff *>(request->data);
|
||||
OHOS::GtManagerService::GetInstance().Install(data->bundleParameter, nullptr,
|
||||
data->bundleInstallerCallback);
|
||||
AdapterFree(request->data);
|
||||
request->data = nullptr;
|
||||
request->len = 0;
|
||||
} else if (request->msgId == BMS_UNINSTALL_MSG) {
|
||||
Bmsbuff *data = static_cast<Bmsbuff *>(request->data);
|
||||
OHOS::GtManagerService::GetInstance().Uninstall(data->bundleParameter, nullptr,
|
||||
data->bundleInstallerCallback);
|
||||
AdapterFree(request->data);
|
||||
request->data = nullptr;
|
||||
request->len = 0;
|
||||
} else if (request->msgId == BMS_SCAN_PACKAGE_MSG) {
|
||||
OHOS::GtManagerService::GetInstance().ScanPackages();
|
||||
} else if (request->msgId == BMS_REGISTER_CALLBACK_MSG && g_bmsbuff != nullptr) {
|
||||
|
||||
@@ -350,8 +350,8 @@ bool GtManagerService::MatchSkills(const Want *want, Skill *const skills[])
|
||||
}
|
||||
bool GtManagerService::isMatchActions(const char *actions, char *const skillActions[])
|
||||
{
|
||||
if (actions == nullptr && skillActions == nullptr) {
|
||||
return true;
|
||||
if (actions == nullptr || skillActions == nullptr) {
|
||||
return false;
|
||||
}
|
||||
for (int32_t i = 0; i < MAX_SKILL_ITEM; i++) {
|
||||
if (skillActions[i] == nullptr) {
|
||||
@@ -953,6 +953,9 @@ void GtManagerService::TransformJsToBcWhenRestart(const char *codePath, const ch
|
||||
}
|
||||
|
||||
cJSON *oldJsEngineVerObj = cJSON_GetObjectItem(installRecordJson, JSON_SUB_KEY_JSENGINE_VERSION);
|
||||
if (oldJsEngineVerObj == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (cJSON_IsString(oldJsEngineVerObj) && strcmp(oldJsEngineVerObj->valuestring, jsEngineVer_) == 0) {
|
||||
cJSON_Delete(jsEngineVerObj);
|
||||
cJSON *transformResultObj = cJSON_GetObjectItem(installRecordJson, JSON_SUB_KEY_TRANSFORM_RESULT);
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
|
||||
#include "gt_bundle_parser.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ability_info_utils.h"
|
||||
#include "adapter.h"
|
||||
|
||||
Reference in New Issue
Block a user