init: Allow device-specific appends to the property service permission structs

Extends device_perms.h API to allow property_perms and control_perms to be
appended on a device-specific basis, without needing to redefine the entire
struct contents.

Conflicts:
	init/property_service.c

Change-Id: Ifa4ec83cbd72b063da5bb8964677fcfd8f4831c5
adb: Fix backup fallback

 * Check for existence of binary first

Conflicts:
	adb/backup_service.c

Change-Id: I5c1884655ae031f51cb935221ae7870b016e259d
Revert "sdcard: Allow building as a static library"

For some reason (maybe gcc) the sdcard daemon is broken for some devices

I can't reproduce this error but I got some logs below:

from logcat
http://paste.omnirom.org/view/380f6994

from kernel
http://paste.omnirom.org/view/3ebfe137

This reverts commit 1e8b51531e4d9ff356da0c09da4bf2860d523c8c.

Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I56b0b8c0b50fdc53101494557c773ce717273bd0
init: uevent: Add msm video symbolic link handling

Create meaningful symbolic links for video encode/decode
devices based on link_name sysfs node so that video client
doesn't have to rely on dynamic dev node names like device32,
device33 etc.

(cherry picked from commit d26280b5d327994c3c89c573de7738b3f47b8600)
(cherry picked from commit c8f57166fadd26648bd9ee0a979a789c944ccba3)
(cherry picked from commit 72e4c35b308270f44795ebcc196319096397c6c1)
(cherry picked from commit aec73795517e7f49c5ebbea611da612b99ba75fb)

Change-Id: Id308a10d3e601616b63ecd1373809c96f0d04435
Add support for -R (recurse) to init chown builtin.

This is helpful for setting ownerships on entire directory trees,
such as sysfs and selinuxfs, particularly when the precise set of
files is dynamically generated at runtime.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>

Change-Id: I81070ea36fd7ffcab4ee8b3ef1bb0028d4b7839c
init: Allow load of lpm.rc by parsing a cmdline argument

A usage example could be:
BOARD_LPM_BOOT_ARGUMENT_NAME := lpm_boot
BOARD_LPM_BOOT_ARGUMENT_VALUE := 1
Where lpm_boot is the argument to read, and 1 the value of it when kernel says we should enter offline charging mode

Change-Id: I2b073a0968d65ba9e3bf6b397280241c1fb0c0f9
init.rc: Restored TCP performance tuning

This patch tunes the TCP buffer sizes for high
performance data links including global max rmem
and wmem.

Change-Id: I78dc92bc8190883686678230b0a34a8e32507fa5
CRs-Fixed: 439205 435908
init: add a restorecon_recursive built-in command to init.

Functionally equivalent to the restorecon -R toolbox command.

Also, fix error handling and documentation for restorecon command.

<3>[    5.447612] init: /init.rc: 230: invalid command 'restorecon_recursive'

Signed-off-by: Humberto Borba <humberos@gmail.com>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Change-Id: Ia7fbcc82645baf52c6bff0490d3492f458881cbb
restorecon /data/misc/media.

Otherwise it will be mislabeled on upgrades with existing userdata.

AOSP: https://android-review.googlesource.com/79022/

Signed-off-by: Humberto Borba <humberos@gmail.com>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Change-Id: Ibde88d5d692ead45b480bb34cfe0831baeffbf94
init: fix cache permissions

required fo dexopt

Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I299509b68e82a2b3c60eabec1998eaa12c60bc71
ueventd.rc: Change owner of graphics drivers to system

iWifi Display service needs permission to open these drivers.

Change-Id: I1d9e4ae372f09ecf4104888a9910d09903d892d1
(cherry picked from commit f087420bf5eada3017e107a3a8da4e74f683da18)
(cherry picked from commit 1b3f9226cd3ad681a0ef08038d874921ca62ee4c)
(cherry picked from commit 5b4becc1b814b0f9e96d4f3aaec380d74f4b0739)
Squashed file permission fixes for "adb push"

adb: configure /system file permission with fs_config

