Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc9caa1a authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Switch RescueParty to PMS.logCriticalInfo().

When RescueParty is triggered, we could end up in recovery before a
bugreport can be taken.  To help understand why RescueParty was
triggered after the fact, this change switches a handful of critical
log messages to use PMS.logCriticalInfo().

These logs then go into our persistent log on disk, which is also
included in all future bugreports.

Bug: 35805331, 36033178
Test: builds, boots, forced crashing recorded in persistent log
Change-Id: Ic71206b25c4b0b703e464ff1d07c5e0b31549257
parent bd5e5e0d
Loading
Loading
Loading
Loading
+16 −4
Original line number Original line Diff line number Diff line
@@ -29,11 +29,13 @@ import android.os.UserManager;
import android.provider.Settings;
import android.provider.Settings;
import android.text.format.DateUtils;
import android.text.format.DateUtils;
import android.util.ExceptionUtils;
import android.util.ExceptionUtils;
import android.util.Log;
import android.util.MathUtils;
import android.util.MathUtils;
import android.util.Slog;
import android.util.Slog;
import android.util.SparseArray;
import android.util.SparseArray;


import com.android.internal.util.ArrayUtils;
import com.android.internal.util.ArrayUtils;
import com.android.server.pm.PackageManagerService;


import java.io.File;
import java.io.File;


@@ -49,6 +51,7 @@ import java.io.File;
public class RescueParty {
public class RescueParty {
    private static final String TAG = "RescueParty";
    private static final String TAG = "RescueParty";


    private static final String PROP_ENABLE_RESCUE = "persist.sys.enable_rescue";
    private static final String PROP_DISABLE_RESCUE = "persist.sys.disable_rescue";
    private static final String PROP_DISABLE_RESCUE = "persist.sys.disable_rescue";
    private static final String PROP_RESCUE_LEVEL = "sys.rescue_level";
    private static final String PROP_RESCUE_LEVEL = "sys.rescue_level";
    private static final String PROP_RESCUE_BOOT_COUNT = "sys.rescue_boot_count";
    private static final String PROP_RESCUE_BOOT_COUNT = "sys.rescue_boot_count";
@@ -66,6 +69,11 @@ public class RescueParty {
    private static SparseArray<Threshold> sApps = new SparseArray<>();
    private static SparseArray<Threshold> sApps = new SparseArray<>();


    private static boolean isDisabled() {
    private static boolean isDisabled() {
        // Check if we're explicitly enabled for testing
        if (SystemProperties.getBoolean(PROP_ENABLE_RESCUE, true)) {
            return false;
        }

        // We're disabled on all engineering devices
        // We're disabled on all engineering devices
        if (Build.IS_ENG) {
        if (Build.IS_ENG) {
            Slog.v(TAG, "Disabled because of eng build");
            Slog.v(TAG, "Disabled because of eng build");
@@ -138,7 +146,8 @@ public class RescueParty {
        SystemProperties.set(PROP_RESCUE_LEVEL, Integer.toString(level));
        SystemProperties.set(PROP_RESCUE_LEVEL, Integer.toString(level));


        EventLogTags.writeRescueLevel(level, triggerUid);
        EventLogTags.writeRescueLevel(level, triggerUid);
        Slog.w(TAG, "Incremented rescue level to " + levelToString(level));
        PackageManagerService.logCriticalInfo(Log.WARN, "Incremented rescue level to "
                + levelToString(level) + " triggered by UID " + triggerUid);
    }
    }


    /**
    /**
@@ -157,10 +166,13 @@ public class RescueParty {
        try {
        try {
            executeRescueLevelInternal(context, level);
            executeRescueLevelInternal(context, level);
            EventLogTags.writeRescueSuccess(level);
            EventLogTags.writeRescueSuccess(level);
            Slog.d(TAG, "Finished rescue level " + levelToString(level));
            PackageManagerService.logCriticalInfo(Log.DEBUG,
                    "Finished rescue level " + levelToString(level));
        } catch (Throwable t) {
        } catch (Throwable t) {
            EventLogTags.writeRescueFailure(level, ExceptionUtils.getCompleteMessage(t));
            final String msg = ExceptionUtils.getCompleteMessage(t);
            Slog.e(TAG, "Failed rescue level " + levelToString(level), t);
            EventLogTags.writeRescueFailure(level, msg);
            PackageManagerService.logCriticalInfo(Log.ERROR,
                    "Failed rescue level " + levelToString(level) + ": " + msg);
        }
        }
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -7649,7 +7649,7 @@ public class PackageManagerService extends IPackageManager.Stub {
        logCriticalInfo(priority, msg);
        logCriticalInfo(priority, msg);
    }
    }
    static void logCriticalInfo(int priority, String msg) {
    public static void logCriticalInfo(int priority, String msg) {
        Slog.println(priority, TAG, msg);
        Slog.println(priority, TAG, msg);
        EventLogTags.writePmCriticalInfo(msg);
        EventLogTags.writePmCriticalInfo(msg);
        try {
        try {