Merge remote-tracking branch 'goog/androidx-platform-dev' into master

* goog/androidx-platform-dev:
  Pull upstream changes.
  Pull upstream changes.
  Move compilation of libicing.so into appsearch:appsearch.
  Move icing lib build.gradle to root of repo.
  Build the external/icing project in a self-contained manner.
  Hide classes from public API surface.
  Pull upstream changes.
  Uncomment CMakeLists.txt to start building icing native lib.
  Update from upstream, including proto location changes.
  Copy over changes made to Google3 codebase in Icing.
  Update CMakeLists.txt to use precompiled protoc.
  Modify external/icing CMake to build against libandroidicu.
  Pull upstream changes.
  Use add_custom_command instead of execute_process for building protos.
  Implement jarjar for icing protos.
  Split icing project into two parts: protos/java, and native lib.
  Modify external/icing CMake to link against libprotobuf.
  Copy over changes made to Google3 codebase in Icing.

Test: m -j
Change-Id: I69b719ca9b0ca9032eaca5ba23c62dfa03b185f8
diff --git a/Android.bp b/Android.bp
index 7982c4f..fb14778 100644
--- a/Android.bp
+++ b/Android.bp
@@ -12,20 +12,6 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-java_library {
-    name: "icing-java-proto-lite",
-    proto: {
-        // If you change the proto type, also update jarjar-rules.txt to match
-        // the corresponding proto lib's package path.
-        type: "lite",
-        include_dirs: ["external/protobuf/src"],
-        canonical_path_from_root: false,
-    },
-    srcs: ["icing/proto/*.proto"],
-    jarjar_rules: "jarjar-rules.txt",
-    sdk_version: "core_current",
-}
-
 cc_defaults {
     name: "libicing_defaults",
 
@@ -46,6 +32,7 @@
         "-Wno-undefined-var-template",
         "-Wno-unused-function",
         "-Wno-unused-parameter",
+        "-Wno-unused-private-field",
         "-Wno-extern-c-compat",
 
         "-funsigned-char",
@@ -53,35 +40,25 @@
     ],
 }
 
-cc_library_static {
-    name: "icing-c-proto",
-    defaults: ["libicing_defaults"],
-    proto: {
-        type: "lite",
-        // Find protos relative from where they're specified (useful for external protos)
-        canonical_path_from_root: false,
-        // Need to be able to see the .pb.h files that are generated
-        export_proto_headers: true,
-    },
-    srcs: ["icing/**/*.proto"],
-}
-
 cc_library_shared {
-    name: "libicing_jni",
+    name: "libicing",
     defaults: ["libicing_defaults"],
     srcs: [
         "icing/**/*.cc",
     ],
     exclude_srcs: [
-        // Tests
+        "icing/**/*-test-*",
+        "icing/**/*-test.*",
         "icing/**/*_test.cc",
-        // Benchmarks
         "icing/**/*_benchmark.cc",
-        // Test-only related files (i.e. utils)
         "icing/testing/**/*",
-        // Tools for manual debugging/investigating
+        "icing/tokenization/reverse_jni/**/*",
+        "icing/tokenization/simple/**/*",
         "icing/tools/**/*",
+        "icing/transform/map/**/*",
+        "icing/transform/simple/**/*",
     ],
+    header_libs: ["jni_headers"],
     static_libs: [
         "icing-c-proto",
         "libutf",
diff --git a/icing/jni.lds b/icing/jni.lds
new file mode 100644
index 0000000..401682a
--- /dev/null
+++ b/icing/jni.lds
@@ -0,0 +1,10 @@
+VERS_1.0 {
+  # Export JNI symbols.
+  global:
+    Java_*;
+    JNI_OnLoad;
+
+  # Hide everything else
+  local:
+    *;
+};
diff --git a/jarjar-rules.txt b/jarjar-rules.txt
deleted file mode 100644
index 0f4292e..0000000
--- a/jarjar-rules.txt
+++ /dev/null
@@ -1 +0,0 @@
-rule com.google.protobuf.** com.google.android.icing.protobuf.@1
diff --git a/java/Android.bp b/java/Android.bp
index 6bc8836..b2c915b 100644
--- a/java/Android.bp
+++ b/java/Android.bp
@@ -16,6 +16,7 @@
     name: "libicing-java",
     srcs: ["src/**/*.java"],
     static_libs: [
+        "androidx.annotation_annotation",
         "icing-java-proto-lite",
         "libprotobuf-java-lite",
     ],
diff --git a/java/tests/instrumentation/Android.bp b/java/tests/instrumentation/Android.bp
index c941acf..6cb579d 100644
--- a/java/tests/instrumentation/Android.bp
+++ b/java/tests/instrumentation/Android.bp
@@ -30,7 +30,7 @@
     ],
 
     jni_libs: [
-        "libicing_jni",
+        "libicing",
     ],
 
     test_suites: [
diff --git a/proto/Android.bp b/proto/Android.bp
new file mode 100644
index 0000000..7bc1859
--- /dev/null
+++ b/proto/Android.bp
@@ -0,0 +1,37 @@
+// 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.
+
+java_library {
+    name: "icing-java-proto-lite",
+    proto: {
+        type: "lite",
+        include_dirs: ["external/protobuf/src"],
+        canonical_path_from_root: false,
+    },
+    srcs: ["icing/proto/*.proto"],
+    sdk_version: "core_current",
+}
+
+cc_library_static {
+    name: "icing-c-proto",
+    defaults: ["libicing_defaults"],
+    proto: {
+        type: "lite",
+        // Find protos relative from where they're specified (useful for external protos)
+        canonical_path_from_root: false,
+        // Need to be able to see the .pb.h files that are generated
+        export_proto_headers: true,
+    },
+    srcs: ["icing/**/*.proto"],
+}