Add test case for location is not available
Bug: 366332766
Flag: com.android.internal.telephony.flags.oem_enabled_satellite_flag
Test: atest SatelliteAccessControllerTest
Test: Manually verified cases below (b/366332766#comment4)
- location query is unavailable and cache(true) is valid - allowed
- location query is unavailable and cache(false) is valid - not allowed
- location query is unavailable and cache is invalid - not allowed
Change-Id: I7f376a5db55f13c105cf31e3c3e69db6e3c0c003
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index 08b041b..04bb952 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -3732,6 +3732,10 @@
state = "cache_allowed";
break;
}
+ case "-na": {
+ state = "cache_not_allowed";
+ break;
+ }
case "-n": {
state = "cache_clear_and_not_allowed";
break;
diff --git a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
index 7b244a1..f9bf0e8 100644
--- a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
+++ b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
@@ -259,9 +259,9 @@
*/
private final ConcurrentHashMap<IBinder, ISatelliteCommunicationAllowedStateCallback>
mSatelliteCommunicationAllowedStateChangedListeners = new ConcurrentHashMap<>();
- private final Object mSatelliteCommunicationAllowStateLock = new Object();
+ protected final Object mSatelliteCommunicationAllowStateLock = new Object();
@GuardedBy("mSatelliteCommunicationAllowStateLock")
- private boolean mCurrentSatelliteAllowedState = false;
+ protected boolean mCurrentSatelliteAllowedState = false;
protected static final long ALLOWED_STATE_CACHE_VALID_DURATION_NANOS =
TimeUnit.HOURS.toNanos(4);
@@ -1920,6 +1920,10 @@
mLatestSatelliteCommunicationAllowedSetTime = getElapsedRealtimeNanos();
mLatestSatelliteCommunicationAllowed = true;
mCurrentSatelliteAllowedState = true;
+ } else if ("cache_not_allowed".equalsIgnoreCase(state)) {
+ mLatestSatelliteCommunicationAllowedSetTime = getElapsedRealtimeNanos();
+ mLatestSatelliteCommunicationAllowed = false;
+ mCurrentSatelliteAllowedState = false;
} else if ("cache_clear_and_not_allowed".equalsIgnoreCase(state)) {
mLatestSatelliteCommunicationAllowedSetTime = 0;
mLatestSatelliteCommunicationAllowed = false;