Merge remote-tracking branch 'goog/androidx-platform-dev' into master
* goog/androidx-platform-dev:
Update icing from upstream.
Pull upstream changes.
Add denpendencies to AppSearch CmakeLists.txt commands. To allow it re-make when file is updated.
Change-Id: I91403876c4265efee2c710951c00c299e65b3c2a
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..fb61c75 100644
--- a/java/Android.bp
+++ b/java/Android.bp
@@ -16,7 +16,9 @@
name: "libicing-java",
srcs: ["src/**/*.java"],
static_libs: [
+ "androidx.annotation_annotation",
"icing-java-proto-lite",
"libprotobuf-java-lite",
],
+ apex_available: ["com.android.appsearch"],
}
diff --git a/java/tests/instrumentation/Android.bp b/java/tests/instrumentation/Android.bp
index c941acf..fd6c4d7 100644
--- a/java/tests/instrumentation/Android.bp
+++ b/java/tests/instrumentation/Android.bp
@@ -14,13 +14,9 @@
android_test {
name: "IcingSearchEngineTest",
-
- manifest: "AndroidManifest.xml",
-
srcs: [
- "src/**/*.java",
+ "src/com/google/android/icing/**/*.java",
],
-
static_libs: [
"androidx.test.ext.junit",
"androidx.test.rules",
@@ -28,15 +24,24 @@
"libicing-java",
"icing-java-proto-lite",
],
+ jni_libs: ["libicing"],
+ test_suites: ["device-tests"],
+ platform_apis: true,
+ use_embedded_native_libs: true,
+}
- jni_libs: [
- "libicing_jni",
+android_test {
+ name: "AndroidXSmokeTest",
+ srcs: ["src/androidx/**/*.java"],
+ static_libs: [
+ "androidx.appsearch_appsearch",
+ "androidx.test.ext.junit",
+ "androidx.test.runner",
+ "truth-prebuilt",
],
-
- test_suites: [
- "device-tests",
- ],
-
+ jni_libs: ["libicing"],
+ plugins: ["androidx.appsearch_appsearch-compiler-plugin"],
+ test_suites: ["device-tests"],
platform_apis: true,
use_embedded_native_libs: true,
}
diff --git a/java/tests/instrumentation/src/androidx/appsearch/smoketest/AppSearchSmokeTest.java b/java/tests/instrumentation/src/androidx/appsearch/smoketest/AppSearchSmokeTest.java
new file mode 100644
index 0000000..1c92c8d
--- /dev/null
+++ b/java/tests/instrumentation/src/androidx/appsearch/smoketest/AppSearchSmokeTest.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+package androidx.appsearch.smoketest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import androidx.appsearch.app.AppSearchManager;
+import androidx.appsearch.app.AppSearchManager.PutDocumentsRequest;
+import androidx.appsearch.app.AppSearchManager.SetSchemaRequest;
+import androidx.appsearch.app.AppSearchSchema;
+import androidx.appsearch.app.AppSearchSchema.PropertyConfig;
+import androidx.appsearch.app.SearchResults;
+import androidx.appsearch.app.SearchSpec;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.filters.SmallTest;
+
+import com.google.android.icing.proto.IcingSearchEngineOptions;
+
+import org.junit.Test;
+
+@SmallTest
+public class AppSearchSmokeTest {
+ @Test
+ public void smokeTest() throws Exception {
+ IcingSearchEngineOptions o = IcingSearchEngineOptions.newBuilder().build();
+ AppSearchManager appSearch =
+ new AppSearchManager.Builder(ApplicationProvider.getApplicationContext())
+ .build()
+ .get()
+ .getResultValue();
+ AppSearchSchema schema =
+ new AppSearchSchema.Builder("testType")
+ .addProperty(
+ new PropertyConfig.Builder("prop")
+ .setDataType(PropertyConfig.DATA_TYPE_STRING)
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setIndexingType(PropertyConfig.INDEXING_TYPE_PREFIXES)
+ .setTokenizerType(PropertyConfig.TOKENIZER_TYPE_PLAIN)
+ .build())
+ .build();
+ appSearch
+ .setSchema(new SetSchemaRequest.Builder().addSchema(schema).build())
+ .get()
+ .getResultValue();
+ }
+
+ @Test
+ public void smokeTestAnnotationProcessor() throws Exception {
+ AppSearchManager appSearch =
+ new AppSearchManager.Builder(ApplicationProvider.getApplicationContext())
+ .build()
+ .get()
+ .getResultValue();
+ appSearch
+ .setSchema(new SetSchemaRequest.Builder().addDataClass(TestDataClass.class).build())
+ .get()
+ .getResultValue();
+
+ TestDataClass input = new TestDataClass("uri1", "avocado");
+ appSearch
+ .putDocuments(new PutDocumentsRequest.Builder().addDataClass(input).build())
+ .get()
+ .checkSuccess();
+ SearchResults results =
+ appSearch
+ .query(
+ "av",
+ SearchSpec.newBuilder().setTermMatchType(
+ SearchSpec.TERM_MATCH_TYPE_PREFIX).build())
+ .get()
+ .getResultValue();
+
+ assertTrue(results.hasNext());
+ SearchResults.Result result = results.next();
+ assertFalse(results.hasNext());
+
+ assertEquals("uri1", result.getDocument().getUri());
+ assertEquals("avocado", result.getDocument().getPropertyString("body"));
+ TestDataClass output = result.getDocument().toDataClass(TestDataClass.class);
+ assertEquals("uri1", output.getUri());
+ assertEquals("avocado", output.getBody());
+ }
+}
diff --git a/java/tests/instrumentation/src/androidx/appsearch/smoketest/TestDataClass.java b/java/tests/instrumentation/src/androidx/appsearch/smoketest/TestDataClass.java
new file mode 100644
index 0000000..45bbf64
--- /dev/null
+++ b/java/tests/instrumentation/src/androidx/appsearch/smoketest/TestDataClass.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+package androidx.appsearch.smoketest;
+
+import androidx.appsearch.annotation.AppSearchDocument;
+import androidx.appsearch.app.AppSearchSchema.PropertyConfig;
+
+@AppSearchDocument
+public class TestDataClass {
+ @AppSearchDocument.Uri private final String uri;
+
+ @AppSearchDocument.Property(indexingType = PropertyConfig.INDEXING_TYPE_PREFIXES)
+ private final String body;
+
+ TestDataClass(String uri, String body) {
+ this.uri = uri;
+ this.body = body;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public String getBody() {
+ return body;
+ }
+}
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"],
+}