Repository navigation
refactor(android SDK): convert UploadHandler to Kotlin - #1001
Conversation
Kotlin migration progressThis pull request converts 380 lines of Java to Kotlin.
Conversion progress: 24.9% (12,434 of 16,550 baseline Java LOC left to convert). 97 Java files and 71 Kotlin files in scope. |
Binary compatibility
Compares this branch with the last version published to Maven Central, both built without R8, over the public classes and members that release keeps under their own names. It also checks that this branch's release AAR still keeps them (see the script docstring). Full japicmp HTML/XML reports are attached as the |
📦 SDK Size Impact ReportWhat the SDK adds to a minified release APK. mParticle Core SDKMeasured against an empty baseline app. Unlike the Rokt kit, android-core ships no Compose and no resources, so there is nothing here that a host app would already provide.
mParticle Core + Rokt kitMeasured against a Compose + Material3 reference app, so these are the costs on top of an app that already ships Compose. The reference app's dependencies are a documented convention, not a measured average: see
Rokt SDK+ umbrella (adds the payment extension)
➡️ SDK size impact change is minimal. Raw measurementscore, Target branch: {"baseline_dex_bytes": 0, "baseline_download_bytes": 2513, "baseline_install_bytes": 7529, "core_dex_bytes": 223136, "core_download_bytes": 124479, "core_install_bytes": 131732}core, This PR: {"baseline_dex_bytes": 0, "baseline_download_bytes": 2512, "baseline_install_bytes": 7528, "core_dex_bytes": 223188, "core_download_bytes": 124484, "core_install_bytes": 131734}rokt, Target branch: {"baseline_dex_bytes": 1829108, "baseline_download_bytes": 1240062, "baseline_install_bytes": 1300934, "kit_dex_bytes": 4172976, "kit_download_bytes": 2549426, "kit_install_bytes": 2623275, "sdkplus_dex_bytes": 9297044, "sdkplus_download_bytes": 7987224, "sdkplus_install_bytes": 8165359}rokt, This PR: {"baseline_dex_bytes": 1829108, "baseline_download_bytes": 1240062, "baseline_install_bytes": 1300934, "kit_dex_bytes": 4173016, "kit_download_bytes": 2549434, "kit_install_bytes": 2623275, "sdkplus_dex_bytes": 9297080, "sdkplus_download_bytes": 7987180, "sdkplus_install_bytes": 8165359} |
Why
Risk class M.
This pull request converts row D4 of the Kotlin migration tracker from Java to Kotlin:
UploadHandler. It is stacked on row D3's pull request.Programme
The Java-to-Kotlin migration of android-core, TRACKER.md row D4 (Stack D, event pipeline), converted under PLAYBOOK.md.
What changes
UploadHandlerbecomes Kotlin in the same directory and package. Every public and protected member keeps its JVM name and descriptor.Decisions made by hand:
UPLOAD_MESSAGES,UPDATE_CONFIG,UPLOAD_TRIGGER_MESSAGESandINIT_CONFIGbecomeconst valin a companion object, so they stay static int fields.isNetworkConnected,mParticleDBManager,containsClause,maybePrunePersistedRecords,uploadMessageanduploadAliasRequestbecomeinternal. Only Kotlin tests call them.@JvmFieldonmApiClient, one@VolatileonisNetworkConnectedand three@Throws. No default arguments and no top-level declarations.UploadHandler, so the companion object needs none.Nullability. Object parameters are nullable and read with
!!where the Java first used them. Departures from the playbook default:fetchUserAudiencesreturns a non-nullAudienceTask, asUserAudiencesRetriever.fetchAudiencesdeclares it.MParticleApiClient.sendAliasRequestdeclares it.mApiClientandmParticleDBManagerare nullable.ConfigRequestTestsandUploadHandlerTestnow read them with!!. The test subclass'sprepareMessageUploadstakes a nullableUploadSettings.The API dump:
UploadHandlergains itsCompanionfield and an emptyUploadHandler$Companionentry.scripts/check_api_dump.pyreports these as reviewable internal changes and no frozen class.Linked work
Stacked on row D3's pull request.
Rollout
This merges with no release, and it reaches apps in the next SDK release. No flag applies, because a library conversion has no runtime switch. To undo it, revert the squash commit, after reverting row D5 if it merged on top of it. Risk class M: the stack's QA smoke run is needed before this merges.
Done before opening:
scripts/check_api_dump.pyagainst main reports reviewable internal changes inUploadHandler, and the hand-made decisions are listed above.Waiting for this pull request's jobs:
./gradlew apiCheck test ktlintCheck lint: Unit Tests, Lint Checks and Kotlin Lint Checks.ConfigRequestTests: the Instrumented Tests jobs.trunk checkand SDK Size Impact.Risks
UploadHandlerTestcovers each.Who
An AI coding agent wrote the conversion, as the next row of the tracker. The SDK team reviews it on this pull request.
Size
Hand-written: 417 lines added, 387 removed, in 5 files.
Cost: not yet read.
1 Kotlin file of 406 lines replacing 1 Java file of 380 lines. Two tests, 7 lines added and 7 removed. The API dump gains 4 lines.