当前位置: 首页>>代码示例>>Java>>正文


Java PackageParser类代码示例

本文整理汇总了Java中android.content.pm.PackageParser的典型用法代码示例。如果您正苦于以下问题:Java PackageParser类的具体用法?Java PackageParser怎么用?Java PackageParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PackageParser类属于android.content.pm包,在下文中一共展示了PackageParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLeanbackLaunchIntent

import android.content.pm.PackageParser; //导入依赖的package包/类
public Intent getLeanbackLaunchIntent() {
    ContentResolver resolver = this.mPluginContext.getContentResolver();
    Intent launcher = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER);

    for (PackageParser.Activity activity : this.mPackage.activities) {
        for (PackageParser.ActivityIntentInfo intentInfo : activity.intents) {
            if (intentInfo.match(resolver, launcher, false, TAG) > 0) {
                Intent intent = new Intent(Intent.ACTION_MAIN);
                intent.setComponent(activity.getComponentName());
                intent.addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER);
                return intent;
            }
        }
    }

    return null;
}
 
开发者ID:didi,项目名称:VirtualAPK,代码行数:18,代码来源:LoadedPlugin.java

示例2: parsePackage

import android.content.pm.PackageParser; //导入依赖的package包/类
public static Package parsePackage(PackageParser parser, File packageFile, int flags) throws Throwable {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.parsePackage.callWithException(parser, packageFile, flags);
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        return PackageParserLollipop22.parsePackage.callWithException(parser, packageFile, flags);
    } else if (API_LEVEL >= LOLLIPOP) {
        return PackageParserLollipop.parsePackage.callWithException(parser, packageFile, flags);
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.parsePackage.callWithException(parser, packageFile, null,
                new DisplayMetrics(), flags);
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.parsePackage.callWithException(parser, packageFile, null,
                new DisplayMetrics(), flags);
    } else {
        return mirror.android.content.pm.PackageParser.parsePackage.callWithException(parser, packageFile, null,
                new DisplayMetrics(), flags);
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:19,代码来源:PackageParserCompat.java

示例3: generatePackageInfo

import android.content.pm.PackageParser; //导入依赖的package包/类
public static PackageInfo generatePackageInfo(Package p, int flags, long firstInstallTime, long lastUpdateTime) {
    if (API_LEVEL >= M) {
        return PackageParserMarshmallow.generatePackageInfo.call(p, GIDS, flags, firstInstallTime, lastUpdateTime,
                null, sUserState);
    } else if (API_LEVEL >= LOLLIPOP) {
        if (PackageParserLollipop22.generatePackageInfo != null) {
            return PackageParserLollipop22.generatePackageInfo.call(p, GIDS, flags, firstInstallTime, lastUpdateTime,
                    null, sUserState);
        } else {
            return PackageParserLollipop.generatePackageInfo.call(p, GIDS, flags, firstInstallTime, lastUpdateTime,
                    null, sUserState);
        }
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        return PackageParserJellyBean17.generatePackageInfo.call(p, GIDS, flags, firstInstallTime, lastUpdateTime,
                null, sUserState);
    } else if (API_LEVEL >= JELLY_BEAN) {
        return PackageParserJellyBean.generatePackageInfo.call(p, GIDS, flags, firstInstallTime, lastUpdateTime,
                null);
    } else {
        return mirror.android.content.pm.PackageParser.generatePackageInfo.call(p, GIDS, flags, firstInstallTime,
                lastUpdateTime);
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:24,代码来源:PackageParserCompat.java

示例4: collectCertificates

import android.content.pm.PackageParser; //导入依赖的package包/类
public static void collectCertificates(PackageParser parser, Package p, int flags) throws Throwable {
    if (API_LEVEL >= N) {
        PackageParserNougat.collectCertificates.callWithException(p, flags);
    } else if (API_LEVEL >= M) {
        PackageParserMarshmallow.collectCertificates.callWithException(parser, p, flags);
    } else if (API_LEVEL >= LOLLIPOP_MR1) {
        PackageParserLollipop22.collectCertificates.callWithException(parser, p, flags);
    } else if (API_LEVEL >= LOLLIPOP) {
        PackageParserLollipop.collectCertificates.callWithException(parser, p, flags);
    } else if (API_LEVEL >= JELLY_BEAN_MR1) {
        PackageParserJellyBean17.collectCertificates.callWithException(parser, p, flags);
    } else if (API_LEVEL >= JELLY_BEAN) {
        PackageParserJellyBean.collectCertificates.callWithException(parser, p, flags);
    } else {
        mirror.android.content.pm.PackageParser.collectCertificates.call(parser, p, flags);
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:18,代码来源:PackageParserCompat.java

示例5: newResult

import android.content.pm.PackageParser; //导入依赖的package包/类
@Override
protected ResolveInfo newResult(PackageParser.ServiceIntentInfo filter, int match) {
	final PackageParser.Service service = filter.service;
	ServiceInfo si = PackageParserCompat.generateServiceInfo(service, mFlags);
	if (si == null) {
		return null;
	}
	final ResolveInfo res = new ResolveInfo();
	res.serviceInfo = si;
	if ((mFlags & PackageManager.GET_RESOLVED_FILTER) != 0) {
		res.filter = filter;
	}
	res.priority = filter.getPriority();
	res.preferredOrder = service.owner.mPreferredOrder;
	res.match = match;
	res.isDefault = filter.hasDefault;
	res.labelRes = filter.labelRes;
	res.nonLocalizedLabel = filter.nonLocalizedLabel;
	res.icon = filter.icon;
	return res;
}
 
开发者ID:codehz,项目名称:container,代码行数:22,代码来源:VPackageManagerService.java

示例6: getPackageInfo

import android.content.pm.PackageParser; //导入依赖的package包/类
@Override
public PackageInfo getPackageInfo(String packageName, int flags, int userId) {
	synchronized (mPackages) {
		PackageParser.Package pkg = mPackages.get(packageName);
		if (pkg != null) {
			AppSetting setting = (AppSetting) pkg.mExtras;
			if ((flags & PackageManager.GET_SIGNATURES) != 0 && pkg.mSignatures == null) {
				if (pkg.mAppMetaData != null && pkg.mAppMetaData.containsKey(Constants.FEATURE_FAKE_SIGNATURE)) {
					String sig = pkg.mAppMetaData.getString("fake-signature");
					if (sig != null) {
						pkg.mSignatures = new Signature[] {new Signature(sig)};
					}
				} else {
					PackageParserCompat.collectCertificates(setting.parser, pkg, PackageParser.PARSE_IS_SYSTEM);
				}
			}
			PackageInfo packageInfo = PackageParserCompat.generatePackageInfo(pkg, flags,
					getFirstInstallTime(pkg), getLastInstallTime(pkg));
			if (packageInfo != null) {
				ComponentFixer.fixApplicationInfo(setting, packageInfo.applicationInfo, userId);
				return packageInfo;
			}
		}
	}
	return null;
}
 
开发者ID:codehz,项目名称:container,代码行数:27,代码来源:VPackageManagerService.java

示例7: activitySupportsIntent

import android.content.pm.PackageParser; //导入依赖的package包/类
@Override
public boolean activitySupportsIntent(ComponentName component, Intent intent, String resolvedType) {
	synchronized (mPackages) {
		PackageParser.Activity a = mActivities.mActivities.get(component);
		if (a == null) {
			return false;
		}
		for (int i = 0; i < a.intents.size(); i++) {
			if (a.intents.get(i).match(intent.getAction(), resolvedType, intent.getScheme(), intent.getData(),
					intent.getCategories(), TAG) >= 0) {
				return true;
			}
		}
		return false;
	}
}
 
开发者ID:codehz,项目名称:container,代码行数:17,代码来源:VPackageManagerService.java

示例8: queryIntentActivities

import android.content.pm.PackageParser; //导入依赖的package包/类
@Override
public List<ResolveInfo> queryIntentActivities(Intent intent, String resolvedType, int flags, int userId) {
	checkUserId(userId);
	ComponentName comp = intent.getComponent();
	if (comp == null) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
			if (intent.getSelector() != null) {
				intent = intent.getSelector();
				comp = intent.getComponent();
			}
		}
	}
	if (comp != null) {
		final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
		final ActivityInfo ai = getActivityInfo(comp, flags, userId);
		if (ai != null) {
			final ResolveInfo ri = new ResolveInfo();
			ri.activityInfo = ai;
			list.add(ri);
		}
		return list;
	}

	// reader
	synchronized (mPackages) {
		final String pkgName = intent.getPackage();
		if (pkgName == null) {
			return mActivities.queryIntent(intent, resolvedType, flags);
		}
		final PackageParser.Package pkg = mPackages.get(pkgName);
		if (pkg != null) {
			return mActivities.queryIntentForPackage(intent, resolvedType, flags, pkg.activities);
		}
		return new ArrayList<ResolveInfo>();
	}
}
 
开发者ID:codehz,项目名称:container,代码行数:37,代码来源:VPackageManagerService.java

示例9: queryIntentReceivers

import android.content.pm.PackageParser; //导入依赖的package包/类
@Override
public List<ResolveInfo> queryIntentReceivers(Intent intent, String resolvedType, int flags, int userId) {
	ComponentName comp = intent.getComponent();
	if (comp == null) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
			if (intent.getSelector() != null) {
				intent = intent.getSelector();
				comp = intent.getComponent();
			}
		}
	}
	if (comp != null) {
		List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
		ActivityInfo ai = getReceiverInfo(comp, flags, userId);
		if (ai != null) {
			ResolveInfo ri = new ResolveInfo();
			ri.activityInfo = ai;
			list.add(ri);
		}
		return list;
	}

	// reader
	synchronized (mPackages) {
		String pkgName = intent.getPackage();
		if (pkgName == null) {
			return mReceivers.queryIntent(intent, resolvedType, flags);
		}
		final PackageParser.Package pkg = mPackages.get(pkgName);
		if (pkg != null) {
			return mReceivers.queryIntentForPackage(intent, resolvedType, flags, pkg.receivers);
		}
		return null;
	}
}
 
开发者ID:codehz,项目名称:container,代码行数:36,代码来源:VPackageManagerService.java

示例10: queryReceivers

import android.content.pm.PackageParser; //导入依赖的package包/类
@Override
public List<ReceiverInfo> queryReceivers(String processName, int uid, int flags) {
	int userId = VUserHandle.getUserId(uid);
	checkUserId(userId);
	ArrayList<ReceiverInfo> finalList = new ArrayList<>(3);
	synchronized (mPackages) {
		for (PackageParser.Activity a : mReceivers.mActivities.values()) {
			if (a.info.processName.equals(processName)) {
				ActivityInfo receiverInfo = PackageParserCompat.generateActivityInfo(a, flags);
				if (receiverInfo != null) {
					AppSetting settings = (AppSetting) mPackages.get(receiverInfo.packageName).mExtras;
					ComponentFixer.fixComponentInfo(settings, receiverInfo, userId);
					ComponentName component = ComponentUtils.toComponentName(receiverInfo);
					IntentFilter[] filters = null;
					if (a.intents != null) {
						filters = a.intents.toArray(new IntentFilter[a.intents.size()]);
					}
					finalList.add(new ReceiverInfo(component, filters, receiverInfo.permission));
				}
			}
		}
	}
	return finalList;
}
 
开发者ID:codehz,项目名称:container,代码行数:25,代码来源:VPackageManagerService.java

示例11: queryIntentServices

import android.content.pm.PackageParser; //导入依赖的package包/类
@Override
public List<ResolveInfo> queryIntentServices(Intent intent, String resolvedType, int flags, int userId) {
	checkUserId(userId);
	ComponentName comp = intent.getComponent();
	if (comp == null) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
			if (intent.getSelector() != null) {
				intent = intent.getSelector();
				comp = intent.getComponent();
			}
		}
	}
	if (comp != null) {
		final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
		final ServiceInfo si = getServiceInfo(comp, flags, userId);
		if (si != null) {
			final ResolveInfo ri = new ResolveInfo();
			ri.serviceInfo = si;
			list.add(ri);
		}
		return list;
	}

	// reader
	synchronized (mPackages) {
		String pkgName = intent.getPackage();
		if (pkgName == null) {
			return mServices.queryIntent(intent, resolvedType, flags);
		}
		final PackageParser.Package pkg = mPackages.get(pkgName);
		if (pkg != null) {
			return mServices.queryIntentForPackage(intent, resolvedType, flags, pkg.services);
		}
		return null;
	}
}
 
