diff --git a/service/Android.bp b/service/Android.bp index 91b9d1c42b..45e43bc291 100644 --- a/service/Android.bp +++ b/service/Android.bp @@ -198,11 +198,10 @@ java_library { lint: { strict_updatability_linting: true }, } -java_library { - name: "service-connectivity", +java_defaults { + name: "service-connectivity-defaults", sdk_version: "system_server_current", min_sdk_version: "30", - installable: true, // This library combines system server jars that have access to different bootclasspath jars. // Lower SDK service jars must not depend on higher SDK jars as that would let them // transitively depend on the wrong bootclasspath jars. Sources also cannot be added here as @@ -224,6 +223,24 @@ java_library { lint: { strict_updatability_linting: true }, } +// A special library created strictly for use by the tests as they need the +// implementation library but that is not available when building from prebuilts. +// Using a library with a different name to what is used by the prebuilts ensures +// that this will never depend on the prebuilt. +// Switching service-connectivity to a java_sdk_library would also have worked as +// that has built in support for managing this but that is too big a change at this +// point. +java_library { + name: "service-connectivity-for-tests", + defaults: ["service-connectivity-defaults"], +} + +java_library { + name: "service-connectivity", + defaults: ["service-connectivity-defaults"], + installable: true, +} + filegroup { name: "connectivity-jarjar-rules", srcs: ["jarjar-rules.txt"], diff --git a/tests/integration/Android.bp b/tests/integration/Android.bp index 97c1265f6e..b3684ac10d 100644 --- a/tests/integration/Android.bp +++ b/tests/integration/Android.bp @@ -71,7 +71,7 @@ java_library { "net-tests-utils", ], libs: [ - "service-connectivity", + "service-connectivity-for-tests", "services.core", "services.net", ], diff --git a/tests/smoketest/Android.bp b/tests/smoketest/Android.bp index df8ab74be2..4ab24fcb0a 100644 --- a/tests/smoketest/Android.bp +++ b/tests/smoketest/Android.bp @@ -22,6 +22,6 @@ android_test { static_libs: [ "androidx.test.rules", "mockito-target-minus-junit4", - "service-connectivity", + "service-connectivity-for-tests", ], }