Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-116775

`QAndroidParcel::writeData()` with an empty ByteArray does nothing (should write empty ByteArray)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 5.15.13
    • Extras: Android
    • None
    • Android

    Description

      What the title says: QAndroidParcel::writeData() with an empty ByteArray does nothing, while it should write an empty ByteArray

      Run this on Android:

      fun ByteArray.toHexString() = "[" + joinToString(separator = ",") { eachByte -> "%02X".format(eachByte) } + "]"
      ....
      // in a function which has `reply: Parcel?`, i.e. a `Binder.onTransact()` override
                  println("xxxx empty Parcel: ${reply?.marshall()?.toHexString()}")
                  reply?.writeByteArray(ByteArray(0))
                  println("xxxx Parcel with empty byte array: ${reply?.marshall()?.toHexString()}")
      

      prints

      2023-09-06 12:03:37.045  6505-6525  System.out              com.example.parcelcreatebytearray    I  xxxx empty Parcel: []
      2023-09-06 12:03:37.045  6505-6525  System.out              com.example.parcelcreatebytearray    I  xxxx Parcel with empty byte array: [00,00,00,00]
      

      So an empty parcel is not the same as one with an empty Byte Array

      Also, parcel.createByteArray() will also return different results in the two cases: null for a Parcel with NoOp vs an empty ByteArray for a parcel which called writeByteArray()

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtandroidteam Qt Android Team
            dan.taga.nvc Dan Taga
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes