[Bug]: System Settings Page should not be opened after permissions were successfully granted
nZeus opened this issue · comments
Component/Nuget
GPS or Geofencing (Shiny.Locations)
What operating system(s) are effected?
- iOS (13+ supported)
- Mac Catalyst
- Android (8+ supported)
- Windows (.NET 7 Target - only Core is currently supported, BLE is coming)
Version(s) of Operation Systems
Android 13
Hosting Model
- MAUI
- Native/Classic Xamarin
- Manual
Steps To Reproduce
Hello!
In our app we need to get permissions to read GPS data.
We use IGpsManager
class for that:
var result = await _gpsManager.RequestAccess(GpsRequest.Realtime(true));
When we do this the user gets this popup, which is indeed what we want:
Once user grants access, the system settings page is opened for some reason...
The system Settings page should not be opened, how can we avoid it?
we also noticed that the Settings page is opened when we start listening (await _gpsManager.StartListener(GpsRequest.Realtime(true))
)
Expected Behavior
The system Settings page should not be opened
Actual Behavior
The system Settings page is opened
Exception or Log output
Details
2023-10-25 10:05:21.700 1116-1116 TaplEvents com...le.android.apps.nexuslauncher D TIS / TouchInteractionService.onInputEvent: MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=513.9624, y[0]=1408.9417, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=92327691, downTime=92327691, deviceId=3, source=0x5002, displayId=0, eventId=591752454 }
2023-10-25 10:05:21.737 13892-13921 EGL_emulation com.sensetech.mobile D app_time_stats: avg=661.01ms min=14.44ms max=10974.94ms count=17
2023-10-25 10:05:21.742 410-457 TransactionTracing pid-410 W Could not find layer id -1
2023-10-25 10:05:21.806 1116-1116 TaplEvents com...le.android.apps.nexuslauncher D TIS / TouchInteractionService.onInputEvent: MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=513.9624, y[0]=1408.9417, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=92327803, downTime=92327691, deviceId=3, source=0x5002, displayId=0, eventId=535199651 }
2023-10-25 10:05:21.863 587-3313 ActivityTaskManager system_process I START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.google.android.permissioncontroller cmp=com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.GrantPermissionsActivity (has extras)} from uid 10187
2023-10-25 10:05:21.879 1515-1515 GoogleInpu...hodService com...gle.android.inputmethod.latin I GoogleInputMethodService.onFinishInputView():2266
2023-10-25 10:05:21.880 1515-1515 TooltipLifecycleManager com...gle.android.inputmethod.latin W TooltipLifecycleManager.dismissTooltips():159 Tooltip with id spell_check_add_to_dictionary not found in tooltipManager.
2023-10-25 10:05:21.884 587-2021 ActivityTaskManager system_process W Tried to set launchTime (0) < mLastActivityLaunchTime (92295800)
2023-10-25 10:05:21.925 4296-4296 AutofillManager com....android.permissioncontroller D Fill dialog is enabled:false, hints=[password, passwordAuto, creditCardNumber, creditCardSecurityCode, creditCardExpirationDate]
2023-10-25 10:05:21.941 587-3313 CoreBackPreview system_process D Window{4850a3 u0 com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.GrantPermissionsActivity}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.IOnBackInvokedCallback$Stub$Proxy@f2d3759, mPriority=0}
2023-10-25 10:05:21.959 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f55970
2023-10-25 10:05:21.959 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761efc810
2023-10-25 10:05:21.979 587-604 ActivityTaskManager system_process I Displayed com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.GrantPermissionsActivity: +91ms
2023-10-25 10:05:22.183 782-1014 EGL_emulation com.android.systemui D app_time_stats: avg=498.96ms min=13.43ms max=28952.68ms count=60
2023-10-25 10:05:22.192 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f55610
2023-10-25 10:05:22.392 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761ef3bd0
2023-10-25 10:05:22.392 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761ef3bd0
2023-10-25 10:05:22.643 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761ef6c90
2023-10-25 10:05:23.195 782-1014 EGL_emulation com.android.systemui D app_time_stats: avg=17.08ms min=10.29ms max=33.15ms count=59
2023-10-25 10:05:28.978 1515-1598 VoiceInput...gerWrapper com...gle.android.inputmethod.latin I VoiceInputManagerWrapper.shutdownVoiceInternal():95 shutdownVoiceInternal()
2023-10-25 10:05:30.983 835-1104 bluetooth com.android.bluetooth I packages/modules/Bluetooth/system/gd/hci/le_address_manager.cc:526 OnCommandComplete: Received command complete with op_code LE_SET_RANDOM_ADDRESS
2023-10-25 10:05:30.984 835-1104 bluetooth com.android.bluetooth I packages/modules/Bluetooth/system/gd/hci/le_address_manager.cc:545 OnCommandComplete: update random address : 64:9a:0f:4a:4a:37
2023-10-25 10:05:31.906 1515-1598 ProtoXDBBufferWrapper com...gle.android.inputmethod.latin I ProtoXDBBufferWrapper.flushToStorage():153 Flushed 17 data item(s) to storage.
2023-10-25 10:05:37.662 1116-1116 TaplEvents com...le.android.apps.nexuslauncher D TIS / TouchInteractionService.onInputEvent: MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=483.96973, y[0]=1438.9343, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=92343656, downTime=92343656, deviceId=3, source=0x5002, displayId=0, eventId=156131612 }
2023-10-25 10:05:37.796 1116-1116 TaplEvents com...le.android.apps.nexuslauncher D TIS / TouchInteractionService.onInputEvent: MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=483.96973, y[0]=1438.9343, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=92343791, downTime=92343656, deviceId=3, source=0x5002, displayId=0, eventId=342177992 }
2023-10-25 10:05:37.801 4296-4296 GrantPermi...sViewModel com....android.permissioncontroller V Logged buttons presented and clicked permissionGroupName=android.permission-group.LOCATION uid=10187 selectedLocations=0 package=com.sensetech.mobile presentedButtons=52 clickedButton=4 sessionId=-2417591843531571155 targetSdk=33
2023-10-25 10:05:37.811 4296-4296 GrantPermi...sViewModel com....android.permissioncontroller V Permission grant result requestId=-2417591843531571155 callingUid=10187 callingPackage=com.sensetech.mobile permission=android.permission.ACCESS_COARSE_LOCATION isImplicit=false result=4
2023-10-25 10:05:37.811 4296-4296 GrantPermi...sViewModel com....android.permissioncontroller V Permission grant result requestId=-2417591843531571155 callingUid=10187 callingPackage=com.sensetech.mobile permission=android.permission.ACCESS_FINE_LOCATION isImplicit=false result=4
2023-10-25 10:05:37.841 410-457 TransactionTracing pid-410 W Could not find layer id -1
2023-10-25 10:05:37.860 587-1927 ActivityTaskManager system_process I START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.google.android.permissioncontroller cmp=com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.GrantPermissionsActivity (has extras)} from uid 10187
2023-10-25 10:05:37.909 587-1927 ActivityTaskManager system_process W Tried to set launchTime (0) < mLastActivityLaunchTime (92327882)
2023-10-25 10:05:37.921 4296-4296 AutofillManager com....android.permissioncontroller D Fill dialog is enabled:false, hints=[password, passwordAuto, creditCardNumber, creditCardSecurityCode, creditCardExpirationDate]
2023-10-25 10:05:37.924 1515-1515 GoogleInpu...hodService com...gle.android.inputmethod.latin I GoogleInputMethodService.onFinishInput():3220
2023-10-25 10:05:37.924 1515-1515 GoogleInpu...hodService com...gle.android.inputmethod.latin I GoogleInputMethodService.updateDeviceLockedStatus():2114 repeatCheckTimes = 0, unlocked = true
2023-10-25 10:05:37.924 1515-1515 GoogleInpu...hodService com...gle.android.inputmethod.latin I GoogleInputMethodService.onStartInput():1919 onStartInput(EditorInfo{inputType=0x0(NULL) imeOptions=0x0 privateImeOptions=null actionName=UNSPECIFIED actionLabel=null actionId=0 initialSelStart=-1 initialSelEnd=-1 initialCapsMode=0x0 hintText=null label=null packageName=com.sensetech.mobile fieldId=-1 fieldName=null extras=null}, false)
2023-10-25 10:05:37.925 1515-1515 GoogleInpu...hodService com...gle.android.inputmethod.latin I GoogleInputMethodService.updateDeviceLockedStatus():2114 repeatCheckTimes = 2, unlocked = true
2023-10-25 10:05:37.930 587-3314 ActivityTaskManager system_process I START u0 {act=android.intent.action.MANAGE_APP_PERMISSION flg=0x8000 cmp=com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.ManagePermissionsActivity (has extras)} from uid 10162
2023-10-25 10:05:37.932 13892-13921 EGL_emulation com.sensetech.mobile D app_time_stats: avg=311.43ms min=8.47ms max=15339.31ms count=52
2023-10-25 10:05:37.937 587-2295 CoreBackPreview system_process D Window{7d465c u0 com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.GrantPermissionsActivity}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.IOnBackInvokedCallback$Stub$Proxy@1c94a3a, mPriority=0}
2023-10-25 10:05:37.938 587-1927 ActivityTaskManager system_process W Tried to set launchTime (0) < mLastActivityLaunchTime (92343907)
2023-10-25 10:05:37.990 4296-4296 AutofillManager com....android.permissioncontroller D Fill dialog is enabled:false, hints=[password, passwordAuto, creditCardNumber, creditCardSecurityCode, creditCardExpirationDate]
2023-10-25 10:05:38.001 587-1927 CoreBackPreview system_process D Window{b2a3ae1 u0 com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.ManagePermissionsActivity}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.IOnBackInvokedCallback$Stub$Proxy@3fb96c7, mPriority=0}
2023-10-25 10:05:38.003 587-3314 CoreBackPreview system_process D Window{4850a3 u0 com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.GrantPermissionsActivity}: Setting back callback null
2023-10-25 10:05:38.003 587-1927 InputManager-JNI system_process W Input channel object '4850a3 com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.GrantPermissionsActivity (client)' was disposed without first being removed with the input manager!
2023-10-25 10:05:38.025 410-457 TransactionTracing pid-410 W Could not find layer id -1
2023-10-25 10:05:38.025 410-457 TransactionTracing pid-410 W Could not find layer id -1
2023-10-25 10:05:38.025 410-457 TransactionTracing pid-410 W Could not find layer id -1
2023-10-25 10:05:38.025 410-457 TransactionTracing pid-410 W Could not find layer id -1
2023-10-25 10:05:38.025 410-457 TransactionTracing pid-410 W Could not find layer id -1
2023-10-25 10:05:38.026 4296-5776 Parcel com....android.permissioncontroller W Expecting binder but got null!
2023-10-25 10:05:38.033 587-604 ActivityTaskManager system_process I Displayed com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.ManagePermissionsActivity: +172ms
2023-10-25 10:05:38.041 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f54f50
2023-10-25 10:05:38.056 587-6431 Parcel system_process W Expecting binder but got null!
2023-10-25 10:05:38.057 587-6431 Parcel system_process W Expecting binder but got null!
2023-10-25 10:05:38.058 410-457 TransactionTracing pid-410 W Could not find layer id -1
2023-10-25 10:05:38.064 587-6431 Parcel system_process W Expecting binder but got null!
2023-10-25 10:05:38.075 410-457 TransactionTracing pid-410 W Could not find layer id -1
2023-10-25 10:05:38.091 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f555b0
2023-10-25 10:05:38.091 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761ef6c90
2023-10-25 10:05:38.145 1515-1515 GoogleInpu...hodService com...gle.android.inputmethod.latin I GoogleInputMethodService.onFinishInput():3220
2023-10-25 10:05:38.145 1515-1515 GoogleInpu...hodService com...gle.android.inputmethod.latin I GoogleInputMethodService.updateDeviceLockedStatus():2114 repeatCheckTimes = 0, unlocked = true
2023-10-25 10:05:38.145 1515-1515 GoogleInpu...hodService com...gle.android.inputmethod.latin I GoogleInputMethodService.onStartInput():1919 onStartInput(EditorInfo{inputType=0x0(NULL) imeOptions=0x0 privateImeOptions=null actionName=UNSPECIFIED actionLabel=null actionId=0 initialSelStart=-1 initialSelEnd=-1 initialCapsMode=0x0 hintText=null label=null packageName=com.google.android.permissioncontroller fieldId=-1 fieldName=null extras=null}, false)
2023-10-25 10:05:38.146 1515-1515 GoogleInpu...hodService com...gle.android.inputmethod.latin I GoogleInputMethodService.updateDeviceLockedStatus():2114 repeatCheckTimes = 2, unlocked = true
2023-10-25 10:05:38.158 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f53330
2023-10-25 10:05:38.175 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f53e10
2023-10-25 10:05:38.175 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f5b850
2023-10-25 10:05:38.175 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f55070
2023-10-25 10:05:38.175 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f55070
2023-10-25 10:05:38.269 782-1014 EGL_emulation com.android.systemui D app_time_stats: avg=38227.31ms min=38227.31ms max=38227.31ms count=1
2023-10-25 10:05:38.278 782-1014 EGL_emulation com.android.systemui D app_time_stats: avg=837.94ms min=13.98ms max=14550.75ms count=18
2023-10-25 10:05:38.525 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f58310
2023-10-25 10:05:38.525 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f585b0
2023-10-25 10:05:38.525 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f55430
2023-10-25 10:05:38.525 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f54e90
2023-10-25 10:05:38.525 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f5aa10
2023-10-25 10:05:38.525 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f5ad10
2023-10-25 10:05:38.525 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f5ad10
2023-10-25 10:05:38.541 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f56ab0
2023-10-25 10:05:38.554 587-1927 AutofillSession system_process D Set the response has expired.
2023-10-25 10:05:38.554 587-1927 Presentati...ventLogger system_process W Shouldn't be logging AutofillPresentationEventReported again for same event
2023-10-25 10:05:38.608 410-457 TransactionTracing pid-410 W Could not find layer handle 0xb400007761f57c50
2023-10-25 10:05:39.296 782-1014 EGL_emulation com.android.systemui D app_time_stats: avg=16.64ms min=14.06ms max=20.62ms count=61
2023-10-25 10:05:39.608 410-457 TransactionTracing pid-410 W Could not find layer id -1
2023-10-25 10:05:39.615 4296-5776 EGL_emulation com....android.permissioncontroller D app_time_stats: avg=113.64ms min=7.03ms max=1351.28ms count=14
Code Sample
var result = await _gpsManager.RequestAccess(GpsRequest.Realtime(true));
Code of Conduct
- I have supplied a reproducible sample that is NOT FROM THE SHINY SAMPLES!
- I am a Sponsor OR I am using the LATEST stable/beta version from nuget (v3.0 stable - ALPHAS are not taking issues - Sponsors can still send v2 issues)
- I am Sponsor OR My GitHub account is 30+ days old
- I understand that if I am checking these boxes and I am not actually following what they are saying, I will be removed from this repository!
One of these is for the background permissions. Notoriously and unfortunately, background modes have not worked without the usual coarse/precision request first.
I'm open to suggestions as I've been through a ton of use-cases and devices for this.
I experimented yesterday with the Xamarin Essentials implementation - that one doesn't open the "settings" page:
var request = new GeolocationRequest(GeolocationAccuracy.Best, TimeSpan.FromSeconds(10));
var location = await Geolocation.GetLocationAsync(request, CancellationToken.None);
But I would prefer to use Shiny library for that as it better does background services.
I don't understand why the "settings" page is opened when using the IGpsManager
..
Also, that confuses me even more:
If I try MAUI version (Shiny.Locations v3), then it doesn't open the settings page, but I couldn't find how to use background reading in v3 (the UseGps<>
was removed, I guess)
UPD. Oh, UseGps<>
became AddGps<>
, good. So, I tested v3 and it doesn't open the settings page, even if the background reader is enabled 👍
But, I don't know how to upgrade from v2 to v3... Things (like ShinyStartup and ShinyHost) have changed a lot...
I don't understand why the "settings" page is opened when using the IGpsManager..
Please read my previous response. It was what I tested. It was changed in v3 because foreground services didn't require the background manifest permission.
But, I don't know how to upgrade from v2 to v3... Things (like ShinyStartup and ShinyHost) have changed a lot...
It's a major version. There are lots of samples and templates that can help.
Ok v3 is all I support right now and if you don't have the issue there - then all is good.
The breaking changes are not documented, unfortunately, so that was a painful upgrade. But (I think) I managed to upgrade it to v3.
if you don't have the issue there - then all is good.
I am not convinced that the issue is fixed.
It seems that the gps background service is broken - I only get the first reading, and never get future readings...
What I do is
if (_gpsManager.IsListening())
{
await _gpsManager.StopListener();
}
await _gpsManager.StartListener(GpsRequest.Realtime(true));
I have my delegate
public class MyGpsDelegate :
Shiny.Locations.IGpsDelegate,
Shiny.IAndroidForegroundServiceDelegate
{
public Task OnReading(GpsReading reading)
{
Log("============ Background === Lat: " + reading.Position.Latitude);
return Task.CompletedTask;
}
...
the OnReading is only hit once.
Do you know if I can be missing something?
Actually, even the Foreground tracking doesn't get the new readings
The breaking changes are not documented, unfortunately, so that was a painful upgrade. But (I think) I managed to upgrade it to v3.
This isn't a product. I do the best I can with the time I have. Documenting upgrade processes just isn't something I have the time to do.
It seems that the gps background service is broken - I only get the first reading, and never get future readings...
I'm using it actively in a couple of projects and its working fine for me. File a new issue with a full reproducible sample and I can take look.
I'm sorry, I didn't mean to blame you. The library is great, and I appreciate the work you do!
--
I kept testing and debugging, until once I got a new reading after ~ 5 minutes. Then I decided to try AndroidGpsRequest
with Interval set to 5 seconds instead of GpsRequest.Realtime(true)
and I do get new readings now!
When the app is minimized, I don't see the logs anymore, I'll keep investigating this one.
But I agree, this issue can be marked as resolved (by upgrading from 2.7 to 3.0). 👍
Thank you for your help and the time spent