Skip to content

Add the android.os.Parcel shim and the AuthKt facade - #86

Merged
nbransby merged 3 commits into
masterfrom
android-os-parcel
Nov 11, 2026
Merged

nbransby merged 3 commits into
masterfrom
android-os-parcel

Conversation

@nbransby

@nbransby nbransby commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

The repackaged Firebase classes implement Parcelable, so Timestamp, RemoteMessage, Trace and others expose writeToParcel(Parcel, int) methods and CREATOR fields whose signatures reference android.os.Parcel, a class that does not exist on the JVM classpath today. Consumers compiling against those signatures, such as the Firebase Kotlin SDK's JVM artifacts for messaging and perf, have had to ship a placeholder android.os.Parcel of their own to get their code to compile.

This adds the shim under src/main/java/android/os, alongside Parcelable and the other framework shims. It is a small in-memory implementation rather than a stub that throws: a parcel is a list of the values written to it, read back in the same order, so a Parcelable round-trips through writeParcelable and its CREATOR. It mirrors the Android signatures of obtain and recycle, the data position and size accessors, marshall and unmarshall, the typed write and read methods for primitives, strings, byte arrays, lists, maps, ArrayMaps, Bundles, Parcelables, Serializables and tagged values, and the exception transport. The hidden writeString8, readString8, writeArrayMap and readArrayMap are included because the ported Uri and ContentValues already call them; with the shim present they now compile against it instead of the Robolectric compile-only jar.

Positions count values rather than bytes and marshall produces a Java-serialized form that only unmarshall understands, which the class documentation spells out; nothing crosses a process boundary on the JVM, so there is no binary format to stay compatible with. A ParcelTest covers the round trips, including one of com.google.firebase.Timestamp through its CREATOR.

The branch also adds the Kotlin extensions facade of the Android firebase-auth library, com.google.firebase.auth.AuthKt. The ported libraries bring their facades along in their jars (FirebaseKt, FirestoreKt, DatabaseKt, StorageKt, FunctionsKt, RemoteConfigKt, InstallationsKt), but Auth is implemented here rather than ported, so its facade was the one missing and the Firebase Kotlin SDK has had to ship a copy in its JVM artifact. Auth.kt declares the same members with the Android signatures: the Firebase.auth property and Firebase.auth(app) function, and the actionCodeSettings, oAuthProvider (with and without a FirebaseAuth), oAuthCredential and userProfileChangeRequest builder functions, each applying its init block to a new builder of the corresponding class. A FirebaseAuthKtTest checks the extensions return the app's FirebaseAuth and that each builder function applies its init.

The repackaged Firebase classes implement Parcelable, so Timestamp,
RemoteMessage, Trace and others expose writeToParcel(Parcel, int) and a
CREATOR that reference android.os.Parcel, a class that was missing from
the JVM classpath until now. Consumers compiling against those
signatures, such as the Firebase Kotlin SDK's JVM artifacts, had to ship
a placeholder of their own.

The shim is a small in-memory implementation rather than a stub that
throws: a parcel is a list of the values written to it, read back in the
same order, so a Parcelable round-trips through writeParcelable and its
CREATOR. It mirrors the Android signatures of obtain and recycle, the
data position and size accessors, marshall and unmarshall, the typed
write and read methods for primitives, strings, byte arrays, lists, maps,
ArrayMaps, Bundles, Parcelables, Serializables and tagged values, and
the exception transport. The hidden writeString8, readString8,
writeArrayMap and readArrayMap are included because the ported Uri and
ContentValues call them.

Positions count values rather than bytes and marshall produces a
Java-serialized form that only unmarshall understands, which is
documented on the class; nothing crosses a process boundary on the JVM
so there is no binary format to be compatible with.
Copilot AI balanced review requested due to automatic review settings November 11, 2026 05:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Parcel serialization retains mutable object references instead of snapshots, and Uri parcelable round-trips fail because CREATOR is not exposed as a public JVM field.

2 open issues
What changed in this PR

Adds an in-memory android.os.Parcel shim so JVM consumers can compile against repackaged Firebase Parcelable APIs without supplying their own placeholder.

Changes:

  • Implements typed reads and writes, Parcelable reconstruction, exception transport, and Java-based marshalling.
  • Documents value-based positions and the JVM-specific serialized format.
  • Adds tests for round trips, Firebase Timestamp, exception handling, and misuse.
File Description
src/​test/​kotlin/​ParcelTest.kt Tests Parcel operations and Firebase Timestamp round trips.
src/​main/​java/​android/​os/​Parcel.java Provides the in-memory Parcel implementation alongside existing Android shims.

Review effort: Balanced

Comment thread src/main/java/android/os/Parcel.java Resolved
Comment thread src/main/java/android/os/Parcel.java Resolved
The Android SDK ships a file of Kotlin extensions with each library, and
the ported libraries bring theirs along in their jars: FirebaseKt,
FirestoreKt, DatabaseKt, StorageKt, FunctionsKt, RemoteConfigKt and
InstallationsKt. Auth is implemented here rather than ported, so its
facade, com.google.firebase.auth.AuthKt, was the one missing, and the
Firebase Kotlin SDK has had to ship a copy of it in its JVM artifact.

Auth.kt declares the same members with the Android signatures: the
Firebase.auth property and Firebase.auth(app) function returning the
FirebaseAuth of the default or a given app, and the actionCodeSettings,
oAuthProvider (with and without a FirebaseAuth), oAuthCredential and
userProfileChangeRequest builder functions, each applying its init block
to a new builder of the corresponding class.
@nbransby nbransby changed the title Add the android.os.Parcel shim Add the android.os.Parcel shim and the AuthKt facade Nov 11, 2026
@nbransby
nbransby requested a balanced review from Copilot November 11, 2026 05:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unmarshalling invokes unrestricted deserialization callbacks before validating the payload, creating a potential code-execution vulnerability when input bytes are attacker-controlled.

3 open issues

Review effort: Balanced

Comment thread src/main/java/android/os/Parcel.java Resolved
Three fixes to the Parcel shim from review.

writeSerializable stored the object itself, so a Serializable changed
after it was written read back changed, and changing a read result
changed later reads; the Serializable fallback of writeValue, which
primitive arrays take, behaved the same. The parcel now keeps the bytes
of the serialized form taken at write time, and readSerializable
deserializes a fresh copy on every read.

marshall used Java serialization for the whole value list and unmarshall
read it back with ObjectInputStream.readObject, which runs deserialization
callbacks before the result is checked to be a list, so bytes from an
untrusted source could execute code through classpath types. The
envelope is now a tagged byte stream written with DataOutputStream: the
number of values, then each as a tag byte and its data, for the types a
value in the list can have once the typed writes have flattened lists,
maps, bundles and parcelables into them (null, String, int, long, float,
double, byte arrays and serialized bytes). unmarshall deserializes
nothing; a Serializable stays bytes until a caller asks for it with
readSerializable, and malformed data is rejected with an
IllegalArgumentException. marshall throws an IllegalStateException
naming the type if a value it cannot carry ever reaches the list.

Uri declared its CREATOR as a JvmStatic property, which the JVM sees as
a getter, so writeParcelable accepted a Uri but readParcelable could not
find the CREATOR field reflectively. It is a JvmField now, a public
static field like Android's, and ParcelTest round-trips hierarchical and
opaque Uris as well as snapshots of Serializables and the new stream.
@nbransby
nbransby merged commit 41857dc into master Nov 11, 2026
1 check passed
@nbransby
nbransby deleted the android-os-parcel branch November 11, 2026 06:31
@nbransby nbransby mentioned this pull request Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants