Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Windows shows app as constantly using the device's location #1394

Open
3 of 5 tasks
Chaphasilor opened this issue Oct 8, 2024 · 3 comments
Open
3 of 5 tasks

Comments

@Chaphasilor
Copy link

Chaphasilor commented Oct 8, 2024

Please check the following before submitting a new issue.

Please select affected platform(s)

  • Android
  • iOS
  • Windows

Steps to reproduce

  1. Add the package to pubspec.yaml
  2. Build and launch the app
  3. Windows shows the "Location in use by" taskbar icon and lists the flutter app

Related issues: #1289

Additional info:
The package is merely included in pubspec.yaml, but isn't actively included anywhere in the code. No location permissions are actively requested, nor needed. Still, as soon as the app is launched, Windows 11 shows the app as currently using the user's location.
This also happens when the app is packaged for Windows using msix package (following the official Flutter instructions). In the msix config, location capabilities are not even requested. I'm assuming this package might request these permissions anyway, overriding the capabilities specified in the msix config.

Expected results

  1. Location is not being used or accessed unless specifically requested

Actual results

  1. Location shows up as being requested at all times. Maybe it's not being used as all, just wrongly detected, but that should also not happen.

Code sample

Code sample
dependencies:
  flutter:
    sdk: flutter
  permission_handler: ^11.3.1

Screenshots or video

Screenshots or video demonstration

image

Version

11.3.1

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.24.3, on Microsoft Windows [Version 10.0.22631.4249], locale en-US)
    • Flutter version 3.24.3 on channel stable at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (4 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\Chaphasilor\AppData\Local\Android\sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)
    • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.11.4)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
    • Visual Studio Build Tools 2022 version 17.11.35312.102
    • Windows 10 SDK version 10.0.22621.0

[✓] Android Studio (version 2024.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)

[✓] VS Code (version 1.94.0)
    • VS Code at C:\Users\Chaphasilor\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.98.0

[✓] Connected device (2 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22631.4249]
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 129.0.2792.79

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
@leonsavvidi
Copy link

leonsavvidi commented Oct 10, 2024

Encountering the same issue when building for windows. No permissions were requested, yet windows displays that location is in use. Removing all code connected to permission handler does not help, only helps if you remove
permission_handler: ^11.3.1'; in the pubspec.yaml

@leonsavvidi
Copy link

PermissionHandlerWindowsPlugin::PermissionHandlerWindowsPlugin(){ m_positionChangedRevoker = geolocator.PositionChanged(winrt::auto_revoke, [this](Geolocator const& geolocator, PositionChangedEventArgs e) { }); }

Found the problem, when the cpp permission_handler plugin class is created during app start, it is getting access to the geolocator even before any app requests for permission are being made. (that's why only adding/removing into pubspec mattered, as it fired up during plugin registration) Commenting it out removes the windows notification that the app uses Location data, but most likely breaks the geolocation. This kind of code should be used after the permission is requested, not before even the main app starts.

@harshitappscrip
Copy link

I'm not using any location-related features in my app, yet my Windows app still accesses location data. I tried to replicate this issue in a fresh project with only the boilerplate code and the permission_handler package added to the pubspec, but I encountered the same problem.

I'm using latest version: 11.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants