diff options
| author | 2018-09-14 19:15:54 -0700 | |
|---|---|---|
| committer | 2018-09-14 19:15:54 -0700 | |
| commit | 65e63ce0de5107ed95060b26e9fb02a5b637249c (patch) | |
| tree | 2e68c83baca25e4e001c25012bf6fac127cd3ce3 | |
| parent | 10f56a4f7665563af485a4234a6fbb3c495e4c21 (diff) | |
| parent | 86f991a7bde823ca335a76f0b9986ea062ac28f0 (diff) | |
Merge "Don't Use NPE for Flow Control in getCellLocation"
am: 86f991a7bd
Change-Id: I3440e965f8f7edfa86359677e704140f39deb320
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index d6f4098f3a8f..7584793783e7 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -1498,23 +1498,24 @@ public class TelephonyManager { Rlog.d(TAG, "getCellLocation returning null because telephony is null"); return null; } + Bundle bundle = telephony.getCellLocation(mContext.getOpPackageName()); - if (bundle.isEmpty()) { - Rlog.d(TAG, "getCellLocation returning null because bundle is empty"); + if (bundle == null || bundle.isEmpty()) { + Rlog.d(TAG, "getCellLocation returning null because CellLocation is unavailable"); return null; } + CellLocation cl = CellLocation.newFromBundle(bundle); - if (cl.isEmpty()) { - Rlog.d(TAG, "getCellLocation returning null because CellLocation is empty"); + if (cl == null || cl.isEmpty()) { + Rlog.d(TAG, "getCellLocation returning null because CellLocation is empty or" + + " phone type doesn't match CellLocation type"); return null; } + return cl; } catch (RemoteException ex) { Rlog.d(TAG, "getCellLocation returning null due to RemoteException " + ex); return null; - } catch (NullPointerException ex) { - Rlog.d(TAG, "getCellLocation returning null due to NullPointerException " + ex); - return null; } } |