dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.23k stars 1.76k forks source link

Bluetooth permission getting fails on Kindle Fire, works on Galaxy ZFlip #15063

Closed TAMHAN closed 1 year ago

TAMHAN commented 1 year ago

Description

Dear Ladies and Gentlemen, please allow me to report a weird incident. In advance, apologies for the weird formatting - I am an old coder with little experience with Git (CVS and MantisBT for me).

I have an application which me and my African-American client have successfully used on a variety of Z Flip handsets. All of them connect to a Bluetooth LE peripheral successfully. We also have a Kindle Fire running Android 9.0, and here the application perishes when asking for permissions.

Our manifest bears the following code: `<?xml version="1.0" encoding="utf-8"?>

` The actual permission access is made like so: ` namespace BopSyncNetPOC.Platforms.Android { public class BluetoothLEPermissions : Permissions.BasePlatformPermission { public override (string androidPermission, bool isRuntime)[] RequiredPermissions { get { return new List<(string androidPermission, bool isRuntime)> { (Manifest.Permission.Bluetooth, true), (Manifest.Permission.BluetoothAdmin, true), (Manifest.Permission.BluetoothScan, true), (Manifest.Permission.BluetoothConnect, true), (Manifest.Permission.AccessFineLocation, true), (Manifest.Permission.AccessCoarseLocation, true), //(Manifest.Permission.AccessBackgroundLocation, true), }.ToArray(); } } } } ` This is very weird. I reinstall the app on the Kindle, and click allow on the window. But the app still fails with the Permission denied: ` private async void OnScanClicked(object sender, EventArgs e) { #if ANDROID PermissionStatus status = await Permissions.CheckStatusAsync(); if (status == PermissionStatus.Granted) { goScan(); } else { await DisplayAlert("Permission required", "Google requires the declaration of this permission to perform a BTLE scan. Please grant it!", "OK"); status = await Permissions.RequestAsync(); if (status == PermissionStatus.Granted) { goScan(); } else { await DisplayAlert("Alert ", "Permission denied. Please reinstall application!", "OK"); } } #endif }` We are willing to help investigate this issue further. The Kindle Fire is in Budapest, Hungary, EUROPE if someone wants to visit and work with it. We are able to host a guest in modest (two star) accomodation in our office. Warm regards Ing. Tam HANNA, iA Eliana Fields ### Steps to Reproduce Please see above ### Link to public reproduction project repository na ### Version with bug 7.0 (current) ### Last version that worked well Unknown/Other ### Affected platforms Android ### Affected platform versions Android 9 on Kindle Fire ### Did you find any workaround? Not yet ### Relevant log output _No response_
ghost commented 1 year ago

Hi @TAMHAN. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

drasticactions commented 1 year ago

Can you try recreating this in a .NET Android application (dotnet new android) and see if it reproduces there? The likelihood that it's a MAUI UI Framework issue that could be solved in this repo is, IMO, quite slim. We should be able to verify that by making a new .NET Android app with no MAUI UI involved.

TAMHAN commented 1 year ago

Hello drastications and msftbot, thank you all so much for the kind response. And thanks Tim for e-mailing me.

The situation is weird. Kiddo and I changed the code like so: ` public class BluetoothLEPermissions : Permissions.BasePlatformPermission { public override (string androidPermission, bool isRuntime)[] RequiredPermissions { get { return new List<(string androidPermission, bool isRuntime)> {

            (Manifest.Permission.Bluetooth, true),
            (Manifest.Permission.BluetoothAdmin, true),
            (Manifest.Permission.BluetoothScan, true), //DISABLE FOR KFONWI
            (Manifest.Permission.BluetoothConnect, true),  //DISABLE FOR KFONWI
            (Manifest.Permission.AccessFineLocation, true),
            (Manifest.Permission.AccessCoarseLocation, true),  //DISABLE FOR KFONWI
            //(Manifest.Permission.AccessBackgroundLocation, true),

`

And then it worked on the Kindle, but not anymore on the Samsung. Probably we will just make a version dependent "hinge" thingy in the software, creating on demand two different permission lists and call it a day.

The core issue, IMHO is that MAUI has no Bluetooth LE API of its own.

So, as we say in Austria, if you take this discovery and 100000 EUR to the Tatra Banka in Gorkeho, you can open a bank account.

Nevertheless, it was a big honour to work with you on this, and apologies for time wasted.

Tam