From 7e8b5a3ee49511e58449e4dd45aa07297650bb65 Mon Sep 17 00:00:00 2001 From: Gavin Corkery Date: Mon, 20 Apr 2020 09:49:18 +0100 Subject: [PATCH] Store native failure reason in session failure message If a native process crashing during boot causes a session to revert, store the name of this process in the failure message of a staged session. This will allow the native process to be exposed in the PackageManager dumpsys for debugging purposes. Test: atest ApexRollbackTests#testAutomaticBootLoopRecovery, adb shell dumpsys package Bug: 149100937 Change-Id: I4a6140d4a72558834baf2ea0d5d215bb402f989d --- .../java/com/android/server/pm/StagingManager.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/pm/StagingManager.java b/services/core/java/com/android/server/pm/StagingManager.java index 60292b45c0eeb..19fbaf4ad78e9 100644 --- a/services/core/java/com/android/server/pm/StagingManager.java +++ b/services/core/java/com/android/server/pm/StagingManager.java @@ -511,8 +511,12 @@ public class StagingManager { // TODO(b/146343545): Persist failure reason across checkpoint reboot Slog.d(TAG, "Reverting back to safe state. Marking " + session.sessionId + " as failed."); - session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_UNKNOWN, - "Reverting back to safe state"); + String errorMsg = "Reverting back to safe state"; + if (!TextUtils.isEmpty(mNativeFailureReason)) { + errorMsg = "Entered fs-rollback mode and reverted session due to crashing " + + "native process: " + mNativeFailureReason; + } + session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_UNKNOWN, errorMsg); return; } } catch (RemoteException e) { @@ -541,6 +545,10 @@ public class StagingManager { if (isApexSessionFailed(apexSessionInfo)) { String errorMsg = "APEX activation failed. Check logcat messages from apexd for " + "more information."; + if (!TextUtils.isEmpty(mNativeFailureReason)) { + errorMsg = "Session reverted due to crashing native process: " + + mNativeFailureReason; + } session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED, errorMsg); abortCheckpoint(errorMsg);