adbd changes the permissions of files uploaded by copying
owner's permission to group and other. This causes kernel
load failure if any changes are made to kernel modules
followed by ``adb push'' or ``adb sync'' because file mode
644 would become 666.

The change uses fs_config to get the target mode of files.

In addition, the SELinux file label is set incorrectly
on synced files. Set the label properly.

Signed-off-by: Liang Cheng <licheng@nvidia.com>
Bug: 12264775

Fix "adb push /sdcard/filename"

Don't assume that calling chown(filename, getuid(), getgid())
will always succeed. In the case of /sdcard, a file you create
will be owned by root, so the chown call will fail.

Instead, use uid=gid=-1 so that the chown call is truly a no-op.

Ignore the results of calling chmod. Again, for /sdcard, the
chmod call will never succeed, because the file isn't owned by
the shell user.

Bug: 12441485
Change-Id: I43ad63b86ad62d58847718f5220204f3ec07392d
charger: Draw battery percentage over charger screen

Let user know the exact battery capacity.

Port from https://github.com/CyanogenMod/android_system_core/commit/f7e1ef2461121c1ebe7f1ef3ea25cca397e4c5ab

Change-Id: I841efe8fa516cbd565e06fc2bd640ce7e3030d0b
charger: allow custom charger res

Change-Id: I9fefc823f72fd34b10073179e9f6d4b1f4831895
Example: BOARD_CHARGER_RES := device/samsung/galaxys2/res/charger
system: core: increase the polling time for remount_ro to 3600

eMMC4.5 introduces an addition of cache on the device.
We experienced long flush durations in some of the devices,
and therefore the adb reboot resets the target before the flush
completes.
Latest tests show that increasing it to 2400 wasn't enough thus
it was increased to 3600.

Conflicts:
	libcutils/android_reboot.c

Change-Id: Ifbe7af16aa1861d0d57c808b0240361c0317d5c5
init: Fix serial number display for semc msm7x30 devices

Add proper check since semc msm7x30 bootloader exports
"serialno" in cmdline instead of the standard androidboot.serialno,
so init doesn't pick it

Signed-off-by: Michael Bestas <mikeioannina@gmail.com>

Change-Id: Ib4e715fafc64dd47fb667aeb63a7307334cca844
liblog: add required function

Some Motorola proprietaries require a function named __android_log_loggable. This
change adds the function and solves problems with radio and other
binaries on qualcomm based Motorola phones. This code is activated with
TARGET_USES_MOTOROLA_LOG:=true

Change-Id: I722b42d34198c027f265c3cf9f220d9798814915
init: Add "export_rc" command to export env from a specified file

New export_rc command to import environment variables from
a specified file at the time the command is executed.

Differences between "import" and "export_rc":
1) export_rc can only import environment vars
2) export_rc is performed when the command
   is executed rather than at the time the
   command is parsed (i.e. "import")

Example:
in /init.rc:
    on post-fs
        export_rc /system/etc/init.xyz.rc

in /system/etc/init.xyz.rc:
    export LD_PRELOAD /system/lib/libxyz.so

Change-Id: If616dea5b508c27e9f7a95b5e9db696ecea2fdee
restorecon_recursive("/sys") speed boot time

Currently, the restorecon_recursive("/sys") call in
init.c takes approx 2 seconds on hammerhead. This change
reduces the delay to 1.2 seconds.

1) Avoid double stat call when using nftw (time savings
of 0.3 seconds)
2) Avoid the repeated calls to is_selinux_enabled() (time
savings of 0.5 seconds)

Avoid calling lsetfilecon if the file is already properly
labeled. This doesn't speed up the restorecon on /sys,
but it should help when handling files on /data.

Change-Id: Icf344edc5bfc9520d3a0ebd9527a065d29832f87
Add support for init mknod command.

This is required for statically allocated devices.
These don't hit ueventd and hence doesn't automatically get a device node.

Change-Id: I83d19f0666e1f1bbb369b226fba019994d403a89