Compare commits

...

1 Commits

Author SHA1 Message Date
Jonas Bark
aff1137c3d fix bluetooth scan issues on older Android devices by asking for location permission 2025-04-07 12:48:20 +02:00
7 changed files with 62 additions and 6 deletions

View File

@@ -1,3 +1,6 @@
#### 2.0.2 (2025-04-07)
- fix bluetooth scan issues on older Android devices by asking for location permission
#### 2.0.1 (2025-04-06)
- long pressing a button will trigger the action again every 250ms

View File

@@ -30,9 +30,13 @@ class _ScanWidgetState extends State<ScanWidget> {
WidgetsBinding.instance.addPostFrameCallback((_) {
// must be called from a button
if (!kIsWeb) {
Future.delayed(Duration(seconds: 1)).then((_) {
connection.performScanning();
});
Future.delayed(Duration(seconds: 1))
.then((_) {
return connection.performScanning();
})
.catchError((e) {
print(e);
});
}
});
}

View File

@@ -34,6 +34,21 @@ class BluetoothScanRequirement extends PlatformRequirement {
}
}
class LocationRequirement extends PlatformRequirement {
LocationRequirement() : super('Allow Location so Bluetooth scan works');
@override
Future<void> call() async {
await Permission.locationWhenInUse.request();
}
@override
Future<void> getStatus() async {
final state = await Permission.locationWhenInUse.status;
status = state.isGranted || state.isLimited;
}
}
class BluetoothConnectRequirement extends PlatformRequirement {
BluetoothConnectRequirement() : super('Allow Bluetooth Connections');

View File

@@ -1,5 +1,6 @@
import 'dart:io';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:swift_control/utils/requirements/android.dart';
@@ -29,12 +30,18 @@ Future<List<PlatformRequirement>> getRequirements() async {
} else if (Platform.isWindows) {
list = [BluetoothTurnedOn(), KeyboardRequirement(), BluetoothScanning()];
} else if (Platform.isAndroid) {
final deviceInfoPlugin = DeviceInfoPlugin();
final deviceInfo = await deviceInfoPlugin.androidInfo;
list = [
BluetoothTurnedOn(),
AccessibilityRequirement(),
NotificationRequirement(),
BluetoothScanRequirement(),
BluetoothConnectRequirement(),
if (deviceInfo.version.sdkInt <= 30)
LocationRequirement()
else ...[
BluetoothScanRequirement(),
BluetoothConnectRequirement(),
],
BluetoothScanning(),
];
} else {

View File

@@ -5,6 +5,7 @@
import FlutterMacOS
import Foundation
import device_info_plus
import file_selector_macos
import flutter_local_notifications
import keypress_simulator_macos
@@ -16,6 +17,7 @@ import url_launcher_macos
import window_manager
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
KeypressSimulatorMacosPlugin.register(with: registry.registrar(forPlugin: "KeypressSimulatorMacosPlugin"))

View File

@@ -128,6 +128,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.11"
device_info_plus:
dependency: "direct main"
description:
name: device_info_plus
sha256: "306b78788d1bb569edb7c55d622953c2414ca12445b41c9117963e03afc5c513"
url: "https://pub.dev"
source: hosted
version: "11.3.3"
device_info_plus_platform_interface:
dependency: transitive
description:
name: device_info_plus_platform_interface
sha256: "0b04e02b30791224b31969eb1b50d723498f402971bff3630bca2ba839bd1ed2"
url: "https://pub.dev"
source: hosted
version: "7.0.2"
fake_async:
dependency: transitive
description:
@@ -912,6 +928,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.12.0"
win32_registry:
dependency: transitive
description:
name: win32_registry
sha256: "6f1b564492d0147b330dd794fee8f512cec4977957f310f9951b5f9d83618dae"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
window_manager:
dependency: "direct main"
description:

View File

@@ -1,7 +1,7 @@
name: swift_control
description: "SwiftControl - Control your virtual riding"
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 2.0.1+0
version: 2.0.2+0
environment:
sdk: ^3.7.0
@@ -19,6 +19,7 @@ dependencies:
image_picker: ^1.1.2
pointycastle: any
window_manager: ^0.4.3
device_info_plus: ^11.3.3
keypress_simulator:
path: keypress_simulator/packages/keypress_simulator
shared_preferences: ^2.5.3