2023-05-15 09:44:11 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
2023-10-04 06:19:06 +00:00
|
|
|
import "package:device_info_plus/device_info_plus.dart";
|
2023-05-15 09:44:11 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:logging/logging.dart';
|
|
|
|
|
2023-05-19 07:50:18 +00:00
|
|
|
DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
2023-05-15 09:44:11 +00:00
|
|
|
|
|
|
|
// https://gist.github.com/adamawolf/3048717
|
2023-05-19 07:50:18 +00:00
|
|
|
final Set<String> iOSLowEndMachineCodes = <String>{
|
2023-05-15 09:44:11 +00:00
|
|
|
"iPhone5,1", //iPhone 5 (GSM)
|
|
|
|
"iPhone5,2", //iPhone 5 (GSM+CDMA)
|
|
|
|
"iPhone5,3", //iPhone 5C (GSM)
|
|
|
|
"iPhone5,4", //iPhone 5C (Global)
|
|
|
|
"iPhone6,1", //iPhone 5S (GSM)
|
|
|
|
"iPhone6,2", //iPhone 5S (Global)
|
|
|
|
"iPhone7,1", //iPhone 6 Plus
|
|
|
|
"iPhone7,2", //iPhone 6
|
|
|
|
"iPhone8,1", // iPhone 6s
|
|
|
|
"iPhone8,2", // iPhone 6s Plus
|
|
|
|
"iPhone8,4", // iPhone SE (GSM)
|
|
|
|
"iPhone9,1", // iPhone 7
|
|
|
|
"iPhone9,2", // iPhone 7 Plus
|
|
|
|
"iPhone9,3", // iPhone 7
|
|
|
|
"iPhone9,4", // iPhone 7 Plus
|
|
|
|
"iPhone10,1", // iPhone 8
|
|
|
|
"iPhone10,2", // iPhone 8 Plus
|
|
|
|
"iPhone10,3", // iPhone X Global
|
|
|
|
"iPhone10,4", // iPhone 8
|
2023-08-19 11:39:56 +00:00
|
|
|
"iPhone10,5", // iPhone 8
|
2023-05-15 09:44:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Future<bool> isLowSpecDevice() async {
|
|
|
|
try {
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
final IosDeviceInfo iosInfo = await deviceInfoPlugin.iosInfo;
|
|
|
|
debugPrint("ios utc name ${iosInfo.utsname.machine}");
|
|
|
|
return iOSLowEndMachineCodes.contains(iosInfo.utsname.machine);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
Logger("device_info").severe("deviceSpec check failed", e);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2023-05-17 05:32:00 +00:00
|
|
|
|
|
|
|
Future<bool> isAndroidSDKVersionLowerThan(int inputSDK) async {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
final AndroidDeviceInfo androidInfo = await deviceInfoPlugin.androidInfo;
|
|
|
|
return androidInfo.version.sdkInt < inputSDK;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2023-10-04 06:22:28 +00:00
|
|
|
|
|
|
|
bool isCompatibleWithMediaKit() {
|
|
|
|
final os = Platform.operatingSystem.toLowerCase();
|
2023-10-04 06:41:52 +00:00
|
|
|
if (os.contains("graphene") || os.contains("divest")) {
|
2023-10-04 06:22:28 +00:00
|
|
|
Logger("device_info").info("os is $os, using video_player for videos");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Logger("device_info").info("os is $os, using media_kit for videos");
|
|
|
|
return true;
|
|
|
|
}
|