/* * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef RESSCHED_PLUGINS_SOCPERF_PLUGIN_INCLUDE_SOCPERF_PLUGIN_H #define RESSCHED_PLUGINS_SOCPERF_PLUGIN_INCLUDE_SOCPERF_PLUGIN_H #ifdef RESSCHED_RESOURCESCHEDULE_SOC_PERF_ENABLE #include #include #include "plugin.h" #include "single_instance.h" #include "socperf_client.h" namespace OHOS { namespace ResourceSchedule { class SocPerfPlugin : public Plugin { DECLARE_SINGLE_INSTANCE(SocPerfPlugin) public: void Init() override; void Disable() override; void DispatchResource(const std::shared_ptr& resData) override; private: using ReqAppTypeFunc = int32_t (*)(const std::string &bundleName); std::set resTypes; std::unordered_map& data)>> functionMap; // app's uid match app type std::map uidToAppTypeMap_; std::string perfReqAppTypeSoPath_; std::string perfReqAppTypeSoFunc_; void* handle_ = nullptr; ReqAppTypeFunc reqAppTypeFunc_ = nullptr; // current focus app type, -1 means no focus app int32_t focusAppType_ = -1; int32_t RES_TYPE_SCENE_BOARD_ID = 0; int32_t RES_TYPE_RGM_BOOTING_STATUS = 0; bool socperfGameBoostSwitch_ = false; void InitEventId(); void InitFunctionMap(); void AddEventToFunctionMap(); void InitResTypes(); void InitPerfCrucialSo(); void InitPerfCrucialFunc(const char* perfSoPath, const char* perfSoFunc); void HandleWindowFocus(const std::shared_ptr& data); void HandleEventClick(const std::shared_ptr& data); void HandleLoadPage(const std::shared_ptr& data); void HandlePopPage(const std::shared_ptr& data); void HandleEventSlide(const std::shared_ptr& data); void HandleEventWebGesture(const std::shared_ptr& data); void HandleAppAbilityStart(const std::shared_ptr& data); void HandleResizeWindow(const std::shared_ptr& data); void HandleMoveWindow(const std::shared_ptr& data); void HandleRemoteAnimation(const std::shared_ptr& data); bool InitFeatureSwitch(std::string featureName); void HandleDragStatusBar(const std::shared_ptr& data); void HandleWebGestureMove(const std::shared_ptr& data); void HandleWebSlideNormal(const std::shared_ptr& data); void HandleLoadUrl(const std::shared_ptr& data); void HandleMousewheel(const std::shared_ptr& data); bool HandleAppStateChange(const std::shared_ptr& data); bool HandleSocperfSceneBoard(const std::shared_ptr& data); void HandleDeviceModeStatusChange(const std::shared_ptr& data); bool HandleSocperfAccountActivating(const std::shared_ptr &data); bool HandleCustEvent(const std::shared_ptr& data); bool HandleCustEventBegin(const std::shared_ptr& data); bool HandleCustEventEnd(const std::shared_ptr& data); bool HandleRgmBootingStatus(const std::shared_ptr& data); bool HandleAppColdStartEx(const std::shared_ptr& data); bool HandleSceneRotation(const std::shared_ptr& data); bool HandleBmmMoniterStatus(const std::shared_ptr& data); bool HandleGameBoost(const std::shared_ptr& data); bool UpdateFocusAppType(const std::shared_ptr& data); bool HandleUninstallEvent(const std::shared_ptr& data); bool UpdateUidToAppTypeMap(const std::shared_ptr& data); bool UpdateUidToAppTypeMap(const std::shared_ptr& data, const int32_t appType); int32_t GetUidByData(const std::shared_ptr& data); std::string GetBundleNameByUid(const int32_t uid); }; } // namespace ResourceSchedule } // namespace OHOS #endif //RESSCHED_RESOURCESCHEDULE_SOC_PERF_ENABLE #endif // RESSCHED_PLUGINS_SOCPERF_PLUGIN_INCLUDE_SOCPERF_PLUGIN_H