Loading core/java/android/content/pm/AndroidTestBaseUpdater.java +5 −5 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ import android.os.Build; import com.android.internal.annotations.VisibleForTesting; /** * Updates a package to ensure that if it targets <= P that the android.test.base library is * Updates a package to ensure that if it targets <= Q that the android.test.base library is * included by default. * * <p>This is separated out so that it can be conditionally included at build time depending on Loading @@ -38,17 +38,17 @@ import com.android.internal.annotations.VisibleForTesting; @VisibleForTesting public class AndroidTestBaseUpdater extends PackageSharedLibraryUpdater { private static boolean apkTargetsApiLevelLessThanOrEqualToP(Package pkg) { private static boolean apkTargetsApiLevelLessThanOrEqualToQ(Package pkg) { int targetSdkVersion = pkg.applicationInfo.targetSdkVersion; return targetSdkVersion <= Build.VERSION_CODES.P; return targetSdkVersion <= Build.VERSION_CODES.Q; } @Override public void updatePackage(Package pkg) { // Packages targeted at <= P expect the classes in the android.test.base library // Packages targeted at <= Q expect the classes in the android.test.base library // to be accessible so this maintains backward compatibility by adding the // android.test.base library to those packages. if (apkTargetsApiLevelLessThanOrEqualToP(pkg)) { if (apkTargetsApiLevelLessThanOrEqualToQ(pkg)) { prefixRequiredLibrary(pkg, ANDROID_TEST_BASE); } else { // If a package already depends on android.test.runner then add a dependency on Loading core/tests/coretests/src/android/content/pm/AndroidTestBaseUpdaterTest.java +11 −11 Original line number Diff line number Diff line Loading @@ -37,37 +37,37 @@ public class AndroidTestBaseUpdaterTest extends PackageSharedLibraryUpdaterTest private static final String OTHER_LIBRARY = "other.library"; @Test public void targeted_at_P() { public void targeted_at_Q() { PackageBuilder before = builder() .targetSdkVersion(Build.VERSION_CODES.P); .targetSdkVersion(Build.VERSION_CODES.Q); // Should add org.apache.http.legacy. PackageBuilder after = builder() .targetSdkVersion(Build.VERSION_CODES.P) .targetSdkVersion(Build.VERSION_CODES.Q) .requiredLibraries(ANDROID_TEST_BASE); checkBackwardsCompatibility(before, after); } @Test public void targeted_at_P_not_empty_usesLibraries() { public void targeted_at_Q_not_empty_usesLibraries() { PackageBuilder before = builder() .targetSdkVersion(Build.VERSION_CODES.P) .targetSdkVersion(Build.VERSION_CODES.Q) .requiredLibraries(OTHER_LIBRARY); // The org.apache.http.legacy jar should be added at the start of the list because it // is not on the bootclasspath and the package targets pre-P. // is not on the bootclasspath and the package targets pre-Q. PackageBuilder after = builder() .targetSdkVersion(Build.VERSION_CODES.P) .targetSdkVersion(Build.VERSION_CODES.Q) .requiredLibraries(ANDROID_TEST_BASE, OTHER_LIBRARY); checkBackwardsCompatibility(before, after); } @Test public void targeted_at_P_in_usesLibraries() { public void targeted_at_Q_in_usesLibraries() { PackageBuilder before = builder() .targetSdkVersion(Build.VERSION_CODES.P) .targetSdkVersion(Build.VERSION_CODES.Q) .requiredLibraries(ANDROID_TEST_BASE); // No change is required because although org.apache.http.legacy has been removed from Loading @@ -76,9 +76,9 @@ public class AndroidTestBaseUpdaterTest extends PackageSharedLibraryUpdaterTest } @Test public void targeted_at_P_in_usesOptionalLibraries() { public void targeted_at_Q_in_usesOptionalLibraries() { PackageBuilder before = builder() .targetSdkVersion(Build.VERSION_CODES.P) .targetSdkVersion(Build.VERSION_CODES.Q) .optionalLibraries(ANDROID_TEST_BASE); // No change is required because although org.apache.http.legacy has been removed from Loading Loading
core/java/android/content/pm/AndroidTestBaseUpdater.java +5 −5 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ import android.os.Build; import com.android.internal.annotations.VisibleForTesting; /** * Updates a package to ensure that if it targets <= P that the android.test.base library is * Updates a package to ensure that if it targets <= Q that the android.test.base library is * included by default. * * <p>This is separated out so that it can be conditionally included at build time depending on Loading @@ -38,17 +38,17 @@ import com.android.internal.annotations.VisibleForTesting; @VisibleForTesting public class AndroidTestBaseUpdater extends PackageSharedLibraryUpdater { private static boolean apkTargetsApiLevelLessThanOrEqualToP(Package pkg) { private static boolean apkTargetsApiLevelLessThanOrEqualToQ(Package pkg) { int targetSdkVersion = pkg.applicationInfo.targetSdkVersion; return targetSdkVersion <= Build.VERSION_CODES.P; return targetSdkVersion <= Build.VERSION_CODES.Q; } @Override public void updatePackage(Package pkg) { // Packages targeted at <= P expect the classes in the android.test.base library // Packages targeted at <= Q expect the classes in the android.test.base library // to be accessible so this maintains backward compatibility by adding the // android.test.base library to those packages. if (apkTargetsApiLevelLessThanOrEqualToP(pkg)) { if (apkTargetsApiLevelLessThanOrEqualToQ(pkg)) { prefixRequiredLibrary(pkg, ANDROID_TEST_BASE); } else { // If a package already depends on android.test.runner then add a dependency on Loading
core/tests/coretests/src/android/content/pm/AndroidTestBaseUpdaterTest.java +11 −11 Original line number Diff line number Diff line Loading @@ -37,37 +37,37 @@ public class AndroidTestBaseUpdaterTest extends PackageSharedLibraryUpdaterTest private static final String OTHER_LIBRARY = "other.library"; @Test public void targeted_at_P() { public void targeted_at_Q() { PackageBuilder before = builder() .targetSdkVersion(Build.VERSION_CODES.P); .targetSdkVersion(Build.VERSION_CODES.Q); // Should add org.apache.http.legacy. PackageBuilder after = builder() .targetSdkVersion(Build.VERSION_CODES.P) .targetSdkVersion(Build.VERSION_CODES.Q) .requiredLibraries(ANDROID_TEST_BASE); checkBackwardsCompatibility(before, after); } @Test public void targeted_at_P_not_empty_usesLibraries() { public void targeted_at_Q_not_empty_usesLibraries() { PackageBuilder before = builder() .targetSdkVersion(Build.VERSION_CODES.P) .targetSdkVersion(Build.VERSION_CODES.Q) .requiredLibraries(OTHER_LIBRARY); // The org.apache.http.legacy jar should be added at the start of the list because it // is not on the bootclasspath and the package targets pre-P. // is not on the bootclasspath and the package targets pre-Q. PackageBuilder after = builder() .targetSdkVersion(Build.VERSION_CODES.P) .targetSdkVersion(Build.VERSION_CODES.Q) .requiredLibraries(ANDROID_TEST_BASE, OTHER_LIBRARY); checkBackwardsCompatibility(before, after); } @Test public void targeted_at_P_in_usesLibraries() { public void targeted_at_Q_in_usesLibraries() { PackageBuilder before = builder() .targetSdkVersion(Build.VERSION_CODES.P) .targetSdkVersion(Build.VERSION_CODES.Q) .requiredLibraries(ANDROID_TEST_BASE); // No change is required because although org.apache.http.legacy has been removed from Loading @@ -76,9 +76,9 @@ public class AndroidTestBaseUpdaterTest extends PackageSharedLibraryUpdaterTest } @Test public void targeted_at_P_in_usesOptionalLibraries() { public void targeted_at_Q_in_usesOptionalLibraries() { PackageBuilder before = builder() .targetSdkVersion(Build.VERSION_CODES.P) .targetSdkVersion(Build.VERSION_CODES.Q) .optionalLibraries(ANDROID_TEST_BASE); // No change is required because although org.apache.http.legacy has been removed from Loading