From ed9297991a922b88a00c04d034c172c18d550ac1 Mon Sep 17 00:00:00 2001 From: Paul Stewart Date: Thu, 11 Feb 2016 11:08:24 -0800 Subject: [PATCH] WifiManager: Return empty scan list on remote exception In the (hopefully rare) situation where there is a remote exception from a call to getScanResults(), do not pass null back to callers. Nobody expects this, and failures that occur as a result can distract from the real problem (e.g., the system server crashing). This CL now returns an empty list. BUG=27139097 TEST=None Change-Id: I637eae1fa8ac1a1bc2b76dea8628359b5dec06e1 --- wifi/java/android/net/wifi/WifiManager.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 4133cda9fe01b..09040f559c361 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -44,6 +44,7 @@ import com.android.internal.util.AsyncChannel; import com.android.internal.util.Protocol; import java.net.InetAddress; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -1293,13 +1294,15 @@ public class WifiManager { * @return the list of access points found in the most recent scan. An app must hold * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION} or * {@link android.Manifest.permission#ACCESS_FINE_LOCATION ACCESS_FINE_LOCATION} permission - * in order to get valid results. + * in order to get valid results. If there is a remote exception (e.g., either a communication + * problem with the system service or an exception within the framework) an empty list will be + * returned. */ public List getScanResults() { try { return mService.getScanResults(mContext.getOpPackageName()); } catch (RemoteException e) { - return null; + return new ArrayList(); } }