OSDN Git Service

One more dex magic update.
authorDan Bornstein <danfuzz@android.com>
Thu, 26 May 2011 05:23:29 +0000 (22:23 -0700)
committerDan Bornstein <danfuzz@android.com>
Thu, 26 May 2011 05:23:29 +0000 (22:23 -0700)
I missed the dexdeps tool in my earlier change. This fixes it
to recognize both supported dex version numbers.

Change-Id: Ia6a26539f2ab6369ecbf3697b01b7d62a1e836b8

tools/dexdeps/src/com/android/dexdeps/DexData.java

index 7ce5d04..89dff18 100644 (file)
@@ -62,6 +62,13 @@ public class DexData {
         markInternalClasses();
     }
 
+    /**
+     * Verifies the given magic number.
+     */
+    private static boolean verifyMagic(byte[] magic) {
+        return Arrays.equals(magic, HeaderItem.DEX_FILE_MAGIC) ||
+            Arrays.equals(magic, HeaderItem.DEX_FILE_MAGIC_API_13);
+    }
 
     /**
      * Parses the interesting bits out of the header.
@@ -73,7 +80,7 @@ public class DexData {
 
         byte[] magic = new byte[8];
         readBytes(magic);
-        if (!Arrays.equals(magic, HeaderItem.DEX_FILE_MAGIC)) {
+        if (!verifyMagic(magic)) {
             System.err.println("Magic number is wrong -- are you sure " +
                 "this is a DEX file?");
             throw new DexDataException();
@@ -532,6 +539,8 @@ public class DexData {
 
         /* expected magic values */
         public static final byte[] DEX_FILE_MAGIC = {
+            0x64, 0x65, 0x78, 0x0a, 0x30, 0x33, 0x36, 0x00 };
+        public static final byte[] DEX_FILE_MAGIC_API_13 = {
             0x64, 0x65, 0x78, 0x0a, 0x30, 0x33, 0x35, 0x00 };
         public static final int ENDIAN_CONSTANT = 0x12345678;
         public static final int REVERSE_ENDIAN_CONSTANT = 0x78563412;