Co-authored-by: Felipe M. <me@fmartingr.com> Co-committed-by: Felipe M. <me@fmartingr.com>
42 lines
1.2 KiB
Dart
42 lines
1.2 KiB
Dart
import 'dart:io';
|
|
import 'package:device_info_plus/device_info_plus.dart';
|
|
|
|
/// Detects whether the current device is a known e-ink device.
|
|
class EinkDetectionHelper {
|
|
static const _einkManufacturers = {
|
|
'onyx', // BOOX
|
|
'boyue', // Likebook
|
|
'amazon', // Kindle
|
|
'kobo',
|
|
'rakuten', // Kobo
|
|
'pocketbook',
|
|
'remarkable',
|
|
'tolino',
|
|
'bigme',
|
|
'dasung',
|
|
};
|
|
|
|
/// Hisense e-ink phone model prefixes (e.g. A5, A7, A9).
|
|
static const _hisenseEinkModels = {'a5', 'a7', 'a9'};
|
|
|
|
/// Returns `true` when the device is a known e-ink device.
|
|
/// On non-Android platforms this always returns `false`.
|
|
static Future<bool> isEinkDevice() async {
|
|
if (!Platform.isAndroid) return false;
|
|
|
|
final info = await DeviceInfoPlugin().androidInfo;
|
|
final manufacturer = info.manufacturer.toLowerCase();
|
|
final model = info.model.toLowerCase();
|
|
|
|
if (_einkManufacturers.contains(manufacturer)) return true;
|
|
|
|
// Hisense makes both LCD and e-ink phones — match specific model lines.
|
|
if (manufacturer == 'hisense') {
|
|
for (final prefix in _hisenseEinkModels) {
|
|
if (model.contains(prefix)) return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|