• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 OHOS_ROSEN_DM_COMMON_H
17 #define OHOS_ROSEN_DM_COMMON_H
18 
19 #include <refbase.h>
20 #include <string>
21 
22 namespace OHOS {
23 namespace Rosen {
24 using DisplayId = uint64_t;
25 using ScreenId = uint64_t;
26 namespace {
27     constexpr DisplayId DISPLAY_ID_INVALID = -1ULL;
28     constexpr ScreenId SCREEN_ID_INVALID = -1ULL;
29     constexpr int DOT_PER_INCH = 160;
30     const static std::string DEFAULT_SCREEN_NAME = "buildIn";
31 }
32 
33 enum class PowerStateChangeReason : uint32_t {
34     POWER_BUTTON,
35 };
36 
37 enum class ScreenPowerState : uint32_t {
38     POWER_ON,
39     POWER_STAND_BY,
40     POWER_SUSPEND,
41     POWER_OFF,
42     POWER_BUTT,
43     INVALID_STATE,
44 };
45 
46 enum class DisplayState : uint32_t {
47     ON,
48     OFF,
49     UNKNOWN,
50 };
51 
52 enum class DisplayEvent : uint32_t {
53     UNLOCK,
54     KEYGUARD_DRAWN,
55 };
56 
57 enum class DMError : int32_t {
58     DM_OK = 0,
59     DM_ERROR_INIT_DMS_PROXY_LOCKED = 100,
60     DM_ERROR_IPC_FAILED = 101,
61     DM_ERROR_REMOTE_CREATE_FAILED = 110,
62     DM_ERROR_NULLPTR = 120,
63     DM_ERROR_INVALID_PARAM = 130,
64     DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED = 140,
65     DM_ERROR_DEATH_RECIPIENT = 150,
66     DM_ERROR_INVALID_MODE_ID = 160,
67     DM_ERROR_WRITE_DATA_FAILED = 170,
68     DM_ERROR_RENDER_SERVICE_FAILED = 180,
69     DM_ERROR_UNKNOWN,
70 };
71 using DisplayStateCallback = std::function<void(DisplayState)>;
72 
73 enum class DisplayPowerEvent : uint32_t {
74     WAKE_UP,
75     SLEEP,
76     DISPLAY_ON,
77     DISPLAY_OFF,
78     DESKTOP_READY,
79 };
80 
81 enum class EventStatus : uint32_t {
82     BEGIN,
83     END,
84 };
85 
86 class IDisplayPowerEventListener : public RefBase {
87 public:
88     virtual void OnDisplayPowerEvent(DisplayPowerEvent event, EventStatus status) = 0;
89 };
90 
91 enum class ScreenChangeEvent : uint32_t {
92     UPDATE_ORIENTATION,
93     CHANGE_MODE,
94 };
95 
96 enum class ScreenGroupChangeEvent : uint32_t {
97     ADD_TO_GROUP,
98     REMOVE_FROM_GROUP,
99     CHANGE_GROUP,
100 };
101 
102 enum class Rotation : uint32_t {
103     ROTATION_0,
104     ROTATION_90,
105     ROTATION_180,
106     ROTATION_270,
107 };
108 
109 enum class Orientation : uint32_t {
110     BEGIN = 0,
111     UNSPECIFIED = BEGIN,
112     VERTICAL = 1,
113     HORIZONTAL = 2,
114     REVERSE_VERTICAL = 3,
115     REVERSE_HORIZONTAL = 4,
116     SENSOR = 5,
117     SENSOR_VERTICAL = 6,
118     SENSOR_HORIZONTAL = 7,
119     END = SENSOR_HORIZONTAL,
120 };
121 
122 enum class DisplayChangeEvent : uint32_t {
123     UPDATE_ORIENTATION,
124     DISPLAY_SIZE_CHANGED,
125     DISPLAY_FREEZED,
126     DISPLAY_UNFREEZED,
127     UNKNOWN,
128 };
129 }
130 }
131 #endif // OHOS_ROSEN_DM_COMMON_H