Commit graph

21847 commits

Author SHA1 Message Date
Hans Boehm
bc2a2284e4 Fix memory order and race bugs in Refbase.h & RefBase.cpp
am: 70a46d674a

* commit '70a46d674a04e95da633a5914abd7a55a46e2b3e':
  Fix memory order and race bugs in Refbase.h & RefBase.cpp

Change-Id: I3562b8b9d12d2f26d80a389292eef760ad0919f3
2016-05-20 00:54:27 +00:00
Hans Boehm
70a46d674a Fix memory order and race bugs in Refbase.h & RefBase.cpp
Convert to use std::atomic directly.

Consistently use relaxed ordering for increments, release ordering
for decrements, and an added acquire fence when the count goes to
zero.

Fix what looks like another race in attemptIncStrong:
It seems entirely possible that the final adjustment for
INITIAL_STRONG_VALUE would see e.g. INITIAL_STRONG_VALUE + 1,
since we could be running in the middle of another initial
increment.

Attempt to somewhat document what this actually does, and
what's expected from the client. Hide the documentation in
the .cpp file for now.

Remove a confusing redundant test in decWeak. OBJECT_LIFETIME_STRONG
and OBJECT_LIFETIME_WEAK are the only options, in spite of some
of the original comments.

It's conceivable that either of these issues has resulted in
actual crashes, though I would guess the probability is small.
It's hard enough to reason about this code without the bugs.

Bug: 28705989
Change-Id: I4107a56c3fc0fdb7ee17fc8a8f0dd7fb128af9d8
(cherry picked from commit e263e6c633)
2016-05-19 16:18:26 -07:00
Josh Gao
dc3d0b7175 Merge changes I40a11748,I5e56f17f,Ie3748b6c,I4e1d56a8 into nyc-dev
am: d4af0d64de

* commit 'd4af0d64de042b0425bbae1f91d1720eebcf95a3':
  adb: use asocket's close function when closing.
  adb: switch the socket list mutex to a recursive_mutex.
  adb: clang-format sockets.cpp.
  adb: add implementations of mutex, recursive_mutex.

Change-Id: Ibb251966874a73e7ad745531ebad7b56c9c82e0d
2016-05-19 19:50:30 +00:00
Josh Gao
d4af0d64de Merge changes I40a11748,I5e56f17f,Ie3748b6c,I4e1d56a8 into nyc-dev
* changes:
  adb: use asocket's close function when closing.
  adb: switch the socket list mutex to a recursive_mutex.
  adb: clang-format sockets.cpp.
  adb: add implementations of mutex, recursive_mutex.
2016-05-19 19:36:36 +00:00
Elliott Hughes
3e2f31f1e6 Remove a dead header (<netutils/dhcp.h>).
am: 847d963598

* commit '847d9635980d2343a47bf31519055fb2bbdddc32':
  Remove a dead header (<netutils/dhcp.h>).

Change-Id: I3f452861c4e379b7a7f750d4e2b8107ee0abdcb1
2016-05-19 04:23:29 +00:00
Josh Gao
014b01706c adb: use asocket's close function when closing.
close_all_sockets was assuming that all registered local sockets used
local_socket_close as their close function. However, this is not true
for JDWP sockets.

Bug: http://b/28347842
Change-Id: I40a1174845cd33f15f30ce70828a7081cd5a087e
(cherry picked from commit 53eb31d87c)
2016-05-18 17:20:30 -07:00
Josh Gao
268068f256 adb: switch the socket list mutex to a recursive_mutex.
sockets.cpp was branching on whether a socket close function was
local_socket_close in order to avoid a potential deadlock if the socket
list lock was held while closing a peer socket.

Bug: http://b/28347842
Change-Id: I5e56f17fa54275284787f0f1dc150d1960256ab3
(cherry picked from commit 9b587dec6d)
2016-05-18 17:20:30 -07:00
Josh Gao
63760409ad adb: clang-format sockets.cpp.
Bug: http://b/28347842
Change-Id: Ie3748b6c803d4e8056e9d7abd065a8b99d945a5b
(cherry picked from commit 52bd8526aa)
2016-05-18 17:20:30 -07:00
Josh Gao
6e106990cf adb: add implementations of mutex, recursive_mutex.
Our version of mingw doesn't support std::mutex or
std::recursive_mutex, so implement our own using the Windows primitives.

Bug: http://b/28347842
Change-Id: I4e1d56a89bc5fcb5f859bf5014343697a4a85b77
(cherry picked from commit 903b749f78)
2016-05-18 17:20:30 -07:00
Elliott Hughes
847d963598 Remove a dead header (<netutils/dhcp.h>).
9c07eb9dd8 removed the implementation, but
missed the header file.

Bug: http://b/27192644
Change-Id: I809a3eb0081b05783b70dbca0274cdde6b1b31a6
2016-05-18 14:22:15 -07:00
Dimitry Ivanov
b4029f1936 Set parent namespace for linker-namespaces
am: ade364b456

* commit 'ade364b4566212a0c16920443a84aa85ac31f781':
  Set parent namespace for linker-namespaces

Change-Id: I07b56584398c43d949bfaa8931074da140a0e071
2016-05-18 07:40:06 +00:00
Dimitry Ivanov
ade364b456 Set parent namespace for linker-namespaces
This change allows applications to share RTLD_GLOBAL
native libraries between namespaces associated with
different classloaders.

The rule is - if a library is GLOBAL within namespace
associated with parent classloader, it is shared
with namespace associated with this classloader

Note that the sharing happens on create_namespace
event, which is tied to createClassloader in case of
application classloaders created by the framework, for
custom application classloaders it is tied to first
loadLibrary() event.

Bug: http://b/28560538
Bug: https://code.google.com/p/android/issues/detail?id=208458
Change-Id: I7ee701166f8ec5eff033b7acc0f80c7aa4ec5bda
(cherry picked from commit 24db75c1ce)
2016-05-17 15:58:56 -07:00
Ruchi Kandoi
8b38bcc915 healthd: Check if battery device exists instead of charger drivers before setting fake properties. am: 9cb3d3ccf4 am: f2ca669e80
am: 6e394f0f6c

* commit '6e394f0f6c693e6f05def66d0427abd385b3f798':
  healthd: Check if battery device exists instead of charger drivers before setting fake properties.

Change-Id: Iea48fb20a7f07c7b9cb212cafd00147f07021ae2
2016-05-17 18:42:29 +00:00
Ruchi Kandoi
6e394f0f6c healthd: Check if battery device exists instead of charger drivers before setting fake properties. am: 9cb3d3ccf4
am: f2ca669e80

* commit 'f2ca669e80078254ad3aceac800161b3266d3195':
  healthd: Check if battery device exists instead of charger drivers before setting fake properties.

Change-Id: I8115836dbd81264634dd7ab84bc360ac610a030b
2016-05-17 18:23:04 +00:00
Ruchi Kandoi
f2ca669e80 healthd: Check if battery device exists instead of charger drivers before setting fake properties.
am: 9cb3d3ccf4

* commit '9cb3d3ccf49bf0fd484563fbf611c68789d5b8a9':
  healthd: Check if battery device exists instead of charger drivers before setting fake properties.

Change-Id: I521f7a7d097da915e40a273d73a655aa01ea397e
2016-05-17 18:20:14 +00:00
Michael Wright
a12fb416d7 Merge "Fix strstr16." into nyc-dev
am: a34a383607

* commit 'a34a383607007d632878929c6c9278221242d457':
  Fix strstr16.

Change-Id: Ia41d8da5d627ac1e28f2fe7b02c7e9a740727556
2016-05-17 17:27:56 +00:00
Michael Wright
a34a383607 Merge "Fix strstr16." into nyc-dev 2016-05-17 17:18:49 +00:00
Dimitry Ivanov
4f31668ad8 Pass permitted_path to the linker as is.
am: 25df4bff44

* commit '25df4bff44a0d1a342dc45521bf7e860b3fef947':
  Pass permitted_path to the linker as is.

Change-Id: I46db0abda9d9e1855af499fce47b899f278d0658
2016-05-17 04:05:43 +00:00
Dimitry Ivanov
25df4bff44 Pass permitted_path to the linker as is.
Now that we have the fixed list of whitelisted libraries
there is no longer need to check if java_permitted_path is nullptr.
In fact checking it prevents custom classloaders created by apps
from loading libraries using absolute path.

Bug: http://b/28659864
Change-Id: I1bfc16a573b090f70f078ecccd0e4016939a5dc0
(cherry picked from commit b31caa95ec)
2016-05-16 18:09:15 -07:00
Michael Wright
0fd60eb9b4 Fix strstr16.
strcmp needs a limit, otherwise it will compare the null terminator
with the next character in the haystack, which results in the compare
failing for all searches except where the needle is found at the very
end.

Bug: 28663748
Change-Id: I1939dc4037c2f2a75d617943b063d2d38a8c5e3a
2016-05-16 21:23:07 +01:00
Ruchi Kandoi
9cb3d3ccf4 healthd: Check if battery device exists instead of charger drivers before
setting fake properties.

healthd used to check for registered charger drivers to determine if the
device is an always-plugged device with no battery. This patch changes
it to check for battery instead.

