From cad0299a450a6d35fc2c6558cb38d4645ce8e869 Mon Sep 17 00:00:00 2001 From: wangdengjia Date: Mon, 1 Nov 2021 20:05:44 +0800 Subject: [PATCH] IssueNo:#I4G633 Description:bms adaptation Sig:appexecfwk Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: wangdengjia Change-Id: Ib9c5a862edff35dcfde419ff515d4362bd2ddaf5 --- frameworks/bundle_lite/BUILD.gn | 128 ++++++++---- .../src/slite/bundlems_slite_client.cpp | 6 +- interfaces/kits/bundle_lite/bundle_manager.h | 3 +- services/bundlemgr_lite/BUILD.gn | 190 ++++++++++++------ .../bundlemgr_lite/include/bundle_common.h | 4 + services/bundlemgr_lite/include/bundle_util.h | 5 + .../bundlemgr_lite/include/bundlems_log.h | 2 +- .../include/gt_bundle_installer.h | 1 - .../include/gt_bundle_manager_service.h | 6 + .../bundlemgr_lite/src/bundle_mgr_service.cpp | 6 +- services/bundlemgr_lite/src/bundle_util.cpp | 6 +- .../src/gt_bundle_extractor.cpp | 6 +- .../src/gt_bundle_installer.cpp | 15 +- .../src/gt_bundle_manager_service.cpp | 12 ++ .../bundlemgr_lite/src/gt_bundle_parser.cpp | 10 +- utils/bundle_lite/adapter.h | 4 +- 16 files changed, 278 insertions(+), 126 deletions(-) diff --git a/frameworks/bundle_lite/BUILD.gn b/frameworks/bundle_lite/BUILD.gn index a3892f5..090f17b 100644 --- a/frameworks/bundle_lite/BUILD.gn +++ b/frameworks/bundle_lite/BUILD.gn @@ -26,28 +26,94 @@ lite_component("appexecfwk_kits_lite") { } lite_library("bundle") { - target_type = "shared_library" - sources = [ - "src/ability_info.cpp", - "src/ability_info_utils.cpp", - "src/bundle_callback.cpp", - "src/bundle_callback_utils.cpp", - "src/bundle_info.cpp", - "src/bundle_info_utils.cpp", - "src/bundle_manager.cpp", - "src/bundle_self_callback.cpp", - "src/convert_utils.cpp", - "src/element_name.cpp", - "src/module_info.cpp", - "src/module_info_utils.cpp", - "src/token_generate.cpp", - ] + if (ohos_kernel_type == "liteos_m") { + target_type = "static_library" - deps = [ - "${aafwk_lite_path}/frameworks/want_lite:want", - "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", - "//base/security/permission/services/permission_lite/pms_client:pms_client", - ] + sources = [ + "src/ability_info.cpp", + "src/ability_info_utils.cpp", + "src/bundle_info.cpp", + "src/bundle_info_utils.cpp", + "src/element_name.cpp", + "src/module_info.cpp", + "src/module_info_utils.cpp", + "src/slite/bundle_manager.cpp", + "src/slite/bundle_manager_inner.cpp", + "src/slite/bundlems_slite_client.cpp", + ] + + public_deps = [ + "${aafwk_lite_path}/frameworks/want_lite:want", + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static", + ] + + include_dirs = [ + "${appexecfwk_lite_path}/services/bundlemgr_lite/include", + "${appexecfwk_lite_path}/interfaces/innerkits/bundlemgr_lite/slite", + "${appexecfwk_lite_path}/interfaces/innerkits/bundlemgr_lite", + "${appexecfwk_lite_path}/interfaces/kits/bundle_lite/slite", + "${appexecfwk_lite_path}/interfaces/kits/bundle_lite", + "${appexecfwk_lite_path}/utils/bundle_lite", + "${appexecfwk_lite_path}/frameworks/bundle_lite/include", + "//base/security/permission/interfaces/kits/permission_lite", + "//base/security/permission/services/permission_lite/pms/include", + "${aafwk_lite_path}/frameworks/want_lite/include", + "${aafwk_lite_path}/interfaces/kits/want_lite", + "${aafwk_lite_path}/interfaces/kits/ability_lite/slite", + "${aafwk_lite_path}/interfaces/innerkits/abilitymgr_lite", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", + "//third_party/bounds_checking_function/include", + "//utils/native/lite/include", + "//utils/native/lite/memory/include", + "//third_party/cJSON", + ] + } else { + target_type = "shared_library" + + sources = [ + "src/ability_info.cpp", + "src/ability_info_utils.cpp", + "src/bundle_callback.cpp", + "src/bundle_callback_utils.cpp", + "src/bundle_info.cpp", + "src/bundle_info_utils.cpp", + "src/bundle_manager.cpp", + "src/bundle_self_callback.cpp", + "src/convert_utils.cpp", + "src/element_name.cpp", + "src/module_info.cpp", + "src/module_info_utils.cpp", + "src/token_generate.cpp", + ] + + deps = [ + "${aafwk_lite_path}/frameworks/want_lite:want", + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + "//base/security/permission/services/permission_lite/pms_client:pms_client", + ] + + include_dirs = [ + "include", + "//base/security/permission/interfaces/kits/permission_lite", + "//base/security/permission/services/permission_lite/pms/include", + "${aafwk_lite_path}/frameworks/want_lite/include", + "${aafwk_lite_path}/interfaces/kits/want_lite", + "${aafwk_lite_path}/interfaces/innerkits/abilitymgr_lite", + "${appexecfwk_lite_path}/interfaces/innerkits/bundlemgr_lite", + "${appexecfwk_lite_path}/interfaces/kits/bundle_lite", + "${appexecfwk_lite_path}/utils/bundle_lite", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", + "//third_party/bounds_checking_function/include", + "//utils/native/lite/include", + "//third_party/cJSON", + ] + + defines = [ "OHOS_APPEXECFWK_BMS_BUNDLEMANAGER" ] + } cflags = [ "-fPIC", @@ -55,26 +121,6 @@ lite_library("bundle") { "-Wno-format", ] cflags_cc = cflags - - include_dirs = [ - "include", - "//base/security/permission/interfaces/kits/permission_lite", - "//base/security/permission/services/permission_lite/pms/include", - "${aafwk_lite_path}/frameworks/want_lite/include", - "${aafwk_lite_path}/interfaces/kits/want_lite", - "${aafwk_lite_path}/interfaces/innerkits/abilitymgr_lite", - "${appexecfwk_lite_path}/interfaces/innerkits/bundlemgr_lite", - "${appexecfwk_lite_path}/interfaces/kits/bundle_lite", - "${appexecfwk_lite_path}/utils/bundle_lite", - "//foundation/communication/ipc_lite/interfaces/kits", - "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", - "//third_party/bounds_checking_function/include", - "//utils/native/lite/include", - "//third_party/cJSON", - ] - - defines = [ "OHOS_APPEXECFWK_BMS_BUNDLEMANAGER" ] } ndk_lib("bundle_notes") { diff --git a/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp b/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp index 9460733..d3e7076 100755 --- a/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp +++ b/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp @@ -83,8 +83,8 @@ bool BundleMsClient::Install(const char *hapPath, const InstallParam *installPar g_bmsbuff->bundleInstallerCallback = installerCallback; Request request = { .msgId = BMS_INSTALL_MSG, - .data = nullptr, .len = 0, + .data = nullptr, .msgValue = 0, }; @@ -118,8 +118,8 @@ bool BundleMsClient::Uninstall (const char *bundleName, const InstallParam *inst g_bmsbuff->bundleInstallerCallback = installerCallback; Request request = { .msgId = BMS_UNINSTALL_MSG, - .data = nullptr, .len = 0, + .data = nullptr, .msgValue = 0, }; int32_t ret = SAMGR_SendRequest(service->GetIdentity(), &request, nullptr); @@ -141,8 +141,8 @@ bool BundleMsClient::RegisterInstallerCallback (InstallerCallback installerCallb g_bmsbuff->bundleInstallerCallback = installerCallback; Request request = { .msgId = BMS_REGISTER_CALLBACK_MSG, - .data = nullptr, .len = 0, + .data = nullptr, .msgValue = 0, }; int32_t ret = SAMGR_SendRequest(service->GetIdentity(), &request, nullptr); diff --git a/interfaces/kits/bundle_lite/bundle_manager.h b/interfaces/kits/bundle_lite/bundle_manager.h index 3d1b8ae..3548415 100755 --- a/interfaces/kits/bundle_lite/bundle_manager.h +++ b/interfaces/kits/bundle_lite/bundle_manager.h @@ -216,6 +216,7 @@ uint8_t GetBundleInfosByMetaData(const char *metaDataKey, BundleInfo **bundleInf */ uint8_t GetBundleNameForUid(int32_t uid, char **bundleName); +#ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER /** * @brief Check if the specify syscap name is supported by the system. * @@ -246,7 +247,7 @@ SystemCapability *GetSystemAvailableCapabilities(); * @version 4 */ void FreeSystemAvailableCapabilitiesInfo(SystemCapability *sysCap); - +#endif /** * @brief Get bundle size * diff --git a/services/bundlemgr_lite/BUILD.gn b/services/bundlemgr_lite/BUILD.gn index 96be3f2..42f73ed 100644 --- a/services/bundlemgr_lite/BUILD.gn +++ b/services/bundlemgr_lite/BUILD.gn @@ -17,68 +17,132 @@ config("bundle_config") { cflags_cc = [ "-std=c++14" ] } -shared_library("bundlems") { - configs -= [ "//build/lite/config:language_cpp" ] - configs += [ ":bundle_config" ] +if (ohos_kernel_type == "liteos_m") { + static_library("bundlems") { + sources = [ + "src/bundle_map.cpp", + "src/bundle_mgr_service.cpp", + "src/bundle_mgr_slite_feature.cpp", + "src/bundle_util.cpp", + "src/gt_bundle_extractor.cpp", + "src/gt_bundle_installer.cpp", + "src/gt_bundle_manager_service.cpp", + "src/gt_bundle_parser.cpp", + "src/gt_extractor_util.cpp", + ] + deps = [ + "${appexecfwk_lite_path}/frameworks/bundle_lite:bundle", + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static", + "//foundation/ace/ace_engine_lite/frameworks:ace_lite", + "//foundation/distributedschedule/samgr_lite/samgr:samgr", + ] - cflags = [ - "-Wall", - "-Wno-format", - "-Wno-format-extra-args", - ] - cflags_cc = cflags + include_dirs = [ + "${appexecfwk_lite_path}/services/bundlemgr_lite/include", + "${appexecfwk_lite_path}/interfaces/innerkits/bundlemgr_lite/slite", + "${appexecfwk_lite_path}/interfaces/innerkits/bundlemgr_lite", + "${appexecfwk_lite_path}/interfaces/kits/bundle_lite/slite", + "${appexecfwk_lite_path}/interfaces/kits/bundle_lite", + "${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", + "${aafwk_lite_path}/interfaces/kits/ability_lite", + "${aafwk_lite_path}/interfaces/kits/want_lite", + "${aafwk_lite_path}/frameworks/want_lite/include", + "//base/global/resmgr_lite/interfaces/innerkits/include", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//third_party/cJSON", + "//third_party/zlib", + "//third_party/zlib/contrib/minizip", + "//base/security/permission/interfaces/kits/permission_lite", + "//base/security/permission/services/permission_lite/pms/include", + "//base/security/appverify/interfaces/innerkits/appverify_lite/include", + "//third_party/bounds_checking_function/include", + "//utils/native/lite/include", + "//utils/native/lite/memory/include", + "include", + ] + } + lite_component("appexecfwk_services_lite") { + features = [ ":bundlems" ] + } +} else { + shared_library("bundlems") { + configs -= [ "//build/lite/config:language_cpp" ] + configs += [ ":bundle_config" ] - sources = [ - "src/bundle_daemon_client.cpp", - "src/bundle_extractor.cpp", - "src/bundle_info_creator.cpp", - "src/bundle_inner_feature.cpp", - "src/bundle_installer.cpp", - "src/bundle_manager_service.cpp", - "src/bundle_map.cpp", - "src/bundle_ms_feature.cpp", - "src/bundle_ms_host.cpp", - "src/bundle_parser.cpp", - "src/bundle_res_transform.cpp", - "src/bundle_util.cpp", - "src/extractor_util.cpp", - "src/hap_sign_verify.cpp", - "src/zip_file.cpp", - ] - include_dirs = [ - "//base/global/resmgr_lite/interfaces/innerkits/include", - "${aafwk_lite_path}/services/abilitymgr_lite/include", - "${aafwk_lite_path}/interfaces/innerkits/abilitymgr_lite", - "${aafwk_lite_path}/interfaces/kits/ability_lite", - "${aafwk_lite_path}/interfaces/kits/want_lite", - "${aafwk_lite_path}/frameworks/want_lite/include", - "${appexecfwk_lite_path}/interfaces/innerkits/bundlemgr_lite", - "${appexecfwk_lite_path}/frameworks/bundle_lite/include", - "${appexecfwk_lite_path}/interfaces/kits/bundle_lite", - "${appexecfwk_lite_path}/utils/bundle_lite", - "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", - "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - "//third_party/cJSON", - "//third_party/zlib", - "//third_party/zlib/contrib/minizip", - "//base/security/permission/interfaces/kits/permission_lite", - "//base/security/permission/services/permission_lite/pms/include", - "//base/security/appverify/interfaces/innerkits/appverify_lite/include", - "//third_party/bounds_checking_function/include", - "//utils/native/lite/include", - "//utils/native/lite/memory", - "include", - ] + cflags = [ + "-Wall", + "-Wno-format", + "-Wno-format-extra-args", + ] + cflags_cc = cflags - public_deps = [ - "${appexecfwk_lite_path}/frameworks/bundle_lite:bundle", - "//base/global/resmgr_lite/frameworks/resmgr_lite:global_resmgr", - "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", - "//base/security/appverify/interfaces/innerkits/appverify_lite:verify", - "//build/lite/config/component/cJSON:cjson_shared", - "//build/lite/config/component/zlib:zlib_shared", - "//foundation/distributedschedule/samgr_lite/samgr:samgr", - ] + sources = [ + "src/bundle_daemon_client.cpp", + "src/bundle_extractor.cpp", + "src/bundle_info_creator.cpp", + "src/bundle_inner_feature.cpp", + "src/bundle_installer.cpp", + "src/bundle_manager_service.cpp", + "src/bundle_map.cpp", + "src/bundle_ms_feature.cpp", + "src/bundle_ms_host.cpp", + "src/bundle_parser.cpp", + "src/bundle_res_transform.cpp", + "src/bundle_util.cpp", + "src/extractor_util.cpp", + "src/hap_sign_verify.cpp", + "src/zip_file.cpp", + ] + include_dirs = [ + "//base/global/resmgr_lite/interfaces/innerkits/include", + "${aafwk_lite_path}/services/abilitymgr_lite/include", + "${aafwk_lite_path}/interfaces/innerkits/abilitymgr_lite", + "${aafwk_lite_path}/interfaces/kits/ability_lite", + "${aafwk_lite_path}/interfaces/kits/want_lite", + "${aafwk_lite_path}/frameworks/want_lite/include", + "${appexecfwk_lite_path}/interfaces/innerkits/bundlemgr_lite", + "${appexecfwk_lite_path}/frameworks/bundle_lite/include", + "${appexecfwk_lite_path}/interfaces/kits/bundle_lite", + "${appexecfwk_lite_path}/utils/bundle_lite", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//third_party/cJSON", + "//third_party/zlib", + "//third_party/zlib/contrib/minizip", + "//base/security/permission/interfaces/kits/permission_lite", + "//base/security/permission/services/permission_lite/pms/include", + "//base/security/appverify/interfaces/innerkits/appverify_lite/include", + "//third_party/bounds_checking_function/include", + "//utils/native/lite/include", + "//utils/native/lite/memory", + "include", + ] + + public_deps = [ + "${appexecfwk_lite_path}/frameworks/bundle_lite:bundle", + "//base/global/resmgr_lite/frameworks/resmgr_lite:global_resmgr", + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + "//base/security/appverify/interfaces/innerkits/appverify_lite:verify", + "//build/lite/config/component/cJSON:cjson_shared", + "//build/lite/config/component/zlib:zlib_shared", + "//foundation/distributedschedule/samgr_lite/samgr:samgr", + ] + } + lite_component("appexecfwk_services_lite") { + features = [ + ":bundlems", + "tools:bm", + "bundle_daemon:bundle_daemon", + ] + } } generate_notice_file("appexecfwk_services_lite_notice_file") { @@ -89,11 +153,3 @@ generate_notice_file("appexecfwk_services_lite_notice_file") { "//third_party/bounds_checking_function", ] } - -lite_component("appexecfwk_services_lite") { - features = [ - ":bundlems", - "tools:bm", - "bundle_daemon:bundle_daemon", - ] -} diff --git a/services/bundlemgr_lite/include/bundle_common.h b/services/bundlemgr_lite/include/bundle_common.h index 1b0e146..918940f 100755 --- a/services/bundlemgr_lite/include/bundle_common.h +++ b/services/bundlemgr_lite/include/bundle_common.h @@ -195,7 +195,11 @@ const char JSON_SUB_KEY_GID[] = "gid"; #endif struct ProfileVersion { +#ifdef __LITEOS_M__ + int32_t versionCode; +#else uint32_t versionCode; +#endif char *versionName; }; diff --git a/services/bundlemgr_lite/include/bundle_util.h b/services/bundlemgr_lite/include/bundle_util.h index 4a2e11c..b73bf2a 100755 --- a/services/bundlemgr_lite/include/bundle_util.h +++ b/services/bundlemgr_lite/include/bundle_util.h @@ -26,6 +26,11 @@ #endif #include "cJSON.h" +#ifdef __LITEOS_M__ +#define S_IREAD S_IRUSR +#define S_IWRITE S_IWUSR +#endif + namespace OHOS { class BundleUtil { public: diff --git a/services/bundlemgr_lite/include/bundlems_log.h b/services/bundlemgr_lite/include/bundlems_log.h index 933673c..d744dda 100755 --- a/services/bundlemgr_lite/include/bundlems_log.h +++ b/services/bundlemgr_lite/include/bundlems_log.h @@ -24,7 +24,7 @@ namespace OHOS { #undef LOG_DOMAIN #define LOG_DOMAIN 0xD001300 -#ifdef APP_PLATFORM_WATCHGT +#ifdef __LITEOS_M__ #ifndef HILOG_DEBUG #define HILOG_DEBUG(mod, format, ...) #endif diff --git a/services/bundlemgr_lite/include/gt_bundle_installer.h b/services/bundlemgr_lite/include/gt_bundle_installer.h index ed558e5..9e3a750 100755 --- a/services/bundlemgr_lite/include/gt_bundle_installer.h +++ b/services/bundlemgr_lite/include/gt_bundle_installer.h @@ -19,7 +19,6 @@ #ifdef __cplusplus extern "C" { #endif -#include "generate-bytecode.h" #ifdef __cplusplus } #endif diff --git a/services/bundlemgr_lite/include/gt_bundle_manager_service.h b/services/bundlemgr_lite/include/gt_bundle_manager_service.h index 0791293..41f9447 100755 --- a/services/bundlemgr_lite/include/gt_bundle_manager_service.h +++ b/services/bundlemgr_lite/include/gt_bundle_manager_service.h @@ -95,8 +95,10 @@ private: bool isSystemApp, bool isUpdated, const char *appId); void RemoveSystemAppPathList(List *systemPathList); void ClearSystemBundleInstallMsg(); +#ifdef BC_TRANS_ENABLE void TransformJsToBcWhenRestart(const char *codePath, const char *bundleName); void TransformJsToBc(const char *codePath, const char *bundleJsonPath, cJSON *installRecordObj); +#endif bool IsSystemBundleInstalledPath(const char *appPath, const List *systemPathList); AppInfoList *APP_InitAllAppInfo(void); void APP_QueryAppInfo(const char *appDir, AppInfoList *list); @@ -119,6 +121,10 @@ 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 \ No newline at end of file diff --git a/services/bundlemgr_lite/src/bundle_mgr_service.cpp b/services/bundlemgr_lite/src/bundle_mgr_service.cpp index d58b112..e4a3d71 100755 --- a/services/bundlemgr_lite/src/bundle_mgr_service.cpp +++ b/services/bundlemgr_lite/src/bundle_mgr_service.cpp @@ -38,8 +38,12 @@ static void Init() { SamgrLite *sm = SAMGR_GetInstance(); CHECK_NULLPTR_RETURN(sm, "BundleManagerService", "get samgr error"); +#ifdef __LITEOS_M__ + sm->RegisterService(BundleMgrService::GetInstance()); +#else BOOL result = sm->RegisterService(BundleMgrService::GetInstance()); PRINTI("BundleManagerService", "bms starts %{public}s", result ? "successfully" : "unsuccessfully"); +#endif } SYSEX_SERVICE_INIT(Init); @@ -58,8 +62,8 @@ BOOL BundleMgrService::ServiceInitialize(Service *service, Identity identity) bundleManagerService->identity_ = identity; Request request = { .msgId = BMS_SCAN_PACKAGE_MSG, - .data = nullptr, .len = 0, + .data = nullptr, .msgValue = 0, }; (void) SAMGR_SendRequest(bundleManagerService->GetIdentity(), &request, nullptr); diff --git a/services/bundlemgr_lite/src/bundle_util.cpp b/services/bundlemgr_lite/src/bundle_util.cpp index 6fb9877..80c5049 100755 --- a/services/bundlemgr_lite/src/bundle_util.cpp +++ b/services/bundlemgr_lite/src/bundle_util.cpp @@ -43,7 +43,11 @@ namespace OHOS { const char DIGITSTR[] = "0123456789"; const uint8_t MAX_CHARACTER_VALUE = 26; const uint8_t NUM_OF_TYPE = 3; +#ifdef __LITEOS_M__ +const int32_t MAX_JSON_SIZE = 1024 * 64; +#else const uint32_t MAX_JSON_SIZE = 1024 * 64; +#endif /* * path should not include ".." or "./" or ".\0" @@ -573,7 +577,7 @@ void BundleUtil::CreateRandStr(char *str, uint32_t len) if (str == nullptr) { return; } -#ifndef APP_PLATFORM_WATCHGT +#ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER srand(time(NULL)); #else srand(LOS_TickCountGet()); diff --git a/services/bundlemgr_lite/src/gt_bundle_extractor.cpp b/services/bundlemgr_lite/src/gt_bundle_extractor.cpp index 1750d77..2e506be 100755 --- a/services/bundlemgr_lite/src/gt_bundle_extractor.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_extractor.cpp @@ -185,12 +185,14 @@ uint8_t GtBundleExtractor::ExtractInstallMsg(const char *path, char **bundleName if (!BundleUtil::CheckRealPath(path)) { return ERR_APPEXECFWK_INSTALL_FAILED_PARAM_ERROR; } - +#ifndef __LITEOS_M__ int32_t totalFileSize = APPVERI_GetUnsignedFileLength(path); if (totalFileSize == V_ERR) { return ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR; } - +#else + int32_t totalFileSize = 0; +#endif char *emptyJsPathComp[] = {const_cast(TMP_RESOURCE_DIR), const_cast(ASSET_JS_PATH)}; char *emptyJsPath = BundleUtil::Strscat(emptyJsPathComp, sizeof(emptyJsPathComp) / sizeof(char *)); if (emptyJsPath == nullptr) { diff --git a/services/bundlemgr_lite/src/gt_bundle_installer.cpp b/services/bundlemgr_lite/src/gt_bundle_installer.cpp index 05e5de3..5386839 100755 --- a/services/bundlemgr_lite/src/gt_bundle_installer.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_installer.cpp @@ -105,6 +105,7 @@ uint8_t GtBundleInstaller::PreCheckBundle(const char *path, int32_t &fp, Signatu uint8_t GtBundleInstaller::VerifySignature(const char *path, SignatureInfo &signatureInfo, uint32_t &fileSize, uint8_t bundleStyle) { +#ifndef __LITEOS_M__ VerifyResult verifyResult; // verify signature (void) APPVERI_SetDebugMode(true); @@ -145,6 +146,7 @@ uint8_t GtBundleInstaller::VerifySignature(const char *path, SignatureInfo &sign } } APPVERI_FreeVerifyRst(&verifyResult); +#endif return ERR_OK; } @@ -464,6 +466,7 @@ uint8_t GtBundleInstaller::HandleFileAndBackUpRecord(const InstallRecord &record return ERR_OK; } +#ifdef BC_TRANS_ENABLE uint8_t GtBundleInstaller::TransformJsToBc(const char *codePath, InstallRecord &record) { if (codePath == nullptr) { @@ -482,11 +485,10 @@ uint8_t GtBundleInstaller::TransformJsToBc(const char *codePath, InstallRecord & return ERR_APPEXECFWK_INSTALL_FAILED_TRANSFORM_BC_FILE_ERROR; } AdapterFree(jsPath); -#ifdef BC_TRANS_ENABLE record.transformResult = 0; -#endif return ERR_OK; } +#endif uint8_t GtBundleInstaller::UpdateBundleInfo(uint8_t bundleStyle, uint32_t labelId, uint32_t iconId, BundleInfo *bundleInfo, bool isUpdate) @@ -576,11 +578,11 @@ uint8_t GtBundleInstaller::Uninstall(const char *bundleName) if (sprintf_s(bundleJsonPath, PATH_LENGTH, "%s%s%s", JSON_PATH, bundleName, JSON_SUFFIX) < 0) { return ERR_APPEXECFWK_UNINSTALL_FAILED_INTERNAL_ERROR; } - +#ifndef __LITEOS_M__ if (DeletePermissions(const_cast(bundleName)) < 0) { return ERR_APPEXECFWK_UNINSTALL_FAILED_DELETE_PERMISSIONS_ERROR; } - +#endif bool res = CheckIsThirdSystemBundle(bundleName); if (!(BundleUtil::RemoveDir(bundleInfo->codePath) && BundleUtil::RemoveDir(bundleInfo->dataPath))) { GtManagerService::GetInstance().RemoveBundleInfo(bundleName); @@ -733,10 +735,12 @@ uint8_t GtBundleInstaller::StorePermissions(const char *bundleName, PermissionTr bool isUpdate) { if (permNum == 0) { +#ifndef __LITEOS_M__ if (isUpdate) { int32_t ret = DeletePermissions(bundleName); HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] delete permissions, result is %d", ret); } +#endif return ERR_OK; } @@ -747,11 +751,12 @@ uint8_t GtBundleInstaller::StorePermissions(const char *bundleName, PermissionTr if (!BundleUtil::IsDir(PERMISSIONS_PATH)) { BundleUtil::MkDirs(PERMISSIONS_PATH); } - +#ifndef __LITEOS_M__ if (SaveOrUpdatePermissions(const_cast(bundleName), permissions, permNum, static_cast(isUpdate)) != 0) { return ERR_APPEXECFWK_INSTALL_FAILED_STORE_PERMISSIONS_ERROR; } +#endif return ERR_OK; } diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index 1c80064..6d69773 100755 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -109,9 +109,13 @@ 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 { @@ -334,12 +338,14 @@ void GtManagerService::ClearSystemBundleInstallMsg() void GtManagerService::ScanPackages() { +#ifdef BC_TRANS_ENABLE JerryBmsPsRamMemInit(); bms_task_context_init(); jsEngineVer_ = get_jerry_version_no(); if (jsEngineVer_ == nullptr) { HILOG_WARN(HILOG_MODULE_AAFWK, "[BMS] get jsEngine version fail when restart!"); } +#endif // get third system bundle uninstall record cJSON *uninstallRecord = BundleUtil::GetJsonStream(UNINSTALL_THIRD_SYSTEM_BUNDLE_JSON); @@ -355,6 +361,10 @@ void GtManagerService::ScanPackages() // scan third apps ScanThirdApp(INSTALL_PATH, &systemPathList_); + +#ifdef __LITEOS_M__ + RegisterInstallerCallback(InstallCallbackFunc); +#endif } void GtManagerService::RemoveSystemAppPathList(List *systemPathList) @@ -659,6 +669,7 @@ void GtManagerService::RemoveBundleResList(const char *bundleName) } } +#ifdef BC_TRANS_ENABLE void GtManagerService::TransformJsToBcWhenRestart(const char *codePath, const char *bundleName) { if (codePath == nullptr) { @@ -764,6 +775,7 @@ void GtManagerService::TransformJsToBc(const char *codePath, const char *bundleJ } (void)BundleUtil::StoreJsonContentToFile(bundleJsonPath, installRecordObj); } +#endif bool GtManagerService::CheckThirdSystemBundleHasUninstalled(const char *bundleName, const cJSON *object) { diff --git a/services/bundlemgr_lite/src/gt_bundle_parser.cpp b/services/bundlemgr_lite/src/gt_bundle_parser.cpp index 8411181..17cb8d6 100755 --- a/services/bundlemgr_lite/src/gt_bundle_parser.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_parser.cpp @@ -312,7 +312,7 @@ bool GtBundleParser::CheckDeviceTypeIsValid(const cJSON *deviceTypeObject) return false; } - const char const *deviceType = GetDeviceType(); + const char *deviceType = GetDeviceType(); if (deviceType == nullptr) { return false; } @@ -419,7 +419,11 @@ BundleInfo *GtBundleParser::CreateBundleInfo(const char *path, const BundleProfi return nullptr; } // set abilityInfo +#ifdef __LITEOS_M__ + AbilityInfo abilityInfo = {.srcPath = jsPath, .bundleName = bundleInfo->bundleName}; +#else AbilityInfo abilityInfo = {.bundleName = bundleInfo->bundleName, .srcPath = jsPath}; +#endif if (!BundleInfoUtils::SetBundleInfoAbilityInfo(bundleInfo, abilityInfo)) { AdapterFree(abilityInfo.srcPath); BundleInfoUtils::FreeBundleInfo(bundleInfo); @@ -602,7 +606,11 @@ uint8_t GtBundleParser::SaveBundleInfo(const BundleProfile &bundleProfile, const *bundleInfo = nullptr; return ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR; } +#ifdef __LITEOS_M__ + AbilityInfo abilityInfo = {.srcPath = jsPath, .bundleName = (*bundleInfo)->bundleName}; +#else AbilityInfo abilityInfo = {.bundleName = (*bundleInfo)->bundleName, .srcPath = jsPath}; +#endif // set abilityInfo if (!BundleInfoUtils::SetBundleInfoAbilityInfo(*bundleInfo, abilityInfo)) { AdapterFree(jsPath); diff --git a/utils/bundle_lite/adapter.h b/utils/bundle_lite/adapter.h index 0f53edb..9137709 100755 --- a/utils/bundle_lite/adapter.h +++ b/utils/bundle_lite/adapter.h @@ -22,7 +22,7 @@ #define EXTERNC #endif -#ifndef APP_PLATFORM_WATCHGT +#ifndef __LITEOS_M__ // memory operator define #include @@ -43,7 +43,7 @@ #define MutexAcquire(a, b) pthread_mutex_lock(a) #define MutexRelease(a) pthread_mutex_unlock(a) -#else // APP_PLATFORM_WATCHGT +#else // __LITEOS_M__ #include "stdint.h" #include "ohos_mem_pool.h" -- Gitee