@Implements(value=android.telephony.TelephonyManager.class, looseSignatures=true) public class ShadowTelephonyManager extends Object
Modifier and Type | Field and Description |
---|---|
protected TelephonyManager |
realTelephonyManager |
Constructor and Description |
---|
ShadowTelephonyManager() |
Modifier and Type | Method and 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 List<String> |
getCarrierPackageNamesForIntent(Intent intent) |
protected List<String> |
getCarrierPackageNamesForIntentAndPhone(Intent intent,
int phoneId) |
protected CellLocation |
getCellLocation() |
protected int |
getCurrentPhoneType(int subId) |
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 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() |
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 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 boolean |
isCurrentEmergencyNumber(String number)
|
protected boolean |
isCurrentPotentialEmergencyNumber(String number) |
protected boolean |
isDataEnabled()
Implementation for
TelephonyManager.isDataEnabled() . |
protected boolean |
isNetworkRoaming()
Returns
false by default or the value specified via setIsNetworkRoaming(boolean) |
protected boolean |
isSmsCapable() |
protected boolean |
isVoicemailVibrationEnabled(PhoneAccountHandle handle)
Returns
null by default or the value specified via setVoicemailVibrationEnabled(PhoneAccountHandle, boolean) . |
protected void |
listen(PhoneStateListener listener,
int flags) |
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 |
setAllCellInfo(List<CellInfo> allCellInfo) |
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 |
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 . |
protected void |
setDataEnabled(boolean enabled)
Implementation for
TelephonyManager.setDataEnabled(boolean) . |
void |
setDeviceId(int slot,
String deviceId)
Sets the value returned by
TelephonyManager.getDeviceId(int) . |
void |
setDeviceId(String newDeviceId) |
void |
setGroupIdLevel1(String groupIdLevel1) |
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) |
void |
setPhoneCount(int phoneCount)
Sets the value returned by
TelephonyManager.getPhoneCount() . |
void |
setPhoneType(int phoneType) |
void |
setReadPhoneStatePermission(boolean readPhoneStatePermission) |
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 |
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 |
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()
Returns the most recent listener passed to #listen().
@Deprecated public int getEventFlags()
Returns the most recent flags passed to #listen().
@Implementation protected int getCallState()
Call state may be specified via setCallState(int)
.
public void setCallState(int callState)
Sets the current call state to the desired state and updates any listeners.
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.
@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)
Set the IMEI returned by getImei().
public void setImei(int slotIndex, String imei)
Set the IMEI returned by getImei(int)
.
@Implementation(minSdk=26) protected String getMeid()
@Implementation(minSdk=26) protected String getMeid(int slotIndex)
public void setMeid(String meid)
Set the MEID returned by getMeid().
public void setMeid(int slotIndex, String meid)
Set the MEID returned by getMeid(int)
.
@Implementation protected String getNetworkOperatorName()
public void setNetworkCountryIso(String networkCountryIso)
@Implementation protected String getNetworkCountryIso()
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)
sets the serial number that will be returned by 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)
Sets the simCountryIso
for the given subId
.
public void resetSimCountryIsos()
Clears subId
to simCountryIso mapping and resets to default state.
@Implementation protected int getSimState()
public void setSimState(int simState)
Sets the sim state of slot 0.
public void setSimState(int slotIndex, int state)
Set the sim state for the given slotIndex
.
@Implementation(minSdk=26) protected int getSimState(int slotIndex)
public void setUiccSlotsInfo(Object uiccSlotsInfos)
Sets the UICC slots information returned by getUiccSlotsInfo()
.
@Implementation(minSdk=28) @HiddenApi protected Object getUiccSlotsInfo()
Returns the UICC slots information set by setUiccSlotsInfo(java.lang.Object)
.
public void resetSimStates()
Clears 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()
public void setNetworkType(int networkType)
@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.
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.
@Implementation(minSdk=17) protected List<CellInfo> getAllCellInfo()
@Implementation protected CellLocation getCellLocation()
public void setCellLocation(CellLocation cellLocation)
@Implementation(minSdk=18) protected String getGroupIdLevel1()
public void setGroupIdLevel1(String groupIdLevel1)
@Implementation protected boolean isSmsCapable()
true
by default, or the value specified via setIsSmsCapable(boolean)
public void setIsSmsCapable(boolean isSmsCapable)
Sets the value returned by TelephonyManager.isSmsCapable()
.
@Implementation(minSdk=26) protected PersistableBundle getCarrierConfig()
Returns a new empty PersistableBundle
by default, or the value specified via setCarrierConfig(PersistableBundle)
.
public void setCarrierConfig(PersistableBundle carrierConfig)
Sets the value returned by TelephonyManager.getCarrierConfig()
.
carrierConfig
- @Implementation protected String getVoiceMailNumber()
Returns null
by default, or the value specified via setVoiceMailNumber(String)
.
public void setVoiceMailNumber(String voiceMailNumber)
Sets the value returned by TelephonyManager.getVoiceMailNumber()
.
@Implementation protected String getVoiceMailAlphaTag()
Returns null
by default or the value specified via setVoiceMailAlphaTag(String)
.
public void setVoiceMailAlphaTag(String voiceMailAlphaTag)
Sets the value returned by TelephonyManager.getVoiceMailAlphaTag()
.
@Implementation(minSdk=23) protected int getPhoneCount()
Returns 1 by default or the value specified via setPhoneCount(int)
.
public void setPhoneCount(int phoneCount)
Sets the value returned by TelephonyManager.getPhoneCount()
.
@Implementation(minSdk=23) protected String getDeviceId(int slot)
Returns null
by default or the value specified via setDeviceId(int, String)
.
public void setDeviceId(int slot, String deviceId)
Sets the value returned by TelephonyManager.getDeviceId(int)
.
@Implementation(minSdk=24) protected boolean isVoicemailVibrationEnabled(PhoneAccountHandle handle)
Returns null
by default or the value specified via setVoicemailVibrationEnabled(PhoneAccountHandle, boolean)
.
@Implementation(minSdk=26) protected void setVoicemailVibrationEnabled(PhoneAccountHandle handle, boolean isEnabled)
Sets the value returned by TelephonyManager.isVoicemailVibrationEnabled(PhoneAccountHandle)
.
@Implementation(minSdk=24) protected Uri getVoicemailRingtoneUri(PhoneAccountHandle handle)
Returns null
by default or the value specified via setVoicemailRingtoneUri(PhoneAccountHandle, Uri)
.
@Implementation(minSdk=26) protected void setVoicemailRingtoneUri(PhoneAccountHandle handle, Uri uri)
Sets the value returned by TelephonyManager.getVoicemailRingtoneUri(PhoneAccountHandle)
.
@Implementation(minSdk=26) protected TelephonyManager createForPhoneAccountHandle(PhoneAccountHandle handle)
Returns null
by default or the value specified via setTelephonyManagerForHandle(PhoneAccountHandle, TelephonyManager)
.
public void setTelephonyManagerForHandle(PhoneAccountHandle handle, TelephonyManager telephonyManager)
Sets the value returned by TelephonyManager.createForPhoneAccountHandle(PhoneAccountHandle)
.
@Implementation(minSdk=24) protected TelephonyManager createForSubscriptionId(int subId)
Returns null
by default or the value specified via setTelephonyManagerForSubscriptionId(int, TelephonyManager)
public void setTelephonyManagerForSubscriptionId(int subscriptionId, TelephonyManager telephonyManager)
Sets the value returned by TelephonyManager.createForSubscriptionId(int)
.
@Implementation(minSdk=26) protected ServiceState getServiceState()
Returns null
by default or the value specified via setServiceState(ServiceState)
public void setServiceState(ServiceState serviceState)
Sets the value returned by TelephonyManager.getServiceState()
.
@Implementation protected boolean isNetworkRoaming()
Returns false
by default or the value specified via setIsNetworkRoaming(boolean)
public void setIsNetworkRoaming(boolean isNetworkRoaming)
Sets the value returned by TelephonyManager.isNetworkRoaming()
.
@Implementation(minSdk=23) @HiddenApi protected int getCurrentPhoneType(int subId)
public void setCurrentPhoneType(int subId, int phoneType)
Sets the phone type for the given subId
.
public void clearPhoneTypes()
Removes all 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)
Sets the packages
for the given phoneId
.
@Implementation(minSdk=28) protected int getSimCarrierId()
public void setSimCarrierId(int simCarrierId)
Sets the value to be returned by getSimCarrierId()
.
@Implementation protected String getSubscriberId()
public void setSubscriberId(String subscriberId)
Sets the value to be returned by getSubscriberId()
.
@Implementation(minSdk=26) protected String getVisualVoicemailPackageName()
Returns the value set by setVisualVoicemailPackageName(String)
.
public void setVisualVoicemailPackageName(String visualVoicemailPackageName)
Sets the value to be returned by getVisualVoicemailPackageName()
.
@Implementation(minSdk=28) protected SignalStrength getSignalStrength()
public void setSignalStrength(SignalStrength signalStrength)
Sets the value to be returned by getSignalStrength()
@Implementation(minSdk=10000) protected boolean isCurrentEmergencyNumber(String number)
Cribbed from PhoneNumberUtils.isEmergencyNumberInternal(java.lang.String, boolean)
.
TODO(b/122324733) need better implementation
@Implementation(minSdk=10000) protected boolean isCurrentPotentialEmergencyNumber(String number)
@Implementation(minSdk=26) protected boolean isDataEnabled()
Implementation for TelephonyManager.isDataEnabled()
.
TelephonyManager.setDataEnabled(boolean)
.@Implementation(minSdk=26) protected void setDataEnabled(boolean enabled)
Implementation for TelephonyManager.setDataEnabled(boolean)
.