當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。