IssueNo:#I4HTFS

Description:bms adaptation
Sig:appexecfwk
Feature or Bugfix:Feature
Binary Source:No

Signed-off-by: wangdengjia <wangdengjia@huawei.com>
Change-Id: I1f65f72ef580654980cb74f3c88dacf114a382ae
Signed-off-by: wangdengjia <wangdengjia@huawei.com>
This commit is contained in:
wangdengjia
2021-11-11 11:17:59 +08:00
parent fcc553b6b7
commit 97e9d85282
7 changed files with 53 additions and 29 deletions
+2 -2
View File
@@ -46,8 +46,6 @@ if (ohos_kernel_type == "liteos_m") {
"${appexecfwk_lite_path}/utils/bundle_lite",
"${appexecfwk_lite_path}/frameworks/bundle_lite/include",
"//base/startup/syspara_lite/interfaces/kits/",
"//third_party/jerryscript/jerry-core/api",
"//third_party/jerryscript/jerry-core/include",
"${aafwk_lite_path}/interfaces/kits/ability_lite/slite",
"${aafwk_lite_path}/services/abilitymgr_lite/include",
"${aafwk_lite_path}/interfaces/innerkits/abilitymgr_lite",
@@ -57,6 +55,8 @@ if (ohos_kernel_type == "liteos_m") {
"//base/global/resmgr_lite/interfaces/innerkits/include",
"//foundation/distributedschedule/samgr_lite/interfaces/kits/registry",
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
"//third_party/jerryscript/jerry-core/api",
"//third_party/jerryscript/jerry-core/include",
"//third_party/cJSON",
"//third_party/zlib",
"//third_party/zlib/contrib/minizip",
+10 -10
View File
@@ -147,22 +147,22 @@ const uint8_t MAX_VERSION_NAME_LEN = 127;
const uint16_t MAX_LABLE_LEN = 255;
#else
const char DEFAULT_DEVICE_TYPE[] = "fitnessWatch";
const char INSTALL_PATH[] = "user/ace/run";
const char DATA_PATH[] = "user/ace/data";
const char SYSTEM_BUNDLE_PATH[] = "system/ace/sys";
const char THIRD_SYSTEM_BUNDLE_PATH[] = "system/ace/vendor";
const char UNINSTALL_THIRD_SYSTEM_BUNDLE_JSON[] = "user/ace/etc/uninstalled_delbundle.json";
const char THIRD_SYSTEM_BUNDLE_JSON[] = "user/ace/etc/third_system_bundle.json";
const char JSON_PATH[] = "user/ace/etc/bundles/";
const char JSON_PATH_NO_SLASH_END[] = "user/ace/etc/bundles";
const char INSTALL_PATH[] = "/data/user/ace/run";
const char DATA_PATH[] = "/data/user/ace/data";
const char SYSTEM_BUNDLE_PATH[] = "/data/system/ace/sys";
const char THIRD_SYSTEM_BUNDLE_PATH[] = "/data/system/ace/vendor";
const char UNINSTALL_THIRD_SYSTEM_BUNDLE_JSON[] = "/data/user/ace/etc/uninstalled_delbundle.json";
const char THIRD_SYSTEM_BUNDLE_JSON[] = "/data/user/ace/etc/third_system_bundle.json";
const char JSON_PATH[] = "/data/user/ace/etc/bundles/";
const char JSON_PATH_NO_SLASH_END[] = "/data/user/ace/etc/bundles";
// store bundle permissions for IAM
const char PERMISSIONS_PATH[] = "user/ace/etc/permissions";
const char PERMISSIONS_PATH[] = "/data/user/ace/etc/permissions";
const char ASSET_JS_PATH[] = "/assets/js/default";
const char ICON_NAME[] = "/icon.bin";
const char SMALL_ICON_NAME[] = "/icon_small.bin";
const char DEFAULT_ICON_SETTING[] = "$media:icon";
const char INSTALL_FILE_SUFFIX[] = ".bin";
const char TMP_RESOURCE_DIR[] = "user/ace/run/tmpResource";
const char TMP_RESOURCE_DIR[] = "/data/user/ace/run/tmpResource";
const char RESOURCES_RAW_FILE[] = "/resources/rawfile";
const char RAW_FILE[] = "/rawfile";
const uint16_t READ_SIZE = 1024 * 4;
@@ -121,10 +121,6 @@ void EnableServiceWdg(void);
void DisableServiceWdg(void);
void SetCurrentBundle(const char *name);
const char *GetCurrentBundle();
#ifdef __LITEOS_M__
void InstallCallbackFunc(const uint8_t resultCode, const void *resultMessage);
#endif
}
#endif // OHOS_GT_BUNDLE_MANAGER_SERVICE_H
@@ -98,7 +98,11 @@ BOOL BundleMgrService::ServiceMessageHandle(Service *service, Request *request)
TaskConfig BundleMgrService::GetServiceTaskConfig(Service *service)
{
#ifdef __LITEOS_M__
TaskConfig config = {LEVEL_HIGH, PRI_ABOVE_NORMAL, STACK_SIZE, QUEUE_SIZE, SINGLE_TASK};
#else
TaskConfig config = {LEVEL_HIGH, PRI_BELOW_NORMAL, STACK_SIZE, QUEUE_SIZE, SINGLE_TASK};
#endif
return config;
}
} // namespace OHOS
@@ -252,7 +252,9 @@ uint8_t GtBundleExtractor::ExtractBundleParam(const char *path, int32_t &fpStart
if (errorCode != ERR_OK) {
return errorCode;
}
#ifdef __LITEOS_M__
close(fp);
#endif
if (strlen(*bundleName) > MAX_BUNDLE_NAME_LEN || strlen(*bundleName) < MIN_BUNDLE_NAME_LEN) {
return ERR_APPEXECFWK_INSTALL_FAILED_PARSE_INVALID_BUNDLENAME_LENGTH;
}
@@ -238,6 +238,14 @@ uint8_t GtBundleInstaller::ProcessBundleInstall(const char *path, const char *ra
uint8_t errorCode = PreCheckBundle(path, fp, signatureInfo, fileSize, bundleStyle);
CHECK_PRO_RESULT(errorCode, fp, permissions, bundleInfo, signatureInfo);
(void) GtManagerService::GetInstance().ReportInstallCallback(OPERATION_DOING, 0, BMS_SECOND_FINISHED_PROCESS, installerCallback);
#ifdef __LITEOS_M__
fp = open(path, O_RDONLY, S_IREAD);
if (fp < 0) {
HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] process bundle install fp open fail");
errorCode = ERR_APPEXECFWK_INSTALL_FAILED_FILE_NOT_EXISTS;
}
CHECK_PRO_RESULT(errorCode, fp, permissions, bundleInfo, signatureInfo);
#endif
// parse HarmoyProfile.json, get permissions and bundleInfo
errorCode = GtBundleParser::ParseHapProfile(fp, fileSize, permissions, bundleRes, &bundleInfo);
CHECK_PRO_RESULT(errorCode, fp, permissions, bundleInfo, signatureInfo);
@@ -63,15 +63,18 @@ GtManagerService::~GtManagerService()
bool GtManagerService::Install(const char *hapPath, const InstallParam *installParam,
InstallerCallback installerCallback)
{
HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] install start");
if (installer_ == nullptr) {
installer_ = new GtBundleInstaller();
}
if (hapPath == nullptr) {
return false;
}
#ifndef __LITEOS_M__
if (installerCallback == nullptr) {
return false;
}
#endif
char *path = reinterpret_cast<char *>(AdapterMalloc(strlen(hapPath) + 1));
if (path == nullptr) {
return false;
@@ -81,6 +84,7 @@ bool GtManagerService::Install(const char *hapPath, const InstallParam *installP
return false;
}
#ifndef __LITEOS_M__
// delete resource temp dir first
(void) BundleUtil::RemoveDir(TMP_RESOURCE_DIR);
// create new bundleInstallMsg
@@ -109,13 +113,9 @@ bool GtManagerService::Install(const char *hapPath, const InstallParam *installP
SetCurrentBundle(bundleInstallMsg_->bundleName);
(void) ReportInstallCallback(OPERATION_DOING, 0, BMS_INSTALLATION_START, installerCallback);
#ifndef __LITEOS_M__
DisableServiceWdg();
ret = installer_->Install(path, installerCallback);
EnableServiceWdg();
#else
ret = installer_->Install(path, installerCallback);
#endif
if (ret == 0) {
(void) ReportInstallCallback(ret, BUNDLE_INSTALL_OK, BMS_INSTALLATION_COMPLETED, installerCallback);
} else {
@@ -123,6 +123,10 @@ bool GtManagerService::Install(const char *hapPath, const InstallParam *installP
}
SetCurrentBundle(nullptr);
ClearSystemBundleInstallMsg();
#else
uint8_t ret = installer_->Install(path, installerCallback);
HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] install ret is %d", ret);
#endif
(void) BundleUtil::RemoveDir(TMP_RESOURCE_DIR);
AdapterFree(path);
return true;
@@ -138,9 +142,11 @@ bool GtManagerService::Uninstall(const char *bundleName, const InstallParam *ins
HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] Parsed bundleName to be uninstalled is null");
return false;
}
#ifndef __LITEOS_M__
if (installerCallback == nullptr) {
return false;
}
#endif
char *innerBundleName = reinterpret_cast<char *>(AdapterMalloc(strlen(bundleName) + 1));
if (innerBundleName == nullptr) {
return false;
@@ -154,6 +160,7 @@ bool GtManagerService::Uninstall(const char *bundleName, const InstallParam *ins
(void) ReportUninstallCallback(OPERATION_DOING, BUNDLE_UNINSTALL_DOING, innerBundleName,
BMS_UNINSTALLATION_START, installerCallback);
uint8_t ret = installer_->Uninstall(innerBundleName);
HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] uninstall ret is %d", ret);
if (ret == 0) {
(void) ReportUninstallCallback(ret, BUNDLE_UNINSTALL_OK, innerBundleName,
BMS_INSTALLATION_COMPLETED, installerCallback);
@@ -251,21 +258,25 @@ uint8_t GtManagerService::GetBundleInfos(const int flags, BundleInfo **bundleInf
bool GtManagerService::RegisterInstallerCallback(InstallerCallback installerCallback)
{
#ifndef __LITEOS_M__
if (installerCallback == nullptr) {
return false;
}
#endif
InstallPreBundle(systemPathList_, installerCallback);
return true;
}
void GtManagerService::InstallPreBundle(List<ToBeInstalledApp *> systemPathList, InstallerCallback installerCallback)
{
#ifndef __LITEOS_M__
if (!BundleUtil::IsDir(JSON_PATH_NO_SLASH_END)) {
BundleUtil::MkDirs(JSON_PATH_NO_SLASH_END);
InstallAllSystemBundle(installerCallback);
RemoveSystemAppPathList(&systemPathList);
return;
}
#endif
for (auto node = systemPathList.Begin(); node != systemPathList.End(); node = node->next_) {
ToBeInstalledApp *toBeInstalledApp = node->value_;
if (toBeInstalledApp->isUpdated) {
@@ -347,6 +358,15 @@ void GtManagerService::ScanPackages()
}
#endif
#ifdef __LITEOS_M__
if (!BundleUtil::MkDirs(INSTALL_PATH) || !BundleUtil::MkDirs(DATA_PATH) ||
!BundleUtil::MkDirs(JSON_PATH)) {
HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] ScanPackages mkdirs failed!");
}
if (!BundleUtil::IsDir(SYSTEM_BUNDLE_PATH)) {
HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] system bundle path is not exist, unable to pre install!");
}
#endif
// get third system bundle uninstall record
cJSON *uninstallRecord = BundleUtil::GetJsonStream(UNINSTALL_THIRD_SYSTEM_BUNDLE_JSON);
if (uninstallRecord == nullptr) {
@@ -363,7 +383,8 @@ void GtManagerService::ScanPackages()
ScanThirdApp(INSTALL_PATH, &systemPathList_);
#ifdef __LITEOS_M__
RegisterInstallerCallback(InstallCallbackFunc);
InstallerCallback installerCallback = nullptr;
RegisterInstallerCallback(installerCallback);
#endif
}
@@ -1044,11 +1065,4 @@ const char *GetCurrentBundle()
MutexRelease(&g_currentBundleMutex);
return bundleName;
}
#ifdef __LITEOS_M__
void InstallCallbackFunc(const uint8_t resultCode, const void *resultMessage)
{
return;
}
#endif
}