소스 검색

Fix identification of OS variant + bump version (#1428)

Neeraj Gupta 1 년 전
부모
커밋
0762f50815
3개의 변경된 파일20개의 추가작업 그리고 8개의 파일을 삭제
  1. 2 0
      lib/main.dart
  2. 17 7
      lib/utils/device_info.dart
  3. 1 1
      pubspec.yaml

+ 2 - 0
lib/main.dart

@@ -43,6 +43,7 @@ import 'package:photos/services/user_service.dart';
 import 'package:photos/ui/tools/app_lock.dart';
 import 'package:photos/ui/tools/lock_screen.dart';
 import 'package:photos/utils/crypto_util.dart';
+import "package:photos/utils/device_info.dart";
 import 'package:photos/utils/file_uploader.dart';
 import 'package:photos/utils/local_settings.dart';
 import 'package:shared_preferences/shared_preferences.dart';
@@ -161,6 +162,7 @@ Future<void> _init(bool isBackground, {String via = ''}) async {
   Computer.shared().turnOn(workersCount: 4, verbose: kDebugMode);
   CryptoUtil.init();
   await NetworkClient.instance.init();
+  initDeviceSpec().ignore();
   await Configuration.instance.init();
   await UserService.instance.init();
   await EntityService.instance.init();

+ 17 - 7
lib/utils/device_info.dart

@@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
 import 'package:logging/logging.dart';
 
 DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
+bool disableMediaKit = false;
 
 // https://gist.github.com/adamawolf/3048717
 final Set<String> iOSLowEndMachineCodes = <String>{
@@ -30,6 +31,21 @@ final Set<String> iOSLowEndMachineCodes = <String>{
   "iPhone10,5", //  iPhone 8
 };
 
+Future<void> initDeviceSpec() async {
+  if (Platform.isAndroid) {
+    // Note: The current version of media_kit crashes while playing video when
+// hardware malloc is enabled. Users either need to disable the hardware
+// malloc for our app or we need to disable the media_kit for these devices.
+// Currently, we have disabled the media_kit for these devices. and in the
+// future if needed we can add a setting.
+    final androidInfo = await deviceInfoPlugin.androidInfo;
+    disableMediaKit = androidInfo.toString().contains('graphene') ||
+        androidInfo.toString().contains('divest');
+  } else {
+    disableMediaKit = false;
+  }
+}
+
 Future<bool> isLowSpecDevice() async {
   try {
     if (Platform.isIOS) {
@@ -53,11 +69,5 @@ Future<bool> isAndroidSDKVersionLowerThan(int inputSDK) async {
 }
 
 bool isCompatibleWithMediaKit() {
-  final os = Platform.operatingSystem.toLowerCase();
-  if (os.contains("graphene") || os.contains("divest")) {
-    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;
+  return disableMediaKit == false;
 }

+ 1 - 1
pubspec.yaml

@@ -12,7 +12,7 @@ description: ente photos application
 # Read more about iOS versioning at
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 
-version: 0.7.98+498
+version: 0.7.99+499
 
 environment:
   sdk: ">=3.0.0 <4.0.0"