diff options
| author | 2018-09-15 00:23:28 +0000 | |
|---|---|---|
| committer | 2018-09-15 00:23:28 +0000 | |
| commit | 86f991a7bde823ca335a76f0b9986ea062ac28f0 (patch) | |
| tree | 2839d2b2a892d97287faeed9d20a7befce95d4a4 | |
| parent | 6d66e03371e02f6cddc02b2377dacd3bfac604ea (diff) | |
| parent | edf6ccaeb3c66baa331aa55fe0fcdc5c4697f3e7 (diff) | |
Merge "Don't Use NPE for Flow Control in getCellLocation"
| -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 2cc175c395e0..ebe05e8b27db 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; } } |