fix unnecessarily slow writing of EMMC partitions

These were attempts to write partitions "conservatively" in hopes of
fixing the problems with writing the radio partition on Nexus 4.  They
didn't work (a kernel patch was needed), but got left in.  They make
writing of partitions unnecessarily slow (ie, we really shouldn't need
to sync() after every 4kb).  Roll back most of them, but leave the
verification read-back in.

Change-Id: I94badc0979e88816c5aa0485f6316c02be69173c
Don't abort on read_file if the file is missing.

Change-Id: I85726bf736203d602428114145c3b98692580656
sr: Fix overlay issues

 * Implement double buffering with no memcpy for overlay mode.
 * Move the split display check to the right place, so that the
   sysfs node is actually initialized on initial startup.
 * Cleanup code.

Change-Id: I6d8b249e8ada80fd1a9f83f2e8ca1f762cb78ae5
sr: Fix sideload error paths

 * Stop sideload and re-enable adbd when cancelled from UI.
 * If sideload file is not found, return INSTALL_NONE.
 * Treat INSTALL_NONE as neither success nor failure.

Change-Id: Id4cc0939bad4235fa3b289465c34bc04458dc2e2

Conflicts:
	adb_install.cpp
	recovery.cpp
sr: Fix overlay harder

 * Use feature test macros instead of QCOM_BSP/MSM_BSP macros:
   - All QCOM targets require overlay and ION.  Remove stub funcs.
   - Split display is detected via MDSS_MDP_RIGHT_MIXER.
 * Alloc ION with ION_SYSTEM_HEAP_ID, as older devices don't have
   ION_SYSTEM_CONTIG_HEAP_ID defined.
 * Put gr_draw back in .bss, it does not need to be on the heap.

Tested and working on p930, mako, e980, find7

Change-Id: I1ec1a70b5d3cb40ee29ad5ae556399bf48bd825b
sr: Only use overlay for MDP 5.x and cleanup a bit

The overlay code currently tries to parse the MDP version to support
MDP 4.0 and higher.  The parsing code fails on most (all?) MDP 4.x
devices because it expects the version to have three digits (4xx).
But the version reported by the kernel only has two digits.  This
means that in practice overlay is only used for MDP 5.x.

Enabling overlay for MDP 4.x revealed the following issues:

 * Older devices with MDP 4.1 and the kernel "mini ION upgrade" such
   as p930 are unable to mmap() the ION memory properly.

 * Newer devices with MDP 4.4 and full ION support such as mako do
   work, but the minui graphics code would need adjusted to work
   because it does not handle the alpha channel properly.

The easiest solution to these issues is to just continue using the
fbdev backend for MDP 4.x.

Also cleanup a couple of error paths while we're here:

 * mmap failure is indicated by MAP_FAILED, not NULL.

 * return NULL when overlay_init fails.

Change-Id: I5236f601fd967111fea736b7382a2295c0551260
sr: Force format /data when wipe_media option is given

Change-Id: I1099fa2d571caa36a8d20db2ff7fc7f30d0f322e
sr: Use in-memory files for SOD and EOD

Change-Id: Ia75203e95837a4a69b420ae769c920992ac6f144
sr: Improve display support

 * As we start using this recovery code on new devices, various
   display quirks are showing up. Let's do it right.
 * Previously we used a single ION buffer and just altered the
   offset when pageflipping. Some older versions of MDSS (kernel)
   don't properly crop the destination rect (hammerhead), so
   let's allocate two buffers and flip between them with the offset
   always at zero.
 * Some display hardware and MDSS kernel versions don't like us
   just shoving buffers down it's throat without vsync running.
   Implemented a simple vsync loop which enables the interrupt
   on-demand and uses a simple signal mechanism to notify waiters.
   The display loop will wait for a vsync before committing
   the current buffer to MDP, and the interrupt will be disabled
   automatically when drawing is done.
 * This also smooths out some of the jank when selecting options
   using the touch UI.

Change-Id: If140b78acf6eaf6d3927cda9f83ac4aee3a64bad
sr: Fix the progress bar

 * The progress thread is running all the time, which causes the device
   to heat up while in recovery. Start this thread only when the
   progress mode is set to something other than EMPTY, and add a
   terminating condition so that it exits when finished.
 * Incorporate Tom's patch to keep it updated when visible, since
   both are needed to get working progress indications without
   killing batteries.

Change-Id: Ib70d2cb25f01d9920ffb698b5b5b47af827ef483