@geastack/host 0.1.30 → 0.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/host/display.cpp +23 -0
- package/host/http.cpp +236 -32
- package/host/local_notifications_apple.mm +199 -0
- package/host/media.cpp +63 -0
- package/host/menu_bar_apple.mm +15 -0
- package/include/gea/embedded-host.h +3 -0
- package/include/host/backends.h +5 -0
- package/include/host/display.h +3 -0
- package/include/host/http.h +83 -1
- package/include/host/local_notifications.h +56 -0
- package/include/host/media.h +115 -6
- package/include/host/notification_relay.h +84 -0
- package/include/host/phone_link.h +173 -0
- package/package.json +1 -1
package/host/display.cpp
CHANGED
|
@@ -44,6 +44,29 @@ void DisplayBackend::setBrightness(double brightness) {
|
|
|
44
44
|
gea::platform::display::Display::setBrightness(static_cast<int>(brightness));
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
// Panel power hooks. Weak defaults keep the surface on every target; a board
|
|
48
|
+
// whose panel can sleep provides the strong definitions in its display driver
|
|
49
|
+
// (display-off + sleep-in, stop presenting, resume on wake).
|
|
50
|
+
extern "C" __attribute__((weak)) void gea_display_set_powered(int on) {
|
|
51
|
+
(void)on;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
extern "C" __attribute__((weak)) int gea_display_powered(void) {
|
|
55
|
+
return 1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void DisplayBackend::sleep() {
|
|
59
|
+
gea_display_set_powered(0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
void DisplayBackend::wake() {
|
|
63
|
+
gea_display_set_powered(1);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
bool DisplayBackend::awake() {
|
|
67
|
+
return gea_display_powered() != 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
47
70
|
void DisplayBackend::setAA(double samples) {
|
|
48
71
|
gea::platform::display::Display::setAA(static_cast<int>(samples));
|
|
49
72
|
}
|
package/host/http.cpp
CHANGED
|
@@ -131,6 +131,158 @@ void runRequests() {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
namespace {
|
|
135
|
+
|
|
136
|
+
std::mutex &bundleMutex() {
|
|
137
|
+
static std::mutex m;
|
|
138
|
+
return m;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
std::vector<const HttpEmbeddedBundle *> &bundleTable() {
|
|
142
|
+
static std::vector<const HttpEmbeddedBundle *> table;
|
|
143
|
+
return table;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const HttpEmbeddedAsset *findAsset(const HttpEmbeddedBundle &bundle,
|
|
147
|
+
std::string_view path) {
|
|
148
|
+
for (std::size_t i = 0; i < bundle.count; ++i) {
|
|
149
|
+
if (bundle.assets[i].path && path == bundle.assets[i].path)
|
|
150
|
+
return &bundle.assets[i];
|
|
151
|
+
}
|
|
152
|
+
return nullptr;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// RFC 9110 If-None-Match: "*" or a comma-separated list of entity tags; weak
|
|
156
|
+
// comparison, so W/"x" matches "x".
|
|
157
|
+
bool etagMatches(std::string_view header, std::string_view etag) {
|
|
158
|
+
if (etag.empty() || header.empty())
|
|
159
|
+
return false;
|
|
160
|
+
std::size_t begin = 0;
|
|
161
|
+
while (begin < header.size()) {
|
|
162
|
+
auto end = header.find(',', begin);
|
|
163
|
+
if (end == std::string_view::npos)
|
|
164
|
+
end = header.size();
|
|
165
|
+
auto tag = header.substr(begin, end - begin);
|
|
166
|
+
while (!tag.empty() && (tag.front() == ' ' || tag.front() == '\t'))
|
|
167
|
+
tag.remove_prefix(1);
|
|
168
|
+
while (!tag.empty() && (tag.back() == ' ' || tag.back() == '\t'))
|
|
169
|
+
tag.remove_suffix(1);
|
|
170
|
+
if (tag == "*")
|
|
171
|
+
return true;
|
|
172
|
+
if (tag.substr(0, 2) == "W/")
|
|
173
|
+
tag.remove_prefix(2);
|
|
174
|
+
if (tag == etag)
|
|
175
|
+
return true;
|
|
176
|
+
begin = end + 1;
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
} // namespace
|
|
182
|
+
|
|
183
|
+
bool register_embedded_bundle(const HttpEmbeddedBundle *bundle) {
|
|
184
|
+
if (!bundle || !bundle->name)
|
|
185
|
+
return false;
|
|
186
|
+
std::lock_guard<std::mutex> lock(bundleMutex());
|
|
187
|
+
for (auto &entry : bundleTable()) {
|
|
188
|
+
if (std::string_view(entry->name) == bundle->name) {
|
|
189
|
+
entry = bundle;
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
bundleTable().push_back(bundle);
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const HttpEmbeddedBundle *find_embedded_bundle(std::string_view name) {
|
|
198
|
+
std::lock_guard<std::mutex> lock(bundleMutex());
|
|
199
|
+
for (const auto *bundle : bundleTable()) {
|
|
200
|
+
if (name == bundle->name)
|
|
201
|
+
return bundle;
|
|
202
|
+
}
|
|
203
|
+
return nullptr;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
EmbeddedAssetResponse resolve_embedded_asset(std::string_view file,
|
|
207
|
+
std::string_view ifNoneMatch) {
|
|
208
|
+
EmbeddedAssetResponse response;
|
|
209
|
+
if (!is_embedded_asset_file(file))
|
|
210
|
+
return response;
|
|
211
|
+
auto rest = file.substr(kEmbeddedAssetScheme.size());
|
|
212
|
+
const auto slash = rest.find('/');
|
|
213
|
+
const auto name = rest.substr(0, slash);
|
|
214
|
+
std::string_view path =
|
|
215
|
+
slash == std::string_view::npos ? std::string_view("/")
|
|
216
|
+
: rest.substr(slash);
|
|
217
|
+
const HttpEmbeddedBundle *bundle = find_embedded_bundle(name);
|
|
218
|
+
if (!bundle)
|
|
219
|
+
return response;
|
|
220
|
+
if (path.empty() || path == "/")
|
|
221
|
+
path = "/index.html";
|
|
222
|
+
const HttpEmbeddedAsset *asset = findAsset(*bundle, path);
|
|
223
|
+
if (!asset && bundle->fallback) {
|
|
224
|
+
const auto lastSlash = path.rfind('/');
|
|
225
|
+
const auto segment =
|
|
226
|
+
lastSlash == std::string_view::npos ? path : path.substr(lastSlash + 1);
|
|
227
|
+
// A route ("/apps", "/settings/wifi") reloads the app; a missing file
|
|
228
|
+
// ("/assets/old-1a2b.js", "/favicon.ico") stays a 404, so a stale hashed
|
|
229
|
+
// name never comes back as HTML parsed as script.
|
|
230
|
+
if (segment.find('.') == std::string_view::npos)
|
|
231
|
+
asset = findAsset(*bundle, bundle->fallback);
|
|
232
|
+
}
|
|
233
|
+
if (!asset)
|
|
234
|
+
return response;
|
|
235
|
+
|
|
236
|
+
response.asset = asset;
|
|
237
|
+
response.contentType =
|
|
238
|
+
asset->contentType ? asset->contentType : "application/octet-stream";
|
|
239
|
+
if (asset->gzip)
|
|
240
|
+
response.headers.push_back({"Content-Encoding", "gzip"});
|
|
241
|
+
response.headers.push_back({"Vary", "Accept-Encoding"});
|
|
242
|
+
response.headers.push_back(
|
|
243
|
+
{"Cache-Control", asset->immutable ? "public, max-age=31536000, immutable"
|
|
244
|
+
: "no-cache"});
|
|
245
|
+
if (asset->etag && *asset->etag)
|
|
246
|
+
response.headers.push_back({"ETag", asset->etag});
|
|
247
|
+
response.status =
|
|
248
|
+
asset->etag && etagMatches(ifNoneMatch, asset->etag) ? 304 : 200;
|
|
249
|
+
return response;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const char *status_reason(int status) {
|
|
253
|
+
switch (status) {
|
|
254
|
+
case 200: return "OK";
|
|
255
|
+
case 201: return "Created";
|
|
256
|
+
case 202: return "Accepted";
|
|
257
|
+
case 204: return "No Content";
|
|
258
|
+
case 206: return "Partial Content";
|
|
259
|
+
case 301: return "Moved Permanently";
|
|
260
|
+
case 302: return "Found";
|
|
261
|
+
case 303: return "See Other";
|
|
262
|
+
case 304: return "Not Modified";
|
|
263
|
+
case 307: return "Temporary Redirect";
|
|
264
|
+
case 308: return "Permanent Redirect";
|
|
265
|
+
case 400: return "Bad Request";
|
|
266
|
+
case 401: return "Unauthorized";
|
|
267
|
+
case 403: return "Forbidden";
|
|
268
|
+
case 404: return "Not Found";
|
|
269
|
+
case 405: return "Method Not Allowed";
|
|
270
|
+
case 409: return "Conflict";
|
|
271
|
+
case 410: return "Gone";
|
|
272
|
+
case 413: return "Content Too Large";
|
|
273
|
+
case 415: return "Unsupported Media Type";
|
|
274
|
+
case 422: return "Unprocessable Content";
|
|
275
|
+
case 423: return "Locked";
|
|
276
|
+
case 429: return "Too Many Requests";
|
|
277
|
+
case 500: return "Internal Server Error";
|
|
278
|
+
case 501: return "Not Implemented";
|
|
279
|
+
case 502: return "Bad Gateway";
|
|
280
|
+
case 503: return "Service Unavailable";
|
|
281
|
+
case 504: return "Gateway Timeout";
|
|
282
|
+
default: return "";
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
134
286
|
HttpReply test_dispatch(NativeHttpServerHandle handle,
|
|
135
287
|
const std::string &method, const std::string &path,
|
|
136
288
|
const std::string &query) {
|
|
@@ -204,27 +356,66 @@ std::string methodName(int method) {
|
|
|
204
356
|
}
|
|
205
357
|
}
|
|
206
358
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
return
|
|
225
|
-
|
|
226
|
-
|
|
359
|
+
// "404 Not Found". httpd_resp_set_status keeps the pointer until the reply
|
|
360
|
+
// is sent, so the caller holds the returned string for the whole send. Every
|
|
361
|
+
// status the app returns goes out as itself: an unknown code is still sent
|
|
362
|
+
// with its own number (an API 401/409/429 must never leave as "200 OK").
|
|
363
|
+
std::string statusLine(int status) {
|
|
364
|
+
if (status < 100 || status > 999)
|
|
365
|
+
status = 500;
|
|
366
|
+
const char *reason = status_reason(status);
|
|
367
|
+
std::string line = std::to_string(status);
|
|
368
|
+
line += ' ';
|
|
369
|
+
line += *reason ? reason : "Status";
|
|
370
|
+
return line;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
bool sameHeaderName(const std::string &a, const char *b) {
|
|
374
|
+
const std::size_t n = std::strlen(b);
|
|
375
|
+
if (a.size() != n)
|
|
376
|
+
return false;
|
|
377
|
+
for (std::size_t i = 0; i < n; ++i) {
|
|
378
|
+
char x = a[i], y = b[i];
|
|
379
|
+
if (x >= 'A' && x <= 'Z')
|
|
380
|
+
x = static_cast<char>(x - 'A' + 'a');
|
|
381
|
+
if (y >= 'A' && y <= 'Z')
|
|
382
|
+
y = static_cast<char>(y - 'A' + 'a');
|
|
383
|
+
if (x != y)
|
|
384
|
+
return false;
|
|
227
385
|
}
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// Serve a compiled-in bundle file straight out of flash .rodata. Content-Type,
|
|
390
|
+
// encoding and caching come from the bundle; the app's own headers are added
|
|
391
|
+
// unless they name one of those.
|
|
392
|
+
esp_err_t sendEmbedded(httpd_req_t *r, const HttpRequest &req,
|
|
393
|
+
const HttpReply &reply) {
|
|
394
|
+
const EmbeddedAssetResponse resolved = resolve_embedded_asset(
|
|
395
|
+
reply.file, find_header(req.headers, "If-None-Match"));
|
|
396
|
+
const std::string status = statusLine(resolved.status);
|
|
397
|
+
httpd_resp_set_status(r, status.c_str());
|
|
398
|
+
if (!resolved.asset) {
|
|
399
|
+
httpd_resp_set_type(r, "text/plain");
|
|
400
|
+
return httpd_resp_sendstr(r, "Not found");
|
|
401
|
+
}
|
|
402
|
+
httpd_resp_set_type(r, resolved.contentType.c_str());
|
|
403
|
+
for (const auto &header : resolved.headers)
|
|
404
|
+
httpd_resp_set_hdr(r, header.name.c_str(), header.value.c_str());
|
|
405
|
+
for (const auto &header : reply.headers) {
|
|
406
|
+
if (!validHttpHeader(header))
|
|
407
|
+
continue;
|
|
408
|
+
bool owned = sameHeaderName(header.name, "Content-Type");
|
|
409
|
+
for (const auto &mine : resolved.headers)
|
|
410
|
+
owned = owned || sameHeaderName(header.name, mine.name.c_str());
|
|
411
|
+
if (!owned)
|
|
412
|
+
httpd_resp_set_hdr(r, header.name.c_str(), header.value.c_str());
|
|
413
|
+
}
|
|
414
|
+
if (resolved.status == 304 || req.method == "HEAD")
|
|
415
|
+
return httpd_resp_send(r, nullptr, 0);
|
|
416
|
+
return httpd_resp_send(
|
|
417
|
+
r, reinterpret_cast<const char *>(resolved.asset->data),
|
|
418
|
+
static_cast<ssize_t>(resolved.asset->size));
|
|
228
419
|
}
|
|
229
420
|
|
|
230
421
|
// Stream a file from disk to the client in chunks, so multi-MB recordings never
|
|
@@ -237,17 +428,19 @@ esp_err_t sendFile(httpd_req_t *r, const HttpReply &reply) {
|
|
|
237
428
|
httpd_resp_sendstr(r, "File not found");
|
|
238
429
|
return ESP_OK;
|
|
239
430
|
}
|
|
240
|
-
|
|
431
|
+
const std::string status = statusLine(reply.status);
|
|
432
|
+
httpd_resp_set_status(r, status.c_str());
|
|
241
433
|
httpd_resp_set_type(r, reply.contentType.c_str());
|
|
242
434
|
for (const auto &header : reply.headers) {
|
|
243
435
|
if (validHttpHeader(header))
|
|
244
436
|
httpd_resp_set_hdr(r, header.name.c_str(), header.value.c_str());
|
|
245
437
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
438
|
+
const std::string disposition =
|
|
439
|
+
reply.download.empty()
|
|
440
|
+
? std::string()
|
|
441
|
+
: "attachment; filename=\"" + reply.download + "\"";
|
|
442
|
+
if (!disposition.empty())
|
|
249
443
|
httpd_resp_set_hdr(r, "Content-Disposition", disposition.c_str());
|
|
250
|
-
}
|
|
251
444
|
auto *buffer = static_cast<char *>(std::malloc(kStreamChunkBytes));
|
|
252
445
|
if (!buffer) {
|
|
253
446
|
std::fclose(f);
|
|
@@ -300,8 +493,9 @@ esp_err_t wildcardHandler(httpd_req_t *r) {
|
|
|
300
493
|
#else
|
|
301
494
|
// Older IDF does not expose header enumeration; retain the standard fields
|
|
302
495
|
// needed by device upload handlers without using private httpd structures.
|
|
303
|
-
for (const char *name :
|
|
304
|
-
|
|
496
|
+
for (const char *name :
|
|
497
|
+
{"Host", "Content-Type", "Content-Length", "X-File-Name",
|
|
498
|
+
"Authorization", "Origin", "If-None-Match", "Accept-Encoding"}) {
|
|
305
499
|
const auto length = httpd_req_get_hdr_value_len(r, name);
|
|
306
500
|
if (!length)
|
|
307
501
|
continue;
|
|
@@ -330,24 +524,34 @@ esp_err_t wildcardHandler(httpd_req_t *r) {
|
|
|
330
524
|
received += static_cast<std::size_t>(count);
|
|
331
525
|
}
|
|
332
526
|
|
|
527
|
+
// The embedded-asset path needs the request's validators after the
|
|
528
|
+
// rendezvous; keep the method and headers, the body has been consumed.
|
|
529
|
+
HttpRequest meta;
|
|
530
|
+
meta.method = req.method;
|
|
531
|
+
meta.headers = req.headers;
|
|
532
|
+
|
|
333
533
|
const HttpReply reply = dispatchAndWait(
|
|
334
534
|
server, std::move(req), kRendezvousTimeoutMs, kRendezvousPollMs,
|
|
335
535
|
[](int ms) { vTaskDelay(pdMS_TO_TICKS(ms)); });
|
|
336
536
|
|
|
537
|
+
if (is_embedded_asset_file(reply.file))
|
|
538
|
+
return sendEmbedded(r, meta, reply);
|
|
337
539
|
if (!reply.file.empty())
|
|
338
540
|
return sendFile(r, reply);
|
|
339
541
|
|
|
340
|
-
|
|
542
|
+
const std::string status = statusLine(reply.status);
|
|
543
|
+
httpd_resp_set_status(r, status.c_str());
|
|
341
544
|
httpd_resp_set_type(r, reply.contentType.c_str());
|
|
342
545
|
for (const auto &header : reply.headers) {
|
|
343
546
|
if (validHttpHeader(header))
|
|
344
547
|
httpd_resp_set_hdr(r, header.name.c_str(), header.value.c_str());
|
|
345
548
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
549
|
+
const std::string disposition =
|
|
550
|
+
reply.download.empty()
|
|
551
|
+
? std::string()
|
|
552
|
+
: "attachment; filename=\"" + reply.download + "\"";
|
|
553
|
+
if (!disposition.empty())
|
|
349
554
|
httpd_resp_set_hdr(r, "Content-Disposition", disposition.c_str());
|
|
350
|
-
}
|
|
351
555
|
httpd_resp_send(r, reply.body.data(), reply.body.size());
|
|
352
556
|
return ESP_OK;
|
|
353
557
|
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// UNUserNotificationCenter backend for `LocalNotifications` (LocalNotificationsDriver
|
|
3
|
+
// in host/local_notifications.h) on iOS and macOS.
|
|
4
|
+
//
|
|
5
|
+
// Nothing here blocks the frame thread. permission() answers from a cached
|
|
6
|
+
// authorization status that UNUserNotificationCenter refreshes asynchronously
|
|
7
|
+
// (at most once a second while the app keeps asking, so a change made in
|
|
8
|
+
// Settings shows up on its own); requestPermission(), post() and cancelAll()
|
|
9
|
+
// hand their work to the center and return at once.
|
|
10
|
+
//
|
|
11
|
+
// The center needs a bundled app with a bundle identifier — touching it from a
|
|
12
|
+
// bare executable throws — so without one the driver reports "unsupported".
|
|
13
|
+
// The delegate presents banners while the app is in the foreground: a
|
|
14
|
+
// notification the app posts on itself then also lands in Notification Center,
|
|
15
|
+
// which is what ANCS forwards to a paired accessory.
|
|
16
|
+
#if defined(__APPLE__)
|
|
17
|
+
|
|
18
|
+
#import <Foundation/Foundation.h>
|
|
19
|
+
#import <UserNotifications/UserNotifications.h>
|
|
20
|
+
|
|
21
|
+
#include <atomic>
|
|
22
|
+
#include <string>
|
|
23
|
+
|
|
24
|
+
#include "host/local_notifications.h"
|
|
25
|
+
|
|
26
|
+
__asm__(".linker_option \"-framework\", \"UserNotifications\"");
|
|
27
|
+
|
|
28
|
+
@interface GeaLocalNotificationsDelegate : NSObject <UNUserNotificationCenterDelegate>
|
|
29
|
+
@end
|
|
30
|
+
|
|
31
|
+
@implementation GeaLocalNotificationsDelegate
|
|
32
|
+
|
|
33
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
34
|
+
willPresentNotification:(UNNotification *)notification
|
|
35
|
+
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
|
|
36
|
+
(void)center;
|
|
37
|
+
(void)notification;
|
|
38
|
+
UNNotificationPresentationOptions options = UNNotificationPresentationOptionSound | UNNotificationPresentationOptionBadge;
|
|
39
|
+
if (@available(iOS 14.0, macOS 11.0, tvOS 14.0, *)) {
|
|
40
|
+
options |= UNNotificationPresentationOptionBanner | UNNotificationPresentationOptionList;
|
|
41
|
+
} else {
|
|
42
|
+
#pragma clang diagnostic push
|
|
43
|
+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
44
|
+
options |= UNNotificationPresentationOptionAlert;
|
|
45
|
+
#pragma clang diagnostic pop
|
|
46
|
+
}
|
|
47
|
+
completionHandler(options);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
51
|
+
didReceiveNotificationResponse:(UNNotificationResponse *)response
|
|
52
|
+
withCompletionHandler:(void (^)(void))completionHandler {
|
|
53
|
+
(void)center;
|
|
54
|
+
(void)response;
|
|
55
|
+
completionHandler();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@end
|
|
59
|
+
|
|
60
|
+
namespace gea::host {
|
|
61
|
+
namespace {
|
|
62
|
+
|
|
63
|
+
enum Status : int { kUnknown = 0, kUndetermined, kGranted, kDenied, kUnsupported };
|
|
64
|
+
|
|
65
|
+
class AppleLocalNotificationsDriver final : public LocalNotificationsDriver {
|
|
66
|
+
public:
|
|
67
|
+
std::string permission() override {
|
|
68
|
+
UNUserNotificationCenter *center = this->center();
|
|
69
|
+
if (!center) return "unsupported";
|
|
70
|
+
refresh(center, false);
|
|
71
|
+
switch (status_.load()) {
|
|
72
|
+
case kGranted: return "granted";
|
|
73
|
+
case kDenied: return "denied";
|
|
74
|
+
case kUnsupported: return "unsupported";
|
|
75
|
+
default: return "undetermined";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
void requestPermission() override {
|
|
80
|
+
UNUserNotificationCenter *center = this->center();
|
|
81
|
+
if (!center) return;
|
|
82
|
+
UNAuthorizationOptions options = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
|
|
83
|
+
[center requestAuthorizationWithOptions:options
|
|
84
|
+
completionHandler:^(BOOL granted, NSError *error) {
|
|
85
|
+
(void)error;
|
|
86
|
+
// The answer is final for this prompt; record it now and
|
|
87
|
+
// let the settings read confirm (provisional, ephemeral).
|
|
88
|
+
status_.store(granted ? kGranted : kDenied);
|
|
89
|
+
refresh(center, true);
|
|
90
|
+
}];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
double post(const std::string &title, const std::string &body, double delaySeconds) override {
|
|
94
|
+
UNUserNotificationCenter *center = this->center();
|
|
95
|
+
if (!center || (title.empty() && body.empty())) return 0;
|
|
96
|
+
refresh(center, false);
|
|
97
|
+
const int status = status_.load();
|
|
98
|
+
if (status == kDenied || status == kUnsupported) return 0;
|
|
99
|
+
|
|
100
|
+
const double id = static_cast<double>(++lastId_);
|
|
101
|
+
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
|
|
102
|
+
content.title = string(title);
|
|
103
|
+
content.body = string(body);
|
|
104
|
+
content.sound = UNNotificationSound.defaultSound;
|
|
105
|
+
// nil trigger = deliver now; a time-interval trigger must be positive.
|
|
106
|
+
UNNotificationTrigger *trigger =
|
|
107
|
+
delaySeconds > 0 ? [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:delaySeconds repeats:NO] : nil;
|
|
108
|
+
NSString *identifier = [NSString stringWithFormat:@"gea.local.%@.%.0f", launchTag(), id];
|
|
109
|
+
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier
|
|
110
|
+
content:content
|
|
111
|
+
trigger:trigger];
|
|
112
|
+
[center addNotificationRequest:request
|
|
113
|
+
withCompletionHandler:^(NSError *error) {
|
|
114
|
+
if (error) NSLog(@"[gea] LocalNotifications.post failed: %@", error.localizedDescription);
|
|
115
|
+
}];
|
|
116
|
+
return id;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
void cancelAll() override {
|
|
120
|
+
UNUserNotificationCenter *center = this->center();
|
|
121
|
+
if (!center) return;
|
|
122
|
+
[center removeAllPendingNotificationRequests];
|
|
123
|
+
[center removeAllDeliveredNotifications];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Called once from the main queue at launch: claim the delegate before any
|
|
127
|
+
// notification arrives and read the authorization status ahead of the first
|
|
128
|
+
// frame that asks for it.
|
|
129
|
+
void prepare() {
|
|
130
|
+
if (UNUserNotificationCenter *center = this->center()) refresh(center, true);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private:
|
|
134
|
+
static NSString *string(const std::string &text) {
|
|
135
|
+
return [[NSString alloc] initWithBytes:text.data() length:text.size() encoding:NSUTF8StringEncoding] ?: @"";
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Unique per launch, so ids restarting at 1 never replace a notification an
|
|
139
|
+
// earlier run left pending.
|
|
140
|
+
static NSString *launchTag() {
|
|
141
|
+
static NSString *tag =
|
|
142
|
+
[NSString stringWithFormat:@"%llx", static_cast<unsigned long long>(NSDate.date.timeIntervalSince1970 * 1000)];
|
|
143
|
+
return tag;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
UNUserNotificationCenter *center() {
|
|
147
|
+
if (status_.load() == kUnsupported) return nil;
|
|
148
|
+
if (center_) return center_;
|
|
149
|
+
if (!NSBundle.mainBundle.bundleIdentifier) {
|
|
150
|
+
status_.store(kUnsupported);
|
|
151
|
+
return nil;
|
|
152
|
+
}
|
|
153
|
+
center_ = UNUserNotificationCenter.currentNotificationCenter;
|
|
154
|
+
delegate_ = [[GeaLocalNotificationsDelegate alloc] init];
|
|
155
|
+
center_.delegate = delegate_;
|
|
156
|
+
return center_;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
void refresh(UNUserNotificationCenter *center, bool force) {
|
|
160
|
+
const double now = NSDate.timeIntervalSinceReferenceDate;
|
|
161
|
+
if (!force && (refreshing_.load() || now - lastRefresh_.load() < 1.0)) return;
|
|
162
|
+
refreshing_.store(true);
|
|
163
|
+
lastRefresh_.store(now);
|
|
164
|
+
[center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings *settings) {
|
|
165
|
+
switch (settings.authorizationStatus) {
|
|
166
|
+
case UNAuthorizationStatusNotDetermined: status_.store(kUndetermined); break;
|
|
167
|
+
case UNAuthorizationStatusDenied: status_.store(kDenied); break;
|
|
168
|
+
default: status_.store(kGranted); break; // authorized, provisional, ephemeral
|
|
169
|
+
}
|
|
170
|
+
refreshing_.store(false);
|
|
171
|
+
}];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
UNUserNotificationCenter *center_ = nil;
|
|
175
|
+
GeaLocalNotificationsDelegate *delegate_ = nil;
|
|
176
|
+
std::atomic<int> status_{kUnknown};
|
|
177
|
+
std::atomic<bool> refreshing_{false};
|
|
178
|
+
std::atomic<double> lastRefresh_{0};
|
|
179
|
+
std::atomic<long long> lastId_{0};
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
AppleLocalNotificationsDriver &appleLocalNotifications() {
|
|
183
|
+
static AppleLocalNotificationsDriver driver;
|
|
184
|
+
return driver;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
[[maybe_unused]] const bool installed = [] {
|
|
188
|
+
setLocalNotificationsDriver(&appleLocalNotifications());
|
|
189
|
+
// Runs once the app's main run loop starts, before the user can interact.
|
|
190
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
191
|
+
appleLocalNotifications().prepare();
|
|
192
|
+
});
|
|
193
|
+
return true;
|
|
194
|
+
}();
|
|
195
|
+
|
|
196
|
+
} // namespace
|
|
197
|
+
} // namespace gea::host
|
|
198
|
+
|
|
199
|
+
#endif
|
package/host/media.cpp
CHANGED
|
@@ -699,6 +699,69 @@ void TrackPcmReader::beginDrain() {
|
|
|
699
699
|
cursor->second.end = it->second.bufferStart + it->second.ringBuffer.size();
|
|
700
700
|
}
|
|
701
701
|
|
|
702
|
+
namespace {
|
|
703
|
+
std::mutex &inputDeviceMutex() {
|
|
704
|
+
static std::mutex mutex;
|
|
705
|
+
return mutex;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
std::string &inputDevice() {
|
|
709
|
+
static std::string device;
|
|
710
|
+
return device;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
int &inputChannel() {
|
|
714
|
+
static int channel = -1;
|
|
715
|
+
return channel;
|
|
716
|
+
}
|
|
717
|
+
} // namespace
|
|
718
|
+
|
|
719
|
+
#ifndef ESP_PLATFORM
|
|
720
|
+
__attribute__((weak)) std::vector<MediaDeviceInfo> platform_input_devices() { return {}; }
|
|
721
|
+
__attribute__((weak)) void platform_input_device_changed() {}
|
|
722
|
+
#else
|
|
723
|
+
std::vector<MediaDeviceInfo> platform_input_devices() { return {}; }
|
|
724
|
+
void platform_input_device_changed() {}
|
|
725
|
+
#endif
|
|
726
|
+
|
|
727
|
+
std::vector<MediaDeviceInfo> enumerate_devices() {
|
|
728
|
+
auto inputs = platform_input_devices();
|
|
729
|
+
if (inputs.empty()) return inputs;
|
|
730
|
+
std::vector<MediaDeviceInfo> out;
|
|
731
|
+
out.reserve(inputs.size() + 1);
|
|
732
|
+
// As in a browser, the system default comes first under its own id; its label names the device it is now.
|
|
733
|
+
out.push_back(MediaDeviceInfo{"default", "audioinput", inputs.front().label, inputs.front().groupId,
|
|
734
|
+
inputs.front().channelCount});
|
|
735
|
+
for (auto &input : inputs) out.push_back(std::move(input));
|
|
736
|
+
return out;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
std::string requested_input_device() {
|
|
740
|
+
std::lock_guard<std::mutex> lock(inputDeviceMutex());
|
|
741
|
+
return inputDevice();
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
int requested_input_channel() {
|
|
745
|
+
std::lock_guard<std::mutex> lock(inputDeviceMutex());
|
|
746
|
+
return inputChannel();
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
NativeMediaStreamHandle get_user_media_audio(const std::string &deviceId) { return get_user_media_audio(deviceId, -1); }
|
|
750
|
+
|
|
751
|
+
NativeMediaStreamHandle get_user_media_audio(const std::string &deviceId, int channel) {
|
|
752
|
+
const std::string next = deviceId == "default" ? std::string() : deviceId;
|
|
753
|
+
const int nextChannel = channel < 0 ? -1 : channel;
|
|
754
|
+
bool changed = false;
|
|
755
|
+
{
|
|
756
|
+
std::lock_guard<std::mutex> lock(inputDeviceMutex());
|
|
757
|
+
changed = inputDevice() != next || inputChannel() != nextChannel;
|
|
758
|
+
inputDevice() = next;
|
|
759
|
+
inputChannel() = nextChannel;
|
|
760
|
+
}
|
|
761
|
+
if (changed) platform_input_device_changed();
|
|
762
|
+
return get_user_media_audio();
|
|
763
|
+
}
|
|
764
|
+
|
|
702
765
|
NativeMediaStreamHandle get_user_media_audio() {
|
|
703
766
|
const auto handle = create_stream();
|
|
704
767
|
const auto owner = workers::Context::current();
|
package/host/menu_bar_apple.mm
CHANGED
|
@@ -30,6 +30,7 @@ static double gCustomMenu = -1;
|
|
|
30
30
|
@property(nonatomic, weak) NSWindow *window;
|
|
31
31
|
@property(nonatomic, strong) NSTimer *timer;
|
|
32
32
|
@property(nonatomic, strong) NSMenu *menu;
|
|
33
|
+
@property(nonatomic, strong) id keyMonitor;
|
|
33
34
|
@end
|
|
34
35
|
|
|
35
36
|
@implementation GeaMenuBar
|
|
@@ -83,6 +84,20 @@ static double gCustomMenu = -1;
|
|
|
83
84
|
quit.target = NSApp;
|
|
84
85
|
[self.menu addItem:quit];
|
|
85
86
|
|
|
87
|
+
// A menu bar app has no menu of its own in the main menu bar, so AppKit never
|
|
88
|
+
// matches its menu's shortcuts (Cmd+D in `shortcut: "Cmd+D"`) while that menu
|
|
89
|
+
// is closed. While the app is active, a key press with Command, Control or
|
|
90
|
+
// Option goes to that menu first, as it would to a regular app's main menu.
|
|
91
|
+
__weak GeaMenuBar *weakSelf = self;
|
|
92
|
+
self.keyMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyDown
|
|
93
|
+
handler:^NSEvent *(NSEvent *event) {
|
|
94
|
+
const NSEventModifierFlags flags = event.modifierFlags & NSEventModifierFlagDeviceIndependentFlagsMask;
|
|
95
|
+
if (!(flags & (NSEventModifierFlagCommand | NSEventModifierFlagControl | NSEventModifierFlagOption))) return event;
|
|
96
|
+
NSMenu *menu = [weakSelf secondaryMenu];
|
|
97
|
+
if (menu && [menu performKeyEquivalent:event]) return nil;
|
|
98
|
+
return event;
|
|
99
|
+
}];
|
|
100
|
+
|
|
86
101
|
[NSNotificationCenter.defaultCenter addObserver:self
|
|
87
102
|
selector:@selector(resigned:)
|
|
88
103
|
name:NSApplicationDidResignActiveNotification
|
|
@@ -41,6 +41,9 @@
|
|
|
41
41
|
#include "host/menu.h"
|
|
42
42
|
#include "host/menu_bar.h"
|
|
43
43
|
#include "host/notify.h"
|
|
44
|
+
#include "host/phone_link.h"
|
|
45
|
+
#include "host/local_notifications.h"
|
|
46
|
+
#include "host/notification_relay.h"
|
|
44
47
|
#include "host/device_control.h"
|
|
45
48
|
#include <input.h>
|
|
46
49
|
#include "host/audio.h"
|
package/include/host/backends.h
CHANGED
|
@@ -389,6 +389,11 @@ public:
|
|
|
389
389
|
static double brightness();
|
|
390
390
|
static void setBrightness(double brightness);
|
|
391
391
|
static void setAA(double samples);
|
|
392
|
+
// Panel power. Weak-hooked (gea_display_set_powered / gea_display_powered):
|
|
393
|
+
// a no-op that always reports awake on boards without panel power control.
|
|
394
|
+
static void sleep();
|
|
395
|
+
static void wake();
|
|
396
|
+
static bool awake();
|
|
392
397
|
static void setFlushConfig(double rows, double depth);
|
|
393
398
|
// E-paper refresh policy + custom waveforms (weak-hooked: no-op on boards
|
|
394
399
|
// without an e-paper panel). Negative numbers = leave unchanged. LUTs must
|
package/include/host/display.h
CHANGED
|
@@ -148,6 +148,9 @@ struct DisplayFacade {
|
|
|
148
148
|
|
|
149
149
|
double getBrightness() const { return gea::framework::display::DisplayBackend::brightness(); }
|
|
150
150
|
void setBrightness(double brightness) const { gea::framework::display::DisplayBackend::setBrightness(brightness); }
|
|
151
|
+
void sleep() const { gea::framework::display::DisplayBackend::sleep(); }
|
|
152
|
+
void wake() const { gea::framework::display::DisplayBackend::wake(); }
|
|
153
|
+
bool awake() const { return gea::framework::display::DisplayBackend::awake(); }
|
|
151
154
|
std::string orientation() const { return gea::framework::display::DisplayBackend::orientation(); }
|
|
152
155
|
std::string getOrientation() const { return orientation(); }
|
|
153
156
|
void setOrientation(const std::string &orientation) const { gea::framework::display::DisplayBackend::setOrientation(orientation); }
|
package/include/host/http.h
CHANGED
|
@@ -77,7 +77,9 @@ struct HttpRequest {
|
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
// What a handler returns. Either an inline `body`, or a `file` path to stream
|
|
80
|
-
// from disk
|
|
80
|
+
// from disk (or "asset://<bundle>/<path>" for a compiled-in bundle, see
|
|
81
|
+
// HttpEmbeddedBundle below). `download` (when set) turns the response into an
|
|
82
|
+
// attachment. `headers` apply to body, file and embedded replies alike.
|
|
81
83
|
struct HttpReply {
|
|
82
84
|
int status = 200;
|
|
83
85
|
std::string contentType = "text/plain";
|
|
@@ -87,8 +89,88 @@ struct HttpReply {
|
|
|
87
89
|
std::vector<HttpHeader> headers;
|
|
88
90
|
};
|
|
89
91
|
|
|
92
|
+
// One file of a compiled-in static bundle (a web dashboard served by the
|
|
93
|
+
// device). The bytes live in flash `.rodata` and are sent straight from there
|
|
94
|
+
// on the server worker task: nothing is copied into JS, the frame task or the
|
|
95
|
+
// heap. Tables of these are emitted by a build step (see
|
|
96
|
+
// examples/apps/relay/web/scripts/emit-device-assets.mjs).
|
|
97
|
+
struct HttpEmbeddedAsset {
|
|
98
|
+
const char *path; // request path, e.g. "/index.html", "/assets/app-1a2b.js"
|
|
99
|
+
const unsigned char *data;
|
|
100
|
+
std::size_t size;
|
|
101
|
+
const char *contentType; // e.g. "text/javascript; charset=utf-8"
|
|
102
|
+
const char *etag; // strong validator INCLUDING quotes, or nullptr
|
|
103
|
+
bool gzip; // bytes are gzip: send `Content-Encoding: gzip`
|
|
104
|
+
bool immutable; // content-hashed name: cache for a year
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
struct HttpEmbeddedBundle {
|
|
108
|
+
const char *name; // addressed as "asset://<name>/<path>" in HttpReply.file
|
|
109
|
+
const HttpEmbeddedAsset *assets;
|
|
110
|
+
std::size_t count;
|
|
111
|
+
// Served (200) for a path that is not in the bundle and does not look like a
|
|
112
|
+
// file (its last segment has no '.'), so client-side routes reload; nullptr
|
|
113
|
+
// makes every miss a 404.
|
|
114
|
+
const char *fallback;
|
|
115
|
+
};
|
|
116
|
+
|
|
90
117
|
namespace http {
|
|
91
118
|
|
|
119
|
+
// `HttpReply.file` values starting with this scheme are served from a
|
|
120
|
+
// registered HttpEmbeddedBundle instead of the filesystem:
|
|
121
|
+
// { file: "asset://relay-dashboard" + req.path }
|
|
122
|
+
// The bundle decides Content-Type, Content-Encoding, Cache-Control and ETag,
|
|
123
|
+
// and answers a matching If-None-Match with 304.
|
|
124
|
+
inline constexpr std::string_view kEmbeddedAssetScheme = "asset://";
|
|
125
|
+
|
|
126
|
+
inline bool is_embedded_asset_file(std::string_view file) {
|
|
127
|
+
return file.substr(0, kEmbeddedAssetScheme.size()) == kEmbeddedAssetScheme;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Registers a bundle under its name (a later registration of the same name
|
|
131
|
+
// replaces the earlier one). Returns true so a generated table can register
|
|
132
|
+
// itself from a namespace-scope initializer.
|
|
133
|
+
bool register_embedded_bundle(const HttpEmbeddedBundle *bundle);
|
|
134
|
+
const HttpEmbeddedBundle *find_embedded_bundle(std::string_view name);
|
|
135
|
+
|
|
136
|
+
// The transport-independent answer for an embedded-asset reply.
|
|
137
|
+
struct EmbeddedAssetResponse {
|
|
138
|
+
int status = 404; // 200, 304 or 404
|
|
139
|
+
const HttpEmbeddedAsset *asset = nullptr; // set for 200 and 304
|
|
140
|
+
std::vector<HttpHeader> headers; // Content-Encoding, Cache-Control, ETag, Vary
|
|
141
|
+
std::string contentType = "text/plain";
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// Resolves "asset://<bundle>/<path>" against the registered bundles. `path`
|
|
145
|
+
// "" or "/" maps to "/index.html". `ifNoneMatch` is the request header value
|
|
146
|
+
// ("" when absent).
|
|
147
|
+
EmbeddedAssetResponse resolve_embedded_asset(std::string_view file,
|
|
148
|
+
std::string_view ifNoneMatch);
|
|
149
|
+
|
|
150
|
+
// Case-insensitive request header lookup ("" when absent).
|
|
151
|
+
inline std::string_view find_header(const std::vector<HttpHeader> &headers,
|
|
152
|
+
std::string_view name) {
|
|
153
|
+
for (const auto &header : headers) {
|
|
154
|
+
if (header.name.size() != name.size())
|
|
155
|
+
continue;
|
|
156
|
+
bool same = true;
|
|
157
|
+
for (std::size_t i = 0; i < name.size() && same; ++i) {
|
|
158
|
+
char a = header.name[i], b = name[i];
|
|
159
|
+
if (a >= 'A' && a <= 'Z')
|
|
160
|
+
a = static_cast<char>(a - 'A' + 'a');
|
|
161
|
+
if (b >= 'A' && b <= 'Z')
|
|
162
|
+
b = static_cast<char>(b - 'A' + 'a');
|
|
163
|
+
same = a == b;
|
|
164
|
+
}
|
|
165
|
+
if (same)
|
|
166
|
+
return header.value;
|
|
167
|
+
}
|
|
168
|
+
return {};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Reason phrase for a status code ("OK", "Not Found", ...; "" if unknown).
|
|
172
|
+
const char *status_reason(int status);
|
|
173
|
+
|
|
92
174
|
// Handler signature on the native side. Runs on the frame task. Pure value
|
|
93
175
|
// types in the signature (no gea_cpp_value), so this file's non-generated TUs
|
|
94
176
|
// can store and call it without the dynamic-value runtime.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
// Notifications posted by the app itself (`LocalNotifications` in
|
|
5
|
+
// @geastack/core): UNUserNotificationCenter on iOS/macOS, NotificationManager
|
|
6
|
+
// on Android. The base driver IS the unsupported one; a platform installs its
|
|
7
|
+
// own with setLocalNotificationsDriver(). Header-only so every target links.
|
|
8
|
+
|
|
9
|
+
#include <string>
|
|
10
|
+
|
|
11
|
+
namespace gea::host {
|
|
12
|
+
|
|
13
|
+
class LocalNotificationsDriver {
|
|
14
|
+
public:
|
|
15
|
+
virtual ~LocalNotificationsDriver() = default;
|
|
16
|
+
// "granted", "denied", "undetermined" or "unsupported".
|
|
17
|
+
virtual std::string permission() { return "unsupported"; }
|
|
18
|
+
virtual void requestPermission() {}
|
|
19
|
+
// Returns the notification id, or 0 when it could not be scheduled.
|
|
20
|
+
virtual double post(const std::string &title, const std::string &body, double delaySeconds) {
|
|
21
|
+
(void)title;
|
|
22
|
+
(void)body;
|
|
23
|
+
(void)delaySeconds;
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
virtual void cancelAll() {}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
namespace local_notifications::detail {
|
|
30
|
+
inline LocalNotificationsDriver *&driverSlot() {
|
|
31
|
+
static LocalNotificationsDriver unsupported;
|
|
32
|
+
static LocalNotificationsDriver *driver = &unsupported;
|
|
33
|
+
return driver;
|
|
34
|
+
}
|
|
35
|
+
} // namespace local_notifications::detail
|
|
36
|
+
|
|
37
|
+
inline void setLocalNotificationsDriver(LocalNotificationsDriver *driver) {
|
|
38
|
+
if (driver) local_notifications::detail::driverSlot() = driver;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
inline LocalNotificationsDriver &localNotificationsDriver() {
|
|
42
|
+
return *local_notifications::detail::driverSlot();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
struct LocalNotificationsFacade {
|
|
46
|
+
std::string permission() const { return localNotificationsDriver().permission(); }
|
|
47
|
+
void requestPermission() const { localNotificationsDriver().requestPermission(); }
|
|
48
|
+
double post(const std::string &title, const std::string &body, double delaySeconds = 0) const {
|
|
49
|
+
return localNotificationsDriver().post(title, body, delaySeconds);
|
|
50
|
+
}
|
|
51
|
+
void cancelAll() const { localNotificationsDriver().cancelAll(); }
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
inline constexpr LocalNotificationsFacade LocalNotifications{};
|
|
55
|
+
|
|
56
|
+
} // namespace gea::host
|
package/include/host/media.h
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
#include <functional>
|
|
7
7
|
#include <memory>
|
|
8
8
|
#include <string>
|
|
9
|
+
#include <type_traits>
|
|
9
10
|
#include <vector>
|
|
10
11
|
#include "host/video_pixels.h"
|
|
11
12
|
|
|
@@ -79,6 +80,19 @@ struct MediaRecorderDataEvent {
|
|
|
79
80
|
GeaAudioBlob data;
|
|
80
81
|
};
|
|
81
82
|
|
|
83
|
+
// One row of `navigator.mediaDevices.enumerateDevices()`.
|
|
84
|
+
struct MediaDeviceInfo {
|
|
85
|
+
std::string deviceId;
|
|
86
|
+
std::string kind;
|
|
87
|
+
std::string label;
|
|
88
|
+
std::string groupId;
|
|
89
|
+
// Input channels the device has (0 when the platform cannot tell); a Gea extension over the browser's list.
|
|
90
|
+
double channelCount = 0;
|
|
91
|
+
|
|
92
|
+
template <typename Value>
|
|
93
|
+
static MediaDeviceInfo __gea_native_from_value(const Value &) { return {}; }
|
|
94
|
+
};
|
|
95
|
+
|
|
82
96
|
namespace media {
|
|
83
97
|
template <typename Options>
|
|
84
98
|
std::string recorder_path_from_options(const Options &options);
|
|
@@ -195,6 +209,10 @@ class TrackPcmReader {
|
|
|
195
209
|
};
|
|
196
210
|
|
|
197
211
|
NativeMediaStreamHandle get_user_media_audio();
|
|
212
|
+
// Captures from `deviceId` (an `audioinput` id from enumerate_devices; "" or "default" is the system default).
|
|
213
|
+
NativeMediaStreamHandle get_user_media_audio(const std::string &deviceId);
|
|
214
|
+
// As above, recording only input `channel` (0-based) of that device; a negative channel mixes them all.
|
|
215
|
+
NativeMediaStreamHandle get_user_media_audio(const std::string &deviceId, int channel);
|
|
198
216
|
NativeMediaRecorderHandle create_recorder(NativeMediaStreamHandle stream, const std::string &path, const std::string &mimeType);
|
|
199
217
|
std::string recorder_state(NativeMediaRecorderHandle handle);
|
|
200
218
|
std::string recorder_mime_type(NativeMediaRecorderHandle handle);
|
|
@@ -237,13 +255,104 @@ std::string recorder_mime_from_options(const Options &options) {
|
|
|
237
255
|
options, [](const auto &record) -> decltype(record.mimeType) { return record.mimeType; }, "audio/wav");
|
|
238
256
|
}
|
|
239
257
|
|
|
240
|
-
//
|
|
241
|
-
//
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
258
|
+
// The capture devices this platform has: the system default input first, as deviceId "default", then every
|
|
259
|
+
// audio input. The platform supplies the inputs (platform_input_devices); a target without one returns nothing.
|
|
260
|
+
std::vector<MediaDeviceInfo> enumerate_devices();
|
|
261
|
+
std::vector<MediaDeviceInfo> platform_input_devices();
|
|
262
|
+
|
|
263
|
+
// The input the newest capture asked for ("" is the system default). The platform capture reads it when it
|
|
264
|
+
// starts, and a request for a different device restarts a running capture on that device.
|
|
265
|
+
std::string requested_input_device();
|
|
266
|
+
// The input channel (0-based) the newest capture asked for; negative mixes every channel.
|
|
267
|
+
int requested_input_channel();
|
|
268
|
+
void platform_input_device_changed();
|
|
269
|
+
|
|
270
|
+
// `deviceId` out of a MediaStreamConstraints-shaped value from
|
|
271
|
+
// `navigator.mediaDevices.getUserMedia({...})`, whatever layers geatsc wraps it in: an optional, a record
|
|
272
|
+
// reference, the `boolean | { deviceId, ... }` union of `audio`, and ConstrainDeviceId's
|
|
273
|
+
// `string | { exact, ideal }`. Anything without one is "".
|
|
274
|
+
template <typename Value>
|
|
275
|
+
std::string constraint_device_id(const Value &value);
|
|
276
|
+
|
|
277
|
+
// A tagged union's `is<I>()` names no arm past its last one, so the walk stops at `arity`.
|
|
278
|
+
template <std::size_t Arm, typename Union>
|
|
279
|
+
std::string constraint_device_id_arm(const Union &value) {
|
|
280
|
+
if constexpr (Arm >= Union::arity) {
|
|
281
|
+
return {};
|
|
282
|
+
} else {
|
|
283
|
+
if (value.template is<Arm>()) return constraint_device_id(value.template get<Arm>());
|
|
284
|
+
return constraint_device_id_arm<Arm + 1>(value);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
template <typename Value>
|
|
289
|
+
std::string constraint_device_id(const Value &value) {
|
|
290
|
+
if constexpr (std::is_same_v<std::decay_t<Value>, bool> || std::is_arithmetic_v<std::decay_t<Value>>) {
|
|
291
|
+
return {};
|
|
292
|
+
} else if constexpr (std::is_constructible_v<std::string, const Value &>) {
|
|
293
|
+
return std::string(value);
|
|
294
|
+
} else if constexpr (requires { value.has_value(); *value; }) {
|
|
295
|
+
return value.has_value() ? constraint_device_id(*value) : std::string();
|
|
296
|
+
} else if constexpr (requires { value.get(); *value; }) {
|
|
297
|
+
return value.get() ? constraint_device_id(*value) : std::string();
|
|
298
|
+
} else if constexpr (requires { std::decay_t<Value>::arity; value.template is<0>(); }) {
|
|
299
|
+
return constraint_device_id_arm<0>(value);
|
|
300
|
+
} else if constexpr (requires { value.audio; }) {
|
|
301
|
+
return constraint_device_id(value.audio);
|
|
302
|
+
} else if constexpr (requires { value.deviceId; }) {
|
|
303
|
+
return constraint_device_id(value.deviceId);
|
|
304
|
+
} else if constexpr (requires { value.exact; value.ideal; }) {
|
|
305
|
+
const auto exact = constraint_device_id(value.exact);
|
|
306
|
+
return exact.empty() ? constraint_device_id(value.ideal) : exact;
|
|
307
|
+
} else if constexpr (requires { value.exact; }) {
|
|
308
|
+
return constraint_device_id(value.exact);
|
|
309
|
+
} else if constexpr (requires { value.ideal; }) {
|
|
310
|
+
return constraint_device_id(value.ideal);
|
|
311
|
+
} else {
|
|
312
|
+
return {};
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// The `channel` (a Gea extension: the 0-based input channel to record) out of the same constraints; -1 when
|
|
317
|
+
// absent, which mixes every channel.
|
|
318
|
+
template <typename Value>
|
|
319
|
+
int constraint_channel(const Value &value);
|
|
320
|
+
|
|
321
|
+
template <std::size_t Arm, typename Union>
|
|
322
|
+
int constraint_channel_arm(const Union &value) {
|
|
323
|
+
if constexpr (Arm >= Union::arity) {
|
|
324
|
+
return -1;
|
|
325
|
+
} else {
|
|
326
|
+
if (value.template is<Arm>()) return constraint_channel(value.template get<Arm>());
|
|
327
|
+
return constraint_channel_arm<Arm + 1>(value);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
template <typename Value>
|
|
332
|
+
int constraint_channel(const Value &value) {
|
|
333
|
+
if constexpr (std::is_same_v<std::decay_t<Value>, bool>) {
|
|
334
|
+
return -1;
|
|
335
|
+
} else if constexpr (std::is_arithmetic_v<std::decay_t<Value>>) {
|
|
336
|
+
return value >= 0 ? static_cast<int>(value) : -1;
|
|
337
|
+
} else if constexpr (requires { value.has_value(); *value; }) {
|
|
338
|
+
return value.has_value() ? constraint_channel(*value) : -1;
|
|
339
|
+
} else if constexpr (requires { value.get(); *value; }) {
|
|
340
|
+
return value.get() ? constraint_channel(*value) : -1;
|
|
341
|
+
} else if constexpr (requires { std::decay_t<Value>::arity; value.template is<0>(); }) {
|
|
342
|
+
return constraint_channel_arm<0>(value);
|
|
343
|
+
} else if constexpr (requires { value.audio; }) {
|
|
344
|
+
return constraint_channel(value.audio);
|
|
345
|
+
} else if constexpr (requires { value.channel; }) {
|
|
346
|
+
return constraint_channel(value.channel);
|
|
347
|
+
} else {
|
|
348
|
+
return -1;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
245
352
|
template <typename Constraints>
|
|
246
|
-
NativeMediaStreamHandle get_user_media_audio(const Constraints &) {
|
|
353
|
+
NativeMediaStreamHandle get_user_media_audio(const Constraints &constraints) {
|
|
354
|
+
return get_user_media_audio(constraint_device_id(constraints), constraint_channel(constraints));
|
|
355
|
+
}
|
|
247
356
|
|
|
248
357
|
} // namespace media
|
|
249
358
|
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
// Phone side of Android notification forwarding (`NotificationRelay` in
|
|
5
|
+
// @geastack/core). The forwarding itself runs in a native Android foreground
|
|
6
|
+
// service (NotificationListenerService + CompanionDeviceManager + a BLE GATT
|
|
7
|
+
// client) so it keeps working while the app is closed; this facade configures
|
|
8
|
+
// that service and reports its state. The base driver IS the unsupported one;
|
|
9
|
+
// the Android target installs its own with setNotificationRelayDriver().
|
|
10
|
+
|
|
11
|
+
#include <string>
|
|
12
|
+
|
|
13
|
+
namespace gea::host {
|
|
14
|
+
|
|
15
|
+
class NotificationRelayDriver {
|
|
16
|
+
public:
|
|
17
|
+
virtual ~NotificationRelayDriver() = default;
|
|
18
|
+
virtual bool supported() { return false; }
|
|
19
|
+
virtual bool listenerEnabled() { return false; }
|
|
20
|
+
virtual void openListenerSettings() {}
|
|
21
|
+
virtual void pair() {}
|
|
22
|
+
virtual bool paired() { return false; }
|
|
23
|
+
virtual std::string deviceName() { return ""; }
|
|
24
|
+
virtual void forget() {}
|
|
25
|
+
// "off", "connecting" or "connected".
|
|
26
|
+
virtual std::string link() { return "off"; }
|
|
27
|
+
virtual bool enabled() { return false; }
|
|
28
|
+
virtual void setEnabled(bool enabled) { (void)enabled; }
|
|
29
|
+
virtual std::string mutedApps() { return ""; }
|
|
30
|
+
virtual void setMutedApps(const std::string &packagesCsv) { (void)packagesCsv; }
|
|
31
|
+
virtual double forwardedCount() { return 0; }
|
|
32
|
+
virtual std::string lastForwarded() { return ""; }
|
|
33
|
+
virtual double appCount() { return 0; }
|
|
34
|
+
virtual std::string appIdAt(int index) {
|
|
35
|
+
(void)index;
|
|
36
|
+
return "";
|
|
37
|
+
}
|
|
38
|
+
virtual std::string appNameAt(int index) {
|
|
39
|
+
(void)index;
|
|
40
|
+
return "";
|
|
41
|
+
}
|
|
42
|
+
virtual void sendTest() {}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
namespace notification_relay::detail {
|
|
46
|
+
inline NotificationRelayDriver *&driverSlot() {
|
|
47
|
+
static NotificationRelayDriver unsupported;
|
|
48
|
+
static NotificationRelayDriver *driver = &unsupported;
|
|
49
|
+
return driver;
|
|
50
|
+
}
|
|
51
|
+
} // namespace notification_relay::detail
|
|
52
|
+
|
|
53
|
+
inline void setNotificationRelayDriver(NotificationRelayDriver *driver) {
|
|
54
|
+
if (driver) notification_relay::detail::driverSlot() = driver;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
inline NotificationRelayDriver ¬ificationRelayDriver() {
|
|
58
|
+
return *notification_relay::detail::driverSlot();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
struct NotificationRelayFacade {
|
|
62
|
+
bool supported() const { return notificationRelayDriver().supported(); }
|
|
63
|
+
bool listenerEnabled() const { return notificationRelayDriver().listenerEnabled(); }
|
|
64
|
+
void openListenerSettings() const { notificationRelayDriver().openListenerSettings(); }
|
|
65
|
+
void pair() const { notificationRelayDriver().pair(); }
|
|
66
|
+
bool paired() const { return notificationRelayDriver().paired(); }
|
|
67
|
+
std::string deviceName() const { return notificationRelayDriver().deviceName(); }
|
|
68
|
+
void forget() const { notificationRelayDriver().forget(); }
|
|
69
|
+
std::string link() const { return notificationRelayDriver().link(); }
|
|
70
|
+
bool enabled() const { return notificationRelayDriver().enabled(); }
|
|
71
|
+
void setEnabled(bool enabled) const { notificationRelayDriver().setEnabled(enabled); }
|
|
72
|
+
std::string mutedApps() const { return notificationRelayDriver().mutedApps(); }
|
|
73
|
+
void setMutedApps(const std::string &packagesCsv) const { notificationRelayDriver().setMutedApps(packagesCsv); }
|
|
74
|
+
double forwardedCount() const { return notificationRelayDriver().forwardedCount(); }
|
|
75
|
+
std::string lastForwarded() const { return notificationRelayDriver().lastForwarded(); }
|
|
76
|
+
double appCount() const { return notificationRelayDriver().appCount(); }
|
|
77
|
+
std::string appIdAt(double index) const { return notificationRelayDriver().appIdAt(static_cast<int>(index)); }
|
|
78
|
+
std::string appNameAt(double index) const { return notificationRelayDriver().appNameAt(static_cast<int>(index)); }
|
|
79
|
+
void sendTest() const { notificationRelayDriver().sendTest(); }
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
inline constexpr NotificationRelayFacade NotificationRelay{};
|
|
83
|
+
|
|
84
|
+
} // namespace gea::host
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
// Phone notification sync, device side (`PhoneLink` in @geastack/core).
|
|
5
|
+
//
|
|
6
|
+
// Two layers:
|
|
7
|
+
// - PhoneLinkDriver: the platform's BLE work (ANCS client for iPhone, the
|
|
8
|
+
// Relay GATT service for the Android companion). The base class IS the
|
|
9
|
+
// unsupported driver; a platform installs its own with setPhoneLinkDriver().
|
|
10
|
+
// - The event queue below, shared by every platform. A driver posts events
|
|
11
|
+
// from its BLE task with phone_link::post(); the app drains them on the
|
|
12
|
+
// frame task through PhoneLink.next() and reads the current slot.
|
|
13
|
+
//
|
|
14
|
+
// Header-only so no target's source list has to change for the surface to link.
|
|
15
|
+
|
|
16
|
+
#include <cstdint>
|
|
17
|
+
#include <deque>
|
|
18
|
+
#include <mutex>
|
|
19
|
+
#include <string>
|
|
20
|
+
|
|
21
|
+
namespace gea::host {
|
|
22
|
+
|
|
23
|
+
namespace phone_link {
|
|
24
|
+
|
|
25
|
+
enum class EventKind : std::uint8_t { Added = 0, Modified = 1, Removed = 2 };
|
|
26
|
+
|
|
27
|
+
struct Event {
|
|
28
|
+
EventKind kind = EventKind::Added;
|
|
29
|
+
std::uint32_t uid = 0;
|
|
30
|
+
std::string appId;
|
|
31
|
+
std::string appName;
|
|
32
|
+
std::string title;
|
|
33
|
+
std::string subtitle;
|
|
34
|
+
std::string message;
|
|
35
|
+
double time = 0; // epoch ms in the phone's local time, 0 = unknown
|
|
36
|
+
int category = 0; // ANCS CategoryID
|
|
37
|
+
int flags = 0; // ANCS EventFlags
|
|
38
|
+
std::string positiveLabel;
|
|
39
|
+
std::string negativeLabel;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Oldest events are dropped past this many; a phone reconnecting after a long
|
|
43
|
+
// gap replays its pre-existing notifications and must not exhaust RAM.
|
|
44
|
+
inline constexpr std::size_t kMaxQueuedEvents = 48;
|
|
45
|
+
|
|
46
|
+
namespace detail {
|
|
47
|
+
struct Queue {
|
|
48
|
+
std::mutex lock;
|
|
49
|
+
std::deque<Event> pending;
|
|
50
|
+
Event current;
|
|
51
|
+
std::uint32_t seq = 0;
|
|
52
|
+
};
|
|
53
|
+
inline Queue &queue() {
|
|
54
|
+
static Queue q;
|
|
55
|
+
return q;
|
|
56
|
+
}
|
|
57
|
+
} // namespace detail
|
|
58
|
+
|
|
59
|
+
// Thread-safe: call from the BLE host task.
|
|
60
|
+
inline void post(Event event) {
|
|
61
|
+
auto &q = detail::queue();
|
|
62
|
+
std::lock_guard<std::mutex> guard(q.lock);
|
|
63
|
+
if (q.pending.size() >= kMaxQueuedEvents) q.pending.pop_front();
|
|
64
|
+
q.pending.push_back(std::move(event));
|
|
65
|
+
q.seq++;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Drop everything queued (e.g. the phone was forgotten).
|
|
69
|
+
inline void clear() {
|
|
70
|
+
auto &q = detail::queue();
|
|
71
|
+
std::lock_guard<std::mutex> guard(q.lock);
|
|
72
|
+
q.pending.clear();
|
|
73
|
+
q.current = Event{};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
inline bool next() {
|
|
77
|
+
auto &q = detail::queue();
|
|
78
|
+
std::lock_guard<std::mutex> guard(q.lock);
|
|
79
|
+
if (q.pending.empty()) return false;
|
|
80
|
+
q.current = std::move(q.pending.front());
|
|
81
|
+
q.pending.pop_front();
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
inline double seq() {
|
|
86
|
+
auto &q = detail::queue();
|
|
87
|
+
std::lock_guard<std::mutex> guard(q.lock);
|
|
88
|
+
return static_cast<double>(q.seq);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// The current slot is only written by next(), which runs on the frame task, so
|
|
92
|
+
// the getters read it without the lock.
|
|
93
|
+
inline const Event ¤t() {
|
|
94
|
+
return detail::queue().current;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
} // namespace phone_link
|
|
98
|
+
|
|
99
|
+
class PhoneLinkDriver {
|
|
100
|
+
public:
|
|
101
|
+
virtual ~PhoneLinkDriver() = default;
|
|
102
|
+
virtual void start(const std::string &name) { (void)name; }
|
|
103
|
+
virtual void stop() {}
|
|
104
|
+
// "unsupported", "off", "advertising", "pairing", "connected" or "ready".
|
|
105
|
+
virtual std::string state() { return "unsupported"; }
|
|
106
|
+
// "ios", "android" or "".
|
|
107
|
+
virtual std::string platform() { return ""; }
|
|
108
|
+
virtual std::string peerName() { return ""; }
|
|
109
|
+
virtual std::string passkey() { return ""; }
|
|
110
|
+
virtual void forget() {}
|
|
111
|
+
virtual double phoneTime() { return 0; }
|
|
112
|
+
virtual void performAction(std::uint32_t uid, bool positive) {
|
|
113
|
+
(void)uid;
|
|
114
|
+
(void)positive;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
namespace phone_link::detail {
|
|
119
|
+
inline PhoneLinkDriver *&driverSlot() {
|
|
120
|
+
static PhoneLinkDriver unsupported;
|
|
121
|
+
static PhoneLinkDriver *driver = &unsupported;
|
|
122
|
+
return driver;
|
|
123
|
+
}
|
|
124
|
+
} // namespace phone_link::detail
|
|
125
|
+
|
|
126
|
+
inline void setPhoneLinkDriver(PhoneLinkDriver *driver) {
|
|
127
|
+
if (driver) phone_link::detail::driverSlot() = driver;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
inline PhoneLinkDriver &phoneLinkDriver() {
|
|
131
|
+
return *phone_link::detail::driverSlot();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
struct PhoneLinkFacade {
|
|
135
|
+
void start(const std::string &name) const { phoneLinkDriver().start(name); }
|
|
136
|
+
void stop() const { phoneLinkDriver().stop(); }
|
|
137
|
+
std::string state() const { return phoneLinkDriver().state(); }
|
|
138
|
+
std::string platform() const { return phoneLinkDriver().platform(); }
|
|
139
|
+
std::string peerName() const { return phoneLinkDriver().peerName(); }
|
|
140
|
+
std::string passkey() const { return phoneLinkDriver().passkey(); }
|
|
141
|
+
void forget() const {
|
|
142
|
+
phoneLinkDriver().forget();
|
|
143
|
+
phone_link::clear();
|
|
144
|
+
}
|
|
145
|
+
double phoneTime() const { return phoneLinkDriver().phoneTime(); }
|
|
146
|
+
double seq() const { return phone_link::seq(); }
|
|
147
|
+
bool next() const { return phone_link::next(); }
|
|
148
|
+
std::string kind() const {
|
|
149
|
+
switch (phone_link::current().kind) {
|
|
150
|
+
case phone_link::EventKind::Modified: return "modified";
|
|
151
|
+
case phone_link::EventKind::Removed: return "removed";
|
|
152
|
+
default: return "added";
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
double uid() const { return static_cast<double>(phone_link::current().uid); }
|
|
156
|
+
std::string appId() const { return phone_link::current().appId; }
|
|
157
|
+
std::string appName() const { return phone_link::current().appName; }
|
|
158
|
+
std::string title() const { return phone_link::current().title; }
|
|
159
|
+
std::string subtitle() const { return phone_link::current().subtitle; }
|
|
160
|
+
std::string message() const { return phone_link::current().message; }
|
|
161
|
+
double time() const { return phone_link::current().time; }
|
|
162
|
+
double category() const { return static_cast<double>(phone_link::current().category); }
|
|
163
|
+
double flags() const { return static_cast<double>(phone_link::current().flags); }
|
|
164
|
+
std::string positiveLabel() const { return phone_link::current().positiveLabel; }
|
|
165
|
+
std::string negativeLabel() const { return phone_link::current().negativeLabel; }
|
|
166
|
+
void performAction(double uid, bool positive) const {
|
|
167
|
+
phoneLinkDriver().performAction(static_cast<std::uint32_t>(uid), positive);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
inline constexpr PhoneLinkFacade PhoneLink{};
|
|
172
|
+
|
|
173
|
+
} // namespace gea::host
|