Merge "Fix permission check for system service" into udc-dev

This commit is contained in:
Treehugger Robot
2023-04-19 05:22:02 +00:00
committed by Android (Google) Code Review
2 changed files with 1 additions and 19 deletions

View File

@@ -165,8 +165,7 @@ public final class CredentialProviderInfoFactory {
Slog.w(TAG, "Context is null in isSystemProviderWithValidPermission");
return false;
}
return PermissionUtils.isSystemApp(context, serviceInfo.packageName)
&& PermissionUtils.hasPermission(context, serviceInfo.packageName,
return PermissionUtils.hasPermission(context, serviceInfo.packageName,
Manifest.permission.PROVIDE_DEFAULT_ENABLED_CREDENTIAL_SERVICE);
}

View File

@@ -17,7 +17,6 @@
package android.service.credentials;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
/**
@@ -33,21 +32,5 @@ public class PermissionUtils {
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,
PackageManager.ApplicationInfoFlags.of(
PackageManager.MATCH_SYSTEM_ONLY));
if (appInfo != null) {
return true;
}
} catch (PackageManager.NameNotFoundException e) {
}
return false;
}
}