• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 ProcessCameraEvent(const nlohmann::json& root, const std::string& eventName);
40     void ProcessWifiEvent(const nlohmann::json& root, const std::string& eventName);
41     bool CheckJsonValue(const nlohmann::json& value, std::initializer_list<std::string> params);
42 
43     std::map<std::string,
44         std::function<void(const nlohmann::json&, const std::string&)>> handleObserverMap_;
45 };
46 
47 /**
48 * Audio State
49 */
50 enum class AudioState : int32_t {
51     AUDIO_STATE_INVALID = -1,
52     AUDIO_STATE_NEW,
53     AUDIO_STATE_PREPARED,
54     AUDIO_STATE_RUNNING,
55     AUDIO_STATE_STOPPED,
56     AUDIO_STATE_RELEASED,
57     AUDIO_STATE_PAUSED
58 };
59 
60 /**
61 * Runninglock State
62 */
63 enum class RunningLockState : int32_t {
64     RUNNINGLOCK_STATE_DISABLE = 0,
65     RUNNINGLOCK_STATE_ENABLE,
66     RUNNINGLOCK_STATE_PROXIED,
67     RUNNINGLOCK_STATE_UNPROXIED_RESTORE,
68 };
69 
70 /**
71 * Wifi State
72 */
73 enum class WifiState : int32_t {
74     CONNECTED = 0,
75     DISCONNECTED
76 };
77 } // namespace ResourceSchedule
78 } // namespace OHOS
79 #endif // RESSCHED_SCHED_CONTROLLER_OBSERVER_INCLUDE_HISYSEVENT_OBSERVER_H
80