Loading src/com/android/server/connectivity/NetworkMonitor.java +1 −0 Original line number Diff line number Diff line Loading @@ -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) { Loading tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java +4 −1 Original line number Diff line number Diff line Loading @@ -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()); Loading Loading
src/com/android/server/connectivity/NetworkMonitor.java +1 −0 Original line number Diff line number Diff line Loading @@ -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) { Loading
tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java +4 −1 Original line number Diff line number Diff line Loading @@ -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()); Loading