forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirmware_update_build_policy.dart
More file actions
37 lines (28 loc) · 1.37 KB
/
Copy pathfirmware_update_build_policy.dart
File metadata and controls
37 lines (28 loc) · 1.37 KB
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
import 'package:omi/backend/schema/bt_device/bt_device.dart';
/// Firmware-update capabilities that differ between the standard app and the
/// Ray-Ban DAT build.
///
/// MWDATCore embeds SwiftProtobuf, so the DAT build intentionally omits the
/// native mcumgr plugin used for Omi pendant firmware updates. OpenGlass uses
/// its independent Wi-Fi OTA path and remains available in both builds.
class FirmwareUpdateBuildPolicy {
const FirmwareUpdateBuildPolicy({required this.rayBanDat});
static const current = FirmwareUpdateBuildPolicy(rayBanDat: bool.fromEnvironment('OMI_RAYBAN_DAT'));
final bool rayBanDat;
bool get allowsOmiFirmwareUpdate => !rayBanDat;
bool get allowsOpenGlassFirmwareUpdate => true;
bool allowsFirmwareUpdate({required bool isOpenGlass}) {
return isOpenGlass ? allowsOpenGlassFirmwareUpdate : allowsOmiFirmwareUpdate;
}
bool isOpenGlassDevice(BtDevice? device) {
if (device == null) return false;
if (device.type == DeviceType.openglass) return true;
if (device.type != DeviceType.omi) return false;
final name = device.name.toLowerCase();
return name.contains('openglass') || name.contains('omiglass') || name.contains('glass');
}
bool allowsFirmwareUpdateForDevice(BtDevice? device) {
if (device?.type == DeviceType.raybanMeta) return false;
return allowsFirmwareUpdate(isOpenGlass: isOpenGlassDevice(device));
}
}