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 "pac_map.h" 21 #include "call_manager_callback.h" 22 23 #ifdef SCENE_BOARD_ENABLE 24 #include "display_manager_lite.h" 25 #else 26 #include "display_manager.h" 27 #endif 28 29 #ifdef LOG_TAG 30 #undef LOG_TAG 31 #endif 32 #define LOG_TAG "tee_tui_daemon" 33 34 /* same with class FoldDisplayMode in dm_common.h */ 35 enum FoldDisplayMode { 36 DISPLAY_MODE_UNKNOWN = 0, 37 DISPLAY_MODE_FULL, 38 DISPLAY_MODE_MAIN, 39 DISPLAY_MODE_SUB, 40 DISPLAY_MODE_COORDINATION, 41 DISPLAY_MODE_MAX, 42 }; 43 44 /* same with class FoldStatus in dm_common.h */ 45 enum FoldStates { 46 FOLD_STATE_UNKNOWN = 0, 47 FOLD_STATE_EXPANDED, 48 FOLD_STATE_FOLDED, 49 FOLD_STATE_HALF_FOLDED, 50 }; 51 52 enum TUIStates { 53 TUI_STATE_INVALID, 54 TUI_STATE_INIT, 55 TUI_STATE_TUI_START, 56 TUI_STATE_TUI_END, 57 TUI_STATE_MAX 58 }; 59 60 typedef struct { 61 uint32_t eventType; /* Tui event type */ 62 uint32_t value; /* return value, is keycode if tui event is getKeycode */ 63 uint32_t notch; /* notch size of phone */ 64 uint32_t width; /* width of foldable screen : cm */ 65 uint32_t height; /* height of foldable screen : cm */ 66 uint32_t foldState; /* state of foldable screen */ 67 uint32_t displayMode; /* one state of folded state */ 68 uint32_t phyWidth; /* real width of the mobile : px */ 69 uint32_t phyHeight; /* real height of the mobile : px */ 70 } TuiParameter; 71 72 class TUIEvent { 73 private: 74 TUIEvent() = default; 75 ~TUIEvent() = default; 76 77 static TUIEvent *tuiInstance; 78 std::shared_ptr<OHOS::PowerMgr::RunningLock> mRunningLock_; 79 TuiParameter mTUIPanelInfo; 80 bool mTUIStatus; 81 bool mTUIFoldable; 82 public: GetInstance()83 static TUIEvent *GetInstance() 84 { 85 if (tuiInstance == nullptr) { 86 tuiInstance = new TUIEvent(); 87 } 88 return tuiInstance; 89 } 90 91 void TuiEventInit(); 92 void TUIGetRunningLock(); 93 void TUIReleaseRunningLock(); 94 bool TUIGetPannelInfo(); 95 void TUIGetFoldable(); 96 void TUISetStatus(bool status); 97 bool TUIGetStatus(); 98 bool TUIGetFoldableStatus(); 99 void TUIDealWithEvent(bool state); 100 bool TUISendCmd(uint32_t tuiEvent); 101 }; 102 103 #ifdef SCENE_BOARD_ENABLE 104 class TUIDisplayListener : public OHOS::Rosen::DisplayManagerLite::IFoldStatusListener { 105 public: 106 TUIDisplayListener() = default; 107 ~TUIDisplayListener() = default; 108 void OnFoldStatusChanged(OHOS::Rosen::FoldStatus foldStatus) override; 109 }; 110 #else 111 class TUIDisplayListener : public OHOS::Rosen::DisplayManager::IFoldStatusListener { 112 public: 113 TUIDisplayListener() = default; 114 ~TUIDisplayListener() = default; 115 void OnFoldStatusChanged(OHOS::Rosen::FoldStatus foldStatus) override; 116 }; 117 #endif 118 119 class TUICallManagerCallback : public OHOS::Telephony::CallManagerCallback { 120 public: 121 TUICallManagerCallback() = default; 122 ~TUICallManagerCallback() = default; 123 int32_t OnCallDetailsChange(const OHOS::Telephony::CallAttributeInfo &info) override; OnCallEventChange(const OHOS::Telephony::CallEventInfo & info)124 int32_t OnCallEventChange(const OHOS::Telephony::CallEventInfo &info) override { return 0; } OnCallDisconnectedCause(const OHOS::Telephony::DisconnectedDetails & details)125 int32_t OnCallDisconnectedCause(const OHOS::Telephony::DisconnectedDetails &details) override { return 0; } OnReportAsyncResults(OHOS::Telephony::CallResultReportId reportId,OHOS::AppExecFwk::PacMap & resultInfo)126 int32_t OnReportAsyncResults(OHOS::Telephony::CallResultReportId reportId, 127 OHOS::AppExecFwk::PacMap &resultInfo) override { return 0; } OnOttCallRequest(OHOS::Telephony::OttCallRequestId requestId,OHOS::AppExecFwk::PacMap & info)128 int32_t OnOttCallRequest(OHOS::Telephony::OttCallRequestId requestId, 129 OHOS::AppExecFwk::PacMap &info) override { return 0; } OnReportMmiCodeResult(const OHOS::Telephony::MmiCodeInfo & info)130 int32_t OnReportMmiCodeResult(const OHOS::Telephony::MmiCodeInfo &info) override { return 0; } OnReportAudioDeviceChange(const OHOS::Telephony::AudioDeviceInfo & info)131 int32_t OnReportAudioDeviceChange(const OHOS::Telephony::AudioDeviceInfo &info) override { return 0; } OnReportPostDialDelay(const std::string & str)132 int32_t OnReportPostDialDelay(const std::string &str) override { return 0; } OnUpdateImsCallModeChange(const OHOS::Telephony::CallMediaModeInfo & imsCallModeInfo)133 int32_t OnUpdateImsCallModeChange( 134 const OHOS::Telephony::CallMediaModeInfo &imsCallModeInfo) override { return 0; } OnCallSessionEventChange(const OHOS::Telephony::CallSessionEvent & callSessionEventOptions)135 int32_t OnCallSessionEventChange( 136 const OHOS::Telephony::CallSessionEvent &callSessionEventOptions) override { return 0; } OnPeerDimensionsChange(const OHOS::Telephony::PeerDimensionsDetail & peerDimensionsDetail)137 int32_t OnPeerDimensionsChange( 138 const OHOS::Telephony::PeerDimensionsDetail &peerDimensionsDetail) override { return 0; } OnCallDataUsageChange(const int64_t dataUsage)139 int32_t OnCallDataUsageChange(const int64_t dataUsage) override { return 0; } OnUpdateCameraCapabilities(const OHOS::Telephony::CameraCapabilities & cameraCapabilities)140 int32_t OnUpdateCameraCapabilities( 141 const OHOS::Telephony::CameraCapabilities &cameraCapabilities) override { return 0; } 142 }; 143 144 class TUIDaemon { 145 public: 146 TUIDaemon() = default; 147 ~TUIDaemon(); 148 void TuiDaemonInit(bool onlyConfigRes); 149 OHOS::sptr<TUIDisplayListener> mTUIDisplayListener_ = nullptr; 150 private: 151 void TuiRegisteCallBack(); 152 void TuiRegisteDisplayListener(); 153 }; 154 #endif 155