Repository navigation
refactor(android SDK): convert MessageManager to Kotlin - #1002
Conversation
Kotlin migration progressThis pull request converts 1095 lines of Java to Kotlin.
Conversion progress: 31.5% (11,339 of 16,550 baseline Java LOC left to convert). 96 Java files and 72 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": 2514, "baseline_install_bytes": 7531, "core_dex_bytes": 223188, "core_download_bytes": 124483, "core_install_bytes": 131734}core, This PR: {"baseline_dex_bytes": 0, "baseline_download_bytes": 2513, "baseline_install_bytes": 7529, "core_dex_bytes": 223684, "core_download_bytes": 124581, "core_install_bytes": 131834}rokt, Target branch: {"baseline_dex_bytes": 1829108, "baseline_download_bytes": 1240062, "baseline_install_bytes": 1300934, "kit_dex_bytes": 4173016, "kit_download_bytes": 2549436, "kit_install_bytes": 2623275, "sdkplus_dex_bytes": 9297080, "sdkplus_download_bytes": 7987179, "sdkplus_install_bytes": 8165359}rokt, This PR: {"baseline_dex_bytes": 1829108, "baseline_download_bytes": 1240062, "baseline_install_bytes": 1300934, "kit_dex_bytes": 4173692, "kit_download_bytes": 2548319, "kit_install_bytes": 2623275, "sdkplus_dex_bytes": 9297648, "sdkplus_download_bytes": 7987548, "sdkplus_install_bytes": 8165359} |
Why
Risk class M.
This pull request converts row D5 of the Kotlin migration tracker from Java to Kotlin:
MessageManager. It is stacked on row D4's pull request.Programme
The Java-to-Kotlin migration of android-core, TRACKER.md row D5 (Stack D, event pipeline), converted under PLAYBOOK.md.
What changes
MessageManagerbecomes Kotlin in the same directory and package. Every public member keeps its JVM name and descriptor.Decisions made by hand:
initblock. The companion's properties keep the Java order around it, so the handler threads start at the same point of class loading.@JvmStatic(getStateInfo,getTotalMemory,getSystemMemoryThreshold,destroy), ten@JvmField, one@Volatile, one@Synchronizedand two@Throws(JSONException::class). No default arguments and no top-level declarations.internal.sPreferences,devicePerformanceMetricsDisabledand the nested classes' fields areinternalwith@JvmField, soConfigManagerstill writes the flag as a static field.getStateInfothrough the companion, whichMockito.mockStaticdoes not reach, soMParticleDBManagerTestnow runs the realgetStateInfoon a mockedMPUtility.setUserAttributebuilds its maps with a nullable key type, so a null key still goes into theHashMap.Nullability. Parameters are nullable and read with
!!where the Java first used them. Departures from the playbook default:createFirstRunMessageandgetStateInforeturn non-null values.postToMessageThreadasserts itsRunnablenon-null beforeHandler.post. Its one caller always passes one.The log methods return
BaseMPMessage?, andmessageHandlerandmParticleDBManagerare nullable.MessageManagerTest,MessageManagerTestsandMParticleDBManagerread them with!!.The API dump:
MessageManagergains itsCompanionfield and aMessageManager$Companionentry, and the four static methods becomestatic final.scripts/check_api_dump.pyreports these as reviewable internal changes and no frozen class.Linked work
Stacked on row D4'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. 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 inMessageManager, 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.MessageManagerTests: the Instrumented Tests jobs.trunk checkand SDK Size Impact.Risks
MessageManagerTestchecks each message type.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: 1299 lines added, 1128 removed, in 8 files.
Cost: not yet read.
1 Kotlin file, 1257 lines, replacing 1 Java file of 1095 lines. Four test files, 29 lines added and 28 removed. The API dump gains 12 lines and loses 4.