Skip to content

refactor(android SDK): convert NetworkConnection and MParticleBaseClientImpl to Kotlin - #1005

Merged
nickolas-dimitrakas merged 1 commit into
mainfrom
refactor/convert-networkconnection-and
Nov 11, 2026
Merged

nickolas-dimitrakas merged 1 commit into
mainfrom
refactor/convert-networkconnection-and

Conversation

@nickolas-dimitrakas

@nickolas-dimitrakas nickolas-dimitrakas commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Why

Risk class M.

This pull request converts row B2 of the Kotlin migration tracker from Java to Kotlin: NetworkConnection and MParticleBaseClientImpl. Neither class is kept by the ProGuard configuration, so R8 renames both in the published AAR.

Programme

The Java-to-Kotlin migration of android-core, the migration tracker row B2 (Stack B, networking), converted using the Kotlin kotlin-tooling-java-to-kotlin skill and the migration playbook. Row B3 (MParticleApiClientImpl) stacks on this pull request.

What changes

  • Converts NetworkConnection and MParticleBaseClientImpl to Kotlin in com.mparticle.networking.
  • Verifies endpoint URL construction and host resolution in MParticleBaseClientImpl against MParticleBaseClientImplTest, NetworkOptionsTest, and EndpointTest. The version 1, version 2, and version 4 path prefixes, REQUEST_ID, resolveHost priority, getPodUrl pod redirection, and every when (endpoint) branch in getUrl match the Java implementation.
  • Verifies certificate pinning in NetworkConnection against MParticleBaseClientImplTest and PinningTest. makeUrlRequest applies getSocketFactory() before opening the gzipped output stream, and getSocketFactory() loads a default KeyStore, parses all default and DomainMapping X509 certificates, and initializes TrustManagerFactory and the TLS SSLContext.
  • Explicit conversion choices: getUrl (five overloads), generateDefaultURL and REQUEST_ID stay protected, as in the Java, and the Kotlin androidTests in the same package reach them through a small Java helper (BaseClientAccess) and Kotlin extensions; isPostGingerBread was package-private and is @RestrictTo(LIBRARY_GROUP) protected open; Endpoint.parseInt carries @JvmStatic and @RestrictTo(LIBRARY_GROUP); unannotated parameters are nullable (T?) and dereferenced with !!. The four makeUrlRequest overloads return MPConnection?, getHeaderHashString returns String?, generateDefaultURL returns MPUrl?, and getPodPrefix(apiKey.orEmpty()) keeps the Java behaviour for a null API key.
  • API dump: additions only, with no removed line. They are a Companion field and an empty $Companion class on MParticleBaseClientImpl, MParticleBaseClientImpl.Endpoint and NetworkConnection, plus Endpoint.getEntries(). The frozen-API check counts these as changes, so this pull request needs the api-change-approved label after API review.
  • Adds an "API-dump traps" section and a checklist item to the migration playbook.

Linked work

Follows row B1 (#985); row B3 (MParticleApiClientImpl) stacks on this branch.

Rollout

Merges with no release and reaches apps in the next SDK release. Revert the squash commit to roll back. Risk class M: the stack's QA smoke run is needed before the next M-class pull request in Stack B merges.

Risks

  • Endpoint URL construction or certificate pinning regression: verified by MParticleBaseClientImplTest, NetworkOptionsTest, EndpointTest, and PinningTest.
  • Public API dump classification: neither class is kept by the ProGuard configuration, so R8 renames both in the shipped AAR. The dump has additions only (listed above), and getUrl, generateDefaultURL and REQUEST_ID keep their Java protected visibility, so a Java subclass that overrides them still compiles.
  • Verification: unit tests, lint, kit compatibility, binary compatibility and kit examples pass in CI. The instrumented jobs ran on an earlier head of this change and will run again on this one.

Who

Prepared by an automated coding agent as row B2 of the migration tracker and reviewed by the SDK team before merge.

Size

657 lines added and 504 removed across 11 files: 2 Kotlin files replacing 2 Java files, 1 import line in UploadHandler, 1 visibility modifier in MParticleBaseClientImplTest, the makeUrlRequest override in MParticleIdentityClientImplTest, two androidTest helper files, the API dump, and the migration playbook.

@nickolas-dimitrakas
nickolas-dimitrakas requested a review from a team as a code owner November 10, 2026 21:18
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Kotlin migration progress

This pull request converts 473 lines of Java to Kotlin.

Module Kotlin LOC Java LOC Java staying (facade) Java left to convert Kotlin share
android-core 9,134 16,828 9,716 7,112 35.2%
android-kit-base 601 5,405 1,651 3,754 10.0%
Total 9,735 22,233 11,367 10,866 30.5%

Conversion progress: 34.3% (10,866 of 16,550 baseline Java LOC left to convert). 94 Java files and 74 Kotlin files in scope.

@github-actions

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 10, 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.39 KB 121.65 KB +268 bytes
Download size 119.21 KB 119.47 KB +270 bytes
Dex bytes 218.44 KB 219.13 KB +704 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 +168 bytes
Dex bytes 2.24 MB 2.24 MB +168 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.44 MB +258 bytes +5.19 MB
Dex bytes 7.12 MB 7.12 MB +168 bytes +4.89 MB

➡️ SDK size impact change is minimal.

Raw measurements

core, Target branch:

{"baseline_dex_bytes": 0, "baseline_download_bytes": 2514, "baseline_install_bytes": 7528, "core_dex_bytes": 223684, "core_download_bytes": 124582, "core_install_bytes": 131833}

core, This PR:

{"baseline_dex_bytes": 0, "baseline_download_bytes": 2513, "baseline_install_bytes": 7529, "core_dex_bytes": 224388, "core_download_bytes": 124851, "core_install_bytes": 132102}

rokt, Target branch:

{"baseline_dex_bytes": 1829108, "baseline_download_bytes": 1240062, "baseline_install_bytes": 1300934, "kit_dex_bytes": 4173692, "kit_download_bytes": 2548321, "kit_install_bytes": 2623275, "sdkplus_dex_bytes": 9297648, "sdkplus_download_bytes": 7987550, "sdkplus_install_bytes": 8165359}

rokt, This PR:

{"baseline_dex_bytes": 1829108, "baseline_download_bytes": 1240062, "baseline_install_bytes": 1300934, "kit_dex_bytes": 4173860, "kit_download_bytes": 2548489, "kit_install_bytes": 2623275, "sdkplus_dex_bytes": 9297816, "sdkplus_download_bytes": 7987808, "sdkplus_install_bytes": 8165359}

Measured 20e1070 merged into 1fc54ee

@jamesnrokt jamesnrokt added the promoted Opened from Rokt's internal review process label Nov 11, 2026
@nickolas-dimitrakas
nickolas-dimitrakas force-pushed the refactor/convert-networkconnection-and branch from 29dfd0c to 846841f Compare November 11, 2026 15:11

@jamesnrokt jamesnrokt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved — NetworkConnection and MParticleBaseClientImpl match the Java, including pinning, pod routing and every endpoint path.

@nickolas-dimitrakas
nickolas-dimitrakas force-pushed the refactor/convert-networkconnection-and branch from 846841f to 20e1070 Compare November 11, 2026 18:12
@nickolas-dimitrakas
nickolas-dimitrakas merged commit 5261b9c into main Nov 11, 2026
45 checks passed
@nickolas-dimitrakas
nickolas-dimitrakas deleted the refactor/convert-networkconnection-and branch November 11, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-change-approved promoted Opened from Rokt's internal review process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants