If it’s the same syntax as C# and the flags are set properly, you could do this:
PackageManager p = context.getPackageManager();
final List<PackageInfo> appinstall =
p.getInstalledPackages(PackageManager.GET_PERMISSIONS |
PackageManager.GET_PROVIDERS)