fix code check

Signed-off-by: jiangwensai <jiangwensai@huawei.com>

Change-Id: Iffdccf0014fdbaac1a00b829e53b453c4dadc3b6
This commit is contained in:
jiangwensai
2022-03-13 10:27:29 +08:00
parent a2846ecfb2
commit 2cb8ac18d5
154 changed files with 108 additions and 160 deletions
Executable → Regular
+7 -7
View File
@@ -61,15 +61,15 @@ foundation/
└──foundation/aafwk/standard
   ├── frameworks
   │   └── kits
   │   └── ability # AbilityKit实现的核心代码
   │   └── ability # AbilityKit实现的核心代码
   ├── interfaces
   │   └── innerkits
   │      └── want # Ability之间交互的信息载体的对外接口
── services
├── abilitymgr # Ability管理服务框架代码
  ├── common # 日志组件目录
  ── test # 测试目录
  └── tools # aa命令代码目录
   │     └── want # Ability之间交互的信息载体的对外接口
── services
├── abilitymgr # Ability管理服务框架代码
  ├── common # 日志组件目录
  ── test # 测试目录
└── tools # aa命令代码目录
```
## 使用说明
@@ -31,7 +31,7 @@ public:
name_ = name;
priority_ = priority;
}
~SpecDispatcherConfig(){};
virtual ~SpecDispatcherConfig() = default;
std::string GetName()
{
return name_;
@@ -31,11 +31,11 @@ public:
DefaultWorkerPoolConfig() = default;
virtual ~DefaultWorkerPoolConfig() = default;
int GetMaxThreadCount(void) const override;
int GetMaxThreadCount() const override;
int GetCoreThreadCount(void) const override;
int GetCoreThreadCount() const override;
long GetKeepAliveTime(void) const override;
long GetKeepAliveTime() const override;
};
} // namespace AppExecFwk
} // namespace OHOS
@@ -42,10 +42,6 @@ ErrCode SpecTaskDispatcher::SyncDispatch(const std::shared_ptr<Runnable> &runnab
}
std::shared_ptr<Task> innerTask = std::make_shared<Task>(runnable, GetPriority(), shared_from_this());
if (innerTask == nullptr) {
HILOG_ERROR("SpecTaskDispatcher::SyncDispatch innerTask is nullptr");
return ERR_APPEXECFWK_CHECK_FAILED;
}
TracePointBeforePost(innerTask, false, SYNC_DISPATCHER_TAG);
HILOG_INFO("SpecTaskDispatcher::SyncDispatch into new sync task");
handler_->DispatchSync(runnable);
@@ -68,10 +64,6 @@ std::shared_ptr<Revocable> SpecTaskDispatcher::AsyncDispatch(const std::shared_p
}
std::shared_ptr<Task> innerTask = std::make_shared<Task>(runnable, GetPriority(), shared_from_this());
if (innerTask == nullptr) {
HILOG_ERROR("SpecTaskDispatcher::AsyncDispatch innerTask is nullptr");
return nullptr;
}
TracePointBeforePost(innerTask, true, ASYNC_DISPATCHER_TAG);
HILOG_INFO("SpecTaskDispatcher::AsyncDispatch into new async task");
handler_->Dispatch(runnable);
@@ -92,10 +84,6 @@ std::shared_ptr<Revocable> SpecTaskDispatcher::DelayDispatch(const std::shared_p
}
std::shared_ptr<Task> innerTask = std::make_shared<Task>(runnable, GetPriority(), shared_from_this());
if (innerTask == nullptr) {
HILOG_ERROR("SpecTaskDispatcher::DelayDispatch innerTask is nullptr");
return nullptr;
}
TracePointBeforePost(innerTask, true, DELAY_DISPATCHER_TAG);
handler_->Dispatch(runnable, delayMs);
HILOG_INFO("SpecTaskDispatcher::DelayDispatch end");
@@ -130,9 +130,6 @@ int TaskDispatcherContext::MapPriorityIndex(TaskPriority priority) const
default:
return DEFAULT_PRIORITY_INDEX;
}
HILOG_ERROR("TaskDispatcherContext.mapPriorityIndex unhandled priority=%{public}d", priority);
return DEFAULT_PRIORITY_INDEX;
}
std::shared_ptr<TaskDispatcher> TaskDispatcherContext::GetGlobalTaskDispatcher(TaskPriority priority)
@@ -23,14 +23,10 @@ DefaultThreadFactory::DefaultThreadFactory() : index_(1)
std::shared_ptr<Thread> DefaultThreadFactory::Create()
{
std::shared_ptr<Thread> pThread = std::make_shared<Thread>();
if (pThread != nullptr) {
int value = std::atomic_fetch_add(&index_, 1);
std::string name = std::string("PoolThread-") + std::to_string(value);
pThread->thread_name_ = name;
HILOG_INFO("DefaultThreadFactory::Create thread name is %{public}s", name.c_str());
} else {
HILOG_ERROR("DefaultThreadFactory::Create error, thread is nullptr");
}
int value = std::atomic_fetch_add(&index_, 1);
std::string name = std::string("PoolThread-") + std::to_string(value);
pThread->thread_name_ = name;
HILOG_INFO("DefaultThreadFactory::Create thread name is %{public}s", name.c_str());
return pThread;
}
@@ -16,17 +16,17 @@
namespace OHOS {
namespace AppExecFwk {
int DefaultWorkerPoolConfig::GetMaxThreadCount(void) const
int DefaultWorkerPoolConfig::GetMaxThreadCount() const
{
return DEFAULT_MAX_THREAD_COUNT;
}
int DefaultWorkerPoolConfig::GetCoreThreadCount(void) const
int DefaultWorkerPoolConfig::GetCoreThreadCount() const
{
return DEFAULT_CORE_THREAD_COUNT;
}
long DefaultWorkerPoolConfig::GetKeepAliveTime(void) const
long DefaultWorkerPoolConfig::GetKeepAliveTime() const
{
return DEFAULT_KEEP_ALIVE_TIME;
}
@@ -205,7 +205,7 @@ void TaskExecutor::Consume()
for (;;) {
if (terminated_.load() && delayTasks_->Empty()) {
HILOG_INFO("TaskExecutor::Consume delay task is empty");
break;
return;
}
std::shared_ptr<DelayTaskWrapper> delayTaskWrapper = delayTasks_->Take();
if (delayTaskWrapper == nullptr || delayTaskWrapper->runnable_ == nullptr) {
Executable → Regular
View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File
View File
+2
View File
@@ -139,6 +139,8 @@ private:
const AppExecFwk::ElementName &connectReceiver, sptr<AbilityConnection> abilityConnection,
const sptr<AbilityConnectCallback> &connectCallback);
std::map<ConnectionInfo, std::vector<sptr<AbilityConnectCallback>>> abilityConnections_;
ErrCode ConnectAbilityInner(const sptr<IRemoteObject> &connectCaller,
const AAFwk::Want &want, int accountId, const sptr<AbilityConnectCallback> &connectCallback);
};
} // namespace AbilityRuntime
} // namespace OHOS
View File
+7 -47
View File
@@ -33,57 +33,17 @@ ConnectionManager& ConnectionManager::GetInstance()
ErrCode ConnectionManager::ConnectAbility(const sptr<IRemoteObject> &connectCaller,
const AAFwk::Want &want, const sptr<AbilityConnectCallback> &connectCallback)
{
if (connectCaller == nullptr || connectCallback == nullptr) {
HILOG_ERROR("%{public}s, connectCaller or connectCallback is nullptr.", __func__);
return ERR_INVALID_VALUE;
}
AppExecFwk::ElementName connectReceiver = want.GetElement();
HILOG_DEBUG("%{public}s begin, connectCaller: %{public}p, connectReceiver: %{public}s.",
__func__, connectCaller.GetRefPtr(),
(connectReceiver.GetBundleName() + ":" + connectReceiver.GetAbilityName()).c_str());
sptr<AbilityConnection> abilityConnection;
auto item = std::find_if(abilityConnections_.begin(), abilityConnections_.end(),
[&connectCaller, &connectReceiver](const std::map<ConnectionInfo,
std::vector<sptr<AbilityConnectCallback>>>::value_type &obj) {
return connectCaller == obj.first.connectCaller &&
connectReceiver.GetBundleName() == obj.first.connectReceiver.GetBundleName() &&
connectReceiver.GetAbilityName() == obj.first.connectReceiver.GetAbilityName();
});
if (item != abilityConnections_.end()) {
std::vector<sptr<AbilityConnectCallback>> callbacks = item->second;
callbacks.push_back(connectCallback);
abilityConnections_[item->first] = callbacks;
abilityConnection = item->first.abilityConnection;
abilityConnection->SetConnectCallback(connectCallback);
HILOG_INFO("%{public}s end, find abilityConnection:%{public}p exist, callbackSize:%{public}d.",
__func__, abilityConnection.GetRefPtr(), (int32_t)callbacks.size());
if (abilityConnection->GetResultCode() == ERR_OK) {
connectCallback->OnAbilityConnectDone(connectReceiver, abilityConnection->GetRemoteObject(),
abilityConnection->GetResultCode());
return ERR_OK;
} else {
return HandleCallbackTimeOut(connectCaller, want, connectReceiver, abilityConnection, connectCallback);
}
} else {
abilityConnection = new AbilityConnection(connectCallback);
ErrCode ret =
AAFwk::AbilityManagerClient::GetInstance()->ConnectAbility(want, abilityConnection, connectCaller);
if (ret == ERR_OK) {
ConnectionInfo connectionInfo(connectCaller, connectReceiver, abilityConnection);
std::vector<sptr<AbilityConnectCallback>> callbacks;
callbacks.push_back(connectCallback);
abilityConnections_[connectionInfo] = callbacks;
}
HILOG_DEBUG("%{public}s end, not find connection, connection: %{public}p, abilityConnectionsSize:%{public}d.",
__func__, abilityConnection.GetRefPtr(), (int32_t)abilityConnections_.size());
return ret;
}
return ConnectAbilityInner(connectCaller, want, AAFwk::DEFAULT_INVAL_VALUE, connectCallback);
}
ErrCode ConnectionManager::ConnectAbilityWithAccount(const sptr<IRemoteObject> &connectCaller,
const AAFwk::Want &want, int accountId, const sptr<AbilityConnectCallback> &connectCallback)
{
return ConnectAbilityInner(connectCaller, want, accountId, connectCallback);
}
ErrCode ConnectionManager::ConnectAbilityInner(const sptr<IRemoteObject> &connectCaller,
const AAFwk::Want &want, int accountId, const sptr<AbilityConnectCallback> &connectCallback)
{
if (connectCaller == nullptr || connectCallback == nullptr) {
HILOG_ERROR("%{public}s, connectCaller or connectCallback is nullptr.", __func__);
-1
View File
@@ -326,7 +326,6 @@ ohos_shared_library("dummy_classes") {
sources = [
"${SUBSYSTEM_DIR}/src/dummy_data_ability_predicates_discard.cpp",
"${SUBSYSTEM_DIR}/src/dummy_result_set_discard.cpp",
"${SUBSYSTEM_DIR}/src/dummy_values_bucket_discard.cpp",
]
configs = [ ":ability_config" ]
@@ -463,6 +463,7 @@ private:
class InputEventConsumerImpl : public MMI::IInputEventConsumer {
public:
explicit InputEventConsumerImpl(const std::shared_ptr<AbilityImpl>& abilityImpl) : abilityImpl_(abilityImpl) {}
~InputEventConsumerImpl() = default;
void OnInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) const override;
void OnInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const override;
void OnInputEvent(std::shared_ptr<MMI::AxisEvent> axisEvent) const override {}
View File
View File
View File
@@ -1,14 +0,0 @@
/*
* Copyright (c) 2021 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
@@ -23,9 +23,9 @@ public:
SharedMemory() = default;
~SharedMemory() = default;
static void ReleaseShmId(const int shmId);
static void ReleaseShmId(int shmId);
static void* PopSharedMemory(int shmKey, int size);
static int PushSharedMemory(const void *data, const int size);
static int PushSharedMemory(const void *data, int size);
};
} // namespace AAFwk
} // namespace OHOS
View File
View File
View File
View File
View File
View File
View File
View File
+5 -2
View File
@@ -74,8 +74,11 @@ napi_value NAPI_KillProcessesByBundleName(napi_env env, napi_callback_info info)
NAPI_ASSERT(env, valuetype == napi_function, "Wrong argument type. Function expected.");
}
AsyncCallbackInfo *async_callback_info =
new AsyncCallbackInfo { .env = env, .asyncWork = nullptr, .deferred = nullptr };
AsyncCallbackInfo *async_callback_info = new AsyncCallbackInfo {
.env = env,
.asyncWork = nullptr,
.deferred = nullptr
};
std::string bundleName;
ParseBundleName(env, bundleName, argv[0]);
View File
View File
View File
@@ -209,7 +209,7 @@ napi_value UnwrapDataAbilityPredicatesBackReferences(
return result;
}
void SetNamedProperty(napi_env env, napi_value obj, const char *propName, const int propValue)
void SetNamedProperty(napi_env env, napi_value obj, const char *propName, int propValue)
{
napi_value prop = nullptr;
napi_create_int32(env, propValue, &prop);
@@ -33,7 +33,7 @@ namespace AppExecFwk {
* @return The return value from Init is treated as the exports object for the module.
*/
napi_value DataAbilityOperationInit(napi_env env, napi_value exports);
void SetNamedProperty(napi_env env, napi_value obj, const char *propName, const int propValue);
void SetNamedProperty(napi_env env, napi_value obj, const char *propName, int propValue);
/**
* @brief Parse the dataAbilityOperation parameters.
*
@@ -47,7 +47,7 @@ napi_value UnwrapDataAbilityOperation(std::shared_ptr<DataAbilityOperation> &par
napi_value BuildDataAbilityOperation(
std::shared_ptr<DataAbilityOperation> &dataAbilityOperation, napi_env env, napi_value param);
bool GetDataAbilityOperationBuilder(
std::shared_ptr<DataAbilityOperationBuilder> &builder, const int type, const std::shared_ptr<Uri> &uri);
std::shared_ptr<DataAbilityOperationBuilder> &builder, int type, const std::shared_ptr<Uri> &uri);
/**
* @brief Parse the ValuesBucket parameters.
*
@@ -541,6 +541,47 @@ bool UnwrapArrayStringFromJS(napi_env env, napi_value param, std::vector<std::st
return true;
}
bool UnwrapArrayComplexFromJSNumber(napi_env env, ComplexArrayData &value, bool isDouble, napi_value jsValue)
{
int32_t elementInt32 = 0;
double elementDouble = 0.0;
if (isDouble) {
if (napi_get_value_double(env, jsValue, &elementDouble) == napi_ok) {
value.doubleList.push_back(elementDouble);
}
return isDouble;
}
bool isReadValue32 = napi_get_value_int32(env, jsValue, &elementInt32) == napi_ok;
bool isReadDouble = napi_get_value_double(env, jsValue, &elementDouble) == napi_ok;
if (isReadValue32 && isReadDouble) {
if (abs(elementDouble - elementInt32 * 1.0) > 0.0) {
isDouble = true;
if (value.intList.size() > 0) {
for (size_t j = 0; j < value.intList.size(); j++) {
value.doubleList.push_back(value.intList[j]);
}
value.intList.clear();
}
value.doubleList.push_back(elementDouble);
} else {
value.intList.push_back(elementInt32);
}
} else if (isReadValue32) {
value.intList.push_back(elementInt32);
} else if (isReadDouble) {
isDouble = true;
if (value.intList.size() > 0) {
for (size_t j = 0; j < value.intList.size(); j++) {
value.doubleList.push_back(value.intList[j]);
}
value.intList.clear();
}
value.doubleList.push_back(elementDouble);
}
return isDouble;
}
bool UnwrapArrayComplexFromJS(napi_env env, napi_value param, ComplexArrayData &value)
{
uint32_t arraySize = 0;
@@ -580,42 +621,7 @@ bool UnwrapArrayComplexFromJS(napi_env env, napi_value param, ComplexArrayData &
break;
}
case napi_number: {
int32_t elementInt32 = 0;
double elementDouble = 0.0;
if (isDouble) {
if (napi_get_value_double(env, jsValue, &elementDouble) == napi_ok) {
value.doubleList.push_back(elementDouble);
}
break;
} else {
bool isReadValue32 = napi_get_value_int32(env, jsValue, &elementInt32) == napi_ok;
bool isReadDouble = napi_get_value_double(env, jsValue, &elementDouble) == napi_ok;
if (isReadValue32 && isReadDouble) {
if (abs(elementDouble - elementInt32 * 1.0) > 0.0) {
isDouble = true;
if (value.intList.size() > 0) {
for (size_t j = 0; j < value.intList.size(); j++) {
value.doubleList.push_back(value.intList[j]);
}
value.intList.clear();
}
value.doubleList.push_back(elementDouble);
} else {
value.intList.push_back(elementInt32);
}
} else if (isReadValue32) {
value.intList.push_back(elementInt32);
} else if (isReadDouble) {
isDouble = true;
if (value.intList.size() > 0) {
for (size_t j = 0; j < value.intList.size(); j++) {
value.doubleList.push_back(value.intList[j]);
}
value.intList.clear();
}
value.doubleList.push_back(elementDouble);
}
}
isDouble = UnwrapArrayComplexFromJSNumber(env, value, isDouble, jsValue);
break;
}
default:
@@ -1169,7 +1175,10 @@ std::vector<uint8_t> ConvertU8Vector(napi_env env, napi_value jsValue)
NAPI_CALL_BASE(env, napi_get_arraybuffer_info(env, buffer, reinterpret_cast<void **>(&data), &total), {});
length = std::min<size_t>(length, total - offset);
std::vector<uint8_t> result(sizeof(uint8_t) + length);
memcpy_s(result.data(), result.size(), &data[offset], length);
int retCode = memcpy_s(result.data(), result.size(), &data[offset], length);
if (retCode != 0) {
return {};
}
return result;
}
View File
View File
View File
@@ -42,6 +42,7 @@ void AbilityConnectionProxy::OnAbilityConnectDone(
MessageOption option;
if (!WriteInterfaceToken(data)) {
HILOG_ERROR("Write interface token failed.");
return;
}
@@ -75,6 +76,7 @@ void AbilityConnectionProxy::OnAbilityDisconnectDone(const AppExecFwk::ElementNa
MessageOption option(MessageOption::TF_ASYNC);
if (!WriteInterfaceToken(data)) {
HILOG_ERROR("Write interface token failed.");
return;
}
if (!data.WriteParcelable(&element) || !data.WriteInt32(resultCode)) {
View File
View File
View File
@@ -114,11 +114,10 @@ bool LockScreenWhiteList::FindBundleNameOnWhiteList(const std::string &bundleNam
isAwakenScreen = jsonFile.at(bundleName).at(AmsWhiteList::ISAWAKEN_SCREEN).get<bool>();
jsonFile.clear();
return true;
} else {
HILOG_INFO("json info not contains bundleName...");
jsonFile.clear();
return false;
}
HILOG_INFO("json info not contains bundleName...");
jsonFile.clear();
return false;
}
bool LockScreenWhiteList::IsExistFile(const std::string &path)
View File
View File
+2 -2
View File
@@ -34,7 +34,7 @@ constexpr unsigned int SHM_READ_WRITE_PERMISSIONS = 0666U;
#endif
}
void SharedMemory::ReleaseShmId(const int shmId)
void SharedMemory::ReleaseShmId(int shmId)
{
if (shmId == -1) {
return;
@@ -45,7 +45,7 @@ void SharedMemory::ReleaseShmId(const int shmId)
}
}
int SharedMemory::PushSharedMemory(const void *data, const int size)
int SharedMemory::PushSharedMemory(const void *data, int size)
{
// internal call, no need to check null.
static int shmKey = SHM_KEY_START;
View File
View File
View File
@@ -358,6 +358,11 @@ void AppMgrServiceInner::ApplicationBackgrounded(const int32_t recordId)
void AppMgrServiceInner::ApplicationTerminated(const int32_t recordId)
{
BYTRACE_NAME(BYTRACE_TAG_APP, __PRETTY_FUNCTION__);
if (!appRunningManager_) {
HILOG_ERROR("appRunningManager_ is nullptr");
return;
}
auto appRecord = GetAppRunningRecordByAppRecordId(recordId);
if (!appRecord) {
HILOG_ERROR("get app record failed");
View File
+7 -6
View File
@@ -237,13 +237,14 @@ int FormDataMgr::CheckEnoughForm(const int callingUid, const int32_t currentUser
return ERR_APPEXECFWK_FORM_MAX_SYSTEM_FORMS;
}
for (auto &userUid : record.formUserUids) {
if (userUid == callingUid) {
if (++callingUidFormCounts >= Constants::MAX_RECORD_PER_APP) {
HILOG_WARN("%{public}s, already use %{public}d forms", __func__, Constants::MAX_RECORD_PER_APP);
return ERR_APPEXECFWK_FORM_MAX_FORMS_PER_CLIENT;
}
break;
if (userUid != callingUid) {
continue;
}
if (++callingUidFormCounts >= Constants::MAX_RECORD_PER_APP) {
HILOG_WARN("%{public}s, already use %{public}d forms", __func__, Constants::MAX_RECORD_PER_APP);
return ERR_APPEXECFWK_FORM_MAX_FORMS_PER_CLIENT;
}
break;
}
}
}
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File

Some files were not shown because too many files have changed in this diff Show More