diff options
Diffstat (limited to 'telephony/java/android/telephony/TelephonyManager.java')
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 138 |
1 files changed, 75 insertions, 63 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 82e612073df7..55983d19a385 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -21,30 +21,31 @@ import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; -import android.telephony.CellLocation; +import android.telephony.CellLocation; import com.android.internal.telephony.IPhoneSubInfo; import com.android.internal.telephony.ITelephony; import com.android.internal.telephony.ITelephonyRegistry; +import com.android.internal.telephony.RILConstants; import com.android.internal.telephony.TelephonyProperties; /** * Provides access to information about the telephony services on * the device. Applications can use the methods in this class to * determine telephony services and states, as well as to access some - * types of subscriber information. Applications can also register - * a listener to receive notification of telephony state changes. + * types of subscriber information. Applications can also register + * a listener to receive notification of telephony state changes. * <p> * You do not instantiate this class directly; instead, you retrieve - * a reference to an instance through + * a reference to an instance through * {@link android.content.Context#getSystemService * Context.getSystemService(Context.TELEPHONY_SERVICE)}. * <p> * Note that acess to some telephony information is - * permission-protected. Your application cannot access the protected - * information unless it has the appropriate permissions declared in - * its manifest file. Where permissions apply, they are noted in the - * the methods through which you access the protected information. + * permission-protected. Your application cannot access the protected + * information unless it has the appropriate permissions declared in + * its manifest file. Where permissions apply, they are noted in the + * the methods through which you access the protected information. */ public class TelephonyManager { private static final String TAG = "TelephonyManager"; @@ -77,10 +78,10 @@ public class TelephonyManager { // /** - * Returns the software version number for the device, for example, + * Returns the software version number for the device, for example, * the IMEI/SV for GSM phones. * - * <p>Requires Permission: + * <p>Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getDeviceSoftwareVersion() { @@ -92,10 +93,10 @@ public class TelephonyManager { } /** - * Returns the unique device ID, for example,the IMEI for GSM + * Returns the unique device ID, for example, the IMEI for GSM and the MEID for CDMA * phones. * - * <p>Requires Permission: + * <p>Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getDeviceId() { @@ -115,9 +116,7 @@ public class TelephonyManager { public CellLocation getCellLocation() { try { Bundle bundle = getITelephony().getCellLocation(); - // TODO remove cdma and gsmCellLocation make CellLocation - // active and define different impl in the phone - return CellLocation.newFromBundle(bundle); + return CellLocation.newFromBundle(bundle); } catch (RemoteException ex) { } return null; @@ -127,7 +126,7 @@ public class TelephonyManager { * Enables location update notifications. {@link PhoneStateListener#onCellLocationChanged * PhoneStateListener.onCellLocationChanged} will be called on location updates. * - * <p>Requires Permission: {@link android.Manifest.permission#CONTROL_LOCATION_UPDATES + * <p>Requires Permission: {@link android.Manifest.permission#CONTROL_LOCATION_UPDATES * CONTROL_LOCATION_UPDATES} * * @hide @@ -166,23 +165,36 @@ public class TelephonyManager { public static final int PHONE_TYPE_GSM = 1; /** - * Returns a constant indicating the device phone type. - * + * CDMA phone + */ + public static final int PHONE_TYPE_CDMA = 2; + + /** + * Returns a constant indicating the device phone type. + * * @see #PHONE_TYPE_NONE * @see #PHONE_TYPE_GSM + * @see #PHONE_TYPE_CDMA */ public int getPhoneType() { - // in the future, we should really check this - return PHONE_TYPE_GSM; + try{ + if(getITelephony().getActivePhoneType() == RILConstants.CDMA_PHONE) { + return PHONE_TYPE_CDMA; + } else { + return PHONE_TYPE_GSM; + } + }catch(RemoteException ex){ + return PHONE_TYPE_NONE; + } } // - // + // // Current Network // // - /** + /** * Returns the alphabetic name of current registered operator. * <p> * Availability: Only when user is registered to a network @@ -191,7 +203,7 @@ public class TelephonyManager { return SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_ALPHA); } - /** + /** * Returns the numeric name (MCC+MNC) of current registered operator. * <p> * Availability: Only when user is registered to a network @@ -200,7 +212,7 @@ public class TelephonyManager { return SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC); } - /** + /** * Returns true if the device is considered roaming on the current * network, for GSM purposes. * <p> @@ -210,7 +222,7 @@ public class TelephonyManager { return "true".equals(SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_ISROAMING)); } - /** + /** * Returns the ISO country code equivilent of the current registered * operator's MCC (Mobile Country Code). * <p> @@ -237,7 +249,7 @@ public class TelephonyManager { public static final int NETWORK_TYPE_1xRTT = 7; /** - * Returns a constant indicating the radio technology (network type) + * Returns a constant indicating the radio technology (network type) * currently in use on the device. * * @see #NETWORK_TYPE_UNKNOWN @@ -285,7 +297,7 @@ public class TelephonyManager { /** SIM card state: Unknown. Signifies that the SIM is in transition * between states. For example, when the user inputs the SIM pin - * under PIN_REQUIRED state, a query for sim status returns + * under PIN_REQUIRED state, a query for sim status returns * this state before turning to SIM_STATE_READY. */ public static final int SIM_STATE_UNKNOWN = 0; /** SIM card state: no SIM card is available in the device */ @@ -298,11 +310,11 @@ public class TelephonyManager { public static final int SIM_STATE_NETWORK_LOCKED = 4; /** SIM card state: Ready */ public static final int SIM_STATE_READY = 5; - - /** - * Returns a constant indicating the state of the + + /** + * Returns a constant indicating the state of the * device SIM card. - * + * * @see #SIM_STATE_UNKNOWN * @see #SIM_STATE_ABSENT * @see #SIM_STATE_PIN_REQUIRED @@ -332,7 +344,7 @@ public class TelephonyManager { } } - /** + /** * Returns the MCC+MNC (mobile country code + mobile network code) of the * provider of the SIM. 5 or 6 decimal digits. * <p> @@ -341,31 +353,31 @@ public class TelephonyManager { * @see #getSimState */ public String getSimOperator() { - return SystemProperties.get(TelephonyProperties.PROPERTY_SIM_OPERATOR_NUMERIC); + return SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC); } - /** - * Returns the Service Provider Name (SPN). + /** + * Returns the Service Provider Name (SPN). * <p> * Availability: SIM state must be {@link #SIM_STATE_READY} * * @see #getSimState */ public String getSimOperatorName() { - return SystemProperties.get(TelephonyProperties.PROPERTY_SIM_OPERATOR_ALPHA); + return SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA); } - /** + /** * Returns the ISO country code equivalent for the SIM provider's country code. */ public String getSimCountryIso() { - return SystemProperties.get(TelephonyProperties.PROPERTY_SIM_OPERATOR_ISO_COUNTRY); + return SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY); } /** * Returns the serial number of the SIM, if applicable. * <p> - * Requires Permission: + * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getSimSerialNumber() { @@ -385,7 +397,7 @@ public class TelephonyManager { /** * Returns the unique subscriber ID, for example, the IMSI for a GSM phone. * <p> - * Requires Permission: + * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getSubscriberId() { @@ -397,10 +409,10 @@ public class TelephonyManager { } /** - * Returns the phone number string for line 1, for example, the MSISDN + * Returns the phone number string for line 1, for example, the MSISDN * for a GSM phone. * <p> - * Requires Permission: + * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getLine1Number() { @@ -412,9 +424,9 @@ public class TelephonyManager { } /** - * Returns the alphabetic identifier associated with the line 1 number. + * Returns the alphabetic identifier associated with the line 1 number. * <p> - * Requires Permission: + * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} * @hide * nobody seems to call this. @@ -430,7 +442,7 @@ public class TelephonyManager { /** * Returns the voice mail number. * <p> - * Requires Permission: + * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getVoiceMailNumber() { @@ -445,7 +457,7 @@ public class TelephonyManager { * Retrieves the alphabetic identifier associated with the voice * mail number. * <p> - * Requires Permission: + * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getVoiceMailAlphaTag() { @@ -465,10 +477,10 @@ public class TelephonyManager { /** Device call state: No activity. */ public static final int CALL_STATE_IDLE = 0; /** Device call state: Ringing. A new call arrived and is - * ringing or waiting. In the latter case, another call is + * ringing or waiting. In the latter case, another call is * already active. */ public static final int CALL_STATE_RINGING = 1; - /** Device call state: Off-hook. At least one call exists + /** Device call state: Off-hook. At least one call exists * that is dialing, active, or on hold, and no calls are ringing * or waiting. */ public static final int CALL_STATE_OFFHOOK = 2; @@ -519,13 +531,13 @@ public class TelephonyManager { public static final int DATA_CONNECTING = 1; /** Data connection state: Connected. IP traffic should be available. */ public static final int DATA_CONNECTED = 2; - /** Data connection state: Suspended. The connection is up, but IP - * traffic is temporarily unavailable. For example, in a 2G network, + /** Data connection state: Suspended. The connection is up, but IP + * traffic is temporarily unavailable. For example, in a 2G network, * data activity may be suspended when a voice call arrives. */ public static final int DATA_SUSPENDED = 3; /** - * Returns a constant indicating the current data connection state + * Returns a constant indicating the current data connection state * (cellular). * * @see #DATA_DISCONNECTED @@ -553,26 +565,26 @@ public class TelephonyManager { // /** - * Registers a listener object to receive notification of changes - * in specified telephony states. + * Registers a listener object to receive notification of changes + * in specified telephony states. * <p> * To register a listener, pass a {@link PhoneStateListener} - * and specify at least one telephony state of interest in - * the events argument. - * + * and specify at least one telephony state of interest in + * the events argument. + * * At registration, and when a specified telephony state - * changes, the telephony manager invokes the appropriate - * callback method on the listener object and passes the + * changes, the telephony manager invokes the appropriate + * callback method on the listener object and passes the * current (udpated) values. * <p> * To unregister a listener, pass the listener object and set the - * events argument to + * events argument to * {@link PhoneStateListener#LISTEN_NONE LISTEN_NONE} (0). - * + * * @param listener The {@link PhoneStateListener} object to register * (or unregister) * @param events The telephony state(s) of interest to the listener, - * as a bitwise-OR combination of {@link PhoneStateListener} + * as a bitwise-OR combination of {@link PhoneStateListener} * LISTEN_ flags. */ public void listen(PhoneStateListener listener, int events) { @@ -624,8 +636,8 @@ public class TelephonyManager { * These have not been implemented because they're not public IMHO. -joeo */ - /* - * Baseband version + /* + * Baseband version * Availability: property is available any time radio is on */ /* |