aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoogler <noreply@google.com>2024-04-01 15:10:29 -0700
committerCopybara-Service <copybara-worker@google.com>2024-04-01 15:11:06 -0700
commit5b99268bfda11ad69244f992b566ea6c4ca50832 (patch)
treeb9a09e3872051e81fb917d90c027102a6fb22b6d
parent4421bed8e8e049eded8a0cdb99fb71888bde9d8e (diff)
downloadrobolectric-5b99268bfda11ad69244f992b566ea6c4ca50832.tar.gz
Add support for getSimCarrierIdName() in ShadowTelephonyManager.
We need to test to simCarrierIdName, so add this support to the ShadowTelephonyManager. as title PiperOrigin-RevId: 620965842
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowTelephonyManagerTest.java9
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelephonyManager.java11
2 files changed, 20 insertions, 0 deletions
diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowTelephonyManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowTelephonyManagerTest.java
index afabf1db0..d560d60ea 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowTelephonyManagerTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowTelephonyManagerTest.java
@@ -867,6 +867,15 @@ public class ShadowTelephonyManagerTest {
}
@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() {
int expectedCarrierId = 419;
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelephonyManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelephonyManager.java
index 871e9f3a8..4c8c369fa 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelephonyManager.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelephonyManager.java
@@ -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;
@@ -1225,6 +1226,16 @@ public class ShadowTelephonyManager {
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();