From e9aea9d397d42bcf73dee1234836b56cb626b709 Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Thu, 9 Feb 2017 18:16:58 -0800 Subject: [PATCH 1/2] [CM] Remove non-functional timeout from request network Until now the request network with timeout was non-functional (see b/31402633). Any caller which was using the timeout getting the request network without a timeout. While the timeout version has now been implemented, a max timeout value is being removed since the large number used (100 minutes) had no rationale for existing. Updating the code to reflect the functionality which was actually used - without a timeout. Bug: 31399536 Bug: 35354391 Test: unit tests and CTS of ConnectivityManager Change-Id: I0ebf0917a4478036a5ae532dd1e0784479057eb8 --- .../android/server/location/GnssLocationProvider.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/location/GnssLocationProvider.java b/services/core/java/com/android/server/location/GnssLocationProvider.java index ae98077c7c2c2..e2e834d2d4a5b 100644 --- a/services/core/java/com/android/server/location/GnssLocationProvider.java +++ b/services/core/java/com/android/server/location/GnssLocationProvider.java @@ -477,12 +477,6 @@ public class GnssLocationProvider implements LocationProviderInterface { public void onLost(Network network) { releaseSuplConnection(GPS_RELEASE_AGPS_DATA_CONN); } - - @Override - public void onUnavailable() { - // timeout, it was not possible to establish the required connection - releaseSuplConnection(GPS_AGPS_DATA_CONN_FAILED); - } }; private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @@ -902,8 +896,7 @@ public class GnssLocationProvider implements LocationProviderInterface { NetworkRequest request = requestBuilder.build(); mConnMgr.requestNetwork( request, - mSuplConnectivityCallback, - ConnectivityManager.MAX_NETWORK_REQUEST_TIMEOUT_MS); + mSuplConnectivityCallback); } private void handleReleaseSuplConnection(int agpsDataConnStatus) { From ba07c8c4ec1bf44875d326a9fab8499853222f82 Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Sun, 5 Feb 2017 10:42:27 -0800 Subject: [PATCH 2/2] [CM] Remove maximum timeout value for request network The request network with timeout was originally created with a check of max timeout against a constant of 100 minutes. However, the API was not public and did not implement a timeout. Any users were internal and never got any onUnavailable() callback (since timeout never triggered). There is no reason to have a max timeout so the constant is remove. Bug: 31399536 Test: unit tests and CTS of ConnectivityManager Change-Id: Icbedfb4299d75b6a7e3e43720111531f1faafd06 --- core/java/android/net/ConnectivityManager.java | 16 +++------------- .../com/android/server/ConnectivityService.java | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 82e3093728bc8..5d4f5e02a785f 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -2968,8 +2968,8 @@ public class ConnectivityManager { * * This function behaves identically to the non-timedout version, but if a suitable * network is not found within the given time (in milliseconds) the - * {@link NetworkCallback#unavailable} callback is called. The request must - * still be released normally by calling {@link unregisterNetworkCallback(NetworkCallback)}. + * {@link NetworkCallback#onUnavailable()} callback is called. The request must + * still be released normally by calling {@link #unregisterNetworkCallback(NetworkCallback)}. * *

This method requires the caller to hold either the * {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission @@ -2981,10 +2981,7 @@ public class ConnectivityManager { * the callbacks must not be shared - they uniquely specify * this request. * @param timeoutMs The time in milliseconds to attempt looking for a suitable network - * before {@link NetworkCallback#unavailable} is called. - * - * TODO: Make timeouts work and then unhide this method. - * + * before {@link NetworkCallback#onUnavailable()} is called. * @hide */ public void requestNetwork(NetworkRequest request, NetworkCallback networkCallback, @@ -2993,13 +2990,6 @@ public class ConnectivityManager { inferLegacyTypeForNetworkCapabilities(request.networkCapabilities)); } - /** - * The maximum number of milliseconds the framework will look for a suitable network - * during a timeout-equiped call to {@link requestNetwork}. - * {@hide} - */ - public final static int MAX_NETWORK_REQUEST_TIMEOUT_MS = 100 * 60 * 1000; - /** * The lookup key for a {@link Network} object included with the intent after * successfully finding a network for the applications request. Retrieve it with diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index dfca02ecc9d9b..6266a394e014c 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -4163,7 +4163,7 @@ public class ConnectivityService extends IConnectivityManager.Stub } ensureRequestableCapabilities(networkCapabilities); - if (timeoutMs < 0 || timeoutMs > ConnectivityManager.MAX_NETWORK_REQUEST_TIMEOUT_MS) { + if (timeoutMs < 0) { throw new IllegalArgumentException("Bad timeout specified"); }