1 /*
2  * Copyright (C) 2023 Huawei Technologies Co., Ltd.
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 
13 #ifndef TUI_EVENT_H
14 #define TUI_EVENT_H
15 
16 #include <cstdint>
17 #include <cstdio>
18 
19 #include "running_lock.h"
20 #include "display_manager.h"
21 #include "pac_map.h"
22 #include "call_manager_callback.h"
23 
24 
25 #ifdef LOG_TAG
26 #undef LOG_TAG
27 #endif
28 #define LOG_TAG "tee_tui_daemon"
29 
30 typedef struct {
31     uint32_t eventType; /* Tui event type */
32     uint32_t value;   /* return value, is keycode if tui event is getKeycode */
33     uint32_t notch;   /* notch size of phone */
34     uint32_t width;   /* width of foldable screen : cm */
35     uint32_t height;  /* height of foldable screen : cm */
36     uint32_t foldState;    /* state of foldable screen */
37     uint32_t displayState; /* one state of folded state */
38     uint32_t phyWidth;     /* real width of the mobile : px */
39     uint32_t phyHeight;    /* real height of the mobile : px */
40 } TuiParameter;
41 
42 class TUIEvent {
43 private:
44     TUIEvent() = default;
45     ~TUIEvent() = default;
46 
47     static TUIEvent *tuiInstance;
48     std::shared_ptr<OHOS::PowerMgr::RunningLock> mRunningLock_;
49     TuiParameter mTUIPanelInfo;
50     bool mTUIStatus;
51 public:
GetInstance()52     static TUIEvent *GetInstance()
53     {
54         if (tuiInstance == nullptr) {
55             tuiInstance = new TUIEvent();
56         }
57         return tuiInstance;
58     }
59 
60     void TuiEventInit();
61     void TUIGetRunningLock();
62     void TUIReleaseRunningLock();
63     int32_t TUIGetPannelInfo();
64     void TUISetStatus(bool status);
65     bool TUIGetStatus();
66     int32_t TUIDealWithEvent(bool state);
67     bool TUISendCmd(uint32_t tuiEvent);
68 };
69 
70 class TUIDisplayListener : public OHOS::Rosen::DisplayManager::IDisplayListener {
71 public:
72     TUIDisplayListener() = default;
73     ~TUIDisplayListener() = default;
OnCreate(OHOS::Rosen::DisplayId dId)74     void OnCreate(OHOS::Rosen::DisplayId dId) override {}
OnDestroy(OHOS::Rosen::DisplayId dId)75     void OnDestroy(OHOS::Rosen::DisplayId dId) override {}
76     void OnChange(OHOS::Rosen::DisplayId dId) override;
77 };
78 
79 class TUICallManagerCallback : public OHOS::Telephony::CallManagerCallback {
80 public:
81     TUICallManagerCallback() = default;
82     ~TUICallManagerCallback() = default;
83     int32_t OnCallDetailsChange(const OHOS::Telephony::CallAttributeInfo &info) override;
OnCallEventChange(const OHOS::Telephony::CallEventInfo & info)84     int32_t OnCallEventChange(const OHOS::Telephony::CallEventInfo &info) override { return 0; }
OnCallDisconnectedCause(const OHOS::Telephony::DisconnectedDetails & details)85     int32_t OnCallDisconnectedCause(const OHOS::Telephony::DisconnectedDetails &details) override { return 0; }
OnReportAsyncResults(OHOS::Telephony::CallResultReportId reportId,OHOS::AppExecFwk::PacMap & resultInfo)86     int32_t OnReportAsyncResults(OHOS::Telephony::CallResultReportId reportId,
87         OHOS::AppExecFwk::PacMap &resultInfo) override { return 0; }
OnOttCallRequest(OHOS::Telephony::OttCallRequestId requestId,OHOS::AppExecFwk::PacMap & info)88     int32_t OnOttCallRequest(OHOS::Telephony::OttCallRequestId requestId,
89         OHOS::AppExecFwk::PacMap &info) override { return 0; }
OnReportMmiCodeResult(const OHOS::Telephony::MmiCodeInfo & info)90     int32_t OnReportMmiCodeResult(const OHOS::Telephony::MmiCodeInfo &info) override { return 0; }
OnReportAudioDeviceChange(const OHOS::Telephony::AudioDeviceInfo & info)91     int32_t OnReportAudioDeviceChange(const OHOS::Telephony::AudioDeviceInfo &info) override { return 0; }
OnReportPostDialDelay(const std::string & str)92     int32_t OnReportPostDialDelay(const std::string &str) override { return 0; }
93 };
94 
95 class TUIDaemon {
96 public:
97     TUIDaemon() = default;
98     ~TUIDaemon();
99     void TuiDaemonInit();
100     OHOS::sptr<TUIDisplayListener> mTUIDisplayListener_ = nullptr;
101 private:
102     void TuiRegisteCallBack();
103     void TuiRegisteDisplayListener();
104     bool CheckSAStarted(int32_t targetSAId);
105 };
106 #endif