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;
}
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");
}
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;
}
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);
}
}
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;
}
Aggregations