Make NetworkStack actually build in an unbundled setup.

The Java code was already using sdk_version: "current", but the
JNI library did not have an sdk_version attribute, and had
forbidden dependencies on internal libraries such as libcutils,
liblog and libnativehelper.

This CL fixes things as follows:
- Use the NDK log functions, and switch to the NDK liblog.
- Switch to the NDK libnativehelper.
- Drop the dependencies on libcutils and libpcap, which were
  unused.
- Use the libc++ STL, and set the sdk_version of the library to
  current.

Bug: 131703417
Test: m
Test: installed NetworkStack APK via "adb install --staged" results in working networking
Test: builds, boots, wifi works
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: I1a7bd7fe2809b90a66073d8c5d5dcdff646c4286
diff --git a/packages/NetworkStack/Android.bp b/packages/NetworkStack/Android.bp
index e0bb862..62de2ba 100644
--- a/packages/NetworkStack/Android.bp
+++ b/packages/NetworkStack/Android.bp
@@ -56,15 +56,24 @@
     srcs: [
         "jni/network_stack_utils_jni.cpp"
     ],
-
+    sdk_version: "current",
     shared_libs: [
         "liblog",
-        "libcutils",
-        "libnativehelper",
+        "libnativehelper_compat_libc++",
     ],
-    static_libs: [
-        "libpcap",
-    ],
+
+    // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
+    //   java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
+    // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
+    // build because soong complains of:
+    //   module NetworkStack missing dependencies: libc++_shared
+    //
+    // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
+    // we depend on do not dynamically link libc++. This is currently the case, because liblog is
+    // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
+    //
+    // TODO: find a better solution for this in R.
+    stl: "c++_static",
     cflags: [
         "-Wall",
         "-Werror",
@@ -79,7 +88,10 @@
     static_libs: [
         "NetworkStackBase",
     ],
-    jni_libs: ["libnetworkstackutilsjni"],
+    jni_libs: [
+        "libnativehelper_compat_libc++",
+        "libnetworkstackutilsjni",
+    ],
     // Resources already included in NetworkStackBase
     resource_dirs: [],
     jarjar_rules: "jarjar-rules-shared.txt",