Include libadbconnection_server in the art apex.

(Also fixes a warning that gets turned on as a result of the change to
use art_defaults to libadbconnection_server)

Bug: http://b/142945903
Test: m
Test: art/build/apex/runtests.sh
Test: adb shell su 0 cat /proc/`adb shell pidof adbd`/maps | cut -c 74- | grep libadbconnection_server
Change-Id: I0ae5668af28f56b7f3c4024f7af4d2c7787b1d48
diff --git a/adbconnection/Android.bp b/adbconnection/Android.bp
index da73619..5bbad72 100644
--- a/adbconnection/Android.bp
+++ b/adbconnection/Android.bp
@@ -55,15 +55,25 @@
     ],
 }
 
+// We export a library to do the server-side socket handling that gets loaded
+// by adbd from the art apex, so that we can update the socket handling
+// independently from the adbd apex.
 cc_library {
     name: "libadbconnection_server",
-    visibility: [
-        // TODO(b/133140750): Clean this up.
-        "//system/core/adb",
-    ],
     srcs: ["adbconnection_server.cc"],
+
     export_include_dirs: ["include"],
     shared_libs: ["libbase"],
+
+    defaults: ["art_defaults"],
+    visibility: [
+        "//system/core/adb",
+    ],
+    stubs: {
+        symbol_file: "libadbconnection_server.map.txt",
+        versions: ["1"],
+    },
+
     host_supported: true,
     recovery_available: true,
 }
diff --git a/adbconnection/adbconnection_server.cc b/adbconnection/adbconnection_server.cc
index 9c1aff9..f69f4a7 100644
--- a/adbconnection/adbconnection_server.cc
+++ b/adbconnection/adbconnection_server.cc
@@ -72,12 +72,12 @@
   }
 
   while (true) {
-    int rc = TEMP_FAILURE_RETRY(epoll_wait(epfd.get(), events.data(), events.size(), -1));
-    if (rc == -1) {
+    int epoll_rc = TEMP_FAILURE_RETRY(epoll_wait(epfd.get(), events.data(), events.size(), -1));
+    if (epoll_rc == -1) {
       PLOG(FATAL) << "epoll_wait failed";
     }
 
-    for (int i = 0; i < rc; ++i) {
+    for (int i = 0; i < epoll_rc; ++i) {
       const epoll_event& event = events[i];
       if (event.data.fd == -1) {
         unique_fd client(TEMP_FAILURE_RETRY(
diff --git a/adbconnection/libadbconnection_server.map.txt b/adbconnection/libadbconnection_server.map.txt
new file mode 100644
index 0000000..b631581
--- /dev/null
+++ b/adbconnection/libadbconnection_server.map.txt
@@ -0,0 +1,22 @@
+#
+# Copyright (C) 2019 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LIBADBCONNECTION_SERVER_1 {
+  global:
+    adbconnection_listen;
+  local:
+    *;
+};
diff --git a/build/apex/Android.bp b/build/apex/Android.bp
index fc9e148..2556923 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -27,6 +27,7 @@
 // the ART APEX.
 art_runtime_base_native_shared_libs = [
     // External API (having APEX stubs).
+    "libadbconnection_server",
     "libdexfile_external",
     "libnativebridge",
     "libnativehelper",
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py
index 3d8c5e3..27b5cf4 100755
--- a/build/apex/art_apex_test.py
+++ b/build/apex/art_apex_test.py
@@ -467,6 +467,7 @@
     self._checker.check_native_library('libnativebridge')
     self._checker.check_native_library('libnativehelper')
     self._checker.check_native_library('libnativeloader')
+    self._checker.check_native_library('libadbconnection_server')
 
     # Check internal libraries for ART.
     self._checker.check_native_library('libadbconnection')