Merge "Set a cap while package manager is dumping the critical info"

This commit is contained in:
TreeHugger Robot
2020-10-29 07:55:17 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 6 deletions

View File

@@ -12305,9 +12305,8 @@ public class PackageManagerService extends IPackageManager.Stub
// user-installed version of the application will be ignored.
if ((scanFlags & SCAN_REQUIRE_KNOWN) != 0) {
if (mExpectingBetter.containsKey(pkg.getPackageName())) {
logCriticalInfo(Log.WARN,
"Relax SCAN_REQUIRE_KNOWN requirement for package "
+ pkg.getPackageName());
Slog.w(TAG, "Relax SCAN_REQUIRE_KNOWN requirement for package "
+ pkg.getPackageName());
} else {
PackageSetting known = mSettings.getPackageLPr(pkg.getPackageName());
if (known != null) {

View File

@@ -103,7 +103,8 @@ import java.util.zip.GZIPInputStream;
* {@hide}
*/
public class PackageManagerServiceUtils {
private final static long SEVEN_DAYS_IN_MILLISECONDS = 7 * 24 * 60 * 60 * 1000;
private static final long SEVEN_DAYS_IN_MILLISECONDS = 7 * 24 * 60 * 60 * 1000;
private static final long MAX_CRITICAL_INFO_DUMP_SIZE = 3 * 1000 * 1000; // 3MB
public final static Predicate<PackageSetting> REMOVE_IF_NULL_PKG =
pkgSetting -> pkgSetting.pkg == null;
@@ -349,7 +350,12 @@ public class PackageManagerServiceUtils {
}
public static void dumpCriticalInfo(ProtoOutputStream proto) {
try (BufferedReader in = new BufferedReader(new FileReader(getSettingsProblemFile()))) {
final File file = getSettingsProblemFile();
final long skipSize = file.length() - MAX_CRITICAL_INFO_DUMP_SIZE;
try (BufferedReader in = new BufferedReader(new FileReader(file))) {
if (skipSize > 0) {
in.skip(skipSize);
}
String line = null;
while ((line = in.readLine()) != null) {
if (line.contains("ignored: updated version")) continue;
@@ -360,7 +366,12 @@ public class PackageManagerServiceUtils {
}
public static void dumpCriticalInfo(PrintWriter pw, String msg) {
try (BufferedReader in = new BufferedReader(new FileReader(getSettingsProblemFile()))) {
final File file = getSettingsProblemFile();
final long skipSize = file.length() - MAX_CRITICAL_INFO_DUMP_SIZE;
try (BufferedReader in = new BufferedReader(new FileReader(file))) {
if (skipSize > 0) {
in.skip(skipSize);
}
String line = null;
while ((line = in.readLine()) != null) {
if (line.contains("ignored: updated version")) continue;