[Demonstration 1]

[Buggy Method]
@Override
public void beforeHookedMethod(MethodHookParam param) throws Throwable {
    mContext = AndroidAppHelper.currentApplication();
    mContext = (Context) XposedHelpers.getObjectField(param.thisObject, "mContext");
    boolean isInstallStage = "installStage".equals(param.method.getName());
    int flags = 0;
    int id = 0;
    if (isInstallStage) {
        try {
            id = 4;
            flags = (Integer) XposedHelpers.getObjectField(param.args[id], "installFlags");
            XposedBridge.log("PreventADBInstall: Hook Flags Success!");
        } catch (Exception e) {
            XposedBridge.log(e);
        }
    } else {
        try {
            id = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ? 2 : 1;
            flags = (Integer) param.args[id];
            XposedBridge.log("PreventADBInstall: Hook Flags Success!");
        } catch (Exception e) {
            XposedBridge.log(e);
        }
    }
    if (isInstallStage) {
        Object sessions = param.args[id];
        XposedHelpers.setIntField(sessions, "installFlags", flags);
        param.args[id] = sessions;
    } else {
        param.args[id] = flags;
    }
    if (getCallingUid() == 0) {
        param.setResult(null);
        XposedBridge.log("PreventADBInstall: Block Success!");
        Looper.prepare();
        Toast.makeText(mContext, "拦截 ADB 安装成功！", Toast.LENGTH_LONG).show();
        Looper.loop();
        return;
    }
}

[Buggy Hunk]
if (getCallingUid() == 0) {

[Patch]
if (getCallingUid() == 2000) {

[Demonstration 2]

[Buggy Method]
public static File createExternalCacheFile(String prefix, String suffix, Context ctx) throws IOException {
    return Storage.isExternalStorageWritable() ? File.createTempFile(prefix, suffix, ctx.getExternalCacheDir()) : null;
}

[Buggy Hunk]
return Storage.isExternalStorageWritable() ? File.createTempFile(prefix, suffix, ctx.getExternalCacheDir()) : null;

[Patch]
return AndroidStorage.isExternalStorageWritable() ? File.createTempFile(prefix, suffix, ctx.getExternalCacheDir()) : null;

[Demonstration 3]

[Buggy Method]
private static void gatherWithBlockCopying(final List<File> vcfs, final File output) {
    try {
        final FileOutputStream out = new FileOutputStream(output);
        boolean isFirstFile = true;
        for (final File f : vcfs) {
            log.info("Gathering " + f.getAbsolutePath());
            final FileInputStream in = new FileInputStream(f);
            // a) It's good to check that the end of the file is valid and b) we need to know if there's a terminator block and not copy it
            final BlockCompressedInputStream.FileTermination term = BlockCompressedInputStream.checkTermination(f);
            if (term == BlockCompressedInputStream.FileTermination.DEFECTIVE)
                throw new PicardException(f.getAbsolutePath() + " does not have a valid GZIP block at the end of the file.");
            if (!isFirstFile) {
                final BlockCompressedInputStream blockIn = new BlockCompressedInputStream(in, false);
                boolean lastByteNewline = true;
                while (in.available() > 0) {
                    // Read a block - blockIn.available() is guaranteed to return the bytes remaining in the block that has been
                    // read, and since we haven't consumed any yet, that is the block size.
                    final int blockLength = blockIn.available();
                    final byte[] blockContents = new byte[blockLength];
                    final int read = blockIn.read(blockContents);
                    if (blockLength == 0 || read != blockLength)
                        throw new IllegalStateException("Could not read available bytes from BlockCompressedInputStream.");
                    // Scan forward within the block to see if we can find the end of the header within this block
                    int firstNonHeaderByteIndex = -1;
                    for (int i = 0; i < read; ++i) {
                        final byte b = blockContents[i];
                        final boolean thisByteNewline = (b == '\n' || b == '\r');
                        if (lastByteNewline && !thisByteNewline && b != '#') {
                            // Aha!  Found first byte of non-header data in file!
                            firstNonHeaderByteIndex = i;
                            break;
                        }
                        lastByteNewline = thisByteNewline;
                    }
                    // If we found the end of the header then write the remainder of this block out as a
                    // new gzip block and then break out of the while loop
                    if (firstNonHeaderByteIndex >= 0) {
                        final BlockCompressedOutputStream blockOut = new BlockCompressedOutputStream(out, null);
                        blockOut.write(blockContents, firstNonHeaderByteIndex, blockContents.length - firstNonHeaderByteIndex);
                        blockOut.flush();
                        // Don't close blockOut because closing underlying stream would break everything
                        break;
                    }
                }
            }
            // Copy remainder of input stream into output stream
            final long currentPos = in.getChannel().position();
            final long length = f.length();
            final long skipLast = (term == BlockCompressedInputStream.FileTermination.HAS_TERMINATOR_BLOCK) ? BlockCompressedStreamConstants.EMPTY_GZIP_BLOCK.length : 0;
            final long bytesToWrite = length - skipLast - currentPos;
            IOUtil.transferByStream(in, out, bytesToWrite);
            in.close();
            isFirstFile = false;
        }
        // And lastly add the Terminator block and close up
        out.write(BlockCompressedStreamConstants.EMPTY_GZIP_BLOCK);
        out.close();
    } catch (final IOException ioe) {
        throw new RuntimeIOException(ioe);
    }
}

[Buggy Hunk]
while (in.available() > 0) {

[Patch]
while (blockIn.available() > 0) {