summaryrefslogtreecommitdiffstats
path: root/telephony/java
diff options
context:
space:
mode:
authorTammo Spalink <tammo@google.com>2009-09-21 15:26:10 +0800
committerTammo Spalink <tammo@google.com>2009-09-24 13:19:08 +0800
commit3cc97f8dbc22eff56f17f30e1633084af507eff4 (patch)
tree3a44bb549fa97af2f2da29fe60f677c6a0783a1a /telephony/java
parent7c5c6076ea5d02aabbb449b1341ec44d184d1316 (diff)
downloadframeworks_base-3cc97f8dbc22eff56f17f30e1633084af507eff4.zip
frameworks_base-3cc97f8dbc22eff56f17f30e1633084af507eff4.tar.gz
frameworks_base-3cc97f8dbc22eff56f17f30e1633084af507eff4.tar.bz2
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
Diffstat (limited to 'telephony/java')
-rw-r--r--telephony/java/android/telephony/CellLocation.java24
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java28
-rw-r--r--telephony/java/com/android/internal/telephony/BaseCommands.java4
-rw-r--r--telephony/java/com/android/internal/telephony/CommandsInterface.java1
-rw-r--r--telephony/java/com/android/internal/telephony/Phone.java11
-rw-r--r--telephony/java/com/android/internal/telephony/PhoneBase.java2
-rw-r--r--telephony/java/com/android/internal/telephony/PhoneFactory.java12
-rw-r--r--telephony/java/com/android/internal/telephony/PhoneProxy.java4
-rwxr-xr-xtelephony/java/com/android/internal/telephony/cdma/CDMAPhone.java18
-rwxr-xr-xtelephony/java/com/android/internal/telephony/gsm/GSMPhone.java21
10 files changed, 66 insertions, 59 deletions
diff --git a/telephony/java/android/telephony/CellLocation.java b/telephony/java/android/telephony/CellLocation.java
index 7d600f0..f763d3f 100644
--- a/telephony/java/android/telephony/CellLocation.java
+++ b/telephony/java/android/telephony/CellLocation.java
@@ -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;
}
}
}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 8914ace..6664b08 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -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();
diff --git a/telephony/java/com/android/internal/telephony/BaseCommands.java b/telephony/java/com/android/internal/telephony/BaseCommands.java
index 52f25f6..7586ba2 100644
--- a/telephony/java/com/android/internal/telephony/BaseCommands.java
+++ b/telephony/java/com/android/internal/telephony/BaseCommands.java
@@ -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();
}
diff --git a/telephony/java/com/android/internal/telephony/CommandsInterface.java b/telephony/java/com/android/internal/telephony/CommandsInterface.java
index 9d83556..5777cad 100644
--- a/telephony/java/com/android/internal/telephony/CommandsInterface.java
+++ b/telephony/java/com/android/internal/telephony/CommandsInterface.java
@@ -1256,6 +1256,7 @@ public interface CommandsInterface {
/** Set the Phone type created */
void setPhoneType(int phoneType);
+
/**
* Query the CDMA roaming preference setting
*
diff --git a/telephony/java/com/android/internal/telephony/Phone.java b/telephony/java/com/android/internal/telephony/Phone.java
index fffd128..c113581 100644
--- a/telephony/java/com/android/internal/telephony/Phone.java
+++ b/telephony/java/com/android/internal/telephony/Phone.java
@@ -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;
@@ -288,6 +293,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.
* @return The string array.
diff --git a/telephony/java/com/android/internal/telephony/PhoneBase.java b/telephony/java/com/android/internal/telephony/PhoneBase.java
index 1c62a82..1c03c5a 100644
--- a/telephony/java/com/android/internal/telephony/PhoneBase.java
+++ b/telephony/java/com/android/internal/telephony/PhoneBase.java
@@ -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;
diff --git a/telephony/java/com/android/internal/telephony/PhoneFactory.java b/telephony/java/com/android/internal/telephony/PhoneFactory.java
index a84f74e..cd72752 100644
--- a/telephony/java/com/android/internal/telephony/PhoneFactory.java
+++ b/telephony/java/com/android/internal/telephony/PhoneFactory.java
@@ -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;
}
}
diff --git a/telephony/java/com/android/internal/telephony/PhoneProxy.java b/telephony/java/com/android/internal/telephony/PhoneProxy.java
index c4f663a..b1eaa93 100644
--- a/telephony/java/com/android/internal/telephony/PhoneProxy.java
+++ b/telephony/java/com/android/internal/telephony/PhoneProxy.java
@@ -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();
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
index dfc4889..6dcfcd9 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
@@ -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;
}
diff --git a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
index 2fc2e13..5614c12 100755
--- a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
@@ -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();
}