Incorrect apns.xml (framework-res.apk) decoding #187

Closed
iBotPeaches opened this Issue Mar 18, 2015 · 4 comments

Comments

Projects
None yet
1 participant
@iBotPeaches
Owner

iBotPeaches commented Mar 18, 2015

Original issue 76 created by stari4ek on 2010-07-05T21:52:13.000Z:

  1. $ apktool d -s base/system/framework/framework-res.apk 1
  2. check /res/xml/apns.xml
  3. it ruins valuable info about mns. It makes from "01" - "1", which is incorrect mns. (string -> int -> string type conversion?)

Example:
Decoded variant:
<apn carrier="MTS internet" apn="internet.mts.ru" user="mts" password="mts" mcc="250" mnc="1" type="default" />
Correct variant:
<apn carrier="MTS internet" apn="internet.mts.ru" user="mts" password="mts" mcc="250" mnc="01" type="default" />

I've checked /data/data/com.android.providers.telephony/databases/telephony.db for correct values.

I've attached framework-res.apk from Hero_HTC_RUS_3.32.411.1

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 18, 2015

Owner

Comment #1 originally posted by Brut.alll on 2010-08-29T20:40:44.000Z:

As I always say, Android resources are very tricky.

XML attributes are stored in both original/string and parsed/integer form. E.g. if you have "android:layout_width="fill_parent"" in your XML, then it's stored as:

  • string value: null (cause it's magic, resource attribute)
  • int value: -1 (this is binary "fill_parent" for android:layout_width attribute)
  • type: I don't remember

This time it was:

  • string value: "01"
  • int value: 1
  • type: int

This is the reason, why apktool has removed "0" - this value is stored in XML file with type=integer, so apktool get its int value. But textual value is still there, so we can use it.

I decided to ignore attribute type and use simple algorithm: if there is string value, then use it, if not, then use int value and if it's resource attribute, then decode it to textual form. I hope I won't blow up everything - these few lines of code are critical for apks decoding.

Owner

iBotPeaches commented Mar 18, 2015

Comment #1 originally posted by Brut.alll on 2010-08-29T20:40:44.000Z:

As I always say, Android resources are very tricky.

XML attributes are stored in both original/string and parsed/integer form. E.g. if you have "android:layout_width="fill_parent"" in your XML, then it's stored as:

  • string value: null (cause it's magic, resource attribute)
  • int value: -1 (this is binary "fill_parent" for android:layout_width attribute)
  • type: I don't remember

This time it was:

  • string value: "01"
  • int value: 1
  • type: int

This is the reason, why apktool has removed "0" - this value is stored in XML file with type=integer, so apktool get its int value. But textual value is still there, so we can use it.

I decided to ignore attribute type and use simple algorithm: if there is string value, then use it, if not, then use int value and if it's resource attribute, then decode it to textual form. I hope I won't blow up everything - these few lines of code are critical for apks decoding.

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 18, 2015

Owner

Comment #2 originally posted by stari4ek on 2010-08-29T21:15:55.000Z:

great, that you digged inside the problem.
hope it won't break other things. This kind of changes really need global testing. Do you have any unit tests? =)

Owner

iBotPeaches commented Mar 18, 2015

Comment #2 originally posted by stari4ek on 2010-08-29T21:15:55.000Z:

great, that you digged inside the problem.
hope it won't break other things. This kind of changes really need global testing. Do you have any unit tests? =)

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 18, 2015

Owner

Comment #3 originally posted by Brut.alll on 2010-08-29T21:25:30.000Z:

I don't: issue 74.

I have about ~100 apks with different "weirdnesses" and I always rebuild them all before release. This don't give me a sureness, that I didn't break something, but it's better than nothing.

Owner

iBotPeaches commented Mar 18, 2015

Comment #3 originally posted by Brut.alll on 2010-08-29T21:25:30.000Z:

I don't: issue 74.

I have about ~100 apks with different "weirdnesses" and I always rebuild them all before release. This don't give me a sureness, that I didn't break something, but it's better than nothing.

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 18, 2015

Owner

Comment #4 originally posted by Brut.alll on 2010-09-03T15:53:16.000Z:

Fixed in v1.3.2 .

Owner

iBotPeaches commented Mar 18, 2015

Comment #4 originally posted by Brut.alll on 2010-09-03T15:53:16.000Z:

Fixed in v1.3.2 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment