broo2s / brut.apktool

A tool for reverse engineering Android apk files
http://code.google.com/p/android-apktool/
350 stars 118 forks source link

confusing logic #26

Open ntop001 opened 10 years ago

ntop001 commented 10 years ago

I find some code snippet in ApkDecoder.java

JarFile jf = new JarFile(mApkFile.getAbsoluteFile());
            JarEntry je = jf.getJarEntry("resources.arsc");
            if (je != null) {
                int compression = je.getMethod();
                mCompressResources = (compression != ZipEntry.STORED)
                        && (compression == ZipEntry.DEFLATED);
            }
            jf.close();

as java define

public static final int DEFLATED
Added in API level 1
Zip entry state: Deflated.
Constant Value: 8 (0x00000008)
public static final int STORED
Added in API level 1
Zip entry state: Stored.
Constant Value: 0 (0x00000000)

possible output for above logic

input(compression's value) output(mCompressResources's value )
ZipEntry.STORED false
ZipEntry.DEFLATED true
Others value false

why not just use mCompressResources = (compression == ZipEntry.DEFLATED); which get the same result ?

iBotPeaches commented 10 years ago

Thanks. I've made the change: https://github.com/iBotPeaches/Apktool/commit/d5d03fe1e4ad4b4dcaad49323615cc0c6d40d870