Skip to content

Commit

Permalink
Add support for getSimCarrierIdName() in ShadowTelephonyManager.
Browse files Browse the repository at this point in the history
We need to test to simCarrierIdName, so add this support to the ShadowTelephonyManager.

as title

PiperOrigin-RevId: 620965842
  • Loading branch information
Googler authored and Copybara-Service committed Apr 1, 2024
1 parent 4421bed commit 5b99268
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,15 @@ public void shouldGetSimCarrierId() {
assertThat(telephonyManager.getSimCarrierId()).isEqualTo(expectedCarrierId);
}

@Test
@Config(minSdk = P)
public void shouldGetSimCarrierIdName() {
String expectedCarrierIdName = "Fi";
shadowOf(telephonyManager).setSimCarrierIdName(expectedCarrierIdName);

assertThat(telephonyManager.getSimCarrierIdName().toString()).isEqualTo(expectedCarrierIdName);
}

@Test
@Config(minSdk = Q)
public void shouldGetCarrierIdFromSimMccMnc() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public class ShadowTelephonyManager {
private static final Map<Integer, String> simCountryIsoMap =
Collections.synchronizedMap(new LinkedHashMap<>());
private int simCarrierId;
private CharSequence simCarrierIdName;
private int carrierIdFromSimMccMnc;
private String subscriberId;
private static volatile /*UiccSlotInfo[]*/ Object uiccSlotInfos;
Expand Down Expand Up @@ -1225,6 +1226,16 @@ public void setSimCarrierId(int simCarrierId) {
this.simCarrierId = simCarrierId;
}

@Implementation(minSdk = P)
protected CharSequence getSimCarrierIdName() {
return simCarrierIdName;
}

/** Sets the value to be returned by {@link #getSimCarrierIdName()}. */
public void setSimCarrierIdName(CharSequence simCarrierIdName) {
this.simCarrierIdName = simCarrierIdName;
}

@Implementation
protected String getSubscriberId() {
checkReadPhoneStatePermission();
Expand Down

0 comments on commit 5b99268

Please sign in to comment.