Merge "Mark the modules as VNDK in Android.bp"
diff --git a/adb/client/usb_libusb.cpp b/adb/client/usb_libusb.cpp
index e7f44c6..7025f28 100644
--- a/adb/client/usb_libusb.cpp
+++ b/adb/client/usb_libusb.cpp
@@ -412,8 +412,13 @@
if (it != usb_handles.end()) {
if (!it->second->device_handle) {
// If the handle is null, we were never able to open the device.
- unregister_usb_transport(it->second.get());
+
+ // Temporarily release the usb handles mutex to avoid deadlock.
+ std::unique_ptr<usb_handle> handle = std::move(it->second);
usb_handles.erase(it);
+ lock.unlock();
+ unregister_usb_transport(handle.get());
+ lock.lock();
} else {
// Closure of the transport will erase the usb_handle.
}
diff --git a/adb/socket.h b/adb/socket.h
index 4acdf4a..64d05a9 100644
--- a/adb/socket.h
+++ b/adb/socket.h
@@ -19,84 +19,83 @@
#include <stddef.h>
+#include <memory>
+
#include "fdevent.h"
struct apacket;
class atransport;
/* An asocket represents one half of a connection between a local and
-** remote entity. A local asocket is bound to a file descriptor. A
-** remote asocket is bound to the protocol engine.
-*/
+ * remote entity. A local asocket is bound to a file descriptor. A
+ * remote asocket is bound to the protocol engine.
+ */
struct asocket {
- /* chain pointers for the local/remote list of
- ** asockets that this asocket lives in
- */
- asocket *next;
- asocket *prev;
+ /* chain pointers for the local/remote list of
+ * asockets that this asocket lives in
+ */
+ asocket* next;
+ asocket* prev;
- /* the unique identifier for this asocket
- */
+ /* the unique identifier for this asocket
+ */
unsigned id;
- /* flag: set when the socket's peer has closed
- ** but packets are still queued for delivery
- */
- int closing;
+ /* flag: set when the socket's peer has closed
+ * but packets are still queued for delivery
+ */
+ int closing;
// flag: set when the socket failed to write, so the socket will not wait to
// write packets and close directly.
bool has_write_error;
- /* flag: quit adbd when both ends close the
- ** local service socket
- */
- int exit_on_close;
+ /* flag: quit adbd when both ends close the
+ * local service socket
+ */
+ int exit_on_close;
- /* the asocket we are connected to
- */
+ // the asocket we are connected to
+ asocket* peer;
- asocket *peer;
-
- /* For local asockets, the fde is used to bind
- ** us to our fd event system. For remote asockets
- ** these fields are not used.
- */
+ /* For local asockets, the fde is used to bind
+ * us to our fd event system. For remote asockets
+ * these fields are not used.
+ */
fdevent fde;
int fd;
- /* queue of apackets waiting to be written
- */
- apacket *pkt_first;
- apacket *pkt_last;
+ // queue of apackets waiting to be written
+ apacket* pkt_first;
+ apacket* pkt_last;
- /* enqueue is called by our peer when it has data
- ** for us. It should return 0 if we can accept more
- ** data or 1 if not. If we return 1, we must call
- ** peer->ready() when we once again are ready to
- ** receive data.
- */
- int (*enqueue)(asocket *s, apacket *pkt);
+ /* enqueue is called by our peer when it has data
+ * for us. It should return 0 if we can accept more
+ * data or 1 if not. If we return 1, we must call
+ * peer->ready() when we once again are ready to
+ * receive data.
+ */
+ int (*enqueue)(asocket* s, apacket* pkt);
- /* ready is called by the peer when it is ready for
- ** us to send data via enqueue again
- */
- void (*ready)(asocket *s);
+ /* ready is called by the peer when it is ready for
+ * us to send data via enqueue again
+ */
+ void (*ready)(asocket* s);
- /* shutdown is called by the peer before it goes away.
- ** the socket should not do any further calls on its peer.
- ** Always followed by a call to close. Optional, i.e. can be NULL.
- */
- void (*shutdown)(asocket *s);
+ /* shutdown is called by the peer before it goes away.
+ * the socket should not do any further calls on its peer.
+ * Always followed by a call to close. Optional, i.e. can be NULL.
+ */
+ void (*shutdown)(asocket* s);
- /* close is called by the peer when it has gone away.
- ** we are not allowed to make any further calls on the
- ** peer once our close method is called.
- */
- void (*close)(asocket *s);
+ /* close is called by the peer when it has gone away.
+ * we are not allowed to make any further calls on the
+ * peer once our close method is called.
+ */
+ void (*close)(asocket* s);
- /* A socket is bound to atransport */
- atransport *transport;
+ /* A socket is bound to atransport */
+ atransport* transport;
size_t get_max_payload() const;
};
diff --git a/adb/sockets.cpp b/adb/sockets.cpp
index f28a3df..c53fbb4 100644
--- a/adb/sockets.cpp
+++ b/adb/sockets.cpp
@@ -96,7 +96,7 @@
}
void remove_socket(asocket* s) {
- // socket_list_lock should already be held
+ std::lock_guard<std::recursive_mutex> lock(local_socket_list_lock);
if (s->prev && s->next) {
s->prev->next = s->next;
s->next->prev = s->prev;
diff --git a/adb/transport.cpp b/adb/transport.cpp
index b2e03a0..1b597fd 100644
--- a/adb/transport.cpp
+++ b/adb/transport.cpp
@@ -615,15 +615,15 @@
static void transport_unref(atransport* t) {
CHECK(t != nullptr);
- size_t old_refcount = t->ref_count--;
- CHECK_GT(old_refcount, 0u);
-
- if (old_refcount == 1u) {
+ std::lock_guard<std::recursive_mutex> lock(transport_lock);
+ CHECK_GT(t->ref_count, 0u);
+ t->ref_count--;
+ if (t->ref_count == 0) {
D("transport: %s unref (kicking and closing)", t->serial);
t->close(t);
remove_transport(t);
} else {
- D("transport: %s unref (count=%zu)", t->serial, old_refcount - 1);
+ D("transport: %s unref (count=%zu)", t->serial, t->ref_count);
}
}
diff --git a/adb/transport.h b/adb/transport.h
index 00fad56..374bfc3 100644
--- a/adb/transport.h
+++ b/adb/transport.h
@@ -64,7 +64,7 @@
// it's better to do this piece by piece.
atransport(ConnectionState state = kCsOffline)
- : id(NextTransportId()), ref_count(0), connection_state_(state) {
+ : id(NextTransportId()), connection_state_(state) {
transport_fde = {};
protocol_version = A_VERSION;
max_payload = MAX_PAYLOAD;
@@ -88,7 +88,7 @@
int fd = -1;
int transport_socket = -1;
fdevent transport_fde;
- std::atomic<size_t> ref_count;
+ size_t ref_count = 0;
uint32_t sync_token = 0;
bool online = false;
TransportType type = kTransportAny;
diff --git a/gatekeeperd/SoftGateKeeper.h b/gatekeeperd/SoftGateKeeper.h
index 92d1752..2f4f4d7 100644
--- a/gatekeeperd/SoftGateKeeper.h
+++ b/gatekeeperd/SoftGateKeeper.h
@@ -27,10 +27,10 @@
#include <android-base/memory.h>
#include <gatekeeper/gatekeeper.h>
-#include <nativehelper/UniquePtr.h>
#include <iostream>
#include <unordered_map>
+#include <memory>
namespace gatekeeper {
@@ -173,7 +173,7 @@
typedef std::unordered_map<uint32_t, failure_record_t> FailureRecordMap;
typedef std::unordered_map<uint64_t, fast_hash_t> FastHashMap;
- UniquePtr<uint8_t[]> key_;
+ std::unique_ptr<uint8_t[]> key_;
FailureRecordMap failure_map_;
FastHashMap fast_hash_map_;
};
diff --git a/gatekeeperd/SoftGateKeeperDevice.h b/gatekeeperd/SoftGateKeeperDevice.h
index 229f9a9..e3dc068 100644
--- a/gatekeeperd/SoftGateKeeperDevice.h
+++ b/gatekeeperd/SoftGateKeeperDevice.h
@@ -19,7 +19,7 @@
#include "SoftGateKeeper.h"
-#include <nativehelper/UniquePtr.h>
+#include <memory>
using namespace gatekeeper;
@@ -68,7 +68,7 @@
const uint8_t *provided_password, uint32_t provided_password_length,
uint8_t **auth_token, uint32_t *auth_token_length, bool *request_reenroll);
private:
- UniquePtr<SoftGateKeeper> impl_;
+ std::unique_ptr<SoftGateKeeper> impl_;
};
} // namespace gatekeeper
diff --git a/gatekeeperd/gatekeeperd.cpp b/gatekeeperd/gatekeeperd.cpp
index e6eb3bc..73dab9b 100644
--- a/gatekeeperd/gatekeeperd.cpp
+++ b/gatekeeperd/gatekeeperd.cpp
@@ -23,6 +23,7 @@
#include <inttypes.h>
#include <stdint.h>
#include <unistd.h>
+#include <memory>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
@@ -375,7 +376,7 @@
private:
sp<IGatekeeper> hw_device;
- UniquePtr<SoftGateKeeperDevice> soft_device;
+ std::unique_ptr<SoftGateKeeperDevice> soft_device;
};
}// namespace android
diff --git a/gatekeeperd/tests/gatekeeper_test.cpp b/gatekeeperd/tests/gatekeeper_test.cpp
index b3aea7b..100375f 100644
--- a/gatekeeperd/tests/gatekeeper_test.cpp
+++ b/gatekeeperd/tests/gatekeeper_test.cpp
@@ -19,7 +19,6 @@
#include <gtest/gtest.h>
#include <hardware/hw_auth_token.h>
-#include <nativehelper/UniquePtr.h>
#include "../SoftGateKeeper.h"
diff --git a/libsync/Android.bp b/libsync/Android.bp
index 1646348..3fae5e6 100644
--- a/libsync/Android.bp
+++ b/libsync/Android.bp
@@ -22,10 +22,15 @@
cc_library_shared {
name: "libsync",
- vendor_available: true,
defaults: ["libsync_defaults"],
}
+llndk_library {
+ name: "libsync",
+ symbol_file: "libsync.map.txt",
+ export_include_dirs: ["include"],
+}
+
// libsync_recovery is only intended for the recovery binary.
// Future versions of the kernel WILL require an updated libsync, and will break
// anything statically linked against the current libsync.
diff --git a/libsync/libsync.map.txt b/libsync/libsync.map.txt
index daa28ae..53bb07a 100644
--- a/libsync/libsync.map.txt
+++ b/libsync/libsync.map.txt
@@ -17,16 +17,12 @@
LIBSYNC {
global:
sync_merge; # introduced=26
- sync_get_fence_info; # introduced=26
- sync_free_fence_info; # introduced=26
+ sync_file_info; # introduced=26
+ sync_file_info_free; # introduced=26
+ sync_wait; # vndk
+ sync_fence_info; # vndk
+ sync_pt_info; # vndk
+ sync_fence_info_free; # vndk
local:
*;
};
-
-LIBSYNC_PLATFORM {
- global:
- sync_wait;
- sync_fence_info;
- sync_pt_info;
- sync_fence_info_free;
-} LIBSYNC_PLATFORM;
diff --git a/shell_and_utilities/README.md b/shell_and_utilities/README.md
index 5d10c18..c4e8aac 100644
--- a/shell_and_utilities/README.md
+++ b/shell_and_utilities/README.md
@@ -4,20 +4,25 @@
Since IceCreamSandwich Android has used
[mksh](https://www.mirbsd.org/mksh.htm) as its shell. Before then it used
[ash](https://en.wikipedia.org/wiki/Almquist_shell) (which actually
-remained in the tree up to and including KitKat).
+remained unused in the tree up to and including KitKat).
-Initially Android had a very limited command-line provided by its
-own "toolbox" binary. These days almost everything is supplied by
+Initially Android had a very limited command-line provided by its own
+"toolbox" binary. Since Marshmallow almost everything is supplied by
[toybox](http://landley.net/toybox/) instead.
We started moving a few of the more important tools to full
-BSD implementations in JellyBean before we started in earnest in
+BSD implementations in JellyBean, and continued this work in
Lollipop. Lollipop was a major break with the past in many ways (LP64
support and the switch to ART both having lots of knock-on effects around
the system), so although this was the beginning of the end of toolbox it
(a) didn't stand out given all the other systems-level changes and (b)
in Marshmallow we changed direction and started the move to toybox.
+Not everything is provided by toybox, though. We currently still use
+the BSD dd and grep (because the toybox versions are still unfinished),
+and for the bzip2 command-line tools we use the ones that are part of
+the bzip2 distribution.
+
The lists below show what tools were provided and where they came from in
each release starting with Gingerbread. This doesn't tell the full story,
because the toolbox implementations did have bugs fixed and options added
@@ -25,6 +30,10 @@
`-f`. But this gives you an idea of what was available in any given release,
and how usable it was likely to be.
+Also note that in any given release `toybox` probably contains more
+commands than there are symlinks for in `/system/bin`. You can get the
+full list for a release by running `toybox` directly.
+
Android 2.3 (Gingerbread)
-------------------------
@@ -132,26 +141,26 @@
uptime usleep vmstat wc which whoami xargs xxd yes
-Current AOSP
-------------
+Android 8.0 (Oreo)
+------------------
BSD: dd grep
bzip2: bzcat bzip2 bunzip2
-toolbox: getevent gzip newfs\_msdos gunzip zcat
+toolbox: getevent newfs\_msdos
toybox: acpi base64 basename blockdev cal cat chcon chgrp chmod chown
chroot chrt cksum clear cmp comm cp cpio cut date df diff dirname dmesg
dos2unix du echo env expand expr fallocate false file find flock free
-getenforce getprop groups head hostname hwclock id ifconfig inotifyd
-insmod ionice iorenice kill killall ln load\_policy log logname losetup
-ls lsmod lsof lsusb md5sum microcom mkdir mknod mkswap mktemp modinfo
-modprobe more mount mountpoint mv netstat nice nl nohup od paste patch
-pgrep pidof pkill pmap printenv printf ps pwd readlink realpath renice
-restorecon rm rmdir rmmod runcon sed sendevent seq setenforce setprop
-setsid sha1sum sha224sum sha256sum sha384sum sha512sum sleep sort split
-start stat stop strings swapoff swapon sync sysctl tac tail tar taskset
-tee time timeout top touch tr true truncate tty ulimit umount uname uniq
-unix2dos uptime usleep uudecode uuencode vmstat wc which whoami xargs
-xxd yes
+getenforce getprop groups gunzip gzip head hostname hwclock id ifconfig
+inotifyd insmod ionice iorenice kill killall ln load\_policy log logname
+losetup ls lsmod lsof lspci lsusb md5sum microcom mkdir mkfifo mknod
+mkswap mktemp modinfo modprobe more mount mountpoint mv netstat nice
+nl nohup od paste patch pgrep pidof pkill pmap printenv printf ps pwd
+readlink realpath renice restorecon rm rmdir rmmod runcon sed sendevent
+seq setenforce setprop setsid sha1sum sha224sum sha256sum sha384sum
+sha512sum sleep sort split start stat stop strings swapoff swapon sync
+sysctl tac tail tar taskset tee time timeout top touch tr true truncate
+tty ulimit umount uname uniq unix2dos uptime usleep uudecode uuencode
+vmstat wc which whoami xargs xxd yes zcat