Package org.robolectric.shadows
Class ShadowSubscriptionManager
java.lang.Object
org.robolectric.shadows.ShadowSubscriptionManager
@Implements(value=android.telephony.SubscriptionManager.class, minSdk=22) public class ShadowSubscriptionManager extends Object
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ShadowSubscriptionManager.SubscriptionInfoBuilder
Builder class to create instance ofSubscriptionInfo
. -
Field Summary
Fields Modifier and Type Field Description static int
INVALID_PHONE_INDEX
-
Constructor Summary
Constructors Constructor Description ShadowSubscriptionManager()
-
Method Summary
Modifier and Type Method Description protected void
addOnSubscriptionsChangedListener(SubscriptionManager.OnSubscriptionsChangedListener listener)
Adds a listener to a local list of listeners.void
clearNetworkRoamingStatus()
Clears the local cache of roaming subscription Ids used byisNetworkRoaming(int)
.static void
clearPhoneIds()
Removes all mappings between subscription IDs and phone IDs from the map used bygetPhoneId(int)
.protected int[]
getActiveSubscriptionIdList()
Returns subscription Ids that were set viasetActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
.protected SubscriptionInfo
getActiveSubscriptionInfo(int subId)
Returns subscription that were set viasetActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
if it can find one with the specified id or null if none found.protected int
getActiveSubscriptionInfoCount()
Returns the size of the list ofSubscriptionInfo
that were set viasetActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
.protected int
getActiveSubscriptionInfoCountMax()
protected SubscriptionInfo
getActiveSubscriptionInfoForSimSlotIndex(int slotIndex)
Returns subscription that were set viasetActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
if it can find one with the specified slot index or null if none found.protected List<SubscriptionInfo>
getActiveSubscriptionInfoList()
Returns the active list ofSubscriptionInfo
that were set viasetActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
.protected List<SubscriptionInfo>
getAvailableSubscriptionInfoList()
Returns the available list ofSubscriptionInfo
that were set viasetAvailableSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
.protected static int
getDefaultDataSubId()
protected static int
getDefaultDataSubscriptionId()
Returns value set withsetDefaultDataSubscriptionId(int)
.protected static int
getDefaultSmsSubId()
protected static int
getDefaultSmsSubscriptionId()
Returns value set withsetDefaultSmsSubscriptionId(int)
.protected static int
getDefaultSubId()
protected static int
getDefaultSubscriptionId()
Returns value set withsetDefaultSubscriptionId(int)
.protected static int
getDefaultVoiceSubId()
protected static int
getDefaultVoiceSubscriptionId()
Returns value set withsetDefaultVoiceSubscriptionId(int)
.protected static int
getPhoneId(int subId)
Uses the map of subscription IDs to phone IDs managed byputPhoneId(int,int)
andremovePhoneId(int)
to return the phone ID for a given subscription ID.protected boolean
isNetworkRoaming(int simSubscriptionId)
Uses the local cache of roaming sim subscription Ids managed bysetNetworkRoamingStatus(int, boolean)
to return subscription Ids marked as roaming.static void
putPhoneId(int subId, int phoneId)
Adds a subscription ID-phone ID mapping to the map used bygetPhoneId(int)
.protected void
removeOnSubscriptionsChangedListener(SubscriptionManager.OnSubscriptionsChangedListener listener)
Removes a listener from a local list of listeners.static Integer
removePhoneId(int subId)
Removes a subscription ID-phone ID mapping from the map used bygetPhoneId(int)
.static void
reset()
void
setActiveSubscriptionInfoList(List<SubscriptionInfo> list)
Sets the active list ofSubscriptionInfo
.void
setActiveSubscriptionInfos(SubscriptionInfo... infos)
Sets the active list ofSubscriptionInfo
.void
setAvailableSubscriptionInfoList(List<SubscriptionInfo> list)
Sets the active list ofSubscriptionInfo
.void
setAvailableSubscriptionInfos(SubscriptionInfo... infos)
Sets the active list ofSubscriptionInfo
.static void
setDefaultDataSubscriptionId(int defaultDataSubscriptionId)
static void
setDefaultSmsSubscriptionId(int defaultSmsSubscriptionId)
static void
setDefaultSubscriptionId(int defaultSubscriptionId)
Sets the value that will be returned bygetDefaultSubscriptionId()
.static void
setDefaultVoiceSubscriptionId(int defaultVoiceSubscriptionId)
void
setNetworkRoamingStatus(int simSubscriptionId, boolean isNetworkRoaming)
If isNetworkRoaming is set, it will mark the provided sim subscriptionId as roaming in a local cache.
-
Field Details
-
INVALID_PHONE_INDEX
public static final int INVALID_PHONE_INDEX
-
-
Constructor Details
-
ShadowSubscriptionManager
public ShadowSubscriptionManager()
-
-
Method Details
-
getDefaultSubscriptionId
Returns value set withsetDefaultSubscriptionId(int)
. -
getDefaultDataSubscriptionId
Returns value set withsetDefaultDataSubscriptionId(int)
. -
getDefaultSmsSubscriptionId
Returns value set withsetDefaultSmsSubscriptionId(int)
. -
getDefaultVoiceSubscriptionId
Returns value set withsetDefaultVoiceSubscriptionId(int)
. -
getDefaultSubId
-
getDefaultVoiceSubId
-
getDefaultSmsSubId
-
getDefaultDataSubId
-
setDefaultSubscriptionId
public static void setDefaultSubscriptionId(int defaultSubscriptionId)Sets the value that will be returned bygetDefaultSubscriptionId()
. -
setDefaultDataSubscriptionId
public static void setDefaultDataSubscriptionId(int defaultDataSubscriptionId) -
setDefaultSmsSubscriptionId
public static void setDefaultSmsSubscriptionId(int defaultSmsSubscriptionId) -
setDefaultVoiceSubscriptionId
public static void setDefaultVoiceSubscriptionId(int defaultVoiceSubscriptionId) -
getActiveSubscriptionInfoList
Returns the active list ofSubscriptionInfo
that were set viasetActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
. -
getAvailableSubscriptionInfoList
Returns the available list ofSubscriptionInfo
that were set viasetAvailableSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
. -
getActiveSubscriptionInfoCount
Returns the size of the list ofSubscriptionInfo
that were set viasetActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
. If no list was set, returns 0. -
getActiveSubscriptionInfo
Returns subscription that were set viasetActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
if it can find one with the specified id or null if none found. -
getActiveSubscriptionInfoCountMax
- Returns:
- the maximum number of active subscriptions that will be returned by
getActiveSubscriptionInfoList()
and the value returned bygetActiveSubscriptionInfoCount()
.
-
getActiveSubscriptionInfoForSimSlotIndex
@Implementation(minSdk=24) protected SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int slotIndex)Returns subscription that were set viasetActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
if it can find one with the specified slot index or null if none found. -
setActiveSubscriptionInfoList
Sets the active list ofSubscriptionInfo
. This call internally triggersSubscriptionManager.OnSubscriptionsChangedListener.onSubscriptionsChanged()
to all the listeners.- Parameters:
list
- - The subscription info list, can be null.
-
setAvailableSubscriptionInfoList
Sets the active list ofSubscriptionInfo
. This call internally triggersSubscriptionManager.OnSubscriptionsChangedListener.onSubscriptionsChanged()
to all the listeners.- Parameters:
list
- - The subscription info list, can be null.
-
setActiveSubscriptionInfos
Sets the active list ofSubscriptionInfo
. This call internally triggersSubscriptionManager.OnSubscriptionsChangedListener.onSubscriptionsChanged()
to all the listeners. -
setAvailableSubscriptionInfos
Sets the active list ofSubscriptionInfo
. This call internally triggersSubscriptionManager.OnSubscriptionsChangedListener.onSubscriptionsChanged()
to all the listeners. -
addOnSubscriptionsChangedListener
@Implementation(minSdk=22) protected void addOnSubscriptionsChangedListener(SubscriptionManager.OnSubscriptionsChangedListener listener)Adds a listener to a local list of listeners. Will be triggered bysetActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
when the local list ofSubscriptionInfo
is updated. -
removeOnSubscriptionsChangedListener
@Implementation(minSdk=22) protected void removeOnSubscriptionsChangedListener(SubscriptionManager.OnSubscriptionsChangedListener listener)Removes a listener from a local list of listeners. Will be triggered bysetActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
when the local list ofSubscriptionInfo
is updated. -
getActiveSubscriptionIdList
Returns subscription Ids that were set viasetActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
. -
clearNetworkRoamingStatus
public void clearNetworkRoamingStatus()Clears the local cache of roaming subscription Ids used byisNetworkRoaming(int)
. -
setNetworkRoamingStatus
public void setNetworkRoamingStatus(int simSubscriptionId, boolean isNetworkRoaming)If isNetworkRoaming is set, it will mark the provided sim subscriptionId as roaming in a local cache. If isNetworkRoaming is unset it will remove the subscriptionId from the local cache. The local cache is used to provide roaming status returned byisNetworkRoaming(int)
. -
isNetworkRoaming
Uses the local cache of roaming sim subscription Ids managed bysetNetworkRoamingStatus(int, boolean)
to return subscription Ids marked as roaming. Otherwise subscription Ids will be considered as non-roaming if they are not in the cache. -
putPhoneId
public static void putPhoneId(int subId, int phoneId)Adds a subscription ID-phone ID mapping to the map used bygetPhoneId(int)
. -
removePhoneId
Removes a subscription ID-phone ID mapping from the map used bygetPhoneId(int)
.- Returns:
- the previous phone ID associated with the subscription ID, or null if there was no mapping for the subscription ID
-
clearPhoneIds
public static void clearPhoneIds()Removes all mappings between subscription IDs and phone IDs from the map used bygetPhoneId(int)
. -
getPhoneId
Uses the map of subscription IDs to phone IDs managed byputPhoneId(int,int)
andremovePhoneId(int)
to return the phone ID for a given subscription ID. -
reset
-