Test apps for content provider tests.

Bug: 195963690
Test: None. Includes only helper apps for tests.

Change-Id: I2fff880ab7953277ea0cdfd51afa5e10a57d8704
diff --git a/tests/tests/packageinstaller/test-apps/contentprovider/Android.bp b/tests/tests/packageinstaller/test-apps/contentprovider/Android.bp
new file mode 100644
index 0000000..37c828e
--- /dev/null
+++ b/tests/tests/packageinstaller/test-apps/contentprovider/Android.bp
@@ -0,0 +1,68 @@
+// Copyright (C) 2022 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 {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+android_test_helper_app {
+    name: "CtsUnprotectedContentProvider",
+    defaults: ["cts_defaults"],
+    sdk_version: "current",
+    min_sdk_version: "23",
+    srcs: ["src/**/*.java"],
+    manifest: "AndroidManifestUnprotected.xml",
+    static_libs: ["androidx.test.rules"],
+    // tag this module as a cts test artifact
+    test_suites: [
+        "arcts",
+        "cts",
+        "general-tests",
+        "sts",
+    ],
+}
+
+android_test_helper_app {
+    name: "CtsExportedContentProvider",
+    defaults: ["cts_defaults"],
+    sdk_version: "current",
+    min_sdk_version: "23",
+    srcs: ["src/**/*.java"],
+    manifest: "AndroidManifestExported.xml",
+    static_libs: ["androidx.test.rules"],
+    // tag this module as a cts test artifact
+    test_suites: [
+        "arcts",
+        "cts",
+        "general-tests",
+        "sts",
+    ],
+}
+
+android_test_helper_app {
+    name: "CtsUnexportedContentProvider",
+    defaults: ["cts_defaults"],
+    sdk_version: "current",
+    min_sdk_version: "23",
+    srcs: ["src/**/*.java"],
+    manifest: "AndroidManifestUnexported.xml",
+    static_libs: ["androidx.test.rules"],
+    // tag this module as a cts test artifact
+    test_suites: [
+        "arcts",
+        "cts",
+        "general-tests",
+        "sts",
+    ],
+}
diff --git a/tests/tests/packageinstaller/test-apps/contentprovider/AndroidManifestExported.xml b/tests/tests/packageinstaller/test-apps/contentprovider/AndroidManifestExported.xml
new file mode 100644
index 0000000..2bd7ee9
--- /dev/null
+++ b/tests/tests/packageinstaller/test-apps/contentprovider/AndroidManifestExported.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2022 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.
+  -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="android.packageinstaller.exportedcontentprovider">
+
+    <application
+        android:label="Exported Test Content Provider App">
+        <provider
+            android:name="android.packageinstaller.contentprovider.MyTestProvider"
+            android:authorities="android.packageinstaller.exportedcontentprovider"
+            android:grantUriPermissions="false"
+            android:exported="true">
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+                <data android:scheme="content" />
+            </intent-filter>
+            <grant-uri-permission android:path="/foo/bar/baz"/>
+        </provider>
+    </application>
+
+</manifest>
\ No newline at end of file
diff --git a/tests/tests/packageinstaller/test-apps/contentprovider/AndroidManifestUnexported.xml b/tests/tests/packageinstaller/test-apps/contentprovider/AndroidManifestUnexported.xml
new file mode 100644
index 0000000..2ddc5e2
--- /dev/null
+++ b/tests/tests/packageinstaller/test-apps/contentprovider/AndroidManifestUnexported.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2022 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.
+  -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="android.packageinstaller.unexportedcontentprovider">
+
+    <application
+        android:label="Unexported Test Content Provider App">
+        <provider
+            android:name="android.packageinstaller.contentprovider.MyTestProvider"
+            android:authorities="android.packageinstaller.unexportedcontentprovider"
+            android:grantUriPermissions="false"
+            android:exported="false">
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+                <data android:scheme="content" />
+            </intent-filter>
+            <grant-uri-permission android:path="/foo/bar/baz"/>
+        </provider>
+    </application>
+
+</manifest>
\ No newline at end of file
diff --git a/tests/tests/packageinstaller/test-apps/contentprovider/AndroidManifestUnprotected.xml b/tests/tests/packageinstaller/test-apps/contentprovider/AndroidManifestUnprotected.xml
new file mode 100644
index 0000000..629dbc2
--- /dev/null
+++ b/tests/tests/packageinstaller/test-apps/contentprovider/AndroidManifestUnprotected.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2022 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.
+  -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="android.packageinstaller.unprotectedcontentprovider">
+
+    <application
+        android:label="Unprotected Test Content Provider App">
+        <provider
+            android:name="android.packageinstaller.contentprovider.MyTestProvider"
+            android:authorities="android.packageinstaller.unprotectedcontentprovider"
+            android:grantUriPermissions="true"
+            android:exported="true">
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+                <data android:scheme="content" />
+            </intent-filter>
+        </provider>
+    </application>
+
+</manifest>
\ No newline at end of file
diff --git a/tests/tests/packageinstaller/test-apps/contentprovider/OWNERS b/tests/tests/packageinstaller/test-apps/contentprovider/OWNERS
new file mode 100644
index 0000000..1db65ea
--- /dev/null
+++ b/tests/tests/packageinstaller/test-apps/contentprovider/OWNERS
@@ -0,0 +1,2 @@
+# Bug component: 195963690
+sumedhsen@google.com
\ No newline at end of file
diff --git a/tests/tests/packageinstaller/test-apps/contentprovider/src/android/packageinstaller/contentprovider/MyTestProvider.java b/tests/tests/packageinstaller/test-apps/contentprovider/src/android/packageinstaller/contentprovider/MyTestProvider.java
new file mode 100644
index 0000000..ad8f158
--- /dev/null
+++ b/tests/tests/packageinstaller/test-apps/contentprovider/src/android/packageinstaller/contentprovider/MyTestProvider.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2022 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 android.packageinstaller.contentprovider;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+public class MyTestProvider extends ContentProvider {
+    @Override
+    public boolean onCreate() {
+        return false;
+    }
+
+    @Nullable
+    @Override
+    public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection,
+            @Nullable String[] selectionArgs, @Nullable String sortOrder) {
+        return null;
+    }
+
+    @Nullable
+    @Override
+    public String getType(@NonNull Uri uri) {
+        return "application/vnd.android.package-archive";
+    }
+
+    @Nullable
+    @Override
+    public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
+        return null;
+    }
+
+    @Override
+    public int delete(@NonNull Uri uri, @Nullable String selection,
+            @Nullable String[] selectionArgs) {
+        return 0;
+    }
+
+    @Override
+    public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection,
+            @Nullable String[] selectionArgs) {
+        return 0;
+    }
+}