FileDocCategorySizeDatePackage
IsolatedContext.javaAPI DocAndroid 5.1 API6005Thu Mar 12 22:22:42 GMT 2015android.test

IsolatedContext

public class IsolatedContext extends android.content.ContextWrapper
A mock context which prevents its users from talking to the rest of the device while stubbing enough methods to satify code that tries to talk to other packages.

Fields Summary
private android.content.ContentResolver
mResolver
private final MockAccountManager
mMockAccountManager
private List
mBroadcastIntents
Constructors Summary
public IsolatedContext(android.content.ContentResolver resolver, android.content.Context targetContext)


     
                
        super(targetContext);
        mResolver = resolver;
        mMockAccountManager = new MockAccountManager();
    
Methods Summary
public booleanbindService(android.content.Intent service, android.content.ServiceConnection conn, int flags)

        return false;
    
public intcheckUriPermission(android.net.Uri uri, int pid, int uid, int modeFlags)

        return PackageManager.PERMISSION_GRANTED;
    
public intcheckUriPermission(android.net.Uri uri, java.lang.String readPermission, java.lang.String writePermission, int pid, int uid, int modeFlags)

        return PackageManager.PERMISSION_GRANTED;
    
public java.util.ListgetAndClearBroadcastIntents()
Returns the list of intents that were broadcast since the last call to this method.

        List<Intent> intents = mBroadcastIntents;
        mBroadcastIntents = Lists.newArrayList();
        return intents;
    
public android.content.ContentResolvergetContentResolver()

        // We need to return the real resolver so that MailEngine.makeRight can get to the
        // subscribed feeds provider. TODO: mock out subscribed feeds too.
        return mResolver;
    
public java.io.FilegetFilesDir()

        return new File("/dev/null");
    
public java.lang.ObjectgetSystemService(java.lang.String name)

        if (Context.ACCOUNT_SERVICE.equals(name)) {
            return mMockAccountManager;
        }
        // No other services exist in this context.
        return null;
    
public android.content.IntentregisterReceiver(android.content.BroadcastReceiver receiver, android.content.IntentFilter filter)

        return null;
    
public voidsendBroadcast(android.content.Intent intent)

        mBroadcastIntents.add(intent);
    
public voidsendOrderedBroadcast(android.content.Intent intent, java.lang.String receiverPermission)

        mBroadcastIntents.add(intent);
    
public voidunregisterReceiver(android.content.BroadcastReceiver receiver)

        // Ignore