fix programming specification problem

Signed-off-by: s00494828 <shilei91@huawei.com>
Change-Id: Ie45d45758e0ec1d4bb2c241ac13d907d65eb5069
This commit is contained in:
s00494828
2022-05-16 09:29:29 +08:00
parent 346bb59ff4
commit 5012226e76
39 changed files with 190 additions and 180 deletions
@@ -505,16 +505,17 @@ ErrCode BundleManagerShellCommand::init()
{
ErrCode result = OHOS::ERR_OK;
if (!bundleMgrProxy_) {
if (bundleMgrProxy_ == nullptr) {
bundleMgrProxy_ = GetBundleMgrProxy();
if (bundleMgrProxy_) {
if (!bundleInstallerProxy_) {
if (bundleInstallerProxy_ == nullptr) {
bundleInstallerProxy_ = bundleMgrProxy_->GetBundleInstaller();
}
}
}
if (!bundleMgrProxy_ || !bundleInstallerProxy_ || !bundleInstallerProxy_->AsObject()) {
if ((bundleMgrProxy_ == nullptr) || (bundleInstallerProxy_ == nullptr) ||
(bundleInstallerProxy_->AsObject() == nullptr)) {
result = OHOS::ERR_INVALID_VALUE;
}
@@ -525,13 +526,13 @@ sptr<IBundleMgr> BundleManagerShellCommand::GetBundleMgrProxy() const
{
sptr<ISystemAbilityManager> systemAbilityManager =
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (!systemAbilityManager) {
if (systemAbilityManager == nullptr) {
APP_LOGE("failed to get system ability mgr.");
return nullptr;
}
sptr<IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
if (!remoteObject) {
if (remoteObject == nullptr) {
APP_LOGE("failed to get bundle manager proxy.");
return nullptr;
}
@@ -543,13 +544,13 @@ sptr<IBundleMgr> BundleManagerShellCommand::GetBundleMgrProxy() const
sptr<IBundleInstaller> BundleManagerShellCommand::GetInstallerProxy() const
{
sptr<IBundleMgr> bundleMgrProxy = GetBundleMgrProxy();
if (!bundleMgrProxy) {
if (bundleMgrProxy == nullptr) {
APP_LOGE("bundle mgr proxy is nullptr.");
return nullptr;
}
sptr<IBundleInstaller> installerProxy = bundleMgrProxy->GetBundleInstaller();
if (!installerProxy) {
if (installerProxy == nullptr) {
APP_LOGE("failed to get bundle installer proxy.");
return nullptr;
}
+1 -1
View File
@@ -28,7 +28,7 @@ public:
static bool CheckFileType(const std::string &fileName, const std::string &extensionName);
static bool CheckFileName(const std::string &fileName);
static bool CheckFileSize(const std::string &bundlePath, const int64_t fileSize);
static bool GetHapFilesFromBundlePath(const std::string& currentBundlePath, std::vector<std::string>& hapFileList);
static bool GetHapFilesFromBundlePath(const std::string &currentBundlePath, std::vector<std::string> &hapFileList);
};
} // AppExecFwk
} // OHOS
+11 -12
View File
@@ -91,15 +91,14 @@ bool BundleFileUtil::CheckFilePath(const std::vector<std::string> &bundlePaths,
return false;
}
return true;
} else {
APP_LOGD("bundlePaths has more than one element");
for (const std::string& bundlePath : bundlePaths) {
std::string realPath = "";
if (!CheckFilePath(bundlePath, realPath)) {
return false;
}
realPaths.emplace_back(realPath);
}
APP_LOGD("bundlePaths has more than one element");
for (const std::string &bundlePath : bundlePaths) {
std::string realPath = "";
if (!CheckFilePath(bundlePath, realPath)) {
return false;
}
realPaths.emplace_back(realPath);
}
APP_LOGD("finish check file path");
return true;
@@ -148,8 +147,8 @@ bool BundleFileUtil::CheckFileSize(const std::string &bundlePath, const int64_t
return true;
}
bool BundleFileUtil::GetHapFilesFromBundlePath(const std::string& currentBundlePath,
std::vector<std::string>& hapFileList)
bool BundleFileUtil::GetHapFilesFromBundlePath(const std::string &currentBundlePath,
std::vector<std::string> &hapFileList)
{
APP_LOGD("GetHapFilesFromBundlePath with path is %{public}s", currentBundlePath.c_str());
if (currentBundlePath.empty()) {
@@ -179,8 +178,8 @@ bool BundleFileUtil::GetHapFilesFromBundlePath(const std::string& currentBundleP
hapFileList.emplace_back(realPath);
APP_LOGD("find hap path %{public}s", realPath.c_str());
if (!hapFileList.empty() && (hapFileList.size() > MAX_HAP_NUMBER)) {
APP_LOGE("reach the max hap number 128, stop to add more.");
if (hapFileList.size() > MAX_HAP_NUMBER) {
APP_LOGE("reach the max hap number %{public}hhu, stop to add more.", MAX_HAP_NUMBER);
closedir(dir);
return false;
}
@@ -56,7 +56,7 @@ bool BundleInstallerProxy::Install(
PARCEL_WRITE(data, String16, Str8ToStr16(bundlePath));
PARCEL_WRITE(data, Parcelable, &installParam);
if (!statusReceiver) {
if (statusReceiver == nullptr) {
APP_LOGE("fail to install, for statusReceiver is nullptr");
return false;
}
@@ -84,7 +84,7 @@ bool BundleInstallerProxy::Install(const std::vector<std::string> &bundleFilePat
}
PARCEL_WRITE(data, Parcelable, &installParam);
if (!statusReceiver) {
if (statusReceiver == nullptr) {
APP_LOGE("fail to install, for statusReceiver is nullptr");
return false;
}
@@ -108,7 +108,7 @@ bool BundleInstallerProxy::Recover(const std::string &bundleName,
PARCEL_WRITE(data, String16, Str8ToStr16(bundleName));
PARCEL_WRITE(data, Parcelable, &installParam);
if (!statusReceiver) {
if (statusReceiver == nullptr) {
APP_LOGE("fail to install, for statusReceiver is nullptr");
return false;
}
@@ -132,7 +132,7 @@ bool BundleInstallerProxy::Uninstall(
PARCEL_WRITE_INTERFACE_TOKEN(data, GetDescriptor());
PARCEL_WRITE(data, String16, Str8ToStr16(bundleName));
PARCEL_WRITE(data, Parcelable, &installParam);
if (!statusReceiver) {
if (statusReceiver == nullptr) {
APP_LOGE("fail to uninstall, for statusReceiver is nullptr");
return false;
}
@@ -156,7 +156,7 @@ bool BundleInstallerProxy::Uninstall(const std::string &bundleName, const std::s
PARCEL_WRITE(data, String16, Str8ToStr16(bundleName));
PARCEL_WRITE(data, String16, Str8ToStr16(modulePackage));
PARCEL_WRITE(data, Parcelable, &installParam);
if (!statusReceiver) {
if (statusReceiver == nullptr) {
APP_LOGE("fail to uninstall, for statusReceiver is nullptr");
return false;
}
@@ -269,12 +269,12 @@ sptr<IBundleStreamInstaller> BundleInstallerProxy::CreateStreamInstaller(const I
}
uint32_t streamInstallerId = reply.ReadUint32();
sptr<IRemoteObject> object = reply.ReadRemoteObject();
if (!object) {
if (object == nullptr) {
APP_LOGE("CreateStreamInstaller create nullptr remote object");
return nullptr;
}
sptr<IBundleStreamInstaller> streamInstaller = iface_cast<IBundleStreamInstaller>(object);
if (!streamInstaller) {
if (streamInstaller == nullptr) {
APP_LOGE("CreateStreamInstaller failed");
return streamInstaller;
}
@@ -396,7 +396,7 @@ bool BundleInstallerProxy::SendInstallRequest(const uint32_t& code, MessageParce
MessageOption& option)
{
sptr<IRemoteObject> remote = Remote();
if (!remote) {
if (remote == nullptr) {
APP_LOGE("fail to uninstall, for Remote() is nullptr");
return false;
}
@@ -661,7 +661,7 @@ ErrCode BundleMgrHost::HandleQueryAbilityInfo(Parcel &data, Parcel &reply)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (!want) {
if (want == nullptr) {
APP_LOGE("ReadParcelable<want> failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@@ -685,7 +685,7 @@ ErrCode BundleMgrHost::HandleQueryAbilityInfoMutiparam(Parcel &data, Parcel &rep
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (!want) {
if (want == nullptr) {
APP_LOGE("ReadParcelable<want> failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@@ -710,7 +710,7 @@ ErrCode BundleMgrHost::HandleQueryAbilityInfos(Parcel &data, Parcel &reply)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (!want) {
if (want == nullptr) {
APP_LOGE("ReadParcelable<want> failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@@ -734,7 +734,7 @@ ErrCode BundleMgrHost::HandleQueryAbilityInfosMutiparam(Parcel &data, Parcel &re
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (!want) {
if (want == nullptr) {
APP_LOGE("ReadParcelable<want> failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@@ -759,7 +759,7 @@ ErrCode BundleMgrHost::HandleQueryAllAbilityInfos(Parcel &data, Parcel &reply)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (!want) {
if (want == nullptr) {
APP_LOGE("ReadParcelable<want> failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@@ -783,7 +783,7 @@ ErrCode BundleMgrHost::HandleQueryAbilityInfosForClone(Parcel &data, Parcel &rep
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (!want) {
if (want == nullptr) {
APP_LOGE("ReadParcelable<want> failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@@ -996,7 +996,7 @@ ErrCode BundleMgrHost::HandleGetHapModuleInfoWithUserId(Parcel &data, Parcel &re
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::unique_ptr<AbilityInfo> abilityInfo(data.ReadParcelable<AbilityInfo>());
if (!abilityInfo) {
if (abilityInfo == nullptr) {
APP_LOGE("ReadParcelable<abilityInfo> failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@@ -1275,7 +1275,7 @@ ErrCode BundleMgrHost::HandleSetAbilityEnabled(Parcel &data, Parcel &reply)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::unique_ptr<AbilityInfo> abilityInfo(data.ReadParcelable<AbilityInfo>());
if (!abilityInfo) {
if (abilityInfo == nullptr) {
APP_LOGE("ReadParcelable<abilityInfo> failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@@ -1384,7 +1384,7 @@ ErrCode BundleMgrHost::HandleGetBundleInstaller(Parcel &data, Parcel &reply)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
sptr<IBundleInstaller> installer = GetBundleInstaller();
if (!installer) {
if (installer == nullptr) {
APP_LOGE("bundle installer is nullptr");
return ERR_APPEXECFWK_INSTALL_HOST_INSTALLER_FAILED;
}
@@ -1400,7 +1400,7 @@ ErrCode BundleMgrHost::HandleGetBundleUserMgr(Parcel &data, Parcel &reply)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
sptr<IBundleUserMgr> bundleUserMgr = GetBundleUserMgr();
if (!bundleUserMgr) {
if (bundleUserMgr == nullptr) {
APP_LOGE("bundle installer is nullptr");
return ERR_APPEXECFWK_INSTALL_HOST_INSTALLER_FAILED;
}
@@ -1610,7 +1610,7 @@ ErrCode BundleMgrHost::HandleQueryExtAbilityInfosWithoutType(Parcel &data, Parce
ErrCode BundleMgrHost::HandleQueryExtAbilityInfos(Parcel &data, Parcel &reply)
{
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (!want) {
if (want == nullptr) {
APP_LOGE("ReadParcelable<want> failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@@ -1802,7 +1802,7 @@ ErrCode BundleMgrHost::HandleImplicitQueryInfoByPriority(Parcel &data, Parcel &r
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (!want) {
if (want == nullptr) {
APP_LOGE("ReadParcelable<want> failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@@ -1897,7 +1897,7 @@ bool BundleMgrHost::WriteParcelableVectorIntoAshmem(
}
MessageParcel *messageParcel = reinterpret_cast<MessageParcel *>(&reply);
if (!messageParcel) {
if (messageParcel == nullptr) {
APP_LOGE("Type conversion failed");
return false;
}
@@ -1977,7 +1977,7 @@ ErrCode BundleMgrHost::HandleQueryAbilityInfoWithCallback(Parcel &data, Parcel &
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (!want) {
if (want == nullptr) {
APP_LOGE("ReadParcelable<want> failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@@ -2002,7 +2002,7 @@ ErrCode BundleMgrHost::HandleUpgradeAtomicService(Parcel &data, Parcel &reply)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (!want) {
if (want == nullptr) {
APP_LOGE("read parcelable want failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@@ -1902,7 +1902,7 @@ sptr<IBundleInstaller> BundleMgrProxy::GetBundleInstaller()
return nullptr;
}
sptr<IBundleInstaller> installer = iface_cast<IBundleInstaller>(object);
if (!installer) {
if (installer == nullptr) {
APP_LOGE("bundle installer is nullptr");
}
@@ -1929,7 +1929,7 @@ sptr<IBundleUserMgr> BundleMgrProxy::GetBundleUserMgr()
return nullptr;
}
sptr<IBundleUserMgr> bundleUserMgr = iface_cast<IBundleUserMgr>(object);
if (!bundleUserMgr) {
if (bundleUserMgr == nullptr) {
APP_LOGE("bundleUserMgr is nullptr");
}
@@ -2415,14 +2415,14 @@ bool BundleMgrProxy::ImplicitQueryInfoByPriority(const Want &want, int32_t flags
}
std::unique_ptr<AbilityInfo> abilityInfoPtr(reply.ReadParcelable<AbilityInfo>());
if (!abilityInfoPtr) {
if (abilityInfoPtr == nullptr) {
APP_LOGE("read AbilityInfo failed");
return false;
}
abilityInfo = *abilityInfoPtr;
std::unique_ptr<ExtensionAbilityInfo> extensionInfoPtr(reply.ReadParcelable<ExtensionAbilityInfo>());
if (!extensionInfoPtr) {
if (extensionInfoPtr == nullptr) {
APP_LOGE("read ExtensionAbilityInfo failed");
return false;
}
@@ -2513,7 +2513,7 @@ bool BundleMgrProxy::GetParcelableInfo(IBundleMgr::Message code, MessageParcel &
}
std::unique_ptr<T> info(reply.ReadParcelable<T>());
if (!info) {
if (info == nullptr) {
APP_LOGE("readParcelableInfo failed");
return false;
}
@@ -2533,7 +2533,7 @@ ErrCode BundleMgrProxy::GetParcelableInfoWithErrCode(IBundleMgr::Message code, M
ErrCode res = reply.ReadInt32();
if (res == ERR_OK) {
std::unique_ptr<T> info(reply.ReadParcelable<T>());
if (!info) {
if (info == nullptr) {
APP_LOGE("readParcelableInfo failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@@ -2560,7 +2560,7 @@ bool BundleMgrProxy::GetParcelableInfos(IBundleMgr::Message code, MessageParcel
int32_t infoSize = reply.ReadInt32();
for (int32_t i = 0; i < infoSize; i++) {
std::unique_ptr<T> info(reply.ReadParcelable<T>());
if (!info) {
if (info == nullptr) {
APP_LOGE("Read Parcelable infos failed");
return false;
}
@@ -2647,7 +2647,7 @@ bool BundleMgrProxy::SendTransactCmd(IBundleMgr::Message code, MessageParcel &da
MessageOption option(MessageOption::TF_SYNC);
sptr<IRemoteObject> remote = Remote();
if (!remote) {
if (remote == nullptr) {
APP_LOGE("fail to send transact cmd %{public}d due to remote object", code);
return false;
}
@@ -251,7 +251,7 @@ void BundleStatusCallbackProxy::OnBundleStateChanged(
}
sptr<IRemoteObject> remote = Remote();
if (!remote) {
if (remote == nullptr) {
APP_LOGE("fail to call OnBundleStateChanged, for Remote() is nullptr");
return;
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -82,7 +82,7 @@ bool BundleStreamInstallerProxy::Install(const sptr<IStatusReceiver>& receiver)
APP_LOGE("fail to Install due to write interface token fail");
return false;
}
if (!receiver) {
if (receiver == nullptr) {
APP_LOGE("fail to install, for receiver is nullptr");
return false;
}
@@ -115,7 +115,7 @@ bool BundleStreamInstallerProxy::SendStreamInstallRequest(const uint32_t& code,
MessageParcel& reply)
{
sptr<IRemoteObject> remote = Remote();
if (!remote) {
if (remote == nullptr) {
APP_LOGE("fail to send request, for remote is nullptr");
return false;
}
@@ -70,7 +70,7 @@ bool BundleUserMgrProxy::SendRequest(const int32_t& code, MessageParcel& data, M
MessageOption& option)
{
sptr<IRemoteObject> remote = Remote();
if (!remote) {
if (remote == nullptr) {
APP_LOGE("fail to uninstall, for Remote() is nullptr");
return false;
}
@@ -50,7 +50,7 @@ void CleanCacheCallbackProxy::OnCleanCacheFinished(bool succeeded)
}
sptr<IRemoteObject> remote = Remote();
if (!remote) {
if (remote == nullptr) {
APP_LOGE("fail to call OnCleanCacheFinished, for Remote() is nullptr");
return;
}
@@ -76,7 +76,7 @@ bool LauncherService::RegisterCallback(const sptr<IBundleStatusCallback> &callba
// check permission
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -97,7 +97,7 @@ bool LauncherService::UnRegisterCallback()
// check permission
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -113,7 +113,7 @@ bool LauncherService::GetAbilityList(
{
APP_LOGI("GetAbilityList called");
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr || bundleName.empty()) {
if ((iBundleMgr == nullptr) || (bundleName.empty())) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -163,7 +163,7 @@ bool LauncherService::GetAbilityList(
bool LauncherService::GetAllLauncherAbilityInfos(int32_t userId, std::vector<LauncherAbilityInfo> &launcherAbilityInfos)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -209,7 +209,7 @@ bool LauncherService::GetAbilityInfo(const Want &want, const int userId, Launche
{
APP_LOGI("GetAbilityInfo called");
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -269,7 +269,7 @@ bool LauncherService::GetApplicationInfo(
{
APP_LOGI("GetApplicationInfo called");
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -290,7 +290,7 @@ bool LauncherService::IsBundleEnabled(const std::string &bundleName)
{
APP_LOGI("IsBundleEnabled called");
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -306,7 +306,7 @@ bool LauncherService::IsAbilityEnabled(const AbilityInfo &abilityInfo)
{
APP_LOGI("IsAbilityEnabled called");
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -323,7 +323,7 @@ bool LauncherService::GetShortcutInfos(
return false;
}
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
+26 -26
View File
@@ -169,7 +169,7 @@ static OHOS::sptr<OHOS::AppExecFwk::IBundleMgr> GetBundleMgr()
static bool CheckIsSystemApp()
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -1176,7 +1176,7 @@ static bool InnerGetApplicationInfos(napi_env env, int32_t flags, const int user
std::vector<OHOS::AppExecFwk::ApplicationInfo> &appInfos)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -1361,7 +1361,7 @@ static bool InnerQueryAbilityInfos(napi_env env, const Want &want,
int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -1915,7 +1915,7 @@ static bool InnerGetBundleInfos(
napi_env env, int32_t flags, int32_t userId, std::vector<OHOS::AppExecFwk::BundleInfo> &bundleInfos)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -2044,7 +2044,7 @@ static bool InnerGetBundleInfo(
napi_env env, const std::string &bundleName, int32_t flags, BundleOptions bundleOptions, BundleInfo &bundleInfo)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -2058,7 +2058,7 @@ static bool InnerGetBundleInfo(
static bool InnerGetBundlePackInfo(const std::string &bundleName, int32_t flags, BundlePackInfo &bundlePackInfo)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -2520,7 +2520,7 @@ static bool InnerGetArchiveInfo(
napi_env env, const std::string &hapFilePath, const int32_t flags, BundleInfo &bundleInfo)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
};
@@ -2626,7 +2626,7 @@ static bool InnerGetLaunchWantForBundle(
napi_env env, const std::string &bundleName, Want &want)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -2744,7 +2744,7 @@ static void ConvertPermissionDef(napi_env env, napi_value result, const Permissi
static bool InnerGetPermissionDef(napi_env env, const std::string &permissionName, PermissionDef &permissionDef)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
};
@@ -2849,7 +2849,7 @@ static void InnerInstall(napi_env env, const std::vector<std::string> &bundleFil
return;
}
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return;
}
@@ -2864,7 +2864,7 @@ static void InnerInstall(napi_env env, const std::vector<std::string> &bundleFil
}
OHOS::sptr<InstallerCallback> callback = new (std::nothrow) InstallerCallback();
if (!callback) {
if (callback == nullptr) {
APP_LOGE("callback nullptr");
return;
}
@@ -2901,18 +2901,18 @@ static void InnerRecover(napi_env env, const std::string &bundleName, InstallPar
return;
}
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return;
}
auto iBundleInstaller = iBundleMgr->GetBundleInstaller();
if (!iBundleInstaller) {
if (iBundleInstaller == nullptr) {
APP_LOGE("can not get iBundleInstaller");
return;
}
OHOS::sptr<InstallerCallback> callback = new (std::nothrow) InstallerCallback();
if (!callback) {
if (callback == nullptr) {
APP_LOGE("callback nullptr");
return;
}
@@ -3625,7 +3625,7 @@ static void InnerUninstall(
napi_env env, const std::string &bundleName, InstallParam &installParam, InstallResult &installResult)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return;
}
@@ -3636,7 +3636,7 @@ static void InnerUninstall(
}
installParam.installFlag = InstallFlag::NORMAL;
OHOS::sptr<InstallerCallback> callback = new (std::nothrow) InstallerCallback();
if (!callback) {
if (callback == nullptr) {
APP_LOGE("callback nullptr");
return;
}
@@ -3790,7 +3790,7 @@ napi_value BundleInstallerConstructor(napi_env env, napi_callback_info info)
static bool InnerGetAllFormsInfo(napi_env env, std::vector<OHOS::AppExecFwk::FormInfo> &formInfos)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -3910,7 +3910,7 @@ static bool InnerGetFormInfosByModule(napi_env env, const std::string &bundleNam
std::vector<OHOS::AppExecFwk::FormInfo> &formInfos)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -4020,7 +4020,7 @@ static bool InnerGetFormInfosByApp(
napi_env env, const std::string &bundleName, std::vector<OHOS::AppExecFwk::FormInfo> &formInfos)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -4343,7 +4343,7 @@ napi_value GetBundleGids(napi_env env, napi_callback_info info)
static bool InnerSetApplicationEnabled(napi_env env, const std::string &bundleName, bool isEnable)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -4357,7 +4357,7 @@ static bool InnerSetApplicationEnabled(napi_env env, const std::string &bundleNa
static bool InnerSetAbilityEnabled(napi_env env, const OHOS::AppExecFwk::AbilityInfo &abilityInfo, bool isEnable)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -4372,11 +4372,11 @@ static bool InnerCleanBundleCacheCallback(
const std::string& bundleName, const OHOS::sptr<CleanCacheCallback>& cleanCacheCallback)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
if (!cleanCacheCallback) {
if (cleanCacheCallback == nullptr) {
APP_LOGE("callback nullptr");
return false;
}
@@ -5611,7 +5611,7 @@ static std::shared_ptr<Media::PixelMap> InnerGetAbilityIcon(
return nullptr;
}
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return nullptr;
}
@@ -5717,7 +5717,7 @@ napi_value GetAbilityIcon(napi_env env, napi_callback_info info)
static bool InnerGetNameForUid(int32_t uid, std::string &bundleName)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -6366,7 +6366,7 @@ static bool ParseWant(napi_env env, AsyncExtensionInfoCallbackInfo &info, napi_v
static bool InnerQueryExtensionInfo(napi_env env, AsyncExtensionInfoCallbackInfo &info)
{
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -424,11 +424,11 @@ static void ParseShortcutInfo(napi_env env, napi_value result,
static bool InnerJSLauncherServiceOn(napi_env env, OHOS::sptr<BundleStatusCallback> callbackRef)
{
if (!callbackRef) {
if (callbackRef == nullptr) {
APP_LOGE("Input null BundleStatusCallback");
}
auto launcher = GetLauncherService();
if (!launcher) {
if (launcher == nullptr) {
APP_LOGE("can not get launcher");
return false;
}
@@ -547,7 +547,7 @@ static napi_value JSLauncherServiceOn(napi_env env, napi_callback_info info)
static bool InnerJSLauncherServiceOff()
{
auto launcher = GetLauncherService();
if (!launcher) {
if (launcher == nullptr) {
APP_LOGE("can not get launcher");
return false;
}
@@ -651,7 +651,7 @@ static bool InnerJSGetAllLauncherAbilityInfos(napi_env env, uint32_t userId,
std::vector<OHOS::AppExecFwk::LauncherAbilityInfo> &launcherAbilityInfos)
{
auto launcher = GetLauncherService();
if (!launcher) {
if (launcher == nullptr) {
APP_LOGE("can not get launcher");
return false;
}
@@ -754,7 +754,7 @@ static bool InnerJSGetLauncherAbilityInfos(napi_env env, std::string& bundleName
uint32_t userId, std::vector<OHOS::AppExecFwk::LauncherAbilityInfo>& launcherAbilityInfos)
{
auto launcher = GetLauncherService();
if (!launcher) {
if (launcher == nullptr) {
APP_LOGE("can not get launcher");
return false;
}
@@ -862,7 +862,7 @@ static bool InnerJSGetShortcutInfos(napi_env env, const std::string& bundleName,
std::vector<OHOS::AppExecFwk::ShortcutInfo>& shortcutInfos)
{
auto launcher = GetLauncherService();
if (!launcher) {
if (launcher == nullptr) {
APP_LOGE("can not get launcher");
return false;
}
+1 -1
View File
@@ -155,7 +155,7 @@ static bool InnerHasInstalled(std::string bundleName)
return false;
}
auto iBundleMgr = GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return false;
}
@@ -73,7 +73,7 @@ bool BundleMgrProxyNative::SendTransactCmd(IBundleMgr::Message code, MessageParc
MessageOption option(MessageOption::TF_SYNC);
sptr<IRemoteObject> remote = Remote();
if (!remote) {
if (remote == nullptr) {
APP_LOGE("fail to send transact cmd %{public}d due to remote object", code);
return false;
}
@@ -81,7 +81,7 @@ char* OH_NativeBundle_GetAppIdByBundleName(const char* bundleName)
return nullptr;
}
auto iBundleMgr = OHOS::AppExecFwk::BundleNative::GetBundleMgr();
if (!iBundleMgr) {
if (iBundleMgr == nullptr) {
APP_LOGE("can not get iBundleMgr");
return nullptr;
}
@@ -31,7 +31,7 @@ bool AbilityManagerHelper::UninstallApplicationProcesses(const std::string &bund
APP_LOGI("uninstall kill running processes, app name is %{public}s", bundleName.c_str());
sptr<AAFwk::IAbilityManager> abilityMgrProxy =
iface_cast<AAFwk::IAbilityManager>(SystemAbilityHelper::GetSystemAbility(ABILITY_MGR_SERVICE_ID));
if (!abilityMgrProxy) {
if (abilityMgrProxy == nullptr) {
APP_LOGE("fail to find the app mgr service to kill application");
return false;
}
@@ -38,7 +38,7 @@ BundleAgingMgr::~BundleAgingMgr()
void BundleAgingMgr::InitAgingRunner()
{
auto agingRunner = EventRunner::Create(AgingConstants::AGING_THREAD);
if (!agingRunner) {
if (agingRunner == nullptr) {
APP_LOGE("create aging runner failed");
return;
}
@@ -96,7 +96,7 @@ int BundleAgingMgr::AgingQueryFormStatistics(std::vector<DeviceUsageStats::Bundl
bool BundleAgingMgr::ReInitAgingRequest(const std::shared_ptr<BundleDataMgr> &dataMgr)
{
if (!dataMgr) {
if (dataMgr == nullptr) {
APP_LOGE("ReInitAgingRequest: dataMgr is null");
return false;
}
@@ -167,7 +167,7 @@ void BundleAgingMgr::Start(AgingTriggertype type)
}
auto dataMgr = OHOS::DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr) {
if (dataMgr == nullptr) {
APP_LOGE("dataMgr is null");
return;
}
@@ -74,14 +74,20 @@ bool RecentlyUnuseBundleAgingHandler::NeedContinue(const AgingRequest &request)
bool RecentlyUnuseBundleAgingHandler::UnInstallBundle(const std::string &bundleName) const
{
auto bms = DelayedSingleton<BundleMgrService>::GetInstance();
if (bms == nullptr) {
return false;
}
auto bundleInstaller = bms->GetBundleInstaller();
auto bundleDataMgr = bms->GetDataMgr();
if (!bundleInstaller) {
if (bundleInstaller == nullptr) {
APP_LOGE("bundleInstaller is null.");
return false;
}
sptr<AgingUninstallReceiveImpl> userReceiverImpl(new (std::nothrow) AgingUninstallReceiveImpl());
if (userReceiverImpl == nullptr) {
return false;
}
InstallParam installParam;
installParam.userId = AccountHelper::GetCurrentActiveUserId();
installParam.installFlag = InstallFlag::FREE_INSTALL;
@@ -440,9 +440,9 @@ ErrCode BaseBundleInstaller::ProcessBundleInstall(const std::vector<std::string>
const InstallParam &installParam, const Constants::AppType appType, int32_t &uid)
{
APP_LOGD("ProcessBundleInstall bundlePath install");
if (!dataMgr_) {
if (dataMgr_ == nullptr) {
dataMgr_ = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr_) {
if (dataMgr_ == nullptr) {
APP_LOGE("Get dataMgr shared_ptr nullptr");
return ERR_APPEXECFWK_UNINSTALL_BUNDLE_MGR_SERVICE_ERROR;
}
@@ -649,7 +649,7 @@ ErrCode BaseBundleInstaller::ProcessBundleUninstall(
}
dataMgr_ = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr_) {
if (dataMgr_ == nullptr) {
APP_LOGE("Get dataMgr shared_ptr nullptr");
return ERR_APPEXECFWK_UNINSTALL_BUNDLE_MGR_SERVICE_ERROR;
}
@@ -873,7 +873,7 @@ ErrCode BaseBundleInstaller::InnerProcessInstallByPreInstallInfo(
const std::string &bundleName, const InstallParam &installParam, int32_t &uid, bool recoverMode)
{
dataMgr_ = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr_) {
if (dataMgr_ == nullptr) {
APP_LOGE("Get dataMgr shared_ptr nullptr.");
return ERR_APPEXECFWK_UNINSTALL_BUNDLE_MGR_SERVICE_ERROR;
}
@@ -1734,9 +1734,9 @@ ErrCode BaseBundleInstaller::CheckAppLabelInfo(const std::unordered_map<std::str
bool BaseBundleInstaller::GetInnerBundleInfo(InnerBundleInfo &info, bool &isAppExist)
{
if (!dataMgr_) {
if (dataMgr_ == nullptr) {
dataMgr_ = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr_) {
if (dataMgr_ == nullptr) {
APP_LOGE("Get dataMgr shared_ptr nullptr");
return false;
}
+1 -1
View File
@@ -276,7 +276,7 @@ bool BundleCloneMgr::RemoveClonedBundle(const std::string &oldName, const std::s
return false;
}
std::shared_ptr<BundleDataMgr> dataMgr_ = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr_) {
if (dataMgr_ == nullptr) {
APP_LOGE("Get dataMgr shared_ptr nullptr");
return false;
}
+3 -3
View File
@@ -2305,7 +2305,7 @@ bool BundleDataMgr::SavePreInstallBundleInfo(
const std::string &bundleName, const PreInstallBundleInfo &preInstallBundleInfo)
{
std::lock_guard<std::mutex> lock(preInstallInfoMutex_);
if (!preInstallDataStorage_) {
if (preInstallDataStorage_ == nullptr) {
return false;
}
@@ -2328,7 +2328,7 @@ bool BundleDataMgr::DeletePreInstallBundleInfo(
const std::string &bundleName, const PreInstallBundleInfo &preInstallBundleInfo)
{
std::lock_guard<std::mutex> lock(preInstallInfoMutex_);
if (!preInstallDataStorage_) {
if (preInstallDataStorage_ == nullptr) {
return false;
}
@@ -2368,7 +2368,7 @@ bool BundleDataMgr::GetPreInstallBundleInfo(
bool BundleDataMgr::LoadAllPreInstallBundleInfos(std::vector<PreInstallBundleInfo> &preInstallBundleInfos)
{
if (!preInstallDataStorage_) {
if (preInstallDataStorage_ == nullptr) {
return false;
}
+1 -1
View File
@@ -192,7 +192,7 @@ std::set<int32_t> BundleInstaller::GetExistsCommonUserIs()
{
std::set<int32_t> userIds;
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr) {
if (dataMgr == nullptr) {
APP_LOGE("Get dataMgr shared_ptr nullptr");
return userIds;
}
@@ -109,7 +109,7 @@ void BundleInstallerHost::HandleInstallMessage(Parcel &data)
APP_LOGD("handle install message");
std::string bundlePath = Str16ToStr8(data.ReadString16());
std::unique_ptr<InstallParam> installParam(data.ReadParcelable<InstallParam>());
if (!installParam) {
if (installParam == nullptr) {
APP_LOGE("ReadParcelable<InstallParam> failed");
return;
}
@@ -129,7 +129,7 @@ void BundleInstallerHost::HandleRecoverMessage(Parcel &data)
APP_LOGD("handle install message by bundleName");
std::string bundleName = Str16ToStr8(data.ReadString16());
std::unique_ptr<InstallParam> installParam(data.ReadParcelable<InstallParam>());
if (!installParam) {
if (installParam == nullptr) {
APP_LOGE("ReadParcelable<InstallParam> failed");
return;
}
@@ -157,7 +157,7 @@ void BundleInstallerHost::HandleInstallMultipleHapsMessage(Parcel &data)
return;
}
std::unique_ptr<InstallParam> installParam(data.ReadParcelable<InstallParam>());
if (!installParam) {
if (installParam == nullptr) {
APP_LOGE("ReadParcelable<InstallParam> failed");
return;
}
@@ -177,7 +177,7 @@ void BundleInstallerHost::HandleUninstallMessage(Parcel &data)
APP_LOGD("handle uninstall message");
std::string bundleName = Str16ToStr8(data.ReadString16());
std::unique_ptr<InstallParam> installParam(data.ReadParcelable<InstallParam>());
if (!installParam) {
if (installParam == nullptr) {
APP_LOGE("ReadParcelable<InstallParam> failed");
return;
}
@@ -198,7 +198,7 @@ void BundleInstallerHost::HandleUninstallModuleMessage(Parcel &data)
std::string bundleName = Str16ToStr8(data.ReadString16());
std::string modulePackage = Str16ToStr8(data.ReadString16());
std::unique_ptr<InstallParam> installParam(data.ReadParcelable<InstallParam>());
if (!installParam) {
if (installParam == nullptr) {
APP_LOGE("ReadParcelable<InstallParam> failed");
return;
}
@@ -247,13 +247,13 @@ void BundleInstallerHost::HandleCreateStreamInstaller(Parcel &data, Parcel &repl
{
APP_LOGD("handle create stream installer message begin");
std::unique_ptr<InstallParam> installParam(data.ReadParcelable<InstallParam>());
if (!installParam) {
if (installParam == nullptr) {
APP_LOGE("ReadParcelable<InstallParam> failed");
return;
}
sptr<IBundleStreamInstaller> streamInstaller = CreateStreamInstaller(*installParam);
if (!streamInstaller) {
if (streamInstaller == nullptr) {
if (!reply.WriteBool(false)) {
APP_LOGE("write result failed");
return;
@@ -471,11 +471,11 @@ bool BundleInstallerHost::DestoryBundleStreamInstaller(uint32_t streamInstallerI
bool BundleInstallerHost::CheckBundleInstallerManager(const sptr<IStatusReceiver> &statusReceiver) const
{
if (!statusReceiver) {
if (statusReceiver == nullptr) {
APP_LOGE("the receiver is nullptr");
return false;
}
if (!manager_) {
if (manager_ == nullptr) {
APP_LOGE("the bundle installer manager is nullptr");
statusReceiver->OnFinished(ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR, GET_MANAGER_FAIL);
return false;
@@ -61,7 +61,7 @@ void BundleInstallerManager::CreateInstallTask(
const std::string &bundleFilePath, const InstallParam &installParam, const sptr<IStatusReceiver> &statusReceiver)
{
auto installer = CreateInstaller(statusReceiver);
if (!installer) {
if (installer == nullptr) {
APP_LOGE("create installer failed");
return;
}
@@ -77,7 +77,7 @@ void BundleInstallerManager::CreateRecoverTask(
const std::string &bundleName, const InstallParam &installParam, const sptr<IStatusReceiver> &statusReceiver)
{
auto installer = CreateInstaller(statusReceiver);
if (!installer) {
if (installer == nullptr) {
APP_LOGE("create installer failed");
return;
}
@@ -93,7 +93,7 @@ void BundleInstallerManager::CreateInstallTask(const std::vector<std::string> &b
const InstallParam &installParam, const sptr<IStatusReceiver> &statusReceiver)
{
auto installer = CreateInstaller(statusReceiver);
if (!installer) {
if (installer == nullptr) {
APP_LOGE("create installer failed");
return;
}
@@ -109,7 +109,7 @@ void BundleInstallerManager::CreateInstallByBundleNameTask(const std::string &bu
const InstallParam &installParam, const sptr<IStatusReceiver> &statusReceiver)
{
auto installer = CreateInstaller(statusReceiver);
if (!installer) {
if (installer == nullptr) {
APP_LOGE("create installer failed");
return;
}
@@ -126,7 +126,7 @@ void BundleInstallerManager::CreateUninstallTask(
const std::string &bundleName, const InstallParam &installParam, const sptr<IStatusReceiver> &statusReceiver)
{
auto installer = CreateInstaller(statusReceiver);
if (!installer) {
if (installer == nullptr) {
APP_LOGE("create installer failed");
return;
}
@@ -142,7 +142,7 @@ void BundleInstallerManager::CreateUninstallTask(const std::string &bundleName,
const InstallParam &installParam, const sptr<IStatusReceiver> &statusReceiver)
{
auto installer = CreateInstaller(statusReceiver);
if (!installer) {
if (installer == nullptr) {
APP_LOGE("create installer failed");
return;
}
@@ -158,7 +158,7 @@ std::shared_ptr<BundleInstaller> BundleInstallerManager::CreateInstaller(const s
{
int64_t installerId = GetMicroTickCount();
auto installer = std::make_shared<BundleInstaller>(installerId, shared_from_this(), statusReceiver);
if (!installer) {
if (installer == nullptr) {
APP_LOGE("create bundle installer failed");
return nullptr;
}
+18 -18
View File
@@ -89,7 +89,7 @@ void BundleMgrService::OnStart()
void BundleMgrService::AfterRegisterToService()
{
if (!distributedSub_) {
if (distributedSub_ == nullptr) {
EventFwk::MatchingSkills matchingSkills;
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED);
EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);
@@ -121,44 +121,44 @@ bool BundleMgrService::Init()
if (host_ == nullptr) {
host_ = new (std::nothrow) BundleMgrHostImpl();
if (!host_) {
if (host_ == nullptr) {
APP_LOGE("create host instance fail");
return false;
}
}
APP_LOGI("init begin");
if (!runner_) {
if (runner_ == nullptr) {
runner_ = EventRunner::Create(Constants::BMS_SERVICE_NAME);
if (!runner_) {
if (runner_ == nullptr) {
APP_LOGE("create runner fail");
return false;
}
}
APP_LOGD("create runner success");
if (!handler_) {
if (handler_ == nullptr) {
handler_ = std::make_shared<BMSEventHandler>(runner_);
if (!handler_) {
if (handler_ == nullptr) {
APP_LOGE("create bms event handler fail");
return false;
}
}
APP_LOGD("create handler success");
if (!installer_) {
if (installer_ == nullptr) {
installer_ = new (std::nothrow) BundleInstallerHost();
if (!installer_ || !installer_->Init()) {
if (installer_ == nullptr || !installer_->Init()) {
APP_LOGE("init installer fail");
return false;
}
}
APP_LOGD("create installer host success");
if (!dataMgr_) {
if (dataMgr_ == nullptr) {
APP_LOGI("Create BundledataMgr");
dataMgr_ = std::make_shared<BundleDataMgr>();
if (!dataMgr_) {
if (dataMgr_ == nullptr) {
APP_LOGE("create data manager fail");
return false;
}
@@ -167,7 +167,7 @@ bool BundleMgrService::Init()
if (userMgrHost_ == nullptr) {
userMgrHost_ = new (std::nothrow) BundleUserMgrHostImpl();
if (!userMgrHost_) {
if (userMgrHost_ == nullptr) {
APP_LOGE("create userMgrHost instance fail");
return false;
}
@@ -183,29 +183,29 @@ bool BundleMgrService::Init()
handler_->SendEvent(BMSEventHandler::BUNDLE_REBOOT_SCAN_START);
}
if (!cloneMgr_) {
if (cloneMgr_ == nullptr) {
APP_LOGI("Create BundleCloneMgr");
cloneMgr_ = std::make_shared<BundleCloneMgr>();
}
APP_LOGI("create BundleCloneMgr success");
#ifdef DEVICE_MANAGER_ENABLE
if (!deviceManager_) {
if (deviceManager_ == nullptr) {
APP_LOGI("Create device manager");
deviceManager_ = std::make_shared<BmsDeviceManager>();
}
#endif
if (!hidumpHelper_) {
if (hidumpHelper_ == nullptr) {
APP_LOGI("Create hidump helper");
hidumpHelper_ = std::make_shared<HidumpHelper>(dataMgr_);
}
#ifdef BUNDLE_FRAMEWORK_FREE_INSTALL
if (!agingMgr_) {
if (agingMgr_ == nullptr) {
APP_LOGI("Create aging manager");
agingMgr_ = DelayedSingleton<BundleAgingMgr>::GetInstance();
if (!agingMgr_) {
if (agingMgr_ == nullptr) {
APP_LOGE("Create aging manager faild.");
}
if (agingMgr_) {
@@ -214,7 +214,7 @@ bool BundleMgrService::Init()
agingMgr_->InitAgingtTimer();
}
}
if (!connectAbilityMgr_) {
if (connectAbilityMgr_ == nullptr) {
APP_LOGI("Create BundleConnectAbility");
connectAbilityMgr_ = std::make_shared<BundleConnectAbilityMgr>();
}
@@ -274,7 +274,7 @@ sptr<BundleUserMgrHostImpl> BundleMgrService::GetBundleUserMgr() const
void BundleMgrService::CheckAllUser()
{
if (!dataMgr_) {
if (dataMgr_ == nullptr) {
return;
}
@@ -37,7 +37,7 @@ void BundleStatusCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>
APP_LOGI("bundle status service died, remove the proxy object");
sptr<IBundleStatusCallback> callback = iface_cast<IBundleStatusCallback>(remote.promote());
APP_LOGI("bundle status service died");
if (!callback) {
if (callback == nullptr) {
APP_LOGE("callback is nullptr");
return;
}
+2 -2
View File
@@ -307,7 +307,7 @@ std::string BundleUtil::CreateInstallTempDir(uint32_t installerId)
std::string tempDir = Constants::HAP_COPY_PATH + Constants::PATH_SEPARATOR + std::to_string(curTime) +
std::to_string(installerId) + Constants::PATH_SEPARATOR;
if (!OHOS::ForceCreateDirectory(tempDir)) {
APP_LOGE("mkdir %{public}s failed", tempDir.c_str());
APP_LOGE("mkdir %{private}s failed", tempDir.c_str());
return "";
}
if (chown(tempDir.c_str(), Constants::BMS_UID, Constants::BMS_GID) != 0) {
@@ -316,7 +316,7 @@ std::string BundleUtil::CreateInstallTempDir(uint32_t installerId)
}
mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
if (!OHOS::ChangeModeFile(tempDir, mode)) {
APP_LOGE("change mode failed, temp install dir : %{public}s", tempDir.c_str());
APP_LOGE("change mode failed, temp install dir : %{private}s", tempDir.c_str());
return "";
}
return tempDir;
@@ -81,7 +81,7 @@ bool DistributedDataStorage::SaveStorageDistributeInfo(const std::string &bundle
return false;
}
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr) {
if (dataMgr == nullptr) {
APP_LOGE("Get dataMgr shared_ptr nullptr");
return false;
}
@@ -27,7 +27,7 @@ int32_t ServiceCenterStatusCallback::OnInstallFinished(std::string installResult
{
APP_LOGI("%{public}s", __func__);
auto server = server_.lock();
if (!server) {
if (server == nullptr) {
APP_LOGE("pointer is nullptr.");
return ERR_INVALID_VALUE;
}
+7 -7
View File
@@ -183,7 +183,7 @@ ErrCode HidumpHelper::ProcessDump(const HidumpParam& hidumpParam, std::string &r
ErrCode HidumpHelper::GetAllAbilityInfo(std::string &result)
{
auto shareDataMgr = dataMgr_.lock();
if (!shareDataMgr) {
if (shareDataMgr == nullptr) {
return ERR_APPEXECFWK_HIDUMP_SERVICE_ERROR;
}
@@ -214,7 +214,7 @@ ErrCode HidumpHelper::GetAllAbilityInfo(std::string &result)
ErrCode HidumpHelper::GetAllAbilityNameList(std::string &result)
{
auto shareDataMgr = dataMgr_.lock();
if (!shareDataMgr) {
if (shareDataMgr == nullptr) {
return ERR_APPEXECFWK_HIDUMP_SERVICE_ERROR;
}
@@ -242,7 +242,7 @@ ErrCode HidumpHelper::GetAllAbilityNameList(std::string &result)
ErrCode HidumpHelper::GetAbilityInfoByName(const std::string &name, std::string &result)
{
auto shareDataMgr = dataMgr_.lock();
if (!shareDataMgr) {
if (shareDataMgr == nullptr) {
return ERR_APPEXECFWK_HIDUMP_SERVICE_ERROR;
}
@@ -275,7 +275,7 @@ ErrCode HidumpHelper::GetAbilityInfoByName(const std::string &name, std::string
ErrCode HidumpHelper::GetAllBundleInfo(std::string &result)
{
auto shareDataMgr = dataMgr_.lock();
if (!shareDataMgr) {
if (shareDataMgr == nullptr) {
return ERR_APPEXECFWK_HIDUMP_SERVICE_ERROR;
}
@@ -304,7 +304,7 @@ ErrCode HidumpHelper::GetAllBundleInfo(std::string &result)
ErrCode HidumpHelper::GetAllBundleNameList(std::string &result)
{
auto shareDataMgr = dataMgr_.lock();
if (!shareDataMgr) {
if (shareDataMgr == nullptr) {
return ERR_APPEXECFWK_HIDUMP_SERVICE_ERROR;
}
@@ -326,7 +326,7 @@ ErrCode HidumpHelper::GetBundleInfoByName(const std::string &name, std::string &
{
APP_LOGD("hidump bundle info begin");
auto shareDataMgr = dataMgr_.lock();
if (!shareDataMgr) {
if (shareDataMgr == nullptr) {
return ERR_APPEXECFWK_HIDUMP_SERVICE_ERROR;
}
@@ -353,7 +353,7 @@ ErrCode HidumpHelper::GetBundleInfoByName(const std::string &name, std::string &
ErrCode HidumpHelper::GetAllDeviced(std::string &result)
{
auto shareDataMgr = dataMgr_.lock();
if (!shareDataMgr) {
if (shareDataMgr == nullptr) {
return ERR_APPEXECFWK_HIDUMP_SERVICE_ERROR;
}
@@ -22,7 +22,7 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
{
using namespace OHOS::AppExecFwk;
std::unique_ptr<InstalldService> service = std::make_unique<InstalldService>();
if (!service) {
if (service == nullptr) {
APP_LOGE("fail to create the installd service");
std::exit(EXIT_FAILURE);
}
+7 -3
View File
@@ -146,17 +146,21 @@ void InstalldClient::ResetInstalldProxy()
bool InstalldClient::GetInstalldProxy()
{
if (!installdProxy_) {
if (installdProxy_ == nullptr) {
APP_LOGD("try to get installd proxy");
std::lock_guard<std::mutex> lock(mutex_);
if (!installdProxy_) {
if (installdProxy_ == nullptr) {
sptr<IInstalld> tempProxy =
iface_cast<IInstalld>(SystemAbilityHelper::GetSystemAbility(INSTALLD_SERVICE_ID));
if ((!tempProxy) || (!tempProxy->AsObject())) {
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;
}
@@ -43,13 +43,13 @@ void KvStoreDeathRecipientCallback::OnRemoteDied()
{
APP_LOGI("OnRemoteDied, register data change listener begin");
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr) {
if (dataMgr == nullptr) {
APP_LOGE("dataMgr is nullptr");
return;
}
auto dataStorage = dataMgr->GetDataStorage();
if (!dataStorage) {
if (dataStorage == nullptr) {
APP_LOGE("dataStorage is nullptr");
return;
}
@@ -356,14 +356,14 @@ bool BundleSandboxInstaller::GetInnerBundleInfo(InnerBundleInfo &info, bool &isA
ErrCode BundleSandboxInstaller::GetSandboxDataMgr()
{
if (!sandboxDataMgr_) {
if (sandboxDataMgr_ == nullptr) {
if (GetDataMgr() != ERR_OK) {
APP_LOGE("Get dataMgr shared_ptr failed");
return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR;
}
sandboxDataMgr_ = dataMgr_->GetSandboxDataMgr();
if (!sandboxDataMgr_) {
if (sandboxDataMgr_ == nullptr) {
APP_LOGE("Get sandbox dataMgr shared_ptr nullptr");
return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR;
}
@@ -373,9 +373,9 @@ ErrCode BundleSandboxInstaller::GetSandboxDataMgr()
ErrCode BundleSandboxInstaller::GetDataMgr()
{
if (!dataMgr_) {
if (dataMgr_ == nullptr) {
dataMgr_ = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr_) {
if (dataMgr_ == nullptr) {
APP_LOGE("Get dataMgr shared_ptr nullptr");
return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR;
}
@@ -357,7 +357,7 @@ void StatusReceiverProxy::OnStatusNotify(const int32_t progress)
}
sptr<IRemoteObject> remote = Remote();
if (!remote) {
if (remote == nullptr) {
APP_LOGE("fail to call OnStatusNotify, for Remote() is nullptr");
return;
}
@@ -393,7 +393,7 @@ void StatusReceiverProxy::OnFinished(const int32_t resultCode, const std::string
}
sptr<IRemoteObject> remote = Remote();
if (!remote) {
if (remote == nullptr) {
APP_LOGE("fail to call OnFinished, for Remote() is nullptr");
return;
}
@@ -420,7 +420,7 @@ void StatusReceiverProxy::TransformResult(const int32_t resultCode)
void StatusReceiverProxy::CloseStreamInstaller(uint32_t installerId)
{
if (installerId <= 0) {
APP_LOGE("invalid installer id: %{public}d", installerId);
APP_LOGE("invalid installer id: %{public}u", installerId);
return;
}
sptr<IBundleInstaller> bundleInstaller = DelayedSingleton<BundleMgrService>::GetInstance()->GetBundleInstaller();
@@ -26,7 +26,7 @@ namespace AppExecFwk {
sptr<IRemoteObject> SystemAbilityHelper::GetSystemAbility(const int32_t systemAbilityId)
{
sptr<ISystemAbilityManager> systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (!systemAbilityMgr) {
if (systemAbilityMgr == nullptr) {
APP_LOGE("fail to get the system ability manager to get %{public}d proxy", systemAbilityId);
return nullptr;
}
@@ -56,7 +56,7 @@ bool SystemBundleInstaller::OTAInstallSystemBundle(
const std::vector<std::string> &filePaths, Constants::AppType appType)
{
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr) {
if (dataMgr == nullptr) {
APP_LOGE("Get dataMgr shared_ptr nullptr");
return false;
}
@@ -88,7 +88,7 @@ bool SystemBundleInstaller::OTAInstallSystemBundle(
bool SystemBundleInstaller::UninstallSystemBundle(const std::string &bundleName)
{
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr) {
if (dataMgr == nullptr) {
APP_LOGE("Get dataMgr shared_ptr nullptr");
return false;
}
@@ -114,7 +114,7 @@ bool SystemBundleInstaller::UninstallSystemBundle(const std::string &bundleName)
bool SystemBundleInstaller::UninstallSystemBundle(const std::string &bundleName, const std::string &modulePackage)
{
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr) {
if (dataMgr == nullptr) {
APP_LOGE("Get dataMgr shared_ptr nullptr");
return false;
}