kuter007 / android-apktool

Automatically exported from code.google.com/p/android-apktool
Other
0 stars 0 forks source link

Incorrect handling of reference resources for flag attributes #648

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Have a menu xml that has an attribute with 
android:showAsAction="@integer/menu_type". Integer menu_type is defined in 
values and values-large, etc...

apktool does a bitwise operation of the potential flags and the resource id of 
"@integer/menu_type" (I.E. 0x7F09000B). This will result in both always and 
ifRoom flag set. This is not a valid scenario. The java code will end up 
crashing.

What is the expected output? What do you see instead?

Instead of using the reference id of the resource, just put the @integer/<name> 
back into the attribute value.

What version of the product are you using? On what operating system?

apktool: 1.5
Host OS: Mac OS X

Please provide any additional information below.

Attached is the diff of the fix. 

Original issue reported on code.google.com by ajdob...@mtu.edu on 24 Jun 2014 at 7:43

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks!

I will see if there is anyway I can add a unit-test for this, or if the change 
is only apparent once loaded on device.

Original comment by connor.tumbleson on 30 Jun 2014 at 12:46

GoogleCodeExporter commented 9 years ago
I found it using aapt d xmltree <apk> <xml file>

Original comment by ajdob...@mtu.edu on 30 Jun 2014 at 10:16

GoogleCodeExporter commented 9 years ago
Test app (Original)

$ aapt d xmltree app-debug-unaligned.apk res/menu/my.xml
      A: android:id(0x010100d0)=@0x7f090000
      A: android:orderInCategory(0x010101df)=(type 0x10)0x64
      A: android:title(0x010101e1)=@0x7f060000
      A: android:showAsAction(0x010102d9)=@0x7f050000

Original decoded then rebuilt (without patch)

$ aapt d xmltree app-debug-unaligned.apk res/menu/my.xml
      A: android:id(0x010100d0)=@0x7f090000
      A: android:orderInCategory(0x010101df)=(type 0x10)0x64
      A: android:title(0x010101e1)=@0x7f060000
      A: android:showAsAction(0x010102d9)=@0x7f050000

Original decoded then rebuilt (with patch enclosed)

$ aapt d xmltree app-debug-unaligned.apk res/menu/my.xml
      A: android:id(0x010100d0)=@0x7f090000
      A: android:orderInCategory(0x010101df)=(type 0x10)0x64
      A: android:title(0x010101e1)=@0x7f060000
      A: android:showAsAction(0x010102d9)=@0x7f050000

Sooo, is this already fixed in 2.x? Or did I miss something?

Original comment by connor.tumbleson on 7 Jul 2014 at 12:43

Attachments:

GoogleCodeExporter commented 9 years ago
I had issues getting 2.0 to work (java 7 scares me since I build from AOSP and 
that requires Java 6 on KitKat). I think I was using it on one of my other 
machines and it still didn't work. When I get some time, I'll try 2.0 again.

Original comment by ajdob...@mtu.edu on 9 Jul 2014 at 3:21

GoogleCodeExporter commented 9 years ago
Any updates? Just going through old issues.

Original comment by connor.tumbleson on 24 Sep 2014 at 12:29

GoogleCodeExporter commented 9 years ago
I haven't been able to look at 2.0. If it worked for you, I'm good with it. 
Thanks

Original comment by ajdob...@mtu.edu on 24 Sep 2014 at 9:23

GoogleCodeExporter commented 9 years ago

Original comment by connor.tumbleson on 24 Sep 2014 at 9:24