开发者ID:codehz,项目名称:container,代码行数:37,代码来源:VPackageManagerService.java

示例12: queryIntentContentProviders

import android.content.pm.PackageParser; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public List<ResolveInfo> queryIntentContentProviders(Intent intent, String resolvedType, int flags, int userId) {
	checkUserId(userId);
	ComponentName comp = intent.getComponent();
	if (comp == null) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
			if (intent.getSelector() != null) {
				intent = intent.getSelector();
				comp = intent.getComponent();
			}
		}
	}
	if (comp != null) {
		final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
		final ProviderInfo pi = getProviderInfo(comp, flags, userId);
		if (pi != null) {
			final ResolveInfo ri = new ResolveInfo();
			ri.providerInfo = pi;
			list.add(ri);
		}
		return list;
	}
	// reader
	synchronized (mPackages) {
		String pkgName = intent.getPackage();
		if (pkgName == null) {
			return mProviders.queryIntent(intent, resolvedType, flags);
		}
		final PackageParser.Package pkg = mPackages.get(pkgName);
		if (pkg != null) {
			return mProviders.queryIntentForPackage(intent, resolvedType, flags, pkg.providers);
		}
		return null;
	}
}
 
开发者ID:codehz,项目名称:container,代码行数:37,代码来源:VPackageManagerService.java

