mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2024-11-26 17:01:24 +00:00
commit
ff0a13c7ff
@ -236,11 +236,7 @@ public:
|
||||
ErrCode AddUserDirDeleteDfx(int32_t userId);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Get the installd proxy object.
|
||||
* @return Returns true if the installd proxy object got successfully; returns false otherwise.
|
||||
*/
|
||||
bool GetInstalldProxy();
|
||||
sptr<IInstalld> GetInstalldProxy();
|
||||
bool LoadInstalldService();
|
||||
|
||||
template<typename F, typename... Args>
|
||||
@ -249,12 +245,11 @@ private:
|
||||
int32_t maxRetryTimes = 2;
|
||||
ErrCode errCode = ERR_APPEXECFWK_INSTALLD_SERVICE_DIED;
|
||||
for (int32_t retryTimes = 0; retryTimes < maxRetryTimes; retryTimes++) {
|
||||
if (!GetInstalldProxy()) {
|
||||
auto proxy = GetInstalldProxy();
|
||||
if (proxy == nullptr) {
|
||||
return ERR_APPEXECFWK_INSTALLD_GET_PROXY_ERROR;
|
||||
}
|
||||
if (installdProxy_ != nullptr) {
|
||||
errCode = (installdProxy_->*func)(std::forward<Args>(args)...);
|
||||
}
|
||||
errCode = (proxy->*func)(std::forward<Args>(args)...);
|
||||
if (errCode == ERR_APPEXECFWK_INSTALLD_SERVICE_DIED) {
|
||||
APP_LOGE("CallService failed, retry times: %{public}d", retryTimes + 1);
|
||||
ResetInstalldProxy();
|
||||
|
@ -268,31 +268,31 @@ bool InstalldClient::LoadInstalldService()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InstalldClient::GetInstalldProxy()
|
||||
sptr<IInstalld> InstalldClient::GetInstalldProxy()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(getProxyMutex_);
|
||||
if (installdProxy_ != nullptr) {
|
||||
APP_LOGD("installd ready");
|
||||
return true;
|
||||
return installdProxy_;
|
||||
}
|
||||
|
||||
APP_LOGI("try to get installd proxy");
|
||||
if (!LoadInstalldService()) {
|
||||
APP_LOGE("load installd service failed");
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
if ((installdProxy_ == nullptr) || (installdProxy_->AsObject() == nullptr)) {
|
||||
APP_LOGE("the installd proxy or remote object is null");
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
recipient_ = new (std::nothrow) InstalldDeathRecipient();
|
||||
if (recipient_ == nullptr) {
|
||||
APP_LOGE("the death recipient is nullptr");
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
installdProxy_->AsObject()->AddDeathRecipient(recipient_);
|
||||
return true;
|
||||
return installdProxy_;
|
||||
}
|
||||
|
||||
ErrCode InstalldClient::ScanDir(
|
||||
@ -500,7 +500,7 @@ void InstalldClient::OnLoadSystemAbilityFail()
|
||||
|
||||
bool InstalldClient::StartInstalldService()
|
||||
{
|
||||
return GetInstalldProxy();
|
||||
return GetInstalldProxy() != nullptr;
|
||||
}
|
||||
|
||||
ErrCode InstalldClient::ExtractEncryptedSoFiles(const std::string &hapPath, const std::string &realSoFilesPath,
|
||||
|
@ -216,28 +216,25 @@ void InstalldClient::ResetInstalldProxy()
|
||||
installdProxy_ = nullptr;
|
||||
}
|
||||
|
||||
bool InstalldClient::GetInstalldProxy()
|
||||
sptr<IInstalld> InstalldClient::GetInstalldProxy()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (installdProxy_ == nullptr) {
|
||||
APP_LOGD("try to get installd proxy");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (installdProxy_ == nullptr) {
|
||||
sptr<IInstalld> tempProxy =
|
||||
iface_cast<IInstalld>(SystemAbilityHelper::GetSystemAbility(INSTALLD_SERVICE_ID));
|
||||
if ((tempProxy == nullptr) || (tempProxy->AsObject() == nullptr)) {
|
||||
APP_LOGE("the installd proxy or remote object is null");
|
||||
return false;
|
||||
}
|
||||
recipient_ = new (std::nothrow) InstalldDeathRecipient();
|
||||
if (recipient_ == nullptr) {
|
||||
APP_LOGE("the death recipient is nullptr");
|
||||
return false;
|
||||
}
|
||||
tempProxy->AsObject()->AddDeathRecipient(recipient_);
|
||||
installdProxy_ = tempProxy;
|
||||
sptr<IInstalld> tempProxy =
|
||||
iface_cast<IInstalld>(SystemAbilityHelper::GetSystemAbility(INSTALLD_SERVICE_ID));
|
||||
if ((tempProxy == nullptr) || (tempProxy->AsObject() == nullptr)) {
|
||||
APP_LOGE("the installd proxy or remote object is null");
|
||||
return nullptr;
|
||||
}
|
||||
recipient_ = new (std::nothrow) InstalldDeathRecipient();
|
||||
if (recipient_ == nullptr) {
|
||||
APP_LOGE("the death recipient is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
tempProxy->AsObject()->AddDeathRecipient(recipient_);
|
||||
installdProxy_ = tempProxy;
|
||||
}
|
||||
return true;
|
||||
return installdProxy_;
|
||||
}
|
||||
|
||||
ErrCode InstalldClient::ScanDir(
|
||||
@ -465,7 +462,7 @@ ErrCode InstalldClient::DeleteEncryptionKeyId(const std::string &bundleName, con
|
||||
|
||||
bool InstalldClient::StartInstalldService()
|
||||
{
|
||||
return GetInstalldProxy();
|
||||
return GetInstalldProxy() != nullptr;
|
||||
}
|
||||
|
||||
ErrCode InstalldClient::GetExtensionSandboxTypeList(std::vector<std::string> &typeList)
|
||||
|
@ -146,9 +146,9 @@ void InstalldClient::ResetInstalldProxy()
|
||||
return;
|
||||
}
|
||||
|
||||
bool InstalldClient::GetInstalldProxy()
|
||||
sptr<IInstalld> InstalldClient::GetInstalldProxy()
|
||||
{
|
||||
return true;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ErrCode InstalldClient::ScanDir(
|
||||
@ -243,7 +243,7 @@ ErrCode InstalldClient::MoveFiles(const std::string &srcDir, const std::string &
|
||||
|
||||
bool InstalldClient::StartInstalldService()
|
||||
{
|
||||
return GetInstalldProxy();
|
||||
return GetInstalldProxy() != nullptr;
|
||||
}
|
||||
|
||||
ErrCode InstalldClient::ExtractDriverSoFiles(const std::string &srcPath,
|
||||
|
Loading…
Reference in New Issue
Block a user