• 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 WindowManager {
61 public:
GetInstance()62     static WindowManager& GetInstance()
63     {
64         static WindowManager instance;
65         return instance;
66     };
67 
GetAccessibilityWindowInfo(std::vector<sptr<Rosen::AccessibilityWindowInfo>> & list)68     WMError GetAccessibilityWindowInfo(std::vector<sptr<Rosen::AccessibilityWindowInfo>>& list)
69     {
70         list = list_;
71         return result_;
72     };
73 
WindowManager()74     WindowManager() {};
75 
SetDefaultSecCompScene()76     void SetDefaultSecCompScene()
77     {
78         result_ = OHOS::Rosen::WMError::WM_OK;
79         std::vector<sptr<AccessibilityWindowInfo>> list;
80         sptr<AccessibilityWindowInfo> compWin = new AccessibilityWindowInfo();
81         compWin->wid_ = 0;
82         compWin->layer_ = 0;
83         compWin->scaleVal_ = 0.0;
84         list.emplace_back(compWin);
85         list_ = list;
86     };
87 
88     std::vector<sptr<Rosen::AccessibilityWindowInfo>> list_;
89     WMError result_ = OHOS::Rosen::WMError::WM_OK;
90 private:
~WindowManager()91     ~WindowManager() {};
92 };
93 } // namespace Rosen
94 } // namespace OHOS
95 #endif // SECURITY_COMPONENT_MOCK_WINDOW_MANAGER_H
96