Class ShadowTelephonyManager

    • Field Detail

      • realTelephonyManager

        @RealObject
        protected TelephonyManager realTelephonyManager
    • Constructor Detail

      • ShadowTelephonyManager

        public ShadowTelephonyManager()
    • Method Detail

      • reset

        @Resetter
        public static void reset()
      • setCallComposerStatus

        public static void setCallComposerStatus​(int callComposerStatus)
      • getCallComposerStatus

        @Implementation(minSdk=31)
        @HiddenApi
        protected int getCallComposerStatus()
      • getBootstrapAuthenticationCallback

        public Object getBootstrapAuthenticationCallback()
      • bootstrapAuthenticationRequest

        @Implementation(minSdk=31)
        @HiddenApi
        public void bootstrapAuthenticationRequest​(Object appType,
                                                   Object nafId,
                                                   Object securityProtocol,
                                                   Object forceBootStrapping,
                                                   Object e,
                                                   Object callback)
      • listen

        @Implementation
        protected void listen​(PhoneStateListener listener,
                              int flags)
      • getListener

        @Deprecated
        public PhoneStateListener getListener()
        Deprecated.
        Avoid using.
        Returns the most recent listener passed to #listen().
        Returns:
        Phone state listener.
      • getEventFlags

        @Deprecated
        public int getEventFlags()
        Deprecated.
        Avoid using.
        Returns the most recent flags passed to #listen().
        Returns:
        Event flags.
      • registerTelephonyCallback

        @Implementation(minSdk=31)
        public void registerTelephonyCallback​(Executor executor,
                                              TelephonyCallback callback)
      • registerTelephonyCallback

        @Implementation(minSdk=33)
        protected void registerTelephonyCallback​(int includeLocationData,
                                                 Executor executor,
                                                 TelephonyCallback callback)
      • unregisterTelephonyCallback

        @Implementation(minSdk=31)
        public void unregisterTelephonyCallback​(TelephonyCallback callback)
      • getLastTelephonyCallback

        public TelephonyCallback getLastTelephonyCallback()
        Returns the most recent callback passed to #registerTelephonyCallback().
      • getCallState

        @Implementation
        protected int getCallState()
        Call state may be specified via setCallState(int).
      • setCallState

        public void setCallState​(int callState)
        Sets the current call state to the desired state and updates any listeners.
      • setCallState

        public void setCallState​(int callState,
                                 String incomingPhoneNumber)
        Sets the current call state with the option to specify an incoming phone number for the CALL_STATE_RINGING state. The incoming phone number will be ignored for all other cases.
      • setDataState

        public void setDataState​(int dataState)
        Sets the data state returned by getDataState().
      • getDeviceId

        @Implementation
        protected String getDeviceId()
      • setDeviceId

        public void setDeviceId​(String newDeviceId)
      • setNetworkOperatorName

        @Implementation(minSdk=22)
        public void setNetworkOperatorName​(String networkOperatorName)
      • getImei

        @Implementation(minSdk=21)
        protected String getImei()
      • getImei

        @Implementation(minSdk=26)
        protected String getImei​(int slotIndex)
      • setImei

        public void setImei​(String imei)
        Set the IMEI returned by getImei().
      • setImei

        public void setImei​(int slotIndex,
                            String imei)
        Set the IMEI returned by getImei(int).
      • getMeid

        @Implementation(minSdk=26)
        protected String getMeid()
      • getMeid

        @Implementation(minSdk=26)
        protected String getMeid​(int slotIndex)
      • setMeid

        public void setMeid​(String meid)
        Set the MEID returned by getMeid().
      • setMeid

        public void setMeid​(int slotIndex,
                            String meid)
        Set the MEID returned by getMeid(int).
      • getNetworkOperatorName

        @Implementation
        protected String getNetworkOperatorName()
      • setNetworkCountryIso

        @Implementation(minSdk=22,
                        maxSdk=28)
        public void setNetworkCountryIso​(String networkCountryIso)
      • getNetworkCountryIso

        @Implementation
        protected String getNetworkCountryIso()
        Returns the SIM country lowercase. This matches the API this shadows: https://developer.android.com/reference/android/telephony/TelephonyManager#getNetworkCountryIso().
      • setSimLocale

        public void setSimLocale​(Locale simLocale)
        Sets the sim locale returned by getSimLocale().
      • setNetworkOperator

        public void setNetworkOperator​(String networkOperator)
      • getNetworkOperator

        @Implementation
        protected String getNetworkOperator()
      • getSimOperator

        @Implementation
        protected String getSimOperator()
      • setSimOperator

        public void setSimOperator​(String simOperator)
      • getSimOperatorName

        @Implementation
        protected String getSimOperatorName()
      • setSimOperatorName

        @Implementation(minSdk=22)
        public void setSimOperatorName​(String simOperatorName)
      • getSimSerialNumber

        @Implementation
        protected String getSimSerialNumber()
      • setSimSerialNumber

        public void setSimSerialNumber​(String simSerialNumber)
        sets the serial number that will be returned by getSimSerialNumber().
      • getSimCountryIso

        @Implementation
        protected String getSimCountryIso()
        Returns the SIM country lowercase. This matches the API it shadows: https://developer.android.com/reference/android/telephony/TelephonyManager#getSimCountryIso().
      • getSimCountryIso

        @Implementation(minSdk=24,
                        maxSdk=29)
        @HiddenApi
        protected String getSimCountryIso​(int subId)
      • setSimCountryIso

        @Implementation(minSdk=22)
        public void setSimCountryIso​(String simCountryIso)
      • setSimCountryIso

        public void setSimCountryIso​(int subId,
                                     String simCountryIso)
        Sets the simCountryIso for the given subId.
      • resetSimCountryIsos

        public void resetSimCountryIsos()
        Clears subId to simCountryIso mapping and resets to default state.
      • getSimState

        @Implementation
        protected int getSimState()
      • setSimState

        public void setSimState​(int simState)
        Sets the sim state of slot 0.
      • setSimState

        public void setSimState​(int slotIndex,
                                int state)
        Set the sim state for the given slotIndex.
      • getSimState

        @Implementation(minSdk=26)
        protected int getSimState​(int slotIndex)
      • setUiccSlotsInfo

        public void setUiccSlotsInfo​(Object uiccSlotsInfos)
        Sets the UICC slots information returned by getUiccSlotsInfo().
      • resetSimStates

        public void resetSimStates()
        Clears slotIndex to state mapping and resets to default state.
      • setReadPhoneStatePermission

        public void setReadPhoneStatePermission​(boolean readPhoneStatePermission)
      • getPhoneType

        @Implementation
        protected int getPhoneType()
      • setPhoneType

        @Implementation(minSdk=22)
        public void setPhoneType​(int phoneType)
      • getLine1Number

        @Implementation
        protected String getLine1Number()
      • setLine1Number

        public void setLine1Number​(String line1Number)
      • getNetworkType

        @Implementation
        protected int getNetworkType()
      • setDataNetworkType

        @Implementation(minSdk=22)
        public void setDataNetworkType​(int dataNetworkType)
        Sets the value to be returned by calls to getDataNetworkType(). This should correspond to one of the NETWORK_TYPE_* constants defined on TelephonyManager, but this is not enforced.
      • getVoiceNetworkType

        @Implementation(minSdk=24)
        protected int getVoiceNetworkType()
        Returns whatever value was set by the last call to setVoiceNetworkType(int), defaulting to TelephonyManager.NETWORK_TYPE_UNKNOWN if it was never called.

        An exception will be thrown if the READ_PHONE_STATE permission has not been granted.

      • setVoiceNetworkType

        public void setVoiceNetworkType​(int voiceNetworkType)
        Sets the value to be returned by calls to getVoiceNetworkType(). This should correspond to one of the NETWORK_TYPE_* constants defined on TelephonyManager, but this is not enforced.
      • getAllCellInfo

        @Implementation(minSdk=17)
        protected List<CellInfo> getAllCellInfo()
      • setAllCellInfo

        public void setAllCellInfo​(List<CellInfo> allCellInfo)
      • setRequestCellInfoUpdateErrorValues

        public void setRequestCellInfoUpdateErrorValues​(int errorCode,
                                                        Throwable detail)
        Sets the values to be returned by a presumed error condition in requestCellInfoUpdate(java.lang.Object,java.lang.Object). These values will persist until cleared: to clear, set (0, null) using this method.
      • getCellLocation

        @Implementation
        protected CellLocation getCellLocation()
      • setCellLocation

        public void setCellLocation​(CellLocation cellLocation)
      • getGroupIdLevel1

        @Implementation(minSdk=18)
        protected String getGroupIdLevel1()
      • setGroupIdLevel1

        public void setGroupIdLevel1​(String groupIdLevel1)
      • initTelephonyCallback

        protected void initTelephonyCallback​(TelephonyCallback callback)
      • getCallbackForListener

        protected <T> Iterable<T> getCallbackForListener​(Class<T> clazz)
        Returns a view of telephonyCallbackRegistrations containing all elements that are of the type clazz.
      • isSmsCapable

        @Implementation
        protected boolean isSmsCapable()
        Returns:
        true by default, or the value specified via setIsSmsCapable(boolean)
      • getPhoneCount

        @Implementation(minSdk=23)
        protected int getPhoneCount()
        Returns 1 by default or the value specified via setPhoneCount(int).
      • getDeviceId

        @Implementation(minSdk=23)
        protected String getDeviceId​(int slot)
        Returns null by default or the value specified via setDeviceId(int, String).
      • isVoiceCapable

        @Implementation(minSdk=22)
        protected boolean isVoiceCapable()
        Returns true by default or the value specified via setVoiceCapable(boolean).
      • setVoiceCapable

        public void setVoiceCapable​(boolean voiceCapable)
        Sets the value returned by isVoiceCapable().
      • isNetworkRoaming

        @Implementation
        protected boolean isNetworkRoaming()
        Returns false by default or the value specified via setIsNetworkRoaming(boolean)
      • getCurrentPhoneType

        @Implementation(minSdk=23)
        @HiddenApi
        protected int getCurrentPhoneType​(int subId)
      • setCurrentPhoneType

        public void setCurrentPhoneType​(int subId,
                                        int phoneType)
        Sets the phone type for the given subId.
      • clearPhoneTypes

        public void clearPhoneTypes()
        Removes all subId to phoneType mappings.
      • getCarrierPackageNamesForIntentAndPhone

        @Implementation(minSdk=23)
        @HiddenApi
        protected List<String> getCarrierPackageNamesForIntentAndPhone​(Intent intent,
                                                                       int phoneId)
      • getCarrierPackageNamesForIntent

        @Implementation(minSdk=21)
        @HiddenApi
        protected List<String> getCarrierPackageNamesForIntent​(Intent intent)
      • setCarrierPackageNamesForPhone

        public void setCarrierPackageNamesForPhone​(int phoneId,
                                                   List<String> packages)
        Sets the packages for the given phoneId.
      • getCarrierIdFromSimMccMnc

        @Implementation(minSdk=29)
        protected int getCarrierIdFromSimMccMnc()
      • setCarrierIdFromSimMccMnc

        public void setCarrierIdFromSimMccMnc​(int carrierIdFromSimMccMnc)
        Sets the value to be returned by getCarrierIdFromSimMccMnc().
      • getSimCarrierId

        @Implementation(minSdk=28)
        protected int getSimCarrierId()
      • setSimCarrierId

        public void setSimCarrierId​(int simCarrierId)
        Sets the value to be returned by getSimCarrierId().
      • getSubscriberId

        @Implementation
        protected String getSubscriberId()
      • setSubscriberId

        public void setSubscriberId​(String subscriberId)
        Sets the value to be returned by getSubscriberId().
      • getSignalStrength

        @Implementation(minSdk=28)
        protected SignalStrength getSignalStrength()
      • isPotentialEmergencyNumber

        @Implementation(minSdk=29)
        protected boolean isPotentialEmergencyNumber​(String number)
      • setDataEnabled

        @Implementation(minSdk=26)
        public void setDataEnabled​(boolean enabled)
        Implementation for TelephonyManager.setDataEnabled(boolean). Marked as public in order to allow it to be used as a test API.
      • setRttSupported

        public void setRttSupported​(boolean isRttSupported)
        Sets the value to be returned by isRttSupported()
      • setHearingAidCompatibilitySupported

        public void setHearingAidCompatibilitySupported​(boolean isSupported)
        Sets the value to be returned by isHearingAidCompatibilitySupported().
      • isDataConnectionAllowed

        @Implementation(minSdk=30)
        @HiddenApi
        protected boolean isDataConnectionAllowed()
      • setIsDataConnectionAllowed

        public void setIsDataConnectionAllowed​(boolean isDataConnectionAllowed)
      • sendVisualVoicemailSms

        @Implementation(minSdk=26)
        public void sendVisualVoicemailSms​(String number,
                                           int port,
                                           String text,
                                           PendingIntent sentIntent)