Java 类android.content.pm.PackageParser.Provider 实例源码

项目:VirtualHook    文件:PackageParserCompat.java   
public static ProviderInfo generateProviderInfo(Provider provider, int flags) {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.generateProviderInfo.call(provider, flags, sUserState, myUserId);
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        return PackageParserLollipop22.generateProviderInfo.call(provider, flags, sUserState, myUserId);
    } else if (API_LEVEL >= LOLLIPOP) {
        return PackageParserLollipop.generateProviderInfo.call(provider, flags, sUserState, myUserId);
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.generateProviderInfo.call(provider, flags, sUserState, myUserId);
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.generateProviderInfo.call(provider, flags, false, 1, myUserId);
    } else {
        return mirror.android.content.pm.PackageParser.generateProviderInfo.call(provider, flags);
    }
}
项目:TPlayer    文件:PackageParserCompat.java   
public static ProviderInfo generateProviderInfo(Provider provider, int flags) {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.generateProviderInfo.call(provider, flags, sUserState, myUserId);
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        return PackageParserLollipop22.generateProviderInfo.call(provider, flags, sUserState, myUserId);
    } else if (API_LEVEL >= LOLLIPOP) {
        return PackageParserLollipop.generateProviderInfo.call(provider, flags, sUserState, myUserId);
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.generateProviderInfo.call(provider, flags, sUserState, myUserId);
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.generateProviderInfo.call(provider, flags, false, 1, myUserId);
    } else {
        return mirror.android.content.pm.PackageParser.generateProviderInfo.call(provider, flags);
    }
}
项目:container    文件:PackageParserCompat.java   
public static ProviderInfo generateProviderInfo(Provider provider, int flags) {

        if (SDK >= M) {

            return PackageParserMarshmallow.generateProviderInfo.call(provider, flags, sUserState, myUserId);

        } else if (SDK >= LOLLIPOP_MR1) {

            return PackageParserLollipop22.generateProviderInfo.call(provider, flags, sUserState, myUserId);

        } else if (SDK >= LOLLIPOP) {

            return PackageParserLollipop.generateProviderInfo.call(provider, flags, sUserState, myUserId);

        } else if (SDK >= JELLY_BEAN_MR1) {

            return PackageParserJellyBean17.generateProviderInfo.call(provider, flags, sUserState, myUserId);

        } else if (SDK >= JELLY_BEAN) {

            return PackageParserJellyBean.generateProviderInfo.call(provider, flags, false, 1, myUserId);

        } else {
            return mirror.android.content.pm.PackageParser.generateProviderInfo.call(provider, flags);
        }
    }
项目:koala--Android-Plugin-Runtime-    文件:PluginManagerImpl.java   
/**
 * 解析APK的manifest
 * 
 * @param info
 *            插件信息
 */
private void getPackageInfo(PluginInfo info) {

    int flags = PackageManager.GET_ACTIVITIES | PackageManager.GET_CONFIGURATIONS
            | PackageManager.GET_INSTRUMENTATION | PackageManager.GET_PERMISSIONS | PackageManager.GET_PROVIDERS
            | PackageManager.GET_RECEIVERS | PackageManager.GET_SERVICES | PackageManager.GET_SIGNATURES;

    // 需要获取Package对象,主要是处理隐式启动插件中的activity
    PackageParser parser = new PackageParser(info.apkPath);
    DisplayMetrics metrics = new DisplayMetrics();
    metrics.setToDefaults();
    File sourceFile = new File(info.apkPath);
    PackageParser.Package pack = parser.parsePackage(sourceFile, info.apkPath, metrics, 0);

    // 因为PackagePaser的generatePackageInfo方法不同版本参数相差太多,所以还是用packagemanager的api
    // 但这样导致APK被解析了两次,上面获取Package是一次
    PackageInfo packageInfo = mContext.getPackageManager().getPackageArchiveInfo(info.apkPath, flags);

    info.packageName = packageInfo.packageName;
    info.mPackageObj = pack;
    info.mPackageInfo = packageInfo;

    ArrayList<PackageParser.Activity> activitys = pack.activities;
    int size = activitys.size();
    for (int i = 0; i < size; i++) {
        mActivitys.addActivity(activitys.get(i));
    }

    ArrayList<PackageParser.Service> services = pack.services;
    size = services.size();
    for (int i = 0; i < size; i++) {
        mServices.addService(services.get(i));
    }

    ArrayList<PackageParser.Provider> providers = pack.providers;
    size = providers.size();
    for (int i = 0; i < size; i++) {
        Provider p = providers.get(i);
        String names[] = PATTERN_SEMICOLON.split(p.info.authority);
        for (int j = 0; j < names.length; j++) {
            mProviderInfoMap.put(names[i], p);
        }
    }
}