init: add detection of charging mode

Based on Prashant Somashekar's patch which is in turn based on techomancer's
patch http://goo.gl/I19GG.

When BOARD_CHARGING_MODE_BOOTING_LPM is set, init will read that
value (usually from /sys) and enable charging mode when set to 1.

This differs from the original patch in that Samsung-specific lpm.rc
is not loaded, but instead, init.rc is loaded using the "charger" class,
which is how AOSP devices handle charging.

The change is because the either the SELinux or the init.rc changes is
causing lpm.rc to not work, and porting lpm.rc to the Android system
is easier than trying to fix it.

Change-Id: Ice7a074da7e982f9a64aaa97de28bfcbccdc8b91
init: Fix memory corruption when sanitizing platform paths

This commit fixes code that incorrectly increments s when it
hits the terminator character of the string being sanitized.
This means it will randomly start trashing memory beyond the
end of the string being sanitized until it happens to hit two
NULs (\0\0) which will break it out of the loop.

Change-Id: I76553d7f183236a78a0bc7b408e92559b98f732f
toolbox: Add setfattr

Change-Id: I1981604f72d96c9ad38583f03f7f65df1ab865b7

Conflicts:
	toolbox/Android.mk

Change-Id: I3e723c67436a374269767ec2e0594ca35af8d003
charger: allow home button to wake

A squashed commit of the following:

commit 6ce21d726a967b2cc942476758b9ab3851ff39f1
Author: Pawit Pornkitprasan <p.pawit@gmail.com>
Date:   Sun Feb 3 22:21:32 2013 +0700

    charger: do not suspend when handling home

    When using Google's suspend implementation, home press should also wake
    the device from suspend

    Change-Id: I51f3e45c5cb418b0b3718e7223a1336876379043

commit 75a7cf84df719d8cf5cd77093b3f9fee3c09017e
Author: Pawit Pornkitprasan <p.pawit@gmail.com>
Date:   Sat Jul 21 22:09:37 2012 +0700

    charger: allow home button to wake

    On certain devices (e.g. galaxysmtd), the user expects the physical
    home button to be able to wake the device as well as the power button.

    Change-Id: If764f36aba3810dfa5233af8baf0a740b04889e0

Change-Id: I362b227e26bc864a2cad471df799bce2d682ecee
mkbootimg: Support 32K 64K and 128K pagesizes

Signed-off-by: ChampionSwimmer <android@championswimmer.tk>
Signed-off-by: Michael Bestas <mikeioannina@gmail.com>

Change-Id: I0ee608b74a1daefe536b9247f99368f3e043f93d
healthd: charger: only reboot under NORMAL mode

If charger is not launched from normal poweroff charging,
we don't want device to reboot. Just leave charger process
to exit by itself but not reboot when not under NORMAL mode.

Change-Id: I9f6535042d7016e21d172d167069a134c8851fa6
Revert "healthd: charger: Support alarm in power off charging mode"

This reverts commit 0041eb9ba5643c99724fa92e79886deb5758c8e1.

Change-Id: I6920564d072c13d9219a90816f4a21bc5f5b63fd
healthd: Support alarm in power off charging mode

To implement this feature need to let the phone reboot some time
earlier than the alarm time.

Change-Id: I6505a99b51932ffa23518769f8fd4d2590021543
init: Check for symlinks with lstat() not open()

Using open() with an O_NOFOLLOW flag will result in a file falsely
being determined to be a symlink if the open fails for another
reason.

For example, a character device that isn't ready due to the
underlying hardware not being initialized yet will fail to open()

An example of this are any CG2900 device files prior to
execution of ste-cg29xx_ctrl

This uses lstat() instead of open() with O_NOFOLLOW to check
whether a file is a symlink or not.

Change-Id: Ie0d8d94b426c84c29b1b04d41a4cc15536cb307c
Allow a device to define the max number of service groups in init.h

Certain proprieatary binaries (such as tcmd for instance) require
more than 12 supplementary service groups.  By definiing:
TARGET_NR_SVC_SUPP_GIDS := in BoardConfig this can now be changed
per device.

Change-Id: Iab853836a028147c051be21e39575635cb463dd1
Signed-off-by: dhacker29 <davidhackerdvm@gmail.com>
toolbox: new applet restart

- stop + start
- for the lazy.

Change-Id: Ie0ef0e27f5b7819a5575ece6b82c5813f4e38420
init: define BOARD_CHARGING_CMDLINE parameters

Change-Id: I722e49e2a13418bf887c361c85e9d102168ca973
healthd: Use project pathmap for recovery

Change-Id: Ifa71a7adfb3a3d897a6e24e7aa18388c364efb95
Revert "Revert "Revert "put back the unused virtuals in Vector<>"""

This reverts commit 14e215dccc71cda7e6cfde6b96d479a29e91c11c.

Change-Id: I2ca2b7c610916db8c8361b7a9f80942bcca6fbac
Revert "Revert "put back the unused virtuals in Vector<>""

This reverts commit 225c66a48cdc3acef21ee380dc134449749d3cb3

Change-Id: If31a04b81052cbc7dd7bf237c07107c33066d03d

Conditionally Revert "put back the unused virtuals in Vector<>"

These symbols are needed for MR2 camera.tegra and other blobs,
but they conflict with KK blobs so define it for devices that
need it by setting COMMON_GLOBAL_CFLAGS += -DNEEDS_VECTORIMPL_SYMBOLS

Change-Id: I59e66074526f013918a29c3afc10e52b9812778c
adb/fastboot: Support SuperSpeed USB devices

When enumerating USB 3.0 devices, a 6-byte SuperSpeed companion
descriptor follows each standard descriptor. The ADB and Fastboot
Linux clients currently fail to interpret these additional
descriptors and simply bail. Fix this by skipping over them.

Change-Id: I254dad8ed81e8de74a4fac36e8ce54b5da9715fe
Make tombstones directory to not follow symlink.

Use file descriptor to change ownership.

Change-Id: I3e00ccb8496d8d91bae9b78ce5e38e4cabd4a3d6
system: core: fastboot: Increase USB protocol buffer size to 1024

With USB3.0 SS support the max packet size supported by USB protocol
is 1024 bytes. When connected to a USB device in SuperSpeed, if only
512 bytes are sent at a time the device would interpret each transfer
as a short packet and slows down overall throughput. To accommodate
for SuperSpeed USB bulk endpoints, increase the buffer size to 1024.

Change-Id: I4f447fe38045bc0008e2d6dd3f36c2d6819d6c15
healthd: Treat Wipower charging as a form of Wireless Charging

Wipower charging is a form of Wireless charging where the
power path is via induction and control path goes over BT.

Change-Id: Ib2767d512394a0b4aef11a961a83872070a46cd8
Revert "healthd: charger: Modify charger unplug shutdown time to 1s"

This fixes hammerhead off mode charging and shouldn't bother
other devices.

This reverts commit 2e8628e9685c62b2cf881ba9f5aef406713f0175.

Change-Id: Ibe6477884d22e37981a3c5549a3a72aae1963152