/** * Verifies that the odex header is valid and a supported version * * @param buf A byte array containing at least the first 8 bytes of an odex file * @param offset The offset within the array to the odex header * @throws NotAnOdexFile If the file is not an odex file * @throws UnsupportedFile If the odex header is valid, but uses unsupported functionality */ public static void verifyOdexHeader(@Nonnull byte[] buf, int offset) { int odexVersion = OdexHeaderItem.getVersion(buf, offset); if (odexVersion == -1) { StringBuilder sb = new StringBuilder("Not a valid odex magic value:"); for (int i=0; i<8; i++) { sb.append(String.format(" %02x", buf[i])); } throw new NotAnOdexFile(sb.toString()); } if (!OdexHeaderItem.isSupportedOdexVersion(odexVersion)) { throw new UnsupportedFile(String.format("Odex version %03d is not supported", odexVersion)); } }
throw new UnsupportedFile(String.format("Dex version %03d is not supported", dexVersion)); throw new UnsupportedFile("Big endian dex files are not supported");
throw new UnsupportedFile(String.format("Dex version %03d is not supported", dexVersion)); throw new UnsupportedFile("Big endian dex files are not supported");
/** * Verifies that the odex header is valid and a supported version * * @param buf A byte array containing at least the first 8 bytes of an odex file * @param offset The offset within the array to the odex header * @throws NotAnOdexFile If the file is not an odex file * @throws UnsupportedFile If the odex header is valid, but uses unsupported functionality */ public static void verifyOdexHeader(@Nonnull byte[] buf, int offset) { int odexVersion = OdexHeaderItem.getVersion(buf, offset); if (odexVersion == -1) { StringBuilder sb = new StringBuilder("Not a valid odex magic value:"); for (int i=0; i<8; i++) { sb.append(String.format(" %02x", buf[i])); } throw new NotAnOdexFile(sb.toString()); } if (!OdexHeaderItem.isSupportedOdexVersion(odexVersion)) { throw new UnsupportedFile(String.format("Odex version %03d is not supported", odexVersion)); } }