Change-Id: Ie4ff5d3f21dc1a83a780a41eb0c929f66b86d631
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
(cherry picked from commit fabd490f58)
2016-05-16 08:58:35 -07:00
Michael Wright
3fe4a71e5f Merge "Add String16#contains and strstr16 methods." into nyc-dev
am: 8b452b876b

* commit '8b452b876b90dcfff1dab9012b65b5e67c4531a4':
  Add String16#contains and strstr16 methods.

Change-Id: I4174527fa81cc725eb874c664c66b75319534d8f
2016-05-16 13:27:57 +00:00
TreeHugger Robot
8b452b876b Merge "Add String16#contains and strstr16 methods." into nyc-dev 2016-05-16 13:21:11 +00:00
Patrick Tjin
c6535a343f Create symlink in the case where device has no cache partition
Create symlink from /cache to /data/cache for devices
which have no cache partition.

Bug: 28747374
Change-Id: Ifb0c3250f1be345ce46fcdb78533e36c2250bb85
2016-05-13 15:25:04 -07:00
Dimitry Ivanov
7c9b3df8ac Move linker-namespace functions declarations
am: c337cae9ad

* commit 'c337cae9adcb538a4562641f97bdde933d085a82':
  Move linker-namespace functions declarations

Change-Id: Ia6351368a781739b08504034c2a2d59a7fbbde82
2016-05-11 23:14:44 +00:00
Dimitry Ivanov
c337cae9ad Move linker-namespace functions declarations
They are intended for platform use only and we shouldn't have them
in the public header file. This CL moves them to libnativeloader
private header file.

Bug: http://b/28174921
Change-Id: I01cf446d2d8d7cf6f9e31130aa3d4e54fbbbb9fc
(cherry picked from commit 6796522256)
2016-05-11 14:20:12 -07:00
Paul Lawrence
5b8a108ef5 Add fileencrypted=software/ice to fstab options
Bug: 28616054
Change-Id: If9dd4a17641412607ca4e4fed7f7dbf661ff0d25
2016-05-11 07:34:47 -07:00
Dimitry Ivanov
bd8c47e2d4 Merge "nativeloader: Ignore empty java_permitted_path" into nyc-dev
am: 6edd0c3a68

* commit '6edd0c3a68f60541c31fd65080e52939f2be3bc2':
  nativeloader: Ignore empty java_permitted_path

Change-Id: I82e39b78ac4ba67018a2d78c24b77ace01a6f2e8
2016-05-11 05:03:07 +00:00
Dimitry Ivanov
6edd0c3a68 Merge "nativeloader: Ignore empty java_permitted_path" into nyc-dev 2016-05-11 04:58:17 +00:00
Dimitry Ivanov
d0b1531929 nativeloader: Ignore empty java_permitted_path
Passing empty permitted path should result in no-op.
This addresses review comment on CL with commit
f334cbf0e1

Bug: http://b/28639227
Change-Id: I4a4540e522e90a145a374939921932c86f35e88d
2016-05-10 17:32:38 -07:00
Paul Crowley
2b2e3f1130 Merge "Wipe device on policy error" into nyc-dev
am: 8a59fa8524

* commit '8a59fa85243a5f748108279f6d30b01292518b0a':
  Wipe device on policy error

Change-Id: I211e83f34ff89ebe6120c952994c54a331165b93
2016-05-10 22:17:07 +00:00
Paul Crowley
8a59fa8524 Merge "Wipe device on policy error" into nyc-dev 2016-05-10 22:12:49 +00:00
Dimitry Ivanov
ff38020da1 Extend white-listed directories to include /mnt/expand
am: f334cbf0e1

* commit 'f334cbf0e1425633bef96a21b0ce9e30f4c6ffa9':
  Extend white-listed directories to include /mnt/expand

Change-Id: I378ed0ea80684585ca7daa833b91336a8d38c98c
2016-05-10 19:26:45 +00:00
Paul Crowley
af8be58ca2 Wipe device on policy error
If we fail to set a crypto policy on a system-DE directory, this is a
serious and unrecoverable condition; the only way forward is to erase
the entire device. In a future commit we will also allow users the
option of booting again.

Bug: 28318405
Change-Id: Iff1e52c5bbee1beed29dc4b609d24bfeb7d138da
2016-05-10 11:04:39 -07:00
Dimitry Ivanov
f334cbf0e1 Extend white-listed directories to include /mnt/expand
Apps on sdcard live under /mnt/expand and therefore
this directory should be under linker namespaces
permitted_path.

Bug: http://b/28639227
Change-Id: I462f9f23656c95d9c2a48bb3f513abcd9d08f340
2016-05-10 10:39:48 -07:00
Dimitry Ivanov
0fa68d09ce nativeloader: Fix the case of search_path == null
am: cf9892b6d1

