Load max shutdown processing from resource
- add maxGarageModeRunningDurationInSecs: Most shutdown processing time
is time for garage mode.
- This should be equal or greater than 15 min (=900 secs). Smaller value will
be ignored and 15 mins will be used instead.
- This allows entering into STR without forcing android to shutdown.
Bug: 128888292
Test: Enter STR and check timeout.
Change-Id: Id0e18128f2dd51c796da4fa73a12dab94c126b34
diff --git a/service/res/values/config.xml b/service/res/values/config.xml
index 200c4c3..1d3fd1b 100644
--- a/service/res/values/config.xml
+++ b/service/res/values/config.xml
@@ -129,6 +129,10 @@
device specific model id. -->
<integer name="fastPairModelId">0x000000</integer>
+ <!-- Maximum allowed time to run garage mode. Note that 15 min (=900sec) is the minimum required
+ duration and this should not be made shorter. -->
+ <integer name="maxGarageModeRunningDurationInSecs">900</integer>
+
<!-- The garage mode configuration, specifying the time after shutdown to reboot into garage
mode and the number of attempts at that time to try before moving to the next wake up
time. This is intended to be a back-off pattern. -->
diff --git a/service/src/com/android/car/CarPowerManagementService.java b/service/src/com/android/car/CarPowerManagementService.java
index 8cf7c46..49e54eb 100644
--- a/service/src/com/android/car/CarPowerManagementService.java
+++ b/service/src/com/android/car/CarPowerManagementService.java
@@ -85,8 +85,10 @@
private static final int SHUTDOWN_POLLING_INTERVAL_MS = 2000;
private static final int SHUTDOWN_EXTEND_MAX_MS = 5000;
- // Use one hour for now
- private static int sShutdownPrepareTimeMs = 60 * 60 * 1000;
+ // maxGarageModeRunningDurationInSecs should be equal or greater than this. 15 min for now.
+ private static final int MIN_MAX_GARAGE_MODE_DURATION_MS = 15 * 60 * 1000;
+
+ private static int sShutdownPrepareTimeMs = MIN_MAX_GARAGE_MODE_DURATION_MS;
private class PowerManagerCallbackList extends RemoteCallbackList<ICarPowerStateListener> {
/**
@@ -107,6 +109,15 @@
mHal = powerHal;
mSystemInterface = systemInterface;
mCarUserManagerHelper = carUserManagerHelper;
+ sShutdownPrepareTimeMs = mContext.getResources().getInteger(
+ R.integer.maxGarageModeRunningDurationInSecs) * 1000;
+ if (sShutdownPrepareTimeMs < MIN_MAX_GARAGE_MODE_DURATION_MS) {
+ Log.w(CarLog.TAG_POWER,
+ "maxGarageModeRunningDurationInSecs smaller than minimum required, resource:"
+ + sShutdownPrepareTimeMs + "(ms) while should exceed:"
+ + MIN_MAX_GARAGE_MODE_DURATION_MS + "(ms), Ignore resource.");
+ sShutdownPrepareTimeMs = MIN_MAX_GARAGE_MODE_DURATION_MS;
+ }
}
/**
@@ -181,7 +192,8 @@
writer.print(",mLastSleepEntryTime:" + mLastSleepEntryTime);
writer.print(",mNextWakeupSec:" + mNextWakeupSec);
writer.print(",mTokenValue:" + mTokenValue);
- writer.println(",mShutdownOnFinish:" + mShutdownOnFinish);
+ writer.print(",mShutdownOnFinish:" + mShutdownOnFinish);
+ writer.println(",sShutdownPrepareTimeMs:" + sShutdownPrepareTimeMs);
}
@Override