Adjust "services.core" defaults for Error Prone.

It ends up that "services.core" itself doesn't catch Error Prone
issues, since it works with JAR output from a previous stage.  To
resolve this, we need to move up to "services.core.unboosted" where
the source code is still available.

Fix one instance of AndroidFrameworkCompatChange that had leaked
into the source tree recently.  Disable other checks since there
are hundreds of failures inside the actual "services.core" code.

Bug: 155703208
Test: manual
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: I13f15db61bbcf5f74023147a95551b541d0a8845
This commit is contained in:
Jeff Sharkey
2020-11-17 12:26:48 -07:00
parent f474b7835f
commit 8fa2407ad2
4 changed files with 22 additions and 15 deletions

View File

@@ -22,9 +22,9 @@ java_defaults {
],
errorprone: {
javacflags: [
"-Xep:AndroidFrameworkBinderIdentity:ERROR",
// "-Xep:AndroidFrameworkBinderIdentity:ERROR",
"-Xep:AndroidFrameworkCompatChange:ERROR",
"-Xep:AndroidFrameworkUid:ERROR",
// "-Xep:AndroidFrameworkUid:ERROR",
// NOTE: only enable to generate local patchfiles
// "-XepPatchChecks:refaster:frameworks/base/errorprone/refaster/EfficientXml.java.refaster",
// "-XepPatchLocation:/tmp/refaster/",
@@ -44,6 +44,7 @@ java_defaults {
"-Xep:AndroidFrameworkEfficientCollections:OFF",
"-Xep:AndroidFrameworkEfficientParcelable:OFF",
"-Xep:AndroidFrameworkEfficientStrings:OFF",
"-Xep:AndroidFrameworkEfficientXml:OFF",
],
},
}

View File

@@ -61,6 +61,7 @@ genrule {
java_library_static {
name: "services.core.unboosted",
defaults: ["platform_service_defaults"],
srcs: [
":services.core.protologsrc",
":dumpstate_aidl",
@@ -146,7 +147,6 @@ java_genrule {
java_library {
name: "services.core",
defaults: ["platform_service_defaults"],
static_libs: ["services.core.priorityboosted"],
}

View File

@@ -1630,6 +1630,8 @@ public final class ActiveServices {
}
}
// TODO: remove as part of fixing b/173627642
@SuppressWarnings("AndroidFrameworkCompatChange")
private void postFgsNotificationLocked(ServiceRecord r) {
boolean showNow = !mAm.mConstants.mFlagFgsNotificationDeferralEnabled;
if (!showNow) {

View File

@@ -17718,6 +17718,17 @@ public class PackageManagerService extends IPackageManager.Stub
}
}
/*
* Cannot properly check CANNOT_INSTALL_WITH_BAD_PERMISSION_GROUPS using CompatChanges
* as this only works for packages that are installed
*
* TODO: Move logic for permission group compatibility into PermissionManagerService
*/
@SuppressWarnings("AndroidFrameworkCompatChange")
private static boolean cannotInstallWithBadPermissionGroups(ParsedPackage parsedPackage) {
return parsedPackage.getTargetSdkVersion() >= Build.VERSION_CODES.S;
}
@GuardedBy("mInstallLock")
private PrepareResult preparePackageLI(InstallArgs args, PackageInstalledInfo res)
throws PrepareFailure {
@@ -17760,7 +17771,7 @@ public class PackageManagerService extends IPackageManager.Stub
| (onExternal ? PackageParser.PARSE_EXTERNAL_STORAGE : 0);
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "parsePackage");
ParsedPackage parsedPackage;
final ParsedPackage parsedPackage;
try (PackageParser2 pp = new PackageParser2(mSeparateProcesses, false, mMetrics, null,
mPackageParserCallback)) {
parsedPackage = pp.parsePackage(tmpPackageFile, parseFlags, false);
@@ -17876,15 +17887,6 @@ public class PackageManagerService extends IPackageManager.Stub
}
}
/*
* Cannot properly check CANNOT_INSTALL_WITH_BAD_PERMISSION_GROUPS using CompatChanges
* as this only works for packages that are installed
*
* TODO: Move logic for permission group compatibility into PermissionManagerService
*/
boolean cannotInstallWithBadPermissionGroups =
parsedPackage.getTargetSdkVersion() >= Build.VERSION_CODES.S;
PackageSetting ps = mSettings.mPackages.get(pkgName);
if (ps != null) {
if (DEBUG_INSTALL) Slog.d(TAG, "Existing package: " + ps);
@@ -17942,7 +17944,8 @@ public class PackageManagerService extends IPackageManager.Stub
parsedPackage.getPermissionGroups().get(groupNum);
final PermissionGroupInfo sourceGroup = getPermissionGroupInfo(group.getName(), 0);
if (sourceGroup != null && cannotInstallWithBadPermissionGroups) {
if (sourceGroup != null
&& cannotInstallWithBadPermissionGroups(parsedPackage)) {
final String sourcePackageName = sourceGroup.packageName;
if ((replace || !parsedPackage.getPackageName().equals(sourcePackageName))
@@ -18017,7 +18020,8 @@ public class PackageManagerService extends IPackageManager.Stub
}
}
if (perm.getGroup() != null && cannotInstallWithBadPermissionGroups) {
if (perm.getGroup() != null
&& cannotInstallWithBadPermissionGroups(parsedPackage)) {
boolean isPermGroupDefinedByPackage = false;
for (int groupNum = 0; groupNum < numGroups; groupNum++) {
if (parsedPackage.getPermissionGroups().get(groupNum).getName()