Remove duplicate classes from org.apache.http.legacy.stubs

Previously, the org.apache.http.legacy.stubs library contained classes
that were also provided by android.jar stubs library. That caused
problems for app developers, e.g, bug 118826718. This change ensures
that the org.apache.http.legacy.stubs library no longer overlaps with
the android.jar stubs library by subtracting the API specification for
the android.jar from the API specification for this.

This could potentially cause build problems if someone is building
against the org.apache.http.legacy.stubs but not against android.jar
stubs. However, that is very unlikely and easy to fix. Binary
compatibility is not affected by this.

Bug: 119021844
Test: make org.apache.http.legacy.stubs and check classes to ensure
      that they do not contain classes provided by android.jar

Change-Id: I0d45f7fae44ef71a9f5ea97f49e99784ce30f033
diff --git a/Android.bp b/Android.bp
index 743a3e7..409f9e6 100644
--- a/Android.bp
+++ b/Android.bp
@@ -69,5 +69,13 @@
     errorprone: {
         javacflags: ["-Xep:MissingOverride:OFF"], // b/73499927
     },
-    droiddoc_options: ["--hide ReferencesHidden"]
+    // Add dependencies on files used by droiddoc_options.
+    droiddoc_option_files: [":frameworks-base-api-current.txt"],
+    droiddoc_options: [
+        "--hide ReferencesHidden",
+        // Subtract classes from the API .txt / stubs that are in the public SDK API. Without this
+        // the org.apache.http.legacy.jar would contain duplicates of classes in android.jar.
+        // See http://b/119021844 for more details.
+        "--subtract-api $(location :frameworks-base-api-current.txt)",
+    ],
 }