diff --git a/javatests/com/android/modules/updatablesharedlibs/Android.bp b/javatests/com/android/modules/updatablesharedlibs/Android.bp
new file mode 100644
index 0000000..1c2f7e7
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/Android.bp
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2021 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"],
+}
+
+java_test_host {
+ name: "UpdatableSharedLibsTest",
+ srcs: [
+ "UpdatableSharedLibsTest.java"
+ ],
+ libs: ["tradefed"],
+ java_resources: [
+ ":test_com.android.modules.updatablesharedlibs",
+ ],
+ data: [
+ ":com.android.modules.updatablesharedlibs.apps.targetS",
+ ":com.android.modules.updatablesharedlibs.apps.targetT",
+ ":com.android.modules.updatablesharedlibs.apps.targetTWithLib",
+ ],
+ static_libs: [
+ "compatibility-host-util",
+ "cts-install-lib-host",
+ "frameworks-base-hostutils",
+ "truth-prebuilt"
+ ],
+}
diff --git a/javatests/com/android/modules/updatablesharedlibs/OWNERS b/javatests/com/android/modules/updatablesharedlibs/OWNERS
new file mode 100644
index 0000000..55f5b97
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/OWNERS
@@ -0,0 +1,5 @@
+# Mainline modularization team
+
+andreionea@google.com
+pedroql@google.com
+satayev@google.com
diff --git a/javatests/com/android/modules/updatablesharedlibs/UpdatableSharedLibsTest.java b/javatests/com/android/modules/updatablesharedlibs/UpdatableSharedLibsTest.java
new file mode 100644
index 0000000..ca2df7d
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/UpdatableSharedLibsTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2021 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 com.android.modules.updatablesharedlibs;
+
+import static org.junit.Assume.assumeTrue;
+
+import com.android.internal.util.test.SystemPreparer;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+
+import android.cts.install.lib.host.InstallUtilsHost;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class UpdatableSharedLibsTest extends BaseHostJUnit4Test {
+
+ private final InstallUtilsHost mHostUtils = new InstallUtilsHost(this);
+ private final TemporaryFolder mTemporaryFolder = new TemporaryFolder();
+ private final SystemPreparer mPreparer = new SystemPreparer(mTemporaryFolder, this::getDevice);
+
+ @Rule
+ public final RuleChain ruleChain = RuleChain.outerRule(mTemporaryFolder).around(mPreparer);
+
+ @Test
+ public void callOnDeviceApiFromHost() throws Exception {
+ if (!getDevice().isAdbRoot()) {
+ getDevice().enableAdbRoot();
+ }
+ assumeTrue("Device does not support updating APEX", mHostUtils.isApexUpdateSupported());
+ assumeTrue("Device requires root", getDevice().isAdbRoot());
+
+ String apex = "test_com.android.modules.updatablesharedlibs.apex";
+ mPreparer.pushResourceFile(apex, "/system/apex/" + apex);
+ mPreparer.reboot();
+ getDevice().disableAdbRoot();
+
+ installPackage("com.android.modules.updatablesharedlibs.apps.targetS.apk");
+ installPackage("com.android.modules.updatablesharedlibs.apps.targetT.apk");
+ installPackage("com.android.modules.updatablesharedlibs.apps.targetTWithLib.apk");
+
+ runDeviceTests("com.android.modules.updatablesharedlibs.apps.targetS", null);
+ runDeviceTests("com.android.modules.updatablesharedlibs.apps.targetT", null);
+ runDeviceTests("com.android.modules.updatablesharedlibs.apps.targetTWithLib", null);
+ }
+}
diff --git a/javatests/com/android/modules/updatablesharedlibs/apex/Android.bp b/javatests/com/android/modules/updatablesharedlibs/apex/Android.bp
new file mode 100644
index 0000000..0c8ec63
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/apex/Android.bp
@@ -0,0 +1,36 @@
+// Copyright (C) 2021 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.
+
+apex_key {
+ name: "com.android.modules.updatablesharedlibs.key",
+ public_key: "com.android.modules.updatablesharedlibs.avbpubkey",
+ private_key: "com.android.modules.updatablesharedlibs.pem",
+}
+
+android_app_certificate {
+ name: "com.android.modules.updatablesharedlibs.certificate",
+ certificate: "com.android.modules.updatablesharedlibs",
+}
+
+apex_test {
+ name: "test_com.android.modules.updatablesharedlibs",
+ manifest: "manifest.json",
+ file_contexts: ":apex.test-file_contexts",
+ key: "com.android.modules.updatablesharedlibs.key",
+ java_libs: [
+ "com.android.modules.updatablesharedlibs.libs.before.t",
+ "com.android.modules.updatablesharedlibs.libs.since.t",
+ ],
+ updatable: false,
+}
diff --git a/javatests/com/android/modules/updatablesharedlibs/apex/com.android.modules.updatablesharedlibs.avbpubkey b/javatests/com/android/modules/updatablesharedlibs/apex/com.android.modules.updatablesharedlibs.avbpubkey
new file mode 100644
index 0000000..e95ecbe
Binary files /dev/null and b/javatests/com/android/modules/updatablesharedlibs/apex/com.android.modules.updatablesharedlibs.avbpubkey differ
diff --git a/javatests/com/android/modules/updatablesharedlibs/apex/com.android.modules.updatablesharedlibs.pem b/javatests/com/android/modules/updatablesharedlibs/apex/com.android.modules.updatablesharedlibs.pem
new file mode 100644
index 0000000..ef30766
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/apex/com.android.modules.updatablesharedlibs.pem
@@ -0,0 +1,51 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIJKQIBAAKCAgEAvN2yqNX4Hw1XQiAuso1VJJjTUr4The6CtQwzE3lzAggKTI+w
+4zy1zmNlnycG8MvJ2hEqJFgMr8dM+ZvtobFE3ZE1qyzjr7rVa7m82SYbazJzacV4
+IGwyAEU6y2trTaqOI3sRkd2JRGiAM6e07abndHxp8FMslQ+bqtAKpbl5zxPlIdnn
+UHj/tqQ+nrscpHZ2sr6FqX/7wsIJPFP98gkQfmWOmP8wwhL0Dl1bGjuotY+KVcJ3
+U29sdNGl1x6RIit8jdmSxVlQNXB1Ps1x8M/QcjC7F7ezf/r5s7BdAgwecYs5xsbA
+waM8E2uiBU6we2yNtuJjFidgktjdSjlUhnPQZYnGe1+62rThwlfg1PXDPuwtk6I3
+15QP9BaxYeHr+3VHkBJ0r2tAlkVuoqG6XgSa1Dtk5ho95HzVOxAF3SBKh+vflu92
+CfmhhuUepZVSrZDg+VWdIHvv7IqNwA0GHHETmAl7oIZBR0Xed/SvLjP6AKI/UYiP
+ZJrfkeXKS+C2OYtofMsIAyDBSeThQSufXQzQv4MpMoQCYMjgJOFSA9+PSpCYtrWE
+OdGk7nur5YP4X6yWaZa6ntWlPJAhZ8GczOT91Rh/MZSJ6lQOSoJQ67O4igwsEjCL
+TGjXQGLHEVeORxUDoXnKadq8uQseI0ElQco5yvkvXtcHc/C7OrORV5ehRrECAwEA
+AQKCAgB7ctm1m+5LtbekZE7BrLnLaw0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Z3hU93hbUwHV+v+HGaI/bUsvA+NCUXIdZmIrNoWrv6m7SwHxyPV/u3JKGZzO75
+avglFXo0qzEbX5s0/al2wHqE7CvYPN2zZlOikb0siXx03bN4OOq3Sv3f2RecZr5k
+WtDI285AgoNhzK4E1CwCjDX2vTKeCFrtNxT+JxXEFa2euNsa4HLgKgOa7wyG/zNy
+6ATVL5oAu5OCcQURao5qjGxhIiSCkbsNm4x9eo7JrhC0aWmv19H6COv0Jo9xEZS1
+xmdRRld3PKRqucBCRStfY/U1HKxujMbsPFOXWCK8p8XzpJm1XGS2Ez+0Mw+b
+-----END RSA PRIVATE KEY-----
diff --git a/javatests/com/android/modules/updatablesharedlibs/apex/com.android.modules.updatablesharedlibs.pk8 b/javatests/com/android/modules/updatablesharedlibs/apex/com.android.modules.updatablesharedlibs.pk8
new file mode 100644
index 0000000..db1a90f
Binary files /dev/null and b/javatests/com/android/modules/updatablesharedlibs/apex/com.android.modules.updatablesharedlibs.pk8 differ
diff --git a/javatests/com/android/modules/updatablesharedlibs/apex/com.android.modules.updatablesharedlibs.x509.pem b/javatests/com/android/modules/updatablesharedlibs/apex/com.android.modules.updatablesharedlibs.x509.pem
new file mode 100644
index 0000000..6d9143f
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/apex/com.android.modules.updatablesharedlibs.x509.pem
@@ -0,0 +1,34 @@
+-----BEGIN CERTIFICATE-----
+MIIF8zCCA9sCFF/jvwHjBgaxHaamJyRxH88j4704MA0GCSqGSIb3DQEBCwUAMIG0
+MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91
+bnRhaW4gVmlldzEQMA4GA1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEi
+MCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTEwMC4GA1UEAwwnY29t
+LmFuZHJvaWQubW9kdWxlcy51cGRhdGFibGVzaGFyZWRsaWJzMCAXD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L
+BQADggIBAGQ5m+rrDvOQUfeOfRdfuU+XyhJ1zaOmyi1Br8ARuUrG5m3H6o8D1DyW
+zmv09YgkcXt4iTSFG5WcxXtu6mA57f9KuiXaRtA4wzmcnSgUpZrhRamltv1xfo8P
+h5vW9EKU67+437CuFBKlyjRLC+MD1GyMgNJwbHBqkIDUIfio+soIBVKgdANshSq7
+Cgc1dLAg7DvJkRg+WyjhBRmmregopXmfJfs73zxt2Jif5QQEZfLG27JkE7Ae06+9
+1FKvotlabdT3LMXjlX6miaJhPV8WPCmGyF2sZ8rOvI8OIKjWfWdf2S5269OnOrpg
+IMRJTnXzsIDNk/nVdbvI50V0/STIKyCj+HYMjlGjyFqs9XOSoWtv7Y41bYDp+eoF
+tfau5WOmVALWQ/M3sSIeBGkpzoq33wkyoqYNrlLRnA8FSNCOahKZpgAZyd7Cs9Fu
+EzK1+35F+5HdxgJaK29cmiaBsx3acTUr4UZrPewsmnYTU+xUtnbOKaLniUxkf/WT
+8qPhdg8n/1Hks5iWRzvKSHmFYMzx/efbz7PcB4UEyzKyaYW5mpX9xPLZ0Du6Je3X
+JIk2t6WEGnMDHWS2fa1KpUfhsiRKkxNP7tMMuAwZ/2OnCiFmZ2/Tzy6bp4EFPsa6
+zXcvJSf7eAe5jJkKrWkoMoKp+SBGoCKXzoMRCAbLSEdnSpr5EZXF
+-----END CERTIFICATE-----
diff --git a/javatests/com/android/modules/updatablesharedlibs/apex/manifest.json b/javatests/com/android/modules/updatablesharedlibs/apex/manifest.json
new file mode 100644
index 0000000..ffe9a73
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/apex/manifest.json
@@ -0,0 +1,4 @@
+{
+ "name": "test_com.android.modules.updatablesharedlibs",
+ "version": 1
+}
diff --git a/javatests/com/android/modules/updatablesharedlibs/apps/targetS/Android.bp b/javatests/com/android/modules/updatablesharedlibs/apps/targetS/Android.bp
new file mode 100644
index 0000000..24c495b
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/apps/targetS/Android.bp
@@ -0,0 +1,29 @@
+// Copyright (C) 2021 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: "com.android.modules.updatablesharedlibs.apps.targetS",
+ srcs: ["UpdatableSharedLibraryTargetSTest.java"],
+ static_libs: [
+ "androidx.test.rules",
+ "androidx.test.core",
+ "truth-prebuilt",
+ ],
+ sdk_version: "current",
+ target_sdk_version: "31",
+}
diff --git a/javatests/com/android/modules/updatablesharedlibs/apps/targetS/AndroidManifest.xml b/javatests/com/android/modules/updatablesharedlibs/apps/targetS/AndroidManifest.xml
new file mode 100644
index 0000000..e0c0ec9
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/apps/targetS/AndroidManifest.xml
@@ -0,0 +1,24 @@
+
+
+
One of the shared libraries included in this test claims to be in the
+ * BOOTCLASSPATH before T so it should be added transparently to this app.
+ */
+@RunWith(AndroidJUnit4.class)
+public class UpdatableSharedLibraryTargetSTest {
+ private static String SHARED_LIB_PATH = "/apex/test_com.android.modules.updatablesharedlibs"
+ + "/javalib/com.android.modules.updatablesharedlibs.libs.before.t.jar";
+
+ private static final Context sContext = InstrumentationRegistry.getInstrumentation()
+ .getContext();
+
+ @Test
+ public void checkSharedLibrary() throws Exception {
+ String packageName = sContext.getPackageName();
+ ApplicationInfo appInfo = sContext.getPackageManager().getApplicationInfo(packageName,
+ PackageManager.GET_SHARED_LIBRARY_FILES);
+
+ assertThat(appInfo.sharedLibraryFiles)
+ .asList()
+ .contains(SHARED_LIB_PATH);
+ }
+
+ @Test
+ public void callApi() throws Exception {
+ Object api = Class.forName("com.android.modules.updatablesharedlibs.libs.before.t.Api")
+ .getDeclaredConstructor()
+ .newInstance();
+
+ String actual = (String) api.getClass().getDeclaredMethod("methodBeforeT").invoke(api);
+ assertThat(actual).isEqualTo("Success");
+ }
+}
diff --git a/javatests/com/android/modules/updatablesharedlibs/apps/targetT/Android.bp b/javatests/com/android/modules/updatablesharedlibs/apps/targetT/Android.bp
new file mode 100644
index 0000000..70a549e
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/apps/targetT/Android.bp
@@ -0,0 +1,29 @@
+// Copyright (C) 2021 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: "com.android.modules.updatablesharedlibs.apps.targetT",
+ srcs: ["UpdatableSharedLibraryTargetTTest.java"],
+ static_libs: [
+ "androidx.test.rules",
+ "androidx.test.core",
+ "truth-prebuilt",
+ ],
+ sdk_version: "current",
+ target_sdk_version: "Tiramisu",
+}
diff --git a/javatests/com/android/modules/updatablesharedlibs/apps/targetT/AndroidManifest.xml b/javatests/com/android/modules/updatablesharedlibs/apps/targetT/AndroidManifest.xml
new file mode 100644
index 0000000..17f52e7
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/apps/targetT/AndroidManifest.xml
@@ -0,0 +1,24 @@
+
+
+
With the shared libraries included in this test, none of the shared libraries present in this
+ * test should be included for this app.
+ */
+@RunWith(AndroidJUnit4.class)
+public class UpdatableSharedLibraryTargetTTest {
+ private static final Correspondence This means the shared library should not be explicitly in the shared libraries in order
+ * to avoid duplication of the BCP.
+ */
+@RunWith(AndroidJUnit4.class)
+public class UpdatableSharedLibraryTargetTWithLibraryTest {
+ // private static final Context sContext = InstrumentationRegistry.getInstrumentation()
+ // .getContext();
+
+ @Test
+ public void checkHasNoSharedLibrary() throws Exception {
+ // TODO(b/205261027): not possible to test yet
+
+ // This is the code we'd like to run. But because before API finalisation PM
+ // will see the shared library as
+ // having "on-bcp-since 9001" this means that it never considers that shared
+ // library to be in the BCP.
+
+ // String packageName = getContext().getPackageName();
+ // ApplicationInfo appInfo = getPackageManager().getApplicationInfo(packageName,
+ // PackageManager.GET_SHARED_LIBRARY_FILES);
+ // Log.d(TAG, "checkHasNoSharedLibrary in " + appInfo.sharedLibraryFiles.length
+ // + " libraries");
+ // for (String path : appInfo.sharedLibraryFiles) {
+ // if (path.contains("com.android.modules.updatablesharedlibs")) {
+ // Assert.fail("Unexpectedly found a shared library: " + path);
+ // }
+ // }
+ }
+}
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/before/t/Android.bp b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/Android.bp
new file mode 100644
index 0000000..8f0565e
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/Android.bp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2021 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"],
+}
+
+java_sdk_library {
+ name: "com.android.modules.updatablesharedlibs.libs.before.t",
+ srcs: [
+ "Api.java"
+ ],
+ permitted_packages: [ "com.android.modules.updatablesharedlibs.libs"],
+ apex_available: [ "test_com.android.modules.updatablesharedlibs" ],
+ min_sdk_version: "Tiramisu",
+ sdk_version: "current",
+ on_bootclasspath_before: "Tiramisu",
+
+ // Output the api files to a special directory that won't trigger an API
+ // review as it is a test only API.
+ api_dir: "api_dir",
+ // Testing only.
+ no_dist: true,
+ unsafe_ignore_missing_latest_api: true,
+}
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/before/t/Api.java b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/Api.java
new file mode 100644
index 0000000..a01d0f0
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/Api.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2021 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 com.android.modules.updatablesharedlibs.libs.before.t;
+
+/**
+ * Basic class to pretend we have one API.
+ */
+public class Api {
+
+ public String methodBeforeT() {
+ return "Success";
+ }
+}
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/current.txt b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/current.txt
new file mode 100644
index 0000000..2b3339c
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/current.txt
@@ -0,0 +1,10 @@
+// Signature format: 2.0
+package com.android.modules.updatablesharedlibs.libs.before.t {
+
+ public class Api {
+ ctor public Api();
+ method public String methodBeforeT();
+ }
+
+}
+
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/module-lib-current.txt b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/module-lib-current.txt
new file mode 100644
index 0000000..e69de29
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/module-lib-removed.txt b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/module-lib-removed.txt
new file mode 100644
index 0000000..e69de29
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/removed.txt b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/removed.txt
new file mode 100644
index 0000000..d802177
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/removed.txt
@@ -0,0 +1 @@
+// Signature format: 2.0
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/system-current.txt b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/system-current.txt
new file mode 100644
index 0000000..d802177
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/system-current.txt
@@ -0,0 +1 @@
+// Signature format: 2.0
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/system-removed.txt b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/system-removed.txt
new file mode 100644
index 0000000..d802177
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/system-removed.txt
@@ -0,0 +1 @@
+// Signature format: 2.0
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/test-current.txt b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/test-current.txt
new file mode 100644
index 0000000..d802177
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/test-current.txt
@@ -0,0 +1 @@
+// Signature format: 2.0
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/test-removed.txt b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/test-removed.txt
new file mode 100644
index 0000000..d802177
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/before/t/api_dir/test-removed.txt
@@ -0,0 +1 @@
+// Signature format: 2.0
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/since/t/Android.bp b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/Android.bp
new file mode 100644
index 0000000..553dca6
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/Android.bp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2021 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"],
+}
+
+java_sdk_library {
+ name: "com.android.modules.updatablesharedlibs.libs.since.t",
+ srcs: [
+ "Api.java"
+ ],
+ permitted_packages: [ "com.android.modules.updatablesharedlibs.libs.since"],
+ apex_available: [ "test_com.android.modules.updatablesharedlibs" ],
+ min_sdk_version: "Tiramisu",
+ sdk_version: "current",
+ on_bootclasspath_since: "Tiramisu",
+
+ // Output the api files to a special directory that won't trigger an API
+ // review as it is a test only API.
+ api_dir: "api_dir",
+ // Testing only.
+ no_dist: true,
+ unsafe_ignore_missing_latest_api: true,
+}
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/since/t/Api.java b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/Api.java
new file mode 100644
index 0000000..53dde68
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/Api.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2021 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 com.android.modules.updatablesharedlibs.libs.since.t;
+
+/**
+ * Basic class to pretend we have one API.
+ */
+public class Api {
+
+ public String methodSinceT() {
+ return "Success";
+ }
+}
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/current.txt b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/current.txt
new file mode 100644
index 0000000..c459c1a
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/current.txt
@@ -0,0 +1,10 @@
+// Signature format: 2.0
+package com.android.modules.updatablesharedlibs.libs.since.t {
+
+ public class Api {
+ ctor public Api();
+ method public String methodSinceT();
+ }
+
+}
+
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/module-lib-current.txt b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/module-lib-current.txt
new file mode 100644
index 0000000..e69de29
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/module-lib-removed.txt b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/module-lib-removed.txt
new file mode 100644
index 0000000..e69de29
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/removed.txt b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/removed.txt
new file mode 100644
index 0000000..d802177
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/removed.txt
@@ -0,0 +1 @@
+// Signature format: 2.0
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/system-current.txt b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/system-current.txt
new file mode 100644
index 0000000..d802177
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/system-current.txt
@@ -0,0 +1 @@
+// Signature format: 2.0
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/system-removed.txt b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/system-removed.txt
new file mode 100644
index 0000000..d802177
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/system-removed.txt
@@ -0,0 +1 @@
+// Signature format: 2.0
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/test-current.txt b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/test-current.txt
new file mode 100644
index 0000000..d802177
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/test-current.txt
@@ -0,0 +1 @@
+// Signature format: 2.0
diff --git a/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/test-removed.txt b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/test-removed.txt
new file mode 100644
index 0000000..d802177
--- /dev/null
+++ b/javatests/com/android/modules/updatablesharedlibs/libs/since/t/api_dir/test-removed.txt
@@ -0,0 +1 @@
+// Signature format: 2.0