public void setAllCellInfo(List<CellInfo> allCellInfo) { this.allCellInfo = allCellInfo; if (VERSION.SDK_INT >= JELLY_BEAN_MR1) { for (PhoneStateListener listener : getListenersForFlags(LISTEN_CELL_INFO)) { listener.onCellInfoChanged(allCellInfo); } } }
private void initListener(PhoneStateListener listener, int flags) { if ((flags & LISTEN_CALL_STATE) != 0) { listener.onCallStateChanged(callState, incomingPhoneNumber); } if ((flags & LISTEN_CELL_INFO) != 0) { if (VERSION.SDK_INT >= JELLY_BEAN_MR1) { listener.onCellInfoChanged(allCellInfo); } } if ((flags & LISTEN_CELL_LOCATION) != 0) { listener.onCellLocationChanged(cellLocation); } }
@Test public void testListenInit() { PhoneStateListener listener = mock(PhoneStateListener.class); telephonyManager.listen(listener, LISTEN_CALL_STATE | LISTEN_CELL_INFO | LISTEN_CELL_LOCATION); verify(listener).onCallStateChanged(CALL_STATE_IDLE, null); verify(listener).onCellLocationChanged(null); if (VERSION.SDK_INT >= JELLY_BEAN_MR1) { verify(listener).onCellInfoChanged(Collections.emptyList()); } }
@Test @Config(minSdk = JELLY_BEAN_MR1) public void shouldGiveAllCellInfo() { PhoneStateListener listener = mock(PhoneStateListener.class); telephonyManager.listen(listener, LISTEN_CELL_INFO); List<CellInfo> allCellInfo = Collections.singletonList(mock(CellInfo.class)); shadowOf(telephonyManager).setAllCellInfo(allCellInfo); assertEquals(allCellInfo, telephonyManager.getAllCellInfo()); verify(listener).onCellInfoChanged(allCellInfo); }
public void setAllCellInfo(List<CellInfo> allCellInfo) { this.allCellInfo = allCellInfo; if (VERSION.SDK_INT >= JELLY_BEAN_MR1) { for (PhoneStateListener listener : getListenersForFlags(LISTEN_CELL_INFO)) { listener.onCellInfoChanged(allCellInfo); } } }
public void setAllCellInfo(List<CellInfo> allCellInfo) { this.allCellInfo = allCellInfo; if (VERSION.SDK_INT >= JELLY_BEAN_MR1) { for (PhoneStateListener listener : getListenersForFlags(LISTEN_CELL_INFO)) { listener.onCellInfoChanged(allCellInfo); } } }
private void initListener(PhoneStateListener listener, int flags) { if ((flags & LISTEN_CALL_STATE) != 0) { listener.onCallStateChanged(callState, incomingPhoneNumber); } if ((flags & LISTEN_CELL_INFO) != 0) { if (VERSION.SDK_INT >= JELLY_BEAN_MR1) { listener.onCellInfoChanged(allCellInfo); } } if ((flags & LISTEN_CELL_LOCATION) != 0) { listener.onCellLocationChanged(cellLocation); } }
private void initListener(PhoneStateListener listener, int flags) { if ((flags & LISTEN_CALL_STATE) != 0) { listener.onCallStateChanged(callState, incomingPhoneNumber); } if ((flags & LISTEN_CELL_INFO) != 0) { if (VERSION.SDK_INT >= JELLY_BEAN_MR1) { listener.onCellInfoChanged(allCellInfo); } } if ((flags & LISTEN_CELL_LOCATION) != 0) { listener.onCellLocationChanged(cellLocation); } }