* commit 'cf9892b6d1b0138bdf2341aaa0670c43af27cb85':
  nativeloader: Fix the case of search_path == null

Change-Id: I1d0f66272bf687c9df55d80edec6ad42be9f90d4
2016-05-09 21:12:23 +00:00
Dimitry Ivanov
cf9892b6d1 nativeloader: Fix the case of search_path == null
When user creates custom classloader which does not extend
BaseDexClassLoader the librarySearchPath gets set to null
by java.lang.Runtime.doLoad().

This patch makes nativeloader correctly handle it.

Bug: http://b/28659864
Change-Id: I1b61c6bc952984d7c49775a9178fc3270948e62a
(cherry picked from commit 8a0425b86a)
2016-05-09 12:21:55 -07:00
Michael Wright
5bacef33c9 Add String16#contains and strstr16 methods.
These are needed for aapt to find javadoc comments that contain
"@removed" in order to skip them when printing styleable docs.

Bug: 28663748
Change-Id: I8866d2167c41e11d6c2586da369560d5815fd13e
2016-05-09 19:45:07 +01:00
Rubin Xu
518f88a3e9 Return correct length from pmsgRead()
am: 08660a811e

* commit '08660a811e078d3a6ce950a340a1b9071cfd7e8d':
  Return correct length from pmsgRead()

Change-Id: I8c1d910d1e8abb5d8cc7902ccadaa71ad5aed113
2016-05-09 18:13:43 +00:00
Rubin Xu
08660a811e Return correct length from pmsgRead()
Bug: 28610769
Change-Id: I38cac786ca43ef8d9530f4e2e5a0bdd4cc3bccef
2016-05-09 16:53:30 +00:00
Dimitry Ivanov
c484862bf6 Merge "Add public libs from an environment variable" into nyc-dev
am: ea41a18c93

* commit 'ea41a18c933d20264b89fc89febf387231dc0c24':
  Add public libs from an environment variable

Change-Id: I69eeea4830f371c135ca62cc61864a0095e33d94
2016-05-06 22:03:25 +00:00
TreeHugger Robot
ea41a18c93 Merge "Add public libs from an environment variable" into nyc-dev 2016-05-06 21:57:11 +00:00
Josh Gao
881aec4bab Merge "adb: search for a maximum of 16 emulators." into nyc-dev
am: 72e47300fb

* commit '72e47300fb2d7842509c492fcb8ee363d43ef446':
  adb: search for a maximum of 16 emulators.

Change-Id: I9f9c8574ec3aa254886ffa90b387afdcd4c257b8
2016-05-06 21:32:56 +00:00
Josh Gao
72e47300fb Merge "adb: search for a maximum of 16 emulators." into nyc-dev 2016-05-06 21:23:28 +00:00
Dimitry Ivanov
7d02829636 Add public libs from an environment variable
This is enabled only for builds with ro.debuggable=1
It is intended for use only in tests using dalvikvm
and needing access to platform libraries.

Bug: http://b/28449304
Change-Id: I402457d0da542996ccf265aeaa305f09881e4333
(cherry picked from commit 4ddabd01bf)
2016-05-06 13:16:45 -07:00
Josh Gao
9fe742684c adb: search for a maximum of 16 emulators.
Android Wear has unfortunately been using port 5601 for years, which
falls into the range of ports we were previously polling for Android
emulators. Reduce the maximum number of emulators we can support so
that 5601 no longer falls within our range.

Bug: http://b/26468076
Change-Id: I931809cfa412122f4781eebe0164facab12c95f0
2016-05-06 11:27:19 -07:00
Christopher Ferris
e179777765 Merge "Set groups before dropping privileges." into nyc-dev
am: fd1eee58f9

* commit 'fd1eee58f985b3d528ca352ff278d7b200390ab2':
  Set groups before dropping privileges.

Change-Id: Ic03fd1f589234d4ed32110d8bdce531a55fdf9b7
2016-05-05 21:57:40 +00:00
Christopher Ferris
fd1eee58f9 Merge "Set groups before dropping privileges." into nyc-dev 2016-05-05 21:49:43 +00:00
Christopher Ferris
798ba98d5b Merge "Fix null pointer dereference." into nyc-dev
am: dac26a76c3

* commit 'dac26a76c313b21b98d2b3d3ddcb6e824a78e233':
  Fix null pointer dereference.

Change-Id: Ie09bb47f7f7d69713ca65ee686efa5e23d577a0a
2016-05-05 21:23:44 +00:00
Christopher Ferris
dac26a76c3 Merge "Fix null pointer dereference." into nyc-dev 2016-05-05 21:19:52 +00:00