am 6183a3ed: am 076cb23a: Merge change I13dd02fc into eclair

Merge commit '6183a3ed5b72902a8e4a441b4d9e99630cb42ee3' into eclair-mr2-plus-aosp

* commit '6183a3ed5b72902a8e4a441b4d9e99630cb42ee3':
  telephony/cdma: Fix Erroneous Roaming Indicators and Latitude-Longitude parsing
This commit is contained in:
Naveen Kalla
2009-10-22 11:02:47 -07:00
committed by Android Git Automerger
2 changed files with 89 additions and 44 deletions

View File

@@ -24,19 +24,35 @@ import android.telephony.CellLocation;
*/ */
public class CdmaCellLocation extends CellLocation { public class CdmaCellLocation extends CellLocation {
private int mBaseStationId = -1; private int mBaseStationId = -1;
private int mBaseStationLatitude = -1;
private int mBaseStationLongitude = -1; /**
* Latitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
* It is represented in units of 0.25 seconds and ranges from -1296000
* to 1296000, both values inclusive (corresponding to a range of -90
* to +90 degrees). Integer.MAX_VALUE is considered invalid value.
*/
private int mBaseStationLatitude = Integer.MAX_VALUE;
/**
* Longitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
* It is represented in units of 0.25 seconds and ranges from -2592000
* to 2592000, both values inclusive (corresponding to a range of -180
* to +180 degrees). Integer.MAX_VALUE is considered invalid value.
*/
private int mBaseStationLongitude = Integer.MAX_VALUE;
private int mSystemId = -1; private int mSystemId = -1;
private int mNetworkId = -1; private int mNetworkId = -1;
/** /**
* Empty constructor. * Empty constructor.
* Initializes the BID, SID, NID and base station latitude and longitude to -1. * Initializes the BID, SID, NID and base station latitude and longitude
* to invalid values.
*/ */
public CdmaCellLocation() { public CdmaCellLocation() {
this.mBaseStationId = -1; this.mBaseStationId = -1;
this.mBaseStationLatitude = -1; this.mBaseStationLatitude = Integer.MAX_VALUE;
this.mBaseStationLongitude = -1; this.mBaseStationLongitude = Integer.MAX_VALUE;
this.mSystemId = -1; this.mSystemId = -1;
this.mNetworkId = -1; this.mNetworkId = -1;
} }
@@ -60,14 +76,14 @@ public class CdmaCellLocation extends CellLocation {
} }
/** /**
* @return cdma base station latitude, -1 if unknown * @return cdma base station latitude, Integer.MAX_VALUE if unknown
*/ */
public int getBaseStationLatitude() { public int getBaseStationLatitude() {
return this.mBaseStationLatitude; return this.mBaseStationLatitude;
} }
/** /**
* @return cdma base station longitude, -1 if unknown * @return cdma base station longitude, Integer.MAX_VALUE if unknown
*/ */
public int getBaseStationLongitude() { public int getBaseStationLongitude() {
return this.mBaseStationLongitude; return this.mBaseStationLongitude;
@@ -88,12 +104,12 @@ public class CdmaCellLocation extends CellLocation {
} }
/** /**
* Invalidate this object. The cell location data is set to -1. * Invalidate this object. The cell location data is set to invalid values.
*/ */
public void setStateInvalid() { public void setStateInvalid() {
this.mBaseStationId = -1; this.mBaseStationId = -1;
this.mBaseStationLatitude = -1; this.mBaseStationLatitude = Integer.MAX_VALUE;
this.mBaseStationLongitude = -1; this.mBaseStationLongitude = Integer.MAX_VALUE;
this.mSystemId = -1; this.mSystemId = -1;
this.mNetworkId = -1; this.mNetworkId = -1;
} }

View File

@@ -350,29 +350,35 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
if (ar.exception == null) { if (ar.exception == null) {
String states[] = (String[])ar.result; String states[] = (String[])ar.result;
int baseStationId = -1; int baseStationId = -1;
int baseStationLongitude = -1; int baseStationLatitude = Integer.MAX_VALUE;
int baseStationLatitude = -1; int baseStationLongitude = Integer.MAX_VALUE;
int systemId = -1;
int networkId = -1;
int baseStationData[] = { if (states.length > 9) {
-1, // baseStationId try {
-1, // baseStationLatitude if (states[4] != null) {
-1 // baseStationLongitude baseStationId = Integer.parseInt(states[4]);
};
if (states.length == 3) {
for(int i = 0; i < states.length; i++) {
try {
if (states[i] != null && states[i].length() > 0) {
baseStationData[i] = Integer.parseInt(states[i], 16);
}
} catch (NumberFormatException ex) {
Log.w(LOG_TAG, "error parsing cell location data: " + ex);
} }
if (states[5] != null) {
baseStationLatitude = Integer.parseInt(states[5]);
}
if (states[6] != null) {
baseStationLongitude = Integer.parseInt(states[6]);
}
if (states[8] != null) {
systemId = Integer.parseInt(states[8]);
}
if (states[9] != null) {
networkId = Integer.parseInt(states[9]);
}
} catch (NumberFormatException ex) {
Log.w(LOG_TAG, "error parsing cell location data: " + ex);
} }
} }
cellLoc.setCellLocationData(baseStationData[0], cellLoc.setCellLocationData(baseStationId, baseStationLatitude,
baseStationData[1], baseStationData[2]); baseStationLongitude, systemId, networkId);
phone.notifyLocationChanged(); phone.notifyLocationChanged();
} }
@@ -640,8 +646,8 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
int registrationState = 4; //[0] registrationState int registrationState = 4; //[0] registrationState
int radioTechnology = -1; //[3] radioTechnology int radioTechnology = -1; //[3] radioTechnology
int baseStationId = -1; //[4] baseStationId int baseStationId = -1; //[4] baseStationId
int baseStationLatitude = -1; //[5] baseStationLatitude int baseStationLatitude = Integer.MAX_VALUE; //[5] baseStationLatitude
int baseStationLongitude = -1; //[6] baseStationLongitude int baseStationLongitude = Integer.MAX_VALUE; //[6] baseStationLongitude
int cssIndicator = 0; //[7] init with 0, because it is treated as a boolean int cssIndicator = 0; //[7] init with 0, because it is treated as a boolean
int systemId = 0; //[8] systemId int systemId = 0; //[8] systemId
int networkId = 0; //[9] networkId int networkId = 0; //[9] networkId
@@ -652,20 +658,43 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
if (states.length == 14) { if (states.length == 14) {
try { try {
registrationState = Integer.parseInt(states[0]); if (states[0] != null) {
radioTechnology = Integer.parseInt(states[3]); registrationState = Integer.parseInt(states[0]);
baseStationId = Integer.parseInt(states[4]); }
baseStationLatitude = Integer.parseInt(states[5], 16); if (states[3] != null) {
baseStationLongitude = Integer.parseInt(states[6], 16); radioTechnology = Integer.parseInt(states[3]);
cssIndicator = Integer.parseInt(states[7]); }
systemId = Integer.parseInt(states[8]); if (states[4] != null) {
networkId = Integer.parseInt(states[9]); baseStationId = Integer.parseInt(states[4]);
roamingIndicator = Integer.parseInt(states[10]); }
systemIsInPrl = Integer.parseInt(states[11]); if (states[5] != null) {
defaultRoamingIndicator = Integer.parseInt(states[12]); baseStationLatitude = Integer.parseInt(states[5]);
reasonForDenial = Integer.parseInt(states[13]); }
} if (states[6] != null) {
catch(NumberFormatException ex) { baseStationLongitude = Integer.parseInt(states[6]);
}
if (states[7] != null) {
cssIndicator = Integer.parseInt(states[7]);
}
if (states[8] != null) {
systemId = Integer.parseInt(states[8]);
}
if (states[9] != null) {
networkId = Integer.parseInt(states[9]);
}
if (states[10] != null) {
roamingIndicator = Integer.parseInt(states[10]);
}
if (states[11] != null) {
systemIsInPrl = Integer.parseInt(states[11]);
}
if (states[12] != null) {
defaultRoamingIndicator = Integer.parseInt(states[12]);
}
if (states[13] != null) {
reasonForDenial = Integer.parseInt(states[13]);
}
} catch (NumberFormatException ex) {
Log.w(LOG_TAG, "error parsing RegistrationState: " + ex); Log.w(LOG_TAG, "error parsing RegistrationState: " + ex);
} }
} else { } else {