From 06d1132344b4600ae00bda63d4da0acff7de42f0 Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Wed, 18 Feb 2015 11:40:05 +0100 Subject: [PATCH] Fix usage of null cell info --- src/org/microg/nlp/api/CellBackendHelper.java | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/org/microg/nlp/api/CellBackendHelper.java b/src/org/microg/nlp/api/CellBackendHelper.java index 538ce2f..cc73ae9 100644 --- a/src/org/microg/nlp/api/CellBackendHelper.java +++ b/src/org/microg/nlp/api/CellBackendHelper.java @@ -53,9 +53,9 @@ public class CellBackendHelper extends AbstractBackendHelper { private final Listener listener; private final TelephonyManager telephonyManager; + private final Set cells = new HashSet<>(); private PhoneStateListener phoneStateListener; private boolean supportsCellInfoChanged = true; - private Set cells = new HashSet<>(); /** * Create a new instance of {@link CellBackendHelper}. Call this in @@ -259,18 +259,26 @@ private boolean hasCid(long cid) { private synchronized boolean loadCells(List cellInfo) { cells.clear(); currentDataUsed = false; - fixAllCellInfo(cellInfo); - for (CellInfo info : cellInfo) { - Cell cell = parseCellInfo(info); - if (cell == null) continue; - cells.add(cell); - } - for (NeighboringCellInfo info : telephonyManager.getNeighboringCellInfo()) { - if (!hasCid(info.getCid())) { - Cell cell = parseCellInfo(info); - if (cell == null) continue; - cells.add(cell); + try { + if (cellInfo != null) { + fixAllCellInfo(cellInfo); + for (CellInfo info : cellInfo) { + Cell cell = parseCellInfo(info); + if (cell == null) continue; + cells.add(cell); + } } + List neighboringCellInfo = telephonyManager.getNeighboringCellInfo(); + if (neighboringCellInfo != null) { + for (NeighboringCellInfo info : neighboringCellInfo) { + if (!hasCid(info.getCid())) { + Cell cell = parseCellInfo(info); + if (cell == null) continue; + cells.add(cell); + } + } + } + } catch (Exception ignored) { } if (state == State.DISABLING) state = State.DISABLED;