示例13: queryContentProviders

import android.content.pm.PackageParser; //导入依赖的package包/类
@Override
public VParceledListSlice<ProviderInfo> queryContentProviders(String processName, int vuid, int flags) {
	int userId = VUserHandle.getUserId(vuid);
	checkUserId(userId);
	ArrayList<ProviderInfo> finalList = new ArrayList<>(3);
	// reader
	synchronized (mPackages) {
		for (PackageParser.Provider p : mProvidersByComponent.values()) {
			AppSetting setting = (AppSetting) p.owner.mExtras;
			if (processName == null || setting.appId == VUserHandle.getAppId(vuid) && p.info.processName.equals(processName)) {
				ProviderInfo providerInfo = PackageParserCompat.generateProviderInfo(p, flags);
				ComponentFixer.fixApplicationInfo(setting, providerInfo.applicationInfo, userId);
				finalList.add(providerInfo);
			}
		}
	}
	if (!finalList.isEmpty()) {
		Collections.sort(finalList, mProviderInitOrderSorter);
	}
	return new VParceledListSlice<>(finalList);
}
 
开发者ID:codehz,项目名称:container,代码行数:22,代码来源:VPackageManagerService.java

示例14: querySharedPackages

import android.content.pm.PackageParser; //导入依赖的package包/类
@Override
public List<String> querySharedPackages(String packageName) {
	synchronized (mPackages) {
		PackageParser.Package p = mPackages.get(packageName);
		if (p == null || p.mSharedUserId == null) {
			// noinspection unchecked
			return Collections.EMPTY_LIST;
		}
		ArrayList<String> list = new ArrayList<>();
		for (PackageParser.Package one : mPackages.values()) {
			if (TextUtils.equals(one.mSharedUserId, p.mSharedUserId)) {
				list.add(one.packageName);
			}
		}
		return list;
	}
}
 
