Fix permission check for system service
Bug: 278589543 Test: built & deployed locally Change-Id: I7cbedd0160a3db7da5e060862d9de6944fb020a9
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user