Progress thread: less aggressive redraw

In commit I643e30505f962ebbf67aae57baa06a296006e542 , 'enhance the
progress thread update', I incorrectly amended philz-cwm6's commit to
work around a theoretical issue of keeping the installer's spinning
cube rotating when no progress bar is shown. While my amendment works,
it keeps the progress_thread updating text and overlays even when
sitting at the menu. This is overly aggressive. Change the update
mechanism to only apply when the background installer image is visible.

Also, make ui_increment_frame() static since is is local-only now.

Change-Id: I2fa2f8a0704f562fb027ba4bee9b1b7d278da404
stop showing the background icon progress outside it's scope

Also, extend print_and_error() to act as a pass-through, returning the
original error code.

Conflicts:
	extendedcommands.c
	nandroid.c
	nandroid.h

Change-Id: I3d7ee71f627f871f64defe7902b91b762ca97d59
Code clean-up

* Alphebetize header includes
  - Files that exist at AOSP retain their ordering
* Add missing licensing headers
* Remove some obvious comments
* Whitespace cleanup
* Make local-only functions static
* Prototype static functions if used before defined
* Move non-functions just below header definitions
* Move edifyscripting functions to a new edify header

Change-Id: Ibb11baafa58c81a3673c6a03c5f631a241e1be3e
Allow selective restore of more than one partition

* Can choose more than one partition from the advanced restore menu
* Change nandroid_restore() to use bit flags representing partitions

Change-Id: I883d8cc81b730db672063d96409ae2478ebb63f9
Use OpenSSL libcrypto for MD5 checking

* Use OpenSSL libcrypto static library for both backup and restore md5
  operations
* Warn users when nandroid.md5 is missing entries on restore
* Only verify md5 checksums for partitions selected for restore instead
  of verifying checksums for all files even if not selected for restore
* Remove unneeded nandroid-md5.sh script

Change-Id: I6f2f4ad3c2bfc837698e4bd487d30684de7703e8
Show logo bckgnd after install, backup, restore

Change-Id: Ibbb78a43c51f945d5af781bd4eff2a675212e659
MD5: add a missing bounds check

Change-Id: I866d434953b3479de9c482b9fb311b93d8e9aec9
MD5: handle no newline at end of nandroid.md5

If there is no newline at the end of nandroid.md5, then fgets will not
have '\n' as the last character for the last line. Make sure we aren't
replacing the last legitimate character of a string when reading the
file.

Change-Id: I3664582d7b13a2171bf074a236b44db104bb975a
recovery: SEARCH should work as SELECT_ITEM

Before 2cc22971e40a0ffc7849cdf09dc96916c22136e0, SEARCH worked as
SELECT_ITEM. After that, it became "back".

It is desirable for SEARCH to work as select because it provides
a full control for devices with the 4-capacitive-buttons row.

MENU = DOWN
HOME = UP
SEARCH = SELECT (was BACK)
BACK = BACK

Change-Id: Idc70366d76a18edecb25adce2e35e31e814443c5
Expose ui_has_initialized

Useful for command line processes so they can determine whether ui
functions are possible.

Change-Id: I2e1b8af39806973ae11eaed5bbdb1f3b6ddc7b13
MD5: Abort on errors for cmdline nandroid restore

If 'nandroid restore' is run from the command line, prompts are not
possible (thanks to Phyto Wardt for pointing this out). Abort with a
listing of files that are missing from directory or nandroid.md5.

Change-Id: I527ffeafc5da50e7878ddc103f4fb55218632ce1
Improve touch code

Currently retains swipe-only touch handling, but all elements are in
place to support taps in the future, if desired.

Change-Id: I276111f767ade32717c859c62d1d9f046ffa161c
Support capacitive touch keys

* Adds basic support for capacitive keys (virtual keys)
* Only enabled if BOARD_RECOVERY_SWIPE is enabled

Change-Id: I13ade22991880e4fb5c5c71639660e1563e95a89
Only show Mount USB storage if UMS possible

In the mounts and storage menu:
* Reduce the complexity of if/elses for /data/media and UMS specific
  menu entries with a simple struct
* Only show UMS mount option if vold managed volumes are available and
  usb-otg is not in use. Vold does not have any mechanism to determine
  if a managed volume is usb-otg, so we have to rely on string
  comparison to the volume label. "usbdisk" is by far the most common
  label, so this should cover most devices just fine.

Change-Id: I8a203a614e1c603c32a06b1afb77834cc4cd51ce
Version 6.0.5.0

Notable changes since 6.0.4.9:
* Segfault fixes for command line nandroid backup/restore
* Optimizations to progress thread so it doesn't get overloaded with
  screen updates (this significantly improves backup/restore speed)
* Fixes for command line nandroid backups of vold volumes
* Correctly update background image for errors and finished processes
* Allow selective restore of more than one partition at a time
* New MD5 calculator only verifies checksums of partition(s) selected
  for restore and warns you when files or checksums are not found
* New touch code supports a wider variety of devices for swipe control
  and virtual (capacative touch) keys are now supported
* Only show Mount USB storage option if possible

Change-Id: I813dce9d31ce2aa445a512026a210a558cab39e6
Do not wipe block misc on bootloader msg update

When set_bootloader_message_block() is called, it fopens /misc in write
binary mode, wiping all contents other than what is being written. The
bootloader msg structure is only 1024+32+32 bytes, so some manufacturers
store more than just a bootloader msg on /misc. fopen in read+append
mode so that only the bootloader msg is written and the rest of the
partition is left untouched.

Change-Id: I2d2fbdf067282744864a19d404ca7dc12f688a98
Allow custom bootloader msg offset in block misc

Use board define BOARD_RECOVERY_BLDRMSG_OFFSET with a decimal integer
to define a custom offset where the bootloader message should be
read/written.

Change-Id: Id13a23dd41bb7d907b96d657b8e21eb839dfeaa9
Set SELinux security contexts correctly for init and services.

Otherwise everything is left running in the kernel domain when
booting recovery.

Change-Id: Ie3d86547d5be0b68dd1875a97afe1e00fc3e4da1
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Add seclabel to minivold

Change-Id: Ia5662f4543e4fbb32b02216b64a2f261e22beb25
adbd: switch to su domain when running as root

When adbd runs as root, it should transition into the
su domain. This is needed to run the adbd and shell
domains in enforcing on userdebug / eng devices without
breaking developer workflows.

Use the new device_banner command line option.

Change-Id: Ib33c0dd2dd6172035230514ac84fcaed2ecf44d6