Repository navigation
Fix documentation errors in Android.App.Usage, Android.App.VoiceInteractions, Android.App.Wallpaper (R102, pass 3) - #1981
Conversation
- Correct the transfer parameter text in four Object-derived constructors. - Correct the NetworkStatsManager.RegisterUsageCallback handler text. - Start the UsageEvents.GetNextEvent null-argument exception at API 33. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the documentation corrections to JNI reference handling and API-version-specific behavior.
No open issues 🎉
What changed in this PR
This documentation-only PR corrects JNI reference handling and API-version-specific behavior in the Android.App.Usage bindings. It makes no runtime code changes.
Changes:
- Clarifies JNI reference release and peer registration in four constructor parameters.
- Documents callback threading differences before and after API level 33.
- Limits the documented null-argument exception for
GetNextEventto API level 33 and later.
| File | Description |
|---|---|
| docs/xml/Android.App.Usage/UsageEvents.xml | Qualifies the null-argument exception by API level. |
| docs/xml/Android.App.Usage/StorageStatsManager.xml | Clarifies constructor JNI reference handling. |
| docs/xml/Android.App.Usage/NetworkStatsManager+UsageCallback.xml | Clarifies constructor JNI reference handling. |
| docs/xml/Android.App.Usage/NetworkStatsManager.xml | Corrects JNI reference handling and callback threading documentation. |
| docs/xml/Android.App.Usage/NetworkStats+Bucket.xml | Clarifies constructor JNI reference handling. |
Review effort: Balanced
|
@dalexsoto review |
|
In response to @jonathanpeppers's request: The remaining checks are the API 32/33 implementation boundary for the null |
dalexsoto
left a comment
There was a problem hiding this comment.
Reviewed all five documentation changes and the relevant JNI reference ownership, usage-event null handling, and API 32/33 callback-threading boundary. The revised wording matches the inspected implementation and version-boundary evidence; no blocking issues found.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
d196e98530fd38450b75ba46df955da83f67126cgit diff --checkis clean.↑ Rubber-duck review (gemini-4-argon) confirmed all three fix types against pinned and AOSP sources.
↓ Copilot review is pending.
Scope
Pass-3 review item R102: 45 XML files in
docs/xml/Android.App.Usage,docs/xml/Android.App.VoiceInteractions,docs/xml/Android.App.Wallpaper, and the three namespace files. Only text that changed since86f7744a1(AI-authored) was reviewed and edited. Pinned sources: AOSPsource-37.2_r02(r01 extract used only where it matches r02), anddotnet/android@9bc18c75for generator and runtime behavior.Fixes
transferparameter on Object-derived constructors (NetworkStats.Bucket,NetworkStatsManager,NetworkStatsManager.UsageCallback,StorageStatsManager).Old: "Specifies whether ownership of the JNI reference transfers to this instance."
New: "Specifies how the runtime handles the JNI reference, including its release and peer registration."
Evidence:
dotnet/android@9bc18c75Object.cs:110-118(SetHandleconstructs the peer withCopy, then callsJNIEnv.DeleteRef(value, transfer)) andJNIEnv.cs:360-393(transferselectsDoNotRegisterand deletion of the incoming reference). Same wording as Fix documentation errors in Android.App.PermissionUI (R060, pass 3) #1941. None of these types derives fromJava.Lang.Throwable.NetworkStatsManager.RegisterUsageCallbackhandlerparameter.Old: "to dispatch callback events through, otherwise if null it uses the calling thread."
New: "The handler to dispatch callback events through. If null, on API level 32 and lower the callback runs on the looper of the thread that calls this method; starting with API level 33, the callback runs directly on the Binder thread that delivers the notification."
Evidence:
android-12.1.0_r27NetworkStatsManager.javausesLooper.myLooper()whenhandler == null.android-13.0.0_r1andsource-37.2NetworkStatsManager.java:1104-1118usehandler == null ? r -> r.run() : r -> handler.post(r), andUsageCallbackWrapper.onThresholdReached(Binder stub) callsmExecutor.execute. The upstream@param handlertext "uses the calling thread" is wrong for API 33+.UsageEvents.GetNextEventexception.Old: the
IllegalArgumentExceptionwas documented for all API levels.New: "Starting with API level 33, if
eventOutis null."Evidence:
android-12.1.0_r27UsageEvents.getNextEventhas no null check.android-13.0.0_r1andsource-37.2UsageEvents.java:855-858throwIllegalArgumentException("Given eventOut must not be null").Out-of-scope finding (not edited; text is not AI-changed)
The remarks of
UsageStatsManager.QueryUsageStats,QueryConfigurations,QueryEventStatsandQueryEventssay "if the device is not unlocked (Android R+), then null will be returned". The client code returns an empty result, not null:UsageStatsManager.java:520-526and553-559and599-605return an empty list, and634-640returnssEmptyResults. This sentence predates86f7744a1, so this PR does not change it.Uncertain findings
None.
Checks
git diff --check: clean.To be addedplaceholders.index.xml,_filter.xmlorFrameworksIndex.Ledger
655 of 655 AI-changed channels have a row with a numeric pinned source line: 649 correct, 6 fixed, 0 uncertain.