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

Android shows a GPS precision popup #1391

Open
aweiand opened this issue Dec 12, 2024 · 9 comments
Open

Android shows a GPS precision popup #1391

aweiand opened this issue Dec 12, 2024 · 9 comments

Comments

@aweiand
Copy link

aweiand commented Dec 12, 2024

Your Environment

  • Plugin version: 4.16.5
  • Platform: Android
  • OS version: 11
  • Device manufacturer / model: Motorola
  • Flutter info (flutter doctor):
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 3.24.3, on macOS 13.7.1 22H221 darwin-x64, locale pt-BR)
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    [!] Xcode - develop for iOS and macOS (Xcode 15.1)
    ! CocoaPods 1.12.1 out of date (1.13.0 is recommended).
    CocoaPods is a package manager for iOS or macOS platform code.
    Without CocoaPods, plugins will not work on iOS or macOS.
    For more info, see https://flutter.dev/to/platform-plugins
    To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
    [✓] Chrome - develop for the web
    [✓] Android Studio (version 2024.1)
    [✓] VS Code (version 1.95.3)
    [✓] Connected device (4 available)
    ! Error: Browsing on the local area network for iPhone de Augusto. Ensure the device is unlocked and attached with a cable or associated with the
    same local area network as this Mac.
    The device must be opted into Developer Mode to connect wirelessly. (code -27)
    [✓] Network resources
    ! Doctor found issues in 1 category.
  • Plugin config:
  bg.Config(
      url: url,
      authorization: await bgAuth,
      headers: {
        'X-domain': _appProvider.domain,
        'authorization': accessToken,
      },
      desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
      notification: bg.Notification(
        title: "Puzzle",
        text: "Captura de Localização Ativa",
        channelName: "Captura de localização",
        smallIcon: "mipmap/ic_launcher_round",
        largeIcon: "mipmap/ic_launcher_foreground",
        sticky: true,
      ),
      distanceFilter: 10.0,
      isMoving: true,
      // disableElasticity: true
      stopOnTerminate: false,
      startOnBoot: true,
      autoSync: true,
      autoSyncThreshold: 80
      batchSync: true,
      // maxBatchSize: 50
      locationsOrderDirection: "ASC",
      maxDaysToPersist: 2,
      locationAuthorizationRequest: 'Always',
      backgroundPermissionRationale: bg.PermissionRationale(
          title:
              "Permitir que o XXXXXXX acesse a localização do dispositivo mesmo quanto está fechado e não em uso.",
          message:
              "Este aplicativo coleta dados de localização para cálculo de pagamento de KM.",
          positiveAction: 'Alterar para Sempre',
          negativeAction: 'Cancelar'),
      locationAuthorizationAlert: {
        "titleWhenNotEnabled": "A captura em segundo plano não está habilitada",
        "titleWhenOff": "A captura em segundo plano não está habilitada",
        "instructions":
            "Para usar o aplicativo em segundo plano, deves marcar sempre na caixa de seleção de permissão.",
        "cancelButton": "Cancelar",
        "settingsButton": "Configuração"
      },
      logMaxDays: 2,
      enableHeadless: true,
      // params: {"itinerary_id": 1},

      debug: Utils.isInDebugMode,
      reset: Utils.isInDebugMode,
      logLevel: (Utils.isInDebugMode
          ? bg.Config.LOG_LEVEL_VERBOSE
          : bg.Config.LOG_LEVEL_WARNING),
      // debug: true,
      // logLevel: bg.Config.LOG_LEVEL_VERBOSE,
    );

Expected Behavior

Run without any alerts.

Actual Behavior

Not open the alert message bellow:
image

Steps to Reproduce

  1. Just run the code as normal use.

Context

We are facing some issues with the Android requesting the change of GPS precision. But, we also knows the app granted all the permissions needed to work, and, the device has the precision enabled. Also, this popup message don't works, even we touch on activate/later, it appears again or don't go out.

Debug logs

We don't have a log, because is production app and cannot reproduce in debug mode

@aweiand aweiand changed the title REceiving Android shows a GPS precision popup Dec 12, 2024
@christocracy
Copy link
Member

Learn about this in the api docs Config.disableLocationAuthorizationAlert

@aweiand
Copy link
Author

aweiand commented Dec 12, 2024

ok, but, why prior this never occoured? We use the plugin almost a two years and just now this appears. We notice that was only in Motorola devices, with Android 11, that was strange, as we has almost 2k users and not all shows this screen. Again, we not modify configs before this dialogs starts opened.
The user confirm that don't change the permissions too.
We are trying to reproduce this on debug devices, but it was difficult.

@christocracy
Copy link
Member

After reading the api docs mentioned, do you now understand that this is a magic dialog produced automatically by the OS? The plug-in says to the OS “here’s the kind of location accuracy I require: go”. The OS then says “thanks, I’ll take it from here” and the dialog is shown if required (eg location disabled globally in device settings).

@christocracy
Copy link
Member

ok, but, why prior this never occoured?

No idea. This mechanism is completely handled by the OS. The plug-in merely says to the OS: “here’s what I need”.

The plug-in has used this mechanism for about 5 years and I don’t recall ever hearing of this problem.

@christocracy
Copy link
Member

This mechanism is actually handled by play-services-location (which I consider an extension of the OS). Therefore, its behaviour could change based upon the version of that dependency (see ext.playServicesLocationVersion in your Android/build.gradle).

search https://maven.google.com to learn about the available versions of play-services-location.

@aweiand
Copy link
Author

aweiand commented Dec 19, 2024

We update the plugin settings to disallow the popup (disableLocationAuthorizationAlert: true) and, only on motorola devices (g8/g10/g20, for example, but other too) running Andoid 11, we are still receiving this message, that causes the app won't be usable.
We are using playServicesLocationVersion = "21.1.0" (on Android/build.gradle).

@christocracy
Copy link
Member

reset: Utils.isInDebugMode,

When you use reset: false, you cause the plugin to ignore any changes you apply to .ready(config).

99% of use-cases do not require reset: false. That option was designed for me and my demo app.

@aweiand
Copy link
Author

aweiand commented Dec 19, 2024

We put this for development tests, because this, we use the Utils.isInDebugMode helper:

  static bool get isInDebugMode {
    bool inDebugMode = false;
    assert(inDebugMode = true);
    return inDebugMode;
  }

But, the issues occur in production mode, when the reset was not set.
You say, its not necessary to do this, even in development/test mode?

@christocracy
Copy link
Member

You do not even need to think about reset: false, ever.

If you are seeing that Dialog, then you are either:

  • A. Using reset: false.
  • B. Not setting disableLocationAuthorizationAlert: true.

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

2 participants