private static void verifyMagic(byte[] buf) { if (!OdexHeaderItem.verifyMagic(buf)) { StringBuilder sb = new StringBuilder("Invalid magic value:"); for (int i = 0; i < 8; i++) { sb.append(String.format(" %02x", buf[i])); } throw new NotAnOdexFile(sb.toString()); } }
/** * Gets the dex version from an odex header * * @param buf A byte array containing at least the first 7 bytes of an odex file * @param offset The offset within the buffer to the beginning of the odex header * @return The odex version if the header is valid or -1 if the header is invalid */ public static int getVersion(byte[] buf, int offset) { if (!verifyMagic(buf, offset)) { return -1; } return getVersionUnchecked(buf, offset); }
/** * Gets the dex version from an odex header * * @param buf A byte array containing at least the first 7 bytes of an odex file * @param offset The offset within the buffer to the beginning of the odex header * @return The odex version if the header is valid or -1 if the header is invalid */ public static int getVersion(byte[] buf, int offset) { if (!verifyMagic(buf, offset)) { return -1; } return getVersionUnchecked(buf, offset); }