From 6ac4bfcb70821f418cd748696b99912dae48f257 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Mon, 7 Oct 2019 07:24:11 -0700 Subject: WifiNetworkFactory: Send match callback on registration If the UI registers its callback to the platform and if we already have some matching results for the request, send it immediately to the UI. Otherwise, we'll need to wait for the next scan results to present users with matches. Bug: 134712530 Test: atest com.android.server.wifi Test: Manually verified with CtsVerifier tests that the UI does not start out with a blank page (because the matched networks are already found by using the cached results). Change-Id: Ice7f89952c0a71c181ea5de58e417c02e7f2bf91 Merged-In: Ice7f89952c0a71c181ea5de58e417c02e7f2bf91 (cherry-picked from bbaee0b899a9606f405e27e0af50ee98d2023de4) --- service/java/com/android/server/wifi/WifiNetworkFactory.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/WifiNetworkFactory.java b/service/java/com/android/server/wifi/WifiNetworkFactory.java index be6ac6473..4b5866b44 100644 --- a/service/java/com/android/server/wifi/WifiNetworkFactory.java +++ b/service/java/com/android/server/wifi/WifiNetworkFactory.java @@ -428,7 +428,12 @@ public class WifiNetworkFactory extends NetworkFactory { new NetworkFactoryUserSelectionCallback(mActiveSpecificNetworkRequest)); } catch (RemoteException e) { Log.e(TAG, "Unable to invoke user selection registration callback " + callback, e); + return; } + + // If we are already in the midst of processing a request, send matching callbacks + // immediately on registering the callback. + sendNetworkRequestMatchCallbacksForActiveRequest(mActiveMatchedScanResults); } /** @@ -981,6 +986,7 @@ public class WifiNetworkFactory extends NetworkFactory { mConnectedSpecificNetworkRequestSpecifier = mActiveSpecificNetworkRequestSpecifier; mActiveSpecificNetworkRequest = null; mActiveSpecificNetworkRequestSpecifier = null; + mActiveMatchedScanResults = null; mPendingConnectionSuccess = false; // Cancel connection timeout alarm. cancelConnectionTimeout(); @@ -1127,7 +1133,8 @@ public class WifiNetworkFactory extends NetworkFactory { } private void sendNetworkRequestMatchCallbacksForActiveRequest( - List matchedScanResults) { + @Nullable List matchedScanResults) { + if (matchedScanResults == null || matchedScanResults.isEmpty()) return; if (mRegisteredCallbacks.getNumCallbacks() == 0) { Log.e(TAG, "No callback registered for sending network request matches. " + "Ignoring..."); -- cgit v1.2.3