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 16 #ifndef SERVICE_PLUGIN_H 17 #define SERVICE_PLUGIN_H 18 19 #include "string" 20 #include "map" 21 #include "thread" 22 #include "GpuCounterCallback.h" 23 #include "sp_profiler.h" 24 25 namespace OHOS { 26 namespace SmartPerf { 27 class GameServicePlugin { 28 public: 29 uint32_t version; 30 const char *pluginName; 31 32 virtual int32_t StartGetGpuPerfInfo(int64_t duration, std::unique_ptr <GpuCounterCallback> callback) = 0; 33 virtual int32_t StopGetGpuPerfInfo() = 0; 34 virtual std::map<std::string, std::string> GetSystemFunctionStatus( 35 std::map<std::string, std::string> &queryParams) = 0; 36 }; 37 38 class ServicePluginHandler : public SpProfiler { 39 public: 40 enum ServicePluginType { 41 GAME_PLUGIN, 42 TEST_PLUGIN, 43 PLUGIN_COUNT 44 }; 45 46 std::map<std::string, std::string> ItemData() override; GetInstance()47 static ServicePluginHandler &GetInstance() 48 { 49 static ServicePluginHandler instance; 50 return instance; 51 } 52 void* GetSoHandler(enum ServicePluginType type); 53 54 private: 55 ServicePluginHandler(); 56 ~ServicePluginHandler() override; 57 ServicePluginHandler(const ServicePluginHandler &); 58 ServicePluginHandler &operator = (const ServicePluginHandler &); 59 60 const std::vector<std::string> pluginSoPath = { 61 "/system/lib64/libgameservice_gpucounter_plugin.z.so", 62 "/system/lib64/libtest_server_client.z.so" 63 }; 64 std::vector<void*> pluginHandle; 65 }; 66 } 67 } 68 69 #endif