@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 . |
Modifier and Type | Field and Description |
---|---|
static int |
INVALID_PHONE_INDEX |
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) . |
static void |
clearPhoneIds()
Removes all mappings between subscription IDs and phone IDs from the map used by
getPhoneId . |
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 List<SubscriptionInfo> |
getAvailableSubscriptionInfoList()
Returns the available list of
SubscriptionInfo that were set via setAvailableSubscriptionInfoList(java.util.List<android.telephony.SubscriptionInfo>) . |
protected static int |
getDefaultDataSubId() |
protected static int |
getDefaultDataSubscriptionId()
Returns value set with
setDefaultDataSubscriptionId(int) . |
protected static int |
getDefaultSmsSubId() |
protected static int |
getDefaultSmsSubscriptionId()
Returns value set with
setDefaultSmsSubscriptionId(int) . |
protected static int |
getDefaultSubId() |
protected static int |
getDefaultSubscriptionId()
Returns value set with
setDefaultSubscriptionId(int) . |
protected static int |
getDefaultVoiceSubId() |
protected static int |
getDefaultVoiceSubscriptionId()
Returns value set with
setDefaultVoiceSubscriptionId(int) . |
protected static int |
getPhoneId(int subId)
Uses the map of subscription IDs to phone IDs managed by
putPhoneId and removePhoneId 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 by
setNetworkRoamingStatus(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 by
getPhoneId . |
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 by
getPhoneId . |
static void |
reset() |
void |
setActiveSubscriptionInfoList(List<SubscriptionInfo> list)
Sets the active list of
SubscriptionInfo . |
void |
setActiveSubscriptionInfos(SubscriptionInfo... infos)
Sets the active list of
SubscriptionInfo . |
void |
setAvailableSubscriptionInfoList(List<SubscriptionInfo> list)
Sets the active list of
SubscriptionInfo . |
void |
setAvailableSubscriptionInfos(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)
.
@Implementation(maxSdk=23) @HiddenApi protected static int getDefaultSubId()
@Implementation(maxSdk=23) @HiddenApi protected static int getDefaultVoiceSubId()
@Implementation(maxSdk=23) @HiddenApi protected static int getDefaultSmsSubId()
@Implementation(maxSdk=23) @HiddenApi protected static int getDefaultDataSubId()
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=27) protected List<SubscriptionInfo> getAvailableSubscriptionInfoList()
Returns the available list of SubscriptionInfo
that were set via setAvailableSubscriptionInfoList(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 setAvailableSubscriptionInfoList(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.
public void setAvailableSubscriptionInfos(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.
public static void putPhoneId(int subId, int phoneId)
Adds a subscription ID-phone ID mapping to the map used by getPhoneId
.
public static Integer removePhoneId(int subId)
Removes a subscription ID-phone ID mapping from the map used by getPhoneId
.
public static void clearPhoneIds()
Removes all mappings between subscription IDs and phone IDs from the map used by getPhoneId
.
@Implementation(minSdk=22, maxSdk=28) @HiddenApi protected static int getPhoneId(int subId)
Uses the map of subscription IDs to phone IDs managed by putPhoneId
and removePhoneId
to return the phone ID for a given subscription ID.
@Resetter public static void reset()