File: 1001_fix-non-libhybris-builds.patch

package info (click to toggle)
repowerd 2022.01-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,048 kB
  • sloc: cpp: 23,768; ansic: 397; xml: 219; makefile: 12
file content (240 lines) | stat: -rw-r--r-- 6,854 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
Description: Fix build without libandroid-properties-dev and android-headers (libhybris).
Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
Forwarded: https://gitlab.com/ubports/development/core/repowerd/-/merge_requests/41

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,6 +25,7 @@
 option(REPOWERD_DISABLE_TIME_SENSITIVE_TESTS "Don't run time-sensitive tests" OFF)
 
 option(REPOWERD_ENABLE_HYBRIS "Enable hybris support" ON)
+option(REPOWERD_ENABLE_ANDROID_PROPERTIES "Enable Android properties" ON)
 
 # Work around cmake setting conf dir to "/usr/etc" instead of "/etc"
 # when prefix is "/usr"
@@ -37,11 +38,12 @@
 find_package(Threads REQUIRED)
 find_package(PkgConfig REQUIRED)
 
-pkg_check_modules(ANDROID_PROPERTIES REQUIRED libandroid-properties)
+
 pkg_check_modules(GIO REQUIRED gio-2.0)
 pkg_check_modules(GIO_UNIX REQUIRED gio-unix-2.0)
 
 if (REPOWERD_ENABLE_HYBRIS)
+    pkg_check_modules(ANDROID_PROPERTIES REQUIRED libandroid-properties)
     pkg_check_modules(UA REQUIRED ubuntu-platform-api)
     pkg_check_modules(LIBHARDWARE REQUIRED libhardware)
     pkg_check_modules(UBUNTU_PLATFORM_HARDWARE_API REQUIRED ubuntu-platform-hardware-api)
