Indonesia and Vietnam agreed Wednesday to establish joint patrols on their maritime border to improve security in the heavily disputed South China Sea, which is claimed almost entirely by China.