Merge "Correct Shutdown Behaviour in Suspend sequence" into main
diff --git a/service/src/com/android/car/power/CarPowerManagementService.java b/service/src/com/android/car/power/CarPowerManagementService.java
index 7ab0dc1..aa557c6 100644
--- a/service/src/com/android/car/power/CarPowerManagementService.java
+++ b/service/src/com/android/car/power/CarPowerManagementService.java
@@ -2772,6 +2772,7 @@
         long retryIntervalMs = INITIAL_SUSPEND_RETRY_INTERVAL_MS;
         long totalWaitDurationMs = 0;
         while (true) {
+            long suspendStartTime = SystemClock.elapsedRealtime();
             Slogf.i(TAG, "Entering %s", suspendTarget);
             if (isSuspendToDisk) {
                 freeMemory();
@@ -2797,7 +2798,7 @@
                         return false;
                     }
                 }
-
+                long suspendStopTime = SystemClock.elapsedRealtime();
                 Slogf.w(TAG, "Failed to Suspend; will retry after %dms", retryIntervalMs);
                 try {
                     mLock.wait(retryIntervalMs);
@@ -2805,6 +2806,7 @@
                     Thread.currentThread().interrupt();
                 }
                 totalWaitDurationMs += retryIntervalMs;
+                totalWaitDurationMs += (suspendStopTime - suspendStartTime);
                 retryIntervalMs = Math.min(retryIntervalMs * 2, MAX_RETRY_INTERVAL_MS);
             }
         }