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

Commit acd97414 authored by Adam Bookatz's avatar Adam Bookatz
Browse files

Make SSM failure logging more consistent

The purpose of this is to help ensure the failure log will be consistent
if a system service fails. This can be used in parsing logcat for tests
(which isn't a great way to test, but it'll do for now).

Test: atest CreateUsersNoAppCrashesTest
Bug: 217246676
Change-Id: I422a380e1da63c4f42687212ac19171819f37ae2
parent 79d91e3e
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -509,8 +509,7 @@ public final class SystemServiceManager implements Dumpable {
                        throw new IllegalArgumentException(onWhat + " what?");
                }
            } catch (Exception ex) {
                Slog.wtf(TAG, "Failure reporting " + onWhat + " of user " + curUser
                        + " to service " + serviceName, ex);
                logFailure(onWhat, curUser, serviceName, ex);
            }
            if (!submitToThreadPool) {
                warnIfTooLong(SystemClock.elapsedRealtime() - time, service,
@@ -584,8 +583,7 @@ public final class SystemServiceManager implements Dumpable {
                warnIfTooLong(SystemClock.elapsedRealtime() - time, service,
                        "on" + USER_STARTING + "User-" + curUserId);
            } catch (Exception e) {
                Slog.wtf(TAG, "Failure reporting " + USER_STARTING + " of user " + curUser
                        + " to service " + serviceName, e);
                logFailure(USER_STARTING, curUser, serviceName, e);
                Slog.e(TAG, "Disabling thread pool - please capture a bug report.");
                sUseLifecycleThreadPool = false;
            } finally {
@@ -608,8 +606,7 @@ public final class SystemServiceManager implements Dumpable {
                warnIfTooLong(SystemClock.elapsedRealtime() - time, service,
                        "on" + USER_COMPLETED_EVENT + "User-" + curUserId);
            } catch (Exception e) {
                Slog.wtf(TAG, "Failure reporting " + USER_COMPLETED_EVENT + " of user " + curUser
                        + " to service " + serviceName, e);
                logFailure(USER_COMPLETED_EVENT, curUser, serviceName, e);
                throw e;
            } finally {
                t.traceEnd();
@@ -617,6 +614,12 @@ public final class SystemServiceManager implements Dumpable {
        };
    }

    /** Logs the failure. That's all. Tests may rely on parsing it, so only modify carefully. */
    private void logFailure(String onWhat, TargetUser curUser, String serviceName, Exception ex) {
        Slog.wtf(TAG, "SystemService failure: Failure reporting " + onWhat + " of user "
                + curUser + " to service " + serviceName, ex);
    }

    /** Sets the safe mode flag for services to query. */
    void setSafeMode(boolean safeMode) {
        mSafeMode = safeMode;