T-vK / android-svc

Easy to use Android service wrapper
74 stars 15 forks source link

Regarding the complex parcel data parsing #7

Open baivoom opened 2 months ago

baivoom commented 2 months ago

Just give an example to explain the format of printed parcel data

x1q:/ $ service call phone 69  s16 'shell' s16 ''
Result: Parcel(
  0x00000000: 00000000 00000001 00000001 00000003 '................'
  ****HIDDEN SOME DATA****
  0x000000a0: 00000000                            '....            ')

the first and last 00000000 seems the open and close tags of the content, therefore just skip these chunks.

then for the 00000001 00000001 00000003, the first 00000001 seems to indicate a successful call. Here the expected call return is List<CellInfo>, hence the second 00000001 is the length of the list.

Since the encoding is using little endian, the 00000001 should be reversed to 01000000 then the Parcel can use readInt() correctly, in this case val count = parcel.readInt() , count indicates how many element in the return list.

To decode the CellInfo , it should call CellInfo.Creator.readFromParcel(parcel) and depends on the count, it should be called multiple times to fully decode them all