Class ShadowSubscriptionManager


  • @Implements(value=android.telephony.SubscriptionManager.class,
                minSdk=22)
    public class ShadowSubscriptionManager
    extends java.lang.Object
    • Field Detail

      • INVALID_PHONE_INDEX

        public static final int INVALID_PHONE_INDEX
    • Constructor Detail

      • ShadowSubscriptionManager

        public ShadowSubscriptionManager()
    • Method Detail

      • getDefaultSubscriptionId

        @Implementation(minSdk=24)
        protected static int getDefaultSubscriptionId()
        Returns value set with setDefaultSubscriptionId(int).
      • getDefaultDataSubscriptionId

        @Implementation(minSdk=24)
        protected static int getDefaultDataSubscriptionId()
        Returns value set with setDefaultDataSubscriptionId(int).
      • getDefaultSmsSubscriptionId

        @Implementation(minSdk=24)
        protected static int getDefaultSmsSubscriptionId()
        Returns value set with setDefaultSmsSubscriptionId(int).
      • getDefaultVoiceSubscriptionId

        @Implementation(minSdk=24)
        protected static int getDefaultVoiceSubscriptionId()
        Returns value set with setDefaultVoiceSubscriptionId(int).
      • getDefaultSubId

        @Implementation(maxSdk=23)
        @HiddenApi
        protected static int getDefaultSubId()
      • getDefaultVoiceSubId

        @Implementation(maxSdk=23)
        @HiddenApi
        protected static int getDefaultVoiceSubId()
      • getDefaultSmsSubId

        @Implementation(maxSdk=23)
        @HiddenApi
        protected static int getDefaultSmsSubId()
      • getDefaultDataSubId

        @Implementation(maxSdk=23)
        @HiddenApi
        protected static int getDefaultDataSubId()
      • setDefaultSubscriptionId

        public static void setDefaultSubscriptionId​(int defaultSubscriptionId)
        Sets the value that will be returned by getDefaultSubscriptionId().
      • setDefaultDataSubscriptionId

        public static void setDefaultDataSubscriptionId​(int defaultDataSubscriptionId)
      • setDefaultSmsSubscriptionId

        public static void setDefaultSmsSubscriptionId​(int defaultSmsSubscriptionId)
      • setDefaultVoiceSubscriptionId

        public static void setDefaultVoiceSubscriptionId​(int defaultVoiceSubscriptionId)
      • setActiveSubscriptionInfoList

        public void setActiveSubscriptionInfoList​(java.util.List<android.telephony.SubscriptionInfo> list)
        Sets the active list of SubscriptionInfo. This call internally triggers SubscriptionManager.OnSubscriptionsChangedListener.onSubscriptionsChanged() to all the listeners.
        Parameters:
        list - - The subscription info list, can be null.
      • setAvailableSubscriptionInfoList

        public void setAvailableSubscriptionInfoList​(java.util.List<android.telephony.SubscriptionInfo> list)
        Sets the active list of SubscriptionInfo. This call internally triggers SubscriptionManager.OnSubscriptionsChangedListener.onSubscriptionsChanged() to all the listeners.
        Parameters:
        list - - The subscription info list, can be null.
      • setActiveSubscriptionInfos

        public void setActiveSubscriptionInfos​(android.telephony.SubscriptionInfo... infos)
        Sets the active list of SubscriptionInfo. This call internally triggers SubscriptionManager.OnSubscriptionsChangedListener.onSubscriptionsChanged() to all the listeners.
      • setAvailableSubscriptionInfos

        public void setAvailableSubscriptionInfos​(android.telephony.SubscriptionInfo... infos)
        Sets the active list of SubscriptionInfo. This call internally triggers SubscriptionManager.OnSubscriptionsChangedListener.onSubscriptionsChanged() to all the listeners.
      • removeOnSubscriptionsChangedListener

        @Implementation(minSdk=22)
        protected void removeOnSubscriptionsChangedListener​(android.telephony.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.
      • clearNetworkRoamingStatus

        public void clearNetworkRoamingStatus()
        Clears the local cache of roaming subscription Ids used by isNetworkRoaming(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 by isNetworkRoaming(int).
      • isNetworkRoaming

        @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.
      • putPhoneId

        public static void putPhoneId​(int subId,
                                      int phoneId)
        Adds a subscription ID-phone ID mapping to the map used by getPhoneId(int).
      • removePhoneId

        public static java.lang.Integer removePhoneId​(int subId)
        Removes a subscription ID-phone ID mapping from the map used by getPhoneId(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 by getPhoneId(int).
      • 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(int,int) and removePhoneId(int) to return the phone ID for a given subscription ID.
      • reset

        @Resetter
        public static void reset()