Codota Logo
ShadowTelephonyManager
Code IndexAdd Codota to your IDE (free)

How to use
ShadowTelephonyManager
in
org.robolectric.shadows

Best Java code snippets using org.robolectric.shadows.ShadowTelephonyManager (Showing top 20 results out of 315)

  • Common ways to obtain ShadowTelephonyManager
private void myMethod () {
ShadowTelephonyManager s =
  • Codota IconObject instance;(ShadowTelephonyManager) Shadow.extract(instance)
  • Smart code suggestions by Codota
}
origin: robolectric/robolectric

@Implementation(minSdk = O)
protected String getImei(int slotIndex) {
 checkReadPhoneStatePermission();
 return slotIndexToImei.get(slotIndex);
}
origin: robolectric/robolectric

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);
  }
 }
}
origin: robolectric/robolectric

@Implementation
protected void listen(PhoneStateListener listener, int flags) {
 lastListener = listener;
 lastEventFlags = flags;
 if (flags == LISTEN_NONE) {
  phoneStateRegistrations.remove(listener);
 } else {
  initListener(listener, flags);
  phoneStateRegistrations.put(listener, flags);
 }
}
origin: robolectric/robolectric

public void setSimCountryIso(String simCountryIso) {
 setSimCountryIso(/* subId= */ 0, simCountryIso);
}
origin: robolectric/robolectric

/** Sets the current call state to the desired state and updates any listeners. */
public void setCallState(int callState) {
 setCallState(callState, null);
}
origin: robolectric/robolectric

/** Sets the sim state of slot 0. */
public void setSimState(int simState) {
 setSimState(/* slotIndex= */ 0, simState);
}
origin: google/ExoPlayer

 private void setNetworkCountryIso(String countryIso) {
  Shadows.shadowOf(telephonyManager).setNetworkCountryIso(countryIso);
 }
}
origin: robolectric/robolectric

@Implementation
protected int getSimState() {
 return getSimState(/* slotIndex= */ 0);
}
origin: robolectric/robolectric

@Test
@Config(minSdk = N)
public void shouldGetSimIosWhenSetUsingSlotNumber() {
 String expectedSimIso = "usa";
 int subId = 2;
 shadowOf(telephonyManager).setSimCountryIso(subId, expectedSimIso);
 assertThat(telephonyManager.getSimCountryIso(subId)).isEqualTo(expectedSimIso);
}
origin: robolectric/robolectric

@Test
public void shouldGiveCallState() {
 PhoneStateListener listener = mock(PhoneStateListener.class);
 telephonyManager.listen(listener, LISTEN_CALL_STATE);
 shadowOf(telephonyManager).setCallState(CALL_STATE_RINGING, "911");
 assertEquals(CALL_STATE_RINGING, telephonyManager.getCallState());
 verify(listener).onCallStateChanged(CALL_STATE_RINGING, "911");
 shadowOf(telephonyManager).setCallState(CALL_STATE_OFFHOOK, "911");
 assertEquals(CALL_STATE_OFFHOOK, telephonyManager.getCallState());
 verify(listener).onCallStateChanged(CALL_STATE_OFFHOOK, null);
}
origin: robolectric/robolectric

@Test
@Config(minSdk = O)
public void shouldGetSimStateUsingSlotNumber() {
 int expectedSimState = TelephonyManager.SIM_STATE_ABSENT;
 int slotNumber = 3;
 shadowOf(telephonyManager).setSimState(slotNumber, expectedSimState);
 assertThat(telephonyManager.getSimState(slotNumber)).isEqualTo(expectedSimState);
}
origin: robolectric/robolectric

@Test
public void shouldGiveNetworkCountryIso() {
 shadowOf(telephonyManager).setNetworkCountryIso("SomeIso");
 assertEquals("SomeIso", telephonyManager.getNetworkCountryIso());
}
origin: org.robolectric/shadows-framework

@Implementation
protected int getSimState() {
 return getSimState(/* slotIndex= */ 0);
}
origin: robolectric/robolectric

@Implementation(minSdk = O)
protected String getMeid(int slotIndex) {
 checkReadPhoneStatePermission();
 return slotIndexToMeid.get(slotIndex);
}
origin: robolectric/robolectric

public void setCellLocation(CellLocation cellLocation) {
 this.cellLocation = cellLocation;
 for (PhoneStateListener listener : getListenersForFlags(LISTEN_CELL_LOCATION)) {
  listener.onCellLocationChanged(cellLocation);
 }
}
origin: org.robolectric/framework

@Implementation
public void listen(PhoneStateListener listener, int flags) {
 lastListener = listener;
 lastEventFlags = flags;
 if (flags == LISTEN_NONE) {
  phoneStateRegistrations.remove(listener);
 } else {
  initListener(listener, flags);
  phoneStateRegistrations.put(listener, flags);
 }
}
origin: org.robolectric/shadows-framework

public void setSimCountryIso(String simCountryIso) {
 setSimCountryIso(/* subId= */ 0, simCountryIso);
}
origin: org.robolectric/shadows-framework

/** Sets the current call state to the desired state and updates any listeners. */
public void setCallState(int callState) {
 setCallState(callState, null);
}
origin: org.robolectric/shadows-framework

/** Sets the sim state of slot 0. */
public void setSimState(int simState) {
 setSimState(/* slotIndex= */ 0, simState);
}
origin: google/ExoPlayer

  (TelephonyManager)
    RuntimeEnvironment.application.getSystemService(Context.TELEPHONY_SERVICE);
Shadows.shadowOf(telephonyManager).setNetworkCountryIso(FAST_COUNTRY_ISO);
networkInfoOffline =
  ShadowNetworkInfo.newInstance(
org.robolectric.shadowsShadowTelephonyManager

Javadoc

Shadow for android.telephony.TelephonyManager.

Most used methods

  • checkReadPhoneStatePermission
  • getListenersForFlags
  • initListener
  • setCallState
    Sets the current call state with the option to specify an incoming phone number for the CALL_STATE_R
  • setSimCountryIso
  • setSimState
    Set the sim state for the given slotIndex.
  • getSimState
  • setNetworkCountryIso
  • getUiccSlotsInfo
    Returns the UICC slots information set by #setUiccSlotsInfo.
  • resetSimCountryIsos
    Clears subId to simCountryIso mapping and resets to default state.
  • resetSimStates
    Clears slotIndex to state mapping and resets to default state.
  • setAllCellInfo
  • resetSimStates,
  • setAllCellInfo,
  • setCarrierConfig,
  • setCarrierPackageNamesForPhone,
  • setCellLocation,
  • setCurrentPhoneType,
  • setDeviceId,
  • setGroupIdLevel1,
  • setImei,
  • setIsNetworkRoaming

Popular in Java

  • Start an intent from android
  • requestLocationUpdates (LocationManager)
  • startActivity (Activity)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • JTextField (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now