Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23651f01 authored by Lucas Lin's avatar Lucas Lin Committed by Automerger Merge Worker
Browse files

Merge "Add a null check to prevent NullPointerException" am: 8467e54f

Original change: undetermined

Change-Id: I0d19fb3f09a9b3c1663a87b2ecd7efb369510730
parents 4154b2e5 8467e54f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1731,6 +1731,7 @@ public class NetworkMonitor extends StateMachine {
        }
        try {
            final List<CellInfo> cells = mTelephonyManager.getAllCellInfo();
            if (cells == null) return null;
            final Map<String, Integer> countryCodeMap = new HashMap<>();
            int maxCount = 0;
            for (final CellInfo cell : cells) {
+4 −1
Original line number Diff line number Diff line
@@ -867,12 +867,15 @@ public class NetworkMonitorTest {
        doReturn(PackageManager.PERMISSION_GRANTED).when(mContext).checkPermission(
                eq(android.Manifest.permission.ACCESS_FINE_LOCATION),  anyInt(), anyInt());
        doReturn(new ContextWrapper(mContext)).when(mContext).createConfigurationContext(any());
        doReturn(null).when(mTelephony).getAllCellInfo();
        assertNull(wnm.getLocationMcc());
        // Prepare CellInfo and check if the vote mechanism is working or not.
        final List<CellInfo> cellList = new ArrayList<CellInfo>();
        doReturn(cellList).when(mTelephony).getAllCellInfo();
        assertNull(wnm.getLocationMcc());
        cellList.add(makeTestCellInfoGsm("460"));
        cellList.add(makeTestCellInfoGsm("460"));
        cellList.add(makeTestCellInfoLte("466"));
        doReturn(cellList).when(mTelephony).getAllCellInfo();
        // The count of 460 is 2 and the count of 466 is 1, so the getLocationMcc() should return
        // 460.
        assertEquals("460", wnm.getLocationMcc());