diff --git a/services/bundlemgr/include/free_install/bundle_connect_ability_mgr.h b/services/bundlemgr/include/free_install/bundle_connect_ability_mgr.h index 9ad7d62d..6d0a4d6d 100644 --- a/services/bundlemgr/include/free_install/bundle_connect_ability_mgr.h +++ b/services/bundlemgr/include/free_install/bundle_connect_ability_mgr.h @@ -75,7 +75,7 @@ private: * @param userId Designation User ID. * @return Returns true if create async task successfully called; returns false otherwise. */ - bool SilentInstallSafely(const TargetAbilityInfo &targetAbilityInfo, const Want &want, + bool SilentInstall(const TargetAbilityInfo &targetAbilityInfo, const Want &want, const sptr &callerToken, int32_t userId); /** @@ -86,7 +86,7 @@ private: * @param userId Designation User ID. * @return Returns true if create async task successfully called; returns false otherwise. */ - bool UpgradeCheckSafely(const TargetAbilityInfo &targetAbilityInfo, const Want &want, + bool UpgradeCheck(const TargetAbilityInfo &targetAbilityInfo, const Want &want, const sptr &callerToken, int32_t userId); /** @@ -97,7 +97,7 @@ private: * @param userId Designation User ID. * @return Returns true if create async task successfully called; returns false otherwise. */ - bool UpgradeInstallSafely(const TargetAbilityInfo &targetAbilityInfo, const Want &want, + bool UpgradeInstall(const TargetAbilityInfo &targetAbilityInfo, const Want &want, const sptr &callerToken, int32_t userId); /** @@ -214,8 +214,8 @@ private: const sptr &callBack, InnerBundleInfo &innerBundleInfo); bool GetAbilityMgrProxy(); - void WaitFormConnecting(std::unique_lock &lock); - void WaitFormConnected(std::unique_lock &lock); + void WaitFromConnecting(std::unique_lock &lock); + void WaitFromConnected(std::unique_lock &lock); mutable std::atomic transactId_ = 0; std::condition_variable cv_; diff --git a/services/bundlemgr/include/free_install/i_service_center_status_callback.h b/services/bundlemgr/include/free_install/i_service_center_status_callback.h index 753d7398..b205010e 100644 --- a/services/bundlemgr/include/free_install/i_service_center_status_callback.h +++ b/services/bundlemgr/include/free_install/i_service_center_status_callback.h @@ -36,7 +36,7 @@ public: * @brief Will be execute when free install is complete. * @param installResult the json of InstallResult */ - virtual void OnInstallFinished(std::string installResult) = 0; + virtual int32_t OnInstallFinished(std::string installResult) = 0; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/services/bundlemgr/include/free_install/service_center_status_callback.h b/services/bundlemgr/include/free_install/service_center_status_callback.h index d1ace4d1..08a20e82 100644 --- a/services/bundlemgr/include/free_install/service_center_status_callback.h +++ b/services/bundlemgr/include/free_install/service_center_status_callback.h @@ -38,7 +38,7 @@ public: * @brief Free install is complete. * @param installResult Install result */ - void OnInstallFinished(std::string installResult); + int32_t OnInstallFinished(std::string installResult); private: std::weak_ptr server_; diff --git a/services/bundlemgr/include/free_install/service_center_status_callback_stub.h b/services/bundlemgr/include/free_install/service_center_status_callback_stub.h index 3fb0ffd8..4a9d462c 100644 --- a/services/bundlemgr/include/free_install/service_center_status_callback_stub.h +++ b/services/bundlemgr/include/free_install/service_center_status_callback_stub.h @@ -37,7 +37,6 @@ public: private: DISALLOW_COPY_AND_MOVE(ServiceCenterStatusCallbackStub); - int32_t OnInstallFinishedInner(MessageParcel &data, MessageParcel &reply); }; } // namespace AppExecFwk } // namespace OHOS diff --git a/services/bundlemgr/src/free_install/bundle_connect_ability_mgr.cpp b/services/bundlemgr/src/free_install/bundle_connect_ability_mgr.cpp index 9ebca746..3f055140 100644 --- a/services/bundlemgr/src/free_install/bundle_connect_ability_mgr.cpp +++ b/services/bundlemgr/src/free_install/bundle_connect_ability_mgr.cpp @@ -17,8 +17,6 @@ #include "app_log_wrapper.h" #include "bundle_mgr_service.h" -#include "event_handler.h" -#include "event_runner.h" #include "free_install_params.h" #include "json_util.h" #include "parcel.h" @@ -33,6 +31,7 @@ const std::u16string ATOMIC_SERVICE_STATUS_CALLBACK_TOKEN = u"ohos.aafwk.IAtomic const std::string serviceCenterBundleName = "com.ohos.hag.famanager"; const std::string serviceCenterAbilityName = "com.ohos.hag.famanager.HapInstallServiceAbility"; constexpr uint32_t FREE_INSTALL_DONE = 0; +constexpr uint32_t DEFAULT_VERSION = 1; constexpr uint32_t CALLING_TYPE_HARMONY = 2; constexpr uint32_t BIT_ONE_COMPATIBLE = 0; constexpr uint32_t BIT_TWO_BACK_MODE = 1; @@ -90,10 +89,10 @@ BundleConnectAbilityMgr::~BundleConnectAbilityMgr() } } -bool BundleConnectAbilityMgr::SilentInstallSafely(const TargetAbilityInfo &targetAbilityInfo, const Want &want, +bool BundleConnectAbilityMgr::SilentInstall(const TargetAbilityInfo &targetAbilityInfo, const Want &want, const sptr &callerToken, int32_t userId) { - APP_LOGI("SilentInstallSafely"); + APP_LOGI("SilentInstall"); if (handler_ == nullptr) { SendCallBack(FreeInstallErrorCode::UNDEFINED_ERROR, want, userId, targetAbilityInfo.targetInfo.transactId); @@ -101,18 +100,18 @@ bool BundleConnectAbilityMgr::SilentInstallSafely(const TargetAbilityInfo &targe APP_LOGE("handler is null"); return false; } - auto silentInstallSafelyFunc = [this, targetAbilityInfo, want, userId, callerToken]() { + auto silentInstallFunc = [this, targetAbilityInfo, want, userId, callerToken]() { int32_t flag = ServiceCenterFunction::CONNECT_SILENT_INSTALL; this->SendRequestToServiceCenter(flag, targetAbilityInfo, want, userId, callerToken); }; - handler_->PostTask(silentInstallSafelyFunc, targetAbilityInfo.targetInfo.transactId.c_str()); + handler_->PostTask(silentInstallFunc, targetAbilityInfo.targetInfo.transactId.c_str()); return true; } -bool BundleConnectAbilityMgr::UpgradeCheckSafely(const TargetAbilityInfo &targetAbilityInfo, const Want &want, +bool BundleConnectAbilityMgr::UpgradeCheck(const TargetAbilityInfo &targetAbilityInfo, const Want &want, const sptr &callerToken, int32_t userId) { - APP_LOGI("UpgradeCheckSafely"); + APP_LOGI("UpgradeCheck"); if (handler_ == nullptr) { SendCallBack(FreeInstallErrorCode::UNDEFINED_ERROR, want, userId, targetAbilityInfo.targetInfo.transactId); @@ -120,18 +119,18 @@ bool BundleConnectAbilityMgr::UpgradeCheckSafely(const TargetAbilityInfo &target APP_LOGE("handler is null"); return false; } - auto upgradeCheckSafelyFunc = [this, targetAbilityInfo, want, userId, callerToken]() { + auto upgradeCheckFunc = [this, targetAbilityInfo, want, userId, callerToken]() { int32_t flag = ServiceCenterFunction::CONNECT_UPGRADE_CHECK; this->SendRequestToServiceCenter(flag, targetAbilityInfo, want, userId, callerToken); }; - handler_->PostTask(upgradeCheckSafelyFunc, targetAbilityInfo.targetInfo.transactId.c_str()); + handler_->PostTask(upgradeCheckFunc, targetAbilityInfo.targetInfo.transactId.c_str()); return true; } -bool BundleConnectAbilityMgr::UpgradeInstallSafely(const TargetAbilityInfo &targetAbilityInfo, const Want &want, +bool BundleConnectAbilityMgr::UpgradeInstall(const TargetAbilityInfo &targetAbilityInfo, const Want &want, const sptr &callerToken, int32_t userId) { - APP_LOGI("UpgradeInstallSafely"); + APP_LOGI("UpgradeInstall"); if (handler_ == nullptr) { SendCallBack(FreeInstallErrorCode::UNDEFINED_ERROR, want, userId, targetAbilityInfo.targetInfo.transactId); @@ -139,11 +138,11 @@ bool BundleConnectAbilityMgr::UpgradeInstallSafely(const TargetAbilityInfo &targ APP_LOGE("handler is null"); return false; } - auto upgradeInstallSafelyFunc = [this, targetAbilityInfo, want, userId, callerToken]() { + auto upgradeInstallFunc = [this, targetAbilityInfo, want, userId, callerToken]() { int32_t flag = ServiceCenterFunction::CONNECT_UPGRADE_INSTALL; this->SendRequestToServiceCenter(flag, targetAbilityInfo, want, userId, callerToken); }; - handler_->PostTask(upgradeInstallSafelyFunc, targetAbilityInfo.targetInfo.transactId.c_str()); + handler_->PostTask(upgradeInstallFunc, targetAbilityInfo.targetInfo.transactId.c_str()); return true; } @@ -178,7 +177,7 @@ void BundleConnectAbilityMgr::DisconnectAbility() } } -void BundleConnectAbilityMgr::WaitFormConnecting(std::unique_lock &lock) +void BundleConnectAbilityMgr::WaitFromConnecting(std::unique_lock &lock) { APP_LOGI("ConnectAbility await start CONNECTING"); while (connectState_ == ServiceCenterConnectState::CONNECTING) { @@ -187,7 +186,7 @@ void BundleConnectAbilityMgr::WaitFormConnecting(std::unique_lock &l APP_LOGI("ConnectAbility await end CONNECTING"); } -void BundleConnectAbilityMgr::WaitFormConnected(std::unique_lock &lock) +void BundleConnectAbilityMgr::WaitFromConnected(std::unique_lock &lock) { APP_LOGI("ConnectAbility await start CONNECTED"); while (connectState_ != ServiceCenterConnectState::CONNECTED) { @@ -201,7 +200,7 @@ bool BundleConnectAbilityMgr::ConnectAbility(const Want &want, const sptr lock(mutex_); if (connectState_ == ServiceCenterConnectState::CONNECTING) { - WaitFormConnecting(lock); + WaitFromConnecting(lock); } else if (connectState_ == ServiceCenterConnectState::DISCONNECTED) { connectState_ = ServiceCenterConnectState::CONNECTING; if (!GetAbilityMgrProxy()) { @@ -221,7 +220,7 @@ bool BundleConnectAbilityMgr::ConnectAbility(const Want &want, const sptrConnectAbility(want, serviceCenterConnection_, callerToken); if (result == ERR_OK) { if (connectState_ != ServiceCenterConnectState::CONNECTED) { - WaitFormConnected(lock); + WaitFromConnected(lock); serviceCenterRemoteObject_ = serviceCenterConnection_->GetRemoteObject(); } } else { @@ -450,7 +449,7 @@ void BundleConnectAbilityMgr::GetTargetAbilityInfo(const Want &want, InnerBundle targetInfo->callingAppType = CALLING_TYPE_HARMONY; targetAbilityInfo->targetInfo = *targetInfo; this->GetCallingInfo(innerBundleInfo, callingBundleNames, callingAppids); - targetAbilityInfo->version = std::to_string(innerBundleInfo.GetVersionCode()); + targetAbilityInfo->version = DEFAULT_VERSION; targetInfo->callingBundleNames = callingBundleNames; targetInfo->callingAppIds = callingAppids; } @@ -512,7 +511,7 @@ bool BundleConnectAbilityMgr::CheckIsModuleNeedUpdate( APP_LOGE("BundleConnectAbilityMgr::QueryAbilityInfo map emplace error"); CallAbilityManager(FreeInstallErrorCode::UNDEFINED_ERROR, want, userId, callBack); } - this->UpgradeInstallSafely(*targetAbilityInfo, want, nullptr, userId); + this->UpgradeInstall(*targetAbilityInfo, want, nullptr, userId); return true; } APP_LOGI("Module is not need update"); @@ -579,7 +578,7 @@ bool BundleConnectAbilityMgr::QueryAbilityInfo(const Want &want, int32_t flags, CallAbilityManager(FreeInstallErrorCode::UNDEFINED_ERROR, want, userId, callBack); return false; } - this->SilentInstallSafely(*targetAbilityInfo, want, nullptr, userId); + this->SilentInstall(*targetAbilityInfo, want, nullptr, userId); return false; } @@ -616,8 +615,7 @@ void BundleConnectAbilityMgr::UpgradeAtomicService(const Want &want, int32_t use APP_LOGE("BundleConnectAbilityMgr::QueryAbilityInfo map emplace error"); return; } - targetAbilityInfo->version = std::to_string(innerBundleInfo.GetVersionCode()); - this->UpgradeCheckSafely(*targetAbilityInfo, want, nullptr, userId); + this->UpgradeCheck(*targetAbilityInfo, want, nullptr, userId); } } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/services/bundlemgr/src/free_install/service_center_death_recipient.cpp b/services/bundlemgr/src/free_install/service_center_death_recipient.cpp index 13e07e06..ca47718f 100644 --- a/services/bundlemgr/src/free_install/service_center_death_recipient.cpp +++ b/services/bundlemgr/src/free_install/service_center_death_recipient.cpp @@ -73,7 +73,7 @@ void ServiceCenterDeathRecipient::SendCallBack(FreeInstallParams &freeInstallPar } MessageParcel reply; MessageOption option; - if (freeInstallParams.callback->SendRequest(FREE_INSTALL_DONE, data, reply, option) != OHOS::NO_ERROR) { + if (freeInstallParams.callback->SendRequest(FREE_INSTALL_DONE, data, reply, option) != ERR_OK) { APP_LOGE("BundleConnectAbilityMgr::SendCallBack SendRequest failed"); } freeInstallParamsMap_.erase(transactId); diff --git a/services/bundlemgr/src/free_install/service_center_status_callback.cpp b/services/bundlemgr/src/free_install/service_center_status_callback.cpp index dce34cf8..c1edab32 100644 --- a/services/bundlemgr/src/free_install/service_center_status_callback.cpp +++ b/services/bundlemgr/src/free_install/service_center_status_callback.cpp @@ -15,25 +15,24 @@ #include "service_center_status_callback.h" -#include "hilog_wrapper.h" - namespace OHOS { namespace AppExecFwk { ServiceCenterStatusCallback::ServiceCenterStatusCallback(const std::weak_ptr &server) : server_(server) { - HILOG_INFO("%{public}s", __func__); + APP_LOGI("%{public}s", __func__); } -void ServiceCenterStatusCallback::OnInstallFinished(std::string installResult) +int32_t ServiceCenterStatusCallback::OnInstallFinished(std::string installResult) { - HILOG_INFO("%{public}s", __func__); + APP_LOGI("%{public}s", __func__); auto server = server_.lock(); if (!server) { - HILOG_ERROR("pointer is nullptr."); - return; + APP_LOGE("pointer is nullptr."); + return ERR_INVALID_VALUE; } server->OnServiceCenterCall(installResult); + return ERR_OK; } } // namespace AppExecFwk } // namespace OHOS diff --git a/services/bundlemgr/src/free_install/service_center_status_callback_proxy.cpp b/services/bundlemgr/src/free_install/service_center_status_callback_proxy.cpp index 975d4657..dc59e3ca 100644 --- a/services/bundlemgr/src/free_install/service_center_status_callback_proxy.cpp +++ b/services/bundlemgr/src/free_install/service_center_status_callback_proxy.cpp @@ -15,7 +15,6 @@ #include "service_center_status_callback_proxy.h" -#include "hilog_wrapper.h" #include "ipc_types.h" #include "message_parcel.h" @@ -35,18 +34,18 @@ void ServiceCenterStatusCallbackProxy::OnRemoteInstallFinished(std::string insta MessageOption option; if (!data.WriteInterfaceToken(IServiceCenterStatusCallback::GetDescriptor())) { - HILOG_ERROR("Write interface token failed."); + APP_LOGE("Write interface token failed."); return; } if (!data.WriteString(installResult)) { - HILOG_ERROR("Write resultCode error."); + APP_LOGE("Write resultCode error."); return; } int32_t error = Remote()->SendRequest(0, data, reply, option); if (error != NO_ERROR) { - HILOG_ERROR("OnFinished fail, error: %{public}d", error); + APP_LOGE("OnFinished fail, error: %{public}d", error); } } } // namespace AppExecFwk diff --git a/services/bundlemgr/src/free_install/service_center_status_callback_stub.cpp b/services/bundlemgr/src/free_install/service_center_status_callback_stub.cpp index 36b2f09d..efbdcb48 100644 --- a/services/bundlemgr/src/free_install/service_center_status_callback_stub.cpp +++ b/services/bundlemgr/src/free_install/service_center_status_callback_stub.cpp @@ -15,9 +15,7 @@ #include "service_center_status_callback_stub.h" -#include "hilog_wrapper.h" -#include "ipc_types.h" -#include "json_util.h" +#include "app_log_wrapper.h" #include "message_parcel.h" #include "string_ex.h" @@ -28,18 +26,12 @@ ServiceCenterStatusCallbackStub::ServiceCenterStatusCallbackStub() APP_LOGI("ServiceCenterStatusCallbackStub is created"); } -int32_t ServiceCenterStatusCallbackStub::OnInstallFinishedInner(MessageParcel &data, MessageParcel &reply) -{ - auto result = data.ReadString16(); - OnInstallFinished(Str16ToStr8(result)); - return NO_ERROR; -} - int32_t ServiceCenterStatusCallbackStub::OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { data.ReadInterfaceToken(); - return (this->OnInstallFinishedInner)(data, reply); + auto result = data.ReadString16(); + return OnInstallFinished(Str16ToStr8(result)); } } // namespace AppExecFwk } // namespace OHOS