Fix testTtffWithNetwork timeout issue
There is no NLP in GSI project, but case testTtffWithNetwork still wait 2 minutes
for network location. This flow will run twice so waste 4 minutes of waiting time,
it's easy to cause case 5 minutes timeout failure.
Do not waiting for network location result if there is no NLP.
Bug: 225083104
Test: CtsLocationGnssTestCase
Change-Id: I2f13579bd79dea7ed83ce9cff7627094887633fb
(cherry picked from commit 05caa14e3df938a3afd147c698b851b866a91c9c)
diff --git a/tests/location/common/src/android/location/cts/common/TestLocationManager.java b/tests/location/common/src/android/location/cts/common/TestLocationManager.java
index 581a107..69a92b7 100644
--- a/tests/location/common/src/android/location/cts/common/TestLocationManager.java
+++ b/tests/location/common/src/android/location/cts/common/TestLocationManager.java
@@ -186,8 +186,9 @@
* See {@code LocationManager#requestNetworkLocationUpdates}.
*
* @param locationListener location listener for request
+ * @return {@code true} if the network provider is valid, {@code false} otherwise.
*/
- public void requestNetworkLocationUpdates(LocationListener locationListener) {
+ public boolean requestNetworkLocationUpdates(LocationListener locationListener) {
if (mLocationManager.getProvider(LocationManager.NETWORK_PROVIDER) != null) {
Log.i(TAG, "Request Network Location updates.");
mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
@@ -195,7 +196,9 @@
0 /* minDistance */,
locationListener,
Looper.getMainLooper());
+ return true;
}
+ return false;
}
/**
diff --git a/tests/location/location_gnss/src/android/location/cts/gnss/GnssTtffTests.java b/tests/location/location_gnss/src/android/location/cts/gnss/GnssTtffTests.java
index c869fee..2c6be79 100644
--- a/tests/location/location_gnss/src/android/location/cts/gnss/GnssTtffTests.java
+++ b/tests/location/location_gnss/src/android/location/cts/gnss/GnssTtffTests.java
@@ -129,8 +129,9 @@
TestLocationListener networkLocationListener
= new TestLocationListener(LOCATION_TO_COLLECT_COUNT);
// fetch the networklocation first to make sure the ttff is not flaky
- mTestLocationManager.requestNetworkLocationUpdates(networkLocationListener);
- networkLocationListener.await();
+ if (mTestLocationManager.requestNetworkLocationUpdates(networkLocationListener)) {
+ networkLocationListener.await();
+ }
TestGnssStatusCallback testGnssStatusCallback =
new TestGnssStatusCallback(TAG, STATUS_TO_COLLECT_COUNT);