class UPS extends Patcher {

    public static UpsCrc readUpsCrc(Context context, File f) throws PatchException, IOException {
        BufferedInputStream stream = null;
        try {
            stream = new BufferedInputStream(new FileInputStream(f));
            CRC32 crc = new CRC32();
            int x;
            for (long i = f.length() - 12; i != 0; i--) {
                x = stream.read();
                if (x == -1)
                    throw new PatchException(context.getString(R.string.notify_error_patch_corrupted));
                crc.update(x);
            }

            long inputCrc = 0;
            for (int i = 0; i < 4; i++) {
                x = stream.read();
                if (x == -1)
                    throw new PatchException(context.getString(R.string.notify_error_patch_corrupted));
                crc.update(x);
                inputCrc += ((long) x) << (i * 8);
            }

            long outputCrc = 0;
            for (int i = 0; i < 4; i++) {
                x = stream.read();
                if (x == -1)
                    throw new PatchException(context.getString(R.string.notify_error_patch_corrupted));
                crc.update(x);
                outputCrc += ((long) x) << (i * 8);
            }

            long realPatchCrc = crc.getValue();
            long patchCrc = readLong(stream);
            if (patchCrc == -1)
                throw new PatchException(context.getString(R.string.notify_error_patch_corrupted));
            return new UpsCrc(inputCrc, outputCrc, patchCrc, realPatchCrc);
        } finally {
            IOUtils.closeQuietly(stream);
        }
    }

    public  UPS(Context context, File patch, File rom, File output);

}