Search in sources :

Example 86 with ProviderInfo

use of android.content.pm.ProviderInfo in project tray by grandcentrix.

the class TrayProviderTestCase method getMockProviderInfo.

public ProviderInfo getMockProviderInfo() {
    ProviderInfo providerInfo = new ProviderInfo();
    providerInfo.authority = getProviderMockContext().getPackageName() + ".tray";
    return providerInfo;
}
Also used : ProviderInfo(android.content.pm.ProviderInfo)

Example 87 with ProviderInfo

use of android.content.pm.ProviderInfo in project tray by grandcentrix.

the class TrayContract method getAuthority.

@NonNull
private static synchronized String getAuthority(@NonNull final Context context) {
    if (sAuthority != null) {
        return sAuthority;
    }
    checkOldWayToSetAuthority(context);
    // read all providers of the app and find the TrayContentProvider to read the authority
    final List<ProviderInfo> providers = context.getPackageManager().queryContentProviders(context.getPackageName(), Process.myUid(), 0);
    if (providers != null) {
        for (ProviderInfo provider : providers) {
            if (provider.name.equals(TrayContentProvider.class.getName())) {
                sAuthority = provider.authority;
                TrayLog.v("found authority: " + sAuthority);
                return sAuthority;
            }
        }
    }
    // Should never happen. Otherwise we implemented tray in a wrong way!
    throw new TrayRuntimeException("Internal tray error. " + "Could not find the provider authority. " + "Please fill an issue at https://github.com/grandcentrix/tray/issues");
}
Also used : TrayRuntimeException(net.grandcentrix.tray.core.TrayRuntimeException) ProviderInfo(android.content.pm.ProviderInfo) NonNull(android.support.annotation.NonNull)

Example 88 with ProviderInfo

use of android.content.pm.ProviderInfo in project ShortcutBadger by leolin310148.

the class SonyHomeBadger method sonyBadgeContentProviderExists.

/**
 * Check if the latest Sony badge content provider exists .
 *
 * @param context the context to use
 * @return true if Sony badge content provider exists, otherwise false.
 */
private static boolean sonyBadgeContentProviderExists(Context context) {
    boolean exists = false;
    ProviderInfo info = context.getPackageManager().resolveContentProvider(SONY_HOME_PROVIDER_NAME, 0);
    if (info != null) {
        exists = true;
    }
    return exists;
}
Also used : ProviderInfo(android.content.pm.ProviderInfo)

Example 89 with ProviderInfo

use of android.content.pm.ProviderInfo in project Sunshine-Version-2 by udacity.

the class TestProvider method testProviderRegistry.

/*
        This test checks to make sure that the content provider is registered correctly.
        Students: Uncomment this test to make sure you've correctly registered the WeatherProvider.
     */
public void testProviderRegistry() {
    PackageManager pm = mContext.getPackageManager();
    // We define the component name based on the package name from the context and the
    // WeatherProvider class.
    ComponentName componentName = new ComponentName(mContext.getPackageName(), WeatherProvider.class.getName());
    try {
        // Fetch the provider info using the component name from the PackageManager
        // This throws an exception if the provider isn't registered.
        ProviderInfo providerInfo = pm.getProviderInfo(componentName, 0);
        // Make sure that the registered authority matches the authority from the Contract.
        assertEquals("Error: WeatherProvider registered with authority: " + providerInfo.authority + " instead of authority: " + WeatherContract.CONTENT_AUTHORITY, providerInfo.authority, WeatherContract.CONTENT_AUTHORITY);
    } catch (PackageManager.NameNotFoundException e) {
        // I guess the provider isn't registered correctly.
        assertTrue("Error: WeatherProvider not registered at " + mContext.getPackageName(), false);
    }
}
Also used : PackageManager(android.content.pm.PackageManager) ProviderInfo(android.content.pm.ProviderInfo) ComponentName(android.content.ComponentName)

Example 90 with ProviderInfo

use of android.content.pm.ProviderInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SettingsSearchIndexablesProviderTest method setUp.

@Before
public void setUp() {
    mProvider = spy(new SettingsSearchIndexablesProvider());
    ProviderInfo info = new ProviderInfo();
    info.exported = true;
    info.grantUriPermissions = true;
    info.authority = BASE_AUTHORITY;
    info.readPermission = Manifest.permission.READ_SEARCH_INDEXABLES;
    mProvider.attachInfo(RuntimeEnvironment.application, info);
    final SearchFeatureProvider featureProvider = new SearchFeatureProviderImpl();
    featureProvider.getSearchIndexableResources().getProviderValues().clear();
    featureProvider.getSearchIndexableResources().getProviderValues().add(FakeSettingsFragment.class);
    mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
    mFakeFeatureFactory.searchFeatureProvider = featureProvider;
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) Before(org.junit.Before)

Aggregations

ProviderInfo (android.content.pm.ProviderInfo)200 ComponentName (android.content.ComponentName)43 RemoteException (android.os.RemoteException)36 ArrayList (java.util.ArrayList)33 PackageManager (android.content.pm.PackageManager)27 ResolveInfo (android.content.pm.ResolveInfo)23 ApplicationInfo (android.content.pm.ApplicationInfo)22 ServiceInfo (android.content.pm.ServiceInfo)16 Point (android.graphics.Point)16 VPackage (com.lody.virtual.server.pm.parser.VPackage)15 PackageInfo (android.content.pm.PackageInfo)14 Map (java.util.Map)14 Test (org.junit.Test)14 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)13 Uri (android.net.Uri)13 File (java.io.File)13 IPackageManager (android.content.pm.IPackageManager)12 ActivityInfo (android.content.pm.ActivityInfo)10 Before (org.junit.Before)10 Intent (android.content.Intent)8