diff --git a/OAT.xml b/OAT.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6c9cf8b131fddb0d26d6b6a864ad6bb2dd049c2f
--- /dev/null
+++ b/OAT.xml
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
new file mode 100644
index 0000000000000000000000000000000000000000..80de028df148207f5e1a4845d04610fd30120140
--- /dev/null
+++ b/RELEASE-NOTES.md
@@ -0,0 +1,4 @@
+# RELEASE-NOTES
+
+# 1.0.0
+1. Initial version
\ No newline at end of file
diff --git a/bundle.json b/bundle.json
new file mode 100644
index 0000000000000000000000000000000000000000..80a435b320d19c7e1097c0adc58c9d7fd595f0b8
--- /dev/null
+++ b/bundle.json
@@ -0,0 +1,61 @@
+{
+ "name": "@ohos/resourceschedule_qos_manager",
+ "description": "resourceschedule_qos_manager",
+ "version": "3.1",
+ "license": "Apache License 2.0",
+ "publishAs": "code-segment",
+ "segment": {
+ "destPath": "foundation/resourceschedule/resourceschedule_qos_manager"
+ },
+ "dirs": {},
+ "scripts": {},
+ "component": {
+ "name": "resourceschedule_qos_manager",
+ "subsystem": "resourceschedule",
+ "syscap": [],
+ "features": [],
+ "adapted_system_type": [
+ "mini",
+ "small",
+ "standard"
+ ],
+ "rom": "2048KB",
+ "ram": "10240KB",
+ "deps": {
+ "components": [
+ "ability_base",
+ "ability_runtime",
+ "libeventhandler",
+ "ipc_single",
+ "samgr",
+ "system_ability_fwk"
+ ],
+ "third_party": [
+ "xml2",
+ "json"
+ ]
+ },
+ "build": {
+ "sub_component": [
+ "//foundation/resourceschedule/resourceschedule_qos_manager/etc/init:concurrent_task_service.cfg",
+ "//foundation/resourceschedule/resourceschedule_qos_manager/sa_profile:concurrent_task_sa_profile",
+ "//foundation/resourceschedule/resourceschedule_qos_manager/services:concurrentsvc",
+ "//foundation/resourceschedule/resourceschedule_qos_manager/frameworks/concurrent_task_client:concurrent_task_client"
+ ],
+ "inner_kits": [
+ {
+ "header": {
+ "header_base": "//foundation/resourceschedule/resourceschedule_qos_manager/interfaces/inner_api/",
+ "header_files": [
+ "concurrent_task_client.h"
+ ]
+ },
+ "name": "//foundation/resourceschedule/resourceschedule_qos_manager/frameworks/concurrent_task_client:concurrent_task_client"
+ }
+ ],
+ "test": [
+ "//foundation/resourceschedule/resourceschedule_qos_manager/test:concurrent_unittest"
+ ]
+ }
+ }
+}
diff --git a/etc/init/BUILD.gn b/etc/init/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..4fc262a52816fb29c0b9dab675c817b68fc1d8fe
--- /dev/null
+++ b/etc/init/BUILD.gn
@@ -0,0 +1,27 @@
+# Copyright (c) 2022 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# 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.
+
+import("//build/ohos.gni")
+
+#################################################################################
+
+group("etc") {
+ deps = [ ":concurrent_task_service.cfg" ]
+}
+
+ohos_prebuilt_etc("concurrent_task_service.cfg") {
+ source = "concurrent_task_service.cfg"
+ relative_install_dir = "init"
+ subsystem_name = "resourceschedule"
+ part_name = "resourceschedule_qos_manager"
+}
diff --git a/etc/init/concurrent_task_service.cfg b/etc/init/concurrent_task_service.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..4453863f420e6a088f6c99bf524fe66fb3a9de4a
--- /dev/null
+++ b/etc/init/concurrent_task_service.cfg
@@ -0,0 +1,18 @@
+{
+ "jobs" : [{
+ "name" : "post-fs-data",
+ "cmds" : [
+ "start concurrent_task_service"
+ ]
+ }
+ ],
+ "services" : [{
+ "name" : "concurrent_task_service",
+ "path" : ["/system/bin/sa_main", "/system/profile/concurrent_task_service.xml"],
+ "importance" : -20,
+ "uid" : "system",
+ "gid" : ["system", "shell"],
+ "secon" : "u:r:concurrent_task_service:s0"
+ }
+ ]
+}
diff --git a/frameworks/concurrent_task_client/BUILD.gn b/frameworks/concurrent_task_client/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..4a9949e19f5c5878f62df03857e173cb0a7690cf
--- /dev/null
+++ b/frameworks/concurrent_task_client/BUILD.gn
@@ -0,0 +1,62 @@
+# Copyright (c) 2022 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# 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.
+
+import("//build/ohos.gni")
+import("//build/test.gni")
+
+config("client_private_config") {
+ cflags_cc = [ "-fexceptions" ]
+ include_dirs = [
+ "./include",
+ "../../include",
+ "../../services/include",
+ "../../interfaces/inner_api/",
+ "//commonlibrary/c_utils/base/include",
+ "//utils/system/safwk/native/include",
+ "//third_party/jsoncpp/include",
+ ]
+}
+
+config("client_public_config") {
+ visibility = [":*"]
+ cflags = [ "-fstack-protector-strong" ]
+ include_dirs = [ "include" ]
+}
+
+ohos_shared_library("concurrent_task_client") {
+ configs = [
+ ":client_private_config",
+ ]
+
+ public_configs = [ ":client_public_config" ]
+
+ sources = [
+ "src/concurrent_task_client.cpp",
+ "src/concurrent_task_service_proxy.cpp",
+ ]
+
+ deps = [
+ "//third_party/jsoncpp:jsoncpp",
+ ]
+
+ external_deps = [
+ "c_utils:utils",
+ "eventhandler:libeventhandler",
+ "hiviewdfx_hilog_native:libhilog",
+ "ipc:ipc_single",
+ "samgr:samgr_proxy",
+ ]
+
+ subsystem_name = "resourceschedule"
+ part_name = "resourceschedule_qos_manager"
+}
diff --git a/frameworks/concurrent_task_client/include/concurrent_task_errors.h b/frameworks/concurrent_task_client/include/concurrent_task_errors.h
new file mode 100644
index 0000000000000000000000000000000000000000..89df25c2837bc91edc01f055032681c1b1a38070
--- /dev/null
+++ b/frameworks/concurrent_task_client/include/concurrent_task_errors.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.
+ */
+
+#ifndef CONCURRENT_TASK_SERVICE_INTERFACES_INNERAPI_CONCURRENT_TASK_CLIENT_INCLUDE_CONCURRENT_TASK_ERRORS_H
+#define CONCURRENT_TASK_SERVICE_INTERFACES_INNERAPI_CONCURRENT_TASK_CLIENT_INCLUDE_CONCURRENT_TASK_ERRORS_H
+
+#include "errors.h"
+
+namespace OHOS {
+namespace ConcurrentTask {
+enum {
+ CONCURRENT_TASK_MODULE_COMMON = 0x00,
+ CONCURRENT_TASK_MODULE_SERVICE = 0x01,
+};
+
+constexpr ErrCode CONCURRENT_TASK_COMMON_ERR_OFFSET = ErrCodeOffset(SUBSYS_IAWARE, CONCURRENT_TASK_MODULE_COMMON);
+enum {
+ ERR_CONCURRENT_TASK_INVALID_PARAM = CONCURRENT_TASK_COMMON_ERR_OFFSET + 1,
+ GET_CONCURRENT_TASK_SERVICE_FAILED,
+};
+
+constexpr ErrCode CONCURRENT_TASK_SERVICE_ERR_OFFSET = ErrCodeOffset(SUBSYS_IAWARE, CONCURRENT_TASK_MODULE_SERVICE);
+enum {
+ ERR_CONCURRENT_TASK_PARCEL_ERROR = CONCURRENT_TASK_SERVICE_ERR_OFFSET + 1,
+ ERR_CONCURRENT_TASK_PERMISSION_DENIED,
+ ERR_CONCURRENT_TASK_WRITE_FILE_FAILED,
+};
+} // namespace ConcurrentTask
+} // namespace OHOS
+
+#endif // CONCURRENT_TASK_SERVICE_INTERFACES_INNERAPI_CONCURRENT_TASK_CLIENT_INCLUDE_CONCURRENT_TASK_ERRORS_H
diff --git a/frameworks/concurrent_task_client/include/concurrent_task_service_proxy.h b/frameworks/concurrent_task_client/include/concurrent_task_service_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..bd07586d87523eea52e558574957dd93d846f9a9
--- /dev/null
+++ b/frameworks/concurrent_task_client/include/concurrent_task_service_proxy.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.
+ */
+
+#ifndef CONCUURENT_TASK_INTERFACES_INNERAPI_CONCURRENT_TASK_CLIENT_INCLUDE_CONCUURENT_TASK_SERVICE_PROXY_H
+#define CONCUURENT_TASK_INTERFACES_INNERAPI_CONCURRENT_TASK_CLIENT_INCLUDE_CONCUURENT_TASK_SERVICE_PROXY_H
+
+#include "iremote_proxy.h"
+#include "iremote_object.h"
+#include "iconcurrent_task_service.h"
+
+namespace OHOS {
+namespace ConcurrentTask {
+class ConcurrentTaskServiceProxy : public IRemoteProxy {
+public:
+ explicit ConcurrentTaskServiceProxy(const sptr& impl) : IRemoteProxy(impl) {}
+ virtual ~ConcurrentTaskServiceProxy() {}
+
+ void ReportData(uint32_t resType, int64_t value, const Json::Value& payload) override;
+ void QueryInterval(int queryItem, IntervalReply& queryRs) override;
+
+private:
+ DISALLOW_COPY_AND_MOVE(ConcurrentTaskServiceProxy);
+ static inline BrokerDelegator delegator_;
+};
+} // namespace ConcurrentTask
+} // namespace OHOS
+
+#endif // CONCUURENT_TASK_INTERFACES_INNERAPI_CONCURRENT_TASK_CLIENT_INCLUDE_CONCUURENT_TASK_SERVICE_PROXY_H
\ No newline at end of file
diff --git a/frameworks/concurrent_task_client/include/concurrent_task_type.h b/frameworks/concurrent_task_client/include/concurrent_task_type.h
new file mode 100644
index 0000000000000000000000000000000000000000..70d5105d57af8fddf888867630de8b7540120f8e
--- /dev/null
+++ b/frameworks/concurrent_task_client/include/concurrent_task_type.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.
+ */
+
+#ifndef CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_TYPE_H
+#define CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_TYPE_H
+namespace OHOS {
+namespace ConcurrentTask {
+constexpr int MAX_KEY_THREADS = 5;
+
+enum MsgType {
+ MSG_FOREGROUND = 0,
+ MSG_BACKGROUND,
+ MSG_APP_START,
+ MSG_APP_KILLED,
+ MSG_FOCUS,
+ MSG_SYSTEM_MAX,
+ MSG_APP_START_TYPE = 100,
+ MSG_REG_RENDER = MSG_APP_START_TYPE,
+ MSG_REG_UI,
+ MSG_REG_KEY_THERAD,
+ MSG_TYPE_MAX
+};
+
+enum PrioType {
+ PRIO_RT = 0,
+ RPIO_IN = 1,
+ PRIO_NORMAL = 2,
+};
+
+enum QueryIntervalItem {
+ QUERY_UI = 0,
+ QUERY_RENDER = 1,
+ QUERY_RENDER_SERVICE = 2,
+ QUERY_COMPOSER = 3,
+ QURRY_TYPE_MAX
+};
+
+struct IntervalReply {
+ int rtgId;
+ int paramA;
+ int paramB;
+ int paramC;
+};
+}
+}
+#endif // CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_TYPE_H
\ No newline at end of file
diff --git a/frameworks/concurrent_task_client/include/iconcurrent_task_service.h b/frameworks/concurrent_task_client/include/iconcurrent_task_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..126f892abe650e8142063deaad276a98be23ac43
--- /dev/null
+++ b/frameworks/concurrent_task_client/include/iconcurrent_task_service.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.
+ */
+
+#ifndef CONCURRENT_TASK_SEVICES_INTERFACES_INNERAPI_CONCURRENT_TASK_CLIENT_INCLUDE_ICONCURRENT_TASK_SERVICE_H
+#define CONCURRENT_TASK_SEVICES_INTERFACES_INNERAPI_CONCURRENT_TASK_CLIENT_INCLUDE_ICONCURRENT_TASK_SERVICE_H
+
+#include "iremote_broker.h"
+#include "json/json.h"
+#include "concurrent_task_type.h"
+
+namespace OHOS {
+namespace ConcurrentTask {
+class IConcurrentTaskService : public IRemoteBroker {
+public:
+ enum : uint32_t {
+ REPORT_DATA = 1,
+ QUERY_INTERVAL = 2,
+ };
+
+ DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ResourceSchedule.ConcurrentTaskService");
+
+ virtual void ReportData(uint32_t resType, int64_t value, const Json::Value& payload) = 0;
+ virtual void QueryInterval(int queryItem, IntervalReply& queryRs) = 0;
+};
+} // namespace ConcurrentTask
+} // namespace OHOS
+
+#endif // CONCURRENT_TASK_SEVICES_INTERFACES_INNERAPI_CONCURRENT_TASK_CLIENT_INCLUDE_ICONCURRENT_TASK_SERVICE_H
diff --git a/frameworks/concurrent_task_client/src/concurrent_task_client.cpp b/frameworks/concurrent_task_client/src/concurrent_task_client.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..03c3296ffc9994fcf32f4c25982c34fd44eae092
--- /dev/null
+++ b/frameworks/concurrent_task_client/src/concurrent_task_client.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.
+ */
+#include "concurrent_task_client.h"
+#include
+#include "if_system_ability_manager.h"
+#include "iservice_registry.h"
+#include "concurrent_task_log.h"
+#include "concurrent_task_errors.h"
+#include "system_ability_definition.h"
+
+namespace OHOS {
+namespace ConcurrentTask {
+ConcurrentTaskClient& ConcurrentTaskClient::GetInstance()
+{
+ static ConcurrentTaskClient instance;
+ return instance;
+}
+
+void ConcurrentTaskClient::ReportData(uint32_t resType, int64_t value,
+ const std::unordered_map& mapPayload)
+{
+ CONCUR_LOGD("ConcurrentTaskClient::ReportData receive resType = %{public}u, value = %{public}" PRId64 ".",
+ resType, value);
+ if (TryConnect() != ERR_OK) {
+ return;
+ }
+ Json::Value payload;
+ for (auto it = mapPayload.begin(); it != mapPayload.end(); ++it) {
+ payload[it->first] = it->second;
+ }
+ clientService_->ReportData(resType, value, payload);
+}
+
+void ConcurrentTaskClient::QueryInterval(int queryItem, IntervalReply& queryRs)
+{
+ if (TryConnect() != ERR_OK) {
+ CONCUR_LOGE("QueryInterval connnect fail");
+ return;
+ }
+ clientService_->QueryInterval(queryItem, queryRs);
+ return;
+}
+
+ErrCode ConcurrentTaskClient::TryConnect()
+{
+ std::lock_guard lock(mutex_);
+ if (clientService_) {
+ return ERR_OK;
+ }
+
+ sptr systemManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ if (!systemManager) {
+ CONCUR_LOGE("ConcurrentTaskClient::Fail to get registry.");
+ return GET_CONCURRENT_TASK_SERVICE_FAILED;
+ }
+
+ remoteObject_ = systemManager->GetSystemAbility(CONCURRENT_TASK_SERVICE_ID);
+ if (!remoteObject_) {
+ CONCUR_LOGE("ConcurrentTaskClient::Fail to connect concurrent task schedule service.");
+ return GET_CONCURRENT_TASK_SERVICE_FAILED;
+ }
+
+ clientService_ = iface_cast(remoteObject_);
+ if (!clientService_) {
+ return GET_CONCURRENT_TASK_SERVICE_FAILED;
+ }
+ try {
+ recipient_ = new ConcurrentTaskDeathRecipient(*this);
+ } catch (const std::bad_alloc& e) {
+ CONCUR_LOGE("ConcurrentTaskClient::New ConcurrentTaskDeathRecipient fail.");
+ }
+ if (!recipient_) {
+ return GET_CONCURRENT_TASK_SERVICE_FAILED;
+ }
+ clientService_->AsObject()->AddDeathRecipient(recipient_);
+ CONCUR_LOGD("ConcurrentTaskClient::Connect concurrent task service success.");
+ return ERR_OK;
+}
+
+void ConcurrentTaskClient::StopRemoteObject()
+{
+ if (clientService_ && clientService_->AsObject()) {
+ clientService_->AsObject()->RemoveDeathRecipient(recipient_);
+ }
+ clientService_ = nullptr;
+}
+
+ConcurrentTaskClient::ConcurrentTaskDeathRecipient::ConcurrentTaskDeathRecipient(
+ ConcurrentTaskClient& concurrentTaskClient) : concurrentTaskClient_(concurrentTaskClient) {}
+
+ConcurrentTaskClient::ConcurrentTaskDeathRecipient::~ConcurrentTaskDeathRecipient() {}
+
+void ConcurrentTaskClient::ConcurrentTaskDeathRecipient::OnRemoteDied(const wptr& object)
+{
+ concurrentTaskClient_.StopRemoteObject();
+}
+} // namespace ConcurrentTask
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/concurrent_task_client/src/concurrent_task_service_proxy.cpp b/frameworks/concurrent_task_client/src/concurrent_task_service_proxy.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a417ee8dfa1fc652b998524ea424e826679ce171
--- /dev/null
+++ b/frameworks/concurrent_task_client/src/concurrent_task_service_proxy.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.
+ */
+
+#include "concurrent_task_service_proxy.h"
+#include "concurrent_task_log.h"
+#include "concurrent_task_errors.h"
+
+namespace OHOS {
+namespace ConcurrentTask {
+void ConcurrentTaskServiceProxy::ReportData(uint32_t resType, int64_t value, const Json::Value& payload)
+{
+ int32_t error;
+ MessageParcel data;
+ MessageParcel reply;
+ MessageOption option = { MessageOption::TF_ASYNC };
+ if (!data.WriteInterfaceToken(ConcurrentTaskServiceProxy::GetDescriptor())) {
+ return;
+ }
+ if (!data.WriteUint32(resType)) {
+ return;
+ }
+ if (!data.WriteInt64(value)) {
+ return;
+ }
+ if (!data.WriteString(payload.toStyledString())) {
+ return;
+ }
+ error = Remote()->SendRequest(IConcurrentTaskService::REPORT_DATA, data, reply, option);
+ if (error != NO_ERROR) {
+ CONCUR_LOGE("Send request error: %{public}d", error);
+ return;
+ }
+ CONCUR_LOGD("ConcurrentTaskServiceProxy::ReportData success.");
+}
+
+void ConcurrentTaskServiceProxy::QueryInterval(int queryItem, IntervalReply& queryRs)
+{
+ int32_t error;
+ MessageParcel data;
+ MessageParcel reply;
+ MessageOption option = { MessageOption::TF_SYNC };
+ queryRs.rtgId = -1;
+ queryRs.paramA = -1;
+ queryRs.paramB = -1;
+ queryRs.paramC = -1;
+ if (!data.WriteInterfaceToken(ConcurrentTaskServiceProxy::GetDescriptor())) {
+ return;
+ }
+ if (!data.WriteInt64(queryItem)) {
+ return;
+ }
+ error = Remote()->SendRequest(IConcurrentTaskService::QUERY_INTERVAL, data, reply, option);
+ if (error != NO_ERROR) {
+ CONCUR_LOGE("QueryInterval error: %{public}d", error);
+ return;
+ }
+ if (!reply.ReadInt32(queryRs.rtgId)) {
+ return;
+ }
+ if (!reply.ReadInt32(queryRs.paramA)) {
+ return;
+ }
+ if (!reply.ReadInt32(queryRs.paramB)) {
+ return;
+ }
+ if (!reply.ReadInt32(queryRs.paramC)) {
+ return;
+ }
+ return;
+}
+} // namespace ConcurrentTask
+} // namespace OHOS
\ No newline at end of file
diff --git a/include/concurrent_task_log.h b/include/concurrent_task_log.h
new file mode 100644
index 0000000000000000000000000000000000000000..716af45cb2084d2a89316869da5322016415d7ca
--- /dev/null
+++ b/include/concurrent_task_log.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.
+ */
+
+#ifndef CONCURRENT_TASK_COMMON_INCLUDE_CONCURRENT_TASK_LOG_H
+#define CONCURRENT_TASK_COMMON_INCLUDE_CONCURRENT_TASK_LOG_H
+
+#include "hilog/log.h"
+
+namespace OHOS {
+namespace ConcurrentTask {
+constexpr OHOS::HiviewDFX::HiLogLabel CONCUR_LABEL = {
+ LOG_CORE,
+ 0xD001707,
+ "CONCUR"
+};
+
+#define CONCUR_LOGF(...) (void)OHOS::HiviewDFX::HiLog::Fatal(CONCUR_LABEL, __VA_ARGS__)
+#define CONCUR_LOGE(...) (void)OHOS::HiviewDFX::HiLog::Error(CONCUR_LABEL, __VA_ARGS__)
+#define CONCUR_LOGW(...) (void)OHOS::HiviewDFX::HiLog::Warn(CONCUR_LABEL, __VA_ARGS__)
+#define CONCUR_LOGI(...) (void)OHOS::HiviewDFX::HiLog::Info(CONCUR_LABEL, __VA_ARGS__)
+#define CONCUR_LOGD(...) (void)OHOS::HiviewDFX::HiLog::Debug(CONCUR_LABEL, __VA_ARGS__)
+} // namespace ConcurrentTask
+} // namespace OHOS
+
+#endif // CONCURRENT_TASK
diff --git a/interfaces/inner_api/concurrent_task_client.h b/interfaces/inner_api/concurrent_task_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..5e2732d83b496bd29a558a81d6fb883a5201ef62
--- /dev/null
+++ b/interfaces/inner_api/concurrent_task_client.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.
+ */
+
+#ifndef CONCURRENT_TASK_SERVICE_INTERFACES_INNERAPI_CONCURRENT_TASK_CLIENT_INCLUDE_CONCURRENT_TASK_CLIENT_H
+#define CONCURRENT_TASK_SERVICE_INTERFACES_INNERAPI_CONCURRENT_TASK_CLIENT_INCLUDE_CONCURRENT_TASK_CLIENT_H
+
+#include
+#include "iremote_object.h"
+#include "iconcurrent_task_service.h"
+
+namespace OHOS {
+namespace ConcurrentTask {
+/*
+ * this class wraped the functions of IConcurrentTaskService,effect is the same.
+ * but through ConcurrentTaskClient, you don't need to get IConcurrentTaskService from samgr,
+ * just use the functions is ok.
+ */
+
+class ConcurrentTaskClient {
+public:
+ /**
+ * Only need one client connect to ConcurrentTaskService, singleton pattern.
+ *
+ * @return Returns the only one implement of ConcurrentTaskClient.
+ */
+ static ConcurrentTaskClient& GetInstance();
+
+ void ReportData(uint32_t resType, int64_t value, const std::unordered_map& mapPayload);
+ void QueryInterval(int queryItem, IntervalReply& queryRs);
+
+ void StopRemoteObject();
+
+protected:
+ ConcurrentTaskClient() = default;
+ virtual ~ConcurrentTaskClient() = default;
+
+private:
+ class ConcurrentTaskDeathRecipient : public IRemoteObject::DeathRecipient {
+ public:
+ explicit ConcurrentTaskDeathRecipient(ConcurrentTaskClient& concurrentTaskClient);
+
+ ~ConcurrentTaskDeathRecipient() override;
+
+ void OnRemoteDied(const wptr& object) override;
+
+ private:
+ ConcurrentTaskClient& concurrentTaskClient_;
+ };
+ ErrCode TryConnect();
+
+ std::mutex mutex_;
+ sptr recipient_;
+ sptr remoteObject_;
+ sptr clientService_;
+ DISALLOW_COPY_AND_MOVE(ConcurrentTaskClient);
+};
+} // namespace ConcurrentTask
+} // namespace OHOS
+
+#endif // CONCURRENT_TASK_SERVICE_INTERFACES_INNERAPI_ConcurrentTask_CLIENT_INCLUDE_CONCURRENT_TASK_CLIENT_H
diff --git a/sa_profile/1912.xml b/sa_profile/1912.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e520da5d66e7d84ee849d81d693d5eb8069a8e5d
--- /dev/null
+++ b/sa_profile/1912.xml
@@ -0,0 +1,28 @@
+
+
+
+ concurrent_task_service
+
+ libconcurrentsvc.z.so
+
+
+ 1912
+ libconcurrentsvc.z.so
+ true
+ false
+ 1
+
+
diff --git a/sa_profile/BUILD.gn b/sa_profile/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..725f2f18fe77a49d27a0b8fb2bfb514c1d5a2d17
--- /dev/null
+++ b/sa_profile/BUILD.gn
@@ -0,0 +1,20 @@
+# Copyright (c) 2022 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# 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.
+
+import("//build/ohos/sa_profile/sa_profile.gni")
+
+ohos_sa_profile("concurrent_task_sa_profile") {
+ sources = [ "1912.xml" ]
+
+ part_name = "resourceschedule_qos_manager"
+}
diff --git a/services/BUILD.gn b/services/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..123c5f1d774e01b2aaf41fd494976135935c9087
--- /dev/null
+++ b/services/BUILD.gn
@@ -0,0 +1,64 @@
+# Copyright (c) 2022 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# 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.
+
+import("//build/ohos.gni")
+
+config("concurrent_task_config") {
+ visibility = [":*"]
+ cflags_cc = [ "-fexceptions" ]
+ include_dirs = [
+ "include",
+ "../include",
+ "../frameworks/concurrent_task_client/include/",
+ "../interfaces/inner_api/",
+ "//foundation/resourceschedule/frame_aware_sched/common/include/",
+ "//utils/system/safwk/native/include",
+ "//commonlibrary/c_utils/base/include",
+ "//third_party/libxml2/include",
+ "//third_party/jsoncpp/include",
+ ]
+}
+
+ohos_shared_library("concurrentsvc") {
+
+ public_configs = [
+ ":concurrent_task_config",
+ ]
+
+ sources = [
+ "src/concurrent_task_service.cpp",
+ "src/concurrent_task_service_ability.cpp",
+ "src/concurrent_task_service_stub.cpp",
+ "src/concurrent_task_controller.cpp",
+ "src/qos_interface.cpp",
+ "src/qos_manager.cpp",
+ ]
+
+ deps = [
+ "//foundation/resourceschedule/frame_aware_sched/interfaces/innerkits/frameintf:rtg_interface",
+ "//third_party/jsoncpp:jsoncpp",
+ "//third_party/libxml2:xml2",
+ ]
+
+ external_deps = [
+ "c_utils:utils",
+ "eventhandler:libeventhandler",
+ "hiviewdfx_hilog_native:libhilog",
+ "ipc:ipc_single",
+ "safwk:system_ability_fwk",
+ "samgr:samgr_proxy",
+ ]
+
+ subsystem_name = "resourceschedule"
+ part_name = "resourceschedule_qos_manager"
+}
diff --git a/services/include/concurrent_task_controller.h b/services/include/concurrent_task_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..4c7ed16ba609602835d3c97cd14984521c2df542
--- /dev/null
+++ b/services/include/concurrent_task_controller.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.
+ */
+
+#ifndef CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_CONTROLLER_H
+#define CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_CONTROLLER_H
+
+#include
+#include
+#include
+#include
+#include
+#include "json/json.h"
+#include "concurrent_task_type.h"
+#include "qos_manager.h"
+
+namespace OHOS {
+namespace ConcurrentTask {
+class ForegroundAppRecord;
+
+class TaskController {
+public:
+ static TaskController& GetInstance();
+ TaskController() = default;
+ virtual ~TaskController() = default;
+ void ReportData(uint32_t resType, int64_t value, const Json::Value& payload);
+ void QueryInterval(int queryItem, IntervalReply& queryRs);
+ void Init();
+ void Release();
+
+private:
+ bool CheckUid(pid_t uid);
+ void TypeMapInit();
+ void QosApplyInit();
+ void SetHwcAuth(bool status);
+ void TryCreateRsGroup();
+ void QueryUi(pid_t uid, IntervalReply& queryRs);
+ void QueryRender(pid_t uid, IntervalReply& queryRs);
+ void QueryRenderService(pid_t uid, IntervalReply& queryRs);
+ void QueryHwc(pid_t uid, IntervalReply& queryRs);
+ int GetRequestType(std::string strRequstType);
+ void DealSystemRequest(int requestType, const Json::Value& payload);
+ void DealAppRequest(int requestType, const Json::Value& payload, pid_t uid);
+ void NewForeground(int uid);
+ void NewBackground(int uid);
+ void NewAppStart(int uid);
+ void AppKilled(int uid);
+ std::list::iterator GetRecordOfUid(int uid);
+ void PrintInfo();
+
+ std::mutex appInfoLock_;
+ std::list foregroundApp_ = {};
+ std::unordered_map msgType_ = {};
+ QosManager qosManager_;
+ std::vector authApps_;
+ int renderServiceGrpId_ = -1;
+ bool rtgEnabled_ = false;
+};
+
+class ForegroundAppRecord {
+public:
+ explicit ForegroundAppRecord(int uid);
+ ~ForegroundAppRecord();
+
+ void AddKeyThread(int tid, int prio = PRIO_NORMAL);
+ bool BeginScene();
+ bool EndScene();
+ int GetUid();
+ int GetGrpId();
+ bool IsValid();
+ void PrintKeyThreads();
+
+private:
+ int uid_ = 0;
+ int grpId_ = 0;
+ std::unordered_set keyThreads_;
+};
+} // namespace ConcurrentTask
+} // namespace OHOS
+
+#endif // CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_CONTROLLER_H
\ No newline at end of file
diff --git a/services/include/concurrent_task_service.h b/services/include/concurrent_task_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..3c8f5aca82014b2fb2a7a426a21b187a229ef4a7
--- /dev/null
+++ b/services/include/concurrent_task_service.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.
+ */
+
+#ifndef CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_SEVICE_H
+#define CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_SEVICE_H
+
+#include "concurrent_task_service_stub.h"
+#include "concurrent_task_log.h"
+
+namespace OHOS {
+namespace ConcurrentTask {
+class ConcurrentTaskService : public ConcurrentTaskServiceStub {
+public:
+ ConcurrentTaskService() {}
+ ~ConcurrentTaskService() override = default;
+
+ void ReportData(uint32_t resType, int64_t value, const Json::Value& payload) override;
+ void QueryInterval(int queryItem, IntervalReply& queryRs) override;
+private:
+ DISALLOW_COPY_AND_MOVE(ConcurrentTaskService);
+};
+} // namespace ConcurrentTask
+} // namespace OHOS
+
+#endif // CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_SEVICE_H
diff --git a/services/include/concurrent_task_service_ability.h b/services/include/concurrent_task_service_ability.h
new file mode 100644
index 0000000000000000000000000000000000000000..8a9a33b619c939d267336907303e33d3d6bfafe4
--- /dev/null
+++ b/services/include/concurrent_task_service_ability.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.
+ */
+
+#ifndef CONCURRENT_TASK_SEVICES_INCLUDE_CONCURRENT_TASK_SERVICE_ABILITY_H
+#define CONCURRENT_TASK_SEVICES_INCLUDE_CONCURRENT_TASK_SERVICE_ABILITY_H
+
+#include "system_ability.h"
+#include "concurrent_task_service.h"
+
+namespace OHOS {
+namespace ConcurrentTask {
+class ConcurrentTaskServiceAbility : public SystemAbility {
+ DECLARE_SYSTEM_ABILITY(ConcurrentTaskServiceAbility);
+
+public:
+ ConcurrentTaskServiceAbility(int32_t sysAbilityId, bool runOnCreate) : SystemAbility(sysAbilityId, runOnCreate) {}
+ ~ConcurrentTaskServiceAbility() override = default;
+
+private:
+ void OnStart() override;
+
+ void OnStop() override;
+
+ void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
+
+ void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
+
+ sptr service_;
+
+ DISALLOW_COPY_AND_MOVE(ConcurrentTaskServiceAbility);
+};
+} // namespace ConcurrentTask
+} // namespace OHOS
+
+#endif // CONCURRENT_TASK_SEVICES_INCLUDE_CONCURRENT_TASK_SERVICE_ABILITY_H
diff --git a/services/include/concurrent_task_service_stub.h b/services/include/concurrent_task_service_stub.h
new file mode 100644
index 0000000000000000000000000000000000000000..9b4a62c5a9b00c83b48610ad685bbbb45c2b9a96
--- /dev/null
+++ b/services/include/concurrent_task_service_stub.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.
+ */
+
+#ifndef CONCURRENT_TASK_SEVICES_INCLUDE_CONCURRENT_TASK_SERVICE_STUB_H
+#define CONCURRENT_TASK_SEVICES_INCLUDE_CONCURRENT_TASK_SERVICE_STUB_H
+
+#include