Skip to content

Fix documentation errors in Android.App.PermissionUI (R060, pass 3) - #1941

Merged
jonathanpeppers merged 2 commits into
mainfrom
jonathanpeppers-review-permissionui-docs-r060
Nov 27, 2026
Merged

jonathanpeppers merged 2 commits into
mainfrom
jonathanpeppers-review-permissionui-docs-r060

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 273a2d823e7fa8d9fdedbcae063caae3016d32dc

Dimension Assessment Rationale
Change confidence 9.5/10 ↑ Fix 1 matches dotnet/android@9bc18c75 Object.cs:110-118 and JNIEnv.cs:360-372, 388-392.
↑ Fix 2 matches LocationButtonClientWrapper.java:116-118 and LocationButtonProviderFactory.java:307-326.
↑ XML parses; git diff --check passes; gemini-4-argon review of each fix commit found no issues.
↓ OpenPublishing.Build result for the new head not yet inspected.
Diagnosis confidence 9.5/10 ↑ ToJniObjectReferenceOptions sets Copy and SetHandle releases the passed handle.
↑ The dialog-start failure path calls onSessionError with no close() and no onSessionClosed.
Evidence fit 9/10 ↑ Both old texts state behavior that the pinned implementation does not do on all paths.

Scope

Pass-3 review item R060. All 249 AI-changed Docs channels (since 86f7744) in the 10 remaining Android.App.PermissionUI files were checked against pinned sources: source-37.2_r01.zip (android/app/permissionui/*.java, android/os/Parcelable.java) and dotnet/android@9bc18c75.

Result: 247 correct, 2 fixed, 0 uncertain.

The 10 Android.App.PersonalContext and Android.App.PersonalContext.Insight.Interaction files listed for this item no longer exist on main (removed by #1594). No action was taken for them.

Fixes

  1. LocationButtonProviderFactory(IntPtr, JniHandleOwnership), transfer param: "Specifies whether ownership of the JNI reference transfers to this instance." is wrong. JNIEnv.ToJniObjectReferenceOptions (dotnet/android@9bc18c75 JNIEnv.cs:388-392) always sets Copy, and Object.SetHandle (Object.cs:110-118) releases the passed handle by DeleteRef(value, transfer) (JNIEnv.cs:360-372). Changed to the established wording "Specifies how the runtime handles the JNI reference, including its release and peer registration."
  2. ILocationButtonClient.OnSessionError remarks: "The session is automatically closed before this callback is invoked" repeats LocationButtonClient.java:103, but the implementation does not do this on all paths. When startIntentSender fails, LocationButtonClientWrapper.java:116-118 calls onSessionError without close() or onSessionClosed. The connection-lost path closes first (LocationButtonProviderFactory.java:307-326), and the remote-error path removes the session record (LocationButtonClientWrapper.java:98). The text now says that the session is closed for those errors, and that it is not closed when the permission dialog cannot be started.

Kept as correct after review

"All callbacks on this interface are invoked serially..." (LocationButtonClient.java:33). The implementation decides this: the factory wraps the client executor in one SerialExecutor for each session (LocationButtonProviderFactory.java:131-132, 474-502), and all wrapper callbacks and the disconnect path use it (LocationButtonClientWrapper.java:75, 87, 99, 118). The raw executor is used only by reportSessionErrorSerialized (LocationButtonProviderFactory.java:251-254), for a request that never opened a session, so no other callback can overlap it.

Pass 2

#1749 changed "in to" to "into" in LocationButtonRequest.WriteToParcel. Checked: correct.

Source excerpts (source-37.2_r01.zip, SHA256 9d637c3a...4e84)

These excerpts let reviewers check the two lifecycle claims without access to the Android sources.

src/android/app/permissionui/LocationButtonClientWrapper.java:

96:     @Override
97:     public void onSessionError(@NonNull ParcelableException e) {
98:         mProvider.onSessionClosed(mClient);
99:         mClientExecutor.execute(() -> mClient.onSessionError(e.getCause()));
100:     }
...
114:         try {
115:             mActivity.startIntentSender(intentSender, null, 0, 0, 0, activityOptions.toBundle());
116:         } catch (IntentSender.SendIntentException e) {
117:             Log.e(LOG_TAG, "Couldn't open location button request dialog.", e);
118:             mClientExecutor.execute(() -> mClient.onSessionError(e.getCause()));
119:         }

src/android/app/permissionui/LocationButtonProviderFactory.java:

131:             LocationButtonClientWrapper clientWrapper = new LocationButtonClientWrapper(activity,
132:                     this, client, new SerialExecutor(clientExecutor));
...
251:         private void reportSessionErrorSerialized(OpenSessionRequest request,
252:                 Throwable cause) {
253:             request.mClientExecutor.execute(() -> request.mClientCallback.onSessionError(cause));
254:         }
...
307:         private void closeActiveSessionsAndNotifyClients(Throwable cause) {
...
315:                 try {
316:                     sessionWrapper.locationButtonSession.close();
317:                 } catch (RemoteException e) {
318:                     // ignore the error.
319:                 }
320:                 sessionWrapper.clientExecutor.execute(() -> client.onSessionError(cause));
...
474:     private static class SerialExecutor implements Executor {
...
484:         public synchronized void execute(Runnable r) {
485:             mTasks.add(() -> {
486:                 try {
487:                     r.run();
488:                 } finally {
489:                     scheduleNext();
490:                 }
491:             });
492:             if (mActive == null) {
493:                 scheduleNext();
494:             }
495:         }

Checks

  • XML parses; git diff --check passes; no new placeholders; CRLF kept.
  • gemini-4-argon rubber-duck review of each fix commit: no issues.

…rFactory (R060)

The activation constructor always copies the JNI reference and releases the passed handle as the transfer value specifies, so ownership does not transfer to the instance.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 27, 2026 04:40
@jonathanpeppers
jonathanpeppers enabled auto-merge (squash) November 27, 2026 04:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the documentation-only clarification of the JNI constructor’s transfer parameter.

No open issues 🎉

What changed in this PR

Corrects the JNI constructor documentation for LocationButtonProviderFactory in the Android API reference. This is a documentation-only change; API behavior is unchanged.

Changes:

  • Replaces ownership-transfer wording with a description covering JNI reference release and peer registration.
File Description
docs/​xml/​Android.App.PermissionUI/​LocationButtonProviderFactory.xml Clarifies the constructor’s transfer parameter description.

Review effort: Balanced

LocationButtonClientWrapper reports a dialog start failure through onSessionError without closing the session, so the remarks no longer say the session is always closed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Unavailable pinned Android wrapper and factory sources prevented independent verification of lifecycle ordering and error-specific session-closure guarantees.

No open issues 🎉

Review effort: Balanced

@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@jonathanpeppers
jonathanpeppers requested a balanced review from Copilot and removed request for dalexsoto November 27, 2026 05:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the documentation-only clarifications.

No open issues 🎉

Review effort: Balanced

@dalexsoto

Copy link
Copy Markdown
Member

In response to @jonathanpeppers's request: I verified the JNI transfer documentation against the handle-copy/release and peer-registration implementation. I still need the Android 37.2 implementation of LocationButtonClientWrapper.java (lines 96-119) and LocationButtonProviderFactory.java (lines 131-132, 251-254, 307-326 and 474-495) to verify the OnSessionError session-lifetime wording. The AOSP fetch returned HTTP 403; the archived GitHub mirror returns null for both files and has no Android 17 tags. This is a reviewer coverage gap, not a defect identified in your PR. The session-lifetime review remains pending; I am not treating the source-access failure as a blocking finding.

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed both documentation changes and their binding/runtime context. The JNI ownership parameter now describes reference release and peer registration accurately. The OnSessionError clarification matches the Android 37.2 implementation: remote/connection failures close the session, while a dialog-start failure reports the error without closing it. No blocking issues found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants