Skip to content

Fix documentation errors in Android.Security.Keystore and Android.Security.Net.Config (R116, pass 3) - #1995

Merged
jonathanpeppers merged 1 commit into
mainfrom
jonathanpeppers-review-security-keystore-netconfig-docs
Nov 28, 2026
Merged

jonathanpeppers merged 1 commit into
mainfrom
jonathanpeppers-review-security-keystore-netconfig-docs

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 34a270e25338195f235af3f076ab27d27ff0e7a2

Dimension Assessment Rationale
Change confidence 9/10 ↑ Each fix cites a pinned source line; all cref targets exist and are not obsolete.
↑ All changed XML parses; git diff --check is clean; gemini-4-argon review found no issues.
↓ SetMgf1Digests fix contradicts the @nullable annotation (implementation evidence used).

Pass-3 review item R116: 25 files in Android.Security.Keystore and Android.Security.Net.Config. Pinned sources: AOSP source-37.2_r01, dotnet/android@9bc18c75.

Fixes (12 channels)

  1. transfer param on 8 Throwable-derived exceptions (BackendBusy, KeyExpired, KeyNotYetValid, KeyPermanentlyInvalidated, SecureKeyImportUnavailable, StrongBoxUnavailable, UserNotAuthenticated, UserPresenceUnavailable). The old text said that transfer controls peer registration. That is true only for Java.Lang.Object. Throwable copies the reference and uses transfer only to release it (Throwable.cs:99-110). Wording as in Fix documentation errors in Android.Health.Connect (R093, pass 3) #1972. KeyInfo, KeyProperties and WrappedKeyEntry are Object-derived, so their text stays as it is.
  2. KeyStorePurpose.AgreeKey: changed the raw javax.crypto.KeyAgreement#init(java.security.Key) text to a cref to KeyAgreement.Init(IKey) (KeyProperties.java:115).
  3. KeyStoreSecurityLevel.UnknownSecure: changed the plain SECURITY_LEVEL_TRUSTED_ENVIRONMENT text to a cref to KeyStoreSecurityLevel.TrustedEnvironment (KeyProperties.java:869 {@link}).
  4. KeyProtection.Builder.SetMgf1Digests: changed "may be null" to "cannot be null". Set.of(mgf1Digests) (KeyProtection.java:802) throws NullPointerException for a null array. A C# null array goes to Java as JNI null.
  5. NetworkSecurityConfig.DomainEncryptionMode: changed the raw NetworkSecurityPolicy#getDomainEncryptionMode(String) text to a cref (API 37, not obsolete).

Uncertain / conflicts

  • SetMgf1Digests: the @Nullable annotation (KeyProtection.java:801) and the 37.2 reference say that null is permitted, but the r01 implementation throws. I fixed the text because the implementation decides behavior. I did not check r02.

Follow-ups (not changed)

  • The "every use" limit on biometric invalidation (KeyGenParameterSpec.Builder, KeyProtection.Builder) is narrower than KeyStore2ParameterUtils.java:260-265.
  • The setDevicePropertiesAttestationIncluded Javadoc names KeyGenerator.generateKey(), but the throw is in KeyPairGenerator.generateKeyPair.

Checks

  • Ledger: 631 channels, each with one row. 394 correct, 65 verbatim, 12 fixed, 149 deferred (boilerplate), 11 excluded.
  • All changed XML parses. git diff --check is clean.
  • gemini-4-argon rubber-duck review: no findings.

…(R116)

- Throwable-derived exception constructors: transfer controls release only.
- KeyStorePurpose.AgreeKey and KeyStoreSecurityLevel.UnknownSecure: use crefs.
- KeyProtection.Builder.SetMgf1Digests: Set.of rejects a null array.
- NetworkSecurityConfig.DomainEncryptionMode: replace raw Class#member text.

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

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 are identified for this documentation-only update to API descriptions and links.

No open issues 🎉

What changed in this PR

This documentation-only PR corrects API descriptions and links in Android.Security.Keystore and Android.Security.Net.Config, continuing the R116 pass-3 cleanup. It does not change runtime behavior.

