Repository navigation
[Android] BlazorWebView: Resolve intent links through browsable activities - #38079
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 38079Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 38079" |
|
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.
🔵 Needs a closer look
Pull request overview
This PR updates Android BlazorWebView external-navigation handling so structured intent: and android-app: links are launched via normal browsable activity resolution (instead of honoring explicit component/selector targets from the URI), aligning behavior with how Android browsers resolve external intents.
Changes:
- Introduced
WebKitWebViewClient.CreateIntentForExternalUrito normalize/secure structured intent URIs by addingCATEGORY_BROWSABLE, clearing component/selector, and masking intent flags. - Added Android device tests and supporting test Activities to validate intent parsing and real activity resolution behavior (browsable vs non-browsable handlers, extras, and allowed flags).
- Granted
DeviceTestsaccess to internal APIs in the BlazorWebView Maui assembly for targeted intent creation testing.
File summaries
| File | Description |
|---|---|
| src/BlazorWebView/src/Maui/Android/WebKitWebViewClient.cs | Centralizes intent creation for external URIs and applies browsable-resolution normalization for intent:/android-app: schemes. |
| src/BlazorWebView/tests/DeviceTests/Elements/BlazorWebViewTests.ExternalNavigation.Android.cs | Adds Android device tests covering intent parsing, explicit-target stripping, flags masking, and resolution outcomes. |
| src/BlazorWebView/tests/DeviceTests/Platforms/Android/ExternalNavigationTestActivities.cs | Adds Android test Activities + launch monitor utilities used by the device tests to observe real resolution/launch behavior. |
| src/BlazorWebView/src/Maui/Properties/AssemblyInfo.cs | Adds InternalsVisibleTo to allow device tests to call internal intent creation logic. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 1 findings
See inline comments for details.
This comment has been minimized.
This comment has been minimized.
…ities Keep structured intent URI handling aligned with browser activity resolution by clearing explicit targets and limiting task flags while preserving registered handlers, routing data, and ordinary external URI behavior. Add Android device coverage for browsable and non-browsable handlers, explicit targets, structured URI fields, and common URI schemes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3
Wait for the marked test host document before executing external navigation instead of requiring Blazor initialization, so the activity-resolution path is exercised directly. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3
Use the DeviceTests platform suffix convention so the Android activity fixture is compiled only for the Android target. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3
6ccdfa9 to
e1db903
Compare
Skill Validation Results
✅ Skill Validation Results —
|
There was a problem hiding this comment.
🟢 Approval recommended
The implementation matches the stated intent-resolution behavior and is backed by focused Android device tests without any evident correctness issues in the reviewed diffs.
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 0 new
- Review effort level: Lite
…ities (#38079) <!-- 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 `BlazorWebView` parsed structured intent links and started the resulting `Intent` unchanged. This meant component, selector, and activity flag fields were treated as direct launch instructions rather than being resolved through browser-capable activities. This bug fix keeps `intent:` and `android-app:` links working while aligning their launch behavior with Android browser activity resolution: - Clears explicit component and selector targets. - Requires handlers to declare `CATEGORY_BROWSABLE`. - Limits activity flags to the set supported by Chromium for external intents. - Preserves package, custom action, data, categories, and typed extras. - Leaves ordinary `https:`, `tel:`, `mailto:`, and `geo:` links as `ACTION_VIEW` intents. Android device tests exercise real activity resolution for explicit targets, browsable and non-browsable handlers, structured routing data, typed extras, allowed activity flags, and common URI schemes. ### Testing - `MauiBlazorWebView.DeviceTests` on Android: 46 run, 42 passed, 0 failed, 4 ignored. - `MauiBlazorWebView.DeviceTests` iOS simulator build succeeded. - Android `Microsoft.AspNetCore.Components.WebView.Maui` build succeeded with CA1416 treated as an error. ### Issues Fixed N/A --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3
…38126) <!-- 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! Backports #38079 and #38078 to `inflight/candidate`. ### Changes - Backports the Android `BlazorWebView` intent-link resolution fix from #38079. - Backports the cross-platform `HybridWebView` message-origin validation fix from #38078. - Includes the device-test coverage from both source PRs. The landed squash commits were cherry-picked in landing order without conflicts. ### Validation - `dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug` - `dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -f net10.0-android -c Debug` - `dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -f net10.0-android -c Debug` - `dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -f net10.0-maccatalyst -c Debug` - Windows cross-build reaches the Windows-only `MakePri.exe` step and cannot complete on macOS. --------- Co-authored-by: Matthew Leibowitz <mattleibow@live.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3 Copilot-Session: a5d3b169-5cb5-440d-a4ba-22e39d132876
…38126) <!-- 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! Backports #38079 and #38078 to `inflight/candidate`. ### Changes - Backports the Android `BlazorWebView` intent-link resolution fix from #38079. - Backports the cross-platform `HybridWebView` message-origin validation fix from #38078. - Includes the device-test coverage from both source PRs. The landed squash commits were cherry-picked in landing order without conflicts. ### Validation - `dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug` - `dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -f net10.0-android -c Debug` - `dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -f net10.0-android -c Debug` - `dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -f net10.0-maccatalyst -c Debug` - Windows cross-build reaches the Windows-only `MakePri.exe` step and cannot complete on macOS. --------- Co-authored-by: Matthew Leibowitz <mattleibow@live.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3 Copilot-Session: a5d3b169-5cb5-440d-a4ba-22e39d132876
…ities (#38079) <!-- 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 `BlazorWebView` parsed structured intent links and started the resulting `Intent` unchanged. This meant component, selector, and activity flag fields were treated as direct launch instructions rather than being resolved through browser-capable activities. This bug fix keeps `intent:` and `android-app:` links working while aligning their launch behavior with Android browser activity resolution: - Clears explicit component and selector targets. - Requires handlers to declare `CATEGORY_BROWSABLE`. - Limits activity flags to the set supported by Chromium for external intents. - Preserves package, custom action, data, categories, and typed extras. - Leaves ordinary `https:`, `tel:`, `mailto:`, and `geo:` links as `ACTION_VIEW` intents. Android device tests exercise real activity resolution for explicit targets, browsable and non-browsable handlers, structured routing data, typed extras, allowed activity flags, and common URI schemes. ### Testing - `MauiBlazorWebView.DeviceTests` on Android: 46 run, 42 passed, 0 failed, 4 ignored. - `MauiBlazorWebView.DeviceTests` iOS simulator build succeeded. - Android `Microsoft.AspNetCore.Components.WebView.Maui` build succeeded with CA1416 treated as an error. ### Issues Fixed N/A --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3
…38126) <!-- 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! Backports #38079 and #38078 to `inflight/candidate`. ### Changes - Backports the Android `BlazorWebView` intent-link resolution fix from #38079. - Backports the cross-platform `HybridWebView` message-origin validation fix from #38078. - Includes the device-test coverage from both source PRs. The landed squash commits were cherry-picked in landing order without conflicts. ### Validation - `dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug` - `dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -f net10.0-android -c Debug` - `dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -f net10.0-android -c Debug` - `dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -f net10.0-maccatalyst -c Debug` - Windows cross-build reaches the Windows-only `MakePri.exe` step and cannot complete on macOS. --------- Co-authored-by: Matthew Leibowitz <mattleibow@live.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3 Copilot-Session: a5d3b169-5cb5-440d-a4ba-22e39d132876
…ities (#38079) <!-- 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 `BlazorWebView` parsed structured intent links and started the resulting `Intent` unchanged. This meant component, selector, and activity flag fields were treated as direct launch instructions rather than being resolved through browser-capable activities. This bug fix keeps `intent:` and `android-app:` links working while aligning their launch behavior with Android browser activity resolution: - Clears explicit component and selector targets. - Requires handlers to declare `CATEGORY_BROWSABLE`. - Limits activity flags to the set supported by Chromium for external intents. - Preserves package, custom action, data, categories, and typed extras. - Leaves ordinary `https:`, `tel:`, `mailto:`, and `geo:` links as `ACTION_VIEW` intents. Android device tests exercise real activity resolution for explicit targets, browsable and non-browsable handlers, structured routing data, typed extras, allowed activity flags, and common URI schemes. ### Testing - `MauiBlazorWebView.DeviceTests` on Android: 46 run, 42 passed, 0 failed, 4 ignored. - `MauiBlazorWebView.DeviceTests` iOS simulator build succeeded. - Android `Microsoft.AspNetCore.Components.WebView.Maui` build succeeded with CA1416 treated as an error. ### Issues Fixed N/A --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3
…ities (#38079) <!-- 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 `BlazorWebView` parsed structured intent links and started the resulting `Intent` unchanged. This meant component, selector, and activity flag fields were treated as direct launch instructions rather than being resolved through browser-capable activities. This bug fix keeps `intent:` and `android-app:` links working while aligning their launch behavior with Android browser activity resolution: - Clears explicit component and selector targets. - Requires handlers to declare `CATEGORY_BROWSABLE`. - Limits activity flags to the set supported by Chromium for external intents. - Preserves package, custom action, data, categories, and typed extras. - Leaves ordinary `https:`, `tel:`, `mailto:`, and `geo:` links as `ACTION_VIEW` intents. Android device tests exercise real activity resolution for explicit targets, browsable and non-browsable handlers, structured routing data, typed extras, allowed activity flags, and common URI schemes. ### Testing - `MauiBlazorWebView.DeviceTests` on Android: 46 run, 42 passed, 0 failed, 4 ignored. - `MauiBlazorWebView.DeviceTests` iOS simulator build succeeded. - Android `Microsoft.AspNetCore.Components.WebView.Maui` build succeeded with CA1416 treated as an error. ### Issues Fixed N/A --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3
…38126) <!-- 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! Backports #38079 and #38078 to `inflight/candidate`. ### Changes - Backports the Android `BlazorWebView` intent-link resolution fix from #38079. - Backports the cross-platform `HybridWebView` message-origin validation fix from #38078. - Includes the device-test coverage from both source PRs. The landed squash commits were cherry-picked in landing order without conflicts. ### Validation - `dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug` - `dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -f net10.0-android -c Debug` - `dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -f net10.0-android -c Debug` - `dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -f net10.0-maccatalyst -c Debug` - Windows cross-build reaches the Windows-only `MakePri.exe` step and cannot complete on macOS. --------- Co-authored-by: Matthew Leibowitz <mattleibow@live.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3 Copilot-Session: a5d3b169-5cb5-440d-a4ba-22e39d132876
…ities (#38079) <!-- 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 `BlazorWebView` parsed structured intent links and started the resulting `Intent` unchanged. This meant component, selector, and activity flag fields were treated as direct launch instructions rather than being resolved through browser-capable activities. This bug fix keeps `intent:` and `android-app:` links working while aligning their launch behavior with Android browser activity resolution: - Clears explicit component and selector targets. - Requires handlers to declare `CATEGORY_BROWSABLE`. - Limits activity flags to the set supported by Chromium for external intents. - Preserves package, custom action, data, categories, and typed extras. - Leaves ordinary `https:`, `tel:`, `mailto:`, and `geo:` links as `ACTION_VIEW` intents. Android device tests exercise real activity resolution for explicit targets, browsable and non-browsable handlers, structured routing data, typed extras, allowed activity flags, and common URI schemes. ### Testing - `MauiBlazorWebView.DeviceTests` on Android: 46 run, 42 passed, 0 failed, 4 ignored. - `MauiBlazorWebView.DeviceTests` iOS simulator build succeeded. - Android `Microsoft.AspNetCore.Components.WebView.Maui` build succeeded with CA1416 treated as an error. ### Issues Fixed N/A --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3
…38126) <!-- 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! Backports #38079 and #38078 to `inflight/candidate`. ### Changes - Backports the Android `BlazorWebView` intent-link resolution fix from #38079. - Backports the cross-platform `HybridWebView` message-origin validation fix from #38078. - Includes the device-test coverage from both source PRs. The landed squash commits were cherry-picked in landing order without conflicts. ### Validation - `dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug` - `dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -f net10.0-android -c Debug` - `dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -f net10.0-android -c Debug` - `dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -f net10.0-maccatalyst -c Debug` - Windows cross-build reaches the Windows-only `MakePri.exe` step and cannot complete on macOS. --------- Co-authored-by: Matthew Leibowitz <mattleibow@live.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3 Copilot-Session: a5d3b169-5cb5-440d-a4ba-22e39d132876
…ities (#38079) <!-- 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 `BlazorWebView` parsed structured intent links and started the resulting `Intent` unchanged. This meant component, selector, and activity flag fields were treated as direct launch instructions rather than being resolved through browser-capable activities. This bug fix keeps `intent:` and `android-app:` links working while aligning their launch behavior with Android browser activity resolution: - Clears explicit component and selector targets. - Requires handlers to declare `CATEGORY_BROWSABLE`. - Limits activity flags to the set supported by Chromium for external intents. - Preserves package, custom action, data, categories, and typed extras. - Leaves ordinary `https:`, `tel:`, `mailto:`, and `geo:` links as `ACTION_VIEW` intents. Android device tests exercise real activity resolution for explicit targets, browsable and non-browsable handlers, structured routing data, typed extras, allowed activity flags, and common URI schemes. ### Testing - `MauiBlazorWebView.DeviceTests` on Android: 46 run, 42 passed, 0 failed, 4 ignored. - `MauiBlazorWebView.DeviceTests` iOS simulator build succeeded. - Android `Microsoft.AspNetCore.Components.WebView.Maui` build succeeded with CA1416 treated as an error. ### Issues Fixed N/A --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3
…38126) <!-- 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! Backports #38079 and #38078 to `inflight/candidate`. ### Changes - Backports the Android `BlazorWebView` intent-link resolution fix from #38079. - Backports the cross-platform `HybridWebView` message-origin validation fix from #38078. - Includes the device-test coverage from both source PRs. The landed squash commits were cherry-picked in landing order without conflicts. ### Validation - `dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug` - `dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -f net10.0-android -c Debug` - `dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -f net10.0-android -c Debug` - `dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -f net10.0-maccatalyst -c Debug` - Windows cross-build reaches the Windows-only `MakePri.exe` step and cannot complete on macOS. --------- Co-authored-by: Matthew Leibowitz <mattleibow@live.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2a40510-33c4-4ff0-87f3-535f4a7e98a3 Copilot-Session: a5d3b169-5cb5-440d-a4ba-22e39d132876
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
BlazorWebViewparsed structured intent links and started the resultingIntentunchanged. This meant component, selector, and activity flag fields were treated as direct launch instructions rather than being resolved through browser-capable activities.This bug fix keeps
intent:andandroid-app:links working while aligning their launch behavior with Android browser activity resolution:CATEGORY_BROWSABLE.https:,tel:,mailto:, andgeo:links asACTION_VIEWintents.Android device tests exercise real activity resolution for explicit targets, browsable and non-browsable handlers, structured routing data, typed extras, allowed activity flags, and common URI schemes.
Testing
MauiBlazorWebView.DeviceTestson Android: 46 run, 42 passed, 0 failed, 4 ignored.MauiBlazorWebView.DeviceTestsiOS simulator build succeeded.Microsoft.AspNetCore.Components.WebView.Mauibuild succeeded with CA1416 treated as an error.Issues Fixed
N/A