mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-09 08:47:31 +00:00
Filter device to force HFR
This commit is contained in:
parent
433ae3d0c7
commit
8e08fd9516
@ -25,6 +25,7 @@ import 'package:spotube/services/audio_player/audio_player.dart';
|
|||||||
import 'package:spotube/services/cli/cli.dart';
|
import 'package:spotube/services/cli/cli.dart';
|
||||||
import 'package:spotube/services/connectivity_adapter.dart';
|
import 'package:spotube/services/connectivity_adapter.dart';
|
||||||
import 'package:spotube/themes/theme.dart';
|
import 'package:spotube/themes/theme.dart';
|
||||||
|
import 'package:spotube/utils/device_utils.dart';
|
||||||
import 'package:spotube/utils/persisted_state_notifier.dart';
|
import 'package:spotube/utils/persisted_state_notifier.dart';
|
||||||
import 'package:system_theme/system_theme.dart';
|
import 'package:system_theme/system_theme.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
@ -44,7 +45,10 @@ Future<void> main(List<String> rawArgs) async {
|
|||||||
|
|
||||||
// force High Refresh Rate on some Android devices (like One Plus)
|
// force High Refresh Rate on some Android devices (like One Plus)
|
||||||
if (DesktopTools.platform.isAndroid) {
|
if (DesktopTools.platform.isAndroid) {
|
||||||
await FlutterDisplayMode.setHighRefreshRate();
|
final props = await buildProps;
|
||||||
|
if (isBuggyOs(props)) {
|
||||||
|
await FlutterDisplayMode.setHighRefreshRate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await DesktopTools.ensureInitialized(
|
await DesktopTools.ensureInitialized(
|
||||||
|
|||||||
32
lib/utils/device_utils.dart
Normal file
32
lib/utils/device_utils.dart
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
|
|
||||||
|
Future<Map<String, String>> get buildProps async {
|
||||||
|
try {
|
||||||
|
final getProp = await Process.run('getprop', []);
|
||||||
|
return Map.fromEntries(
|
||||||
|
getProp.stdout
|
||||||
|
.toString()
|
||||||
|
.split('\n')
|
||||||
|
.where((x) => x.startsWith('[') && x.endsWith(']'))
|
||||||
|
.map((e) => e.replaceAll(RegExp(r'(^\[|\]$)'), '').split(']: ['))
|
||||||
|
.map((x) => MapEntry(x.first, x.last))
|
||||||
|
.where((x) => x.value.isNotEmpty),
|
||||||
|
);
|
||||||
|
} catch (e, s) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isBuggyOs(Map<String, String> props) {
|
||||||
|
final brand = [
|
||||||
|
'ro.product.brand',
|
||||||
|
'ro.product.system.brand',
|
||||||
|
'ro.product.system_ext.brand',
|
||||||
|
'ro.product.vendor.brand',
|
||||||
|
].map((x) => props[x]?.toLowerCase()).whereNotNull();
|
||||||
|
final oppo = ['oppo', 'oplus', 'oneplus', 'realme'];
|
||||||
|
|
||||||
|
return oppo.any(brand.contains);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user