Convert Settings to Android.bp

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

Test: m checkbuild
Test: m RunSettingsRoboTests
Change-Id: I267534c095c30833f77273dbdb1893b7830ed45d
Merged-In: I267534c095c30833f77273dbdb1893b7830ed45d
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..b8d152f
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,48 @@
+java_library {
+    name: "settings-logtags",
+
+    srcs: ["src/**/*.logtags"],
+
+}
+
+// Build the Settings APK
+android_app {
+    name: "Settings",
+    defaults: ["SettingsLibDefaults"],
+    platform_apis: true,
+    certificate: "platform",
+    product_specific: true,
+    privileged: true,
+    required: ["privapp_whitelist_com.android.settings"],
+
+    srcs: ["src/**/*.java"],
+
+    static_libs: [
+        "androidx.slice_slice-builders",
+        "androidx.slice_slice-core",
+        "androidx.slice_slice-view",
+        "androidx.core_core",
+        "androidx.legacy_legacy-support-v4",
+        "androidx.legacy_legacy-support-v13",
+        "androidx.appcompat_appcompat",
+        "androidx.cardview_cardview",
+        "androidx.preference_preference",
+        "androidx.recyclerview_recyclerview",
+        "androidx.legacy_legacy-preference-v14",
+        "androidx.lifecycle_lifecycle-runtime",
+        "androidx.lifecycle_lifecycle-extensions",
+        "guava",
+        "jsr305",
+        "settings-logtags",
+        "setup-wizard-lib-gingerbread-compat",
+    ],
+
+    libs: [
+        "telephony-common",
+        "ims-common",
+    ],
+
+    optimize: {
+        proguard_flags_files: ["proguard.flags"],
+    },
+}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index 3be56c3..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,65 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-        $(call all-logtags-files-under, src)
-
-LOCAL_MODULE := settings-logtags
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# Build the Settings APK
-include $(CLEAR_VARS)
-
-LOCAL_PACKAGE_NAME := Settings
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_CERTIFICATE := platform
-LOCAL_PRODUCT_MODULE := true
-LOCAL_PRIVILEGED_MODULE := true
-LOCAL_REQUIRED_MODULES := privapp_whitelist_com.android.settings
-LOCAL_MODULE_TAGS := optional
-LOCAL_USE_AAPT2 := true
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_STATIC_ANDROID_LIBRARIES := \
-    androidx.slice_slice-builders \
-    androidx.slice_slice-core \
-    androidx.slice_slice-view \
-    androidx.core_core \
-    androidx.legacy_legacy-support-v4 \
-    androidx.legacy_legacy-support-v13 \
-    androidx.appcompat_appcompat \
-    androidx.cardview_cardview \
-    androidx.preference_preference \
-    androidx.recyclerview_recyclerview \
-    androidx.legacy_legacy-preference-v14 \
-
-LOCAL_JAVA_LIBRARIES := \
-    telephony-common \
-    ims-common
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    androidx.lifecycle_lifecycle-runtime \
-    androidx.lifecycle_lifecycle-extensions \
-    guava \
-    jsr305 \
-    settings-logtags \
-
-LOCAL_PROGUARD_FLAG_FILES := proguard.flags
-
-ifneq ($(INCREMENTAL_BUILDS),)
-    LOCAL_PROGUARD_ENABLED := disabled
-    LOCAL_JACK_ENABLED := incremental
-    LOCAL_JACK_FLAGS := --multi-dex native
-endif
-
-include frameworks/opt/setupwizard/library/common-gingerbread.mk
-include frameworks/base/packages/SettingsLib/common.mk
-
-include $(BUILD_PACKAGE)
-
-# Use the following include to make our test apk.
-ifeq (,$(ONE_SHOT_MAKEFILE))
-include $(call all-makefiles-under,$(LOCAL_PATH))
-endif
diff --git a/tests/Android.mk b/tests/Android.mk
deleted file mode 100644
index fd297e3..0000000
--- a/tests/Android.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# Include all makefiles in subdirectories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/anomaly-tester/Android.bp b/tests/anomaly-tester/Android.bp
new file mode 100644
index 0000000..0200807
--- /dev/null
+++ b/tests/anomaly-tester/Android.bp
@@ -0,0 +1,24 @@
+android_test {
+    name: "AnomalyTester",
+
+    certificate: "platform",
+
+    libs: ["android.test.runner"],
+
+    static_libs: [
+        "android-support-test",
+        "mockito-target",
+        "ub-uiautomator",
+        "truth-prebuilt",
+    ],
+
+    srcs: ["**/*.java"],
+
+    optimize: {
+        enabled: false,
+    },
+
+    platform_apis: true,
+
+    instrumentation_for: "Settings",
+}
diff --git a/tests/anomaly-tester/Android.mk b/tests/anomaly-tester/Android.mk
deleted file mode 100644
index 9a0a875..0000000
--- a/tests/anomaly-tester/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_CERTIFICATE := platform
-
-LOCAL_JAVA_LIBRARIES := android.test.runner
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    android-support-test \
-    mockito-target \
-    ub-uiautomator \
-    truth-prebuilt \
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-LOCAL_PACKAGE_NAME := AnomalyTester
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_INSTRUMENTATION_FOR := Settings
-
-LOCAL_USE_AAPT2 := true
-
-include $(BUILD_PACKAGE)
diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp
new file mode 100644
index 0000000..d63f3ba
--- /dev/null
+++ b/tests/robotests/Android.bp
@@ -0,0 +1,24 @@
+//############################################
+// Settings Robolectric test target.         #
+//############################################
+
+android_robolectric_test {
+    name: "SettingsRoboTests",
+
+    srcs: ["src/**/*.java"],
+
+    java_resource_dirs: ["config"],
+
+    libs: [
+        "robolectric_android-all-stub",
+        "Robolectric_all-target",
+        "mockito-robolectric-prebuilt",
+        "truth-prebuilt",
+    ],
+
+    instrumentation_for: "Settings",
+
+    test_options: {
+        timeout: "36000",
+    },
+}
diff --git a/tests/robotests/Android.mk b/tests/robotests/Android.mk
deleted file mode 100644
index 102e8da..0000000
--- a/tests/robotests/Android.mk
+++ /dev/null
@@ -1,45 +0,0 @@
-#############################################
-# Settings Robolectric test target.         #
-#############################################
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := SettingsRoboTests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAVA_RESOURCE_DIRS := config
-
-LOCAL_JAVA_LIBRARIES := \
-    robolectric_android-all-stub \
-    Robolectric_all-target \
-    mockito-robolectric-prebuilt \
-    truth-prebuilt
-
-LOCAL_INSTRUMENTATION_FOR := Settings
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-#############################################################
-# Settings runner target to run the previous target.        #
-#############################################################
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := RunSettingsRoboTests
-
-LOCAL_JAVA_LIBRARIES := \
-    SettingsRoboTests \
-    robolectric_android-all-stub \
-    Robolectric_all-target \
-    mockito-robolectric-prebuilt \
-    truth-prebuilt
-
-LOCAL_TEST_PACKAGE := Settings
-
-LOCAL_INSTRUMENT_SOURCE_DIRS := $(dir $(LOCAL_PATH))../src
-
-LOCAL_ROBOTEST_TIMEOUT := 36000
-
-include external/robolectric-shadows/run_robotests.mk
\ No newline at end of file
diff --git a/tests/uitests/Android.bp b/tests/uitests/Android.bp
new file mode 100644
index 0000000..f31aaec
--- /dev/null
+++ b/tests/uitests/Android.bp
@@ -0,0 +1,41 @@
+// Copyright (C) 2018 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: "SettingsUITests",
+    platform_apis: true,
+    certificate: "platform",
+    test_suites: ["device-tests"],
+    srcs: ["src/**/*.java"],
+
+    libs: [
+        "android.test.runner",
+        "android.test.base",
+    ],
+
+    static_libs: [
+        "android-support-test",
+        "app-helpers-core",
+        "launcher-helper-lib",
+        "metrics-helper-lib",
+        "platform-test-annotations",
+        "settings-helper",
+        "sysui-helper",
+        "timeresult-helper-lib",
+        "truth-prebuilt",
+        "ub-uiautomator",
+    ],
+
+    //sdk_version: "current",
+}
diff --git a/tests/uitests/Android.mk b/tests/uitests/Android.mk
deleted file mode 100644
index 89f9133..0000000
--- a/tests/uitests/Android.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright (C) 2018 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_PACKAGE_NAME := SettingsUITests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_CERTIFICATE := platform
-LOCAL_COMPATIBILITY_SUITE := device-tests
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_JAVA_LIBRARIES := \
-    android.test.runner \
-    android.test.base
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    android-support-test \
-    app-helpers-core \
-    launcher-helper-lib \
-    metrics-helper-lib \
-    platform-test-annotations \
-    settings-helper \
-    sysui-helper \
-    timeresult-helper-lib \
-    truth-prebuilt \
-    ub-uiautomator \
-
-#LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
diff --git a/tests/unit/Android.bp b/tests/unit/Android.bp
new file mode 100644
index 0000000..dc48a38
--- /dev/null
+++ b/tests/unit/Android.bp
@@ -0,0 +1,33 @@
+android_test {
+    name: "SettingsUnitTests",
+
+    // We only want this apk build for tests.
+    certificate: "platform",
+
+    libs: [
+        "android.test.runner",
+        "telephony-common",
+        "ims-common",
+        "android.test.base",
+        "android.test.mock",
+    ],
+
+    static_libs: [
+        "android-support-test",
+        "espresso-core",
+        "espresso-contrib-nodep",
+        "espresso-intents-nodep",
+        "mockito-target-minus-junit4",
+        "platform-test-annotations",
+        "truth-prebuilt",
+        "ub-uiautomator",
+    ],
+
+    // Include all test java files.
+    srcs: ["src/**/*.java"],
+
+    platform_apis: true,
+    test_suites: ["device-tests"],
+
+    instrumentation_for: "Settings",
+}
diff --git a/tests/unit/Android.mk b/tests/unit/Android.mk
deleted file mode 100644
index 1981a63..0000000
--- a/tests/unit/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-LOCAL_CERTIFICATE := platform
-
-LOCAL_JAVA_LIBRARIES := \
-    android.test.runner \
-    telephony-common \
-    ims-common \
-    android.test.base \
-    android.test.mock \
-
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    android-support-test \
-    espresso-core \
-    espresso-contrib-nodep \
-    espresso-intents-nodep \
-    mockito-target-minus-junit4 \
-    platform-test-annotations \
-    truth-prebuilt \
-    ub-uiautomator
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := SettingsUnitTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_COMPATIBILITY_SUITE := device-tests
-
-LOCAL_INSTRUMENTATION_FOR := Settings
-
-include $(BUILD_PACKAGE)