Merge change 1791 into donut
* changes: Add a method to get the PhoneType in CellLocation.
This commit is contained in:
@@ -2061,13 +2061,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode";
|
public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode";
|
||||||
|
|
||||||
/**
|
|
||||||
* represents current active phone class
|
|
||||||
* 1 = GSM-Phone, 0 = CDMA-Phone
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public static final String CURRENT_ACTIVE_PHONE = "current_active_phone";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The preferred network mode 7 = Global
|
* The preferred network mode 7 = Global
|
||||||
* 6 = EvDo only
|
* 6 = EvDo only
|
||||||
|
|||||||
@@ -584,8 +584,7 @@ class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
+ " VALUES(?,?);");
|
+ " VALUES(?,?);");
|
||||||
|
|
||||||
Resources r = mContext.getResources();
|
Resources r = mContext.getResources();
|
||||||
loadSetting(stmt, Settings.Secure.CURRENT_ACTIVE_PHONE,
|
|
||||||
RILConstants.CDMA_PHONE);
|
|
||||||
loadBooleanSetting(stmt, Settings.System.DIM_SCREEN,
|
loadBooleanSetting(stmt, Settings.System.DIM_SCREEN,
|
||||||
R.bool.def_dim_screen);
|
R.bool.def_dim_screen);
|
||||||
loadSetting(stmt, Settings.System.STAY_ON_WHILE_PLUGGED_IN,
|
loadSetting(stmt, Settings.System.STAY_ON_WHILE_PLUGGED_IN,
|
||||||
|
|||||||
@@ -62,13 +62,10 @@ public abstract class CellLocation {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static CellLocation newFromBundle(Bundle bundle) {
|
public static CellLocation newFromBundle(Bundle bundle) {
|
||||||
// TODO: My need to be use: Settings.Secure.getInt(mContext, Settings.Secure.CURRENT_ACTIVE_PHONE, 0))
|
// TelephonyManager.getDefault().getPhoneType() handles the case when
|
||||||
// instead of SystemProperties???
|
// ITelephony interface is not up yet.
|
||||||
|
int type = TelephonyManager.getDefault().getPhoneType();
|
||||||
// NOTE here TelephonyManager.getDefault().getPhoneType() cannot be used since at startup
|
if (type == RILConstants.CDMA_PHONE) {
|
||||||
// ITelephony have not been created
|
|
||||||
if (RILConstants.CDMA_PHONE == SystemProperties.getInt(
|
|
||||||
Settings.Secure.CURRENT_ACTIVE_PHONE, RILConstants.CDMA_PHONE)) {
|
|
||||||
return new CdmaCellLocation(bundle);
|
return new CdmaCellLocation(bundle);
|
||||||
} else {
|
} else {
|
||||||
return new GsmCellLocation(bundle);
|
return new GsmCellLocation(bundle);
|
||||||
@@ -85,13 +82,10 @@ public abstract class CellLocation {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static CellLocation getEmpty() {
|
public static CellLocation getEmpty() {
|
||||||
// TODO: My need to be use: Settings.Secure.getInt(mContext, Settings.Secure.CURRENT_ACTIVE_PHONE, 0))
|
// TelephonyManager.getDefault().getPhoneType() handles the case when
|
||||||
// instead of SystemProperties???
|
// ITelephony interface is not up yet.
|
||||||
|
int type = TelephonyManager.getDefault().getPhoneType();
|
||||||
// NOTE here TelephonyManager.getDefault().getPhoneType() cannot be used since at startup
|
if (type == RILConstants.CDMA_PHONE) {
|
||||||
// ITelephony have not been created
|
|
||||||
if (RILConstants.CDMA_PHONE == SystemProperties.getInt(
|
|
||||||
Settings.Secure.CURRENT_ACTIVE_PHONE, RILConstants.CDMA_PHONE)) {
|
|
||||||
return new CdmaCellLocation();
|
return new CdmaCellLocation();
|
||||||
} else {
|
} else {
|
||||||
return new GsmCellLocation();
|
return new GsmCellLocation();
|
||||||
|
|||||||
@@ -16,26 +16,24 @@
|
|||||||
|
|
||||||
package android.telephony;
|
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;
|
||||||
|
import android.annotation.SdkConstant.SdkConstantType;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.telephony.CellLocation;
|
|
||||||
|
|
||||||
import com.android.internal.telephony.IPhoneSubInfo;
|
import com.android.internal.telephony.IPhoneSubInfo;
|
||||||
import com.android.internal.telephony.ITelephony;
|
import com.android.internal.telephony.ITelephony;
|
||||||
import com.android.internal.telephony.ITelephonyRegistry;
|
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.RILConstants;
|
||||||
import com.android.internal.telephony.TelephonyProperties;
|
import com.android.internal.telephony.TelephonyProperties;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to information about the telephony services on
|
* Provides access to information about the telephony services on
|
||||||
* the device. Applications can use the methods in this class to
|
* the device. Applications can use the methods in this class to
|
||||||
@@ -256,19 +254,20 @@ public class TelephonyManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* No phone module
|
* No phone module
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public static final int PHONE_TYPE_NONE = 0;
|
public static final int PHONE_TYPE_NONE = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GSM phone
|
* GSM phone
|
||||||
*/
|
*/
|
||||||
public static final int PHONE_TYPE_GSM = 1;
|
public static final int PHONE_TYPE_GSM = RILConstants.GSM_PHONE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CDMA phone
|
* CDMA phone
|
||||||
* @hide
|
* @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.
|
* Returns a constant indicating the device phone type.
|
||||||
@@ -279,16 +278,41 @@ public class TelephonyManager {
|
|||||||
*/
|
*/
|
||||||
public int getPhoneType() {
|
public int getPhoneType() {
|
||||||
try{
|
try{
|
||||||
if(getITelephony().getActivePhoneType() == RILConstants.CDMA_PHONE) {
|
ITelephony telephony = getITelephony();
|
||||||
|
if (telephony != null) {
|
||||||
|
if(telephony.getActivePhoneType() == RILConstants.CDMA_PHONE) {
|
||||||
return PHONE_TYPE_CDMA;
|
return PHONE_TYPE_CDMA;
|
||||||
} else {
|
} else {
|
||||||
return PHONE_TYPE_GSM;
|
return PHONE_TYPE_GSM;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// This can happen when the ITelephony interface is not up yet.
|
||||||
|
return getPhoneTypeFromProperty();
|
||||||
|
}
|
||||||
} catch(RemoteException ex){
|
} catch(RemoteException ex){
|
||||||
return PHONE_TYPE_NONE;
|
// 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
|
// Current Network
|
||||||
@@ -640,8 +664,10 @@ public class TelephonyManager {
|
|||||||
/** Data connection activity: Currently both sending and receiving
|
/** Data connection activity: Currently both sending and receiving
|
||||||
* IP PPP traffic. */
|
* IP PPP traffic. */
|
||||||
public static final int DATA_ACTIVITY_INOUT = DATA_ACTIVITY_IN | DATA_ACTIVITY_OUT;
|
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;
|
public static final int DATA_ACTIVITY_DORMANT = 0x00000004;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -107,30 +107,46 @@ public class PhoneFactory {
|
|||||||
//reads the system properties and makes commandsinterface
|
//reads the system properties and makes commandsinterface
|
||||||
sCommandsInterface = new RIL(context, networkMode, cdmaSubscription);
|
sCommandsInterface = new RIL(context, networkMode, cdmaSubscription);
|
||||||
|
|
||||||
|
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) {
|
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_WCDMA_PREF:
|
||||||
case RILConstants.NETWORK_MODE_GSM_ONLY:
|
case RILConstants.NETWORK_MODE_GSM_ONLY:
|
||||||
case RILConstants.NETWORK_MODE_WCDMA_ONLY:
|
case RILConstants.NETWORK_MODE_WCDMA_ONLY:
|
||||||
case RILConstants.NETWORK_MODE_GSM_UMTS:
|
case RILConstants.NETWORK_MODE_GSM_UMTS:
|
||||||
sProxyPhone = new PhoneProxy(new GSMPhone(context,
|
return RILConstants.GSM_PHONE;
|
||||||
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:
|
case RILConstants.NETWORK_MODE_GLOBAL:
|
||||||
|
return RILConstants.CDMA_PHONE;
|
||||||
default:
|
default:
|
||||||
sProxyPhone = new PhoneProxy(new CDMAPhone(context,
|
return RILConstants.GSM_PHONE;
|
||||||
sCommandsInterface, sPhoneNotifier));
|
|
||||||
Log.i(LOG_TAG, "Creating CDMAPhone");
|
|
||||||
}
|
|
||||||
sMadeDefaults = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ public interface TelephonyProperties
|
|||||||
*/
|
*/
|
||||||
static final String PROPERTY_OPERATOR_ISO_COUNTRY = "gsm.operator.iso-country";
|
static final String PROPERTY_OPERATOR_ISO_COUNTRY = "gsm.operator.iso-country";
|
||||||
|
|
||||||
|
static final String CURRENT_ACTIVE_PHONE = "gsm.current.phone-type";
|
||||||
|
|
||||||
//****** SIM Card
|
//****** SIM Card
|
||||||
/**
|
/**
|
||||||
* One of <code>"UNKNOWN"</code> <code>"ABSENT"</code> <code>"PIN_REQUIRED"</code>
|
* One of <code>"UNKNOWN"</code> <code>"ABSENT"</code> <code>"PIN_REQUIRED"</code>
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import com.android.internal.telephony.PhoneProxy;
|
|||||||
import com.android.internal.telephony.PhoneSubInfo;
|
import com.android.internal.telephony.PhoneSubInfo;
|
||||||
import com.android.internal.telephony.RILConstants;
|
import com.android.internal.telephony.RILConstants;
|
||||||
import com.android.internal.telephony.TelephonyIntents;
|
import com.android.internal.telephony.TelephonyIntents;
|
||||||
|
import com.android.internal.telephony.TelephonyProperties;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -126,8 +127,8 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
|
|
||||||
|
|
||||||
//Change the system setting
|
//Change the system setting
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
SystemProperties.set(TelephonyProperties.CURRENT_ACTIVE_PHONE,
|
||||||
Settings.Secure.CURRENT_ACTIVE_PHONE, RILConstants.CDMA_PHONE);
|
new Integer(RILConstants.CDMA_PHONE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ import com.android.internal.telephony.PhoneNotifier;
|
|||||||
import com.android.internal.telephony.PhoneProxy;
|
import com.android.internal.telephony.PhoneProxy;
|
||||||
import com.android.internal.telephony.PhoneSubInfo;
|
import com.android.internal.telephony.PhoneSubInfo;
|
||||||
import com.android.internal.telephony.RILConstants;
|
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.gsm.stk.StkService;
|
||||||
import com.android.internal.telephony.test.SimulatedRadioControl;
|
import com.android.internal.telephony.test.SimulatedRadioControl;
|
||||||
import com.android.internal.telephony.IccVmNotSupportedException;
|
import com.android.internal.telephony.IccVmNotSupportedException;
|
||||||
@@ -204,9 +205,9 @@ public class GSMPhone extends PhoneBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Change the system setting
|
//Change the system property
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
SystemProperties.set(TelephonyProperties.CURRENT_ACTIVE_PHONE,
|
||||||
Settings.Secure.CURRENT_ACTIVE_PHONE, RILConstants.GSM_PHONE);
|
new Integer(RILConstants.GSM_PHONE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
|||||||
Reference in New Issue
Block a user