Convert Android.mk to Android.bp

1. Convert ApiDemos/Android.mk to ApiDemos/Android.bp;
2. Convert ApiDemos/tests/Android.mk to ApiDemos/tests/Android.bp

Bug: 186778349
Test: compared the apk files built by Make and Soong
Test: TreeHugger
Change-Id: I7b72a998b56804e647d0908be5a118f9bf2cd896
Merged-In: I7b72a998b56804e647d0908be5a118f9bf2cd896
diff --git a/samples/ApiDemos/Android.bp b/samples/ApiDemos/Android.bp
new file mode 100644
index 0000000..32ae196
--- /dev/null
+++ b/samples/ApiDemos/Android.bp
@@ -0,0 +1,21 @@
+package {
+    // See: http://go/android-license-faq
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+android_test {
+    name: "ApiDemos",
+    // Only compile source java files in this apk.
+    srcs: [
+        "src/**/*.java",
+        "src/com/example/android/apis/app/IRemoteService.aidl",
+        "src/com/example/android/apis/app/IRemoteServiceCallback.aidl",
+        "src/com/example/android/apis/app/ISecondary.aidl",
+    ],
+    static_libs: ["androidx.legacy_legacy-support-v4"],
+    sdk_version: "current",
+    dex_preopt: {
+        enabled: false,
+    },
+    test_suites: ["device-tests"],
+}
diff --git a/samples/ApiDemos/Android.mk b/samples/ApiDemos/Android.mk
deleted file mode 100644
index 9bc1ba0..0000000
--- a/samples/ApiDemos/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := samples tests
-
-# Only compile source java files in this apk.
-LOCAL_SRC_FILES := \
-    $(call all-java-files-under, src) \
-    src/com/example/android/apis/app/IRemoteService.aidl \
-    src/com/example/android/apis/app/IRemoteServiceCallback.aidl \
-    src/com/example/android/apis/app/ISecondary.aidl \
-
-LOCAL_STATIC_ANDROID_LIBRARIES += \
-    androidx.legacy_legacy-support-v4
-
-LOCAL_USE_AAPT2 := true
-
-LOCAL_PACKAGE_NAME := ApiDemos
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-
-LOCAL_SDK_VERSION := current
-
-LOCAL_DEX_PREOPT := false
-
-LOCAL_COMPATIBILITY_SUITE := device-tests
-
-include $(BUILD_PACKAGE)
-
-# Use the folloing include to make our test apk.
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/samples/ApiDemos/tests/Android.bp b/samples/ApiDemos/tests/Android.bp
new file mode 100644
index 0000000..abb7fd7
--- /dev/null
+++ b/samples/ApiDemos/tests/Android.bp
@@ -0,0 +1,21 @@
+package {
+    // See: http://go/android-license-faq
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+android_test {
+    name: "ApiDemosTests",
+    // We only want this apk build for tests.
+    libs: [
+        "android.test.runner.stubs",
+        "android.test.base.stubs",
+    ],
+    static_libs: ["junit"],
+    // Include all test java files.
+    srcs: ["src/**/*.java"],
+    // Notice that we don't have to include the src files of ApiDemos because, by
+    // running the tests using an instrumentation targeting ApiDemos, we
+    // automatically get all of its classes loaded into our environment.
+    instrumentation_for: "ApiDemos",
+    sdk_version: "current",
+}
diff --git a/samples/ApiDemos/tests/Android.mk b/samples/ApiDemos/tests/Android.mk
deleted file mode 100644
index ed37fbe..0000000
--- a/samples/ApiDemos/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_JAVA_LIBRARIES := android.test.runner.stubs android.test.base.stubs
-
-LOCAL_STATIC_JAVA_LIBRARIES := junit
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-# Notice that we don't have to include the src files of ApiDemos because, by
-# running the tests using an instrumentation targeting ApiDemos, we
-# automatically get all of its classes loaded into our environment.
-
-LOCAL_PACKAGE_NAME := ApiDemosTests
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-
-LOCAL_INSTRUMENTATION_FOR := ApiDemos
-
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)