public class

CMTelephonyManager

extends Object
java.lang.Object
   ↳ cyanogenmod.app.CMTelephonyManager

Class Overview

The CMTelephonyManager allows you to view and manage the phone state and the data connection, with multiple SIMs support.

To get the instance of this class, utilize CMTelephonyManager#getInstance(Context context)

Summary

Constants
int ASK_FOR_SUBSCRIPTION_ID Subscription ID used to set the default Phone and SMS to "ask every time".
Public Methods
static CMTelephonyManager getInstance(Context context)
Get or create an instance of the CMTelephonyManager
List<SubscriptionInfo> getSubInformation()
Gets the list of SubscriptionInfo that are registered on the phone.
boolean isDataConnectionEnabled()
Checks if the network data connection is enabled.
boolean isDataConnectionSelectedOnSub(int subId)
Checks if the received subscription received has the data connection enabled.
boolean isSubActive(int subId)
Returns the state of the SIM by subscription ID.
void setDataConnectionState(boolean state)
Sets the network data conection active or inactive.
void setDefaultPhoneSub(int subId)
Sets the default phone used to make phone calls as the one received on subId.
void setDefaultSmsSub(int subId)
Sets the default phone used to send SMS as the one received on subId.
void setSubState(int subId, boolean state)
Sets the state of one of the SIMs by subscription ID.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ASK_FOR_SUBSCRIPTION_ID

Added in API level 2

Subscription ID used to set the default Phone and SMS to "ask every time".

Constant Value: 0 (0x00000000)

Public Methods

public static CMTelephonyManager getInstance (Context context)

Added in API level 2

Get or create an instance of the CMTelephonyManager

public List<SubscriptionInfo> getSubInformation ()

Added in API level 2

Gets the list of SubscriptionInfo that are registered on the phone.

Returns
  • The list of SIM subscriptions. The returning list can be null or empty.
See Also

public boolean isDataConnectionEnabled ()

Added in API level 2

Checks if the network data connection is enabled. This method will return true (or false if inactive) even when an internet connection is active through Wifi/BT.

Returns
  • true if the network data connection is enabled, false otherwise.

public boolean isDataConnectionSelectedOnSub (int subId)

Added in API level 2

Checks if the received subscription received has the data connection enabled. This method will return true (or false if inactive on the SIM) even when an internet connection is active through Wifi/BT. If the subscription ID is not valid the method will return false.

Parameters
subId The subscription ID to query.
Returns
  • true if the data connection is enabled on the SIM, false otherwise.

public boolean isSubActive (int subId)

Added in API level 2

Returns the state of the SIM by subscription ID. If the subscription ID is not valid the method will return false.

Parameters
subId The subscription ID to query.
Returns
  • true if the SIM is activated (even without signal or requesting the PIN/PUK), false otherwise.

public void setDataConnectionState (boolean state)

Added in API level 2

Sets the network data conection active or inactive.

Parameters
state If true enables the network data connection, if false disables it.

public void setDefaultPhoneSub (int subId)

Added in API level 2

Sets the default phone used to make phone calls as the one received on subId. If ASK_FOR_SUBSCRIPTION_ID is used as a parameter, then the option to choose what SIM to use is selected.

Parameters
subId The subscription to set as default for phone calls. To select SIM when calling use ASK_FOR_SUBSCRIPTION_ID.

public void setDefaultSmsSub (int subId)

Added in API level 2

Sets the default phone used to send SMS as the one received on subId. If ASK_FOR_SUBSCRIPTION_ID is used as a parameter, then the option to choose what SIM to use is selected.

Parameters
subId The subscription to set as default for sending SMS. To select SIM when sending SMS use ASK_FOR_SUBSCRIPTION_ID.

public void setSubState (int subId, boolean state)

Added in API level 2

Sets the state of one of the SIMs by subscription ID. If the subscription ID is not valid or the SIM already is in the desired state the method will do nothing.

Parameters
subId The subscription ID to change the state.
state true to activate the SIM, false to disable.