Convert Android.mk file to Android.bp

See build/soong/README.md for more information.

Bug: 122333363
Test: treehugger
Change-Id: Idb03dd371284aec57ed356c6091965672b7b95f5
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..b6bddce
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,32 @@
+android_app {
+    name: "ContactsProvider",
+    // Only compile source java files in this apk.
+    srcs: [
+        "src/**/*.java",
+        "src/com/android/providers/contacts/EventLogTags.logtags",
+    ],
+    libs: [
+        "ext",
+        "telephony-common",
+    ],
+    static_libs: [
+        "android-common",
+        "com.android.vcard",
+        "guava",
+    ],
+
+    // The Jacoco tool analyzes code coverage when running unit tests on the
+    // application. This configuration line selects which packages will be analyzed,
+    // leaving out code which is tested by other means (e.g. static libraries) that
+    // would dilute the coverage results. These options do not affect regular
+    // production builds.
+    jacoco: {
+        include_filter: ["com.android.providers.contacts.*"],
+    },
+    platform_apis: true,
+    certificate: "shared",
+    privileged: true,
+    optimize: {
+        proguard_flags_files: ["proguard.flags"],
+    },
+}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index d31ad73..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-# Only compile source java files in this apk.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_SRC_FILES += \
-        src/com/android/providers/contacts/EventLogTags.logtags
-
-LOCAL_JAVA_LIBRARIES := ext telephony-common
-
-LOCAL_STATIC_JAVA_LIBRARIES += android-common com.android.vcard guava
-
-# The Jacoco tool analyzes code coverage when running unit tests on the
-# application. This configuration line selects which packages will be analyzed,
-# leaving out code which is tested by other means (e.g. static libraries) that
-# would dilute the coverage results. These options do not affect regular
-# production builds.
-LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.providers.contacts.*
-
-LOCAL_PACKAGE_NAME := ContactsProvider
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_CERTIFICATE := shared
-LOCAL_PRIVILEGED_MODULE := true
-
-LOCAL_PROGUARD_FLAG_FILES := proguard.flags
-
-include $(BUILD_PACKAGE)
-
-# Use the following include to make our test apk.
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/test_common/Android.bp b/test_common/Android.bp
new file mode 100644
index 0000000..b30e2e3
--- /dev/null
+++ b/test_common/Android.bp
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 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: "ContactsProviderTestUtils",
+    srcs: ["src/**/*.java"],
+    libs: [
+        "android.test.runner",
+        "androidx.test.rules",
+        "mockito-target-minus-junit4",
+    ],
+}
diff --git a/test_common/Android.mk b/test_common/Android.mk
deleted file mode 100644
index d42ef66..0000000
--- a/test_common/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-    $(call all-java-files-under, src)
-
-LOCAL_JAVA_LIBRARIES := \
-    android.test.runner \
-    androidx.test.rules \
-    mockito-target-minus-junit4
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := ContactsProviderTestUtils
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/tests/Android.bp b/tests/Android.bp
new file mode 100644
index 0000000..b15ded4
--- /dev/null
+++ b/tests/Android.bp
@@ -0,0 +1,23 @@
+android_test {
+    name: "ContactsProviderTests",
+    static_libs: [
+        "ContactsProviderTestUtils",
+        "androidx.test.rules",
+        "mockito-target-minus-junit4",
+    ],
+    libs: [
+        "android.test.runner",
+        "android.test.base",
+        "android.test.mock",
+    ],
+
+    // Only compile source java files in this apk.
+    srcs: ["src/**/*.java"],
+    platform_apis: true,
+    test_suites: ["device-tests"],
+    instrumentation_for: "ContactsProvider",
+    certificate: "shared",
+    optimize: {
+        enabled: false,
+    },
+}
diff --git a/tests/Android.mk b/tests/Android.mk
deleted file mode 100644
index 87b7ab6..0000000
--- a/tests/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    ContactsProviderTestUtils \
-    androidx.test.rules \
-    mockito-target-minus-junit4
-
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base android.test.mock
-
-# Only compile source java files in this apk.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := ContactsProviderTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_COMPATIBILITY_SUITE := device-tests
-
-LOCAL_INSTRUMENTATION_FOR := ContactsProvider
-LOCAL_CERTIFICATE := shared
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-include $(BUILD_PACKAGE)
diff --git a/tests2/Android.bp b/tests2/Android.bp
new file mode 100644
index 0000000..9a2351a
--- /dev/null
+++ b/tests2/Android.bp
@@ -0,0 +1,36 @@
+//
+// Copyright (C) 2016 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.
+//
+
+android_test {
+    name: "ContactsProviderTests2",
+    static_libs: [
+        "ContactsProviderTestUtils",
+        "androidx.test.rules",
+        "mockito-target-minus-junit4",
+    ],
+    libs: [
+        "android.test.runner",
+        "android.test.base",
+    ],
+    srcs: ["src/**/*.java"],
+    platform_apis: true,
+    test_suites: ["device-tests"],
+    instrumentation_for: "ContactsProvider",
+    certificate: "shared",
+    optimize: {
+        enabled: false,
+    },
+}
diff --git a/tests2/Android.mk b/tests2/Android.mk
deleted file mode 100644
index d590163..0000000
--- a/tests2/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Copyright (C) 2016 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    ContactsProviderTestUtils \
-    androidx.test.rules \
-    mockito-target-minus-junit4
-
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := ContactsProviderTests2
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_COMPATIBILITY_SUITE := device-tests
-
-LOCAL_INSTRUMENTATION_FOR := ContactsProvider
-LOCAL_CERTIFICATE := shared
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-include $(BUILD_PACKAGE)