Revert "Use ApplicationInfo.isSignedWithPlatformKey()"
Revert "Update for Utils.isSystemPackage()" Revert submission 20385585-isSystemPackage Reason for revert: DroidMonitor: Potential culprit for Bug 259576639 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted. Reverted Changes: Id80c40a30:Update for Utils.isSystemPackage() I8af59268c:Use ApplicationInfo.isSignedWithPlatformKey() Change-Id: I7f0325c1cece43f0203a58c57abd1c9832c7c409
This commit is contained in:
committed by
Android (Google) Code Review
parent
474f20ba0b
commit
ea48129aef
@@ -10,6 +10,8 @@ import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.Signature;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
@@ -60,6 +62,7 @@ public class Utils {
|
||||
static final String STORAGE_MANAGER_ENABLED_PROPERTY =
|
||||
"ro.storage_manager.enabled";
|
||||
|
||||
private static Signature[] sSystemSignature;
|
||||
private static String sPermissionControllerPackageName;
|
||||
private static String sServicesSystemSharedLibPackageName;
|
||||
private static String sSharedSystemSharedLibPackageName;
|
||||
@@ -370,22 +373,14 @@ public class Utils {
|
||||
return new ColorMatrixColorFilter(getAlphaInvariantColorMatrixForColor(color));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #isSystemPackage(Resources, PackageManager, ApplicationInfo)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isSystemPackage(Resources resources, PackageManager pm, PackageInfo pkg) {
|
||||
return pkg.applicationInfo != null && isSystemPackage(resources, pm, pkg.applicationInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether a package is a "system package", in which case certain things (like
|
||||
* disabling notifications or disabling the package altogether) should be disallowed.
|
||||
*
|
||||
* Note: This function is just for UI treatment, and should not be used for security purposes.
|
||||
*/
|
||||
public static boolean isSystemPackage(
|
||||
Resources resources, PackageManager pm, @NonNull ApplicationInfo app) {
|
||||
public static boolean isSystemPackage(Resources resources, PackageManager pm, PackageInfo pkg) {
|
||||
if (sSystemSignature == null) {
|
||||
sSystemSignature = new Signature[]{getSystemSignature(pm)};
|
||||
}
|
||||
if (sPermissionControllerPackageName == null) {
|
||||
sPermissionControllerPackageName = pm.getPermissionControllerPackageName();
|
||||
}
|
||||
@@ -395,12 +390,29 @@ public class Utils {
|
||||
if (sSharedSystemSharedLibPackageName == null) {
|
||||
sSharedSystemSharedLibPackageName = pm.getSharedSystemSharedLibraryPackageName();
|
||||
}
|
||||
return app.isSignedWithPlatformKey()
|
||||
|| app.packageName.equals(sPermissionControllerPackageName)
|
||||
|| app.packageName.equals(sServicesSystemSharedLibPackageName)
|
||||
|| app.packageName.equals(sSharedSystemSharedLibPackageName)
|
||||
|| app.packageName.equals(PrintManager.PRINT_SPOOLER_PACKAGE_NAME)
|
||||
|| isDeviceProvisioningPackage(resources, app.packageName);
|
||||
return (sSystemSignature[0] != null
|
||||
&& sSystemSignature[0].equals(getFirstSignature(pkg)))
|
||||
|| pkg.packageName.equals(sPermissionControllerPackageName)
|
||||
|| pkg.packageName.equals(sServicesSystemSharedLibPackageName)
|
||||
|| pkg.packageName.equals(sSharedSystemSharedLibPackageName)
|
||||
|| pkg.packageName.equals(PrintManager.PRINT_SPOOLER_PACKAGE_NAME)
|
||||
|| isDeviceProvisioningPackage(resources, pkg.packageName);
|
||||
}
|
||||
|
||||
private static Signature getFirstSignature(PackageInfo pkg) {
|
||||
if (pkg != null && pkg.signatures != null && pkg.signatures.length > 0) {
|
||||
return pkg.signatures[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Signature getSystemSignature(PackageManager pm) {
|
||||
try {
|
||||
final PackageInfo sys = pm.getPackageInfo("android", PackageManager.GET_SIGNATURES);
|
||||
return getFirstSignature(sys);
|
||||
} catch (NameNotFoundException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user