Merge "Update Satellite Test App UI to work better on small screens such a Wear devices" into main
diff --git a/res/values-fr-rCA/strings.xml b/res/values-fr-rCA/strings.xml
index b62728f..ff32473 100644
--- a/res/values-fr-rCA/strings.xml
+++ b/res/values-fr-rCA/strings.xml
@@ -582,7 +582,7 @@
<string name="description_concat_format" msgid="2014471565101724088">"%1$s, %2$s"</string>
<string name="dialerKeyboardHintText" msgid="1115266533703764049">"Utilisez le clavier pour composer un numéro."</string>
<string name="onscreenHoldText" msgid="4025348842151665191">"Attente"</string>
- <string name="onscreenEndCallText" msgid="6138725377654842757">"Terminé"</string>
+ <string name="onscreenEndCallText" msgid="6138725377654842757">"Terminer"</string>
<string name="onscreenShowDialpadText" msgid="658465753816164079">"Clavier numérique"</string>
<string name="onscreenMuteText" msgid="5470306116733843621">"Couper le son"</string>
<string name="onscreenAddCallText" msgid="9075675082903611677">"Autre appel"</string>
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index f20960c..22a69bb 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -582,7 +582,7 @@
<string name="description_concat_format" msgid="2014471565101724088">"%1$s, %2$s"</string>
<string name="dialerKeyboardHintText" msgid="1115266533703764049">"Utilisez le clavier pour composer un numéro."</string>
<string name="onscreenHoldText" msgid="4025348842151665191">"En attente"</string>
- <string name="onscreenEndCallText" msgid="6138725377654842757">"Raccrocher"</string>
+ <string name="onscreenEndCallText" msgid="6138725377654842757">"Terminer"</string>
<string name="onscreenShowDialpadText" msgid="658465753816164079">"Clavier"</string>
<string name="onscreenMuteText" msgid="5470306116733843621">"Silencieux"</string>
<string name="onscreenAddCallText" msgid="9075675082903611677">"Autre appel"</string>
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index bfc93e0..e92e4c4 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -3739,6 +3739,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;
diff --git a/src/com/android/services/telephony/domainselection/NormalCallDomainSelector.java b/src/com/android/services/telephony/domainselection/NormalCallDomainSelector.java
index 37813e3..a7ed708 100644
--- a/src/com/android/services/telephony/domainselection/NormalCallDomainSelector.java
+++ b/src/com/android/services/telephony/domainselection/NormalCallDomainSelector.java
@@ -140,7 +140,10 @@
if (subId == getSubId()) {
logd("NormalCallDomainSelection triggered. Sub-id:" + subId);
- sendEmptyMessageDelayed(MSG_WAIT_FOR_IMS_STATE_TIMEOUT, WAIT_FOR_IMS_STATE_TIMEOUT_MS);
+ if (!mReselectDomain) {
+ sendEmptyMessageDelayed(MSG_WAIT_FOR_IMS_STATE_TIMEOUT,
+ WAIT_FOR_IMS_STATE_TIMEOUT_MS);
+ }
post(() -> selectDomain());
} else {
mSelectorState = SelectorState.INACTIVE;
diff --git a/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java b/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
index 55f72fc..3d2c953 100644
--- a/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
+++ b/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
@@ -34,6 +34,7 @@
import static com.android.phone.satellite.accesscontrol.SatelliteAccessController.DEFAULT_DELAY_MINUTES_BEFORE_VALIDATING_POSSIBLE_CHANGE_IN_ALLOWED_REGION;
import static com.android.phone.satellite.accesscontrol.SatelliteAccessController.DEFAULT_THROTTLE_INTERVAL_FOR_LOCATION_QUERY_MINUTES;
import static com.android.phone.satellite.accesscontrol.SatelliteAccessController.EVENT_CONFIG_DATA_UPDATED;
+import static com.android.phone.satellite.accesscontrol.SatelliteAccessController.EVENT_WAIT_FOR_CURRENT_LOCATION_TIMEOUT;
import static com.android.phone.satellite.accesscontrol.SatelliteAccessController.GOOGLE_US_SAN_SAT_S2_FILE_NAME;
import static com.android.phone.satellite.accesscontrol.SatelliteAccessController.DEFAULT_MAX_RETRY_COUNT_FOR_VALIDATING_POSSIBLE_CHANGE_IN_ALLOWED_REGION;
@@ -369,6 +370,49 @@
}
@Test
+ public void testOnCurrentLocationNotAvailable() throws Exception {
+ // Verify the cache is used when the location is null and the cache is valid and true.
+ mSatelliteAccessControllerUT.elapsedRealtimeNanos =
+ ALLOWED_STATE_CACHE_VALID_DURATION_NANOS - 1;
+ mSatelliteAccessControllerUT
+ .setIsSatelliteCommunicationAllowedForCurrentLocationCache("cache_allowed");
+ mSatelliteAccessControllerUT.setLocationRequestCancellationSignalAsNull(false);
+
+ sendCurrentLocationTimeoutEvent();
+ assertTrue(mSatelliteAccessControllerUT.isCurrentSatelliteAllowedState());
+
+ // Verify the cache is used when the location is null and the cache is valid and false.
+ mSatelliteAccessControllerUT
+ .setIsSatelliteCommunicationAllowedForCurrentLocationCache("cache_not_allowed");
+ mSatelliteAccessControllerUT.setLocationRequestCancellationSignalAsNull(false);
+
+ sendCurrentLocationTimeoutEvent();
+ assertFalse(mSatelliteAccessControllerUT.isCurrentSatelliteAllowedState());
+
+ // Verify the result code is SATELLITE_RESULT_LOCATION_NOT_AVAILABLE
+ // and allowedState is false when the location is null and the cache is expired
+ mSatelliteAccessControllerUT.elapsedRealtimeNanos =
+ ALLOWED_STATE_CACHE_VALID_DURATION_NANOS + 1;
+ Iterator<ResultReceiver> mockIterator = mock(Iterator.class);
+ doReturn(mockIterator).when(mMockSatelliteAllowResultReceivers).iterator();
+ doReturn(true, false).when(mockIterator).hasNext();
+ doNothing().when(mMockSatelliteAllowResultReceivers).clear();
+ doReturn(mMockSatelliteSupportedResultReceiver).when(mockIterator).next();
+ replaceInstance(SatelliteAccessController.class, "mSatelliteAllowResultReceivers",
+ mSatelliteAccessControllerUT, mMockSatelliteAllowResultReceivers);
+ mSatelliteAccessControllerUT.setIsSatelliteCommunicationAllowedForCurrentLocationCache(
+ "cache_clear_and_not_allowed");
+ mSatelliteAccessControllerUT.setLocationRequestCancellationSignalAsNull(false);
+
+ sendCurrentLocationTimeoutEvent();
+ verify(mMockSatelliteSupportedResultReceiver)
+ .send(mResultCodeIntCaptor.capture(), any());
+ assertEquals(Integer.valueOf(SATELLITE_RESULT_LOCATION_NOT_AVAILABLE),
+ mResultCodeIntCaptor.getValue());
+ assertFalse(mSatelliteAccessControllerUT.isCurrentSatelliteAllowedState());
+ }
+
+ @Test
public void testIsSatelliteAccessAllowedForLocation() {
when(mMockFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(true);
@@ -1056,7 +1100,7 @@
// In emergency case,
// verify if the location manager get FUSED provider and ignore location settings
doReturn(true).when(mMockTelecomManager).isInEmergencyCall();
- mSatelliteAccessControllerUT.setLocationRequestCancellationSignalAsNull();
+ mSatelliteAccessControllerUT.setLocationRequestCancellationSignalAsNull(true);
mSatelliteAccessControllerUT.elapsedRealtimeNanos = TEST_LOCATION_FRESH_DURATION_NANOS + 1;
mSatelliteAccessControllerUT.checkSatelliteAccessRestrictionUsingGPS();
@@ -1074,7 +1118,7 @@
doReturn(false).when(mMockPhone2).isInEcm();
doReturn(false).when(mMockSatelliteController).isInEmergencyMode();
doReturn(true).when(mMockLocationManager).isLocationEnabled();
- mSatelliteAccessControllerUT.setLocationRequestCancellationSignalAsNull();
+ mSatelliteAccessControllerUT.setLocationRequestCancellationSignalAsNull(true);
mSatelliteAccessControllerUT.checkSatelliteAccessRestrictionUsingGPS();
verify(mMockLocationManager, times(1))
@@ -1173,7 +1217,7 @@
doReturn(false).when(mMockPhone2).isInEcm();
doReturn(false).when(mMockSatelliteController).isInEmergencyMode();
doReturn(true).when(mMockLocationManager).isLocationEnabled();
- mSatelliteAccessControllerUT.setLocationRequestCancellationSignalAsNull();
+ mSatelliteAccessControllerUT.setLocationRequestCancellationSignalAsNull(true);
mSatelliteAccessControllerUT.elapsedRealtimeNanos = TEST_LOCATION_FRESH_DURATION_NANOS + 1;
// Invoking requestIsCommunicationAllowedForCurrentLocation(resultReceiver, "false");
@@ -1217,6 +1261,13 @@
mTestableLooper.processAllMessages();
}
+ private void sendCurrentLocationTimeoutEvent() {
+ Message msg = mSatelliteAccessControllerUT
+ .obtainMessage(EVENT_WAIT_FOR_CURRENT_LOCATION_TIMEOUT);
+ msg.sendToTarget();
+ mTestableLooper.processAllMessages();
+ }
+
private void sendCommandValidateCountryCodeChangeEvent(Context context) {
Message msg = mSatelliteAccessControllerUT.obtainMessage(EVENT_COUNTRY_CODE_CHANGED);
msg.obj = new AsyncResult(context, SATELLITE_RESULT_SUCCESS, null);
@@ -1382,9 +1433,15 @@
return mLocationModeChangedBroadcastReceiver;
}
- public void setLocationRequestCancellationSignalAsNull() {
+ public void setLocationRequestCancellationSignalAsNull(boolean isNull) {
synchronized (mLock) {
- mLocationRequestCancellationSignal = null;
+ mLocationRequestCancellationSignal = isNull ? null : new CancellationSignal();
+ }
+ }
+
+ public boolean isCurrentSatelliteAllowedState() {
+ synchronized (mSatelliteCommunicationAllowStateLock) {
+ return mCurrentSatelliteAllowedState;
}
}
}
diff --git a/tests/src/com/android/services/telephony/domainselection/NormalCallDomainSelectorTest.java b/tests/src/com/android/services/telephony/domainselection/NormalCallDomainSelectorTest.java
index 49411bd..7acc7d6 100644
--- a/tests/src/com/android/services/telephony/domainselection/NormalCallDomainSelectorTest.java
+++ b/tests/src/com/android/services/telephony/domainselection/NormalCallDomainSelectorTest.java
@@ -743,6 +743,27 @@
mNormalCallDomainSelector.getSelectorState());
}
+ @Test
+ public void testReselectDomainNoTimeoutMessage() {
+ final TestTransportSelectorCallback transportSelectorCallback =
+ new TestTransportSelectorCallback(mNormalCallDomainSelector);
+
+ DomainSelectionService.SelectionAttributes attributes =
+ new DomainSelectionService.SelectionAttributes.Builder(
+ SLOT_ID, SUB_ID_1, SELECTOR_TYPE_CALLING)
+ .setAddress(TEST_URI)
+ .setCallId(TEST_CALLID)
+ .setEmergency(false)
+ .setVideoCall(false)
+ .setExitedFromAirplaneMode(false)
+ .build();
+
+ mNormalCallDomainSelector.selectDomain(null, transportSelectorCallback);
+ mNormalCallDomainSelector.reselectDomain(attributes);
+ assertFalse(mNormalCallDomainSelector.hasMessages(
+ NormalCallDomainSelector.MSG_WAIT_FOR_IMS_STATE_TIMEOUT));
+ }
+
static class TestTransportSelectorCallback implements TransportSelectorCallback,
WwanSelectorCallback {
public boolean mCreated;