开发者ID:codehz,项目名称:container,代码行数:18,代码来源:VPackageManagerService.java

示例15: queryIntentForPackage

import android.content.pm.PackageParser; //导入依赖的package包/类
public List<ResolveInfo> queryIntentForPackage(Intent intent, String resolvedType, int flags,
		ArrayList<PackageParser.Activity> packageActivities) {
	if (packageActivities == null) {
		return null;
	}
	mFlags = flags;
	final boolean defaultOnly = (flags & PackageManager.MATCH_DEFAULT_ONLY) != 0;
	final int N = packageActivities.size();
	ArrayList<PackageParser.ActivityIntentInfo[]> listCut = new ArrayList<PackageParser.ActivityIntentInfo[]>(
			N);

	ArrayList<PackageParser.ActivityIntentInfo> intentFilters;
	for (int i = 0; i < N; ++i) {
		intentFilters = packageActivities.get(i).intents;
		if (intentFilters != null && intentFilters.size() > 0) {
			PackageParser.ActivityIntentInfo[] array = new PackageParser.ActivityIntentInfo[intentFilters
					.size()];
			intentFilters.toArray(array);
			listCut.add(array);
		}
	}
	return super.queryIntentFromList(intent, resolvedType, defaultOnly, listCut);
}
 
开发者ID:codehz,项目名称:container,代码行数:24,代码来源:VPackageManagerService.java


注:本文中的android.content.pm.PackageParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。