Skip to content

Add EnableOnBackInvokedCallback property to ApplicationAttribute - #11307

Merged
simonrozsival merged 3 commits into
mainfrom
copilot/add-enableonbackinvokedcallback-property
May 11, 2026
Merged

Add EnableOnBackInvokedCallback property to ApplicationAttribute#11307
simonrozsival merged 3 commits into
mainfrom
copilot/add-enableonbackinvokedcallback-property

Conversation

Copilot AI commented May 8, 2026

Copy link
Copy Markdown
Contributor

ApplicationAttribute is missing EnableOnBackInvokedCallback, which is already present on ActivityAttribute. This prevents setting android:enableOnBackInvokedCallback at the <application> level in the manifest — a valid attribute per Android docs.

  • Added EnableOnBackInvokedCallback bool property to ApplicationAttribute
  • Added corresponding manifest mapping entry in the static constructor

Users can now write:

[assembly: Application(EnableOnBackInvokedCallback = true)]

which generates android:enableOnBackInvokedCallback="true" on the <application> element in AndroidManifest.xml.

Agent-Logs-Url: https://github.com/dotnet/android/sessions/04dfc86c-5088-4d18-a35e-8e0ea12a2f3a

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot AI changed the title [WIP] Add EnableOnBackInvokedCallback property to ApplicationAttribute Add EnableOnBackInvokedCallback property to ApplicationAttribute May 8, 2026
Copilot AI requested a review from jonathanpeppers May 8, 2026 13:55
@jonathanpeppers
jonathanpeppers marked this pull request as ready for review May 8, 2026 15:01
Copilot AI review requested due to automatic review settings May 8, 2026 15:02
@jonathanpeppers

Copy link
Copy Markdown
Member

/review

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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; } on ApplicationAttribute.
  • Add manifest mapping for EnableOnBackInvokedCallback to the ApplicationAttribute mapping table so it emits android:enableOnBackInvokedCallback.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot ⚠️ Needs Changes — 2 issues found.

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:

  1. Don't hand-edit the auto-generated file. ApplicationAttribute.cs is generated by manifest-attribute-codegen. The <auto-generated> header warns changes will be lost. Instead, update build-tools/manifest-attribute-codegen/metadata.xml — change application.enableOnBackInvokedCallback from visible="false" to type="bool" (see inline comment for details), then re-run the codegen tool.

  2. Add PublicAPI entries. The new property needs to be listed in PublicAPI.Unshipped.txt for 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>
@jonathanpeppers
jonathanpeppers force-pushed the copilot/add-enableonbackinvokedcallback-property branch from 6fd774f to fd2645b Compare May 8, 2026 15:48
@jonathanpeppers

Copy link
Copy Markdown
Member

/review

@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label May 8, 2026
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM

Clean PR that correctly adds EnableOnBackInvokedCallback to ApplicationAttribute, matching the existing pattern on ActivityAttribute.

What's good:

  • ✅ Metadata change in metadata.xml is the source-of-truth approach (previous review feedback addressed)
  • ✅ Generated ApplicationAttribute.cs matches the ActivityAttribute pattern 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/cla and dotnet-android AZDO build pass)

Issue counts: 0 ❌ | 0 ⚠️ | 1 💡

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

Comment on lines +4378 to +4379
Android.App.ApplicationAttribute.EnableOnBackInvokedCallback.get -> bool
Android.App.ApplicationAttribute.EnableOnBackInvokedCallback.set -> void

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 💡 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)

@simonrozsival
simonrozsival merged commit 06d1de6 into main May 11, 2026
2 of 3 checks passed
@simonrozsival
simonrozsival deleted the copilot/add-enableonbackinvokedcallback-property branch May 11, 2026 07:20
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The EnableOnBackInvokedCallback property is missing on ApplicationAttribute (as opposed to ActivityAttribute)

4 participants