• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #ifndef SECURITY_COMPONENT_MOCK_WINDOW_MANAGER_H
16 #define SECURITY_COMPONENT_MOCK_WINDOW_MANAGER_H
17 #include <cstdint>
18 #include <iremote_object.h>
19 #include <refbase.h>
20 #include <vector>
21 
22 namespace OHOS {
23 namespace Rosen {
24 using DisplayId = uint64_t;
25 using WindowMode = uint32_t;
26 using WindowType = uint32_t;
27 enum class WMError : int32_t {
28     WM_OK = 0,
29 };
30 
31 struct Rect {
32     int32_t posX_;
33     int32_t posY_;
34     uint32_t width_;
35     uint32_t height_;
36 };
37 
38 class AccessibilityWindowInfo : public Parcelable {
39 public:
40     AccessibilityWindowInfo() = default;
41     ~AccessibilityWindowInfo() = default;
Marshalling(Parcel & parcel)42     virtual bool Marshalling(Parcel& parcel) const override
43     {
44         return true;
45     };
46 
47     int32_t wid_;
48     int32_t innerWid_;
49     int32_t uiNodeId_;
50     Rect windowRect_;
51     bool focused_ { false };
52     bool isDecorEnable_ { false };
53     DisplayId displayId_;
54     uint32_t layer_;
55     WindowMode mode_;
56     WindowType type_;
57     float scaleVal_;
58 };
59 
60 class UnreliableWindowInfo : public Parcelable {
61 public:
62     UnreliableWindowInfo() = default;
63     ~UnreliableWindowInfo() = default;
Marshalling(Parcel & parcel)64     virtual bool Marshalling(Parcel& parcel) const override
65     {
66         return true;
67     };
68     int32_t windowId_ { 0 };
69     Rect windowRect_;
70     uint32_t zOrder_ { 0 };
71     float floatingScale_ { 1.0f };
72     float scaleX_ { 1.0f };
73     float scaleY_ { 1.0f };
74 };
75 
76 class WindowManager {
77 public:
GetInstance()78     static WindowManager& GetInstance()
79     {
80         static WindowManager instance;
81         return instance;
82     };
83 
GetAccessibilityWindowInfo(std::vector<sptr<Rosen::AccessibilityWindowInfo>> & list)84     WMError GetAccessibilityWindowInfo(std::vector<sptr<Rosen::AccessibilityWindowInfo>>& list)
85     {
86         list = list_;
87         return result_;
88     };
GetUnreliableWindowInfo(int32_t windowId,std::vector<sptr<UnreliableWindowInfo>> & infos)89     WMError GetUnreliableWindowInfo(int32_t windowId, std::vector<sptr<UnreliableWindowInfo>>& infos) const
90     {
91         return result_;
92     }
93 
WindowManager()94     WindowManager() {};
95 
SetDefaultSecCompScene()96     void SetDefaultSecCompScene()
97     {
98         result_ = OHOS::Rosen::WMError::WM_OK;
99         std::vector<sptr<AccessibilityWindowInfo>> list;
100         sptr<AccessibilityWindowInfo> compWin = new AccessibilityWindowInfo();
101         compWin->wid_ = 0;
102         compWin->layer_ = 0;
103         compWin->scaleVal_ = 0.0;
104         list.emplace_back(compWin);
105         list_ = list;
106 
107         std::vector<sptr<UnreliableWindowInfo>> info;
108         sptr<UnreliableWindowInfo> unreliableWinInfo = new UnreliableWindowInfo();
109         unreliableWinInfo->windowId_ = 0;
110         unreliableWinInfo->zOrder_ = 0;
111         unreliableWinInfo->floatingScale_ = 0.0;
112         info.emplace_back(unreliableWinInfo);
113         info_ = info;
114     };
115 
116     std::vector<sptr<Rosen::AccessibilityWindowInfo>> list_;
117     std::vector<sptr<Rosen::UnreliableWindowInfo>> info_;
118     WMError result_ = OHOS::Rosen::WMError::WM_OK;
119 private:
~WindowManager()120     ~WindowManager() {};
121 };
122 } // namespace Rosen
123 } // namespace OHOS
124 #endif // SECURITY_COMPONENT_MOCK_WINDOW_MANAGER_H
125