From 32b2b0380e0594b59fd5fcf3b10015be7433bf8b Mon Sep 17 00:00:00 2001 From: kirill <63228361+kirill-21@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:17:14 -0700 Subject: [PATCH 1/8] Update permission_handler_windows_plugin.cpp Fixed https://github.com/Baseflow/flutter-permission-handler/issues/1388 --- .../windows/permission_handler_windows_plugin.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/permission_handler_windows/windows/permission_handler_windows_plugin.cpp b/permission_handler_windows/windows/permission_handler_windows_plugin.cpp index 4b4d6d184..778ee65cf 100644 --- a/permission_handler_windows/windows/permission_handler_windows_plugin.cpp +++ b/permission_handler_windows/windows/permission_handler_windows_plugin.cpp @@ -87,10 +87,14 @@ void PermissionHandlerWindowsPlugin::RegisterWithRegistrar( } PermissionHandlerWindowsPlugin::PermissionHandlerWindowsPlugin(){ - m_positionChangedRevoker = geolocator.PositionChanged(winrt::auto_revoke, - [this](Geolocator const& geolocator, PositionChangedEventArgs e) - { - }); + try { + m_positionChangedRevoker = geolocator.PositionChanged(winrt::auto_revoke, + [this](Geolocator const& geolocator, PositionChangedEventArgs e) + { + }); + } catch (...) { + /* Do nothing */ + } } PermissionHandlerWindowsPlugin::~PermissionHandlerWindowsPlugin() = default; From 248e9d9516aaee81f1928b72dda95a8bfdabfb20 Mon Sep 17 00:00:00 2001 From: kirill <63228361+kirill-21@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:17:56 -0700 Subject: [PATCH 2/8] Update pubspec.yaml Bumped version --- permission_handler_windows/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/permission_handler_windows/pubspec.yaml b/permission_handler_windows/pubspec.yaml index f5553e0d6..3495a07b7 100644 --- a/permission_handler_windows/pubspec.yaml +++ b/permission_handler_windows/pubspec.yaml @@ -1,6 +1,6 @@ name: permission_handler_windows description: Permission plugin for Flutter. This plugin provides the Windows API to request and check permissions. -version: 0.2.1 +version: 0.2.2 homepage: https://github.com/baseflow/flutter-permission-handler flutter: From 8a74cc8d7a43617a142a545fa1be9272f83f742d Mon Sep 17 00:00:00 2001 From: kirill <63228361+kirill-21@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:18:38 -0700 Subject: [PATCH 3/8] Update CHANGELOG.md --- permission_handler_windows/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/permission_handler_windows/CHANGELOG.md b/permission_handler_windows/CHANGELOG.md index 91c2f5049..88a17aa4e 100644 --- a/permission_handler_windows/CHANGELOG.md +++ b/permission_handler_windows/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.2.2 +* Fixed crashing issue on early windows 10 machines (https://github.com/Baseflow/flutter-permission-handler/issues/1388) + ## 0.2.1 * Updates the dependency on `permission_handler_platform_interface` to version 4.1.0 (SiriKit support is only available for iOS and macOS). From d6a60b025d00895e5ab47bc240390b7cd38631ea Mon Sep 17 00:00:00 2001 From: kirill <63228361+kirill-21@users.noreply.github.com> Date: Fri, 27 Sep 2024 11:26:54 -0700 Subject: [PATCH 4/8] Update permission_handler_windows_plugin.cpp --- .../windows/permission_handler_windows_plugin.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/permission_handler_windows/windows/permission_handler_windows_plugin.cpp b/permission_handler_windows/windows/permission_handler_windows_plugin.cpp index 778ee65cf..dc6842b49 100644 --- a/permission_handler_windows/windows/permission_handler_windows_plugin.cpp +++ b/permission_handler_windows/windows/permission_handler_windows_plugin.cpp @@ -191,7 +191,11 @@ winrt::fire_and_forget PermissionHandlerWindowsPlugin::IsBluetoothServiceEnabled void PermissionHandlerWindowsPluginRegisterWithRegistrar( FlutterDesktopPluginRegistrarRef registrar) { - PermissionHandlerWindowsPlugin::RegisterWithRegistrar( + try { + PermissionHandlerWindowsPlugin::RegisterWithRegistrar( PluginRegistrarManager::GetInstance() ->GetRegistrar(registrar)); + } catch (...) { + /* Do nothing */ + } } From cfa14cc4c0f594c71b0ad6352b573372b7480882 Mon Sep 17 00:00:00 2001 From: krll-kov <63228361+krll-kov@users.noreply.github.com> Date: Thu, 6 Nov 2025 13:17:19 +0100 Subject: [PATCH 5/8] Fixed network lag spikes --- .../permission_handler_windows_plugin.cpp | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/permission_handler_windows/windows/permission_handler_windows_plugin.cpp b/permission_handler_windows/windows/permission_handler_windows_plugin.cpp index dc6842b49..74a577e8d 100644 --- a/permission_handler_windows/windows/permission_handler_windows_plugin.cpp +++ b/permission_handler_windows/windows/permission_handler_windows_plugin.cpp @@ -65,7 +65,6 @@ class PermissionHandlerWindowsPlugin : public Plugin { winrt::fire_and_forget IsBluetoothServiceEnabled(std::unique_ptr> result); winrt::Windows::Devices::Geolocation::Geolocator geolocator; - winrt::Windows::Devices::Geolocation::Geolocator::PositionChanged_revoker m_positionChangedRevoker; }; // static @@ -87,14 +86,17 @@ void PermissionHandlerWindowsPlugin::RegisterWithRegistrar( } PermissionHandlerWindowsPlugin::PermissionHandlerWindowsPlugin(){ - try { - m_positionChangedRevoker = geolocator.PositionChanged(winrt::auto_revoke, - [this](Geolocator const& geolocator, PositionChangedEventArgs e) - { - }); - } catch (...) { - /* Do nothing */ - } +// Access should not be requested on app start before plugin is even used, this causes ping spikes +// and other issues +// +// try { +// m_positionChangedRevoker = geolocator.PositionChanged(winrt::auto_revoke, +// [this](Geolocator const& geolocator, PositionChangedEventArgs e) +// { +// }); +// } catch (...) { +// /* Do nothing */ +// } } PermissionHandlerWindowsPlugin::~PermissionHandlerWindowsPlugin() = default; From a157fe09443f46030634d476e8a2fbc140ab61ba Mon Sep 17 00:00:00 2001 From: krll-kov <63228361+krll-kov@users.noreply.github.com> Date: Thu, 6 Nov 2025 13:33:34 +0100 Subject: [PATCH 6/8] Lazy loading of geo-locator --- .../permission_handler_windows_plugin.cpp | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/permission_handler_windows/windows/permission_handler_windows_plugin.cpp b/permission_handler_windows/windows/permission_handler_windows_plugin.cpp index 74a577e8d..fcc96a40f 100644 --- a/permission_handler_windows/windows/permission_handler_windows_plugin.cpp +++ b/permission_handler_windows/windows/permission_handler_windows_plugin.cpp @@ -64,7 +64,14 @@ class PermissionHandlerWindowsPlugin : public Plugin { void IsLocationServiceEnabled(std::unique_ptr> result); winrt::fire_and_forget IsBluetoothServiceEnabled(std::unique_ptr> result); - winrt::Windows::Devices::Geolocation::Geolocator geolocator; + std::optional geolocator; + + winrt::Windows::Devices::Geolocation::Geolocator& GetGeolocator() { + if (!geolocator.has_value()) { + geolocator.emplace(); + } + return geolocator.value(); + } }; // static @@ -104,7 +111,7 @@ PermissionHandlerWindowsPlugin::~PermissionHandlerWindowsPlugin() = default; void PermissionHandlerWindowsPlugin::HandleMethodCall( const MethodCall<>& method_call, std::unique_ptr> result) { - + auto methodName = method_call.method_name(); if (methodName.compare("checkServiceStatus") == 0) { auto permission = (PermissionConstants::PermissionGroup)std::get(*method_call.arguments()); @@ -125,7 +132,7 @@ void PermissionHandlerWindowsPlugin::HandleMethodCall( } result->Success(EncodableValue((int)PermissionConstants::ServiceStatus::NOT_APPLICABLE)); - + } else if (methodName.compare("checkPermissionStatus") == 0) { result->Success(EncodableValue((int)PermissionConstants::PermissionStatus::GRANTED)); } else if (methodName.compare("requestPermissions") == 0) { @@ -137,7 +144,7 @@ void PermissionHandlerWindowsPlugin::HandleMethodCall( [](const EncodableValue& encoded) { return std::get(encoded); }); - + EncodableMap requestResults; for (int i=0;i> result) { - result->Success(EncodableValue((int)(geolocator.LocationStatus() != PositionStatus::NotAvailable + result->Success(EncodableValue((int)(GetGeolocator().LocationStatus() != PositionStatus::NotAvailable ? PermissionConstants::ServiceStatus::ENABLED : PermissionConstants::ServiceStatus::DISABLED))); } @@ -167,12 +174,12 @@ winrt::fire_and_forget PermissionHandlerWindowsPlugin::IsBluetoothServiceEnabled result->Success(EncodableValue((int)PermissionConstants::ServiceStatus::DISABLED)); co_return; } - + if (!btAdapter.IsCentralRoleSupported()) { result->Success(EncodableValue((int)PermissionConstants::ServiceStatus::DISABLED)); co_return; } - + auto radios = co_await Radio::GetRadiosAsync(); for (uint32_t i=0; i Date: Thu, 6 Nov 2025 17:17:22 +0100 Subject: [PATCH 7/8] Update CHANGELOG.md --- permission_handler_windows/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/permission_handler_windows/CHANGELOG.md b/permission_handler_windows/CHANGELOG.md index 88a17aa4e..e8dd7f2ef 100644 --- a/permission_handler_windows/CHANGELOG.md +++ b/permission_handler_windows/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.2.2 * Fixed crashing issue on early windows 10 machines (https://github.com/Baseflow/flutter-permission-handler/issues/1388) +* Fixed constant geo-location usage after app is started that caused lags for users with bad internet and always displayed app in taskbar +([https://github.com/Baseflow/flutter-permission-handler/issues/1388](https://github.com/Baseflow/flutter-permission-handler/issues/1394)) ## 0.2.1 From b78a4009dc932bbf47a675ba5a5f19d9e4fd9bdb Mon Sep 17 00:00:00 2001 From: "Kyrylo K." <63228361+krll-kov@users.noreply.github.com> Date: Thu, 6 Nov 2025 17:18:20 +0100 Subject: [PATCH 8/8] Fix changelog entry for geo-location issue --- permission_handler_windows/CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/permission_handler_windows/CHANGELOG.md b/permission_handler_windows/CHANGELOG.md index e8dd7f2ef..be80608a0 100644 --- a/permission_handler_windows/CHANGELOG.md +++ b/permission_handler_windows/CHANGELOG.md @@ -1,7 +1,6 @@ ## 0.2.2 * Fixed crashing issue on early windows 10 machines (https://github.com/Baseflow/flutter-permission-handler/issues/1388) -* Fixed constant geo-location usage after app is started that caused lags for users with bad internet and always displayed app in taskbar -([https://github.com/Baseflow/flutter-permission-handler/issues/1388](https://github.com/Baseflow/flutter-permission-handler/issues/1394)) +* Fixed constant geo-location usage after app is started that caused lags for users with bad internet and always displayed app in taskbar (https://github.com/Baseflow/flutter-permission-handler/issues/1394) ## 0.2.1