Changes:

  • Corrects JNI reference-release wording for eight Throwable-derived exceptions, consistent with #1972.
  • Replaces three raw Java references with managed API links.
  • Documents that SetMgf1Digests rejects null, based on the pinned implementation despite conflicting upstream annotations.
File Description
docs/​xml/​Android.Security.Net.Config/​NetworkSecurityConfig.xml Links to the managed domain-encryption query.
docs/​xml/​Android.Security.Keystore/​UserPresenceUnavailableException.xml Corrects JNI reference-release wording.
docs/​xml/​Android.Security.Keystore/​UserNotAuthenticatedException.xml Corrects JNI reference-release wording.
docs/​xml/​Android.Security.Keystore/​StrongBoxUnavailableException.xml Corrects JNI reference-release wording.
docs/​xml/​Android.Security.Keystore/​SecureKeyImportUnavailableException.xml Corrects JNI reference-release wording.
docs/​xml/​Android.Security.Keystore/​KeyStoreSecurityLevel.xml Links to TrustedEnvironment.
docs/​xml/​Android.Security.Keystore/​KeyStorePurpose.xml Links to the managed KeyAgreement.Init overload.
docs/​xml/​Android.Security.Keystore/​KeyProtection+Builder.xml Changes mgf1Digests documentation to disallow null.
docs/​xml/​Android.Security.Keystore/​KeyPermanentlyInvalidatedException.xml Corrects JNI reference-release wording.
docs/​xml/​Android.Security.Keystore/​KeyNotYetValidException.xml Corrects JNI reference-release wording.
docs/​xml/​Android.Security.Keystore/​KeyExpiredException.xml Corrects JNI reference-release wording.
docs/​xml/​Android.Security.Keystore/​BackendBusyException.xml Corrects JNI reference-release wording.

Review effort: Balanced

@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto

Copy link
Copy Markdown
Member

In response to @jonathanpeppers's request: I still need to check the edited constructor remarks about the incoming JNI reference (transfer, particularly DoNotTransfer) against the binding ownership implementation, read the full material member context in all 12 changed files, and reconcile the target-branch changes. This is a reviewer coverage gap, not a defect identified in this PR. The setMgf1Digests null behavior in Android 15/16 and the three new cref targets have been checked.

@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.

I reviewed all 12 changed members at 34a270e against the current target 81f1249 (merge base aae7c2c). The 7 commits merged into the target since then don't touch these files or the cref targets.

  • transfer on the 8 Throwable-derived (IntPtr, JniHandleOwnership) constructors: matches the current runtime. Throwable.SetHandle (dotnet/android@9bc18c75 and release/10.0.1xx, Throwable.cs:99-110) copies the reference with JniObjectReferenceOptions.Copy and passes transfer only to JNIEnv.DeleteRef, so the old 'whether the peer is registered' text was wrong for these types. This is the wording accepted in #1972.
  • Non-blocking note: these constructor docs are shared with the net-android-34.0 and 35.0 views (all 8 DocIds are listed in both FrameworksIndex files). On .NET 9 (API 35), Throwable.SetHandle goes through AndroidValueManager.AddPeer, which keeps a TransferGlobalRef handle without copying it and honors DoNotRegister (release/9.0.1xx AndroidRuntime.cs:686-709). So the sentence isn't exact on those older views. #1972 already settled on documenting the current managed pin, so I'm not blocking on this. If you want the series to be exact on every view, wording that also covers adopting the reference would do it.
  • SetMgf1Digests: 'cannot be null' is correct for API 35+ because a null array reaches Set.of(mgf1Digests), which throws. The @Nullable conflict is disclosed in the description.
  • The three new crefs (KeyAgreement.Init(IKey), KeyStoreSecurityLevel.TrustedEnvironment, NetworkSecurityPolicy.GetDomainEncryptionMode(string)) resolve to existing, matching members.

No blocking issues found.

@jonathanpeppers
jonathanpeppers merged commit 0803140 into main Nov 28, 2026
4 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers-review-security-keystore-netconfig-docs branch November 28, 2026 18:24
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