@Implements(value=android.telephony.SubscriptionManager.class, minSdk=22) public class ShadowSubscriptionManager extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ShadowSubscriptionManager.SubscriptionInfoBuilder
Builder class to create instance of
SubscriptionInfo . |
Constructor and Description |
---|
ShadowSubscriptionManager() |
Modifier and Type | Method and 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 by
isNetworkRoaming(int) . |
protected int[] |
getActiveSubscriptionIdList()
Returns subscription Ids that were set via
setActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>) . |
protected SubscriptionInfo |
getActiveSubscriptionInfo(int subId)
Returns subscription that were set via
setActiveSubscriptionInfoList(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 of
SubscriptionInfo that were set via setActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>) . |
protected SubscriptionInfo |
getActiveSubscriptionInfoForSimSlotIndex(int slotIndex)
Returns subscription that were set via
setActiveSubscriptionInfoList(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 of
SubscriptionInfo that were set via setActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>) . |
protected static int |
getDefaultDataSubscriptionId()
Returns value set with
setDefaultDataSubscriptionId(int) . |
protected static int |
getDefaultSmsSubscriptionId()
Returns value set with
setDefaultSmsSubscriptionId(int) . |
protected static int |
getDefaultSubscriptionId()
Returns value set with
setDefaultSubscriptionId(int) . |
protected static int |
getDefaultVoiceSubscriptionId()
Returns value set with
setDefaultVoiceSubscriptionId(int) . |
protected boolean |
isNetworkRoaming(int simSubscriptionId)
Uses the local cache of roaming sim subscription Ids managed by
setNetworkRoamingStatus(int, boolean) to return subscription Ids marked as roaming. |
protected void |
removeOnSubscriptionsChangedListener(SubscriptionManager.OnSubscriptionsChangedListener listener)
Removes a listener from a local list of listeners.
|
static void |
reset() |
void |
setActiveSubscriptionInfoList(List<SubscriptionInfo> list)
Sets the active list of
SubscriptionInfo . |
void |
setActiveSubscriptionInfos(SubscriptionInfo... infos)
Sets the active list of
SubscriptionInfo . |
static void |
setDefaultDataSubscriptionId(int defaultDataSubscriptionId) |
static void |
setDefaultSmsSubscriptionId(int defaultSmsSubscriptionId) |
static void |
setDefaultSubscriptionId(int defaultSubscriptionId)
Sets the value that will be returned by
getDefaultSubscriptionId() . |
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.
|
@Implementation(minSdk=24) protected static int getDefaultSubscriptionId()
Returns value set with setDefaultSubscriptionId(int)
.
@Implementation(minSdk=24) protected static int getDefaultDataSubscriptionId()
Returns value set with setDefaultDataSubscriptionId(int)
.
@Implementation(minSdk=24) protected static int getDefaultSmsSubscriptionId()
Returns value set with setDefaultSmsSubscriptionId(int)
.
@Implementation(minSdk=24) protected static int getDefaultVoiceSubscriptionId()
Returns value set with setDefaultVoiceSubscriptionId(int)
.
public static void setDefaultSubscriptionId(int defaultSubscriptionId)
Sets the value that will be returned by getDefaultSubscriptionId()
.
public static void setDefaultDataSubscriptionId(int defaultDataSubscriptionId)
public static void setDefaultSmsSubscriptionId(int defaultSmsSubscriptionId)
public static void setDefaultVoiceSubscriptionId(int defaultVoiceSubscriptionId)
@Implementation(minSdk=22) protected List<SubscriptionInfo> getActiveSubscriptionInfoList()
Returns the active list of SubscriptionInfo
that were set via setActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
.
@Implementation(minSdk=22) protected int getActiveSubscriptionInfoCount()
Returns the size of the list of SubscriptionInfo
that were set via setActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
. If no list was set, returns 0.
@Implementation(minSdk=22) protected SubscriptionInfo getActiveSubscriptionInfo(int subId)
Returns subscription that were set via setActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
if it can find one with the specified id or null if none found.
@Implementation(minSdk=24) protected SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int slotIndex)
Returns subscription that were set via setActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
if it can find one with the specified slot index or null if none found.
public void setActiveSubscriptionInfoList(List<SubscriptionInfo> list)
Sets the active list of SubscriptionInfo
. This call internally triggers SubscriptionManager.OnSubscriptionsChangedListener.onSubscriptionsChanged()
to all the listeners.
list
- public void setActiveSubscriptionInfos(SubscriptionInfo... infos)
Sets the active list of SubscriptionInfo
. This call internally triggers SubscriptionManager.OnSubscriptionsChangedListener.onSubscriptionsChanged()
to all the listeners.
@Implementation(minSdk=22) protected void addOnSubscriptionsChangedListener(SubscriptionManager.OnSubscriptionsChangedListener listener)
Adds a listener to a local list of listeners. Will be triggered by setActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
when the local list of SubscriptionInfo
is updated.
@Implementation(minSdk=22) protected void removeOnSubscriptionsChangedListener(SubscriptionManager.OnSubscriptionsChangedListener listener)
Removes a listener from a local list of listeners. Will be triggered by setActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
when the local list of SubscriptionInfo
is updated.
@Implementation(minSdk=22) @HiddenApi protected int[] getActiveSubscriptionIdList()
Returns subscription Ids that were set via setActiveSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>)
.
public void clearNetworkRoamingStatus()
Clears the local cache of roaming subscription Ids used by isNetworkRoaming(int)
.
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 by isNetworkRoaming(int)
.
@Implementation(minSdk=22) protected boolean isNetworkRoaming(int simSubscriptionId)
Uses the local cache of roaming sim subscription Ids managed by setNetworkRoamingStatus(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.
@Resetter public static void reset()