summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/android/telephony/CellLocation.java22
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java73
-rw-r--r--telephony/java/com/android/internal/telephony/Phone.java24
-rw-r--r--telephony/java/com/android/internal/telephony/PhoneFactory.java58
-rw-r--r--telephony/java/com/android/internal/telephony/RIL.java2
-rw-r--r--telephony/java/com/android/internal/telephony/TelephonyProperties.java2
-rwxr-xr-xtelephony/java/com/android/internal/telephony/cdma/CDMAPhone.java5
-rwxr-xr-xtelephony/java/com/android/internal/telephony/gsm/GSMPhone.java33
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/MccTable.java2
9 files changed, 131 insertions, 90 deletions
diff --git a/telephony/java/android/telephony/CellLocation.java b/telephony/java/android/telephony/CellLocation.java
index 1483522..7d600f0 100644
--- a/telephony/java/android/telephony/CellLocation.java
+++ b/telephony/java/android/telephony/CellLocation.java
@@ -62,13 +62,10 @@ public abstract class CellLocation {
* @hide
*/
public static CellLocation newFromBundle(Bundle bundle) {
- // TODO: My need to be use: Settings.Secure.getInt(mContext, Settings.Secure.CURRENT_ACTIVE_PHONE, 0))
- // instead of SystemProperties???
-
- // NOTE here TelephonyManager.getDefault().getPhoneType() cannot be used since at startup
- // ITelephony have not been created
- if (RILConstants.CDMA_PHONE == SystemProperties.getInt(
- Settings.Secure.CURRENT_ACTIVE_PHONE, RILConstants.CDMA_PHONE)) {
+ // TelephonyManager.getDefault().getPhoneType() handles the case when
+ // ITelephony interface is not up yet.
+ int type = TelephonyManager.getDefault().getPhoneType();
+ if (type == RILConstants.CDMA_PHONE) {
return new CdmaCellLocation(bundle);
} else {
return new GsmCellLocation(bundle);
@@ -85,13 +82,10 @@ public abstract class CellLocation {
*
*/
public static CellLocation getEmpty() {
- // TODO: My need to be use: Settings.Secure.getInt(mContext, Settings.Secure.CURRENT_ACTIVE_PHONE, 0))
- // instead of SystemProperties???
-
- // NOTE here TelephonyManager.getDefault().getPhoneType() cannot be used since at startup
- // ITelephony have not been created
- if (RILConstants.CDMA_PHONE == SystemProperties.getInt(
- Settings.Secure.CURRENT_ACTIVE_PHONE, RILConstants.CDMA_PHONE)) {
+ // TelephonyManager.getDefault().getPhoneType() handles the case when
+ // ITelephony interface is not up yet.
+ int type = TelephonyManager.getDefault().getPhoneType();
+ if (type == RILConstants.CDMA_PHONE) {
return new CdmaCellLocation();
} else {
return new GsmCellLocation();
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index e836991..a79eb3a 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -16,26 +16,24 @@
package android.telephony;
-import com.android.internal.telephony.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SdkConstant;
+import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
-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.Phone;
+import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.TelephonyProperties;
+import java.util.List;
+
/**
* Provides access to information about the telephony services on
* the device. Applications can use the methods in this class to
@@ -192,8 +190,9 @@ public class TelephonyManager {
/**
* Returns the current location of the device.
*
- * <p>Requires Permission: {@link android.Manifest.permission#ACCESS_COARSE_LOCATION
- * ACCESS_COARSE_LOCATION}.
+ * <p>Requires Permission:
+ * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION} or
+ * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_FINE_LOCATION}.
*/
public CellLocation getCellLocation() {
try {
@@ -238,10 +237,10 @@ public class TelephonyManager {
/**
* Returns the neighboring cell information of the device.
- *
+ *
* @return List of NeighboringCellInfo or null if info unavailable.
- *
- * <p>Requires Permission:
+ *
+ * <p>Requires Permission:
* (@link android.Manifest.permission#ACCESS_COARSE_UPDATES}
*/
public List<NeighboringCellInfo> getNeighboringCellInfo() {
@@ -250,24 +249,25 @@ public class TelephonyManager {
} catch (RemoteException ex) {
}
return null;
-
+
}
-
+
/**
* No phone module
+ *
*/
public static final int PHONE_TYPE_NONE = 0;
/**
* GSM phone
*/
- public static final int PHONE_TYPE_GSM = 1;
+ public static final int PHONE_TYPE_GSM = RILConstants.GSM_PHONE;
/**
* CDMA phone
* @hide
*/
- public static final int PHONE_TYPE_CDMA = 2;
+ public static final int PHONE_TYPE_CDMA = RILConstants.CDMA_PHONE;
/**
* Returns a constant indicating the device phone type.
@@ -278,16 +278,41 @@ public class TelephonyManager {
*/
public int getPhoneType() {
try{
- if(getITelephony().getActivePhoneType() == RILConstants.CDMA_PHONE) {
- return PHONE_TYPE_CDMA;
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ if(telephony.getActivePhoneType() == RILConstants.CDMA_PHONE) {
+ return PHONE_TYPE_CDMA;
+ } else {
+ return PHONE_TYPE_GSM;
+ }
} else {
- return PHONE_TYPE_GSM;
+ // This can happen when the ITelephony interface is not up yet.
+ return getPhoneTypeFromProperty();
}
- }catch(RemoteException ex){
- return PHONE_TYPE_NONE;
+ } catch(RemoteException ex){
+ // This shouldn't happen in the normal case, as a backup we
+ // read from the system property.
+ return getPhoneTypeFromProperty();
}
}
+
+ private int getPhoneTypeFromProperty() {
+ int type =
+ SystemProperties.getInt(TelephonyProperties.CURRENT_ACTIVE_PHONE,
+ getPhoneTypeFromNetworkType());
+ return type;
+ }
+
+ private int getPhoneTypeFromNetworkType() {
+ // When the system property CURRENT_ACTIVE_PHONE, has not been set,
+ // use the system property for default network type.
+ // This is a fail safe, and can only happen at first boot.
+ int mode = SystemProperties.getInt("ro.telephony.default_network", -1);
+ if (mode == -1)
+ return PHONE_TYPE_NONE;
+ return PhoneFactory.getPhoneType(mode);
+ }
//
//
// Current Network
@@ -639,8 +664,10 @@ public class TelephonyManager {
/** Data connection activity: Currently both sending and receiving
* IP PPP traffic. */
public static final int DATA_ACTIVITY_INOUT = DATA_ACTIVITY_IN | DATA_ACTIVITY_OUT;
- /** Data connection is active, but physical link is down */
- /** @hide */
+ /**
+ * Data connection is active, but physical link is down
+ * @hide
+ */
public static final int DATA_ACTIVITY_DORMANT = 0x00000004;
/**
diff --git a/telephony/java/com/android/internal/telephony/Phone.java b/telephony/java/com/android/internal/telephony/Phone.java
index b5f2afe..4d0cf41 100644
--- a/telephony/java/com/android/internal/telephony/Phone.java
+++ b/telephony/java/com/android/internal/telephony/Phone.java
@@ -165,18 +165,18 @@ public interface Phone {
// Used for preferred network type
// Note NT_* substitute RILConstants.NETWORK_MODE_* above the Phone
- static final int NT_MODE_WCDMA_PREF = 0; /* GSM/WCDMA (WCDMA preferred) */
- static final int NT_MODE_GSM_ONLY = 1; /* GSM only */
- static final int NT_MODE_WCDMA_ONLY = 2; /* WCDMA only */
- static final int NT_MODE_GSM_UMTS = 3; /* GSM/WCDMA (auto mode, according to PRL)
- AVAILABLE Application Settings menu */
- static final int NT_MODE_CDMA = 4; /* CDMA and EvDo (auto mode, according to PRL)
- AVAILABLE Application Settings menu */
- static final int NT_MODE_CDMA_NO_EVDO = 5; /* CDMA only */
- static final int NT_MODE_EVDO_NO_CDMA = 6; /* EvDo only */
- static final int NT_MODE_GLOBAL = 7; /* GSM/WCDMA, CDMA, and EvDo (auto mode, according
- to PRL) AVAILABLE Application Settings menu */
- static final int PREFERRED_NT_MODE = NT_MODE_GLOBAL;
+ int NT_MODE_WCDMA_PREF = RILConstants.NETWORK_MODE_WCDMA_PREF;
+ int NT_MODE_GSM_ONLY = RILConstants.NETWORK_MODE_GSM_ONLY;
+ int NT_MODE_WCDMA_ONLY = RILConstants.NETWORK_MODE_WCDMA_ONLY;
+ int NT_MODE_GSM_UMTS = RILConstants.NETWORK_MODE_GSM_UMTS;
+
+ int NT_MODE_CDMA = RILConstants.NETWORK_MODE_CDMA;
+
+ int NT_MODE_CDMA_NO_EVDO = RILConstants.NETWORK_MODE_CDMA_NO_EVDO;
+ int NT_MODE_EVDO_NO_CDMA = RILConstants.NETWORK_MODE_EVDO_NO_CDMA;
+ int NT_MODE_GLOBAL = RILConstants.NETWORK_MODE_GLOBAL;
+
+ int PREFERRED_NT_MODE = RILConstants.PREFERRED_NETWORK_MODE;
// Used for CDMA roaming mode
diff --git a/telephony/java/com/android/internal/telephony/PhoneFactory.java b/telephony/java/com/android/internal/telephony/PhoneFactory.java
index 3beb60a..a84f74e 100644
--- a/telephony/java/com/android/internal/telephony/PhoneFactory.java
+++ b/telephony/java/com/android/internal/telephony/PhoneFactory.java
@@ -107,33 +107,49 @@ public class PhoneFactory {
//reads the system properties and makes commandsinterface
sCommandsInterface = new RIL(context, networkMode, cdmaSubscription);
- switch(networkMode) {
- case RILConstants.NETWORK_MODE_WCDMA_PREF:
- case RILConstants.NETWORK_MODE_GSM_ONLY:
- case RILConstants.NETWORK_MODE_WCDMA_ONLY:
- case RILConstants.NETWORK_MODE_GSM_UMTS:
- sProxyPhone = new PhoneProxy(new GSMPhone(context,
- sCommandsInterface, sPhoneNotifier));
- Log.i(LOG_TAG, "Creating GSMPhone");
- break;
- case RILConstants.NETWORK_MODE_CDMA:
- case RILConstants.NETWORK_MODE_CDMA_NO_EVDO:
- case RILConstants.NETWORK_MODE_EVDO_NO_CDMA:
- sProxyPhone = new PhoneProxy(new CDMAPhone(context,
- sCommandsInterface, sPhoneNotifier));
- Log.i(LOG_TAG, "Creating CDMAPhone");
- break;
- case RILConstants.NETWORK_MODE_GLOBAL:
- default:
- sProxyPhone = new PhoneProxy(new CDMAPhone(context,
- sCommandsInterface, sPhoneNotifier));
- Log.i(LOG_TAG, "Creating CDMAPhone");
+ int phoneType = getPhoneType(networkMode);
+ if (phoneType == RILConstants.GSM_PHONE) {
+ sProxyPhone = new PhoneProxy(new GSMPhone(context,
+ sCommandsInterface, sPhoneNotifier));
+ Log.i(LOG_TAG, "Creating GSMPhone");
+ } else if (phoneType == RILConstants.CDMA_PHONE) {
+ sProxyPhone = new PhoneProxy(new CDMAPhone(context,
+ sCommandsInterface, sPhoneNotifier));
+ Log.i(LOG_TAG, "Creating CDMAPhone");
}
+
sMadeDefaults = true;
}
}
}
+ /*
+ * This function returns the type of the phone, depending
+ * on the network mode.
+ *
+ * @param network mode
+ * @return Phone Type
+ */
+ public static int getPhoneType(int networkMode) {
+ switch(networkMode) {
+ case RILConstants.NETWORK_MODE_CDMA:
+ case RILConstants.NETWORK_MODE_CDMA_NO_EVDO:
+ case RILConstants.NETWORK_MODE_EVDO_NO_CDMA:
+ return RILConstants.CDMA_PHONE;
+
+ 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;
+
+ case RILConstants.NETWORK_MODE_GLOBAL:
+ return RILConstants.CDMA_PHONE;
+ default:
+ return RILConstants.GSM_PHONE;
+ }
+ }
+
public static Phone getDefaultPhone() {
if (sLooper != Looper.myLooper()) {
throw new RuntimeException(
diff --git a/telephony/java/com/android/internal/telephony/RIL.java b/telephony/java/com/android/internal/telephony/RIL.java
index 04e33fe..070d233 100644
--- a/telephony/java/com/android/internal/telephony/RIL.java
+++ b/telephony/java/com/android/internal/telephony/RIL.java
@@ -1857,7 +1857,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
* and/or radio knowing.
*/
if (RILJ_LOGD) Log.d(LOG_TAG, "Radio ON @ init; reset to OFF");
- setRadioPower(false, null);
+ setRadioPower(false, null);
} else {
if (DBG) Log.d(LOG_TAG, "Radio OFF @ init");
setRadioState(newState);
diff --git a/telephony/java/com/android/internal/telephony/TelephonyProperties.java b/telephony/java/com/android/internal/telephony/TelephonyProperties.java
index 67ae169..453185f 100644
--- a/telephony/java/com/android/internal/telephony/TelephonyProperties.java
+++ b/telephony/java/com/android/internal/telephony/TelephonyProperties.java
@@ -69,6 +69,8 @@ public interface TelephonyProperties
*/
static final String PROPERTY_OPERATOR_ISO_COUNTRY = "gsm.operator.iso-country";
+ static final String CURRENT_ACTIVE_PHONE = "gsm.current.phone-type";
+
//****** SIM Card
/**
* One of <code>"UNKNOWN"</code> <code>"ABSENT"</code> <code>"PIN_REQUIRED"</code>
diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
index 3f8d40c..03f7f98 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
@@ -52,6 +52,7 @@ 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;
import java.util.ArrayList;
import java.util.List;
@@ -126,8 +127,8 @@ public class CDMAPhone extends PhoneBase {
//Change the system setting
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.CURRENT_ACTIVE_PHONE, RILConstants.CDMA_PHONE);
+ SystemProperties.set(TelephonyProperties.CURRENT_ACTIVE_PHONE,
+ new Integer(RILConstants.CDMA_PHONE).toString());
}
public void dispose() {
diff --git a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
index 4fe1ea0..3459dcd 100755
--- a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
@@ -68,6 +68,7 @@ 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;
import com.android.internal.telephony.IccVmNotSupportedException;
@@ -204,9 +205,9 @@ public class GSMPhone extends PhoneBase {
}
}
- //Change the system setting
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.CURRENT_ACTIVE_PHONE, RILConstants.GSM_PHONE);
+ //Change the system property
+ SystemProperties.set(TelephonyProperties.CURRENT_ACTIVE_PHONE,
+ new Integer(RILConstants.GSM_PHONE).toString());
}
public void dispose() {
@@ -837,21 +838,21 @@ public class GSMPhone extends PhoneBase {
private void storeVoiceMailNumber(String number) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
SharedPreferences.Editor editor = sp.edit();
- editor.putString(VM_NUMBER, number);
+ editor.putString(VM_NUMBER, number);
editor.commit();
setVmSimImsi(getSubscriberId());
}
public String getVoiceMailNumber() {
// Read from the SIM. If its null, try reading from the shared preference area.
- String number = mSIMRecords.getVoiceMailNumber();
+ String number = mSIMRecords.getVoiceMailNumber();
if (TextUtils.isEmpty(number)) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
number = sp.getString(VM_NUMBER, null);
- }
+ }
return number;
}
-
+
private String getVmSimImsi() {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
return sp.getString(VM_SIM_IMSI, null);
@@ -863,7 +864,7 @@ public class GSMPhone extends PhoneBase {
editor.putString(VM_SIM_IMSI, imsi);
editor.commit();
}
-
+
public String getVoiceMailAlphaTag() {
String ret;
@@ -932,13 +933,13 @@ public class GSMPhone extends PhoneBase {
public void setVoiceMailNumber(String alphaTag,
String voiceMailNumber,
Message onComplete) {
-
- Message resp;
+
+ Message resp;
mVmNumber = voiceMailNumber;
resp = h.obtainMessage(EVENT_SET_VM_NUMBER_DONE, 0, 0, onComplete);
mSIMRecords.setVoiceMailNumber(alphaTag, mVmNumber, resp);
}
-
+
private boolean isValidCommandInterfaceCFReason (int commandInterfaceCFReason) {
switch (commandInterfaceCFReason) {
case CF_REASON_UNCONDITIONAL:
@@ -1317,11 +1318,11 @@ public class GSMPhone extends PhoneBase {
case EVENT_SIM_RECORDS_LOADED:
updateCurrentCarrierInProvider();
-
+
// Check if this is a different SIM than the previous one. If so unset the
// voice mail number.
String imsi = getVmSimImsi();
- if (imsi != null && !getSubscriberId().equals(imsi)) {
+ if (imsi != null && !getSubscriberId().equals(imsi)) {
storeVoiceMailNumber(null);
setVmSimImsi(null);
}
@@ -1403,7 +1404,7 @@ public class GSMPhone extends PhoneBase {
onComplete.sendToTarget();
}
break;
-
+
case EVENT_SET_VM_NUMBER_DONE:
ar = (AsyncResult)msg.obj;
if (IccVmNotSupportedException.class.isInstance(ar.exception)) {
@@ -1417,7 +1418,7 @@ public class GSMPhone extends PhoneBase {
}
break;
-
+
case EVENT_GET_CALL_FORWARD_DONE:
ar = (AsyncResult)msg.obj;
if (ar.exception == null) {
@@ -1460,7 +1461,7 @@ public class GSMPhone extends PhoneBase {
/**
* Sets the "current" field in the telephony provider according to the SIM's operator
- *
+ *
* @return true for success; false otherwise.
*/
boolean updateCurrentCarrierInProvider() {
diff --git a/telephony/java/com/android/internal/telephony/gsm/MccTable.java b/telephony/java/com/android/internal/telephony/gsm/MccTable.java
index 6198979..e18da56 100644
--- a/telephony/java/com/android/internal/telephony/gsm/MccTable.java
+++ b/telephony/java/com/android/internal/telephony/gsm/MccTable.java
@@ -182,7 +182,7 @@ public final class MccTable
table.add(new MccEntry(222,"it",2,"Europe/Rome","it")); //Italy
table.add(new MccEntry(225,"va",2,"Europe/Rome","it")); //Vatican City State
table.add(new MccEntry(226,"ro",2)); //Romania
- table.add(new MccEntry(228,"ch",2,"Europe/Zurich","en")); //Switzerland (Confederation of)
+ table.add(new MccEntry(228,"ch",2,"Europe/Zurich","de")); //Switzerland (Confederation of)
table.add(new MccEntry(230,"cz",2,"Europe/Prague","cs")); //Czech Republic
table.add(new MccEntry(231,"sk",2)); //Slovak Republic
table.add(new MccEntry(232,"at",2,"Europe/Vienna","de")); //Austria