pass blobs to applypatch in incremental OTAs

applypatch now takes patches as blob-valued arguments instead of just
filenames, eliminating the need to unpack all patches to /tmp before
starting to apply them.

Revert the last change I made where sha1_check(read_file(...)) was
substituted for apply_patch_check(...).  apply_patch_check() knows to
check /cache/saved.file if the original source file is missing or has
a bad checksum, which is important if the device loses power or
otherwise restarts during patching.

Change-Id: Ia5b761474b0f809a5a5eed29455b1b145145699e
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index 1e3f9a3..70ab55f 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -690,11 +690,6 @@
 
   if patch_list or updating_recovery or updating_boot:
     script.CacheFreeSpaceCheck(largest_source_size)
-    script.Print("Unpacking patches...")
-    script.UnpackPackageDir("patch", "/tmp/patchtmp")
-
-    for fn, tf, sf, size, patch_sha in patch_list:
-      script.PatchCheck("/tmp/patchtmp/" + tf.name + ".p", patch_sha)
 
   device_specific.IncrementalOTA_VerifyEnd()
 
@@ -718,8 +713,7 @@
 
   script.Print("Patching system files...")
   for fn, tf, sf, size, _ in patch_list:
-    script.ApplyPatch("/"+fn, "-", tf.size, tf.sha1,
-                      sf.sha1, "/tmp/patchtmp/"+fn+".p")
+    script.ApplyPatch("/"+fn, "-", tf.size, tf.sha1, sf.sha1, "patch/"+fn+".p")
     so_far += tf.size
     script.SetProgress(so_far / total_patch_size)
 
@@ -733,7 +727,7 @@
                          target_boot.size, target_boot.sha1),
                       "-",
                       target_boot.size, target_boot.sha1,
-                      source_boot.sha1, "/tmp/patchtmp/boot.img.p")
+                      source_boot.sha1, "patch/boot.img.p")
     so_far += target_boot.size
     script.SetProgress(so_far / total_patch_size)
     print "boot image changed; including."