1 
2 /*
3  * Copyright (c) 2024 Huawei Device Co., Ltd.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "vsync_system_ability_listener.h"
18 #include "vsync_log.h"
19 
20 #ifdef COMPOSER_SCHED_ENABLE
21 #include "res_sched_client.h"
22 #include "res_type.h"
23 #include "system_ability_definition.h"
24 #include "ressched_event_listener.h"
25 #endif
26 
27 namespace OHOS {
28 namespace Rosen {
OnAddSystemAbility(int32_t systemAbilityId,const std::string & deviceId)29 void VSyncSystemAbilityListener::OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
30 {
31 #ifdef COMPOSER_SCHED_ENABLE
32     if (systemAbilityId == RES_SCHED_SYS_ABILITY_ID) {
33         VLOGI("%{public}s: threadName=%{public}s, pid=%{public}s, tid=%{public}s, uid=%{public}s.",
34             __func__, threadName_.c_str(), pid_.c_str(), tid_.c_str(), uid_.c_str());
35         std::unordered_map<std::string, std::string> mapPayload;
36         int32_t userInteraction = 0;
37         mapPayload["uid"] = uid_;
38         mapPayload["pid"] = pid_;
39         mapPayload["tid"] = tid_;
40         mapPayload["threadName"] = threadName_;
41         mapPayload["extType"] = threadName_ == "RSMainThread" ? "10003" : "10002";
42         mapPayload["isSa"] = "1";
43         mapPayload["cgroupPrio"] = "1";
44         OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(
45             ResourceSchedule::ResType::RES_TYPE_KEY_PERF_SCENE, userInteraction, mapPayload);
46         OHOS::ResourceSchedule::ResSchedClient::GetInstance().RegisterEventListener(
47             ResschedEventListener::GetInstance(),
48             ResourceSchedule::ResType::EventType::EVENT_DRAW_FRAME_REPORT);
49     }
50 #endif
51 }
52 
OnRemoveSystemAbility(int32_t systemAbilityId,const std::string & deviceId)53 void VSyncSystemAbilityListener::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
54 {
55     VLOGD("%{public}s: remove system ability %{public}d.", __func__, systemAbilityId);
56 }
57 } // namespace Rosen
58 } // namespace OHOS
59 
60