1 package org.robolectric.annotation; 2 3 import java.lang.annotation.Documented; 4 import java.lang.annotation.ElementType; 5 import java.lang.annotation.Retention; 6 import java.lang.annotation.RetentionPolicy; 7 import java.lang.annotation.Target; 8 9 /** 10 * A {@link org.robolectric.pluginapi.config.Configurer} annotation for controlling how Robolectric 11 * executes {@code PackageManager#getInstallerPackageName} method. 12 * 13 * <p>'getInstallerPackageName' method in PackageManager must throw IllegalArgumentException if the 14 * installer package is not present. The legacy robolectric behavior returns a null value for these 15 * cases. 16 * 17 * <p>This annotation can be applied to tests to have Robolectric perform the legacy mechanism of 18 * not throwing IllegalArgumentException and instead return 'null', when installer package name is 19 * not found. 20 * 21 * <p>This annotation will be deleted in a forthcoming Robolectric release. 22 */ 23 @Documented 24 @Retention(RetentionPolicy.RUNTIME) 25 @Target({ElementType.PACKAGE, ElementType.TYPE, ElementType.METHOD}) 26 public @interface GetInstallerPackageNameMode { 27 28 /** 29 * Specifies the different {@code ShadowApplicationPackageManager#getInstallerPackageName} modes. 30 */ 31 enum Mode { 32 /** Robolectric's prior behavior when calling getInstallerPackageName method. */ 33 LEGACY, 34 /** The new, real behavior when calling getInstallerPackageName method. */ 35 REALISTIC, 36 } 37 value()38 Mode value(); 39 40 /** 41 * Optional string for storing the issue / bug id tracking the fixing of the affected tests and 42 * thus removal of this annotation. 43 */ issueId()44 String issueId() default ""; 45 } 46