1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "audio_schedule.h"
17
18 #include <unistd.h>
19 #include <sys/types.h>
20 #include <cstring>
21 #include <unordered_map>
22
23 #ifdef RESSCHE_ENABLE
24 #include "res_type.h"
25 #include "res_sched_client.h"
26 #endif
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #ifdef RESSCHE_ENABLE
33 const uint32_t AUDIO_QOS_LEVEL = 7;
34
ScheduleReportData(uint32_t pid,uint32_t tid,const char * bundleName)35 void ScheduleReportData(uint32_t pid, uint32_t tid, const char* bundleName)
36 {
37 std::string strBundleName = bundleName;
38 std::string strPid = std::to_string(pid);
39 std::string strTid = std::to_string(tid);
40 std::string strQos = std::to_string(AUDIO_QOS_LEVEL);
41 std::unordered_map<std::string, std::string> mapPayload;
42 mapPayload["pid"] = strPid;
43 mapPayload[strTid] = strQos;
44 mapPayload["bundleName"] = strBundleName;
45 uint32_t type = OHOS::ResourceSchedule::ResType::RES_TYPE_THREAD_QOS_CHANGE;
46 int64_t value = 0;
47 OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(type, value, mapPayload);
48 }
49 #else
50 void ScheduleReportData(uint32_t /* pid */, uint32_t /* tid */, const char* /* bundleName*/) {};
51 #endif
52
53 #ifdef __cplusplus
54 }
55 #endif