Home | History | Annotate | Download | only in shadows
      1 package org.robolectric.shadows;
      2 
      3 import static android.os.Build.VERSION_CODES.KITKAT;
      4 import static org.robolectric.shadow.api.Shadow.directlyOn;
      5 
      6 import android.content.ContentProvider;
      7 import org.robolectric.annotation.Implementation;
      8 import org.robolectric.annotation.Implements;
      9 import org.robolectric.annotation.RealObject;
     10 
     11 @Implements(ContentProvider.class)
     12 public class ShadowContentProvider {
     13   @RealObject private ContentProvider realContentProvider;
     14 
     15   private String callingPackage;
     16 
     17   public void setCallingPackage(String callingPackage) {
     18     this.callingPackage = callingPackage;
     19   }
     20 
     21   @Implementation(minSdk = KITKAT)
     22   protected String getCallingPackage() {
     23     if (callingPackage != null) {
     24       return callingPackage;
     25     } else {
     26       return directlyOn(realContentProvider, ContentProvider.class, "getCallingPackage");
     27     }
     28   }
     29 }
     30