From 5b07c288b05407c75d95c42e8cc8e74d92d1f096 Mon Sep 17 00:00:00 2001 From: TimHoogstrate Date: Mon, 6 Nov 2023 16:09:00 +0100 Subject: [PATCH 1/6] [platform_interface] 1145 removed optional timestamp (#1362) * removed optional timestamp * Changed changelog text * Removed accidental committed generated_plugins.cmake * changed platform interface version * Update CHANGELOG.md --- geolocator_platform_interface/CHANGELOG.md | 4 ++++ .../lib/src/models/position.dart | 11 +++++------ geolocator_platform_interface/pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/geolocator_platform_interface/CHANGELOG.md b/geolocator_platform_interface/CHANGELOG.md index fb4ff66ba..eb5ffe5d0 100644 --- a/geolocator_platform_interface/CHANGELOG.md +++ b/geolocator_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.2.0 + +- Replaces an optional DateTime? `timestamp` in `Position` object for an NonNull DateTime `timestamp`. + ## 4.1.1 - Updates dependencies to latest versions to prevent conflicts with other packages. diff --git a/geolocator_platform_interface/lib/src/models/position.dart b/geolocator_platform_interface/lib/src/models/position.dart index 5fdf15669..d6a491416 100644 --- a/geolocator_platform_interface/lib/src/models/position.dart +++ b/geolocator_platform_interface/lib/src/models/position.dart @@ -30,7 +30,7 @@ class Position { final double longitude; /// The time at which this position was determined. - final DateTime? timestamp; + final DateTime timestamp; /// The altitude of the device in meters. /// @@ -141,10 +141,9 @@ class Position { 'The supplied map doesn\'t contain the mandatory key `longitude`.'); } - final timestamp = positionMap['timestamp'] != null - ? DateTime.fromMillisecondsSinceEpoch(positionMap['timestamp'].toInt(), - isUtc: true) - : null; + final timestamp = DateTime.fromMillisecondsSinceEpoch( + positionMap['timestamp'].toInt(), + isUtc: true); return Position( latitude: positionMap['latitude'], @@ -167,7 +166,7 @@ class Position { Map toJson() => { 'longitude': longitude, 'latitude': latitude, - 'timestamp': timestamp?.millisecondsSinceEpoch, + 'timestamp': timestamp.millisecondsSinceEpoch, 'accuracy': accuracy, 'altitude': altitude, 'altitude_accuracy': altitudeAccuracy, diff --git a/geolocator_platform_interface/pubspec.yaml b/geolocator_platform_interface/pubspec.yaml index 82489c082..efb3104c4 100644 --- a/geolocator_platform_interface/pubspec.yaml +++ b/geolocator_platform_interface/pubspec.yaml @@ -3,7 +3,7 @@ description: A common platform interface for the geolocator plugin. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator_platform_interface # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 4.1.1 +version: 4.2.0 dependencies: flutter: From b311084e641bc45e7e80e7bc64bde29853fcc43b Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Tue, 14 Nov 2023 10:40:16 +0100 Subject: [PATCH 2/6] Ensure timestamp is not null (#1377) --- .../example/windows/flutter/generated_plugins.cmake | 8 ++++++++ geolocator_linux/CHANGELOG.md | 4 ++++ geolocator_linux/lib/src/geoclue_x.dart | 2 +- geolocator_linux/pubspec.yaml | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/geolocator/example/windows/flutter/generated_plugins.cmake b/geolocator/example/windows/flutter/generated_plugins.cmake index c9e02adbf..f0bcafdb9 100644 --- a/geolocator/example/windows/flutter/generated_plugins.cmake +++ b/geolocator/example/windows/flutter/generated_plugins.cmake @@ -7,6 +7,9 @@ list(APPEND FLUTTER_PLUGIN_LIST url_launcher_windows ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -15,3 +18,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/geolocator_linux/CHANGELOG.md b/geolocator_linux/CHANGELOG.md index befc9aed9..1f0b29cc4 100644 --- a/geolocator_linux/CHANGELOG.md +++ b/geolocator_linux/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.0+1 + +- Ensures the `Position` instance always contains a timestamp. + ## 0.2.0 - Bumps `geolocator_platform_interface` dependency to `^4.1.0`. diff --git a/geolocator_linux/lib/src/geoclue_x.dart b/geolocator_linux/lib/src/geoclue_x.dart index 869b7880e..8ada49478 100644 --- a/geolocator_linux/lib/src/geoclue_x.dart +++ b/geolocator_linux/lib/src/geoclue_x.dart @@ -23,7 +23,7 @@ extension GeoCluePosition on GeoClueLocation { headingAccuracy: 0, latitude: latitude, longitude: longitude, - timestamp: timestamp, + timestamp: timestamp ?? DateTime.now(), speed: speed ?? 0, speedAccuracy: 0, ); diff --git a/geolocator_linux/pubspec.yaml b/geolocator_linux/pubspec.yaml index 66a7d7aae..2a9058692 100644 --- a/geolocator_linux/pubspec.yaml +++ b/geolocator_linux/pubspec.yaml @@ -3,7 +3,7 @@ description: Geolocation Linux plugin for Flutter. This plugin provides the Linux implementation for the geolocator. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator_linux issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen -version: 0.2.0 +version: 0.2.0+1 environment: sdk: '>=2.15.0 <4.0.0' From 6fb962c055a19fef5437e9fba2bc935bdefa56a5 Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Wed, 27 Dec 2023 22:37:21 +0200 Subject: [PATCH 3/6] Ensures [CLLocationManager locationServicesEnabled] is called on background thread (#1399) * Call locationServiceEnabled on separate thread * Update version number * Remove redundant empty lines --- geolocator_apple/CHANGELOG.md | 5 +++++ .../Handlers/LocationServiceStreamHandler.m | 15 ++++++++++----- geolocator_apple/pubspec.yaml | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/geolocator_apple/CHANGELOG.md b/geolocator_apple/CHANGELOG.md index 7ba7387e5..b915352b9 100644 --- a/geolocator_apple/CHANGELOG.md +++ b/geolocator_apple/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.3.3 + +* Ensures the `[CLLocationManager locationServicesEnabled]` message is called +on a background thread when listening for service updates. + ## 2.3.2 * Fixes build error and warnings regarding unused variables and unavailable APIs on macOS. diff --git a/geolocator_apple/ios/Classes/Handlers/LocationServiceStreamHandler.m b/geolocator_apple/ios/Classes/Handlers/LocationServiceStreamHandler.m index 31fac8baf..ac6e8ff4c 100644 --- a/geolocator_apple/ios/Classes/Handlers/LocationServiceStreamHandler.m +++ b/geolocator_apple/ios/Classes/Handlers/LocationServiceStreamHandler.m @@ -34,11 +34,16 @@ - (FlutterError * _Nullable)onListenWithArguments:(id _Nullable)arguments eventS } - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status{ - if ([CLLocationManager locationServicesEnabled]) { - _eventSink([NSNumber numberWithInt:(ServiceStatus)enabled]); - } else { - _eventSink([NSNumber numberWithInt:(ServiceStatus)disabled]); - } + dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + BOOL isEnabled = [CLLocationManager locationServicesEnabled]; + dispatch_async(dispatch_get_main_queue(), ^(void) { + if (isEnabled) { + self->_eventSink([NSNumber numberWithInt:(ServiceStatus)enabled]); + } else { + self->_eventSink([NSNumber numberWithInt:(ServiceStatus)disabled]); + } + }); + }); } @end diff --git a/geolocator_apple/pubspec.yaml b/geolocator_apple/pubspec.yaml index 529aea4d8..d44528774 100644 --- a/geolocator_apple/pubspec.yaml +++ b/geolocator_apple/pubspec.yaml @@ -2,7 +2,7 @@ name: geolocator_apple description: Geolocation Apple plugin for Flutter. This plugin provides the Apple implementation for the geolocator. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator_apple issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen -version: 2.3.2 +version: 2.3.3 environment: sdk: ">=2.15.0 <4.0.0" From 93b32f94eae00b88153f118eb7bb7dae014b51eb Mon Sep 17 00:00:00 2001 From: Arthur Monteiro Alves Melo Date: Mon, 8 Jan 2024 10:49:32 -0300 Subject: [PATCH 4/6] [iOS]: Allow arm64 simulator (#1405) --- geolocator_apple/CHANGELOG.md | 4 ++++ geolocator_apple/ios/geolocator_apple.podspec | 2 +- geolocator_apple/pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/geolocator_apple/CHANGELOG.md b/geolocator_apple/CHANGELOG.md index b915352b9..2d96f0f75 100644 --- a/geolocator_apple/CHANGELOG.md +++ b/geolocator_apple/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.3.4 + +* Allows the ARM64 architecture as a valid IPhone simulator architecture. + ## 2.3.3 * Ensures the `[CLLocationManager locationServicesEnabled]` message is called diff --git a/geolocator_apple/ios/geolocator_apple.podspec b/geolocator_apple/ios/geolocator_apple.podspec index e9cf2ed9d..0bf0363de 100644 --- a/geolocator_apple/ios/geolocator_apple.podspec +++ b/geolocator_apple/ios/geolocator_apple.podspec @@ -20,5 +20,5 @@ Pod::Spec.new do |s| s.platform = :ios, '8.0' # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported. - s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' } + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386'} end diff --git a/geolocator_apple/pubspec.yaml b/geolocator_apple/pubspec.yaml index d44528774..c5f64677b 100644 --- a/geolocator_apple/pubspec.yaml +++ b/geolocator_apple/pubspec.yaml @@ -2,7 +2,7 @@ name: geolocator_apple description: Geolocation Apple plugin for Flutter. This plugin provides the Apple implementation for the geolocator. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator_apple issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen -version: 2.3.3 +version: 2.3.4 environment: sdk: ">=2.15.0 <4.0.0" From ba015e657b374935706042429192e01261e0474b Mon Sep 17 00:00:00 2001 From: vanya elizarov Date: Mon, 15 Jan 2024 13:22:28 +0300 Subject: [PATCH 5/6] fix LocationManager `minUpdateIntervalMillis` (#1402) * fix LocationManager `minUpdateIntervalMillis` * bump version, update CHANGELOG --- geolocator_android/CHANGELOG.md | 4 ++++ .../baseflow/geolocator/location/LocationManagerClient.java | 1 + geolocator_android/pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/geolocator_android/CHANGELOG.md b/geolocator_android/CHANGELOG.md index 2252b527f..643feb901 100644 --- a/geolocator_android/CHANGELOG.md +++ b/geolocator_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.4.1 + +* Fixes a bug where `getPositionStream` caused an `java.lang.IllegalStateException: passive location requests must have an explicit minimum update interval` because `minUpdateIntervalMillis` property in location request was set to -1 by default + ## 4.4.0 - Adds `color` to `ForegroundNotificationConfig` to set the color of the notification icon. diff --git a/geolocator_android/android/src/main/java/com/baseflow/geolocator/location/LocationManagerClient.java b/geolocator_android/android/src/main/java/com/baseflow/geolocator/location/LocationManagerClient.java index a57054d15..c8b3e59a0 100644 --- a/geolocator_android/android/src/main/java/com/baseflow/geolocator/location/LocationManagerClient.java +++ b/geolocator_android/android/src/main/java/com/baseflow/geolocator/location/LocationManagerClient.java @@ -181,6 +181,7 @@ public void startPositionUpdates( final LocationRequestCompat locationRequest = new LocationRequestCompat.Builder(timeInterval) .setMinUpdateDistanceMeters(distanceFilter) + .setMinUpdateIntervalMillis(timeInterval) .setQuality(quality) .build(); diff --git a/geolocator_android/pubspec.yaml b/geolocator_android/pubspec.yaml index 5b98eb575..62d51482f 100644 --- a/geolocator_android/pubspec.yaml +++ b/geolocator_android/pubspec.yaml @@ -2,7 +2,7 @@ name: geolocator_android description: Geolocation plugin for Flutter. This plugin provides the Android implementation for the geolocator. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator_android issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen -version: 4.4.0 +version: 4.4.1 environment: sdk: ">=2.15.0 <4.0.0" From ff5be16c0146098e1c7e38107ac3dbbc3041148d Mon Sep 17 00:00:00 2001 From: TimHoogstrate Date: Tue, 16 Jan 2024 19:02:35 +0100 Subject: [PATCH 6/6] Enables passing negative values for heading and or heading accuracy from the plugin. (#1409) --- geolocator_apple/CHANGELOG.md | 4 ++++ .../ios/Classes/Utils/LocationMapper.m | 14 ++++---------- geolocator_apple/pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/geolocator_apple/CHANGELOG.md b/geolocator_apple/CHANGELOG.md index 2d96f0f75..bc5dd5b57 100644 --- a/geolocator_apple/CHANGELOG.md +++ b/geolocator_apple/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.3.5 + +* Previously the plugin filtered out negative values for heading and/or heading accuracy. Now the plugin is returning the heading and/or the heading accuracy even if the they have a negative value (invalid), so that the developer can use it and decide what to do with it. + ## 2.3.4 * Allows the ARM64 architecture as a valid IPhone simulator architecture. diff --git a/geolocator_apple/ios/Classes/Utils/LocationMapper.m b/geolocator_apple/ios/Classes/Utils/LocationMapper.m index 1ca60c705..7395c586f 100644 --- a/geolocator_apple/ios/Classes/Utils/LocationMapper.m +++ b/geolocator_apple/ios/Classes/Utils/LocationMapper.m @@ -58,16 +58,10 @@ + (NSDictionary *) toDictionary:(CLLocation *)location { // - https://developer.apple.com/documentation/corelocation/cllocation/1423832-course?language=objc // - https://developer.apple.com/documentation/corelocation/cllocation/3524338-courseaccuracy?language=objc double heading = location.course; - if (heading >= 0.0) { - if (@available(iOS 13.4, macOS 10.15.4, *)) { - double headingAccuracy = location.courseAccuracy; - if (headingAccuracy >= 0.0) { - [locationMap setObject:@(heading) forKey: @"heading"]; - [locationMap setObject:@(headingAccuracy) forKey: @"heading_accuracy"]; - } - } else { - [locationMap setObject:@(heading) forKey: @"heading"]; - } + [locationMap setObject:@(heading) forKey: @"heading"]; + if (@available(iOS 13.4, macOS 10.15.4, *)) { + double headingAccuracy = location.courseAccuracy; + [locationMap setObject:@(headingAccuracy) forKey: @"heading_accuracy"]; } if(@available(iOS 15.0, macOS 12.0, *)) { diff --git a/geolocator_apple/pubspec.yaml b/geolocator_apple/pubspec.yaml index c5f64677b..e79f868a5 100644 --- a/geolocator_apple/pubspec.yaml +++ b/geolocator_apple/pubspec.yaml @@ -2,7 +2,7 @@ name: geolocator_apple description: Geolocation Apple plugin for Flutter. This plugin provides the Apple implementation for the geolocator. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator_apple issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen -version: 2.3.4 +version: 2.3.5 environment: sdk: ">=2.15.0 <4.0.0"