use of android.content.pm.ProviderInfo in project OneSignal-Android-SDK by OneSignal.
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 atlas by alibaba.
the class BridgeApplicationDelegate method attachBaseContext.
public void attachBaseContext() {
AtlasHacks.defineAndVerify();
RuntimeVariables.androidApplication = mRawApplication;
RuntimeVariables.originalResources = mRawApplication.getResources();
RuntimeVariables.sCurrentProcessName = mCurrentProcessname;
RuntimeVariables.sInstalledVersionCode = mInstalledVersionCode;
RuntimeVariables.sAppLastUpdateTime = mLastUpdateTime;
RuntimeVariables.sApkPath = mApkPath;
RuntimeVariables.delegateResources = mRawApplication.getResources();
RuntimeVariables.sDexLoadBooster = mdexLoadBooster;
Log.e("BridgeApplication", "length =" + new File(mRawApplication.getApplicationInfo().sourceDir).length());
if (!TextUtils.isEmpty(mInstalledVersionName)) {
RuntimeVariables.sInstalledVersionName = mInstalledVersionName;
}
System.out.print(SoLoader.class.getName());
try {
String preLaunchStr = (String) RuntimeVariables.getFrameworkProperty("preLaunch");
if (!TextUtils.isEmpty(preLaunchStr)) {
AtlasPreLauncher launcher = (AtlasPreLauncher) Class.forName(preLaunchStr).newInstance();
if (launcher != null) {
launcher.initBeforeAtlas(mRawApplication.getBaseContext());
}
}
} catch (Throwable e) {
throw new RuntimeException(e);
}
// *2 init atlas use reflect
boolean multidexEnable = false;
try {
ApplicationInfo appInfo = mRawApplication.getPackageManager().getApplicationInfo(mRawApplication.getPackageName(), PackageManager.GET_META_DATA);
mRealApplicationName = appInfo.metaData.getString("REAL_APPLICATION");
multidexEnable = appInfo.metaData.getBoolean("multidex_enable");
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
if (multidexEnable) {
MultiDex.install(mRawApplication);
}
mRealApplicationName = TextUtils.isEmpty(mRealApplicationName) ? "android.app.Application" : mRealApplicationName;
if (mRealApplicationName.startsWith(".")) {
mRealApplicationName = mRawApplication.getPackageName() + mRealApplicationName;
}
RuntimeVariables.sRealApplicationName = mRealApplicationName;
try {
Atlas.getInstance().init(mRawApplication, mIsUpdated);
} catch (Throwable e) {
File storageDir = new File(mRawApplication.getFilesDir(), "storage");
Framework.deleteDirectory(storageDir);
KernalVersionManager.instance().removeBaseLineInfo();
android.os.Process.killProcess(Process.myPid());
// throw new RuntimeException("atlas initialization fail--->" + e.getMessage());
}
// ////////////////////////////////////////launchTime////////////////////
try {
Class BuildConfig = Class.forName(mRawApplication.getPackageName() + ".BuildConfig");
Field launchTimeField = BuildConfig.getDeclaredField("launchTime");
launchTimeField.setAccessible(true);
launchTimeField.set(BuildConfig, System.currentTimeMillis());
} catch (Throwable e) {
}
// *3 remove providerinfo for so installcontentprovider is delayed
try {
Object activityThread = AndroidHack.getActivityThread();
Object mBoundApplication = AtlasHacks.ActivityThread_mBoundApplication.get(activityThread);
mBoundApplication_provider = AtlasHacks.ActivityThread$AppBindData_providers.get(mBoundApplication);
if (mBoundApplication_provider != null && mBoundApplication_provider.size() > 0) {
AtlasHacks.ActivityThread$AppBindData_providers.set(mBoundApplication, null);
} else if (Build.VERSION.SDK_INT >= 24 && mCurrentProcessname != null && mCurrentProcessname.equals(mRawApplication.getPackageName())) {
mBoundApplication_provider = new ArrayList<>();
ProviderInfo providerInfo = mRawApplication.getPackageManager().resolveContentProvider(mRawApplication.getPackageName() + ".update.provider", 0);
if (providerInfo != null) {
providerInfo.exported = false;
providerInfo.grantUriPermissions = true;
mBoundApplication_provider.add(providerInfo);
}
}
} catch (Exception e) {
if (e instanceof InvocationTargetException) {
throw new RuntimeException(((InvocationTargetException) e).getTargetException());
} else {
throw new RuntimeException(e);
}
}
}
use of android.content.pm.ProviderInfo in project robolectric by robolectric.
the class ShadowPackageManagerTest method queryIntentContentProviders_Match.
@Test
@Config(minSdk = LOLLIPOP)
public void queryIntentContentProviders_Match() {
Intent i = new Intent(DocumentsContract.PROVIDER_INTERFACE);
ResolveInfo resolveInfo = new ResolveInfo();
ProviderInfo providerInfo = new ProviderInfo();
providerInfo.authority = "com.robolectric";
resolveInfo.providerInfo = providerInfo;
shadowOf(packageManager).addResolveInfoForIntent(i, resolveInfo);
List<ResolveInfo> contentProviders = packageManager.queryIntentContentProviders(i, 0);
assertThat(contentProviders).hasSize(1);
assertThat(contentProviders.get(0).providerInfo.authority).isEqualTo(providerInfo.authority);
}
use of android.content.pm.ProviderInfo in project robolectric by robolectric.
the class ShadowPackageManagerTest method getProviderInfo_shouldMetaDataInProviderInfos.
@Test
public void getProviderInfo_shouldMetaDataInProviderInfos() throws Exception {
ProviderInfo providerInfo = packageManager.getProviderInfo(new ComponentName(context, "org.robolectric.shadows.testing.TestContentProvider1"), PackageManager.GET_META_DATA);
assertThat(providerInfo.authority).isEqualTo("org.robolectric.authority1");
assertThat(providerInfo.metaData.getString("greeting")).isEqualTo("Hello");
}
use of android.content.pm.ProviderInfo in project robolectric by robolectric.
the class ShadowPackageManagerTest method resolveContentProvider_multiAuthorities.
@Test
public void resolveContentProvider_multiAuthorities() {
ProviderInfo providerInfo = packageManager.resolveContentProvider("org.robolectric.authority3", 0);
assertThat(providerInfo.packageName).isEqualTo("org.robolectric");
assertThat(providerInfo.authority).isEqualTo("org.robolectric.authority3;org.robolectric.authority4");
}
Aggregations