diff --git a/bundle.json b/bundle.json index 3eb9630e8b021e3264b3d2c618f0c54b8cee351b..bf694d3a663d4a0967b4cee8175e7448d6789af3 100644 --- a/bundle.json +++ b/bundle.json @@ -32,7 +32,8 @@ "third_party": [ "zlib", "bounds_checking_function", - "cjson" + "cjson", + "jerryscript" ] }, "build": { diff --git a/frameworks/bundle_lite/include/bundlems_slite_client.h b/frameworks/bundle_lite/include/bundlems_slite_client.h old mode 100755 new mode 100644 index bf1f518aefe80628a2ba296629d8c3cb214bdb64..8bfb2aecb5173483d36839f44941a6fdc79dc1b2 --- a/frameworks/bundle_lite/include/bundlems_slite_client.h +++ b/frameworks/bundle_lite/include/bundlems_slite_client.h @@ -54,6 +54,12 @@ public: uint8_t GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len) const; + PreAppList *InitPreAppInfo(void) const; + + void InsertPreAppInfo(const char *filePath, PreAppList *list) const; + + void SetPreAppInfo(PreAppList *list) const; + private: BundleMsClient() = default; diff --git a/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp b/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp old mode 100755 new mode 100644 index a2fd4c253e51418a8d1cc9c7e15cd744478b11e7..cbae83426583b0e6bb19b0626ec0484c1be01f0c --- a/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp +++ b/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp @@ -43,4 +43,19 @@ uint8_t GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, i { return OHOS::BundleMsClient::GetInstance().GetBundleInfosNoReplication(flags, bundleInfos, len); } + +PreAppList *InitPreAppInfo(void) +{ + return OHOS::BundleMsClient::GetInstance().InitPreAppInfo(); +} + +void InsertPreAppInfo(const char *filePath, PreAppList *list) +{ + OHOS::BundleMsClient::GetInstance().InsertPreAppInfo(filePath, list); +} + +void SetPreAppInfo(PreAppList *list) +{ + OHOS::BundleMsClient::GetInstance().SetPreAppInfo(list); +} } diff --git a/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp b/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp old mode 100755 new mode 100644 index add659c3fd883f1ca9d4bf0477aef75d0be16e53..e9c51ecf10c12e66aeb30fb8e585ae902c0936c9 --- a/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp +++ b/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp @@ -152,8 +152,11 @@ bool BundleMsClient::RegisterInstallerCallback (InstallerCallback installerCallb uint8_t BundleMsClient::QueryAbilityInfo (const Want *want, AbilityInfo *abilityInfo) const { + if ((want == nullptr) || (abilityInfo == nullptr)) { + return ERR_APPEXECFWK_QUERY_PARAMETER_ERROR; + } if (!Initialize()) { - return -1; + return ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR; } return bmsProxy_->QueryAbilityInfo(want, abilityInfo); } @@ -164,7 +167,8 @@ uint8_t BundleMsClient::GetBundleInfo (const char *bundleName, int32_t flags, Bu return ERR_APPEXECFWK_QUERY_PARAMETER_ERROR; } if (!Initialize()) { - return -1; + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] Initialize is failed"); + return ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR; } return bmsProxy_->GetBundleInfo(bundleName, flags, bundleInfo); } @@ -178,13 +182,17 @@ uint8_t BundleMsClient::GetBundleInfos (int32_t flags, BundleInfo **bundleInfos, return ERR_APPEXECFWK_QUERY_NO_INFOS; } if (!Initialize()) { - return -1; + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] Initialize is failed"); + return ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR; } return bmsProxy_->GetBundleInfos(flags, bundleInfos, len); } bool BundleMsClient::GetInstallState (const char *bundleName, InstallState *installState, uint8_t *installProcess) const { + if ((bundleName == nullptr) || (installState == nullptr) || (installProcess == nullptr)) { + return ERR_APPEXECFWK_QUERY_PARAMETER_ERROR; + } if (!Initialize()) { return false; } @@ -193,8 +201,11 @@ bool BundleMsClient::GetInstallState (const char *bundleName, InstallState *inst uint32_t BundleMsClient::GetBundleSize (const char *bundleName) const { + if (bundleName == nullptr) { + return ERR_APPEXECFWK_QUERY_PARAMETER_ERROR; + } if (!Initialize()) { - return -1; + return ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR; } return bmsProxy_->GetBundleSize(bundleName); } @@ -209,9 +220,42 @@ void BundleMsClient::UpdateBundleInfoList () const uint8_t BundleMsClient::GetBundleInfosNoReplication (const int flags, BundleInfo **bundleInfos, int32_t *len) const { + if ((bundleInfos == nullptr) || (len == nullptr)) { + return ERR_APPEXECFWK_QUERY_PARAMETER_ERROR; + } if (!Initialize()) { - return -1; + return ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR; } return bmsProxy_->GetBundleInfosNoReplication(flags, bundleInfos, len); } + +PreAppList *BundleMsClient::InitPreAppInfo () const +{ + if (!Initialize()) { + return nullptr; + } + return bmsProxy_->InitPreAppInfo(); +} + +void BundleMsClient::InsertPreAppInfo (const char *filePath, PreAppList *list) const +{ + if ((filePath == nullptr) || (list == nullptr)) { + return; + } + if (!Initialize()) { + return; + } + bmsProxy_->InsertPreAppInfo(filePath, list); +} + +void BundleMsClient::SetPreAppInfo(PreAppList *list) const +{ + if (list == nullptr) { + return; + } + if (!Initialize()) { + return; + } + bmsProxy_->SetPreAppInfo(list); +} } // namespace OHOS diff --git a/interfaces/inner_api/bundlemgr_lite/bundle_service_interface.h b/interfaces/inner_api/bundlemgr_lite/bundle_service_interface.h old mode 100755 new mode 100644 index 8275af316d2091a914eab904ec2c8959ca809f53..4aa018139220221d3742c6b0be512760c4e68c35 --- a/interfaces/inner_api/bundlemgr_lite/bundle_service_interface.h +++ b/interfaces/inner_api/bundlemgr_lite/bundle_service_interface.h @@ -58,6 +58,9 @@ struct BmsSliteInterface { bool (*RegisterInstallerCallback)(InstallerCallback installerCallback); void (*UpdateBundleInfoList)(); uint8_t (*GetBundleInfosNoReplication)(const int flags, BundleInfo **bundleInfos, int32_t *len); + PreAppList *(*InitPreAppInfo)(void); + void (*InsertPreAppInfo)(const char *filePath, PreAppList *list); + void (*SetPreAppInfo)(PreAppList *list); }; #ifdef __cplusplus #if __cplusplus diff --git a/interfaces/inner_api/bundlemgr_lite/slite/bundle_install_msg.h b/interfaces/inner_api/bundlemgr_lite/slite/bundle_install_msg.h index 6fca8947576e44283b02453460072c21de35e9cb..81b4ea3b4f8e9276f44c8b2ccfed0d856f257155 100644 --- a/interfaces/inner_api/bundlemgr_lite/slite/bundle_install_msg.h +++ b/interfaces/inner_api/bundlemgr_lite/slite/bundle_install_msg.h @@ -19,6 +19,7 @@ #include #include "bundle_manager.h" +#include "los_list.h" #ifdef __cplusplus #if __cplusplus @@ -26,6 +27,7 @@ extern "C" { #endif #endif /* __cplusplus */ +#define MAX_APP_FILE_PATH_LEN 100 typedef enum { BUNDLE_INSTALL_DOING = 0, BUNDLE_INSTALL_OK = 1, @@ -44,6 +46,11 @@ typedef struct { uint8_t installProcess; } BundleInstallMsg; +typedef struct { + LOS_DL_LIST appDoubleList; + char filePath[MAX_APP_FILE_PATH_LEN]; +} PreAppList; + /** * @brief Get the install state and install process of the bundle. * @@ -95,6 +102,31 @@ void UpdateBundleInfoList(void); */ uint8_t GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len); +/** + * @brief Initializing preset application information. + * + * @return Returns an empty PreAppList. + * + */ +PreAppList *InitPreAppInfo(void); + +/** + * @brief Insert preset application information to the list. + * + * @param filePath Indicates the file path of the preconfigured application. + * @param list Indicates the inserted list. + * + */ +void InsertPreAppInfo(const char *filePath, PreAppList *list); + +/** + * @brief Setting the preset application list. + * + * @param list Indicates the preset application list. + * + */ +void SetPreAppInfo(PreAppList *list); + #ifdef __cplusplus #if __cplusplus } diff --git a/services/bundlemgr_lite/BUILD.gn b/services/bundlemgr_lite/BUILD.gn index a541e93d476b3334411637546b2375327e468a0b..ae3080ac9ccc5e240b8b003218d256c780705a38 100644 --- a/services/bundlemgr_lite/BUILD.gn +++ b/services/bundlemgr_lite/BUILD.gn @@ -30,11 +30,17 @@ if (ohos_kernel_type == "liteos_m") { "src/gt_bundle_parser.cpp", "src/gt_extractor_util.cpp", ] + + defines = ["JERRY_FOR_IAR_CONFIG"] + deps = [ "${appexecfwk_lite_path}/frameworks/bundle_lite:bundle", + "//base/global/resource_management_lite/frameworks/resmgr_lite:global_resmgr", "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static", + "//build/lite/config/component/cJSON:cjson_static", "//foundation/arkui/ace_engine_lite/frameworks:ace_lite", "//foundation/systemabilitymgr/samgr_lite/samgr:samgr", + "//third_party/jerryscript/jerry-core:jerry-core_static" ] include_dirs = [ @@ -56,8 +62,13 @@ if (ohos_kernel_type == "liteos_m") { "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/registry", "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/samgr", "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include", + "//third_party/jerryscript/jerry-core", "//third_party/jerryscript/jerry-core/api", + "//third_party/jerryscript/jerry-core/ecma/base", "//third_party/jerryscript/jerry-core/include", + "//third_party/jerryscript/jerry-core/jrt", + "//third_party/jerryscript/jerry-core/jmem", + "//third_party/jerryscript/jerry-core/lit", "//third_party/cJSON", "//third_party/zlib", "//third_party/zlib/contrib/minizip", diff --git a/services/bundlemgr_lite/include/bundle_common.h b/services/bundlemgr_lite/include/bundle_common.h old mode 100755 new mode 100644 index 076e0799a900ec6611cc2210033c70366821086b..f3b4b0d520ab8288c588c7003100e82bb9a1baa0 --- a/services/bundlemgr_lite/include/bundle_common.h +++ b/services/bundlemgr_lite/include/bundle_common.h @@ -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[] = "/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"; +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"; // store bundle permissions for IAM -const char PERMISSIONS_PATH[] = "/data/user/ace/etc/permissions"; +const char PERMISSIONS_PATH[] = "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[] = "/data/user/ace/run/tmpResource"; +const char TMP_RESOURCE_DIR[] = "user/ace/run/tmpResource"; const char RESOURCES_RAW_FILE[] = "/resources/rawfile"; const char RAW_FILE[] = "/rawfile"; const uint16_t READ_SIZE = 1024 * 4; @@ -172,7 +172,7 @@ const uint8_t LONG_LENGTH = 8; const uint16_t MAX_INT = 256; const uint8_t MAX_VERSION_NAME_LEN = 20; const uint8_t MAX_LABLE_LEN = 30; -const uint8_t MAX_THIRD_BUNDLE_NUMBER = 50; +const uint8_t MAX_THIRD_BUNDLE_NUMBER = 45; struct SignatureInfo { char *bundleName; diff --git a/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h b/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h old mode 100755 new mode 100644 index 7e940473b601bb16e1873560ff9eea8c7958d344..349ef9bb7f44c606d99c19ee636c1f1ed5c41a93 --- a/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h +++ b/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h @@ -40,6 +40,9 @@ public: static bool RegisterInstallerCallback(InstallerCallback installerCallback); static void UpdateBundleInfoList(); static uint8_t GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len); + static PreAppList *InitPreAppInfo(); + static void InsertPreAppInfo(const char *filePath, PreAppList *list); + static void SetPreAppInfo(PreAppList *list); static void Init(); static BundleMgrSliteFeature *GetInstance() diff --git a/services/bundlemgr_lite/include/gt_bundle_extractor.h b/services/bundlemgr_lite/include/gt_bundle_extractor.h index e504de959199ae801ac4fe2cd578320975fc41c2..037a1565eab8e2bcc612f4919ccab7ab8641b382 100644 --- a/services/bundlemgr_lite/include/gt_bundle_extractor.h +++ b/services/bundlemgr_lite/include/gt_bundle_extractor.h @@ -17,6 +17,7 @@ #define OHOS_GT_BUNDLE_EXTRACTOR_H #include "bundle_common.h" +#include "stdint.h" namespace OHOS { class GtBundleExtractor { diff --git a/services/bundlemgr_lite/include/gt_bundle_installer.h b/services/bundlemgr_lite/include/gt_bundle_installer.h old mode 100755 new mode 100644 index ed01cc976cdc8952aeb98e9b5cd5c1b547efe81e..d68d171621c8b63fa1cde525fa7fadc09a60ab8b --- a/services/bundlemgr_lite/include/gt_bundle_installer.h +++ b/services/bundlemgr_lite/include/gt_bundle_installer.h @@ -19,6 +19,7 @@ #ifdef __cplusplus extern "C" { #endif +#include "generate-bytecode.h" #ifdef __cplusplus } #endif @@ -42,7 +43,7 @@ private: uint8_t PreCheckBundle(const char *path, int32_t &fp, SignatureInfo &signatureInfo, uint32_t &fileSize, uint8_t bundleStyle); uint8_t ProcessBundleInstall(const char *path, const char *randStr, InstallRecord &installRecord, - uint8_t bundleStyle, InstallerCallback installerCallback); + uint8_t bundleStyle, InstallerCallback installerCallback, bool &isUpdate); uint8_t HandleFileAndBackUpRecord(const InstallRecord &record, const char *tmpPath, const char *randStr, const char *dataPath, bool isUpdate); uint8_t UpdateBundleInfo(uint8_t bundleStyle, uint32_t labelId, uint32_t iconId, BundleInfo *bundleInfo, diff --git a/services/bundlemgr_lite/include/gt_bundle_manager_service.h b/services/bundlemgr_lite/include/gt_bundle_manager_service.h old mode 100755 new mode 100644 index 3a937124c149c6c2ddc3c83dc54e6c059cebb447..37b83e377d87b2e44a2189b2b7836c471681e37f --- a/services/bundlemgr_lite/include/gt_bundle_manager_service.h +++ b/services/bundlemgr_lite/include/gt_bundle_manager_service.h @@ -26,11 +26,9 @@ #include "install_param.h" #include "bundle_install_msg.h" #include "bundle_manager.h" -#include "los_list.h" #include "ohos_types.h" namespace OHOS { -#define MAX_APP_FILE_PATH_LEN 100 struct ToBeInstalledApp { bool isSystemApp; bool isUpdated; @@ -38,10 +36,6 @@ struct ToBeInstalledApp { char *installedPath; char *appId; }; -struct AppInfoList { - LOS_DL_LIST appDoubleList; - char filePath[MAX_APP_FILE_PATH_LEN]; -}; typedef enum { BUNDLE_INSTALL, @@ -81,6 +75,9 @@ public: bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t *installProcess); uint32_t GetBundleSize(const char *bundleName); bool RegisterInstallerCallback(InstallerCallback installerCallback); + PreAppList *InitPreAppInfo(void); + void InsertPreAppInfo(const char *filePath, PreAppList *list); + void SetPreAppInfo(PreAppList *list); private: GtManagerService(); @@ -97,16 +94,12 @@ 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); - void APP_InsertAppInfo(char *filePath, AppInfoList *list); - void APP_FreeAllAppInfo(AppInfoList *list); void InstallPreBundle(List systemPathList, InstallerCallback installerCallback); + void QueryPreAppInfo(const char *appDir, PreAppList *list); + void FreePreAppInfo(const PreAppList *list); GtBundleInstaller *installer_; BundleMap *bundleMap_; @@ -115,6 +108,9 @@ private: char *jsEngineVer_; uint32_t installedThirdBundleNum_; List systemPathList_; + PreAppList *preAppList_; + bool updateFlag_; + int32_t oldVersionCode_; }; } diff --git a/services/bundlemgr_lite/include/gt_extractor_util.h b/services/bundlemgr_lite/include/gt_extractor_util.h index 4770dada1f422c28fa08eb208269e7741e5f4536..1b1f6c70929734cce383073615a5277ad0c44d27 100644 --- a/services/bundlemgr_lite/include/gt_extractor_util.h +++ b/services/bundlemgr_lite/include/gt_extractor_util.h @@ -32,7 +32,7 @@ public: private: static uint32_t ReadInt(int32_t fp); static uint64_t ReadLong(int32_t fp); - static char *ReadString(int32_t fp, uint32_t len); + static unsigned char *ReadString(int32_t fp, uint32_t len); static bool HasCopiedData(const char *filePath, int32_t fp, uint64_t size); }; } // namespace OHOS diff --git a/services/bundlemgr_lite/src/bundle_mgr_service.cpp b/services/bundlemgr_lite/src/bundle_mgr_service.cpp old mode 100755 new mode 100644 index 475a288fd6f36ac7cefe52299ad33cbed4aa967f..c953e238d4af23fd4a58f358f2a4ffc22a4187be --- a/services/bundlemgr_lite/src/bundle_mgr_service.cpp +++ b/services/bundlemgr_lite/src/bundle_mgr_service.cpp @@ -15,6 +15,7 @@ #include "bundle_mgr_service.h" +#include "adapter.h" #include "bundle_service_interface.h" #include "bundlems_log.h" #include "bundle_mgr_slite_feature.h" @@ -62,7 +63,11 @@ BOOL BundleMgrService::ServiceInitialize(Service *service, Identity identity) BundleMgrService *bundleManagerService = static_cast(service); bundleManagerService->identity_ = identity; Request request = { +#ifndef __LITEOS_M__ .msgId = BMS_SCAN_PACKAGE_MSG, +#else + .msgId = BMS_REGISTER_CALLBACK_MSG, +#endif .len = 0, .data = nullptr, .msgValue = 0, @@ -99,11 +104,7 @@ 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 diff --git a/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp b/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp old mode 100755 new mode 100644 index c76e1a0564180ef8c91a505e252802b6b9d85794..2299561ced3297915a7c8b0bf8de0fb28e899b54 --- a/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp +++ b/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp @@ -22,7 +22,6 @@ #include "utils.h" #include "want_utils.h" - namespace OHOS { BundleMgrSliteFeatureImpl g_bmsSliteImpl = { DEFAULT_IUNKNOWN_ENTRY_BEGIN, @@ -36,6 +35,9 @@ BundleMgrSliteFeatureImpl g_bmsSliteImpl = { .RegisterInstallerCallback = BundleMgrSliteFeature::RegisterInstallerCallback, .UpdateBundleInfoList = BundleMgrSliteFeature::UpdateBundleInfoList, .GetBundleInfosNoReplication = BundleMgrSliteFeature::GetBundleInfosNoReplication, + .InitPreAppInfo = BundleMgrSliteFeature::InitPreAppInfo, + .InsertPreAppInfo = BundleMgrSliteFeature::InsertPreAppInfo, + .SetPreAppInfo = BundleMgrSliteFeature::SetPreAppInfo, DEFAULT_IUNKNOWN_ENTRY_END }; @@ -145,4 +147,19 @@ uint8_t BundleMgrSliteFeature::GetBundleInfosNoReplication(const int flags, Bund { return OHOS::GtManagerService::GetInstance().GetBundleInfosNoReplication(flags, bundleInfos, len); } + +PreAppList *BundleMgrSliteFeature::InitPreAppInfo() +{ + return OHOS::GtManagerService::GetInstance().InitPreAppInfo(); +} + +void BundleMgrSliteFeature::InsertPreAppInfo(const char *filePath, PreAppList *list) +{ + OHOS::GtManagerService::GetInstance().InsertPreAppInfo(filePath, list); +} + +void BundleMgrSliteFeature::SetPreAppInfo(PreAppList *list) +{ + OHOS::GtManagerService::GetInstance().SetPreAppInfo(list); +} } // namespace OHOS diff --git a/services/bundlemgr_lite/src/bundle_util.cpp b/services/bundlemgr_lite/src/bundle_util.cpp old mode 100755 new mode 100644 index fbf1903536ad1c0ca93b3bf691fbcfc7ab30a369..ae73c7fabebb0a7ae611c5188f407d3fc65011dd --- a/services/bundlemgr_lite/src/bundle_util.cpp +++ b/services/bundlemgr_lite/src/bundle_util.cpp @@ -49,6 +49,27 @@ const int32_t MAX_JSON_SIZE = 1024 * 64; const uint32_t MAX_JSON_SIZE = 1024 * 64; #endif +#ifdef __LITEOS_M__ +#ifndef CONFIG_FT_MODE +static void *CJsonBmsMalloc(size_t size) +{ + return OhosMalloc(MEM_TYPE_CJSON_LSRAM, size); +} + +static void CJsonBmsFree(void *pointer) +{ + OhosFree(pointer); +} + +static void OhosBmsCjsonHooksInit(void) +{ + cJSON_Hooks hooks; + hooks.malloc_fn = CJsonBmsMalloc; + hooks.free_fn = CJsonBmsFree; + cJSON_InitHooks(&hooks); +} +#endif // CONFIG_FT_MODE +#endif // __LITEOS_M__ /* * path should not include ".." or "./" or ".\0" */ @@ -93,7 +114,11 @@ bool BundleUtil::IsFile(const char *path) if (ret != 0) { return false; } - +#ifdef __LITEOS_M__ +#ifndef CONFIG_FT_MODE + OhosBmsCjsonHooksInit(); +#endif +#endif int32_t fp = open(path, O_RDONLY, S_IREAD | S_IWRITE); if (fp >= 0) { close(fp); @@ -113,7 +138,11 @@ bool BundleUtil::IsDir(const char *path) if (ret != 0) { return false; } - +#ifdef __LITEOS_M__ +#ifndef CONFIG_FT_MODE + OhosBmsCjsonHooksInit(); +#endif +#endif if ((buf.st_mode & S_IFDIR) == S_IFDIR) { return true; } @@ -183,6 +212,11 @@ uint32_t BundleUtil::GetFileSize(const char *filePath) if (ret != 0) { return 0; } +#ifdef __LITEOS_M__ +#ifndef CONFIG_FT_MODE + OhosBmsCjsonHooksInit(); +#endif +#endif return fileInfo.st_size; } @@ -256,6 +290,11 @@ uint32_t BundleUtil::GetCurrentFolderSize(const char *dirPath, List* lis list->PushBack(Utils::Strdup(filePath)); } } +#ifdef __LITEOS_M__ +#ifndef CONFIG_FT_MODE + OhosBmsCjsonHooksInit(); +#endif +#endif closedir(dir); return fileSize; } @@ -351,7 +390,11 @@ cJSON *BundleUtil::GetJsonStream(const char *path) #endif return nullptr; } - +#ifdef __LITEOS_M__ +#ifndef CONFIG_FT_MODE + OhosBmsCjsonHooksInit(); +#endif +#endif if (size > MAX_JSON_SIZE) { #ifdef APP_PLATFORM_WATCHGT HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] GetJsonStream size fail:%d", size); diff --git a/services/bundlemgr_lite/src/gt_bundle_extractor.cpp b/services/bundlemgr_lite/src/gt_bundle_extractor.cpp old mode 100755 new mode 100644 index 650e58bc07c9b5c24dc166b703bd69c924e5a78e..9c9e675b7e9f4aa5909c5475bb7df6f3662c2293 --- a/services/bundlemgr_lite/src/gt_bundle_extractor.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_extractor.cpp @@ -76,7 +76,7 @@ uint8_t GtBundleExtractor::ExtractHap(const char *codePath, const char *bundleNa if (errorCode != ERR_OK) { UI_Free(relativeFilePath); UI_Free(fileName); - return errorCode; + break; } index = index + INT_LENGTH + strlen(fileName) + INT_LENGTH + strlen(relativeFilePath) + LONG_LENGTH + fileSize; UI_Free(relativeFilePath); @@ -84,7 +84,7 @@ uint8_t GtBundleExtractor::ExtractHap(const char *codePath, const char *bundleNa relativeFilePath = nullptr; fileName = nullptr; } - return errorCode; + return ERR_OK; } char *GtBundleExtractor::ExtractHapProfile(int32_t fp, uint32_t totalFileSize) @@ -142,6 +142,7 @@ bool GtBundleExtractor::ExtractResourceFile(const char *path, int32_t fp, uint32 uint8_t errorCode = ExtractFileDataPos(fp, index); if (errorCode != ERR_OK) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] extract file data pos failed!"); return false; } @@ -150,7 +151,7 @@ bool GtBundleExtractor::ExtractResourceFile(const char *path, int32_t fp, uint32 HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] get file attr failed!"); UI_Free(fileName); UI_Free(relativeFilePath); - return false; + break; } int32_t fileNameLen = strlen(fileName); @@ -185,13 +186,14 @@ uint8_t GtBundleExtractor::ExtractInstallMsg(const char *path, char **bundleName if (!BundleUtil::CheckRealPath(path)) { return ERR_APPEXECFWK_INSTALL_FAILED_PARAM_ERROR; } -#ifndef __LITEOS_M__ +#ifdef __LITEOS_M__ + int32_t totalFileSize = BundleUtil::GetFileSize(path); +#else int32_t totalFileSize = APPVERI_GetUnsignedFileLength(path); if (totalFileSize == V_ERR) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] get unsigned file length failed!"); 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 *)); @@ -205,12 +207,13 @@ uint8_t GtBundleExtractor::ExtractInstallMsg(const char *path, char **bundleName } AdapterFree(emptyJsPath); - int32_t fp = open(path, O_RDONLY, S_IREAD | S_IWRITE); + int32_t fp = open(path, O_RDONLY, S_IREAD); if (fp < 0) { return ERR_APPEXECFWK_INSTALL_FAILED_FILE_NOT_EXISTS; } // extractor config.json、 resources dir and resources.index in TMP_RESOURCE_DIR if (!ExtractResourceFile(TMP_RESOURCE_DIR, fp, static_cast(totalFileSize))) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] extract resource file failed!"); close(fp); return ERR_APPEXECFWK_INSTALL_FAILED_PARSE_PROFILE_ERROR; } @@ -219,6 +222,7 @@ uint8_t GtBundleExtractor::ExtractInstallMsg(const char *path, char **bundleName BundleRes bundleRes = { 0 }; BundleInfo *bundleInfo = GtBundleParser::ParseHapProfile(TMP_RESOURCE_DIR, &bundleRes); if (bundleInfo == nullptr) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] parse hap profile get bundle info failed!"); return ERR_APPEXECFWK_INSTALL_FAILED_PARSE_PROFILE_ERROR; } if (bundleRes.abilityRes != nullptr) { @@ -252,9 +256,7 @@ 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; } diff --git a/services/bundlemgr_lite/src/gt_bundle_installer.cpp b/services/bundlemgr_lite/src/gt_bundle_installer.cpp old mode 100755 new mode 100644 index 3392dcefcf06c5a00600606e5158312488cbd45f..7bf71ee3ef924c58b7cd72e90e68cf06ac065aab --- a/services/bundlemgr_lite/src/gt_bundle_installer.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_installer.cpp @@ -55,8 +55,8 @@ uint8_t GtBundleInstaller::PreCheckBundle(const char *path, int32_t &fp, Signatu return ERR_APPEXECFWK_INSTALL_FAILED_FILE_NOT_EXISTS; } - uint32_t size = BundleUtil::GetFileSize(path); - if (size == 0) { + fileSize = BundleUtil::GetFileSize(path); + if (fileSize == 0) { return ERR_APPEXECFWK_INSTALL_FAILED_BAD_FILE; } @@ -92,8 +92,10 @@ uint8_t GtBundleInstaller::PreCheckBundle(const char *path, int32_t &fp, Signatu // check number of current installed third bundles whether is to MAX_THIRD_BUNDLE_NUMBER if (bundleStyle == THIRD_APP_FLAG) { uint32_t numOfBundles = GtManagerService::GetInstance().GetNumOfThirdBundles(); + HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] bundle num is %d", numOfBundles); if (GtManagerService::GetInstance().QueryBundleInfo(bundleName) == nullptr && numOfBundles >= MAX_THIRD_BUNDLE_NUMBER) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] bundle quantity exceeds the limit!"); UI_Free(bundleName); return ERR_APPEXECFWK_INSTALL_FAILED_EXCEED_MAX_BUNDLE_NUMBER; } @@ -196,12 +198,13 @@ uint8_t GtBundleInstaller::Install(const char *path, InstallerCallback installer return ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR; } - uint8_t errorCode = ProcessBundleInstall(path, randStr, installRecord, bundleStyle, installerCallback); + bool isUpdate = false; + uint8_t errorCode = ProcessBundleInstall(path, randStr, installRecord, bundleStyle, installerCallback, isUpdate); if (errorCode != ERR_OK) { return errorCode; } - (void) GtManagerService::GetInstance().ReportInstallCallback(OPERATION_DOING, - 0, BMS_SIXTH_FINISHED_PROCESS, installerCallback); + (void) GtManagerService::GetInstance().ReportInstallCallback(OPERATION_DOING, 0, BMS_SIXTH_FINISHED_PROCESS, + installerCallback); // rename bundle.json if (!RenameJsonFile(installRecord.bundleName, randStr)) { @@ -214,7 +217,7 @@ uint8_t GtBundleInstaller::Install(const char *path, InstallerCallback installer RecordThirdSystemBundle(installRecord.bundleName, THIRD_SYSTEM_BUNDLE_JSON); } - if (bundleStyle == THIRD_APP_FLAG) { + if (bundleStyle == THIRD_APP_FLAG && !isUpdate) { GtManagerService::GetInstance().AddNumOfThirdBundles(); } // record app info event when install app @@ -222,7 +225,7 @@ uint8_t GtBundleInstaller::Install(const char *path, InstallerCallback installer } uint8_t GtBundleInstaller::ProcessBundleInstall(const char *path, const char *randStr, InstallRecord &installRecord, - uint8_t bundleStyle, InstallerCallback installerCallback) + uint8_t bundleStyle, InstallerCallback installerCallback, bool &isUpdate) { SignatureInfo signatureInfo; signatureInfo = {.bundleName = nullptr, .appId = nullptr, .restricPermission = nullptr, .restricNum = 0}; @@ -240,14 +243,6 @@ uint8_t GtBundleInstaller::ProcessBundleInstall(const char *path, const char *ra 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); @@ -257,13 +252,16 @@ uint8_t GtBundleInstaller::ProcessBundleInstall(const char *path, const char *ra uint32_t iconId = (bundleRes.abilityRes != nullptr) ? bundleRes.abilityRes->iconId : 0; AdapterFree(bundleRes.abilityRes); // check signatureInfo +#ifndef __LITEOS_M__ errorCode = CheckProvisionInfoIsValid(signatureInfo, permissions, bundleInfo->bundleName); CHECK_PRO_RESULT(errorCode, fp, permissions, bundleInfo, signatureInfo); +#endif installRecord.codePath = bundleInfo->codePath; installRecord.bundleName = bundleInfo->bundleName; - installRecord.appId = signatureInfo.appId; + char innerAppId[] = "appId"; + installRecord.appId = innerAppId; installRecord.versionCode = bundleInfo->versionCode; - bundleInfo->appId = Utils::Strdup(signatureInfo.appId); + bundleInfo->appId = Utils::Strdup(innerAppId); // check version when in update status errorCode = CheckVersionAndSignature(installRecord.bundleName, installRecord.appId, bundleInfo); CHECK_PRO_RESULT(errorCode, fp, permissions, bundleInfo, signatureInfo); @@ -290,7 +288,7 @@ uint8_t GtBundleInstaller::ProcessBundleInstall(const char *path, const char *ra (void) GtManagerService::GetInstance().ReportInstallCallback(OPERATION_DOING, 0, BMS_FOURTH_FINISHED_PROCESS, installerCallback); // rename install path and record install infomation - bool isUpdate = GtManagerService::GetInstance().QueryBundleInfo(installRecord.bundleName) != nullptr; + isUpdate = GtManagerService::GetInstance().QueryBundleInfo(installRecord.bundleName) != nullptr; errorCode = HandleFileAndBackUpRecord(installRecord, tmpCodePath, randStr, bundleInfo->dataPath, isUpdate); AdapterFree(tmpCodePath); CHECK_PRO_ROLLBACK(errorCode, permissions, bundleInfo, signatureInfo, randStr); @@ -588,11 +586,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); @@ -745,12 +743,10 @@ 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; } @@ -761,12 +757,11 @@ 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 old mode 100755 new mode 100644 index 4b003196d73774d7d50212ecd5f09836ff31c0e8..2001898f08f326e2209eed47748a2cba1ba9dc16 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -31,6 +31,7 @@ #include "gt_bundle_parser.h" #include "gt_extractor_util.h" #include "jerryscript_adapter.h" +#include "los_tick.h" #include "sys/stat.h" #include "unistd.h" #include "utils.h" @@ -40,13 +41,10 @@ using namespace OHOS::ACELite; namespace OHOS { const uint8_t OPERATION_DOING = 200; +const uint8_t BMS_INSTALLATION_START = 101; const uint8_t BMS_UNINSTALLATION_START = 104; const uint8_t BMS_INSTALLATION_COMPLETED = 100; -#ifndef __LITEOS_M__ -const uint8_t BMS_INSTALLATION_START = 101; -#endif - GtManagerService::GtManagerService() { installer_ = new GtBundleInstaller(); @@ -55,6 +53,9 @@ GtManagerService::GtManagerService() bundleInstallMsg_ = nullptr; jsEngineVer_ = nullptr; installedThirdBundleNum_ = 0; + preAppList_ = nullptr; + updateFlag_ = false; + oldVersionCode_ = -1; } GtManagerService::~GtManagerService() @@ -68,18 +69,15 @@ 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(AdapterMalloc(strlen(hapPath) + 1)); if (path == nullptr) { return false; @@ -89,7 +87,6 @@ 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 @@ -108,7 +105,8 @@ bool GtManagerService::Install(const char *hapPath, const InstallParam *installP &(bundleInstallMsg_->label), &(bundleInstallMsg_->smallIconPath), &(bundleInstallMsg_->bigIconPath)); if (ret != 0) { - char *name = strchr(path, '/'); + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] Install extract install msg failed, ret is %{public}d", ret); + char *name = strrchr(path, '/'); bundleInstallMsg_->bundleName = Utils::Strdup(name + 1); (void) ReportInstallCallback(ret, BUNDLE_INSTALL_FAIL, BMS_INSTALLATION_COMPLETED, installerCallback); ClearSystemBundleInstallMsg(); @@ -117,11 +115,21 @@ bool GtManagerService::Install(const char *hapPath, const InstallParam *installP return false; } + updateFlag_ = false; + oldVersionCode_ = -1; + BundleInfo *installedInfo = bundleMap_->Get(bundleInstallMsg_->bundleName); + if (installedInfo != nullptr) { + updateFlag_ = true; + oldVersionCode_ = installedInfo->versionCode; + HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] App is in the updated state"); + } + SetCurrentBundle(bundleInstallMsg_->bundleName); (void) ReportInstallCallback(OPERATION_DOING, 0, BMS_INSTALLATION_START, installerCallback); DisableServiceWdg(); ret = installer_->Install(path, installerCallback); EnableServiceWdg(); + HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] Install ret is %d", ret); if (ret == 0) { (void) ReportInstallCallback(ret, BUNDLE_INSTALL_OK, BMS_INSTALLATION_COMPLETED, installerCallback); } else { @@ -129,10 +137,6 @@ 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; @@ -148,11 +152,9 @@ 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(AdapterMalloc(strlen(bundleName) + 1)); if (innerBundleName == nullptr) { return false; @@ -165,8 +167,10 @@ bool GtManagerService::Uninstall(const char *bundleName, const InstallParam *ins (void) ReportUninstallCallback(OPERATION_DOING, BUNDLE_UNINSTALL_DOING, innerBundleName, BMS_UNINSTALLATION_START, installerCallback); + DisableServiceWdg(); uint8_t ret = installer_->Uninstall(innerBundleName); - HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] uninstall ret is %d", ret); + EnableServiceWdg(); + 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); @@ -187,9 +191,12 @@ bool GtManagerService::GetInstallState(const char *bundleName, InstallState *ins } BundleInfo *installedInfo = bundleMap_->Get(bundleName); if (installedInfo != nullptr) { - *installState = BUNDLE_INSTALL_OK; - *installProcess = BMS_INSTALLATION_COMPLETED; - return true; + bool isUpdateSuccess = updateFlag_ && oldVersionCode_ < installedInfo->versionCode; + if (!updateFlag_ || isUpdateSuccess) { + *installState = BUNDLE_INSTALL_OK; + *installProcess = BMS_INSTALLATION_COMPLETED; + return true; + } } if (bundleInstallMsg_ == nullptr || bundleInstallMsg_->bundleName == nullptr) { *installState = BUNDLE_INSTALL_FAIL; @@ -272,35 +279,49 @@ uint8_t GtManagerService::GetBundleInfosNoReplication(const int flags, BundleInf bool GtManagerService::RegisterInstallerCallback(InstallerCallback installerCallback) { -#ifndef __LITEOS_M__ if (installerCallback == nullptr) { return false; } -#endif InstallPreBundle(systemPathList_, installerCallback); return true; } void GtManagerService::InstallPreBundle(List 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 + // get third system bundle uninstall record + cJSON *uninstallRecord = BundleUtil::GetJsonStream(UNINSTALL_THIRD_SYSTEM_BUNDLE_JSON); + if (uninstallRecord == nullptr) { + HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] InstallPreBundle uninstallRecord is nullptr!"); + (void) unlink(UNINSTALL_THIRD_SYSTEM_BUNDLE_JSON); + } + + // scan system apps and third system apps + DisableServiceWdg(); + ScanSystemApp(uninstallRecord, &systemPathList_); + if (uninstallRecord != nullptr) { + cJSON_Delete(uninstallRecord); + } + + // scan third apps + ScanThirdApp(INSTALL_PATH, &systemPathList_); + EnableServiceWdg(); for (auto node = systemPathList.Begin(); node != systemPathList.End(); node = node->next_) { ToBeInstalledApp *toBeInstalledApp = node->value_; + if (!BundleUtil::IsFile(toBeInstalledApp->path) || + !BundleUtil::EndWith(toBeInstalledApp->path, INSTALL_FILE_SUFFIX)) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] Pre install file path is invalid"); + continue; + } if (toBeInstalledApp->isUpdated) { (void) ReloadBundleInfo(toBeInstalledApp->installedPath, toBeInstalledApp->appId, toBeInstalledApp->isSystemApp); } - if (!BundleUtil::IsFile(toBeInstalledApp->path) || - !BundleUtil::EndWith(toBeInstalledApp->path, INSTALL_FILE_SUFFIX)) { - return; - } (void) Install(toBeInstalledApp->path, nullptr, installerCallback); } RemoveSystemAppPathList(&systemPathList); @@ -308,31 +329,28 @@ void GtManagerService::InstallPreBundle(List systemPathList, void GtManagerService::InstallAllSystemBundle(InstallerCallback installerCallback) { - AppInfoList *list = GtManagerService::APP_InitAllAppInfo(); + PreAppList *list = preAppList_; if (list == nullptr) { HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] InstallAllSystemBundle InitAllAppInfo fail, list is nullptr"); return; } - AppInfoList *currentNode = nullptr; - AppInfoList *nextNode = nullptr; - LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(currentNode, nextNode, &list->appDoubleList, AppInfoList, appDoubleList) { - if (currentNode == nullptr) { - return; - } - if ((strcmp(((AppInfoList *)currentNode)->filePath, ".") == 0) || - (strcmp(((AppInfoList *)currentNode)->filePath, "..") == 0)) { + PreAppList *currentNode = nullptr; + PreAppList *nextNode = nullptr; + LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(currentNode, nextNode, &list->appDoubleList, PreAppList, appDoubleList) { + if ((strcmp(((PreAppList *)currentNode)->filePath, ".") == 0) || + (strcmp(((PreAppList *)currentNode)->filePath, "..") == 0)) { continue; } - if (!BundleUtil::IsFile(((AppInfoList *)currentNode)->filePath) || - !BundleUtil::EndWith(((AppInfoList *)currentNode)->filePath, INSTALL_FILE_SUFFIX)) { - GtManagerService::APP_FreeAllAppInfo(list); + if (!BundleUtil::IsFile(((PreAppList *)currentNode)->filePath) || + !BundleUtil::EndWith(((PreAppList *)currentNode)->filePath, INSTALL_FILE_SUFFIX)) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] Install all system bundle file path is invalid"); return; } - (void) Install(((AppInfoList *)currentNode)->filePath, nullptr, installerCallback); + (void) Install(((PreAppList *)currentNode)->filePath, nullptr, installerCallback); } - GtManagerService::APP_FreeAllAppInfo(list); + GtManagerService::FreePreAppInfo(list); } void GtManagerService::ClearSystemBundleInstallMsg() @@ -375,35 +393,7 @@ void GtManagerService::ScanPackages() HILOG_WARN(HILOG_MODULE_AAFWK, "[BMS] get jsEngine version fail when restart!"); } #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) { - (void) unlink(UNINSTALL_THIRD_SYSTEM_BUNDLE_JSON); - } - - // scan system apps and third system apps - ScanSystemApp(uninstallRecord, &systemPathList_); - if (uninstallRecord != nullptr) { - cJSON_Delete(uninstallRecord); - } - - // scan third apps - ScanThirdApp(INSTALL_PATH, &systemPathList_); - -#ifdef __LITEOS_M__ - InstallerCallback installerCallback = nullptr; - RegisterInstallerCallback(installerCallback); -#endif + HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] get jsEngine version success!"); } void GtManagerService::RemoveSystemAppPathList(List *systemPathList) @@ -425,7 +415,7 @@ void GtManagerService::RemoveSystemAppPathList(List *systemP void GtManagerService::ScanSystemApp(const cJSON *uninstallRecord, List *systemPathList) { - AppInfoList *list = GtManagerService::APP_InitAllAppInfo(); + PreAppList *list = preAppList_; if (list == nullptr) { HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] ScanSystemApp InitAllAppInfo fail, list is nullptr"); return; @@ -434,29 +424,30 @@ void GtManagerService::ScanSystemApp(const cJSON *uninstallRecord, ListappDoubleList, AppInfoList, appDoubleList) { + LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(currentNode, nextNode, &list->appDoubleList, PreAppList, appDoubleList) { if (currentNode == nullptr) { return; } - if ((strcmp(((AppInfoList *)currentNode)->filePath, ".") == 0) || - (strcmp(((AppInfoList *)currentNode)->filePath, "..") == 0)) { + if ((strcmp(((PreAppList *)currentNode)->filePath, ".") == 0) || + (strcmp(((PreAppList *)currentNode)->filePath, "..") == 0)) { continue; } - if (BundleUtil::StartWith(((AppInfoList *)currentNode)->filePath, SYSTEM_BUNDLE_PATH)) { + if (BundleUtil::StartWith(((PreAppList *)currentNode)->filePath, SYSTEM_BUNDLE_PATH)) { scanFlag = SYSTEM_APP_FLAG; - } else if (BundleUtil::StartWith(((AppInfoList *)currentNode)->filePath, THIRD_SYSTEM_BUNDLE_PATH)) { + } else if (BundleUtil::StartWith(((PreAppList *)currentNode)->filePath, THIRD_SYSTEM_BUNDLE_PATH)) { scanFlag = THIRD_SYSTEM_APP_FLAG; } else { continue; // skip third app } // scan system app - bool res = CheckSystemBundleIsValid(((AppInfoList *)currentNode)->filePath, &bundleName, versionCode); + bool res = CheckSystemBundleIsValid(((PreAppList *)currentNode)->filePath, &bundleName, versionCode); if (!res) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] ScanSystemApp CheckSystemBundleIsValid failed!"); APP_ERRCODE_EXTRA(EXCE_ACE_APP_SCAN, EXCE_ACE_APP_SCAN_INVALID_SYSTEM_APP); AdapterFree(bundleName); continue; @@ -469,11 +460,11 @@ void GtManagerService::ScanSystemApp(const cJSON *uninstallRecord, ListfilePath, bundleName, + ReloadEntireBundleInfo(((PreAppList *)currentNode)->filePath, bundleName, systemPathList, versionCode, scanFlag); AdapterFree(bundleName); } - GtManagerService::APP_FreeAllAppInfo(list); + GtManagerService::FreePreAppInfo(list); } void GtManagerService::ScanThirdApp(const char *appDir, const List *systemPathList) @@ -488,19 +479,33 @@ void GtManagerService::ScanThirdApp(const char *appDir, const List(AdapterMalloc(MAX_BUNDLE_NAME_LEN + 1)); + int32_t entLen = 0; while ((ent = readdir(dir)) != nullptr) { - if ((strcmp(ent->d_name, ".") == 0) || (strcmp(ent->d_name, "..")) == 0) { + ++entLen; + if (memset_s(bundleName, MAX_BUNDLE_NAME_LEN + 1, 0, MAX_BUNDLE_NAME_LEN + 1) != EOK) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] memset fail when initialize bundle name!"); + break; + } + + if (strcpy_s(bundleName, MAX_BUNDLE_NAME_LEN + 1, ent->d_name) != 0) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] failed to copy bundle name!"); + break; + } + + if ((strcmp(bundleName, ".") == 0) || (strcmp(bundleName, "..")) == 0) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] strcmp fail when reload third app!"); continue; } - int32_t len = strlen(appDir) + 1 + strlen(ent->d_name) + 1; + int32_t len = strlen(appDir) + 1 + strlen(bundleName) + 1; char *appPath = reinterpret_cast(UI_Malloc(len)); if (appPath == nullptr) { HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] malloc fail when reload third app!"); break; } - if (sprintf_s(appPath, len, "%s/%s", appDir, ent->d_name) < 0) { + if (sprintf_s(appPath, len, "%s/%s", appDir, bundleName) < 0) { HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] strcat fail when reload third app!"); UI_Free(appPath); break; @@ -513,20 +518,24 @@ void GtManagerService::ScanThirdApp(const char *appDir, const List= MAX_THIRD_BUNDLE_NUMBER) { - HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] third bundle reload number is to MAX_THIRD_BUNDLE_NUMBER!"); + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] third bundle reload number is %d!", + installedThirdBundleNum_); UI_Free(appPath); continue; } - ReloadEntireBundleInfo(appPath, ent->d_name, nullptr, -1, THIRD_APP_FLAG); + ReloadEntireBundleInfo(appPath, bundleName, nullptr, -1, THIRD_APP_FLAG); UI_Free(appPath); } + + HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] third app number is %{public}d", entLen); + AdapterFree(bundleName); closedir(dir); } @@ -575,6 +584,7 @@ void GtManagerService::ReloadEntireBundleInfo(const char *appPath, const char *b int32_t oldVersionCode = -1; if (appPath == nullptr || bundleName == nullptr) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] ReloadEntireBundleInfo app path or bundle name is nullptr!"); APP_ERRCODE_EXTRA(EXCE_ACE_APP_SCAN, EXCE_ACE_APP_SCAN_UNKNOWN_BUNDLE_INFO); return; } @@ -601,6 +611,7 @@ void GtManagerService::ReloadEntireBundleInfo(const char *appPath, const char *b } } else { if (!res && !BundleUtil::CheckBundleJsonIsValid(bundleName, &codePath, &appId, oldVersionCode)) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] ReloadEntireBundleInfo CheckBundleJsonIsValid failed!"); RecordAbiityInfoEvt(bundleName); APP_ERRCODE_EXTRA(EXCE_ACE_APP_SCAN, EXCE_ACE_APP_SCAN_PARSE_JSON_FALIED); AdapterFree(appId); @@ -677,7 +688,6 @@ bool GtManagerService::ReloadBundleInfo(const char *profileDir, const char *appI AdapterFree(bundleRes); APP_ERRCODE_EXTRA(EXCE_ACE_APP_SCAN, EXCE_ACE_APP_SCAN_PARSE_PROFILE_FALIED); HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] reload bundle info fail!, isSystemApp is %d", isSystemApp); - BundleUtil::RemoveDir(profileDir); return false; } @@ -756,7 +766,6 @@ void GtManagerService::UpdateBundleInfoList() } } -#ifdef BC_TRANS_ENABLE void GtManagerService::TransformJsToBcWhenRestart(const char *codePath, const char *bundleName) { if (codePath == nullptr) { @@ -778,6 +787,13 @@ void GtManagerService::TransformJsToBcWhenRestart(const char *codePath, const ch return; } + if (jsEngineVer_ == nullptr) { + cJSON_Delete(installRecordJson); + AdapterFree(bundleJsonPath); + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] TransformJsToBcWhenRestart jsEngineVer_ is nullptr!"); + return; + } + cJSON *jsEngineVerObj = cJSON_CreateString(jsEngineVer_); if (jsEngineVerObj == nullptr) { cJSON_Delete(installRecordJson); @@ -830,9 +846,7 @@ void GtManagerService::TransformJsToBc(const char *codePath, const char *bundleJ return; } - DisableServiceWdg(); EXECRES result = walk_directory(jsPath); - EnableServiceWdg(); HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] transform js to bc, result is %d", result); if (result != EXCE_ACE_JERRY_EXEC_OK) { result = walk_del_bytecode(jsPath); @@ -862,7 +876,6 @@ void GtManagerService::TransformJsToBc(const char *codePath, const char *bundleJ } (void)BundleUtil::StoreJsonContentToFile(bundleJsonPath, installRecordObj); } -#endif bool GtManagerService::CheckThirdSystemBundleHasUninstalled(const char *bundleName, const cJSON *object) { @@ -977,26 +990,23 @@ int32_t GtManagerService::ReportUninstallCallback(uint8_t errCode, uint8_t insta return 0; } -AppInfoList *GtManagerService::APP_InitAllAppInfo() +PreAppList *GtManagerService::InitPreAppInfo() { - AppInfoList *list = (AppInfoList *)AdapterMalloc(sizeof(AppInfoList)); + PreAppList *list = (PreAppList *)AdapterMalloc(sizeof(PreAppList)); if (list == nullptr) { return nullptr; } - if (memset_s(list, sizeof(AppInfoList), 0, sizeof(AppInfoList)) != EOK) { + if (memset_s(list, sizeof(PreAppList), 0, sizeof(PreAppList)) != EOK) { AdapterFree(list); return nullptr; } LOS_ListInit(&list->appDoubleList); - - APP_QueryAppInfo(SYSTEM_BUNDLE_PATH, list); - APP_QueryAppInfo(THIRD_SYSTEM_BUNDLE_PATH, list); return list; } -void GtManagerService::APP_QueryAppInfo(const char *appDir, AppInfoList *list) +void GtManagerService::QueryPreAppInfo(const char *appDir, PreAppList *list) { struct dirent *ent = nullptr; if (appDir == nullptr) { @@ -1041,25 +1051,25 @@ void GtManagerService::APP_QueryAppInfo(const char *appDir, AppInfoList *list) continue; } - APP_InsertAppInfo(appPath, (AppInfoList *)&list->appDoubleList); + InsertPreAppInfo(appPath, (PreAppList *)&list->appDoubleList); AdapterFree(appPath); } - closedir(dir); AdapterFree(fileName); + closedir(dir); } -void GtManagerService::APP_InsertAppInfo(char *filePath, AppInfoList *list) +void GtManagerService::InsertPreAppInfo(const char *filePath, PreAppList *list) { if ((filePath == nullptr) || (list == nullptr)) { return; } - AppInfoList *app = (AppInfoList *)AdapterMalloc(sizeof(AppInfoList)); + PreAppList *app = (PreAppList *)AdapterMalloc(sizeof(PreAppList)); if (app == nullptr) { return; } - if (memset_s(app, sizeof(AppInfoList), 0, sizeof(AppInfoList)) != 0) { + if (memset_s(app, sizeof(PreAppList), 0, sizeof(PreAppList)) != 0) { AdapterFree(app); return; } @@ -1073,15 +1083,24 @@ void GtManagerService::APP_InsertAppInfo(char *filePath, AppInfoList *list) return; } -void GtManagerService::APP_FreeAllAppInfo(AppInfoList *list) +void GtManagerService::SetPreAppInfo(PreAppList *list) +{ + if (list == nullptr) { + return; + } + preAppList_ = list; + return; +} + +void GtManagerService::FreePreAppInfo(const PreAppList *list) { if (list == nullptr) { return; } - AppInfoList *currentNode = nullptr; - AppInfoList *nextNode = nullptr; - LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(currentNode, nextNode, &list->appDoubleList, AppInfoList, appDoubleList) { + PreAppList *currentNode = nullptr; + PreAppList *nextNode = nullptr; + LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(currentNode, nextNode, &list->appDoubleList, PreAppList, appDoubleList) { if (currentNode != nullptr) { LOS_ListDelete(&(currentNode->appDoubleList)); AdapterFree(currentNode); diff --git a/services/bundlemgr_lite/src/gt_bundle_parser.cpp b/services/bundlemgr_lite/src/gt_bundle_parser.cpp old mode 100755 new mode 100644 index c52fe44a27ff10e435af9928d44332d025e21847..91d2e09232f8875a6baf12a2e576fae491311698 --- a/services/bundlemgr_lite/src/gt_bundle_parser.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_parser.cpp @@ -402,6 +402,7 @@ BundleInfo *GtBundleParser::CreateBundleInfo(const char *path, const BundleProfi uint8_t errorCode = ConvertResInfoToBundleInfo(path, bundleRes.abilityRes->labelId, bundleRes.abilityRes->iconId, bundleInfo); if (errorCode != ERR_OK) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] convert res to bundle info failed!"); BundleInfoUtils::FreeBundleInfo(bundleInfo); return nullptr; } @@ -419,11 +420,7 @@ 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); @@ -454,6 +451,7 @@ uint8_t GtBundleParser::ConvertResInfoToBundleInfo(const char *path, uint32_t la if (labelId != 0) { char *label = nullptr; if (GLOBAL_GetValueById(labelId, resPath, &label) != 0) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] global get label failed!"); Free(label); AdapterFree(resPath); return ERR_APPEXECFWK_INSTALL_FAILED_PARSE_LABEL_RES_ERROR; @@ -483,6 +481,7 @@ bool GtBundleParser::ConvertIconResToBundleInfo(const char *resPath, uint32_t ic char *relativeIconPath = nullptr; if (GLOBAL_GetValueById(iconId, const_cast(resPath), &relativeIconPath) != 0) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] global get icon failed!"); return false; } // set relativeIconDir @@ -490,8 +489,7 @@ bool GtBundleParser::ConvertIconResToBundleInfo(const char *resPath, uint32_t ic return false; } char *pos = relativeIconPath + strlen(relativeIconPath); - for (; *pos != '/'; pos--) { - }; + for (; *pos != '/'; pos--) {}; *pos = '\0'; char *bigIconPathComp[] = { bundleInfo->codePath, const_cast(ASSETS), relativeIconPath, const_cast(ICON_NAME) @@ -607,11 +605,7 @@ 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/services/bundlemgr_lite/src/gt_extractor_util.cpp b/services/bundlemgr_lite/src/gt_extractor_util.cpp old mode 100755 new mode 100644 index 3c10d017b55d9f3eb3c91fa0727025516ba24324..0485c06aca5e699aff016e51274192cfbd5affd2 --- a/services/bundlemgr_lite/src/gt_extractor_util.cpp +++ b/services/bundlemgr_lite/src/gt_extractor_util.cpp @@ -33,8 +33,8 @@ const uint8_t SHIFT_NUM = 8; uint32_t GtExtractorUtil::ReadInt(int32_t fp) { - char buf[INT_LENGTH] = {0}; - if (read(fp, buf, INT_LENGTH) != INT_LENGTH) { + unsigned char buf[INT_LENGTH] = {0}; + if (read(fp, buf, INT_LENGTH) != INT_LENGTH) { return UINT_MAX; } @@ -50,7 +50,7 @@ uint32_t GtExtractorUtil::ReadInt(int32_t fp) bool GtExtractorUtil::CheckMagicNumber(int32_t fp) { - char buf[MAGIC_NUMBER_LEN] = {0}; + unsigned char buf[MAGIC_NUMBER_LEN] = {0}; if (read(fp, buf, MAGIC_NUMBER_LEN) != MAGIC_NUMBER_LEN) { return false; } @@ -62,7 +62,7 @@ bool GtExtractorUtil::CheckMagicNumber(int32_t fp) uint64_t GtExtractorUtil::ReadLong(int32_t fp) { - char buf[LONG_LENGTH] = {0}; + unsigned char buf[LONG_LENGTH] = {0}; if (read(fp, buf, LONG_LENGTH) != LONG_LENGTH) { return 0; } @@ -77,9 +77,9 @@ uint64_t GtExtractorUtil::ReadLong(int32_t fp) return result; } -char *GtExtractorUtil::ReadString(int32_t fp, uint32_t len) +unsigned char *GtExtractorUtil::ReadString(int32_t fp, uint32_t len) { - char *buf = reinterpret_cast(UI_Malloc((len + 1) * sizeof(char))); + unsigned char *buf = reinterpret_cast(UI_Malloc((len + 1) * sizeof(unsigned char))); if (buf == nullptr) { return nullptr; } @@ -108,7 +108,7 @@ uint8_t GtExtractorUtil::ExtractFileHeaderInfo(int32_t fp, char **bundleName) return ERR_APPEXECFWK_INSTALL_FAILED_FILE_DATA_INVALID; } - if ((*bundleName = ReadString(fp, bundleNameLen)) == nullptr) { + if ((*bundleName = (char *)ReadString(fp, bundleNameLen)) == nullptr) { return ERR_APPEXECFWK_INSTALL_FAILED_FILE_DATA_INVALID; } return ERR_OK; @@ -136,7 +136,7 @@ uint8_t GtExtractorUtil::ExtractFileAttr(int32_t fp, char **fileName, char **rel return ERR_APPEXECFWK_INSTALL_FAILED_FILE_DATA_INVALID; } - if ((*fileName = ReadString(fp, nameLen)) == nullptr) { + if ((*fileName = (char *)ReadString(fp, nameLen)) == nullptr) { HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] Read fileName fail"); return ERR_APPEXECFWK_INSTALL_FAILED_FILE_DATA_INVALID; } @@ -146,7 +146,7 @@ uint8_t GtExtractorUtil::ExtractFileAttr(int32_t fp, char **fileName, char **rel HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] Read path Int fail"); return ERR_APPEXECFWK_INSTALL_FAILED_FILE_DATA_INVALID; } else { - if ((*relativeFilePath = ReadString(fp, pathLen)) == nullptr) { + if ((*relativeFilePath = (char *)ReadString(fp, pathLen)) == nullptr) { HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] Read relativeFilePath fail"); return ERR_APPEXECFWK_INSTALL_FAILED_FILE_DATA_INVALID; } @@ -168,7 +168,7 @@ uint8_t GtExtractorUtil::ExtractFileAttr(int32_t fp, char **fileName, uint32_t & return ERR_APPEXECFWK_INSTALL_FAILED_FILE_DATA_INVALID; } - if ((*fileName = ReadString(fp, nameLen)) == nullptr) { + if ((*fileName = (char *)ReadString(fp, nameLen)) == nullptr) { HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] Read fileName fail"); return ERR_APPEXECFWK_INSTALL_FAILED_FILE_DATA_INVALID; } diff --git a/utils/bundle_lite/adapter.h b/utils/bundle_lite/adapter.h old mode 100755 new mode 100644