Snap for 7478028 from 3c5cf0bebd44055642a4d0ed34f45cb7434e3e85 to mainline-adbd-release

Change-Id: I22f15dc7524f6c1c1f3ea74d0d65bf1012687b87
diff --git a/Android.bp b/Android.bp
index 3704241..1a3f3ae 100644
--- a/Android.bp
+++ b/Android.bp
@@ -12,4 +12,39 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    default_applicable_licenses: ["external_ppp_license"],
+}
+
+// Added automatically by a large-scale-change that took the approach of
+// 'apply every license found to every target'. While this makes sure we respect
+// every license restriction, it may not be entirely correct.
+//
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
+//
+// Please consider splitting the single license below into multiple licenses,
+// taking care not to lose any license_kind information, and overriding the
+// default license using the 'licenses: [...]' property on targets as needed.
+//
+// For unused files, consider creating a 'fileGroup' with "//visibility:private"
+// to attach the license to, and including a comment whether the files may be
+// used in the current project.
+// See: http://go/android-license-faq
+license {
+    name: "external_ppp_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-0BSD",
+        "SPDX-license-identifier-Apache-2.0",
+        "SPDX-license-identifier-BSD",
+        "SPDX-license-identifier-GPL",
+        "SPDX-license-identifier-GPL-2.0",
+        "SPDX-license-identifier-LGPL",
+        "SPDX-license-identifier-MIT",
+        "legacy_notice",
+        "legacy_unencumbered",
+    ],
+    // large-scale-change unable to identify any license_text files
+}
+
 subdirs = ["pppd"]
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..6d8601b
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,3 @@
+third_party {
+  license_type: RESTRICTED
+}
diff --git a/pppd/Android.bp b/pppd/Android.bp
index 4e01738..dfa36bd 100644
--- a/pppd/Android.bp
+++ b/pppd/Android.bp
@@ -12,6 +12,43 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    default_applicable_licenses: ["external_ppp_pppd_license"],
+}
+
+// Added automatically by a large-scale-change that took the approach of
+// 'apply every license found to every target'. While this makes sure we respect
+// every license restriction, it may not be entirely correct.
+//
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
+//
+// Please consider splitting the single license below into multiple licenses,
+// taking care not to lose any license_kind information, and overriding the
+// default license using the 'licenses: [...]' property on targets as needed.
+//
+// For unused files, consider creating a 'fileGroup' with "//visibility:private"
+// to attach the license to, and including a comment whether the files may be
+// used in the current project.
+// See: http://go/android-license-faq
+license {
+    name: "external_ppp_pppd_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-0BSD",
+        "SPDX-license-identifier-Apache-2.0",
+        "SPDX-license-identifier-BSD",
+        "SPDX-license-identifier-GPL",
+        "SPDX-license-identifier-GPL-2.0",
+        "SPDX-license-identifier-LGPL",
+        "SPDX-license-identifier-MIT",
+        "legacy_notice",
+        "legacy_unencumbered",
+    ],
+    license_text: [
+        "NOTICE",
+    ],
+}
+
 cc_defaults {
     name: "ppp_defaults",
     cflags: [
@@ -23,14 +60,13 @@
         "-Wno-unused-parameter",
         "-Werror",
         "-Wno-pointer-sign",
+        "-DPLUGIN",
     ],
     local_include_dirs: ["include"],
 }
 
-cc_binary {
-    name: "pppd",
-    defaults: ["ppp_defaults"],
-
+filegroup {
+    name: "pppd-sources",
     srcs: [
         "auth.c",
         "ccp.c",
@@ -55,7 +91,17 @@
         "tty.c",
         "upap.c",
         "utils.c",
+    ]
+}
+
+cc_library_static {
+    name: "libpppd",
+    defaults: ["ppp_defaults"],
+
+    srcs: [
+        ":pppd-sources"
     ],
+    export_include_dirs:[".", "include"],
 
     // options.c:623:21: error: passing 'const char *' to parameter of
     // type 'char *' discards qualifiers.
@@ -70,10 +116,10 @@
     ],
 
     cflags: [
+        "-Dmain=main_loop",
         "-Wno-empty-body",
         "-Wno-attributes",
         "-Wno-sign-compare",
-        "-DPLUGIN",
     ],
 
     ldflags: ["-rdynamic"],
@@ -83,6 +129,35 @@
     ],
 }
 
+cc_binary {
+    name: "pppd",
+    defaults: ["ppp_defaults"],
+
+    srcs: [
+        ":pppd-sources"
+    ],
+
+    shared_libs: [
+        "libdl",
+        "liblog",
+        "libcutils",
+        "libcrypto",
+    ],
+
+    ldflags: ["-rdynamic"],
+
+    clang_cflags: ["-Wno-incompatible-pointer-types-discards-qualifiers"],
+
+    required: [
+        "pppol2tp-android",
+        "pppopptp-android",
+    ],
+
+    sanitize: {
+        memtag_heap: true,
+    },
+}
+
 cc_library_shared {
     name: "pppol2tp-android",
     defaults: ["ppp_defaults"],