當前位置: 首頁>>代碼示例>>Java>>正文


Java PackageInfo.REQUESTED_PERMISSION_GRANTED屬性代碼示例

本文整理匯總了Java中android.content.pm.PackageInfo.REQUESTED_PERMISSION_GRANTED屬性的典型用法代碼示例。如果您正苦於以下問題:Java PackageInfo.REQUESTED_PERMISSION_GRANTED屬性的具體用法?Java PackageInfo.REQUESTED_PERMISSION_GRANTED怎麽用?Java PackageInfo.REQUESTED_PERMISSION_GRANTED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.content.pm.PackageInfo的用法示例。


在下文中一共展示了PackageInfo.REQUESTED_PERMISSION_GRANTED屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isDisplayablePermission

private boolean isDisplayablePermission(PermissionInfo pInfo, int existingReqFlags) {
    final int base = pInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
    final boolean isNormal = base == PermissionInfo.PROTECTION_NORMAL;
    final boolean isDangerous = base == PermissionInfo.PROTECTION_DANGEROUS
            || ((pInfo.protectionLevel & PermissionInfo.PROTECTION_FLAG_PRE23) != 0);

    // Dangerous and normal permissions are always shown to the user
    // this is matches the permission list in AppDetails2
    if (isNormal || isDangerous) {
        return true;
    }

    final boolean isDevelopment = (pInfo.protectionLevel & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0;
    final boolean wasGranted = (existingReqFlags & PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0;

    // Development permissions are only shown to the user if they are already
    // granted to the app -- if we are installing an app and they are not
    // already granted, they will not be granted as part of the install.
    return isDevelopment && wasGranted;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:20,代碼來源:AppSecurityPermissions.java

示例2: neededPermissions

@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @NonNull
static String[] neededPermissions(Context context) {
	PackageInfo info = null;
	try {
		info = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS);
	} catch (PackageManager.NameNotFoundException e) { /* */ }
	List<String> needed = new ArrayList<>();
	if (info != null &&
		info.requestedPermissions != null &&
		info.requestedPermissionsFlags != null) {
		for (int i = 0; i < info.requestedPermissions.length; i++) {
			int flags = info.requestedPermissionsFlags[i];
			if ((flags & PackageInfo.REQUESTED_PERMISSION_GRANTED) == 0) {
				needed.add(info.requestedPermissions[i]);
			}
		}
	}
	return needed.toArray(new String[needed.size()]);
}
 
開發者ID:sensorberg-dev,項目名稱:permission-bitte,代碼行數:19,代碼來源:PermissionBitteImpl.java

示例3: fetchDetail

private AppDetails fetchDetail(String packageName) {
  PackageManager packageManager = context.getPackageManager();
  AppDetails appDetails = new AppDetails();
  try {
    PackageInfo packageInfo = packageManager.getPackageInfo(packageName,
        PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS);
    appDetails.name = packageInfo.applicationInfo.loadLabel(packageManager).toString();
    appDetails.icon = packageInfo.applicationInfo.loadIcon(packageManager);
    appDetails.packageName = packageName;
    appDetails.publicSrcDir = packageInfo.applicationInfo.publicSourceDir;
    if (packageInfo.requestedPermissions != null) {
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        for (int index = 0; index < packageInfo.requestedPermissions.length; index++) {
          if ((packageInfo.requestedPermissionsFlags[index]
              & PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0) {
            appDetails.grantedPermissionList.add(packageInfo.requestedPermissions[index]);
          } else {
            appDetails.deniedPermissionList.add(packageInfo.requestedPermissions[index]);
          }
        }
      } else {
        appDetails.grantedPermissionList =
            new ArrayList<>(Arrays.asList(packageInfo.requestedPermissions));
      }
    }
  } catch (PackageManager.NameNotFoundException e) {
    e.printStackTrace();
  }
  return appDetails;
}
 
開發者ID:Arjun-sna,項目名稱:android-permission-checker-app,代碼行數:30,代碼來源:DataProvider.java

示例4: isNewPermission

/**
 * A permission is a "new permission" if the app is already installed and
 * doesn't currently hold this permission. On older devices that don't support
 * this concept, permissions are never "new permissions".
 */
@TargetApi(16)
private static boolean isNewPermission(PackageInfo installedPkgInfo, int existingFlags) {
    if (installedPkgInfo == null || Build.VERSION.SDK_INT < 16) {
        return false;
    }

    return (existingFlags & PackageInfo.REQUESTED_PERMISSION_GRANTED) == 0;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:13,代碼來源:AppSecurityPermissions.java

示例5: 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.PackageInfo.REQUESTED_PERMISSION_GRANTED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。