Home | History | Annotate | Download | only in shadows
      1 package com.xtremelabs.robolectric.shadows;
      2 
      3 import java.io.File;
      4 
      5 import android.os.Environment;
      6 import com.xtremelabs.robolectric.internal.Implementation;
      7 import com.xtremelabs.robolectric.internal.Implements;
      8 
      9 @Implements(Environment.class)
     10 public class ShadowEnvironment {
     11 
     12     private static final String MEDIA_REMOVED = "removed";
     13 
     14     private static String externalStorageState = MEDIA_REMOVED;
     15 
     16     @Implementation
     17     public static String getExternalStorageState() {
     18         return externalStorageState;
     19     }
     20 
     21     public static void setExternalStorageState(String externalStorageState) {
     22         ShadowEnvironment.externalStorageState = externalStorageState;
     23     }
     24 
     25     @Implementation
     26     public static File getExternalStorageDirectory() {
     27     	ShadowContext.EXTERNAL_CACHE_DIR.mkdirs();
     28 		return ShadowContext.EXTERNAL_CACHE_DIR;
     29     }
     30 
     31     @Implementation
     32     public static File getExternalStoragePublicDirectory(String type) {
     33 		File f = (type == null) ? ShadowContext.EXTERNAL_FILES_DIR : new File( ShadowContext.EXTERNAL_FILES_DIR, type );
     34         f.mkdirs();
     35         return f;
     36     }
     37 }
     38