kuter007 / android-apktool

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

Don't rename resources 9.qmg to qmg #689

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. decompile any apk from for example I9305XXUFNI3
2. all images 9.qmg will be decompiled as .qmg

What is the expected output? What do you see instead?
9.qmg should be decompiled (unpacked) as 9.qmg, but i've got qmg instead

What version of the product are you using? On what operating system?
Apktool 2.0.0 (pre-RC2, compiled by myself).

Please provide any additional information below.
Samsung start to use qmg image format in their latest ROMs. QMG has smaller 
size than PNG and faster in decoding. Would be good if ApkTool will be able to 
auto-convert QMG to PNG while decompiling (optionally). Framework handles both 
PNG and QMG (but currently there are no tools to work with QMG).
But main task for begining is to keep 9.qmg extension.

Original issue reported on code.google.com by pour.gar...@gmail.com on 22 Oct 2014 at 1:26

GoogleCodeExporter commented 9 years ago
Can you attach a a single apk from that build (frameworks too)?

---

Are these 9.qmg files in the regular res/drawable* folders? If so, are they 
just modified 9 patch files?

I can take a look then and patch it, but not sure the extent of the problem. 
Usually when an OEM adds their own 9patch, they add their own images too. So 
maybe we are dealing with .9.qmg and .qmg.

Original comment by connor.tumbleson on 22 Oct 2014 at 1:40

GoogleCodeExporter commented 9 years ago
yes, it's in drawable. Both qmg and 9.qmg are exist (similar to png and 9.png).
I've attached framework resources which contains 9.png itself.

Original comment by pour.gar...@gmail.com on 22 Oct 2014 at 2:39

Attachments:

GoogleCodeExporter commented 9 years ago
https://github.com/iBotPeaches/Apktool/commit/986b585f261a74c8c48fdcd4107e84d967
721a3c

Fixed.

Original comment by connor.tumbleson on 22 Oct 2014 at 9:33

GoogleCodeExporter commented 9 years ago
I didn't try this fix yet, but according to this logic, apktool will try to 
decode 9.qmg as 9.png and obviously will fail because there is no qmg decoder 
yet.

i propose another way to fix:

--- 
a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResFileDecode
r.java
+++ 
b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResFileDecode
r.java
@@ -83,6 +83,9 @@ public class ResFileDecoder {
                     }
                 }
                 if (!".xml".equals(ext)) {
+                                       if 
(inFileName.toLowerCase().endsWith(".9.qmg")) {
+                                               outFileName = outResName + ".9" 
+ ext;
+                                       }
                     decode(inDir, inFileName, outDir, outFileName, "raw");
                     return;
                 }
-------------------

This way, 9.qmg will be simply copied as-is.

Original comment by pour.gar...@gmail.com on 23 Oct 2014 at 1:45

GoogleCodeExporter commented 9 years ago
Ok, checked. Your fix doesn't work. Apktool still renames 9.qmg to qmg.
Please use my patch above - it produces correct 9.qmg. We can use this method 
till someone create QMG decoder.

Original comment by pour.gar...@gmail.com on 23 Oct 2014 at 2:40

GoogleCodeExporter commented 9 years ago
If you'd like to submit patches, you can do so via Googlecode / Bitbucket / 
Github so unit-tests can be automated. 

Your method is not right. You just said QMG has no known decoder, so the 
decode() method won't work. 

Please attach a whitepaper or some format of QMG. Until then it is passed on 
raw without being touched.

https://github.com/iBotPeaches/Apktool/commit/3e6fc8c5ef25cf1421732abd3d03cd529a
476df3

Original comment by connor.tumbleson on 23 Oct 2014 at 3:05

GoogleCodeExporter commented 9 years ago
There is no known public implementation of decoder for QMG. It's proprietary 
Quram image format http://quramsoft.com/solution_e/qmage.asp
It's used in recent Samsung firmwares for GT-I9305, SM-G901, SM-N910 and other 
devices. Currently, you can decode QMG images only directly on one of mentioned 
phone. There is no known decoder for PC.
Thus only raw copy is possible (as i've mentioned in previous post) - that's 
what my patch was for. Your new patch looks OK now.

Original comment by pour.gar...@gmail.com on 23 Oct 2014 at 4:28

GoogleCodeExporter commented 9 years ago
By the way, to be a more precise: 9.qmg is a 9patches qmg just like 9.png. It 
uses exactly the same 9patches header as 9.png. So, when QMG decoder will 
become available, you can use existing 9patches procedures to re-create picture 
with black lines on the edges.

Original comment by pour.gar...@gmail.com on 23 Oct 2014 at 4:34