Loading core/java/android/service/credentials/CredentialProviderInfoFactory.java +2 −1 Original line number Diff line number Diff line Loading @@ -167,7 +167,8 @@ public final class CredentialProviderInfoFactory { Slog.w(TAG, "Context is null in isSystemProviderWithValidPermission"); return false; } return PermissionUtils.hasPermission(context, serviceInfo.packageName, return PermissionUtils.isSystemApp(context, serviceInfo.packageName) && PermissionUtils.hasPermission(context, serviceInfo.packageName, Manifest.permission.PROVIDE_DEFAULT_ENABLED_CREDENTIAL_SERVICE); } Loading core/java/android/service/credentials/PermissionUtils.java +8 −5 Original line number Diff line number Diff line Loading @@ -30,16 +30,19 @@ public class PermissionUtils { /** Checks whether the given package name hold the given permission **/ public static boolean hasPermission(Context context, String packageName, String permission) { return context.getPackageManager().checkPermission(permission, packageName) == PackageManager.PERMISSION_GRANTED; } /** Checks whether the given package name is a system app on the device **/ public static boolean isSystemApp(Context context, String packageName) { try { ApplicationInfo appInfo = context.getPackageManager() .getApplicationInfo( packageName, .getApplicationInfo(packageName, PackageManager.ApplicationInfoFlags.of( PackageManager.MATCH_SYSTEM_ONLY)); if (appInfo != null && context.checkPermission(permission, /* pid= */ -1, appInfo.uid) == PackageManager.PERMISSION_GRANTED) { if (appInfo != null) { return true; } } catch (PackageManager.NameNotFoundException e) { Loading Loading
core/java/android/service/credentials/CredentialProviderInfoFactory.java +2 −1 Original line number Diff line number Diff line Loading @@ -167,7 +167,8 @@ public final class CredentialProviderInfoFactory { Slog.w(TAG, "Context is null in isSystemProviderWithValidPermission"); return false; } return PermissionUtils.hasPermission(context, serviceInfo.packageName, return PermissionUtils.isSystemApp(context, serviceInfo.packageName) && PermissionUtils.hasPermission(context, serviceInfo.packageName, Manifest.permission.PROVIDE_DEFAULT_ENABLED_CREDENTIAL_SERVICE); } Loading
core/java/android/service/credentials/PermissionUtils.java +8 −5 Original line number Diff line number Diff line Loading @@ -30,16 +30,19 @@ public class PermissionUtils { /** Checks whether the given package name hold the given permission **/ public static boolean hasPermission(Context context, String packageName, String permission) { return context.getPackageManager().checkPermission(permission, packageName) == PackageManager.PERMISSION_GRANTED; } /** Checks whether the given package name is a system app on the device **/ public static boolean isSystemApp(Context context, String packageName) { try { ApplicationInfo appInfo = context.getPackageManager() .getApplicationInfo( packageName, .getApplicationInfo(packageName, PackageManager.ApplicationInfoFlags.of( PackageManager.MATCH_SYSTEM_ONLY)); if (appInfo != null && context.checkPermission(permission, /* pid= */ -1, appInfo.uid) == PackageManager.PERMISSION_GRANTED) { if (appInfo != null) { return true; } } catch (PackageManager.NameNotFoundException e) { Loading