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

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

Comments

Projects
None yet
1 participant
@iBotPeaches
Owner

iBotPeaches commented Mar 18, 2015

Original issue 689 created by pour.garbage on 2014-10-22T01:26:10.000Z:

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.

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 18, 2015

Owner

Comment #1 originally posted by connor.tumbleson on 2014-10-22T01:40:56.000Z:

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.

Owner

iBotPeaches commented Mar 18, 2015

Comment #1 originally posted by connor.tumbleson on 2014-10-22T01:40:56.000Z:

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.

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 18, 2015

Owner

Comment #2 originally posted by pour.garbage on 2014-10-22T02:39:01.000Z:

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.

Owner

iBotPeaches commented Mar 18, 2015

Comment #2 originally posted by pour.garbage on 2014-10-22T02:39:01.000Z:

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.

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 18, 2015

Owner

Comment #3 originally posted by connor.tumbleson on 2014-10-22T21:33:24.000Z:

986b585

Fixed.

Owner

iBotPeaches commented Mar 18, 2015

Comment #3 originally posted by connor.tumbleson on 2014-10-22T21:33:24.000Z:

986b585

Fixed.

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 18, 2015

Owner

Comment #4 originally posted by pour.garbage on 2014-10-23T01:45:28.000Z:

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/ResFileDecoder.java
+++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResFileDecoder.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.

Owner

iBotPeaches commented Mar 18, 2015

Comment #4 originally posted by pour.garbage on 2014-10-23T01:45:28.000Z:

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/ResFileDecoder.java
+++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResFileDecoder.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.

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 18, 2015

Owner

Comment #5 originally posted by pour.garbage on 2014-10-23T02:40:21.000Z:

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.

Owner

iBotPeaches commented Mar 18, 2015

Comment #5 originally posted by pour.garbage on 2014-10-23T02:40:21.000Z:

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.

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 18, 2015

Owner

Comment #6 originally posted by connor.tumbleson on 2014-10-23T03:05:58.000Z:

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.

3e6fc8c

Owner

iBotPeaches commented Mar 18, 2015

Comment #6 originally posted by connor.tumbleson on 2014-10-23T03:05:58.000Z:

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.

3e6fc8c

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 18, 2015

Owner

Comment #7 originally posted by pour.garbage on 2014-10-23T04:28:24.000Z:

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.

Owner

iBotPeaches commented Mar 18, 2015

Comment #7 originally posted by pour.garbage on 2014-10-23T04:28:24.000Z:

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.

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 18, 2015

Owner

Comment #8 originally posted by pour.garbage on 2014-10-23T04:34:48.000Z:

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.

Owner

iBotPeaches commented Mar 18, 2015

Comment #8 originally posted by pour.garbage on 2014-10-23T04:34:48.000Z:

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.

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