sync aafwk to release3.1

Signed-off-by: zhongjianfei <zhongjianfei@huawei.com>
Change-Id: I0436a3a061297b02b50bef0861d66e8243419b5e
This commit is contained in:
zhongjianfei
2022-03-11 10:26:13 +08:00
parent 801026a114
commit 9a9cd53c84
345 changed files with 4607 additions and 1758 deletions
+8
View File
@@ -24,3 +24,11 @@ dispatcher_path = "${aafwk_path}/common/task_dispatcher"
system_test_app_path =
"${aafwk_path}/test/resource/amssystemtestability/abilitySrc"
declare_args() {
background_task_mgr_continuous_task_enable = true
if (!defined(global_parts_info.resourceschedule_background_task_mgr)) {
background_task_mgr_continuous_task_enable = false
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -30,7 +30,6 @@ namespace AppExecFwk {
/**
* Base implementation for interface of TaskDispatcher.
*/
class BaseTaskDispatcher : public TaskDispatcher {
public:
BaseTaskDispatcher(const std::string &dispatcherName, const TaskPriority priority);
@@ -90,7 +89,7 @@ public:
/**
* Synchronously waiting all tasks in the group to be done.
* @param group contains a serial of jobs.
* @param group contains a serial of jobs.
* @param timeout is the max waiting time for jobs in group execute, in ms.
* @return true if all jobs in group has finished or false if timeout occurs.
*
@@ -110,7 +109,7 @@ public:
/**
* Called to dispatch |task| |iterations| times and wait.
*
* @param task is the job to execute multi times.
* @param task is the job to execute multi times.
* @param iterations indicates times the task should be executed.
*
*/
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -55,6 +55,7 @@ struct PriorityTaskWrapper {
static constexpr int DEFAULT_PRIORITY_WEIGHT = 1;
static constexpr int LOW_PRIORITY_WEIGHT = 0;
};
struct CompareTaskPriority {
bool operator()(const std::shared_ptr<PriorityTaskWrapper> &wrapper1,
const std::shared_ptr<PriorityTaskWrapper> &wrapper2) const
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_APP_DISPATCHER_SERIAL_TASK_DISPATCHER_H
#define OHOS_APP_DISPATCHER_SERIAL_TASK_DISPATCHER_H
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -95,7 +95,7 @@ bool GroupImpl::AddNotification(const std::shared_ptr<Runnable> &notification)
if (count_.load() != 0) {
std::unique_lock<std::mutex> lock(dataMutex_);
if (notifications_.size() == MAX_TASK) {
HILOG_WARN("GroupImpl::AddNotification called maximun number of tasks exceeded");
HILOG_WARN("GroupImpl::AddNotification called maximum number of tasks exceeded");
return false;
}
if (count_.load() != 0) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
+5 -4
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -208,9 +208,10 @@ void Task::ConcurrentQueueStatusUpdate(const TaskStage::TASKSTAGE taskstage)
bool Task::operator==(std::shared_ptr<Task> &rec) const
{
return this->sequence_ == rec->sequence_ && this->state_ == rec->state_ && this->priority_ == rec->priority_ &&
this->revocable_ == rec->revocable_ && this->runnable_ == rec->runnable_ &&
this->baseTaskDispatcher_ == rec->baseTaskDispatcher_;
return ((this->sequence_ == rec->sequence_) && (this->state_ == rec->state_) &&
(this->priority_ == rec->priority_) &&
(this->revocable_ == rec->revocable_) && (this->runnable_ == rec->runnable_) &&
(this->baseTaskDispatcher_ == rec->baseTaskDispatcher_));
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -49,7 +49,7 @@ WorkerPool::~WorkerPool()
bool WorkerPool::Init(const std::shared_ptr<WorkerPoolConfig> &config)
{
if (CheckConfigParams(config) == false) {
if (!CheckConfigParams(config)) {
HILOG_ERROR("WorkerPool::checkConfigParams parameters are illegal");
return false;
}
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -64,7 +64,7 @@ std::shared_ptr<ParallelTaskDispatcher> ParallelTaskDispatcherModuleTest::Create
HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_LifeCycleTest_001, TestSize.Level1)
{
auto name = std::string("ParallelTaskDispatcher_LifeCycleTest_001");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::shared_ptr<ParallelTaskDispatcher> ptr = CreateMtParallelTaskDispatcher(name, TaskPriority::DEFAULT);
std::atomic<int> count(0);
std::shared_ptr<Runnable> runnable = std::make_shared<Runnable>([&]() {
@@ -161,7 +161,7 @@ HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_AsyncDispatchT
HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_AsyncGroupDispatchTest_001, TestSize.Level1)
{
auto name = std::string("ParallelTaskDispatcher_AsyncGroupDispatchTest_001");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::shared_ptr<ParallelTaskDispatcher> ptr = CreateMtParallelTaskDispatcher(name, TaskPriority::DEFAULT);
std::atomic<int> count(0);
long sleep1 = 200;
@@ -205,7 +205,7 @@ HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_AsyncGroupDisp
HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_AsyncGroupDispatchTest_002, TestSize.Level1)
{
auto name = std::string("ParallelTaskDispatcher_AsyncGroupDispatchTest_002");
GTEST_LOG_(INFO) << name + " start";
GTEST_LOG_(INFO) << (name + " start");
std::shared_ptr<ParallelTaskDispatcher> ptr = CreateMtParallelTaskDispatcher(name, TaskPriority::DEFAULT);
std::shared_ptr<Group> group = ptr->CreateDispatchGroup();
ptr->AsyncGroupDispatch(group, std::make_shared<Runnable>([&]() {
@@ -246,7 +246,7 @@ HWTEST_F(ParallelTaskDispatcherModuleTest, ParallelTaskDispatcher_ApplyDispatchT
int index = count.fetch_add(1);
EXPECT_TRUE(index >= repeatCount);
EXPECT_TRUE(index < repeatCount * 2);
GTEST_LOG_(INFO) << name + " repeats1";
GTEST_LOG_(INFO) << (name + " repeats1");
});
ptr->ApplyDispatch(repeats1, repeatCount);
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -34,6 +34,7 @@ void AbilityConnection::OnAbilityConnectDone(
HILOG_DEBUG("%{public}s begin.", __func__);
if (abilityConnectCallback_ == nullptr) {
HILOG_ERROR("%{public}s abilityConnectCallback is nullptr.", __func__);
return;
}
SetRemoteObject(remoteObject);
SetResultCode(resultCode);
@@ -47,6 +48,7 @@ void AbilityConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &e
HILOG_DEBUG("%{public}s begin, resultCode:%{public}d.", __func__, resultCode);
if (abilityConnectCallback_ == nullptr) {
HILOG_ERROR("%{public}s abilityConnectCallback is nullptr.", __func__);
return;
}
// if resultCode < 0 that means the connectReceiver is died
if (resultCode == DIED) {
@@ -344,7 +344,7 @@ ErrCode AbilityContextImpl::RestoreWindowStage(NativeEngine& engine, NativeValue
ErrCode AbilityContextImpl::StartAbility(
const AAFwk::Want& want, const std::shared_ptr<CallerCallBack> &callback)
{
if (!localCallContainer_) {
if (localCallContainer_ == nullptr) {
localCallContainer_ = new (std::nothrow)LocalCallContainer();
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -158,12 +158,6 @@ bool MockServiceAbilityManagerService::IsFirstInMission(const sptr<IRemoteObject
return true;
}
int MockServiceAbilityManagerService::CompelVerifyPermission(
const std::string &permission, int pid, int uid, std::string &message)
{
return 0;
}
int MockServiceAbilityManagerService::PowerOff()
{
return 0;
@@ -95,7 +95,7 @@ public:
MOCK_METHOD1(GetAllStackInfo, int(StackInfo &stackInfo));
MOCK_METHOD1(MoveMissionToTop, int(int32_t missionId));
MOCK_METHOD1(KillProcess, int(const std::string &bundleName));
MOCK_METHOD1(UninstallApp, int(const std::string &bundleName));
MOCK_METHOD2(UninstallApp, int(const std::string &bundleName, int32_t uid));
MOCK_METHOD2(
GetWantSender, sptr<IWantSender>(const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken));
MOCK_METHOD2(SendWantSender, int(const sptr<IWantSender> &target, const SenderInfo &senderInfo));
@@ -140,12 +140,12 @@ public:
MOCK_METHOD0(CleanAllMissions, int());
MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId));
MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions &startOptions));
MOCK_METHOD1(GetMissionIdByToken, int32_t(const sptr<IRemoteObject> &token));
MOCK_METHOD2(GetWantSenderInfo, int(const sptr<IWantSender> &target, std::shared_ptr<WantSenderInfo> &info));
int MoveMissionToEnd(const sptr<IRemoteObject> &token, const bool nonFirst) override;
bool IsFirstInMission(const sptr<IRemoteObject> &token) override;
int CompelVerifyPermission(const std::string &permission, int pid, int uid, std::string &message) override;
int RemoveMission(int id) override;
@@ -55,7 +55,7 @@ void AbilityCallerTest::SetUpTestCase(void)
OHOS::sptr<OHOS::IRemoteObject> abilityObject = new (std::nothrow) MockServiceAbilityManagerService();
auto sysMgr = OHOS::DelayedSingleton<SysMrgClient>::GetInstance();
if (sysMgr == NULL) {
if (sysMgr == nullptr) {
GTEST_LOG_(ERROR) << "fail to get ISystemAbilityManager";
return;
}
+9 -2
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
@@ -12,6 +12,7 @@
# limitations under the License.
import("//build/ohos.gni")
import("//foundation/aafwk/standard/aafwk.gni")
import("//foundation/aafwk/standard/feature.gni")
SUBSYSTEM_DIR = "//foundation/aafwk/standard/frameworks/kits/ability/native"
INNERKITS_PATH = "//foundation/aafwk/standard/interfaces/innerkits"
@@ -253,7 +254,6 @@ ohos_shared_library("abilitykit_native") {
"ability_runtime:task_dispatcher",
"ability_runtime:wantagent_innerkits",
"access_token:libaccesstoken_sdk",
"background_task_mgr:bgtaskmgr_innerkits",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"bytrace_standard:bytrace_core",
@@ -264,12 +264,19 @@ ohos_shared_library("abilitykit_native") {
"native_appdatamgr:native_appdatafwk",
"native_appdatamgr:native_dataability",
"native_appdatamgr:native_rdb",
"os_account_standard:os_account_innerkits",
"permission_standard:libpermissionsdk_standard",
"resmgr_standard:global_resmgr",
"samgr_standard:samgr_proxy",
"utils_base:utils",
]
defines = []
if (background_task_mgr_continuous_task_enable) {
external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
defines += [ "BGTASKMGR_CONTINUOUS_TASK_ENABLE" ]
}
public_deps = [
"//base/global/resmgr_standard/frameworks/resmgr:global_resmgr",
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
@@ -45,6 +45,7 @@
#include "form_death_callback.h"
#include "form_info.h"
#include "form_provider_info.h"
#include "form_state_info.h"
#include "foundation/multimodalinput/input/interfaces/native/innerkits/event/include/key_event.h"
#include "foundation/multimodalinput/input/interfaces/native/innerkits/event/include/pointer_event.h"
#endif
@@ -1281,6 +1282,13 @@ public:
* @param message Form event message.
*/
virtual void OnTriggerEvent(const int64_t formId, const std::string &message);
/**
* @brief Called to notify the form supplier to acquire form state.
*
* @param want Indicates the detailed information about the form to be obtained, including
* the bundle name, module name, ability name, form name and form dimension.
*/
virtual FormState OnAcquireFormState(const Want &want);
/**
* @brief Requests for form data update.
*
@@ -1328,6 +1336,24 @@ public:
*/
bool CheckFMSReady();
/**
* @brief Delete the given invalid forms.
*
* @param formIds Indicates the ID of the forms to delete.
* @param numFormsDeleted Returns the number of the deleted forms.
* @return Returns true if the request is successfully initiated; returns false otherwise.
*/
ErrCode DeleteInvalidForms(const std::vector<int64_t> &formIds, int32_t &numFormsDeleted);
/**
* @brief Acquire form state info by passing a set of parameters (using Want) to the form provider.
*
* @param want Indicates a set of parameters to be transparently passed to the form provider.
* @param stateInfo Returns the form's state info of the specify.
* @return Returns true if the request is successfully initiated; returns false otherwise.
*/
ErrCode AcquireFormState(const Want &want, FormStateInfo &stateInfo);
/**
* @brief Get All FormsInfo.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -398,53 +398,6 @@ public:
*/
std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager() const override;
/**
* @brief Checks whether the current process has the given permission.
* You need to call requestPermissionsFromUser(java.lang.std::string[],int) to request a permission only
* if the current process does not have the specific permission.
*
* @param permission Indicates the permission to check. This parameter cannot be null.
*
* @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission;
* returns -1 (IBundleManager.PERMISSION_DENIED) otherwise.
*/
virtual int VerifySelfPermission(const std::string &permission) override;
/**
* @brief Checks whether the calling process for inter-process communication has the given permission.
* The calling process is not the current process.
*
* @param permission Indicates the permission to check. This parameter cannot be null.
*
* @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the calling process has the permission;
* returns -1 (IBundleManager.PERMISSION_DENIED) otherwise.
*/
virtual int VerifyCallingPermission(const std::string &permission) override;
/**
* @brief Confirms with the permission management module to check whether a request prompt is required for granting
* a certain permission. You need to call the current method to check whether a prompt is required before calling
* requestPermissionsFromUser(java.lang.String[],int) to request a permission. If a prompt is not required,
* permission request will not be initiated.
*
* @param requestCode Indicates the permission to be queried. This parameter cannot be null.
*
* @return Returns true if the current application does not have the permission and the user does not turn off
* further requests; returns false if the current application already has the permission, the permission is rejected
* by the system, or the permission is denied by the user and the user has turned off further requests.
*/
virtual bool CanRequestPermission(const std::string &permission) override;
/**
* @brief When there is a remote call to check whether the remote has permission, otherwise check whether it has
* permission
*
* @param permissions Indicates the list of permissions to be requested. This parameter cannot be null.
* @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission;
* returns -1 (IBundleManager.PERMISSION_DENIED) otherwise.
*/
virtual int VerifyCallingOrSelfPermission(const std::string &permission) override;
/**
* @brief Query whether the application of the specified PID and UID has been granted a certain permission
*
@@ -49,17 +49,17 @@ public:
std::shared_ptr<ContextDeal> &contextDeal);
/**
* @brief Set if use new mission.
*
* @param useNewMission new mission flag.
*/
* @brief Set if use new mission.
*
* @param useNewMission new mission flag.
*/
static void SetUseNewMission(bool useNewMission);
/**
* @brief Get if use new mission.
*
* @return return true if use new mission.
*/
/**
* @brief Get if use new mission.
*
* @return return true if use new mission.
*/
static bool IsUseNewMission();
/**
@@ -18,6 +18,7 @@
#include "extension_base.h"
#include "form_provider_info.h"
#include "form_state_info.h"
namespace OHOS {
namespace AbilityRuntime {
@@ -128,6 +129,15 @@ public:
* @return none.
*/
virtual void OnVisibilityChange(const std::map<int64_t, int32_t>& formEventsMap);
/**
* @brief Called to notify the form provider to acquire form state.
*
* @param want Indicates the detailed information about the form to be obtained, including
* the bundle name, module name, ability name, form name and form dimension.
* @return none.
*/
virtual FormState OnAcquireFormState(const Want &want);
};
} // namespace AbilityRuntime
} // namespace OHOS
@@ -123,6 +123,16 @@ public:
const std::string &message,
const Want &want,
const sptr<IRemoteObject> &callerToken) override;
/**
* @brief Acquire form state to form provider.
* @param wantArg The want of onAcquireFormState.
* @param want The want of the request.
* @param callerToken Form provider proxy object.
* @return Returns ERR_OK on success, others on failure.
*/
virtual int AcquireState(const Want &wantArg, const Want &want, const sptr<IRemoteObject> &callerToken) override;
/**
* @brief Set the owner ability of the form provider client.
*
@@ -144,6 +154,8 @@ protected:
int HandleDisconnect(const Want &want, const sptr<IRemoteObject> &callerToken);
int HandleAcquire(const FormProviderInfo &formProviderInfo, const Want &newWant,
const sptr<IRemoteObject> &callerToken);
int HandleAcquireStateResult(FormState state, int errorCode, const Want &want,
const sptr<IRemoteObject> &callerToken);
private:
std::shared_ptr<Ability> GetOwner();
@@ -107,6 +107,15 @@ public:
virtual int FireFormEvent(const int64_t formId, const std::string &message,
const Want &want, const sptr<IRemoteObject> &callerToken) override;
/**
* @brief Acquire form state to form provider.
* @param wantArg The want of onAcquireFormState.
* @param want The want of the request.
* @param callerToken Form provider proxy object.
* @return Returns ERR_OK on success, others on failure.
*/
virtual int AcquireState(const Want &wantArg, const Want &want, const sptr<IRemoteObject> &callerToken) override;
/**
* @brief Set the owner form extension of the form provider client.
*
@@ -141,6 +150,7 @@ private:
const sptr<IRemoteObject> &callerToken);
void FireFormExtensionEvent(const int64_t formId, const std::string &message, const Want &want,
const sptr<IRemoteObject> &callerToken);
void NotifyFormExtensionAcquireState(const Want &wantArg, const Want &want, const sptr<IRemoteObject> &callerToken);
private:
mutable std::mutex formExtensionMutex_;
+107 -16
View File
@@ -23,7 +23,9 @@
#include "ability_post_event_timeout.h"
#include "ability_runtime/js_ability.h"
#include "abs_shared_result_set.h"
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
#include "background_task_mgr_helper.h"
#endif
#include "bytrace.h"
#include "configuration_convertor.h"
#include "connection_manager.h"
@@ -31,7 +33,9 @@
#include "continuation_manager.h"
#include "continuation_register_manager.h"
#include "continuation_register_manager_proxy.h"
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
#include "continuous_task_param.h"
#endif
#include "data_ability_operation.h"
#include "data_ability_predicates.h"
#include "data_ability_result.h"
@@ -291,12 +295,14 @@ void Ability::OnStart(const Want &want)
HILOG_ERROR("%{public}s error, resConfig is nullptr.", __func__);
return;
}
resConfig->SetScreenDensity(ConvertDensity(density));
resConfig->SetDirection(ConvertDirection(height, width));
auto resourceManager = GetResourceManager();
if (resourceManager != nullptr) {
resourceManager->GetResConfig(*resConfig);
resConfig->SetScreenDensity(ConvertDensity(density));
resConfig->SetDirection(ConvertDirection(height, width));
resourceManager->UpdateResConfig(*resConfig);
HILOG_INFO("%{public}s Notify ResourceManager.", __func__);
HILOG_INFO("%{public}s Notify ResourceManager, Density: %{public}d, Direction: %{public}d.", __func__,
resConfig->GetScreenDensity(), resConfig->GetDirection());
}
}
}
@@ -1012,8 +1018,13 @@ void Ability::OnConfigurationUpdatedNotify(const Configuration &changeConfigurat
// Notify ResourceManager
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
if (resConfig != nullptr) {
HILOG_INFO("make resource mgr data");
if (resConfig == nullptr) {
HILOG_ERROR("Create res config failed.");
return;
}
auto resourceManager = GetResourceManager();
if (resourceManager != nullptr) {
resourceManager->GetResConfig(*resConfig);
#ifdef SUPPORT_GRAPHICS
if (!language.empty()) {
UErrorCode status = U_ZERO_ERROR;
@@ -1025,13 +1036,10 @@ void Ability::OnConfigurationUpdatedNotify(const Configuration &changeConfigurat
}
#endif
resConfig->SetColorMode(ConvertColorMode(colormode));
auto resourceManager = GetResourceManager();
if (resourceManager != nullptr) {
resourceManager->UpdateResConfig(*resConfig);
HILOG_INFO("%{public}s Notify ResourceManager.", __func__);
}
resourceManager->UpdateResConfig(*resConfig);
HILOG_INFO("Notify ResourceManager, colorMode: %{public}d.", resConfig->GetColorMode());
}
#ifdef SUPPORT_GRAPHICS
// Notify WindowScene
if (scene_ != nullptr && !language.empty()) {
@@ -2116,10 +2124,14 @@ ErrCode Ability::DeleteForm(const int64_t formId)
*/
int Ability::StartBackgroundRunning(const AbilityRuntime::WantAgent::WantAgent &wantAgent)
{
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
uint32_t defaultBgMode = 0;
BackgroundTaskMgr::ContinuousTaskParam taskParam = BackgroundTaskMgr::ContinuousTaskParam(false, defaultBgMode,
std::make_shared<AbilityRuntime::WantAgent::WantAgent>(wantAgent), abilityInfo_->name, GetToken());
return BackgroundTaskMgr::BackgroundTaskMgrHelper::RequestStartBackgroundRunning(taskParam);
#else
return ERR_INVALID_OPERATION;
#endif
}
/**
@@ -2129,7 +2141,11 @@ int Ability::StartBackgroundRunning(const AbilityRuntime::WantAgent::WantAgent &
*/
int Ability::StopBackgroundRunning()
{
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
return BackgroundTaskMgr::BackgroundTaskMgrHelper::RequestStopBackgroundRunning(abilityInfo_->name, GetToken());
#else
return ERR_INVALID_OPERATION;
#endif
}
#ifdef SUPPORT_GRAPHICS
@@ -2478,6 +2494,17 @@ void Ability::OnVisibilityChanged(const std::map<int64_t, int32_t> &formEventsMa
*/
void Ability::OnTriggerEvent(const int64_t formId, const std::string &message)
{}
/**
* @brief Called to notify the form supplier to acquire form state.
*
* @param want Indicates the detailed information about the form to be obtained, including
* the bundle name, module name, ability name, form name and form dimension.
*/
FormState Ability::OnAcquireFormState(const Want &want)
{
return FormState::DEFAULT;
}
/**
* @brief Delete or release form with formId.
*
@@ -2915,6 +2942,54 @@ bool Ability::CheckFMSReady()
return true;
}
/**
* @brief Delete the given invalid forms.
*
* @param formIds Indicates the ID of the forms to delete.
* @param numFormsDeleted Returns the number of the deleted forms.
* @return Returns true if the request is successfully initiated; returns false otherwise.
*/
ErrCode Ability::DeleteInvalidForms(const std::vector<int64_t> &formIds, int32_t &numFormsDeleted)
{
HILOG_INFO("%{public}s called.", __func__);
if (FormMgr::GetRecoverStatus() == Constants::IN_RECOVERING) {
HILOG_ERROR("%{public}s error, form is in recover status, can't do action on form.", __func__);
return ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR;
}
// DeleteInvalidForms request to fms
int resultCode = FormMgr::GetInstance().DeleteInvalidForms(formIds, FormHostClient::GetInstance(), numFormsDeleted);
if (resultCode != ERR_OK) {
HILOG_ERROR("%{public}s error, failed to DeleteInvalidForms, error code is %{public}d.", __func__, resultCode);
}
return resultCode;
}
/**
* @brief Acquire form state info by passing a set of parameters (using Want) to the form provider.
*
* @param want Indicates a set of parameters to be transparently passed to the form provider.
* @param stateInfo Returns the form's state info of the specify.
* @return Returns true if the request is successfully initiated; returns false otherwise.
*/
ErrCode Ability::AcquireFormState(const Want &want, FormStateInfo &stateInfo)
{
HILOG_INFO("%{public}s called.", __func__);
if (FormMgr::GetRecoverStatus() == Constants::IN_RECOVERING) {
HILOG_ERROR("%{public}s error, form is in recover status, can't do action on form.", __func__);
return ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR;
}
// AcquireFormState request to fms
int resultCode = FormMgr::GetInstance().AcquireFormState(want, FormHostClient::GetInstance(), stateInfo);
if (resultCode != ERR_OK) {
HILOG_ERROR("%{public}s error, failed to AcquireFormState, error code is %{public}d.", __func__, resultCode);
}
return resultCode;
}
/**
* @brief Get All FormsInfo.
*
@@ -3235,7 +3310,9 @@ std::shared_ptr<NativeRdb::DataAbilityPredicates> Ability::ParsePredictionArgsRe
HILOG_INFO("Ability::ParsePredictionArgsReference push_back done");
}
predicates->SetWhereArgs(strPredicatesList);
if (predicates) {
predicates->SetWhereArgs(strPredicatesList);
}
return predicates;
}
@@ -3523,13 +3600,14 @@ void Ability::OnChange(Rosen::DisplayId displayId)
int32_t height = display->GetHeight();
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
if (resConfig != nullptr) {
resConfig->SetScreenDensity(ConvertDensity(density));
resConfig->SetDirection(ConvertDirection(height, width));
auto resourceManager = GetResourceManager();
if (resourceManager != nullptr) {
resourceManager->GetResConfig(*resConfig);
resConfig->SetScreenDensity(ConvertDensity(density));
resConfig->SetDirection(ConvertDirection(height, width));
resourceManager->UpdateResConfig(*resConfig);
HILOG_INFO("%{public}s Notify ResourceManager.", __func__);
HILOG_INFO("%{public}s Notify ResourceManager, Density: %{public}d, Direction: %{public}d.", __func__,
resConfig->GetScreenDensity(), resConfig->GetDirection());
}
}
@@ -3570,6 +3648,19 @@ void Ability::OnDisplayMove(Rosen::DisplayId from, Rosen::DisplayId to)
float density = display->GetVirtualPixelRatio();
int32_t width = display->GetWidth();
int32_t height = display->GetHeight();
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
if (resConfig != nullptr) {
auto resourceManager = GetResourceManager();
if (resourceManager != nullptr) {
resourceManager->GetResConfig(*resConfig);
resConfig->SetScreenDensity(ConvertDensity(density));
resConfig->SetDirection(ConvertDirection(height, width));
resourceManager->UpdateResConfig(*resConfig);
HILOG_INFO("%{public}s Notify ResourceManager, Density: %{public}d, Direction: %{public}d.", __func__,
resConfig->GetScreenDensity(), resConfig->GetDirection());
}
}
Configuration newConfig;
newConfig.AddItem(ConfigurationInner::APPLICATION_DISPLAYID, std::to_string(to));
newConfig.AddItem(to, ConfigurationInner::APPLICATION_DIRECTION, GetDirectionStr(height, width));
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -16,9 +16,11 @@
#include "ability_context.h"
#include "ability_manager_client.h"
#include "accesstoken_kit.h"
#include "bundle_constants.h"
#include "hilog_wrapper.h"
#include "iservice_registry.h"
#include "os_account_manager.h"
#include "resource_manager.h"
#include "sys_mgr_client.h"
#include "system_ability_definition.h"
@@ -349,92 +351,6 @@ std::shared_ptr<Global::Resource::ResourceManager> AbilityContext::GetResourceMa
return resourceManager;
}
int AbilityContext::VerifySelfPermission(const std::string &permission)
{
HILOG_INFO("%{public}s begin. permission=%{public}s", __func__, permission.c_str());
if (permission.empty()) {
HILOG_ERROR("VerifySelfPermission permission invalid");
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
}
std::string bundle_name = GetBundleName();
if (bundle_name.empty()) {
HILOG_ERROR("VerifySelfPermission failed to get bundle name error");
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
}
sptr<IBundleMgr> ptr = GetBundleManager();
if (ptr == nullptr) {
HILOG_ERROR("VerifySelfPermission failed to get bundle manager service");
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
}
HILOG_INFO("%{public}s start bms->CheckPermission. bundle_name=%{public}s", __func__, bundle_name.c_str());
int ret = ptr->CheckPermission(bundle_name, permission);
HILOG_INFO("%{public}s end bms->CheckPermission, ret=%{public}d", __func__, ret);
HILOG_INFO("%{public}s end.", __func__);
return ret;
}
int AbilityContext::VerifyCallingPermission(const std::string &permission)
{
HILOG_INFO("%{public}s begin. permission=%{public}s", __func__, permission.c_str());
if (permission.empty()) {
HILOG_ERROR("VerifyCallingPermission permission invalid");
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
}
std::string bundle_name = GetCallingBundle();
if (bundle_name.empty()) {
HILOG_ERROR("VerifyCallingPermission failed to get bundle name by uid");
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
}
sptr<IBundleMgr> ptr = GetBundleManager();
if (ptr == nullptr) {
HILOG_ERROR("VerifyCallingPermission failed to get bundle manager service");
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
}
HILOG_INFO("%{public}s start bms->CheckPermission. bundle_name=%{public}s", __func__, bundle_name.c_str());
int ret = ptr->CheckPermission(bundle_name, permission);
HILOG_INFO("%{public}s end bms->CheckPermission, ret=%{public}d", __func__, ret);
HILOG_INFO("%{public}s end.", __func__);
return ret;
}
bool AbilityContext::CanRequestPermission(const std::string &permission)
{
HILOG_INFO("%{public}s begin. permission=%{public}s", __func__, permission.c_str());
if (permission.empty()) {
HILOG_ERROR("CanRequestPermission permission invalid");
return true;
}
std::string bundle_name = GetBundleName();
if (bundle_name.empty()) {
HILOG_ERROR("CanRequestPermission failed to get bundle name error");
return true;
}
sptr<IBundleMgr> ptr = GetBundleManager();
if (ptr == nullptr) {
HILOG_ERROR("CanRequestPermission failed to get bundle manager service");
return true;
}
HILOG_INFO("%{public}s start bms->CanRequestPermission. bundle_name=%{public}s", __func__, bundle_name.c_str());
bool ret = ptr->CanRequestPermission(bundle_name, permission, 0);
HILOG_INFO("%{public}s end bms->CanRequestPermission, ret=%{public}s", __func__, ret ? "true" : "false");
HILOG_INFO("%{public}s end.", __func__);
return ret;
}
int AbilityContext::VerifyCallingOrSelfPermission(const std::string &permission)
{
return VerifySelfPermission(permission);
}
int AbilityContext::VerifyPermission(const std::string &permission, int pid, int uid)
{
HILOG_INFO("%{public}s begin. permission=%{public}s, pid=%{public}d, uid=%{public}d",
@@ -459,27 +375,36 @@ int AbilityContext::VerifyPermission(const std::string &permission, int pid, int
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
}
HILOG_INFO("%{public}s start bms->CheckPermission. bundle_name=%{public}s", __func__, bundle_name.c_str());
int ret = ptr->CheckPermission(bundle_name, permission);
HILOG_INFO("%{public}s end bms->CheckPermission, ret=%{public}d", __func__, ret);
HILOG_INFO("%{public}s end.", __func__);
return ret;
int account = -1;
if (AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(uid, account) != 0) {
HILOG_ERROR("VerifyPermission failed to get account by uid");
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
}
AppExecFwk::ApplicationInfo appInfo;
if (!ptr->GetApplicationInfo(bundle_name, AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, account, appInfo)) {
HILOG_ERROR("VerifyPermission failed to get application info");
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
}
int32_t ret = Security::AccessToken::AccessTokenKit::VerifyAccessToken(appInfo.accessTokenId, permission);
if (ret == Security::AccessToken::PermissionState::PERMISSION_DENIED) {
HILOG_ERROR("VerifyPermission %{public}d: PERMISSION_DENIED", appInfo.accessTokenId);
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
}
return 0;
}
void AbilityContext::GetPermissionDes(const std::string &permissionName, std::string &des)
{
sptr<IBundleMgr> ptr = GetBundleManager();
if (ptr == nullptr) {
HILOG_ERROR("GetPermissionDes failed to get bundle manager service");
return;
}
PermissionDef permissionDef;
HILOG_INFO("%{public}s start bms->GetPermissionDef. permissionName=%{public}s", __func__, permissionName.c_str());
if (ptr->GetPermissionDef(permissionName, permissionDef)) {
Security::AccessToken::PermissionDef permissionDef;
int32_t ret = Security::AccessToken::AccessTokenKit::GetDefPermission(permissionName, permissionDef);
if (ret == Security::AccessToken::AccessTokenKitRet::RET_SUCCESS) {
HILOG_DEBUG("GetPermissionDes %{public}s: RET_SUCCESS", permissionName.c_str());
des = permissionDef.description;
}
HILOG_INFO("%{public}s end bms->GetPermissionDef.", __func__);
HILOG_DEBUG("%{public}s end GetPermissionDef.", __func__);
}
void AbilityContext::RequestPermissionsFromUser(std::vector<std::string> &permissions, int requestCode)
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@@ -195,7 +195,7 @@ void AbilityWindow::OnPostAbilityStop()
if (windowScene_) {
windowScene_ = nullptr;
HILOG_INFO("AbilityWindow::widow windowScene_ release end.");
HILOG_INFO("AbilityWindow::window windowScene_ release end.");
}
isWindowAttached = false;
@@ -58,7 +58,7 @@ int32_t ReverseContinuationSchedulerReplicaStub::NotifyReverseResultInner(Messag
int ReverseContinuationSchedulerReplicaStub::OnRemoteRequest(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
HILOG_INFO("%{public}s called begin, code = %{public}d, flags= %{public}d.", __func__, code, option.GetFlags());
HILOG_INFO("%{public}s called begin, code = %{public}u, flags= %{public}d.", __func__, code, option.GetFlags());
std::u16string remoteDescriptor = data.ReadInterfaceToken();
if (remoteDescriptor != ReverseContinuationSchedulerReplicaStub::GetDescriptor()) {
HILOG_ERROR("ReverseContinuationSchedulerReplicaStub::OnRemoteRequest token is invalid");
@@ -250,8 +250,7 @@ std::shared_ptr<DataAbilityHelper> DataAbilityHelper::Creator(
if (uri->GetScheme() != SchemeOhos) {
HILOG_ERROR("DataAbilityHelper::Creator (context, uri, tryBind) failed, the Scheme is not dataability, Scheme: "
"%{public}s",
uri->GetScheme().c_str());
"%{public}s", uri->GetScheme().c_str());
return nullptr;
}
@@ -855,25 +854,31 @@ bool DataAbilityHelper::CheckUriParam(const Uri &uri)
return false;
}
auto uriSp = uri_; // do not directly use uri_ here, otherwise, it will crash.
if (uriSp != nullptr) {
if (!CheckOhosUri(*uriSp)) {
HILOG_ERROR("DataAbilityHelper::CheckUriParam failed. CheckOhosUri uriSp failed");
// do not directly use uri_ here, otherwise, it will probably crash.
std::vector<std::string> segments;
{
std::lock_guard<std::mutex> guard(lock_);
if (!uri_) {
HILOG_INFO("DataAbilityHelper::CheckUriParam uri_ is nullptr, no need check");
return true;
}
if (!CheckOhosUri(*uri_)) {
HILOG_ERROR("DataAbilityHelper::CheckUriParam failed. CheckOhosUri uri_ failed");
return false;
}
std::vector<std::string> checkSegments;
checkUri.GetPathSegments(checkSegments);
std::vector<std::string> segments;
uriSp->GetPathSegments(segments);
if (checkSegments.empty() || segments.empty() || checkSegments[0] != segments[0]) {
HILOG_ERROR(
"DataAbilityHelper::CheckUriParam failed. the dataability in uri doesn't equal the one in uriSp.");
return false;
}
uri_->GetPathSegments(segments);
}
std::vector<std::string> checkSegments;
checkUri.GetPathSegments(checkSegments);
if (checkSegments.empty() || segments.empty() || checkSegments[0] != segments[0]) {
HILOG_ERROR("DataAbilityHelper::CheckUriParam failed. dataability in uri doesn't equal the one in uri_.");
return false;
}
HILOG_INFO("DataAbilityHelper::CheckUriParam end.");
return true;
}
@@ -374,7 +374,7 @@ DataAbilityOperation *DataAbilityOperation::Unmarshalling(Parcel &in)
HILOG_DEBUG("DataAbilityOperation::Unmarshalling start");
DataAbilityOperation *dataAbilityOperation = new (std::nothrow) DataAbilityOperation();
if (dataAbilityOperation != nullptr && !dataAbilityOperation->ReadFromParcel(in)) {
HILOG_ERROR("DataAbilityOperation::Unmarshalling dataAbilityOperation(%p) error", dataAbilityOperation);
HILOG_ERROR("DataAbilityOperation::Unmarshalling dataAbilityOperation error");
delete dataAbilityOperation;
dataAbilityOperation = nullptr;
}
@@ -94,5 +94,11 @@ void FormExtension::OnVisibilityChange(const std::map<int64_t, int32_t>& formEve
{
HILOG_INFO("%{public}s called.", __func__);
}
FormState FormExtension::OnAcquireFormState(const Want &want)
{
HILOG_INFO("%{public}s called.", __func__);
return FormState::DEFAULT;
}
}
}
@@ -368,6 +368,41 @@ int FormProviderClient::FireFormEvent(
return disconnectErrorCode;
}
}
/**
* @brief Acquire form state to form provider.
* @param wantArg The want of onAcquireFormState.
* @param want The want of the request.
* @param callerToken Form provider proxy object.
* @return Returns ERR_OK on success, others on failure.
*/
int FormProviderClient::AcquireState(const Want &wantArg, const Want &want, const sptr<IRemoteObject> &callerToken)
{
HILOG_INFO("%{public}s called.", __func__);
// The error code for business operation.
int errorCode = ERR_OK;
FormState state = FormState::UNKNOWN;
do {
std::shared_ptr<Ability> ownerAbility = GetOwner();
if (ownerAbility == nullptr) {
HILOG_ERROR("%{public}s error, ownerAbility is nullptr.", __func__);
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
break;
}
if (!CheckIsSystemApp()) {
HILOG_ERROR("%{public}s caller permission denied", __func__);
errorCode = ERR_APPEXECFWK_FORM_PERMISSION_DENY;
break;
}
HILOG_INFO("%{public}s come, %{public}s", __func__, ownerAbility->GetAbilityName().c_str());
state = ownerAbility->OnAcquireFormState(wantArg);
} while (false);
HandleAcquireStateResult(state, errorCode, want, callerToken);
return errorCode;
}
/**
* @brief Set the owner ability of the form provider client.
*
@@ -466,5 +501,20 @@ int FormProviderClient::HandleDisconnect(const Want &want, const sptr<IRemoteOb
formSupplyClient->OnEventHandle(want);
return ERR_OK;
}
int FormProviderClient::HandleAcquireStateResult(FormState state, int errorCode, const Want &want,
const sptr<IRemoteObject> &callerToken)
{
HILOG_INFO("%{public}s start, form state is %{public}d", __func__, state);
sptr<IFormSupply> formSupplyClient = iface_cast<IFormSupply>(callerToken);
if (formSupplyClient == nullptr) {
HILOG_ERROR("%{public}s warn, IFormSupply is nullptr", __func__);
return ERR_APPEXECFWK_FORM_BIND_PROVIDER_FAILED;
}
formSupplyClient->OnAcquireStateResult(state, want);
HILOG_INFO("%{public}s end", __func__);
return errorCode;
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -378,6 +378,49 @@ void FormExtensionProviderClient::FireFormExtensionEvent(const int64_t formId, c
HILOG_INFO("%{public}s called end.", __func__);
}
/**
* @brief Acquire form state to form provider.
* @param wantArg The want of onAcquireFormState.
* @param want The want of the request.
* @param callerToken Form provider proxy object.
* @return Returns ERR_OK on success, others on failure.
*/
int FormExtensionProviderClient::AcquireState(const Want &wantArg, const Want &want,
const sptr<IRemoteObject> &callerToken)
{
HILOG_INFO("%{public}s called.", __func__);
std::pair<int, int> errorCode = CheckParam(want, callerToken);
if (errorCode.first != ERR_OK) {
HILOG_ERROR("%{public}s CheckParam failed", __func__);
return errorCode.second;
}
std::shared_ptr<EventHandler> mainHandler = std::make_shared<EventHandler>(EventRunner::GetMainEventRunner());
std::function<void()> notifyFormExtensionAcquireStateFunc = [client = sptr<FormExtensionProviderClient>(this),
wantArg, want, callerToken]() {
client->NotifyFormExtensionAcquireState(wantArg, want, callerToken);
};
mainHandler->PostSyncTask(notifyFormExtensionAcquireStateFunc);
return ERR_OK;
}
void FormExtensionProviderClient::NotifyFormExtensionAcquireState(const Want &wantArg, const Want &want,
const sptr<IRemoteObject> &callerToken)
{
HILOG_INFO("%{public}s called.", __func__);
int errorCode = ERR_OK;
FormState state = FormState::UNKNOWN;
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
if (ownerFormExtension == nullptr) {
HILOG_ERROR("%{public}s error, ownerFormExtension is nullptr.", __func__);
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
} else {
state = ownerFormExtension->OnAcquireFormState(wantArg);
}
HandleAcquireStateResult(state, errorCode, want, callerToken);
HILOG_INFO("%{public}s called end.", __func__);
}
/**
* @brief Set the owner form extension of the form provider client.
*

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