1 package org.robolectric.shadows; 2 3 import static android.os.Build.VERSION_CODES.O_MR1; 4 import static android.os.Build.VERSION_CODES.P; 5 6 import java.util.List; 7 import java.util.function.Supplier; 8 import org.robolectric.annotation.Implementation; 9 import org.robolectric.annotation.Implements; 10 11 /** 12 * Shadow of {@link PackageBackwardCompatibility} to handle a scenario that can come up when 13 * multiple Android versions end up on the classpath. 14 */ 15 @Implements( 16 className = "android.content.pm.PackageBackwardCompatibility", 17 minSdk = O_MR1, 18 maxSdk = P) 19 public class ShadowPackageBackwardCompatibility { 20 21 /** 22 * Stubbing this out as if Android S+ is on the classpath, we'll get a ClassCastException instead 23 * of a ClassNotFoundException. Since we don't really need this logic, simpler to just skip it 24 */ 25 @Implementation(minSdk = P) addOptionalUpdater( List<Object> packageUpdaters, String className, Supplier<Object> defaultUpdater)26 protected static boolean addOptionalUpdater( 27 List<Object> packageUpdaters, String className, Supplier<Object> defaultUpdater) { 28 return false; 29 } 30 } 31