mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-23 09:16:19 +01:00
55 lines
1.4 KiB
Dart
55 lines
1.4 KiB
Dart
import 'package:device_info_plus/device_info_plus.dart';
|
|
import 'package:logging/logging.dart';
|
|
import 'package:memory_info/memory_info.dart';
|
|
import 'package:nc_photos/double_extension.dart';
|
|
|
|
/// System info for Android
|
|
///
|
|
/// Only meaningful when running on Android. Must call [init] before accessing
|
|
/// the data fields
|
|
class AndroidInfo {
|
|
factory AndroidInfo() => _inst;
|
|
|
|
const AndroidInfo._({
|
|
required this.sdkInt,
|
|
required this.totalMemMb,
|
|
});
|
|
|
|
static Future<void> init() async {
|
|
final info = await DeviceInfoPlugin().androidInfo;
|
|
final sdkInt = info.version.sdkInt!;
|
|
|
|
final memInfo = await MemoryInfoPlugin().memoryInfo;
|
|
final totalMemMb = memInfo.totalMem!.toDouble();
|
|
|
|
_inst = AndroidInfo._(
|
|
sdkInt: sdkInt,
|
|
totalMemMb: totalMemMb,
|
|
);
|
|
_log.info("[init] $_inst");
|
|
}
|
|
|
|
@override
|
|
toString() => "$runtimeType {"
|
|
"sdkInt: $sdkInt, "
|
|
"totalMemMb: ${totalMemMb.toStringAsFixedTruncated(2)}, "
|
|
"}";
|
|
|
|
static late final AndroidInfo _inst;
|
|
|
|
/// Corresponding to Build.VERSION.SDK_INT
|
|
final int sdkInt;
|
|
final double totalMemMb;
|
|
|
|
static final _log = Logger("mobile.android.android_info.AndroidInfo");
|
|
}
|
|
|
|
abstract class AndroidVersion {
|
|
static const O = 26;
|
|
// ignore: constant_identifier_names
|
|
static const O_MR1 = 27;
|
|
static const P = 28;
|
|
static const Q = 29;
|
|
static const R = 30;
|
|
static const S = 31;
|
|
}
|