Add EnableOnBackInvokedCallback property to ApplicationAttribute - #11307
Conversation
Agent-Logs-Url: https://github.com/dotnet/android/sessions/04dfc86c-5088-4d18-a35e-8e0ea12a2f3a Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
|
/review |
|
✅ Android PR Reviewer completed successfully! |
There was a problem hiding this comment.
Pull request overview
This PR adds EnableOnBackInvokedCallback to Android.App.ApplicationAttribute so consumers can generate android:enableOnBackInvokedCallback="true" on the <application> element in the produced Android manifest, aligning ApplicationAttribute capabilities with the existing ActivityAttribute support.
Changes:
- Introduce
public bool EnableOnBackInvokedCallback { get; set; }onApplicationAttribute. - Add manifest mapping for
EnableOnBackInvokedCallbackto theApplicationAttributemapping table so it emitsandroid:enableOnBackInvokedCallback.
There was a problem hiding this comment.
@copilot
Summary: The intent of this PR is correct — android:enableOnBackInvokedCallback is a valid <application> attribute per [Android docs]((developer.android.com/redacted), and it should be exposed on ApplicationAttribute. However, the implementation approach needs to change.
| Severity | Count | Details |
|---|---|---|
| ❌ Error | 2 | Hand-edited auto-generated file; missing PublicAPI entries |
What to fix:
-
Don't hand-edit the auto-generated file.
ApplicationAttribute.csis generated bymanifest-attribute-codegen. The<auto-generated>header warns changes will be lost. Instead, updatebuild-tools/manifest-attribute-codegen/metadata.xml— changeapplication.enableOnBackInvokedCallbackfromvisible="false"totype="bool"(see inline comment for details), then re-run the codegen tool. -
Add PublicAPI entries. The new property needs to be listed in
PublicAPI.Unshipped.txtfor each API level, or the public API analyzer will fail the build.
Generated by Android PR Reviewer for issue #11307 · ● 2.6M
- Update metadata.xml: set application.enableOnBackInvokedCallback to type="bool" (was visible="false") so the next codegen run preserves the attribute - Add PublicAPI.Unshipped.txt entries for all API levels - Note: full codegen regeneration skipped to avoid pulling in unrelated API 37 manifest-definition.xml changes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
6fd774f to
fd2645b
Compare
|
/review |
|
✅ Android PR Reviewer completed successfully! |
There was a problem hiding this comment.
✅ LGTM
Clean PR that correctly adds EnableOnBackInvokedCallback to ApplicationAttribute, matching the existing pattern on ActivityAttribute.
What's good:
- ✅ Metadata change in
metadata.xmlis the source-of-truth approach (previous review feedback addressed) - ✅ Generated
ApplicationAttribute.csmatches theActivityAttributepattern exactly — property and mapping entry both in correct alphabetical position - ✅ PublicAPI entries added for all API levels (API-35, API-36, API-36.1, API-37)
- ✅ CI is green (both
license/claanddotnet-androidAZDO build pass)
Issue counts: 0 ❌ | 0
The only minor suggestion is the PublicAPI entry ordering in the API-36 unshipped file (entries appended at end instead of sorted position). Not blocking.
Generated by Android PR Reviewer for issue #11307 · ● 2.2M
| Android.App.ApplicationAttribute.EnableOnBackInvokedCallback.get -> bool | ||
| Android.App.ApplicationAttribute.EnableOnBackInvokedCallback.set -> void |
There was a problem hiding this comment.
🤖 💡 Code organization — These entries are appended after the Java.Util.* entries, breaking the alphabetical ordering that the rest of the file follows. Android.App.ApplicationAttribute should sort before Java.*.
Not a functional issue (the PublicAPI analyzer doesn't require ordering), but keeping the file sorted makes diffs cleaner and avoids merge conflicts.
Rule: Minimal diffs (Postmortem #36)
ApplicationAttributeis missingEnableOnBackInvokedCallback, which is already present onActivityAttribute. This prevents settingandroid:enableOnBackInvokedCallbackat the<application>level in the manifest — a valid attribute per Android docs.EnableOnBackInvokedCallbackbool property toApplicationAttributeUsers can now write:
which generates
android:enableOnBackInvokedCallback="true"on the<application>element inAndroidManifest.xml.