1 /* 2 * Copyright (c) 2022-2023 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 RESSCHED_SCHED_CONTROLLER_OBSERVER_INCLUDE_HISYSEVENT_OBSERVER_H 17 #define RESSCHED_SCHED_CONTROLLER_OBSERVER_INCLUDE_HISYSEVENT_OBSERVER_H 18 19 #include <memory> 20 #include <string> 21 22 #include "hisysevent_listener.h" 23 #include "nlohmann/json.hpp" 24 25 namespace OHOS { 26 namespace ResourceSchedule { 27 class HiSysEventObserver : public HiviewDFX::HiSysEventListener { 28 public: 29 void OnEvent(std::shared_ptr<HiviewDFX::HiSysEventRecord> sysEvent) override; 30 void OnServiceDied() override; 31 void ProcessHiSysEvent(const std::string& eventName, const nlohmann::json& root); 32 33 HiSysEventObserver(); 34 ~HiSysEventObserver(); 35 36 private: 37 void ProcessAvCodecEvent(const nlohmann::json& root, const std::string& eventName); 38 void ProcessRunningLockEvent(const nlohmann::json& root, const std::string& eventName); 39 void ProcessAudioEvent(const nlohmann::json& root, const std::string& eventName); 40 void ProcessCameraEvent(const nlohmann::json& root, const std::string& eventName); 41 void ProcessBluetoothEvent(const nlohmann::json& root, const std::string& eventName); 42 void ProcessWifiEvent(const nlohmann::json& root, const std::string& eventName); 43 bool CheckJsonValue(const nlohmann::json& value, std::initializer_list<std::string> params); 44 45 std::map<std::string, 46 std::function<void(const nlohmann::json&, const std::string&)>> handleObserverMap_; 47 }; 48 49 /** 50 * Audio State 51 */ 52 enum class AudioState : int32_t { 53 AUDIO_STATE_INVALID = -1, 54 AUDIO_STATE_NEW, 55 AUDIO_STATE_PREPARED, 56 AUDIO_STATE_RUNNING, 57 AUDIO_STATE_STOPPED, 58 AUDIO_STATE_RELEASED, 59 AUDIO_STATE_PAUSED 60 }; 61 62 /** 63 * Runninglock State 64 */ 65 enum class RunningLockState : int32_t { 66 RUNNINGLOCK_STATE_DISABLE = 0, 67 RUNNINGLOCK_STATE_ENABLE, 68 RUNNINGLOCK_STATE_PROXIED, 69 RUNNINGLOCK_STATE_UNPROXIED_RESTORE, 70 }; 71 72 /** 73 * Wifi State 74 */ 75 enum class WifiState : int32_t { 76 CONNECTED = 0, 77 DISCONNECTED 78 }; 79 } // namespace ResourceSchedule 80 } // namespace OHOS 81 #endif // RESSCHED_SCHED_CONTROLLER_OBSERVER_INCLUDE_HISYSEVENT_OBSERVER_H 82