From 2e58e734efc7a09ef1d1f3a5b50703fe310ea6de Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Fri, 20 Nov 2026 23:33:40 +0100 Subject: [PATCH] workout_app: drop geolocator for LocationManager geolocator_android links non-free play-services-location (plus -base, -basement, -tasks). LocationManagerPositionSource reads fixes through kuhyx/utils platform_location (AOSP LocationManager, also registers in the run-service isolate). Release APK: 0 com/google/android/gms classes (was 15). Emulator: 2 s GPS fixes with the screen off, location-off and denied-forever states. Co-Authored-By: Claude Opus 5.5 --- .../lib/sandbox/sandbox_run_replay.dart | 6 +- .../lib/services/position_source.dart | 2 +- .../services/position_source_geolocator.dart | 68 ----------- .../position_source_location_manager.dart | 57 +++++++++ .../lib/services/run_service_isolate.dart | 4 +- .../workout_app/pubspec.lock | 97 ++------------- .../workout_app/pubspec.yaml | 10 +- .../workout_app/test/fake_geolocator.dart | 27 ----- .../test/fake_platform_location.dart | 54 +++++++++ .../test/sandbox/sandbox_run_replay_test.dart | 6 +- .../test/screens/home_run_entry_test.dart | 10 +- .../test/services/position_source_test.dart | 114 +++++++----------- 12 files changed, 183 insertions(+), 272 deletions(-) delete mode 100644 stronglift_replacement/workout_app/lib/services/position_source_geolocator.dart create mode 100644 stronglift_replacement/workout_app/lib/services/position_source_location_manager.dart delete mode 100644 stronglift_replacement/workout_app/test/fake_geolocator.dart create mode 100644 stronglift_replacement/workout_app/test/fake_platform_location.dart diff --git a/stronglift_replacement/workout_app/lib/sandbox/sandbox_run_replay.dart b/stronglift_replacement/workout_app/lib/sandbox/sandbox_run_replay.dart index c08e013..bd539de 100644 --- a/stronglift_replacement/workout_app/lib/sandbox/sandbox_run_replay.dart +++ b/stronglift_replacement/workout_app/lib/sandbox/sandbox_run_replay.dart @@ -10,7 +10,7 @@ import 'dart:math' as math; import 'package:workout_app/sandbox/sandbox.dart'; import 'package:workout_app/services/gps_filter.dart'; import 'package:workout_app/services/position_source.dart'; -import 'package:workout_app/services/position_source_geolocator.dart'; +import 'package:workout_app/services/position_source_location_manager.dart'; import 'package:workout_app/services/position_source_scripted.dart'; /// Length of the synthetic loop in metres. @@ -60,11 +60,11 @@ PositionSource sandboxRunSource({DateTime? now}) => ScriptedPositionSource( /// The source a recording uses: the replay in the sandbox, the phone's GPS /// otherwise. PositionSource positionSourceFor() => - Sandbox.enabled ? sandboxRunSource() : GeolocatorPositionSource(); + Sandbox.enabled ? sandboxRunSource() : LocationManagerPositionSource(); /// The source the idle map watches: in the sandbox just the replay's first /// fix (so the marker sits at the loop's start and does not walk the lap /// before the run), the phone's GPS otherwise. PositionSource idlePositionSourceFor({DateTime? now}) => Sandbox.enabled ? ScriptedPositionSource([sandboxLoopFixes(now ?? DateTime.now()).first]) - : GeolocatorPositionSource(); + : LocationManagerPositionSource(); diff --git a/stronglift_replacement/workout_app/lib/services/position_source.dart b/stronglift_replacement/workout_app/lib/services/position_source.dart index 94dd8e9..050916b 100644 --- a/stronglift_replacement/workout_app/lib/services/position_source.dart +++ b/stronglift_replacement/workout_app/lib/services/position_source.dart @@ -2,7 +2,7 @@ /// /// Everything above this interface (recorder, map, sandbox replay) is pure /// Dart and runs on the Linux test host and the desktop target; only -/// `GeolocatorPositionSource` touches the geolocator plugin. +/// `LocationManagerPositionSource` touches the platform_location plugin. library; import 'package:workout_app/services/gps_filter.dart'; diff --git a/stronglift_replacement/workout_app/lib/services/position_source_geolocator.dart b/stronglift_replacement/workout_app/lib/services/position_source_geolocator.dart deleted file mode 100644 index 6c346f8..0000000 --- a/stronglift_replacement/workout_app/lib/services/position_source_geolocator.dart +++ /dev/null @@ -1,68 +0,0 @@ -/// The real [PositionSource], backed by the geolocator plugin. -library; - -import 'package:geolocator/geolocator.dart'; -import 'package:workout_app/services/gps_filter.dart'; -import 'package:workout_app/services/position_source.dart'; - -/// Reads fixes through [GeolocatorPlatform.instance], so a test can swap the -/// platform and drive this class without a device. -class GeolocatorPositionSource implements PositionSource { - /// Creates the source; [forceLocationManager] skips Google Play services. - GeolocatorPositionSource({this.forceLocationManager = false}); - - /// Android: use the legacy LocationManager instead of the fused provider. - final bool forceLocationManager; - - GeolocatorPlatform get _platform => GeolocatorPlatform.instance; - - @override - Future requestAccess() async { - if (!await _platform.isLocationServiceEnabled()) { - return LocationAccess.serviceOff; - } - var permission = await _platform.checkPermission(); - if (permission == LocationPermission.denied) { - permission = await _platform.requestPermission(); - } - return _access(permission); - } - - @override - Future checkAccess() async { - if (!await _platform.isLocationServiceEnabled()) { - return LocationAccess.serviceOff; - } - return _access(await _platform.checkPermission()); - } - - static LocationAccess _access(LocationPermission permission) => - switch (permission) { - LocationPermission.always || - LocationPermission.whileInUse => LocationAccess.granted, - LocationPermission.deniedForever => LocationAccess.deniedForever, - LocationPermission.denied || - LocationPermission.unableToDetermine => LocationAccess.denied, - }; - - @override - Stream fixes({Duration interval = const Duration(seconds: 2)}) => - _platform - .getPositionStream( - locationSettings: AndroidSettings( - accuracy: LocationAccuracy.bestForNavigation, - intervalDuration: interval, - forceLocationManager: forceLocationManager, - ), - ) - .map( - (p) => GpsFix( - time: p.timestamp, - latitude: p.latitude, - longitude: p.longitude, - altitudeM: p.altitude, - accuracyM: p.accuracy, - isMocked: p.isMocked, - ), - ); -} diff --git a/stronglift_replacement/workout_app/lib/services/position_source_location_manager.dart b/stronglift_replacement/workout_app/lib/services/position_source_location_manager.dart new file mode 100644 index 0000000..b6c9503 --- /dev/null +++ b/stronglift_replacement/workout_app/lib/services/position_source_location_manager.dart @@ -0,0 +1,57 @@ +/// The real [PositionSource], backed by the platform_location plugin +/// (AOSP LocationManager; no Google Play services in the APK). +library; + +import 'package:platform_location/platform_location.dart'; +import 'package:workout_app/services/gps_filter.dart'; +import 'package:workout_app/services/position_source.dart'; + +/// Reads fixes through [PlatformLocation.instance], so a test can swap the +/// platform and drive this class without a device. +class LocationManagerPositionSource implements PositionSource { + PlatformLocation get _platform => PlatformLocation.instance; + + @override + Future requestAccess() async { + if (!await _platform.isLocationEnabled()) { + return LocationAccess.serviceOff; + } + var permission = await _platform.checkPermission(); + if (permission != LocationPermissionState.granted) { + // Asked again even after a refusal: only the request itself can tell + // Android's "don't ask again" (deniedForever) apart from "denied". + permission = await _platform.requestPermission(); + } + return _access(permission); + } + + @override + Future checkAccess() async { + if (!await _platform.isLocationEnabled()) { + return LocationAccess.serviceOff; + } + return _access(await _platform.checkPermission()); + } + + static LocationAccess _access(LocationPermissionState permission) => + switch (permission) { + LocationPermissionState.granted => LocationAccess.granted, + LocationPermissionState.deniedForever => LocationAccess.deniedForever, + LocationPermissionState.denied => LocationAccess.denied, + }; + + @override + Stream fixes({Duration interval = const Duration(seconds: 2)}) => + _platform + .fixes(interval: interval) + .map( + (p) => GpsFix( + time: p.time, + latitude: p.latitude, + longitude: p.longitude, + altitudeM: p.altitude, + accuracyM: p.accuracy, + isMocked: p.isMock, + ), + ); +} diff --git a/stronglift_replacement/workout_app/lib/services/run_service_isolate.dart b/stronglift_replacement/workout_app/lib/services/run_service_isolate.dart index b5e44d3..8afbc21 100644 --- a/stronglift_replacement/workout_app/lib/services/run_service_isolate.dart +++ b/stronglift_replacement/workout_app/lib/services/run_service_isolate.dart @@ -18,7 +18,7 @@ import 'package:workout_app/sandbox/sandbox_run_replay.dart'; import 'package:workout_app/services/feedback_cues.dart'; import 'package:workout_app/services/gps_filter.dart'; import 'package:workout_app/services/position_source.dart'; -import 'package:workout_app/services/position_source_geolocator.dart'; +import 'package:workout_app/services/position_source_location_manager.dart'; import 'package:workout_app/services/run_checkpoint_location.dart'; import 'package:workout_app/services/run_engine_recorder.dart'; import 'package:workout_app/services/run_host.dart'; @@ -116,7 +116,7 @@ class _RunServiceTaskHandler extends TaskHandler { engineFactory: recorderEngineFactory( () => Sandbox.enabled ? sandboxRunSource() - : NoPromptSource(GeolocatorPositionSource()), + : NoPromptSource(LocationManagerPositionSource()), ), port: port, store: await openRunCheckpointStore(), diff --git a/stronglift_replacement/workout_app/pubspec.lock b/stronglift_replacement/workout_app/pubspec.lock index 6a06390..0541297 100644 --- a/stronglift_replacement/workout_app/pubspec.lock +++ b/stronglift_replacement/workout_app/pubspec.lock @@ -551,70 +551,6 @@ packages: description: flutter source: sdk version: "0.0.0" - geoclue: - dependency: transitive - description: - name: geoclue - sha256: c2a998c77474fc57aa00c6baa2928e58f4b267649057a1c76738656e9dbd2a7f - url: "https://pub.dev" - source: hosted - version: "0.1.1" - geolocator: - dependency: "direct main" - description: - name: geolocator - sha256: "2b3bc0f7320d5a5fa02f8209ffcf1aaa7c2cabb7b2bedbc0cfeb5ff2778b8b09" - url: "https://pub.dev" - source: hosted - version: "14.1.2" - geolocator_android: - dependency: transitive - description: - name: geolocator_android - sha256: e67583809a1fab5f4a2255902978e2bc095ace9451fde0d9624e54facd0a5c22 - url: "https://pub.dev" - source: hosted - version: "5.2.1" - geolocator_apple: - dependency: transitive - description: - name: geolocator_apple - sha256: a1e177f3081089724f2095856aeb96eb8d7d1c59e425aed8dd4de7aa2c11ab66 - url: "https://pub.dev" - source: hosted - version: "2.4.3" - geolocator_linux: - dependency: transitive - description: - name: geolocator_linux - sha256: "3da7420f11c3496511a5bd3c18fd67b88e5659f12e46b7ce00a788f6996e850a" - url: "https://pub.dev" - source: hosted - version: "0.2.6" - geolocator_platform_interface: - dependency: transitive - description: - name: geolocator_platform_interface - sha256: e012af6b7e2674e7500237ab11e44ac9119e87fd0105e7bb55cde1750e8e5d80 - url: "https://pub.dev" - source: hosted - version: "4.4.1" - geolocator_web: - dependency: transitive - description: - name: geolocator_web - sha256: "19e485a0f8d6a88abcf9c53cba3a4105e14b7435ed8ac1c108c067b938fe8429" - url: "https://pub.dev" - source: hosted - version: "4.1.4" - geolocator_windows: - dependency: transitive - description: - name: geolocator_windows - sha256: "175435404d20278ffd220de83c2ca293b73db95eafbdc8131fe8609be1421eb6" - url: "https://pub.dev" - source: hosted - version: "0.2.5" glob: dependency: transitive description: @@ -632,14 +568,6 @@ packages: url: "https://github.com/kuhyx/utils" source: git version: "0.1.0" - gsettings: - dependency: transitive - description: - name: gsettings - sha256: "1b0ce661f5436d2db1e51f3c4295a49849f03d304003a7ba177d01e3a858249c" - url: "https://pub.dev" - source: hosted - version: "0.2.8" hooks: dependency: transitive description: @@ -856,22 +784,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" - package_info_plus: - dependency: transitive - description: - name: package_info_plus - sha256: "73ef2cd5c11a7548f9b7f6fc2a4f6113de2e64aa2a70de63feede95548822908" - url: "https://pub.dev" - source: hosted - version: "10.2.2" - package_info_plus_platform_interface: - dependency: transitive - description: - name: package_info_plus_platform_interface - sha256: db762cb2f4f25ee60fb6359773861b0f199e00b90d237bd85a76a1e806b46ef4 - url: "https://pub.dev" - source: hosted - version: "4.1.0" path: dependency: "direct main" description: @@ -992,6 +904,15 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.6" + platform_location: + dependency: "direct main" + description: + path: platform_location + ref: "platform_location-v0.1.0" + resolved-ref: b8e2bf88132716bc3b52c0ae13fb169e1e411eaa + url: "https://github.com/kuhyx/utils" + source: git + version: "0.1.0" plugin_platform_interface: dependency: transitive description: diff --git a/stronglift_replacement/workout_app/pubspec.yaml b/stronglift_replacement/workout_app/pubspec.yaml index 91b05ee..f3e5a55 100644 --- a/stronglift_replacement/workout_app/pubspec.yaml +++ b/stronglift_replacement/workout_app/pubspec.yaml @@ -39,8 +39,6 @@ dependencies: flutter_map: 8.3.2 flutter_map_cache: 2.1.2 flutter_secure_storage: 11.2.0 - # GPS fixes, behind the PositionSource seam (lib/services/position_source). - geolocator: 14.1.2 # One-tap sign-in for the sync account (AccountManager ID token; no Play # Services SDK in the APK). App-side only: crdt_sync stays pure Dart so it # keeps working on Linux desktop and headless. @@ -56,6 +54,14 @@ dependencies: path: 1.9.1 path_provider: 2.1.6 permission_handler: 13.0.2 + # GPS fixes over AOSP LocationManager, behind the PositionSource seam + # (lib/services/position_source). No Google Play services: the previous + # plugin linked non-free play-services-location on Android. + platform_location: + git: + url: https://github.com/kuhyx/utils + ref: platform_location-v0.1.0 + path: platform_location shared_preferences: 2.5.6 sqflite: 2.4.6 # Linux desktop has no sqflite plugin; the FFI factory drives the same diff --git a/stronglift_replacement/workout_app/test/fake_geolocator.dart b/stronglift_replacement/workout_app/test/fake_geolocator.dart deleted file mode 100644 index 4df724b..0000000 --- a/stronglift_replacement/workout_app/test/fake_geolocator.dart +++ /dev/null @@ -1,27 +0,0 @@ -/// A geolocator platform that answers from fields, for tests that build the -/// real run controller (and so the real position source) without a device. -library; - -import 'package:geolocator/geolocator.dart'; - -/// Location on, permission granted, no positions. -class FakeGeolocator extends GeolocatorPlatform { - /// Whether the device's location switch is on. - bool serviceOn = true; - - /// The permission [checkPermission] reports. - LocationPermission permission = LocationPermission.whileInUse; - - @override - Future isLocationServiceEnabled() async => serviceOn; - - @override - Future checkPermission() async => permission; - - @override - Future requestPermission() async => permission; - - @override - Stream getPositionStream({LocationSettings? locationSettings}) => - const Stream.empty(); -} diff --git a/stronglift_replacement/workout_app/test/fake_platform_location.dart b/stronglift_replacement/workout_app/test/fake_platform_location.dart new file mode 100644 index 0000000..3440607 --- /dev/null +++ b/stronglift_replacement/workout_app/test/fake_platform_location.dart @@ -0,0 +1,54 @@ +/// A platform_location fake that answers from fields, for tests that build +/// the real run controller (and so the real position source) without a +/// device. +library; + +import 'package:platform_location/platform_location.dart'; + +/// Location on, permission granted, no fixes unless [positions] says so. +class FakePlatformLocation extends PlatformLocation { + /// Whether the device's location switch is on. + bool serviceOn = true; + + /// The permission [checkPermission] reports. + LocationPermissionState current = LocationPermissionState.granted; + + /// What a [requestPermission] call turns [current] into. + LocationPermissionState? afterRequest; + + /// How many times [requestPermission] ran. + int requests = 0; + + /// The `precise` flag of the last request. + bool? lastPrecise; + + /// The interval the last [fixes] call asked for. + Duration? interval; + + /// What [fixes] emits. + List positions = []; + + @override + Future isLocationEnabled() async => serviceOn; + + @override + Future checkPermission() async => current; + + @override + Future requestPermission({ + bool precise = true, + }) async { + requests++; + lastPrecise = precise; + return current = afterRequest ?? current; + } + + @override + Future currentLocation() async => positions.first; + + @override + Stream fixes({Duration interval = const Duration(seconds: 2)}) { + this.interval = interval; + return Stream.fromIterable(positions); + } +} diff --git a/stronglift_replacement/workout_app/test/sandbox/sandbox_run_replay_test.dart b/stronglift_replacement/workout_app/test/sandbox/sandbox_run_replay_test.dart index 17f4f7b..b6db265 100644 --- a/stronglift_replacement/workout_app/test/sandbox/sandbox_run_replay_test.dart +++ b/stronglift_replacement/workout_app/test/sandbox/sandbox_run_replay_test.dart @@ -3,7 +3,7 @@ import 'package:workout_app/models/run_track.dart'; import 'package:workout_app/sandbox/sandbox.dart'; import 'package:workout_app/sandbox/sandbox_run_replay.dart'; import 'package:workout_app/services/gps_filter.dart'; -import 'package:workout_app/services/position_source_geolocator.dart'; +import 'package:workout_app/services/position_source_location_manager.dart'; import 'package:workout_app/services/position_source_scripted.dart'; import 'package:workout_app/services/run_math.dart'; @@ -70,7 +70,7 @@ void main() { Sandbox.enabled = true; expect(positionSourceFor(), isA()); Sandbox.enabled = false; - expect(positionSourceFor(), isA()); + expect(positionSourceFor(), isA()); }); test('the idle position is the replay first fix, and only that', () async { @@ -83,6 +83,6 @@ void main() { expect(fixes.single.longitude, first.longitude); expect((await source.requestAccess()).isGranted, isTrue); Sandbox.enabled = false; - expect(idlePositionSourceFor(), isA()); + expect(idlePositionSourceFor(), isA()); }); } diff --git a/stronglift_replacement/workout_app/test/screens/home_run_entry_test.dart b/stronglift_replacement/workout_app/test/screens/home_run_entry_test.dart index 3424562..de3f069 100644 --- a/stronglift_replacement/workout_app/test/screens/home_run_entry_test.dart +++ b/stronglift_replacement/workout_app/test/screens/home_run_entry_test.dart @@ -1,7 +1,7 @@ // The run icon on the home screen opens the run screen. import 'package:material_ui/material_ui.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:geolocator/geolocator.dart'; +import 'package:platform_location/platform_location.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; import 'package:sqflite_common_ffi/sqflite_ffi.dart'; @@ -9,7 +9,7 @@ import 'package:workout_app/screens/run_screen.dart'; import 'package:workout_app/services/storage_service.dart'; import '../fake_audio_platform.dart'; -import '../fake_geolocator.dart'; +import '../fake_platform_location.dart'; import '../fake_secure_storage.dart'; import '../run_persist_rig.dart'; import '_home_test_fixtures.dart'; @@ -29,9 +29,9 @@ void main() { installFakeSecureStorage(); installFakeAudioPlatform(); // The real run controller asks the real source where the user is. - final original = GeolocatorPlatform.instance; - GeolocatorPlatform.instance = FakeGeolocator(); - addTearDown(() => GeolocatorPlatform.instance = original); + final original = PlatformLocation.instance; + PlatformLocation.instance = FakePlatformLocation(); + addTearDown(() => PlatformLocation.instance = original); // `main` installs the real wiring; here the run lives in a fake host. RunScreen.defaultControllerFactory = PersistRig().build; addTearDown(() => RunScreen.defaultControllerFactory = null); diff --git a/stronglift_replacement/workout_app/test/services/position_source_test.dart b/stronglift_replacement/workout_app/test/services/position_source_test.dart index 8110e4d..66c49e2 100644 --- a/stronglift_replacement/workout_app/test/services/position_source_test.dart +++ b/stronglift_replacement/workout_app/test/services/position_source_test.dart @@ -1,50 +1,19 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:geolocator/geolocator.dart'; +import 'package:platform_location/platform_location.dart'; import 'package:workout_app/services/gps_filter.dart'; import 'package:workout_app/services/position_source.dart'; -import 'package:workout_app/services/position_source_geolocator.dart'; +import 'package:workout_app/services/position_source_location_manager.dart'; import 'package:workout_app/services/position_source_scripted.dart'; -/// A platform that answers from fields instead of a method channel. -class _FakeGeolocator extends GeolocatorPlatform { - bool serviceOn = true; - LocationPermission current = LocationPermission.denied; - LocationPermission afterRequest = LocationPermission.whileInUse; - int requests = 0; - LocationSettings? settings; - List positions = []; +import '../fake_platform_location.dart'; - @override - Future isLocationServiceEnabled() async => serviceOn; - - @override - Future checkPermission() async => current; - - @override - Future requestPermission() async { - requests++; - return current = afterRequest; - } - - @override - Stream getPositionStream({LocationSettings? locationSettings}) { - settings = locationSettings; - return Stream.fromIterable(positions); - } -} - -Position _position({bool mocked = false}) => Position( +LocationFix _position({bool mocked = false}) => LocationFix( latitude: 48.8584, longitude: 2.2945, - timestamp: DateTime.utc(2026, 11, 9, 12), + time: DateTime.utc(2026, 11, 9, 12), accuracy: 4.5, altitude: 33, - altitudeAccuracy: 1, - heading: 0, - headingAccuracy: 1, - speed: 2, - speedAccuracy: 1, - isMocked: mocked, + isMock: mocked, ); void main() { @@ -54,88 +23,87 @@ void main() { ]); }); - group('GeolocatorPositionSource', () { - late _FakeGeolocator platform; - final original = GeolocatorPlatform.instance; + group('LocationManagerPositionSource', () { + late FakePlatformLocation platform; + final original = PlatformLocation.instance; setUp(() { - platform = _FakeGeolocator(); - GeolocatorPlatform.instance = platform; + platform = FakePlatformLocation() + ..current = LocationPermissionState.denied + ..afterRequest = LocationPermissionState.granted; + PlatformLocation.instance = platform; }); - tearDown(() => GeolocatorPlatform.instance = original); + tearDown(() => PlatformLocation.instance = original); test('service off wins over any permission', () async { platform.serviceOn = false; expect( - await GeolocatorPositionSource().requestAccess(), + await LocationManagerPositionSource().requestAccess(), LocationAccess.serviceOff, ); expect(platform.requests, 0); }); - test('a denied permission is requested once and then granted', () async { - expect( - await GeolocatorPositionSource().requestAccess(), - LocationAccess.granted, - ); - expect(platform.requests, 1); - }); + test( + 'a denied permission is requested once, precise, then granted', + () async { + expect( + await LocationManagerPositionSource().requestAccess(), + LocationAccess.granted, + ); + expect(platform.requests, 1); + expect(platform.lastPrecise, isTrue); + }, + ); test('an already granted permission is not requested again', () async { - platform.current = LocationPermission.always; + platform.current = LocationPermissionState.granted; expect( - await GeolocatorPositionSource().requestAccess(), + await LocationManagerPositionSource().requestAccess(), LocationAccess.granted, ); expect(platform.requests, 0); }); test('refusals map to denied / deniedForever', () async { - platform.afterRequest = LocationPermission.denied; + platform.afterRequest = LocationPermissionState.denied; expect( - await GeolocatorPositionSource().requestAccess(), + await LocationManagerPositionSource().requestAccess(), LocationAccess.denied, ); - platform.current = LocationPermission.deniedForever; + platform.afterRequest = LocationPermissionState.deniedForever; expect( - await GeolocatorPositionSource().requestAccess(), + await LocationManagerPositionSource().requestAccess(), LocationAccess.deniedForever, ); - platform.current = LocationPermission.unableToDetermine; - expect( - await GeolocatorPositionSource().requestAccess(), - LocationAccess.denied, - ); }); test('checkAccess reads the state and never prompts', () async { - final source = GeolocatorPositionSource(); + final source = LocationManagerPositionSource(); expect(await source.checkAccess(), LocationAccess.denied); - platform.current = LocationPermission.whileInUse; + platform.current = LocationPermissionState.granted; expect(await source.checkAccess(), LocationAccess.granted); - platform.current = LocationPermission.deniedForever; + platform.current = LocationPermissionState.deniedForever; expect(await source.checkAccess(), LocationAccess.deniedForever); platform.serviceOn = false; expect(await source.checkAccess(), LocationAccess.serviceOff); expect(platform.requests, 0); }); - test('fixes maps positions and asks for navigation accuracy', () async { + test('fixes maps platform fixes at the asked interval', () async { platform.positions = [_position(), _position(mocked: true)]; - final fixes = await GeolocatorPositionSource( - forceLocationManager: true, - ).fixes(interval: const Duration(seconds: 3)).toList(); + final fixes = await LocationManagerPositionSource() + .fixes(interval: const Duration(seconds: 3)) + .toList(); expect(fixes, hasLength(2)); expect(fixes.first.latitude, 48.8584); + expect(fixes.first.longitude, 2.2945); expect(fixes.first.altitudeM, 33); expect(fixes.first.accuracyM, 4.5); expect(fixes.first.time, DateTime.utc(2026, 11, 9, 12)); expect(fixes.first.isMocked, isFalse); expect(fixes.last.isMocked, isTrue); - final android = platform.settings! as AndroidSettings; - expect(android.accuracy, LocationAccuracy.bestForNavigation); - expect(android.intervalDuration, const Duration(seconds: 3)); - expect(android.forceLocationManager, isTrue); + expect(platform.interval, const Duration(seconds: 3)); }); });