diff --git a/lib/utils/client_manager.dart b/lib/utils/client_manager.dart index 5c5a07663..6fad0b847 100644 --- a/lib/utils/client_manager.dart +++ b/lib/utils/client_manager.dart @@ -106,7 +106,7 @@ abstract class ClientManager { return Client( clientName, - httpClient: CustomHttpClient.createHTTPClient(), + httpClient: await CustomHttpClient.createHTTPClient(), verificationMethods: { KeyVerificationMethod.numbers, if (kIsWeb || PlatformInfos.isMobile || PlatformInfos.isLinux) diff --git a/lib/utils/custom_http_client.dart b/lib/utils/custom_http_client.dart index b0a3dcb28..6e00ca460 100644 --- a/lib/utils/custom_http_client.dart +++ b/lib/utils/custom_http_client.dart @@ -1,6 +1,9 @@ import 'dart:convert'; import 'dart:io'; +import 'package:cronet_http/cronet_http.dart' as cronet; +import 'package:cupertino_http/cupertino_http.dart' as cupertino_http; +import 'package:device_info_plus/device_info_plus.dart'; import 'package:http/http.dart' as http; import 'package:http/io_client.dart'; import 'package:http/retry.dart' as retry; @@ -32,9 +35,20 @@ class CustomHttpClient { return HttpClient(context: context); } - static http.Client createHTTPClient() => retry.RetryClient( - PlatformInfos.isAndroid - ? IOClient(customHttpClient(ISRG_X1)) - : http.Client(), + static Future createHTTPClient() async { + if (PlatformInfos.isAndroid) { + final info = await DeviceInfoPlugin().androidInfo; + if (info.version.sdkInt <= 24) { + return retry.RetryClient(IOClient(customHttpClient(ISRG_X1))); + } + return retry.RetryClient(cronet.CronetClient.defaultCronetEngine()); + } + if (PlatformInfos.isIOS || PlatformInfos.isMacOS) { + return retry.RetryClient( + cupertino_http.CupertinoClient.defaultSessionConfiguration(), ); + } + + return retry.RetryClient(http.Client()); + } } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 9d145db6f..e9f683e0f 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -19,6 +19,7 @@ list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST flutter_vodozemac + jni ) set(PLUGIN_BUNDLED_LIBRARIES) diff --git a/pubspec.lock b/pubspec.lock index c66f1b1e0..4681a1352 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -254,6 +254,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.13.1" + cronet_http: + dependency: "direct main" + description: + name: cronet_http + sha256: df26af0de7c4eff46c53c190b5590e22457bfce6ea679aedb1e6326197f27d6f + url: "https://pub.dev" + source: hosted + version: "1.4.0" cross_file: dependency: "direct main" description: @@ -278,6 +286,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.2" + cupertino_http: + dependency: "direct main" + description: + name: cupertino_http + sha256: "8fb9e2c36d0732d9d96abd76683406b57e78a2514e27c962e0c603dbe6f2e3f8" + url: "https://pub.dev" + source: hosted + version: "2.2.0" cupertino_icons: dependency: "direct main" description: @@ -943,6 +959,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.2" + http_profile: + dependency: transitive + description: + name: http_profile + sha256: "7e679e355b09aaee2ab5010915c932cce3f2d1c11c3b2dc177891687014ffa78" + url: "https://pub.dev" + source: hosted + version: "0.1.0" image: dependency: "direct main" description: @@ -1044,6 +1068,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" + jni: + dependency: transitive + description: + name: jni + sha256: d2c361082d554d4593c3012e26f6b188f902acd291330f13d6427641a92b3da1 + url: "https://pub.dev" + source: hosted + version: "0.14.2" js: dependency: transitive description: @@ -1260,6 +1292,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + objective_c: + dependency: transitive + description: + name: objective_c + sha256: "9f034ba1eeca53ddb339bc8f4813cb07336a849cd735559b60cdc068ecce2dc7" + url: "https://pub.dev" + source: hosted + version: "7.1.0" opus_caf_converter_dart: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 0cdd20ca7..cceaebb06 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,9 @@ dependencies: blurhash_dart: ^1.2.1 chewie: ^1.12.1 collection: ^1.18.0 + cronet_http: ^1.4.0 cross_file: ^0.3.4+2 + cupertino_http: ^2.2.0 cupertino_icons: any desktop_drop: ^0.4.4 desktop_notifications: ^0.6.3 diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 3276ee890..83d52aa5d 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -22,6 +22,7 @@ list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST flutter_local_notifications_windows flutter_vodozemac + jni ) set(PLUGIN_BUNDLED_LIBRARIES)