Add Phone.getPhoneType() operation.

This routine returns integer values defined in the Phone interface,
derived from RILConstants values.  Direct references to the
RILConstants are replaced by references to these new ones for
consistency.

API CHANGE:
  unhide TelephonyManager.PHONE_TYPE_CDMA

Addresses issue:
http://buganizer/issue?id=1905415

Change-Id: Icfec6d457231b098c031677a66770b5e57be4a44
This commit is contained in:
Tammo Spalink
2009-09-21 15:26:10 +08:00
parent 7c5c6076ea
commit 3cc97f8dbc
11 changed files with 77 additions and 59 deletions

View File

@ -125112,6 +125112,17 @@
visibility="public"
>
</field>
<field name="PHONE_TYPE_CDMA"
type="int"
transient="false"
volatile="false"
value="2"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="PHONE_TYPE_GSM"
type="int"
transient="false"

View File

@ -26,11 +26,10 @@ import android.provider.Settings;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.Phone;
/**
* Abstract class that represents the location of the device. Currently the only
* subclass is {@link android.telephony.gsm.GsmCellLocation}. {@more}
* Abstract class that represents the location of the device. {@more}
*/
public abstract class CellLocation {
@ -64,11 +63,13 @@ public abstract class CellLocation {
public static CellLocation newFromBundle(Bundle bundle) {
// TelephonyManager.getDefault().getPhoneType() handles the case when
// ITelephony interface is not up yet.
int type = TelephonyManager.getDefault().getPhoneType();
if (type == RILConstants.CDMA_PHONE) {
switch(TelephonyManager.getDefault().getPhoneType()) {
case Phone.PHONE_TYPE_CDMA:
return new CdmaCellLocation(bundle);
} else {
case Phone.PHONE_TYPE_GSM:
return new GsmCellLocation(bundle);
default:
return null;
}
}
@ -78,17 +79,20 @@ public abstract class CellLocation {
public abstract void fillInNotifierBundle(Bundle bundle);
/**
* Return a new CellLocation object representing an unknown location.
* Return a new CellLocation object representing an unknown
* location, or null for unknown/none phone radio types.
*
*/
public static CellLocation getEmpty() {
// TelephonyManager.getDefault().getPhoneType() handles the case when
// ITelephony interface is not up yet.
int type = TelephonyManager.getDefault().getPhoneType();
if (type == RILConstants.CDMA_PHONE) {
switch(TelephonyManager.getDefault().getPhoneType()) {
case Phone.PHONE_TYPE_CDMA:
return new CdmaCellLocation();
} else {
case Phone.PHONE_TYPE_GSM:
return new GsmCellLocation();
default:
return null;
}
}
}

View File

@ -263,22 +263,12 @@ public class TelephonyManager {
}
}
/**
* No phone module
*
*/
public static final int PHONE_TYPE_NONE = RILConstants.NO_PHONE;
/**
* GSM phone
*/
public static final int PHONE_TYPE_GSM = RILConstants.GSM_PHONE;
/**
* CDMA phone
* @hide
*/
public static final int PHONE_TYPE_CDMA = RILConstants.CDMA_PHONE;
/** No phone radio. */
public static final int PHONE_TYPE_NONE = Phone.PHONE_TYPE_NONE;
/** Phone radio is GSM. */
public static final int PHONE_TYPE_GSM = Phone.PHONE_TYPE_GSM;
/** Phone radio is CDMA. */
public static final int PHONE_TYPE_CDMA = Phone.PHONE_TYPE_CDMA;
/**
* Returns a constant indicating the device phone type.
@ -291,11 +281,7 @@ public class TelephonyManager {
try{
ITelephony telephony = getITelephony();
if (telephony != null) {
if(telephony.getActivePhoneType() == RILConstants.CDMA_PHONE) {
return PHONE_TYPE_CDMA;
} else {
return PHONE_TYPE_GSM;
}
return telephony.getActivePhoneType();
} else {
// This can happen when the ITelephony interface is not up yet.
return getPhoneTypeFromProperty();

View File

@ -676,7 +676,7 @@ public abstract class BaseCommands implements CommandsInterface {
mRadioTechnologyChangedRegistrants.notifyRegistrants();
}
if (mState.isGsm() && !oldState.isOn() && (mPhoneType == RILConstants.CDMA_PHONE)) {
if (mState.isGsm() && !oldState.isOn() && (mPhoneType == Phone.PHONE_TYPE_CDMA)) {
Log.d(LOG_TAG,"Notifying: radio technology change CDMA OFF to GSM");
mRadioTechnologyChangedRegistrants.notifyRegistrants();
}
@ -686,7 +686,7 @@ public abstract class BaseCommands implements CommandsInterface {
mRadioTechnologyChangedRegistrants.notifyRegistrants();
}
if (mState.isCdma() && !oldState.isOn() && (mPhoneType == RILConstants.GSM_PHONE)) {
if (mState.isCdma() && !oldState.isOn() && (mPhoneType == Phone.PHONE_TYPE_GSM)) {
Log.d(LOG_TAG,"Notifying: radio technology change GSM OFF to CDMA");
mRadioTechnologyChangedRegistrants.notifyRegistrants();
}

View File

@ -1256,6 +1256,7 @@ public interface CommandsInterface {
/** Set the Phone type created */
void setPhoneType(int phoneType);
/**
* Query the CDMA roaming preference setting
*

View File

@ -173,6 +173,11 @@ public interface Phone {
static final int BM_AUS2_BAND = 5; // GSM-900 / DCS-1800 / WCDMA-850
static final int BM_BOUNDARY = 6; // upper band boundary
// Radio Type
static final int PHONE_TYPE_NONE = RILConstants.NO_PHONE;
static final int PHONE_TYPE_GSM = RILConstants.GSM_PHONE;
static final int PHONE_TYPE_CDMA = RILConstants.CDMA_PHONE;
// Used for preferred network type
// Note NT_* substitute RILConstants.NETWORK_MODE_* above the Phone
int NT_MODE_WCDMA_PREF = RILConstants.NETWORK_MODE_WCDMA_PREF;
@ -287,6 +292,12 @@ public interface Phone {
*/
String getPhoneName();
/**
* Return a numerical identifier for the phone radio interface.
* @return PHONE_TYPE_XXX as defined above.
*/
int getPhoneType();
/**
* Returns an array of string identifiers for the APN types serviced by the
* currently active or last connected APN.

View File

@ -740,6 +740,8 @@ public abstract class PhoneBase extends Handler implements Phone {
public abstract String getPhoneName();
public abstract int getPhoneType();
/** @hide */
public int getVoiceMessageCount(){
return 0;

View File

@ -108,11 +108,11 @@ public class PhoneFactory {
sCommandsInterface = new RIL(context, networkMode, cdmaSubscription);
int phoneType = getPhoneType(networkMode);
if (phoneType == RILConstants.GSM_PHONE) {
if (phoneType == Phone.PHONE_TYPE_GSM) {
sProxyPhone = new PhoneProxy(new GSMPhone(context,
sCommandsInterface, sPhoneNotifier));
Log.i(LOG_TAG, "Creating GSMPhone");
} else if (phoneType == RILConstants.CDMA_PHONE) {
} else if (phoneType == Phone.PHONE_TYPE_CDMA) {
sProxyPhone = new PhoneProxy(new CDMAPhone(context,
sCommandsInterface, sPhoneNotifier));
Log.i(LOG_TAG, "Creating CDMAPhone");
@ -135,18 +135,18 @@ public class PhoneFactory {
case RILConstants.NETWORK_MODE_CDMA:
case RILConstants.NETWORK_MODE_CDMA_NO_EVDO:
case RILConstants.NETWORK_MODE_EVDO_NO_CDMA:
return RILConstants.CDMA_PHONE;
return Phone.PHONE_TYPE_CDMA;
case RILConstants.NETWORK_MODE_WCDMA_PREF:
case RILConstants.NETWORK_MODE_GSM_ONLY:
case RILConstants.NETWORK_MODE_WCDMA_ONLY:
case RILConstants.NETWORK_MODE_GSM_UMTS:
return RILConstants.GSM_PHONE;
return Phone.PHONE_TYPE_GSM;
case RILConstants.NETWORK_MODE_GLOBAL:
return RILConstants.CDMA_PHONE;
return Phone.PHONE_TYPE_CDMA;
default:
return RILConstants.GSM_PHONE;
return Phone.PHONE_TYPE_GSM;
}
}

View File

@ -191,6 +191,10 @@ public class PhoneProxy extends Handler implements Phone {
return mActivePhone.getPhoneName();
}
public int getPhoneType() {
return mActivePhone.getPhoneType();
}
public String[] getActiveApnTypes() {
return mActivePhone.getActiveApnTypes();
}

View File

@ -60,7 +60,6 @@ import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.PhoneNotifier;
import com.android.internal.telephony.PhoneProxy;
import com.android.internal.telephony.PhoneSubInfo;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyProperties;
@ -143,7 +142,7 @@ public class CDMAPhone extends PhoneBase {
boolean unitTestMode) {
super(notifier, context, ci, unitTestMode);
mCM.setPhoneType(RILConstants.CDMA_PHONE);
mCM.setPhoneType(Phone.PHONE_TYPE_CDMA);
mCT = new CdmaCallTracker(this);
mSST = new CdmaServiceStateTracker (this);
mSMS = new CdmaSMSDispatcher(this);
@ -171,7 +170,7 @@ public class CDMAPhone extends PhoneBase {
//Change the system setting
SystemProperties.set(TelephonyProperties.CURRENT_ACTIVE_PHONE,
new Integer(RILConstants.CDMA_PHONE).toString());
new Integer(Phone.PHONE_TYPE_CDMA).toString());
// This is needed to handle phone process crashes
String inEcm=SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE, "false");
@ -261,23 +260,24 @@ public class CDMAPhone extends PhoneBase {
return mSST.ss;
}
public Phone.State
getState() {
public Phone.State getState() {
return mCT.state;
}
public String
getPhoneName() {
public String getPhoneName() {
return "CDMA";
}
public int getPhoneType() {
return Phone.PHONE_TYPE_CDMA;
}
public boolean canTransfer() {
Log.e(LOG_TAG, "canTransfer: not possible in CDMA");
return false;
}
public CdmaCall
getRingingCall() {
public CdmaCall getRingingCall() {
return mCT.ringingCall;
}

View File

@ -66,7 +66,6 @@ import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.PhoneNotifier;
import com.android.internal.telephony.PhoneProxy;
import com.android.internal.telephony.PhoneSubInfo;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.telephony.gsm.stk.StkService;
import com.android.internal.telephony.test.SimulatedRadioControl;
@ -141,7 +140,7 @@ public class GSMPhone extends PhoneBase {
mSimulatedRadioControl = (SimulatedRadioControl) ci;
}
mCM.setPhoneType(RILConstants.GSM_PHONE);
mCM.setPhoneType(Phone.PHONE_TYPE_GSM);
mCT = new GsmCallTracker(this);
mSST = new GsmServiceStateTracker (this);
mSMS = new GsmSMSDispatcher(this);
@ -201,7 +200,7 @@ public class GSMPhone extends PhoneBase {
//Change the system property
SystemProperties.set(TelephonyProperties.CURRENT_ACTIVE_PHONE,
new Integer(RILConstants.GSM_PHONE).toString());
new Integer(Phone.PHONE_TYPE_GSM).toString());
}
public void dispose() {
@ -262,27 +261,27 @@ public class GSMPhone extends PhoneBase {
return mSST.cellLoc;
}
public Phone.State
getState() {
public Phone.State getState() {
return mCT.state;
}
public String
getPhoneName() {
public String getPhoneName() {
return "GSM";
}
public int getPhoneType() {
return Phone.PHONE_TYPE_GSM;
}
public SignalStrength getSignalStrength() {
return mSST.mSignalStrength;
}
public boolean
getMessageWaitingIndicator() {
public boolean getMessageWaitingIndicator() {
return mSIMRecords.getVoiceMessageWaiting();
}
public boolean
getCallForwardingIndicator() {
public boolean getCallForwardingIndicator() {
return mSIMRecords.getVoiceCallForwardingFlag();
}