FileDocCategorySizeDatePackage
ComponentTest.javaAPI DocAndroid 1.5 API35360Wed May 06 22:42:02 BST 2009com.android.unit_tests

ComponentTest

public class ComponentTest extends android.test.AndroidTestCase
Tests for disabling and enabling application components. Note: These tests are on the slow side. This is probably because most of the tests trigger the package settings file to get written out by the PackageManagerService. Better, more unit-y test would fix this.

Fields Summary
private android.content.pm.PackageManager
mPackageManager
private android.content.Intent
mDisabledActivityIntent
private android.content.Intent
mEnabledActivityIntent
private android.content.Intent
mDisabledServiceIntent
private android.content.Intent
mEnabledServiceIntent
private android.content.Intent
mDisabledReceiverIntent
private android.content.Intent
mEnabledReceiverIntent
private android.content.Intent
mDisabledAppEnabledActivityIntent
private static final String
ENABLED_PACKAGENAME
private static final String
DISABLED_PACKAGENAME
private static final String
DISABLED_ACTIVITY_CLASSNAME
private static final android.content.ComponentName
DISABLED_ACTIVITY_COMPONENTNAME
private static final String
ENABLED_ACTIVITY_CLASSNAME
private static final android.content.ComponentName
ENABLED_ACTIVITY_COMPONENTNAME
private static final String
DISABLED_SERVICE_CLASSNAME
private static final android.content.ComponentName
DISABLED_SERVICE_COMPONENTNAME
private static final String
DISABLED_PROVIDER_CLASSNAME
private static final android.content.ComponentName
DISABLED_PROVIDER_COMPONENTNAME
private static final String
DISABLED_PROVIDER_NAME
private static final String
ENABLED_SERVICE_CLASSNAME
private static final android.content.ComponentName
ENABLED_SERVICE_COMPONENTNAME
private static final String
DISABLED_RECEIVER_CLASSNAME
private static final android.content.ComponentName
DISABLED_RECEIVER_COMPONENTNAME
private static final String
ENABLED_RECEIVER_CLASSNAME
private static final android.content.ComponentName
ENABLED_RECEIVER_COMPONENTNAME
private static final String
ENABLED_PROVIDER_CLASSNAME
private static final android.content.ComponentName
ENABLED_PROVIDER_COMPONENTNAME
private static final String
ENABLED_PROVIDER_NAME
private static final String
DISABLED_APP_ENABLED_ACTIVITY_CLASSNAME
private static final android.content.ComponentName
DISABLED_APP_ENABLED_ACTIVITY_COMPONENTNAME
private static final String
TEST_CATEGORY
Constructors Summary
Methods Summary
public voidDISABLED_testDisableApplication()

        mPackageManager.setApplicationEnabledSetting(ENABLED_PACKAGENAME,
                                                     COMPONENT_ENABLED_STATE_DEFAULT,
                                                     0);
        mPackageManager.setComponentEnabledSetting(ENABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final ResolveInfo info = mPackageManager.resolveActivity(mEnabledActivityIntent, 0);
        assertNotNull(info);
        assertNotNull(info.activityInfo);
        assertTrue(info.activityInfo.enabled);

        mPackageManager.setApplicationEnabledSetting(ENABLED_PACKAGENAME,
                                                     COMPONENT_ENABLED_STATE_DISABLED,
                                                     0);
        final ResolveInfo info2 = mPackageManager.resolveActivity(mEnabledActivityIntent, 0);
        assertNull(info2);

        // Clean up
        mPackageManager.setApplicationEnabledSetting(ENABLED_PACKAGENAME,
                                                     COMPONENT_ENABLED_STATE_DEFAULT,
                                                     0);

    
public voidDISABLED_testEnableApplication()

        mPackageManager.setApplicationEnabledSetting(DISABLED_PACKAGENAME,
                                                     COMPONENT_ENABLED_STATE_DEFAULT,
                                                     0);
        mPackageManager.setComponentEnabledSetting(DISABLED_APP_ENABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final ResolveInfo info =
                mPackageManager.resolveActivity(mDisabledAppEnabledActivityIntent, 0);
        assertNull(info);

        mPackageManager.setApplicationEnabledSetting(DISABLED_PACKAGENAME,
                                                     COMPONENT_ENABLED_STATE_ENABLED,
                                                     0);
        final ResolveInfo info2 = mPackageManager.resolveActivity(
                mDisabledAppEnabledActivityIntent, 0);
        assertNotNull(info2);
        assertNotNull(info2.activityInfo);
        assertTrue(info2.activityInfo.enabled);

    
public voidDISABLED_testResolveEnabledActivityInDisabledApp()

        mPackageManager.setApplicationEnabledSetting(DISABLED_PACKAGENAME,
                                                     COMPONENT_ENABLED_STATE_DEFAULT,
                                                     0);
        mPackageManager.setComponentEnabledSetting(DISABLED_APP_ENABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final ResolveInfo info =
                mPackageManager.resolveActivity(mDisabledAppEnabledActivityIntent, 0);
        assertNull(info);

        final ResolveInfo info2 = mPackageManager.resolveActivity(
                mDisabledAppEnabledActivityIntent, GET_DISABLED_COMPONENTS);
        assertNotNull(info2);
        assertNotNull(info2.activityInfo);
        assertTrue(info2.activityInfo.enabled);
    
private java.lang.StringgetComponentProcessName(java.lang.String componentNameStr)

        ComponentInfo providerInfo =
                mPackageManager.resolveContentProvider(componentNameStr,
                                                       GET_DISABLED_COMPONENTS);
        return providerInfo.processName;
    
protected voidsetUp()


    
         
        super.setUp();
        mPackageManager = mContext.getPackageManager();
        mDisabledActivityIntent = new Intent();
        mDisabledActivityIntent.setComponent(DISABLED_ACTIVITY_COMPONENTNAME);
        mEnabledActivityIntent = new Intent();
        mEnabledActivityIntent.setComponent(ENABLED_ACTIVITY_COMPONENTNAME);
        mDisabledServiceIntent = new Intent();
        mDisabledServiceIntent.setComponent(DISABLED_SERVICE_COMPONENTNAME);
        mEnabledServiceIntent = new Intent();
        mEnabledServiceIntent.setComponent(ENABLED_SERVICE_COMPONENTNAME);
        mDisabledReceiverIntent = new Intent("android.intent.action.ENABLED_APP_DISABLED_RECEIVER");
        mDisabledReceiverIntent.setComponent(DISABLED_RECEIVER_COMPONENTNAME);
        mEnabledReceiverIntent = new Intent("android.intent.action.ENABLED_APP_ENABLED_RECEIVER");
        mEnabledReceiverIntent.setComponent(ENABLED_RECEIVER_COMPONENTNAME);
        mDisabledAppEnabledActivityIntent = new Intent();
        mDisabledAppEnabledActivityIntent.setComponent(DISABLED_APP_ENABLED_ACTIVITY_COMPONENTNAME);
    
public voidtestContextNotNull()

        assertNotNull(mContext);
    
public voidtestDisableActivity()

        mPackageManager.setComponentEnabledSetting(ENABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final ResolveInfo info = mPackageManager.resolveActivity(mEnabledActivityIntent, 0);
        assertNotNull(info);
        assertNotNull(info.activityInfo);
        mPackageManager.setComponentEnabledSetting(ENABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DISABLED,
                                                   PackageManager.DONT_KILL_APP);
        final ResolveInfo info2 =
                mPackageManager.resolveActivity(mEnabledActivityIntent,
                                                0);
        assertNull(info2);

        final ResolveInfo info3 = mPackageManager.resolveActivity(mEnabledActivityIntent,
                                                                  GET_DISABLED_COMPONENTS);
        assertNotNull(info3);
        assertNotNull(info3.activityInfo);
        assertTrue(info3.activityInfo.enabled);

        final List<ResolveInfo> infoList =
                mPackageManager.queryIntentActivities(mEnabledActivityIntent, 0);
        assertEquals(0, infoList.size());
    
public voidtestDisableProvider()

        mPackageManager.setComponentEnabledSetting(ENABLED_PROVIDER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);
        ProviderInfo providerInfo =
                mPackageManager.resolveContentProvider(ENABLED_PROVIDER_NAME, 0);
        assertNotNull(providerInfo);
        assertTrue(providerInfo.enabled);

        mPackageManager.setComponentEnabledSetting(ENABLED_PROVIDER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DISABLED,
                                                   PackageManager.DONT_KILL_APP);
        ProviderInfo providerInfo2 =
                mPackageManager.resolveContentProvider(ENABLED_PROVIDER_NAME, 0);
        assertNull(providerInfo2);
    
public voidtestDisableReceiver()

        mPackageManager.setComponentEnabledSetting(ENABLED_RECEIVER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        ActivityInfo activityInfo =
              mPackageManager.getReceiverInfo(ENABLED_RECEIVER_COMPONENTNAME, 0);
        assertNotNull(activityInfo);
        assertTrue(activityInfo.enabled);
        mPackageManager.setComponentEnabledSetting(DISABLED_RECEIVER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DISABLED,
                                                   PackageManager.DONT_KILL_APP);
        try {
            mPackageManager.getReceiverInfo(DISABLED_RECEIVER_COMPONENTNAME, 0);
            fail("Attempt to get info on disabled component should fail.");
        } catch (PackageManager.NameNotFoundException e) {
            // expected
        }
    
public voidtestDisableService()

        mPackageManager.setComponentEnabledSetting(ENABLED_SERVICE_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final ResolveInfo info = mPackageManager.resolveService(mEnabledServiceIntent, 0);
        assertNotNull(info);
        assertNotNull(info.serviceInfo);
        mPackageManager.setComponentEnabledSetting(ENABLED_SERVICE_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DISABLED,
                                                   PackageManager.DONT_KILL_APP);
        final ResolveInfo info2 =
                mPackageManager.resolveService(mEnabledServiceIntent,
                                                0);
        assertNull(info2);

        final ResolveInfo info3 = mPackageManager.resolveService(mEnabledServiceIntent,
                                                                  GET_DISABLED_COMPONENTS);
        assertNotNull(info3);
        assertNotNull(info3.serviceInfo);
        assertTrue(info3.serviceInfo.enabled);
    
public voidtestEnableActivity()

        mPackageManager.setComponentEnabledSetting(DISABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final ResolveInfo info = mPackageManager.resolveActivity(mDisabledActivityIntent, 0);
        assertNull(info);
        mPackageManager.setComponentEnabledSetting(DISABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_ENABLED,
                                                   PackageManager.DONT_KILL_APP);
        final ResolveInfo info2 =
                mPackageManager.resolveActivity(mDisabledActivityIntent,
                                                0);
        assertNotNull(info2);
        assertNotNull(info2.activityInfo);
        assertFalse(info2.activityInfo.enabled);

        final List<ResolveInfo> infoList =
                mPackageManager.queryIntentActivities(mDisabledActivityIntent, 0);
        assertEquals(1, infoList.size());
    
public voidtestEnableProvider()

        mPackageManager.setComponentEnabledSetting(DISABLED_PROVIDER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);
        ProviderInfo providerInfo =
                mPackageManager.resolveContentProvider(DISABLED_PROVIDER_NAME, 0);
        assertNull(providerInfo);

        mPackageManager.setComponentEnabledSetting(DISABLED_PROVIDER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_ENABLED,
                                                   PackageManager.DONT_KILL_APP);
        ProviderInfo providerInfo2 =
                mPackageManager.resolveContentProvider(DISABLED_PROVIDER_NAME, 0);
        assertNotNull(providerInfo2);
        assertFalse(providerInfo2.enabled);
    
public voidtestEnableReceiver()

        mPackageManager.setComponentEnabledSetting(DISABLED_RECEIVER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        try {
            mPackageManager.getReceiverInfo(DISABLED_RECEIVER_COMPONENTNAME, 0);
            fail("Attempt to get info on disabled component should fail.");
        } catch (PackageManager.NameNotFoundException e) {
            // expected
        }

        mPackageManager.setComponentEnabledSetting(DISABLED_RECEIVER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_ENABLED,
                                                   PackageManager.DONT_KILL_APP);
        ActivityInfo activityInfo =
              mPackageManager.getReceiverInfo(DISABLED_RECEIVER_COMPONENTNAME, 0);
        assertNotNull(activityInfo);
        assertFalse(activityInfo.enabled);
    
public voidtestEnableService()

        mPackageManager.setComponentEnabledSetting(DISABLED_SERVICE_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final ResolveInfo info = mPackageManager.resolveService(mDisabledServiceIntent, 0);
        assertNull(info);
        mPackageManager.setComponentEnabledSetting(DISABLED_SERVICE_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_ENABLED,
                                                   PackageManager.DONT_KILL_APP);
        final ResolveInfo info2 =
                mPackageManager.resolveService(mDisabledServiceIntent,
                                                0);
        assertNotNull(info2);
        assertNotNull(info2.serviceInfo);
        assertFalse(info2.serviceInfo.enabled);
    
public voidtestGetDisabledActivityInfo()

        mPackageManager.setComponentEnabledSetting(DISABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        try {
            mPackageManager.getActivityInfo(DISABLED_ACTIVITY_COMPONENTNAME, 0);
            fail("Attempt to get info on disabled component should fail.");
        } catch (PackageManager.NameNotFoundException e) {
            // expected
        }

        final ActivityInfo activityInfo =
              mPackageManager.getActivityInfo(DISABLED_ACTIVITY_COMPONENTNAME,
                                              GET_DISABLED_COMPONENTS);
        assertNotNull(activityInfo);
        assertFalse(activityInfo.enabled);
    
public voidtestGetDisabledReceiverInfo()

        mPackageManager.setComponentEnabledSetting(DISABLED_RECEIVER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        try {
            mPackageManager.getReceiverInfo(DISABLED_RECEIVER_COMPONENTNAME, 0);
            fail("Attempt to get info on disabled component should fail.");
        } catch (PackageManager.NameNotFoundException e) {
            // expected
        }

        final ActivityInfo activityInfo =
              mPackageManager.getReceiverInfo(DISABLED_RECEIVER_COMPONENTNAME,
                                              GET_DISABLED_COMPONENTS);
        assertNotNull(activityInfo);
        assertFalse(activityInfo.enabled);
    
public voidtestGetDisabledServiceInfo()

        mPackageManager.setComponentEnabledSetting(DISABLED_SERVICE_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        try {
            mPackageManager.getServiceInfo(DISABLED_SERVICE_COMPONENTNAME, 0);
            fail("Attempt to get info on disabled component should fail.");
        } catch (PackageManager.NameNotFoundException e) {
            // expected
        }

        final ServiceInfo serviceInfo =
              mPackageManager.getServiceInfo(DISABLED_SERVICE_COMPONENTNAME,
                                              GET_DISABLED_COMPONENTS);
        assertNotNull(serviceInfo);
        assertFalse(serviceInfo.enabled);
    
public voidtestGetEnabledActivityInfo()

        mPackageManager.setComponentEnabledSetting(ENABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        ActivityInfo activityInfo =
              mPackageManager.getActivityInfo(ENABLED_ACTIVITY_COMPONENTNAME, 0);
        assertNotNull(activityInfo);
        assertTrue(activityInfo.enabled);
    
public voidtestGetEnabledReceiverInfo()

        mPackageManager.setComponentEnabledSetting(ENABLED_RECEIVER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        ActivityInfo activityInfo =
              mPackageManager.getReceiverInfo(ENABLED_RECEIVER_COMPONENTNAME, 0);
        assertNotNull(activityInfo);
        assertTrue(activityInfo.enabled);
    
public voidtestGetEnabledServiceInfo()

        mPackageManager.setComponentEnabledSetting(ENABLED_SERVICE_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        ServiceInfo serviceInfo =
              mPackageManager.getServiceInfo(ENABLED_SERVICE_COMPONENTNAME, 0);
        assertNotNull(serviceInfo);
        assertTrue(serviceInfo.enabled);
    
public voidtestNonExplicitResolveAfterEnabling()

        mPackageManager.setComponentEnabledSetting(DISABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        Intent intent = new Intent(Intent.ACTION_MAIN, null);
        intent.addCategory(TEST_CATEGORY);

        final List<ResolveInfo> launchables =
                mPackageManager.queryIntentActivities(intent, 0);

        int numItems = launchables.size();
        assertEquals(0, numItems);

        mPackageManager.setComponentEnabledSetting(DISABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_ENABLED,
                                                   PackageManager.DONT_KILL_APP);

        final List<ResolveInfo> launchables2 =
                mPackageManager.queryIntentActivities(intent, 0);

        int numItems2 = launchables2.size();
        assertEquals(1, numItems2);
    
public voidtestQueryDisabledActivity()

        mPackageManager.setComponentEnabledSetting(DISABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final List<ResolveInfo> infoList =
                mPackageManager.queryIntentActivities(mDisabledActivityIntent, 0);
        assertEquals(0, infoList.size());

        final List<ResolveInfo> infoList2 =
                mPackageManager.queryIntentActivities(mDisabledActivityIntent,
                                                      GET_DISABLED_COMPONENTS);
        assertEquals(1, infoList2.size());
        final ResolveInfo info = infoList2.get(0);
        assertNotNull(info);
        assertNotNull(info.activityInfo);
        assertFalse(info.activityInfo.enabled);
    
public voidtestQueryDisabledProvider()

        mPackageManager.setComponentEnabledSetting(DISABLED_PROVIDER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        PackageInfo pi = mPackageManager.getPackageInfo(ENABLED_PACKAGENAME, 0);
        
        String disabledProviderProcessName = getComponentProcessName(DISABLED_PROVIDER_NAME);
        List<ProviderInfo> providerInfoList =
                mPackageManager.queryContentProviders(disabledProviderProcessName,
                        pi.applicationInfo.uid, 0);
        assertNull(providerInfoList);


        List<ProviderInfo> providerInfoList2 =
                mPackageManager.queryContentProviders(disabledProviderProcessName,
                        pi.applicationInfo.uid, GET_DISABLED_COMPONENTS);
        assertNotNull(providerInfoList2);
        assertEquals(1, providerInfoList2.size());
        assertEquals(DISABLED_PROVIDER_CLASSNAME,
                     providerInfoList2.get(0).name);
    
public voidtestQueryDisabledReceiver()

        mPackageManager.setComponentEnabledSetting(DISABLED_RECEIVER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final List<ResolveInfo> infoList =
                mPackageManager.queryBroadcastReceivers(mDisabledReceiverIntent, 0);
        assertEquals(0, infoList.size());

        final List<ResolveInfo> infoList2 =
                mPackageManager.queryBroadcastReceivers(mDisabledReceiverIntent,
                                                      GET_DISABLED_COMPONENTS);
        assertEquals(1, infoList2.size());
        final ResolveInfo info = infoList2.get(0);
        assertNotNull(info);
        assertNotNull(info.activityInfo);
        assertFalse(info.activityInfo.enabled);
    
public voidtestQueryDisabledService()

        mPackageManager.setComponentEnabledSetting(DISABLED_SERVICE_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final List<ResolveInfo> infoList =
                mPackageManager.queryIntentServices(mDisabledServiceIntent, 0);
        assertEquals(0, infoList.size());

        final List<ResolveInfo> infoList2 =
                mPackageManager.queryIntentServices(mDisabledServiceIntent,
                                                      GET_DISABLED_COMPONENTS);
        assertEquals(1, infoList2.size());
        final ResolveInfo info = infoList2.get(0);
        assertNotNull(info);
        assertNotNull(info.serviceInfo);
        assertFalse(info.serviceInfo.enabled);
    
public voidtestQueryEnabledActivity()

        mPackageManager.setComponentEnabledSetting(ENABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final List<ResolveInfo> infoList =
                mPackageManager.queryIntentActivities(mEnabledActivityIntent, 0);
        assertEquals(1, infoList.size());
        final ResolveInfo info = infoList.get(0);
        assertNotNull(info);
        assertNotNull(info.activityInfo);
        assertTrue(info.activityInfo.enabled);
    
public voidtestQueryEnabledProvider()

        mPackageManager.setComponentEnabledSetting(ENABLED_PROVIDER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        String enabledProviderProcessName = getComponentProcessName(ENABLED_PROVIDER_NAME);
        PackageInfo pi = mPackageManager.getPackageInfo(ENABLED_PACKAGENAME, 0);
        List<ProviderInfo> providerInfoList =
                mPackageManager.queryContentProviders(enabledProviderProcessName,
                        pi.applicationInfo.uid, 0);
        assertNotNull(providerInfoList);
        assertEquals(1, providerInfoList.size());
        assertEquals(ENABLED_PROVIDER_CLASSNAME,
                     providerInfoList.get(0).name);
    
public voidtestQueryEnabledReceiver()

        mPackageManager.setComponentEnabledSetting(ENABLED_RECEIVER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final List<ResolveInfo> infoList =
                mPackageManager.queryBroadcastReceivers(mEnabledReceiverIntent, 0);
        assertEquals(1, infoList.size());
        final ResolveInfo info = infoList.get(0);
        assertNotNull(info);
        assertNotNull(info.activityInfo);
        assertTrue(info.activityInfo.enabled);
    
public voidtestQueryEnabledService()

        mPackageManager.setComponentEnabledSetting(ENABLED_SERVICE_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final List<ResolveInfo> infoList =
                mPackageManager.queryIntentServices(mEnabledServiceIntent, 0);
        assertEquals(1, infoList.size());
        final ResolveInfo info = infoList.get(0);
        assertNotNull(info);
        assertNotNull(info.serviceInfo);
        assertTrue(info.serviceInfo.enabled);
    
public voidtestResolveDisabledActivity()

        mPackageManager.setComponentEnabledSetting(DISABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final ResolveInfo info = mPackageManager.resolveActivity(mDisabledActivityIntent, 0);
        assertNull(info);

        final ResolveInfo info2 = mPackageManager.resolveActivity(
                mDisabledActivityIntent, GET_DISABLED_COMPONENTS);
        assertNotNull(info2);
        assertNotNull(info2.activityInfo);
        assertFalse(info2.activityInfo.enabled);
    
public voidtestResolveDisabledProvider()

        mPackageManager.setComponentEnabledSetting(DISABLED_PROVIDER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        ProviderInfo providerInfo =
                mPackageManager.resolveContentProvider(DISABLED_PROVIDER_NAME, 0);
        assertNull(providerInfo);
        ProviderInfo providerInfo2 =
                mPackageManager.resolveContentProvider(DISABLED_PROVIDER_NAME,
                                                       GET_DISABLED_COMPONENTS);
        assertNotNull(providerInfo2);
        assertFalse(providerInfo2.enabled);
    
public voidtestResolveDisabledService()

        mPackageManager.setComponentEnabledSetting(DISABLED_SERVICE_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final ResolveInfo info = mPackageManager.resolveService(mDisabledServiceIntent, 0);
        assertNull(info);

        final ResolveInfo info2 = mPackageManager.resolveService(
                mDisabledServiceIntent, GET_DISABLED_COMPONENTS);
        assertNotNull(info2);
        assertNotNull(info2.serviceInfo);
        assertFalse(info2.serviceInfo.enabled);
    
public voidtestResolveEnabledActivity()

        mPackageManager.setComponentEnabledSetting(ENABLED_ACTIVITY_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final ResolveInfo info = mPackageManager.resolveActivity(mEnabledActivityIntent, 0);
        assertNotNull(info);
        assertNotNull(info);
        assertNotNull(info.activityInfo);
        assertTrue(info.activityInfo.enabled);
    
public voidtestResolveEnabledProvider()

        mPackageManager.setComponentEnabledSetting(ENABLED_PROVIDER_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        ProviderInfo providerInfo =
                mPackageManager.resolveContentProvider(ENABLED_PROVIDER_NAME, 0);
        assertNotNull(providerInfo);
        assertTrue(providerInfo.enabled);
    
public voidtestResolveEnabledService()

        mPackageManager.setComponentEnabledSetting(ENABLED_SERVICE_COMPONENTNAME,
                                                   COMPONENT_ENABLED_STATE_DEFAULT,
                                                   PackageManager.DONT_KILL_APP);

        final ResolveInfo info = mPackageManager.resolveService(mEnabledServiceIntent, 0);
        assertNotNull(info);
        assertNotNull(info);
        assertNotNull(info.serviceInfo);
        assertTrue(info.serviceInfo.enabled);