• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 #include "AI_schedule.h"
16 #include "interface/GameServicePlugin.h"
17 #include <string>
18 #include <map>
19 #include <service_plugin.h>
20 #include <sp_log.h>
21 #include <dlfcn.h>
22 
23 
24 namespace OHOS {
25 namespace SmartPerf {
ItemData()26 std::map<std::string, std::string> AISchedule::ItemData()
27 {
28     if (processId.empty()) {
29         WLOGE("AISchedule need processId.");
30         return std::map<std::string, std::string>();
31     }
32     aiScheduleParams[aiScheduleParamPid] = processId;
33     aiScheduleParams[aiScheduleParamType] = "1";
34     ServicePluginHandler &servicePluginHandler = ServicePluginHandler::GetInstance();
35 
36     void* handle = servicePluginHandler.GetSoHandler(ServicePluginHandler::ServicePluginType::GAME_PLUGIN);
37     if (handle == nullptr) {
38         WLOGE("Get service plugin handler failed.");
39         return std::map<std::string, std::string>();
40     }
41 
42     typedef GameServicePlugin *(*GetServicePlugin)();
43     GetServicePlugin servicePlugin = (GetServicePlugin)dlsym(handle, createPlugin.c_str());
44     if (!servicePlugin) {
45         WLOGE("GameServicePlugin Error loading symbol");
46         return std::map<std::string, std::string>();
47     }
48     return servicePlugin()->GetSystemFunctionStatus(aiScheduleParams);
49 }
50 
SetProcessId(const std::string & pid)51 void AISchedule::SetProcessId(const std::string &pid)
52 {
53     processId = pid;
54 }
55 } // namespace SmartPerf
56 } // namespace OHOS