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


Java PackageManager.GET_PERMISSIONS属性代码示例

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


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

示例1: getPackageInfo

@Override public PackageInfo getPackageInfo(final String pkg, final int flags) throws NameNotFoundException {
	final PackageInfo info = mCondom.proceed(OutboundType.GET_PACKAGE_INFO, pkg, null, new CondomCore.WrappedValueProcedureThrows<PackageInfo, NameNotFoundException>() {
		@Override public PackageInfo proceed() throws NameNotFoundException {
			return CondomPackageManager.super.getPackageInfo(pkg, flags);
		}
	});
	if (info == null) throw new NameNotFoundException(pkg);
	if ((flags & PackageManager.GET_PERMISSIONS) != 0 && ! mCondom.getSpoofPermissions().isEmpty() && mCondom.getPackageName().equals(pkg)) {
		final List<String> requested_permissions = info.requestedPermissions == null ? new ArrayList<String>()
				: new ArrayList<>(Arrays.asList(info.requestedPermissions));
		final List<String> missing_permissions = new ArrayList<>(mCondom.getSpoofPermissions());
		missing_permissions.removeAll(requested_permissions);
		if (! missing_permissions.isEmpty()) {
			requested_permissions.addAll(missing_permissions);
			info.requestedPermissions = requested_permissions.toArray(new String[requested_permissions.size()]);
		}    // Even if all permissions to spoof are already requested, the permission granted state still requires amending.

		if (SDK_INT >= JELLY_BEAN) {
			final int[] req_permissions_flags = info.requestedPermissionsFlags == null ? new int[requested_permissions.size()]
					: Arrays.copyOf(info.requestedPermissionsFlags, requested_permissions.size());
			for (int i = 0; i < info.requestedPermissions.length; i++)
				if (mCondom.shouldSpoofPermission(info.requestedPermissions[i]))
					req_permissions_flags[i] = PackageInfo.REQUESTED_PERMISSION_GRANTED;
			info.requestedPermissionsFlags = req_permissions_flags;
		}
	}
	return info;
}
 
开发者ID:oasisfeng,项目名称:condom,代码行数:28,代码来源:CondomPackageManager.java


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