Revert "adb: do not chown/chmod files pushed to sdcard"

This reverts commit 05165edc0b40c182b11e115820ab1822ed478720.
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: I11eaf1d6f6049c1158afc29754fbb7af2baf2c78
restorecon /data/misc/media.

Otherwise it will be mislabeled on upgrades with existing userdata.

Change-Id: Ibde88d5d692ead45b480bb34cfe0831baeffbf94
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
adb: Allow configuring the adb shell with a persistent property.

To set to bash: setprop persist.sys.adb.shell /system/xbin/bash

Change-Id: I24e65f4592aaf23356c13db02c9869076df3b841
Add DC-HSPA+ TCP buffer sizes

Change-Id: I5e7ca981ed79a3563215dd7fcef3504c39e973d5
fs_mgr.c: fix i++ error and optimize code

Change-Id: I4d7c9846143ec5b9f76af42c7ee4d5a7c2a3fd6d
Fix overflow in adb_client

Credit: Joshua Drake
Bug: 12060953

(cherry picked from commit e89e09dd2b9b42184973e3ade291186a2737bced)

Change-Id: I8a9b2592a5e4f7527c607abfe4ea6df6eb550aa8
Add a restorecon_recursive built-in command to init.

Functionally equivalent to the restorecon -R toolbox command.
A use case is given by:
I48eaa2b9901ac8c978192c14493ba1058a089423

Also, fix error handling and documentation for restorecon command.

Change-Id: Ia7fbcc82645baf52c6bff0490d3492f458881cbb
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
init: Add vendor-specific initialization hooks

Allow optional vendor-specific initializations
within init.  This can be used for runtime
initialization setup that init rc scripts do
not support.

Change-Id: I7623a0d59b18f9ec8e3623958e2f7ccd72b877bf
(cherry picked from commit a36f7998a135a63934465889f089f96deefe7c42)
(cherry picked from commit 2ce27688b13bbc9a2237442ec2d6a554325ef658)
(cherry picked from commit 8e4dc4f79011bf0a8832e8d1251fc17b3e542057)
chmod: Fix for displaying help

Validate options and number of argument to display help

Change-Id: Ia003bd362c44d5d868e68f45c7dcfea50864dc7b
CRs-Fixed: 589737
sdcard: Respect check_caller_access_to_name on readdir() calls

While looking at a blocked path failed as expected when trying
to access it with a stat(), read(), or getattr(), readdir() still
returned the entry, making devices with mounted external storage fail
com.android.cts.appsecurity.AppSecurityTests#testExternalStorageWrite
by trying to interact with otherwise invisible paths.

Fixit by skipping all entries that would've been made invisible at
LOOKUP

Change-Id: Ia8afac0703fa10f78c89046f029776bd290e4846
libsysutils: Add iovec/runOnEachSocket

SocketClient:
* Replace sendDataLocked with sendDataLockedv which takes an iovec.
* Add a version of sendData, sendDatav, which takes an iovec.
* do not preserve iovec content through sendDatav

SocketListener:
* Add runOnEachSocket, which allows to to specify a SocketClientCommand to
  run individually on each socket. This allows you to do broadcast-like
  actions customized for each individual socket.
* Client safe list reference counting for sendBroadcast & runOnEach Socket

(cherry picked from commit a6e965578e44f8ae5f98de822ba5decec381d5fc)

Signed-off-by: Nick Kralevich <nnk@google.com>
Signed-off-by: Mark Salyzyn <salyzyn@google.com>

Change-Id: I716f89c01b4cb7af900045c7e41fac1492defb06
libsysutils: Get rid of warnings

- UNUSED argument warnings
- Remove LOG_NDEBUG define

(cherry picked from commit 696f267ff5a1e6227c2f5784dae60c190e0228b8)

Change-Id: I48b0942adfdb7a46a7693e580bc6ed5a685b0d5b
libsysutils: SocketListener export release

* Foreground thread (legacy) closes connection by
  reporting false return value for onDataAvailable.
* Background thread can choose instead to close the
  connection asynchronously by calling release, must
  return true for the onDataAvailable method.

(cherry picked from commit d7ad4e409eaac53db3a9789060097b712850b337)

Change-Id: I70ab37d5c22b02804aa3b4dfb26cc9b75291f8b6
libsysutil: frequent native crash /system/bin/vold

regression from commit a6e965578e44f9ae5f98de822ba5decec381dffc

* wrap writev with sigaction SIG_IGN SIGPIPE to emulate the
  send(,,,MSG_NOSIGNAL) call it had replaced.

(cherry pick from commit 83fc720785c4e40f3341daf7c0bf5ee99261fee9)

BUG: 12796279
Change-Id: I14363630ada79c0a5b85bb6b2afd0a1c4d5c3109
Fix assertion failure

Adding 0 items to vector causes assertion failure in _grow -> itemLocation

Change-Id: Ief232a9c12e2e43ee6c87a7a137fe8a94aa741d4
Unicode: Fix mismatched type initialization

Fixes the following:
system/core/libutils/Unicode.cpp:579:27: error: cannot initialize a variable of type 'const uint16_t *const' (aka 'const
unsigned short *const') with an rvalue of type 'char16_t *'
    const uint16_t* const u16end = dst + dstLen;
                          ^        ~~~~~~~~~~~~

Change-Id: I6b1c64d69bb78faeb0e7ae7b08afe05f426c7532
ueventd: fix a busy loop while reading uevents

Under certain conditions, poll() may raise the POLLERR
flag along with POLLIN, in which case the check for
(ufd.revents == POLLIN) results in an endless busy loop.

The following fix was applied to
hardware/libhardware_legacy/uevent/uevent.c
to fix a similar bug:

  commit 3aabb260ceef10377c31c9e45fb239247f5cfeba
  Author: Mathias Agopian <mathias@google.com>
  Date:   Mon Oct 1 14:53:18 2012 -0700

    fix a typo in uevent_next_eventi

    Bug: 7114973
    Change-Id: I15a4c714b59aeb1d02db00517d70b5f0e5ab22c2

Applying the same fix for two more poll loops in init
and ueventd.

https://android.googlesource.com/platform/hardware/libhardware_legacy.git/+/3aabb260ceef10377c31c9e45fb239247f5cfeba
Signed-off-by: houst0nn <houstonn@gmail.com>
Change-Id: I50693f6d3c904992ac4b8a9a14a83c7106e6b9e0
audio: Add Dolby subformat

Add Dolby subformats to support Dual-Mono content

Change-Id: Iff7d141f6689d5c378bee35c9e6627ce8af70cb6
system/audio: Add the the SPDIF device entry

Add the the SPDIF device entry

Change-Id: Ied13adebb4581c4f45ab9fde858c5417c4414d9a