DO NOT MERGE - Merge pi-dev@5234907 into stage-aosp-master

Bug: 120848293
Change-Id: Id5b93505f0e715fa4b0ee732ae63730cc38f7c3b
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..8b70d7a
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,51 @@
+// 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_app {
+    name: "DownloadProvider",
+
+    manifest: "AndroidManifest.xml",
+
+    srcs: [
+        "src/**/*.java",
+    ],
+
+    resource_dirs: [
+        "res",
+    ],
+
+    platform_apis: true,
+
+    certificate: "media",
+
+    privileged: true,
+
+    static_libs: ["guava"],
+
+    jacoco: {
+        include_filter: ["com.android.providers.downloads.*"],
+    },
+}
+
+filegroup {
+    name: "download_provider-files",
+
+    srcs: [
+        "src/com/android/providers/downloads/Constants.java",
+        "src/com/android/providers/downloads/DownloadDrmHelper.java",
+        "src/com/android/providers/downloads/OpenHelper.java",
+        "src/com/android/providers/downloads/RawDocumentsHelper.java",
+    ],
+}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index 8d3c7b4..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := DownloadProvider
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_CERTIFICATE := media
-LOCAL_PRIVILEGED_MODULE := true
-LOCAL_STATIC_JAVA_LIBRARIES := guava
-
-LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.providers.downloads.*
-
-include $(BUILD_PACKAGE)
-
-# build UI + tests
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/OWNERS b/OWNERS
index d194753..8134437 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1 +1,2 @@
 jsharkey@android.com
+sudheersai@google.com
diff --git a/tests/Android.bp b/tests/Android.bp
new file mode 100644
index 0000000..3c03c82
--- /dev/null
+++ b/tests/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: "DownloadProviderTests",
+
+    srcs: [
+        "src/**/*.java",
+    ],
+
+    libs: [
+        "android.test.base",
+        "android.test.mock",
+        "android.test.runner",
+    ],
+
+    static_libs: [
+        "mockito-target",
+        "mockwebserver",
+    ],
+
+    platform_apis: true,
+
+    instrumentation_for: "DownloadProvider",
+
+    test_suites: ["device-tests"],
+
+    certificate: "media",
+}
diff --git a/tests/Android.mk b/tests/Android.mk
deleted file mode 100644
index c3d9bcb..0000000
--- a/tests/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_INSTRUMENTATION_FOR := DownloadProvider
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base android.test.mock
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    mockwebserver \
-    mockito-target
-LOCAL_PACKAGE_NAME := DownloadProviderTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_COMPATIBILITY_SUITE := device-tests
-LOCAL_CERTIFICATE := media
-
-include $(BUILD_PACKAGE)
-
-# additionally, build sub-tests in a separate .apk
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/permission/Android.bp b/tests/permission/Android.bp
new file mode 100644
index 0000000..c3767e1
--- /dev/null
+++ b/tests/permission/Android.bp
@@ -0,0 +1,34 @@
+// 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: "DownloadProviderPermissionTests",
+
+    srcs: [
+        "src/**/*.java",
+    ],
+
+    libs: [
+        "android.test.base",
+        "android.test.runner",
+    ],
+
+    static_libs: [
+        "junit",
+    ],
+
+    platform_apis: true,
+
+}
diff --git a/tests/permission/Android.mk b/tests/permission/Android.mk
deleted file mode 100644
index ae96b5c..0000000
--- a/tests/permission/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base
-LOCAL_STATIC_JAVA_LIBRARIES := junit
-LOCAL_PACKAGE_NAME := DownloadProviderPermissionTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-include $(BUILD_PACKAGE)
-
diff --git a/tests/public_api_access/Android.bp b/tests/public_api_access/Android.bp
new file mode 100644
index 0000000..0845bfa
--- /dev/null
+++ b/tests/public_api_access/Android.bp
@@ -0,0 +1,33 @@
+// 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: "DownloadPublicApiAccessTests",
+
+    srcs: [
+        "src/**/*.java",
+    ],
+
+    libs: [
+        "android.test.base",
+        "android.test.runner",
+    ],
+
+    static_libs: [
+        "junit",
+    ],
+
+    platform_apis: true,
+}
diff --git a/tests/public_api_access/Android.mk b/tests/public_api_access/Android.mk
deleted file mode 100644
index 3bc2e8e..0000000
--- a/tests/public_api_access/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base
-LOCAL_STATIC_JAVA_LIBRARIES := junit
-LOCAL_PACKAGE_NAME := DownloadPublicApiAccessTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-include $(BUILD_PACKAGE)
-
diff --git a/ui/Android.bp b/ui/Android.bp
new file mode 100644
index 0000000..5192ead
--- /dev/null
+++ b/ui/Android.bp
@@ -0,0 +1,35 @@
+// 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_app {
+    name: "DownloadProviderUi",
+
+    manifest: "AndroidManifest.xml",
+
+    srcs: [
+        ":download_provider-files",
+        "src/**/*.java",
+    ],
+
+    resource_dirs: [
+        "res",
+    ],
+
+    platform_apis: true,
+
+    certificate: "media",
+
+    privileged: true,
+}
diff --git a/ui/Android.mk b/ui/Android.mk
deleted file mode 100644
index f63d7e3..0000000
--- a/ui/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) \
-    ../src/com/android/providers/downloads/OpenHelper.java \
-    ../src/com/android/providers/downloads/Constants.java \
-    ../src/com/android/providers/downloads/DownloadDrmHelper.java \
-    ../src/com/android/providers/downloads/RawDocumentsHelper.java
-
-LOCAL_PACKAGE_NAME := DownloadProviderUi
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_CERTIFICATE := media
-LOCAL_PRIVILEGED_MODULE := true
-
-include $(BUILD_PACKAGE)