mirror of
https://github.com/ente-io/ente.git
synced 2025-07-01 13:13:35 +00:00
34 lines
942 B
Dart
34 lines
942 B
Dart
import 'dart:io';
|
|
|
|
import "package:device_info_plus/device_info_plus.dart";
|
|
import 'package:logging/logging.dart';
|
|
|
|
DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
|
|
|
Future<bool> isAndroidSDKVersionLowerThan(int inputSDK) async {
|
|
if (Platform.isAndroid) {
|
|
final AndroidDeviceInfo androidInfo = await deviceInfoPlugin.androidInfo;
|
|
return androidInfo.version.sdkInt < inputSDK;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
Future<String?> getDeviceName() async {
|
|
try {
|
|
if (Platform.isIOS) {
|
|
final IosDeviceInfo iosInfo = await deviceInfoPlugin.iosInfo;
|
|
return iosInfo.utsname.machine;
|
|
} else if (Platform.isAndroid) {
|
|
final AndroidDeviceInfo androidInfo = await deviceInfoPlugin.androidInfo;
|
|
|
|
return "${androidInfo.brand} ${androidInfo.model}";
|
|
} else {
|
|
return "Not iOS or Android";
|
|
}
|
|
} catch (e) {
|
|
Logger("device_info").severe("deviceSpec check failed", e);
|
|
return null;
|
|
}
|
|
}
|