@Implements(value=android.telephony.TelephonyManager.class, looseSignatures=true) public class ShadowTelephonyManager extends Object
Modifier and Type | Field | Description |
---|---|---|
protected TelephonyManager |
realTelephonyManager |
Constructor | Description |
---|---|
ShadowTelephonyManager() |
Modifier and Type | Method | Description |
---|---|---|
void |
clearPhoneTypes() |
Removes all
subId to phoneType mappings. |
protected TelephonyManager |
createForPhoneAccountHandle(PhoneAccountHandle handle) |
Returns
null by default or the value specified via setTelephonyManagerForHandle(PhoneAccountHandle, TelephonyManager) . |
protected TelephonyManager |
createForSubscriptionId(int subId) |
Returns
null by default or the value specified via setTelephonyManagerForSubscriptionId(int, TelephonyManager) |
protected List<CellInfo> |
getAllCellInfo() |
|
protected int |
getCallState() |
Call state may be specified via
setCallState(int) . |
protected PersistableBundle |
getCarrierConfig() |
Returns a new empty
PersistableBundle by default, or the value specified via setCarrierConfig(PersistableBundle) . |
protected int |
getCarrierIdFromSimMccMnc() |
|
protected List<String> |
getCarrierPackageNamesForIntent(Intent intent) |
|
protected List<String> |
getCarrierPackageNamesForIntentAndPhone(Intent intent,
int phoneId) |
|
protected CellLocation |
getCellLocation() |
|
protected int |
getCurrentPhoneType(int subId) |
|
protected int |
getDataNetworkType() |
Returns whatever value was set by the last call to
setDataNetworkType(int) , defaulting to
TelephonyManager.NETWORK_TYPE_UNKNOWN if it was never called. |
protected int |
getDataState() |
Data state may be specified via
setDataState(int) . |
protected String |
getDeviceId() |
|
protected String |
getDeviceId(int slot) |
Returns
null by default or the value specified via setDeviceId(int, String) . |
int |
getEventFlags() |
Deprecated.
Avoid using.
|
protected String |
getGroupIdLevel1() |
|
protected String |
getImei() |
|
protected String |
getImei(int slotIndex) |
|
protected String |
getLine1Number() |
|
PhoneStateListener |
getListener() |
Deprecated.
Avoid using.
|
protected Iterable<PhoneStateListener> |
getListenersForFlags(int flags) |
|
protected String |
getMeid() |
|
protected String |
getMeid(int slotIndex) |
|
protected String |
getNetworkCountryIso() |
|
protected String |
getNetworkOperator() |
|
protected String |
getNetworkOperatorName() |
|
protected int |
getNetworkType() |
|
protected int |
getPhoneCount() |
Returns 1 by default or the value specified via
setPhoneCount(int) . |
protected int |
getPhoneType() |
|
List<String> |
getSentDialerSpecialCodes() |
Returns immutable list of special codes sent using
TelephonyManager.sendDialerSpecialCode(String) . |
protected ServiceState |
getServiceState() |
Returns
null by default or the value specified via setServiceState(ServiceState) |
protected SignalStrength |
getSignalStrength() |
|
protected int |
getSimCarrierId() |
|
protected String |
getSimCountryIso() |
|
protected String |
getSimCountryIso(int subId) |
|
protected Locale |
getSimLocale() |
Returns sim locale set by
setSimLocale(java.util.Locale) . |
protected String |
getSimOperator() |
|
protected String |
getSimOperatorName() |
|
protected String |
getSimSerialNumber() |
|
protected int |
getSimState() |
|
protected int |
getSimState(int slotIndex) |
|
protected String |
getSubscriberId() |
|
protected Object |
getUiccSlotsInfo() |
Returns the UICC slots information set by
setUiccSlotsInfo(java.lang.Object) . |
protected String |
getVisualVoicemailPackageName() |
Returns the value set by
setVisualVoicemailPackageName(String) . |
protected String |
getVoiceMailAlphaTag() |
Returns
null by default or the value specified via setVoiceMailAlphaTag(String) . |
protected String |
getVoiceMailNumber() |
Returns
null by default, or the value specified via setVoiceMailNumber(String) . |
protected Uri |
getVoicemailRingtoneUri(PhoneAccountHandle handle) |
Returns
null by default or the value specified via setVoicemailRingtoneUri(PhoneAccountHandle, Uri) . |
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. |
protected void |
initListener(PhoneStateListener listener,
int flags) |
|
protected boolean |
isDataEnabled() |
Implementation for
TelephonyManager.isDataEnabled() . |
protected boolean |
isEmergencyNumber(String number) |
|
protected boolean |
isHearingAidCompatibilitySupported() |
Implementation for
TelephonyManager.isHearingAidCompatibilitySupported() . |
protected boolean |
isNetworkRoaming() |
Returns
false by default or the value specified via setIsNetworkRoaming(boolean) |
protected boolean |
isPotentialEmergencyNumber(String number) |
|
protected boolean |
isRttSupported() |
Implementation for
TelephonyManager.isRttSupported() . |
protected boolean |
isSmsCapable() |
|
protected boolean |
isVoiceCapable() |
Returns
true by default or the value specified via setVoiceCapable(boolean) . |
protected boolean |
isVoicemailVibrationEnabled(PhoneAccountHandle handle) |
Returns
null by default or the value specified via setVoicemailVibrationEnabled(PhoneAccountHandle, boolean) . |
protected void |
listen(PhoneStateListener listener,
int flags) |
|
protected void |
requestCellInfoUpdate(Object cellInfoExecutor,
Object cellInfoCallback) |
Returns the value set by
setCallbackCellInfos(java.util.List<android.telephony.CellInfo>) , defaulting to calling the real TelephonyManager.NETWORK_TYPE_UNKNOWN if it was never called. |
void |
resetSimCountryIsos() |
Clears
subId to simCountryIso mapping and resets to default state. |
void |
resetSimStates() |
Clears
slotIndex to state mapping and resets to default state. |
void |
sendDialerSpecialCode(String inputCode) |
Implementation for
TelephonyManager.sendDialerSpecialCode(String) . |
void |
setAllCellInfo(List<CellInfo> allCellInfo) |
|
void |
setCallbackCellInfos(List<CellInfo> callbackCellInfos) |
Sets the value to be returned by calls to
requestCellInfoUpdate(java.lang.Object,java.lang.Object) . |
void |
setCallState(int callState) |
Sets the current call state to the desired state and updates any listeners.
|
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.
|
void |
setCarrierConfig(PersistableBundle carrierConfig) |
Sets the value returned by
TelephonyManager.getCarrierConfig() . |
void |
setCarrierIdFromSimMccMnc(int carrierIdFromSimMccMnc) |
Sets the value to be returned by
getCarrierIdFromSimMccMnc() . |
void |
setCarrierPackageNamesForPhone(int phoneId,
List<String> packages) |
Sets the
packages for the given phoneId . |
void |
setCellLocation(CellLocation cellLocation) |
|
void |
setCurrentPhoneType(int subId,
int phoneType) |
Sets the phone type for the given
subId . |
void |
setDataEnabled(boolean enabled) |
Implementation for
TelephonyManager.setDataEnabled(boolean) . |
void |
setDataNetworkType(int dataNetworkType) |
Sets the value to be returned by calls to
getDataNetworkType() . |
void |
setDataState(int dataState) |
Sets the data state returned by
getDataState() . |
void |
setDeviceId(int slot,
String deviceId) |
Sets the value returned by
TelephonyManager.getDeviceId(int) . |
void |
setDeviceId(String newDeviceId) |
|
void |
setGroupIdLevel1(String groupIdLevel1) |
|
void |
setHearingAidCompatibilitySupported(boolean isSupported) |
Sets the value to be returned by
isHearingAidCompatibilitySupported() . |
void |
setImei(int slotIndex,
String imei) |
Set the IMEI returned by
getImei(int) . |
void |
setImei(String imei) |
Set the IMEI returned by getImei().
|
void |
setIsNetworkRoaming(boolean isNetworkRoaming) |
Sets the value returned by
TelephonyManager.isNetworkRoaming() . |
void |
setIsSmsCapable(boolean isSmsCapable) |
Sets the value returned by
TelephonyManager.isSmsCapable() . |
void |
setLine1Number(String line1Number) |
|
void |
setMeid(int slotIndex,
String meid) |
Set the MEID returned by
getMeid(int) . |
void |
setMeid(String meid) |
Set the MEID returned by getMeid().
|
void |
setNetworkCountryIso(String networkCountryIso) |
|
void |
setNetworkOperator(String networkOperator) |
|
void |
setNetworkOperatorName(String networkOperatorName) |
|
void |
setNetworkType(int networkType) |
Deprecated.
TelephonyManager.getNetworkType() was replaced with TelephonyManager.getDataNetworkType() in Android N, and has been deprecated in Android R.
Use instead . |
void |
setPhoneCount(int phoneCount) |
Sets the value returned by
TelephonyManager.getPhoneCount() . |
void |
setPhoneType(int phoneType) |
|
void |
setReadPhoneStatePermission(boolean readPhoneStatePermission) |
|
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) . |
void |
setRttSupported(boolean isRttSupported) |
Sets the value to be returned by
isRttSupported() |
void |
setServiceState(ServiceState serviceState) |
Sets the value returned by
TelephonyManager.getServiceState() . |
void |
setSignalStrength(SignalStrength signalStrength) |
Sets the value to be returned by
getSignalStrength() |
void |
setSimCarrierId(int simCarrierId) |
Sets the value to be returned by
getSimCarrierId() . |
void |
setSimCountryIso(int subId,
String simCountryIso) |
Sets the
simCountryIso for the given subId . |
void |
setSimCountryIso(String simCountryIso) |
|
void |
setSimLocale(Locale simLocale) |
Sets the sim locale returned by
getSimLocale() . |
void |
setSimOperator(String simOperator) |
|
void |
setSimOperatorName(String simOperatorName) |
|
void |
setSimSerialNumber(String simSerialNumber) |
sets the serial number that will be returned by
getSimSerialNumber() . |
void |
setSimState(int simState) |
Sets the sim state of slot 0.
|
void |
setSimState(int slotIndex,
int state) |
Set the sim state for the given
slotIndex . |
void |
setSubscriberId(String subscriberId) |
Sets the value to be returned by
getSubscriberId() . |
void |
setTelephonyManagerForHandle(PhoneAccountHandle handle,
TelephonyManager telephonyManager) |
Sets the value returned by
TelephonyManager.createForPhoneAccountHandle(PhoneAccountHandle) . |
void |
setTelephonyManagerForSubscriptionId(int subscriptionId,
TelephonyManager telephonyManager) |
Sets the value returned by
TelephonyManager.createForSubscriptionId(int) . |
void |
setUiccSlotsInfo(Object uiccSlotsInfos) |
Sets the UICC slots information returned by
getUiccSlotsInfo() . |
void |
setVisualVoicemailPackageName(String visualVoicemailPackageName) |
Sets the value to be returned by
getVisualVoicemailPackageName() . |
void |
setVoiceCapable(boolean voiceCapable) |
Sets the value returned by
isVoiceCapable() . |
void |
setVoiceMailAlphaTag(String voiceMailAlphaTag) |
Sets the value returned by
TelephonyManager.getVoiceMailAlphaTag() . |
void |
setVoiceMailNumber(String voiceMailNumber) |
Sets the value returned by
TelephonyManager.getVoiceMailNumber() . |
protected void |
setVoicemailRingtoneUri(PhoneAccountHandle handle,
Uri uri) |
Sets the value returned by
TelephonyManager.getVoicemailRingtoneUri(PhoneAccountHandle) . |
protected void |
setVoicemailVibrationEnabled(PhoneAccountHandle handle,
boolean isEnabled) |
Sets the value returned by
TelephonyManager.isVoicemailVibrationEnabled(PhoneAccountHandle) . |
void |
setVoiceNetworkType(int voiceNetworkType) |
Sets the value to be returned by calls to
getVoiceNetworkType() . |
@RealObject protected TelephonyManager realTelephonyManager
@Implementation protected void listen(PhoneStateListener listener, int flags)
@Deprecated public PhoneStateListener getListener()
@Deprecated public int getEventFlags()
@Implementation protected int getCallState()
setCallState(int)
.public void setCallState(int callState)
public void setCallState(int callState, String incomingPhoneNumber)
@Implementation protected int getDataState()
setDataState(int)
. If no override is set, this
defaults to TelephonyManager.DATA_DISCONNECTED
.public void setDataState(int dataState)
getDataState()
.@Implementation protected String getDeviceId()
public void setDeviceId(String newDeviceId)
public void setNetworkOperatorName(String networkOperatorName)
@Implementation(minSdk=21) protected String getImei()
@Implementation(minSdk=26) protected String getImei(int slotIndex)
public void setImei(String imei)
public void setImei(int slotIndex, String imei)
getImei(int)
.@Implementation(minSdk=26) protected String getMeid()
@Implementation(minSdk=26) protected String getMeid(int slotIndex)
public void setMeid(String meid)
public void setMeid(int slotIndex, String meid)
getMeid(int)
.@Implementation protected String getNetworkOperatorName()
public void setNetworkCountryIso(String networkCountryIso)
@Implementation protected String getNetworkCountryIso()
public void setSimLocale(Locale simLocale)
getSimLocale()
.@Implementation(minSdk=29) protected Locale getSimLocale()
setSimLocale(java.util.Locale)
.public void setNetworkOperator(String networkOperator)
@Implementation protected String getNetworkOperator()
@Implementation protected String getSimOperator()
public void setSimOperator(String simOperator)
@Implementation protected String getSimOperatorName()
public void setSimOperatorName(String simOperatorName)
@Implementation protected String getSimSerialNumber()
public void setSimSerialNumber(String simSerialNumber)
getSimSerialNumber()
.@Implementation protected String getSimCountryIso()
@Implementation(minSdk=24) @HiddenApi protected String getSimCountryIso(int subId)
public void setSimCountryIso(String simCountryIso)
public void setSimCountryIso(int subId, String simCountryIso)
simCountryIso
for the given subId
.public void resetSimCountryIsos()
subId
to simCountryIso mapping and resets to default state.@Implementation protected int getSimState()
public void setSimState(int simState)
public void setSimState(int slotIndex, int state)
slotIndex
.@Implementation(minSdk=26) protected int getSimState(int slotIndex)
public void setUiccSlotsInfo(Object uiccSlotsInfos)
getUiccSlotsInfo()
.@Implementation(minSdk=28) @HiddenApi protected Object getUiccSlotsInfo()
setUiccSlotsInfo(java.lang.Object)
.public void resetSimStates()
slotIndex
to state mapping and resets to default state.public void setReadPhoneStatePermission(boolean readPhoneStatePermission)
@Implementation protected int getPhoneType()
public void setPhoneType(int phoneType)
@Implementation protected String getLine1Number()
public void setLine1Number(String line1Number)
@Implementation protected int getNetworkType()
@Deprecated public void setNetworkType(int networkType)
TelephonyManager.getNetworkType()
was replaced with TelephonyManager.getDataNetworkType()
in Android N, and has been deprecated in Android R.
Use instead
.@Implementation(minSdk=24) protected int getDataNetworkType()
setDataNetworkType(int)
, defaulting to
TelephonyManager.NETWORK_TYPE_UNKNOWN
if it was never called.public void setDataNetworkType(int dataNetworkType)
getDataNetworkType()
. This should
correspond to one of the NETWORK_TYPE_*
constants defined on TelephonyManager
,
but this is not enforced.@Implementation(minSdk=24) protected int getVoiceNetworkType()
setVoiceNetworkType(int)
, defaulting to
TelephonyManager.NETWORK_TYPE_UNKNOWN
if it was never called.public void setVoiceNetworkType(int voiceNetworkType)
getVoiceNetworkType()
. This should
correspond to one of the NETWORK_TYPE_*
constants defined on TelephonyManager
,
but this is not enforced.@Implementation(minSdk=17) protected List<CellInfo> getAllCellInfo()
@Implementation(minSdk=29) protected void requestCellInfoUpdate(Object cellInfoExecutor, Object cellInfoCallback)
setCallbackCellInfos(java.util.List<android.telephony.CellInfo>)
, defaulting to calling the real TelephonyManager.NETWORK_TYPE_UNKNOWN
if it was never called.public void setCallbackCellInfos(List<CellInfo> callbackCellInfos)
requestCellInfoUpdate(java.lang.Object,java.lang.Object)
. Note that it does not
set the value to be returned by calls to getAllCellInfo()
; for that, see
setAllCellInfo(java.util.List<android.telephony.CellInfo>)
.public void setRequestCellInfoUpdateErrorValues(int errorCode, Throwable detail)
requestCellInfoUpdate(java.lang.Object,java.lang.Object)
.
These values will persist until cleared: to clear, set (0, null) using this method.@Implementation protected CellLocation getCellLocation()
public void setCellLocation(CellLocation cellLocation)
@Implementation(minSdk=18) protected String getGroupIdLevel1()
public void setGroupIdLevel1(String groupIdLevel1)
protected void initListener(PhoneStateListener listener, int flags)
protected Iterable<PhoneStateListener> getListenersForFlags(int flags)
@Implementation protected boolean isSmsCapable()
setIsSmsCapable(boolean)
public void setIsSmsCapable(boolean isSmsCapable)
TelephonyManager.isSmsCapable()
.@Implementation(minSdk=26) protected PersistableBundle getCarrierConfig()
PersistableBundle
by default, or the value specified via setCarrierConfig(PersistableBundle)
.public void setCarrierConfig(PersistableBundle carrierConfig)
TelephonyManager.getCarrierConfig()
.carrierConfig
- @Implementation protected String getVoiceMailNumber()
null
by default, or the value specified via setVoiceMailNumber(String)
.public void setVoiceMailNumber(String voiceMailNumber)
TelephonyManager.getVoiceMailNumber()
.@Implementation protected String getVoiceMailAlphaTag()
null
by default or the value specified via setVoiceMailAlphaTag(String)
.public void setVoiceMailAlphaTag(String voiceMailAlphaTag)
TelephonyManager.getVoiceMailAlphaTag()
.@Implementation(minSdk=23) protected int getPhoneCount()
setPhoneCount(int)
.public void setPhoneCount(int phoneCount)
TelephonyManager.getPhoneCount()
.@Implementation(minSdk=23) protected String getDeviceId(int slot)
null
by default or the value specified via setDeviceId(int, String)
.public void setDeviceId(int slot, String deviceId)
TelephonyManager.getDeviceId(int)
.@Implementation(minSdk=22) protected boolean isVoiceCapable()
true
by default or the value specified via setVoiceCapable(boolean)
.public void setVoiceCapable(boolean voiceCapable)
isVoiceCapable()
.@Implementation(minSdk=24) protected boolean isVoicemailVibrationEnabled(PhoneAccountHandle handle)
null
by default or the value specified via setVoicemailVibrationEnabled(PhoneAccountHandle, boolean)
.@Implementation(minSdk=26) protected void setVoicemailVibrationEnabled(PhoneAccountHandle handle, boolean isEnabled)
TelephonyManager.isVoicemailVibrationEnabled(PhoneAccountHandle)
.@Implementation(minSdk=24) protected Uri getVoicemailRingtoneUri(PhoneAccountHandle handle)
null
by default or the value specified via setVoicemailRingtoneUri(PhoneAccountHandle, Uri)
.@Implementation(minSdk=26) protected void setVoicemailRingtoneUri(PhoneAccountHandle handle, Uri uri)
TelephonyManager.getVoicemailRingtoneUri(PhoneAccountHandle)
.@Implementation(minSdk=26) protected TelephonyManager createForPhoneAccountHandle(PhoneAccountHandle handle)
null
by default or the value specified via setTelephonyManagerForHandle(PhoneAccountHandle, TelephonyManager)
.public void setTelephonyManagerForHandle(PhoneAccountHandle handle, TelephonyManager telephonyManager)
TelephonyManager.createForPhoneAccountHandle(PhoneAccountHandle)
.@Implementation(minSdk=24) protected TelephonyManager createForSubscriptionId(int subId)
null
by default or the value specified via setTelephonyManagerForSubscriptionId(int, TelephonyManager)
public void setTelephonyManagerForSubscriptionId(int subscriptionId, TelephonyManager telephonyManager)
TelephonyManager.createForSubscriptionId(int)
.@Implementation(minSdk=26) protected ServiceState getServiceState()
null
by default or the value specified via setServiceState(ServiceState)
public void setServiceState(ServiceState serviceState)
TelephonyManager.getServiceState()
.@Implementation protected boolean isNetworkRoaming()
false
by default or the value specified via setIsNetworkRoaming(boolean)
public void setIsNetworkRoaming(boolean isNetworkRoaming)
TelephonyManager.isNetworkRoaming()
.@Implementation(minSdk=23) @HiddenApi protected int getCurrentPhoneType(int subId)
public void setCurrentPhoneType(int subId, int phoneType)
subId
.public void clearPhoneTypes()
subId
to phoneType
mappings.@Implementation(minSdk=23) @HiddenApi protected List<String> getCarrierPackageNamesForIntentAndPhone(Intent intent, int phoneId)
@Implementation(minSdk=21) @HiddenApi protected List<String> getCarrierPackageNamesForIntent(Intent intent)
public void setCarrierPackageNamesForPhone(int phoneId, List<String> packages)
packages
for the given phoneId
.@Implementation(minSdk=29) protected int getCarrierIdFromSimMccMnc()
public void setCarrierIdFromSimMccMnc(int carrierIdFromSimMccMnc)
getCarrierIdFromSimMccMnc()
.@Implementation(minSdk=28) protected int getSimCarrierId()
public void setSimCarrierId(int simCarrierId)
getSimCarrierId()
.@Implementation protected String getSubscriberId()
public void setSubscriberId(String subscriberId)
getSubscriberId()
.@Implementation(minSdk=26) protected String getVisualVoicemailPackageName()
setVisualVoicemailPackageName(String)
.public void setVisualVoicemailPackageName(String visualVoicemailPackageName)
getVisualVoicemailPackageName()
.@Implementation(minSdk=28) protected SignalStrength getSignalStrength()
public void setSignalStrength(SignalStrength signalStrength)
getSignalStrength()
@Implementation(minSdk=29) protected boolean isEmergencyNumber(String number)
PhoneNumberUtils.isEmergencyNumberInternal(java.lang.String, boolean)
.
TODO(b/122324733) need better implementation@Implementation(minSdk=29) protected boolean isPotentialEmergencyNumber(String number)
@Implementation(minSdk=26) protected boolean isDataEnabled()
TelephonyManager.isDataEnabled()
.TelephonyManager.setDataEnabled(boolean)
.@Implementation(minSdk=26) public void setDataEnabled(boolean enabled)
TelephonyManager.setDataEnabled(boolean)
. Marked as public in order to allow
it to be used as a test API.@Implementation(minSdk=29) protected boolean isRttSupported()
TelephonyManager.isRttSupported()
.setRttSupported(boolean)
.public void setRttSupported(boolean isRttSupported)
isRttSupported()
@Implementation(minSdk=26) public void sendDialerSpecialCode(String inputCode)
TelephonyManager.sendDialerSpecialCode(String)
.inputCode
- special code to be sent.public List<String> getSentDialerSpecialCodes()
TelephonyManager.sendDialerSpecialCode(String)
. Special codes contained in the list are in the
order they were sent.public void setHearingAidCompatibilitySupported(boolean isSupported)
isHearingAidCompatibilitySupported()
.@Implementation(minSdk=23) protected boolean isHearingAidCompatibilitySupported()
TelephonyManager.isHearingAidCompatibilitySupported()
.setHearingAidCompatibilitySupported(boolean)
.