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

Commit 631ac152 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 am:...

Merge "Add a null check to prevent NullPointerException" am: 8467e54f am: 23651f01 am: 142deba5 am: 5b13d878

Original change: undetermined

Change-Id: I5affb15b0225a9be4b3b60e8c0fbf8ed9e7b1449
parents bbc55374 5b13d878
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());