Skip to content

refactor(android SDK): convert UploadHandler to Kotlin - #1001

Merged
nickolas-dimitrakas merged 1 commit into
refactor/convert-messagehandler-to-kotlinfrom
refactor/convert-uploadhandler-to-kotlin
Nov 10, 2026
Merged

nickolas-dimitrakas merged 1 commit into
refactor/convert-messagehandler-to-kotlinfrom
refactor/convert-uploadhandler-to-kotlin

Conversation

@nickolas-dimitrakas

Copy link
Copy Markdown
Contributor

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

UploadHandler becomes Kotlin in the same directory and package. Every public and protected member keeps its JVM name and descriptor.

Decisions made by hand:

  • Open. The class and its public and protected members stay open, because the unit tests subclass it.
  • Constants. UPLOAD_MESSAGES, UPDATE_CONFIG, UPLOAD_TRIGGER_MESSAGES and INIT_CONFIG become const val in a companion object, so they stay static int fields.
  • Package-private members. The two retention constants, the test constructor, isNetworkConnected, mParticleDBManager, containsClause, maybePrunePersistedRecords, uploadMessage and uploadAliasRequest become internal. Only Kotlin tests call them.
  • Modifiers. One @JvmField on mApiClient, one @Volatile on isNetworkConnected and three @Throws. No default arguments and no top-level declarations.
  • ProGuard. No keep rule names 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:

  • fetchUserAudiences returns a non-null AudienceTask, as UserAudiencesRetriever.fetchAudiences declares it.
  • The alias response is non-null, as MParticleApiClient.sendAliasRequest declares it.

mApiClient and mParticleDBManager are nullable. ConfigRequestTests and UploadHandlerTest now read them with !!. The test subclass's prepareMessageUploads takes a nullable UploadSettings.

The API dump: UploadHandler gains its Companion field and an empty UploadHandler$Companion entry. scripts/check_api_dump.py reports 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.py against main reports reviewable internal changes in UploadHandler, 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.
  • Instrumented tests on an API 28 emulator, among them ConfigRequestTests: the Instrumented Tests jobs.
  • Binary Compatibility, Kit Compatibility Test, build-kits, trunk check and SDK Size Impact.
  • The stack's QA smoke run.

Risks

  • The Kotlin fails to compile or a test fails on the first run, because no Android SDK was available where it was written. The fix goes on this pull request.
  • The upload loop, the retry rule or the alias callback changes behaviour. The statements keep the Java's order, and UploadHandlerTest covers each.
  • A minified app breaks. Binary Compatibility compares the public signatures with the last release, and SDK Size Impact shows the size.

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.

@nickolas-dimitrakas
nickolas-dimitrakas requested a review from a team as a code owner November 9, 2026 23:25
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Kotlin migration progress

This pull request converts 380 lines of Java to Kotlin.

Module Kotlin LOC Java LOC Java staying (facade) Java left to convert Kotlin share
android-core 7,443 18,396 9,716 8,680 28.8%
android-kit-base 601 5,405 1,651 3,754 10.0%
Total 8,044 23,801 11,367 12,434 25.3%

Conversion progress: 24.9% (12,434 of 16,550 baseline Java LOC left to convert). 97 Java files and 71 Kotlin files in scope.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Binary compatibility

  • ✅ android-core is compatible with 6.1.10 (112 classes compared, 0 with additions only).
  • ✅ android-kit-base is compatible with 6.1.10 (37 classes compared, 0 with additions only).

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 api-compat-reports workflow artifact. This check is not in the required-check set yet, so a red result here does not block merging.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

📦 SDK Size Impact Report

What the SDK adds to a minified release APK.

mParticle Core SDK

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

Metric Target branch This PR Change
APK size 121.29 KB 121.29 KB +3 bytes
Download size 119.11 KB 119.11 KB +6 bytes
Dex bytes 217.91 KB 217.96 KB +52 bytes

mParticle Core + Rokt kit

Measured 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 size-report-rokt/README.md.

Metric Target branch This PR Change
APK size 1.26 MB 1.26 MB 0 bytes
Download size 1.25 MB 1.25 MB +8 bytes
Dex bytes 2.24 MB 2.24 MB +40 bytes

Rokt SDK+ umbrella (adds the payment extension)

Metric Target branch This PR Change On top of mParticle Core + Rokt kit
APK size 6.55 MB 6.55 MB 0 bytes +5.29 MB
Download size 6.43 MB 6.43 MB -44 bytes +5.19 MB
Dex bytes 7.12 MB 7.12 MB +36 bytes +4.89 MB

➡️ SDK size impact change is minimal.

Raw measurements

core, 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}

Measured 92871a2 merged into 76f8c34

@nickolas-dimitrakas nickolas-dimitrakas self-assigned this Nov 10, 2026
@nickolas-dimitrakas
nickolas-dimitrakas merged commit 67a4e06 into main Nov 10, 2026
44 of 45 checks passed
@nickolas-dimitrakas
nickolas-dimitrakas deleted the refactor/convert-uploadhandler-to-kotlin branch November 10, 2026 01:40
@jamesnrokt jamesnrokt added the promoted Opened from Rokt's internal review process label Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

promoted Opened from Rokt's internal review process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants