1 /*
2  * Copyright (c) 2024 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 "scene_system_ability_listener.h"
17 
18 #ifdef RES_SCHED_ENABLE
19 #include "res_sched_client.h"
20 #include "res_type.h"
21 #include "system_ability_definition.h"
22 #include "window_manager_hilog.h"
23 #endif
24 
25 namespace OHOS {
26 namespace Rosen {
OnAddSystemAbility(int32_t systemAbilityId,const std::string & deviceId)27 void SceneSystemAbilityListener::OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
28 {
29 #ifdef RES_SCHED_ENABLE
30     if (systemAbilityId == RES_SCHED_SYS_ABILITY_ID) {
31         std::unordered_map<std::string, std::string> payload {
32             { "pid", info_.scbPid_ },
33             { "tid", info_.scbTid_ },
34             { "uid", info_.scbUid_ },
35             { "bundleName", info_.scbBundleName_ },
36         };
37         uint32_t type = OHOS::ResourceSchedule::ResType::RES_TYPE_REPORT_SCENE_BOARD;
38         OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(type, 0, payload);
39         constexpr int32_t userInteraction = 2;
40         payload = {
41             { "pid", info_.scbPid_ },
42             { "tid", info_.ssmTid_ },
43             { "uid", info_.scbUid_ },
44             { "extType", "10002" },
45             { "cgroupPrio", "1" },
46             { "isSa", "0" },
47             { "threadName", info_.ssmThreadName_ }
48         };
49         type = ResourceSchedule::ResType::RES_TYPE_KEY_PERF_SCENE;
50         OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(type, userInteraction, payload);
51         TLOGI(WmsLogTag::WMS_MAIN, "set RES_TYPE_KEY_PERF_SCENE success");
52     }
53 #endif
54 }
55 } // namespace Rosen
56 } // namespace OHOS
57 
58