mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2024-11-22 23:00:31 +00:00
代码优化(一)
Signed-off-by: ming-yue-liu1 <liumingyue12@huawei.com> Change-Id: I3e9369b3214f6b6b2c6d9f3caf7bcdaa5fb5c053
This commit is contained in:
parent
c7daad017d
commit
f80d2bf63d
@ -32,7 +32,7 @@ std::string AppLogWrapper::GetBriefFileName(const char *str)
|
||||
return std::string();
|
||||
}
|
||||
std::string fullPath(str);
|
||||
size_t pos = fullPath.find_last_of("/");
|
||||
size_t pos = fullPath.find_last_of('/');
|
||||
if (pos == std::string::npos) {
|
||||
return std::string();
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ bool BundleFileUtil::CheckFilePath(const std::vector<std::string> &bundlePaths,
|
||||
|
||||
if (bundlePaths.size() == 1) {
|
||||
APP_LOGD("bundlePaths only has one element");
|
||||
std::string bundlePath = bundlePaths.front();
|
||||
const std::string& bundlePath = bundlePaths.front();
|
||||
std::string realPath = "";
|
||||
// it is a file
|
||||
if (CheckFilePath(bundlePaths.front(), realPath)) {
|
||||
|
@ -16,8 +16,6 @@
|
||||
#ifndef FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_COMMON_EVENT_H
|
||||
#define FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_COMMON_EVENT_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
constexpr const char* COMMON_EVENT_SANDBOX_PACKAGE_ADDED = "usual.event.SANDBOX_PACKAGE_ADDED";
|
||||
|
@ -24,7 +24,6 @@
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
struct LauncherAbilityInfo {
|
||||
public:
|
||||
ApplicationInfo applicationInfo;
|
||||
ElementName elementName; // bundle name , ability name, deviceid
|
||||
uint32_t labelId = 0;
|
||||
|
@ -32,8 +32,8 @@ enum OverlayType : int8_t {
|
||||
struct OverlayBundleInfo : public Parcelable {
|
||||
std::string bundleName;
|
||||
std::string bundleDir;
|
||||
int32_t state; // 0 is for disable and 1 is for enable
|
||||
int32_t priority;
|
||||
int32_t state = 0; // 0 is for disable and 1 is for enable
|
||||
int32_t priority = 0;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <cstdint>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "bundle_constants.h"
|
||||
@ -505,7 +505,7 @@ bool AbilityInfo::Marshalling(Parcel &parcel) const
|
||||
|
||||
void AbilityInfo::Dump(std::string prefix, int fd)
|
||||
{
|
||||
APP_LOGI("called dump Abilityinfo");
|
||||
APP_LOGI("call Dump");
|
||||
if (fd < 0) {
|
||||
APP_LOGE("dump Abilityinfo fd error");
|
||||
return;
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "application_info.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
@ -290,7 +291,7 @@ bool ApplicationInfo::ReadMetaDataFromParcel(Parcel &parcel)
|
||||
std::vector<CustomizeData> customizeDatas;
|
||||
metaData[moduleName] = customizeDatas;
|
||||
CONTAINER_SECURITY_VERIFY(parcel, customizeDataSize, &customizeDatas);
|
||||
for (int j = 0; j < customizeDataSize; j++) {
|
||||
for (int32_t j = 0; j < customizeDataSize; j++) {
|
||||
std::unique_ptr<CustomizeData> customizeData(parcel.ReadParcelable<CustomizeData>());
|
||||
if (!customizeData) {
|
||||
APP_LOGE("ReadParcelable<CustomizeData> failed");
|
||||
@ -793,7 +794,6 @@ void ApplicationInfo::Dump(std::string prefix, int fd)
|
||||
APP_LOGE("dump write error : %{public}d", errno);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool ApplicationInfo::CheckNeedPreload(const std::string &moduleName) const
|
||||
|
@ -89,12 +89,12 @@ FormInfo::FormInfo(const ExtensionAbilityInfo &abilityInfo, const ExtensionFormI
|
||||
src = formInfo.src;
|
||||
window.designWidth = formInfo.window.designWidth;
|
||||
window.autoDesignWidth = formInfo.window.autoDesignWidth;
|
||||
std::size_t pos = formInfo.displayName.find(":");
|
||||
std::size_t pos = formInfo.displayName.find(':');
|
||||
if (pos != std::string::npos) {
|
||||
displayNameId = static_cast<unsigned int>(
|
||||
atoi(formInfo.displayName.substr(pos + 1, formInfo.displayName.length() - pos - 1).c_str()));
|
||||
}
|
||||
pos = formInfo.description.find(":");
|
||||
pos = formInfo.description.find(':');
|
||||
if (pos != std::string::npos) {
|
||||
descriptionId = static_cast<unsigned int>(
|
||||
atoi(formInfo.description.substr(pos + 1, formInfo.description.length() - pos - 1).c_str()));
|
||||
|
@ -43,7 +43,7 @@ PreinstalledApplicationInfo *PreinstalledApplicationInfo::Unmarshalling(Parcel &
|
||||
APP_LOGE("Info is null");
|
||||
return nullptr;
|
||||
}
|
||||
if (info && !info->ReadFromParcel(parcel)) {
|
||||
if (!info->ReadFromParcel(parcel)) {
|
||||
APP_LOGW("Read from parcel failed");
|
||||
delete info;
|
||||
info = nullptr;
|
||||
|
@ -71,7 +71,7 @@ bool Skill::Match(const OHOS::AAFwk::Want &want) const
|
||||
}
|
||||
std::vector<std::string> vecTypes = want.GetStringArrayParam(OHOS::AAFwk::Want::PARAM_ABILITY_URITYPES);
|
||||
std::string uriString = want.GetUriString();
|
||||
if (vecTypes.size() > 0) {
|
||||
if (!vecTypes.empty()) {
|
||||
for (std::string strType : vecTypes) {
|
||||
if (MatchUriAndType(uriString, strType)) {
|
||||
APP_LOGD("type %{public}s, Is Matched", strType.c_str());
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
private:
|
||||
DISALLOW_COPY_AND_MOVE(BundleStreamInstallerHost);
|
||||
|
||||
void init();
|
||||
void Init();
|
||||
ErrCode HandleCreateStream(MessageParcel &data, MessageParcel &reply);
|
||||
ErrCode HandleCreateSignatureFileStream(MessageParcel &data, MessageParcel &reply);
|
||||
ErrCode HandleCreateSharedBundleStream(MessageParcel &data, MessageParcel &reply);
|
||||
|
@ -107,7 +107,7 @@ private:
|
||||
const int32_t userId);
|
||||
|
||||
private:
|
||||
void init();
|
||||
void Init();
|
||||
void OnDeath();
|
||||
static OHOS::sptr<OHOS::AppExecFwk::IBundleMgr> GetBundleMgr();
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace AppExecFwk {
|
||||
namespace {
|
||||
constexpr size_t MAX_PARCEL_CAPACITY = 1024 * 1024 * 1024; // allow max 1GB resource size
|
||||
constexpr size_t MAX_IPC_ALLOWED_CAPACITY = 100 * 1024 * 1024; // max ipc size 100MB
|
||||
bool GetData(void *&buffer, size_t size, const void *data)
|
||||
bool GetData(size_t size, const void *data, void *&buffer)
|
||||
{
|
||||
if (data == nullptr) {
|
||||
APP_LOGE("failed due to null data");
|
||||
@ -277,7 +277,7 @@ ErrCode BundleResourceProxy::GetParcelInfo(BundleResourceInterfaceCode code, Mes
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
} else {
|
||||
if (!GetData(buffer, dataSize, reply.ReadRawData(dataSize))) {
|
||||
if (!GetData(dataSize, reply.ReadRawData(dataSize), buffer)) {
|
||||
APP_LOGE("GetData failed dataSize: %{public}zu", dataSize);
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
@ -328,7 +328,7 @@ ErrCode BundleResourceProxy::GetVectorParcelInfo(
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
} else {
|
||||
if (!GetData(buffer, dataSize, reply.ReadRawData(dataSize))) {
|
||||
if (!GetData(dataSize, reply.ReadRawData(dataSize), buffer)) {
|
||||
APP_LOGE("GetData failed dataSize: %{public}zu", dataSize);
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
|
@ -136,8 +136,7 @@ bool BundleMgrClientImpl::GetResConfigFile(const HapModuleInfo &hapModuleInfo, c
|
||||
APP_LOGE("no valid file can be obtained");
|
||||
return false;
|
||||
}
|
||||
int32_t InfoSize = static_cast<int32_t>(profileInfos.size());
|
||||
APP_LOGD("The size of the profile info is : %{public}d", InfoSize);
|
||||
APP_LOGD("The size of the profile info is : %{public}zu", profileInfos.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -154,8 +153,7 @@ bool BundleMgrClientImpl::GetResConfigFile(const ExtensionAbilityInfo &extension
|
||||
APP_LOGE("no valid file can be obtained");
|
||||
return false;
|
||||
}
|
||||
int32_t InfoSize = static_cast<int32_t>(profileInfos.size());
|
||||
APP_LOGD("The size of the profile info is : %{public}d", InfoSize);
|
||||
APP_LOGD("The size of the profile info is : %{public}zu", profileInfos.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace AppExecFwk {
|
||||
BundleStreamInstallerHost::BundleStreamInstallerHost()
|
||||
{
|
||||
LOG_D(BMS_TAG_INSTALLER, "create bundle stream installer host instance");
|
||||
init();
|
||||
Init();
|
||||
}
|
||||
|
||||
int BundleStreamInstallerHost::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
@ -108,7 +108,7 @@ ErrCode BundleStreamInstallerHost::HandleInstall(MessageParcel &data, MessagePar
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void BundleStreamInstallerHost::init()
|
||||
void BundleStreamInstallerHost::Init()
|
||||
{
|
||||
funcMap_.emplace(static_cast<uint32_t>(BundleStreamInstallerInterfaceCode::CREATE_STREAM),
|
||||
[this](MessageParcel &data, MessageParcel &reply)->ErrCode {
|
||||
|
@ -40,10 +40,10 @@ void LauncherService::LauncherServiceDeathRecipient::OnRemoteDied([[maybe_unused
|
||||
|
||||
LauncherService::LauncherService()
|
||||
{
|
||||
init();
|
||||
Init();
|
||||
}
|
||||
|
||||
void LauncherService::init()
|
||||
void LauncherService::Init()
|
||||
{
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED);
|
||||
@ -266,7 +266,7 @@ ErrCode LauncherService::GetShortcutInfos(
|
||||
APP_LOGE("GetShortcutInfos is empty");
|
||||
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
|
||||
}
|
||||
if (infos.size() == 0) {
|
||||
if (infos.empty()) {
|
||||
APP_LOGE("infos size is empty");
|
||||
return ERR_BUNDLE_MANAGER_PROFILE_NOT_EXIST;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ int DefaultAppHost::OnRemoteRequest(
|
||||
case static_cast<uint32_t>(DefaultAppInterfaceCode::RESET_DEFAULT_APPLICATION):
|
||||
return HandleResetDefaultApplication(data, reply);
|
||||
default:
|
||||
LOG_W(BMS_TAG_DEFAULT, "DefaultAppHost receive unknown code, code = %{public}d", code);
|
||||
LOG_W(BMS_TAG_DEFAULT, "DefaultAppHost receive unknown code, code = %{public}zu", code);
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ napi_value SetDisposedStatus(napi_env env, napi_callback_info info)
|
||||
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
|
||||
return nullptr;
|
||||
}
|
||||
asyncCallbackInfo->err = asyncCallbackInfo->appId.size() == 0 ? ERROR_INVALID_APPID : NO_ERROR;
|
||||
asyncCallbackInfo->err = asyncCallbackInfo->appId.empty() ? ERROR_INVALID_APPID : NO_ERROR;
|
||||
} else if (i == ARGS_POS_ONE) {
|
||||
if (!CommonFunc::ParseWantWithoutVerification(env, args[i], asyncCallbackInfo->want)) {
|
||||
APP_LOGE("disposed want invalid");
|
||||
@ -195,7 +195,7 @@ napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info)
|
||||
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
|
||||
return nRet;
|
||||
}
|
||||
if (appId.size() == 0) {
|
||||
if (appId.empty()) {
|
||||
napi_value businessError = BusinessError::CreateCommonError(
|
||||
env, ERROR_INVALID_APPID, SET_DISPOSED_STATUS_SYNC);
|
||||
napi_throw(env, businessError);
|
||||
@ -282,7 +282,7 @@ napi_value DeleteDisposedStatus(napi_env env, napi_callback_info info)
|
||||
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
|
||||
return nullptr;
|
||||
}
|
||||
if (asyncCallbackInfo->appId.size() == 0) {
|
||||
if (asyncCallbackInfo->appId.empty()) {
|
||||
asyncCallbackInfo->err = ERROR_INVALID_APPID;
|
||||
}
|
||||
} else if (i == ARGS_POS_ONE) {
|
||||
@ -308,7 +308,7 @@ static napi_value InnerDeleteDisposedStatusSync(napi_env env, std::string &appId
|
||||
{
|
||||
napi_value nRet;
|
||||
napi_get_undefined(env, &nRet);
|
||||
if (appId.size() == 0) {
|
||||
if (appId.empty()) {
|
||||
napi_value businessError = BusinessError::CreateCommonError(
|
||||
env, ERROR_INVALID_APPID, DELETE_DISPOSED_STATUS_SYNC);
|
||||
napi_throw(env, businessError);
|
||||
@ -429,7 +429,7 @@ napi_value GetDisposedStatus(napi_env env, napi_callback_info info)
|
||||
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
|
||||
return nullptr;
|
||||
}
|
||||
if (asyncCallbackInfo->appId.size() == 0) {
|
||||
if (asyncCallbackInfo->appId.empty()) {
|
||||
asyncCallbackInfo->err = ERROR_INVALID_APPID;
|
||||
}
|
||||
} else if (i == ARGS_POS_ONE) {
|
||||
@ -466,7 +466,7 @@ napi_value GetDisposedStatusSync(napi_env env, napi_callback_info info)
|
||||
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
|
||||
return nullptr;
|
||||
}
|
||||
if (appId.size() == 0) {
|
||||
if (appId.empty()) {
|
||||
napi_value businessError = BusinessError::CreateCommonError(
|
||||
env, ERROR_INVALID_APPID, GET_DISPOSED_STATUS_SYNC);
|
||||
napi_throw(env, businessError);
|
||||
@ -613,7 +613,7 @@ bool ParseDiposedRule(napi_env env, napi_value nRule, DisposedRule &rule)
|
||||
|
||||
static napi_value InnerGetDisposedRule(napi_env env, std::string &appId, int32_t appIndex)
|
||||
{
|
||||
if (appId.size() == 0) {
|
||||
if (appId.empty()) {
|
||||
napi_value businessError = BusinessError::CreateCommonError(
|
||||
env, ERROR_INVALID_APPID, GET_DISPOSED_STATUS_SYNC);
|
||||
napi_throw(env, businessError);
|
||||
@ -723,7 +723,7 @@ napi_value SetDisposedRule(napi_env env, napi_callback_info info)
|
||||
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
|
||||
return nRet;
|
||||
}
|
||||
if (appId.size() == 0) {
|
||||
if (appId.empty()) {
|
||||
napi_value businessError = BusinessError::CreateCommonError(
|
||||
env, ERROR_INVALID_APPID, SET_DISPOSED_STATUS_SYNC);
|
||||
napi_throw(env, businessError);
|
||||
|
Loading…
Reference in New Issue
Block a user