Search in sources :

Example 71 with ProviderInfo

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;
}
Also used : ProviderInfo(android.content.pm.ProviderInfo)

Example 72 with ProviderInfo

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);
        }
    }
}
Also used : SoLoader(android.taobao.atlas.util.SoLoader) AtlasPreLauncher(android.taobao.atlas.runtime.AtlasPreLauncher) ApplicationInfo(android.content.pm.ApplicationInfo) ArrayList(java.util.ArrayList) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Field(java.lang.reflect.Field) PackageManager(android.content.pm.PackageManager) ProviderInfo(android.content.pm.ProviderInfo) DexFile(dalvik.system.DexFile) File(java.io.File)

Example 73 with ProviderInfo

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);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ProviderInfo(android.content.pm.ProviderInfo) Intent(android.content.Intent) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 74 with ProviderInfo

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");
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 75 with ProviderInfo

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");
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) Test(org.junit.Test)

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