Reduce allowed state cache valid duration to 4 hours
Bug: 352448792
Test: SatelliteAccessControllerTest SatelliteManagerTestOnMockService
Manual tests with Skylo network
Change-Id: Ie5ad3e6e1aeb6d3c94474677b8223aa863c36df8
Merged-In: Ie5ad3e6e1aeb6d3c94474677b8223aa863c36df8
diff --git a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
index 67059cb..6d8e5f7 100644
--- a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
+++ b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
@@ -227,7 +227,8 @@
@GuardedBy("mSatelliteCommunicationAllowStateLock")
private boolean mCurrentSatelliteAllowedState = false;
- private static final long NANOS_IN_12_HOURS = Duration.ofHours(12).toNanos();
+ private static final long ALLOWED_STATE_CACHE_VALID_DURATION_HOURS =
+ Duration.ofHours(4).toNanos();
private boolean mLatestSatelliteCommunicationAllowed;
private long mLatestSatelliteCommunicationAllowedSetTime;
@@ -970,11 +971,15 @@
}
}
- /* returns true if the latest query was executed in 12Hr, or returns false. */
+ /**
+ * @return {@code true} if the latest query was executed within the predefined valid duration,
+ * {@code false} otherwise.
+ */
private boolean isCommunicationAllowedCacheValid() {
if (mLatestSatelliteCommunicationAllowedSetTime > 0) {
long currentTime = SystemClock.elapsedRealtimeNanos();
- if ((currentTime - mLatestSatelliteCommunicationAllowedSetTime) <= NANOS_IN_12_HOURS) {
+ if ((currentTime - mLatestSatelliteCommunicationAllowedSetTime)
+ <= ALLOWED_STATE_CACHE_VALID_DURATION_HOURS) {
logv("isCommunicationAllowedCacheValid: cache is valid");
return true;
}
@@ -1079,7 +1084,7 @@
} else {
plogd("current location is not available");
if (isCommunicationAllowedCacheValid()) {
- plogd("onCurrentLocationAvailable: 12Hr cache is still valid, using it");
+ plogd("onCurrentLocationAvailable: cache is still valid, using it");
bundle.putBoolean(KEY_SATELLITE_COMMUNICATION_ALLOWED,
mLatestSatelliteCommunicationAllowed);
sendSatelliteAllowResultToReceivers(SATELLITE_RESULT_SUCCESS, bundle,
@@ -1131,7 +1136,7 @@
if (isCommunicationAllowedCacheValid()) {
bundle.putBoolean(KEY_SATELLITE_COMMUNICATION_ALLOWED,
mLatestSatelliteCommunicationAllowed);
- plogd("checkSatelliteAccessRestrictionForLocation: 24Hr cache is still valid, "
+ plogd("checkSatelliteAccessRestrictionForLocation: cache is still valid, "
+ "using it");
} else {
bundle.putBoolean(KEY_SATELLITE_COMMUNICATION_ALLOWED, false);