From f7e8b40fcc5ef2b368bc93e6ef44989bc3c270a9 Mon Sep 17 00:00:00 2001 From: wangdengjia Date: Mon, 9 Aug 2021 11:13:52 +0800 Subject: [PATCH] IssueNo:#I44HOB Description:change uninstall callback Sig:appexecfwk Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: wangdengjia --- .../include/bundlems_slite_client.h | 2 - .../src/slite/bundle_manager_inner.cpp | 5 -- .../src/slite/bundlems_slite_client.cpp | 8 --- .../bundlemgr_lite/bundle_service_interface.h | 1 - .../bundlemgr_lite/slite/bundle_install_msg.h | 21 ++------ .../include/bundle_mgr_slite_feature.h | 1 - .../include/gt_bundle_manager_service.h | 9 +--- .../src/bundle_mgr_slite_feature.cpp | 6 --- .../src/gt_bundle_manager_service.cpp | 50 +++++-------------- 9 files changed, 17 insertions(+), 86 deletions(-) diff --git a/frameworks/bundle_lite/include/bundlems_slite_client.h b/frameworks/bundle_lite/include/bundlems_slite_client.h index 2c92dd4..a96f37d 100755 --- a/frameworks/bundle_lite/include/bundlems_slite_client.h +++ b/frameworks/bundle_lite/include/bundlems_slite_client.h @@ -47,8 +47,6 @@ public: bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t *installProcess) const; - bool GetUninstallState(const char *bundleName, UninstallState *uninstallState) const; - uint32_t GetBundleSize(const char *bundleName) const; private: diff --git a/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp b/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp index 23e0083..04c4e1b 100755 --- a/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp +++ b/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp @@ -24,11 +24,6 @@ bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t return OHOS::BundleMsClient::GetInstance().GetInstallState(bundleName, installState, installProcess); } -bool GetUninstallState(const char *bundleName, UninstallState *uninstallState) -{ - return OHOS::BundleMsClient::GetInstance().GetUninstallState(bundleName, uninstallState); -} - uint32_t GetBundleSize(const char *bundleName) { return OHOS::BundleMsClient::GetInstance().GetBundleSize(bundleName); diff --git a/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp b/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp index e8f0d77..ba326bc 100755 --- a/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp +++ b/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp @@ -158,14 +158,6 @@ bool BundleMsClient::GetInstallState (const char *bundleName, InstallState *inst return bmsProxy_->GetInstallState(bundleName, installState, installProcess); } -bool BundleMsClient::GetUninstallState (const char *bundleName, UninstallState *uninstallState) const -{ - if (!Initialize()) { - return false; - } - return bmsProxy_->GetUninstallState(bundleName, uninstallState); -} - uint32_t BundleMsClient::GetBundleSize (const char *bundleName) const { if (!Initialize()) { diff --git a/interfaces/innerkits/bundlemgr_lite/bundle_service_interface.h b/interfaces/innerkits/bundlemgr_lite/bundle_service_interface.h index 064633e..fec629b 100755 --- a/interfaces/innerkits/bundlemgr_lite/bundle_service_interface.h +++ b/interfaces/innerkits/bundlemgr_lite/bundle_service_interface.h @@ -50,7 +50,6 @@ struct BmsSliteInterface { uint8_t (*GetBundleInfo)(const char *bundleName, int32_t flags, BundleInfo *bundleInfo); uint8_t (*GetBundleInfos)(int32_t flags, BundleInfo **bundleInfos, int32_t *len); bool (*GetInstallState)(const char *bundleName, InstallState *installState, uint8_t *installProcess); - bool (*GetUninstallState)(const char *bundleName, UninstallState *uninstallState); uint32_t (*GetBundleSize)(const char *bundleName); }; #ifdef __cplusplus diff --git a/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h b/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h index a4f844d..77523d5 100644 --- a/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h +++ b/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h @@ -27,7 +27,10 @@ extern "C" { typedef enum { BUNDLE_INSTALL_DOING = 0, BUNDLE_INSTALL_OK = 1, - BUNDLE_INSTALL_FAIL = 2 + BUNDLE_INSTALL_FAIL = 2, + BUNDLE_UNINSTALL_DOING = 3, + BUNDLE_UNINSTALL_OK = 4, + BUNDLE_UNINSTALL_FAIL = 5 } InstallState; typedef struct { @@ -39,12 +42,6 @@ typedef struct { uint8_t installProcess; } BundleInstallMsg; -typedef enum { - BUNDLE_UNINSTALL_DOING = 0, - BUNDLE_UNINSTALL_OK = 1, - BUNDLE_UNINSTALL_FAIL = 2 -} UninstallState; - /** * @brief Get the install state and install process of the bundle. * @@ -58,16 +55,6 @@ typedef enum { */ bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t *installProcess); -/** - * @brief Get the uninstall state and uninstall state of the bundle. - * - * @param bundleName Indicates the name of the bundle. - * @param uninstallState Obtains uninstall state. - * @return Returns success or not. - * - */ -bool GetUninstallState(const char *bundleName, UninstallState *uninstallState); - /** * @brief Get the bundle size. * diff --git a/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h b/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h index 3008e5b..b81bdf4 100755 --- a/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h +++ b/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h @@ -36,7 +36,6 @@ public: static uint8_t GetBundleInfo(const char *bundleName, int32_t flags, BundleInfo *bundleInfo); static uint8_t GetBundleInfos(int32_t flags, BundleInfo **bundleInfos, int32_t *len); static bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t *installProcess); - static bool GetUninstallState(const char *bundleName, UninstallState *uninstallState); static uint32_t GetBundleSize (const char *bundleName); static BundleMgrSliteFeature *GetInstance() diff --git a/services/bundlemgr_lite/include/gt_bundle_manager_service.h b/services/bundlemgr_lite/include/gt_bundle_manager_service.h index 8cbecf4..4f0564b 100755 --- a/services/bundlemgr_lite/include/gt_bundle_manager_service.h +++ b/services/bundlemgr_lite/include/gt_bundle_manager_service.h @@ -49,11 +49,6 @@ typedef enum { BUNDLE_UPDATE, } BundleState; -typedef struct { - char *bundleName; - UninstallState uninstallState; -} BundleUninstallMsg; - class GtManagerService { public: static GtManagerService &GetInstance() @@ -79,10 +74,9 @@ public: void ReduceNumOfThirdBundles(); int32_t ReportInstallCallback(uint8_t errCode, uint8_t installState, uint8_t process, InstallerCallback installerCallback); - int32_t ReportUninstallCallback(uint8_t errCode, char *bundleName, + int32_t ReportUninstallCallback(uint8_t errCode, uint8_t installState, char *bundleName, uint8_t process, InstallerCallback installerCallback); bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t *installProcess); - bool GetUninstallState(const char *bundleName, UninstallState *uninstallState); uint32_t GetBundleSize(const char *bundleName); private: @@ -113,7 +107,6 @@ private: BundleMap *bundleMap_; List *bundleResList_; BundleInstallMsg *bundleInstallMsg_; - BundleUninstallMsg *bundleUninstallMsg_; char *jsEngineVer_; uint32_t installedThirdBundleNum_; }; diff --git a/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp b/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp index 2fcbcd5..5b12cff 100755 --- a/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp +++ b/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp @@ -33,7 +33,6 @@ BundleMgrSliteFeatureImpl g_bmsSliteImpl = { .GetBundleInfo = BundleMgrSliteFeature::GetBundleInfo, .GetBundleInfos = BundleMgrSliteFeature::GetBundleInfos, .GetInstallState = BundleMgrSliteFeature::GetInstallState, - .GetUninstallState = BundleMgrSliteFeature::GetUninstallState, .GetBundleSize = BundleMgrSliteFeature::GetBundleSize, DEFAULT_IUNKNOWN_ENTRY_END }; @@ -129,11 +128,6 @@ bool BundleMgrSliteFeature::GetInstallState(const char *bundleName, InstallState return OHOS::GtManagerService::GetInstance().GetInstallState(bundleName, installState, installProcess); } -bool BundleMgrSliteFeature::GetUninstallState(const char *bundleName, UninstallState *uninstallState) -{ - return OHOS::GtManagerService::GetInstance().GetUninstallState(bundleName, uninstallState); -} - uint32_t BundleMgrSliteFeature::GetBundleSize(const char *bundleName) { return OHOS::GtManagerService::GetInstance().GetBundleSize(bundleName); diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index 86f97cc..a8eb947 100755 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -49,7 +49,6 @@ GtManagerService::GtManagerService() bundleResList_ = new List(); bundleMap_ = BundleMap::GetInstance(); bundleInstallMsg_ = nullptr; - bundleUninstallMsg_ = nullptr; jsEngineVer_ = nullptr; installedThirdBundleNum_ = 0; } @@ -150,30 +149,19 @@ bool GtManagerService::Uninstall(const char *bundleName, const InstallParam *ins } SetCurrentBundle(innerBundleName); - bundleUninstallMsg_ = reinterpret_cast(AdapterMalloc(sizeof(BundleUninstallMsg))); - if (bundleUninstallMsg_ == nullptr) { - return false; - } - if (memset_s(bundleUninstallMsg_, sizeof(BundleUninstallMsg), 0, sizeof(BundleUninstallMsg)) != EOK) { - AdapterFree(bundleUninstallMsg_); - return false; - } - bundleUninstallMsg_->bundleName = innerBundleName; - bundleUninstallMsg_->uninstallState = BUNDLE_UNINSTALL_DOING; - - (void) ReportUninstallCallback(OPERATION_DOING, innerBundleName, BMS_UNINSTALLATION_START, installerCallback); + (void) ReportUninstallCallback(OPERATION_DOING, BUNDLE_UNINSTALL_DOING, innerBundleName, + BMS_UNINSTALLATION_START, installerCallback); uint8_t ret = installer_->Uninstall(innerBundleName); if (ret == 0) { - bundleUninstallMsg_->uninstallState = BUNDLE_UNINSTALL_OK; + (void) ReportUninstallCallback(ret, BUNDLE_UNINSTALL_OK, innerBundleName, + BMS_INSTALLATION_COMPLETED, installerCallback); } else { - bundleUninstallMsg_->uninstallState = BUNDLE_UNINSTALL_FAIL; + (void) ReportUninstallCallback(ret, BUNDLE_UNINSTALL_FAIL, innerBundleName, + BMS_INSTALLATION_COMPLETED, installerCallback); } - (void) ReportUninstallCallback(ret, innerBundleName, BMS_INSTALLATION_COMPLETED, installerCallback); SetCurrentBundle(nullptr); AdapterFree(innerBundleName); - AdapterFree(bundleUninstallMsg_); - bundleUninstallMsg_ = nullptr; return true; } @@ -224,21 +212,6 @@ uint32_t GtManagerService::GetBundleSize(const char *bundleName) return codeBundleSize + dataBundleSize; } -bool GtManagerService::GetUninstallState(const char *bundleName, UninstallState *uninstallState) -{ - BundleInfo *uninstalledInfo = bundleMap_->Get(bundleName); - if (uninstalledInfo == nullptr) { - *uninstallState = BUNDLE_UNINSTALL_OK; - return true; - } - if (strcmp(bundleName, bundleUninstallMsg_->bundleName) == 0) { - *uninstallState = bundleUninstallMsg_->uninstallState; - return true; - } - *uninstallState = BUNDLE_UNINSTALL_DOING; - return true; -} - uint8_t GtManagerService::QueryAbilityInfo(const Want *want, AbilityInfo *abilityInfo) { if (want->element == nullptr) { @@ -909,19 +882,20 @@ int32_t GtManagerService::ReportInstallCallback(uint8_t errCode, uint8_t install return 0; } -int32_t GtManagerService::ReportUninstallCallback(uint8_t errCode, char *bundleName, +int32_t GtManagerService::ReportUninstallCallback(uint8_t errCode, uint8_t installState, char *bundleName, uint8_t process, InstallerCallback installerCallback) { if (installerCallback == nullptr) { return -1; } - BundleInstallMsg *bundleUninstallMsg = reinterpret_cast(AdapterMalloc(sizeof(BundleInstallMsg))); + BundleInstallMsg *bundleInstallMsg = reinterpret_cast(AdapterMalloc(sizeof(BundleInstallMsg))); if (bundleUninstallMsg == nullptr) { return -1; } - bundleUninstallMsg->bundleName = bundleName; - bundleUninstallMsg->installProcess = process; - (*installerCallback)(errCode, bundleUninstallMsg); + bundleInstallMsg->installState = static_cast(installState); + bundleInstallMsg->bundleName = bundleName; + bundleInstallMsg->installProcess = process; + (*installerCallback)(errCode, bundleInstallMsg); return 0; } -- Gitee