--- a/src/adapters/CMakeLists.txt
+++ b/src/adapters/CMakeLists.txt
@@ -18,7 +18,10 @@
 
 if (REPOWERD_ENABLE_HYBRIS)
     set(REPOWERD_ADAPTER_HYBRIS_SRCS
+        android_autobrightness_algorithm.cpp
         android_backlight.cpp
+        android_device_config.cpp
+        android_device_quirks.cpp
         dev_alarm_wakeup_service.cpp
         ubuntu_light_sensor.cpp
         ubuntu_performance_booster.cpp
@@ -29,9 +32,6 @@
 set(
     REPOWERD_ADAPTER_SRCS
 
-    android_autobrightness_algorithm.cpp
-    android_device_config.cpp
-    android_device_quirks.cpp
     backlight_brightness_control.cpp
     brightness_params.cpp
     console_log.cpp
@@ -63,6 +63,7 @@
     upower_power_source_and_lid.cpp
 
     ${REPOWERD_ADAPTER_HYBRIS_SRCS}
+
 )
 
 add_library(
--- a/tests/adapter-tests/CMakeLists.txt
+++ b/tests/adapter-tests/CMakeLists.txt
@@ -15,10 +15,16 @@
 # Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
 
 if (REPOWERD_ENABLE_HYBRIS)
+    add_definition("-DREPOWERD_ENABLE_HYBRIS")
+
     set(REPOWERD_ADAPTER_TEST_HYBRIS_SRCS
         fake_libhardware.cpp
+        fake_android_properties.cpp
 
+        test_android_autobrightness_algorithm.cpp
         test_android_backlight.cpp
+        test_android_device_config.cpp
+        test_android_device_quirks.cpp
         test_dev_alarm_wakeup_service.cpp
         test_ubuntu_light_sensor.cpp
         test_ubuntu_proximity_sensor.cpp
@@ -31,7 +37,6 @@
     current_thread_name.cpp
     dbus_bus.cpp
     dbus_client.cpp
-    fake_android_properties.cpp
     fake_brightness_notification.cpp
     fake_chrono.cpp
     fake_device_config.cpp
@@ -47,9 +52,6 @@
     temporary_file.cpp
     unity_screen_dbus_client.cpp
 
-    test_android_autobrightness_algorithm.cpp
-    test_android_device_config.cpp
-    test_android_device_quirks.cpp
     test_backlight_brightness_control.cpp
     test_brightness_params.cpp
     test_dbus_event_loop.cpp
@@ -77,6 +79,8 @@
     test_upower_power_source_and_lid.cpp
 
     ${REPOWERD_ADAPTER_TEST_HYBRIS_SRCS}
+    ${REPOWERD_ADAPTER_ANDROID_PROPERTIES_SRCS}
+
 )
 
 target_link_libraries(
--- a/src/adapters/default_state_machine_options.cpp
+++ b/src/adapters/default_state_machine_options.cpp
@@ -20,7 +20,9 @@
 #include "src/core/log.h"
 #include "src/core/infinite_timeout.h"
 
+#ifdef REPOWERD_ENABLE_HYBRIS
 #include <hybris/properties/properties.h>
+#endif
 
 using namespace std::chrono_literals;
 
@@ -31,9 +33,13 @@
 
 std::string determine_device_name()
 {
+#ifdef REPOWERD_ENABLE_HYBRIS
     char name[PROP_VALUE_MAX] = "";
     property_get("ro.product.device", name, "");
     return name;
+#else
+    return "";
+#endif
 }
 
 bool treat_power_button_as_user_activity_for(
--- a/src/default_daemon_config.cpp
+++ b/src/default_daemon_config.cpp
@@ -21,9 +21,6 @@
 #include "src/core/performance_booster.h"
 #include "src/core/proximity_sensor.h"
 
-#include "adapters/android_autobrightness_algorithm.h"
-#include "adapters/android_device_config.h"
-#include "adapters/android_device_quirks.h"
 #include "adapters/backlight_brightness_control.h"
 #include "adapters/console_log.h"
 #include "adapters/default_state_machine_options.h"
@@ -49,7 +46,10 @@
 
 // Hybris
 #ifdef REPOWERD_ENABLE_HYBRIS
+#include "adapters/android_autobrightness_algorithm.h"
 #include "adapters/android_backlight.h"
+#include "adapters/android_device_config.h"
+#include "adapters/android_device_quirks.h"
 #include "adapters/dev_alarm_wakeup_service.h"
 #include "adapters/ubuntu_light_sensor.h"
 #include "adapters/ubuntu_performance_booster.h"
@@ -415,6 +415,7 @@
 {
     if (!backlight_brightness_control)
     {
+#ifdef REPOWERD_ENABLE_HYBRIS
         auto const ab_log_env_cstr = getenv("REPOWERD_LOG_AUTOBRIGHTNESS");
         std::string const ab_log_env{ab_log_env_cstr ? ab_log_env_cstr : ""};
 
@@ -428,6 +429,7 @@
             the_log(),
             *the_device_config(),
             *the_device_quirks());
+#endif
     }
 
     return backlight_brightness_control;
@@ -474,6 +476,7 @@
 {
     if (!device_config)
     {
+#ifdef REPOWERD_ENABLE_HYBRIS
         auto const dir_env_cstr = getenv("REPOWERD_DEVICE_CONFIG_DIR");
         std::string const dir_env{dir_env_cstr ? dir_env_cstr : ""};
 
@@ -490,6 +493,7 @@
             the_log(),
             the_filesystem(),
             device_config_dirs);
+#endif
     }
 
     return device_config;
@@ -499,8 +503,11 @@
 repowerd::DefaultDaemonConfig::the_device_quirks()
 {
     if (!device_quirks)
+    {
+#ifdef REPOWERD_ENABLE_HYBRIS
         device_quirks = std::make_shared<AndroidDeviceQuirks>(*the_log());
-
+#endif
+    }
     return device_quirks;
 }
 
--- a/tests/adapter-tests/test_default_state_machine_options.cpp
+++ b/tests/adapter-tests/test_default_state_machine_options.cpp
@@ -18,7 +18,9 @@
 
 #include "src/adapters/default_state_machine_options.h"
 
+#ifdef REPOWERD_ENABLE_HYBRIS
 #include "fake_android_properties.h"
+#endif
 #include "fake_log.h"
 
 #include <gtest/gtest.h>
@@ -43,15 +45,20 @@
 {
     void set_device_name()
     {
+#ifdef REPOWERD_ENABLE_HYBRIS
         fake_android_properties.set("ro.product.device", "device");
+#endif
     }
 
+#ifdef REPOWERD_ENABLE_HYBRIS
     rt::FakeAndroidProperties fake_android_properties;
+#endif
     rt::FakeLog fake_log;
 };
 
 }
 
+#ifdef REPOWERD_ENABLE_HYBRIS
 TEST_F(ADefaultStateMachineOptions,
        treat_power_button_as_user_activity_is_false_if_device_has_a_name)
 {
@@ -60,6 +67,7 @@
 
     EXPECT_FALSE(default_state_machine_options.treat_power_button_as_user_activity());
 }
+#endif
 
 TEST_F(ADefaultStateMachineOptions,
        treat_power_button_as_user_activity_is_true_if_device_does_not_have_a_name)