Map base station lat-lng of "0","0" to undefined.

Also introduce a public constant for the invalid lat/lng value.

Change-Id: Ifaa1e563bfa94c06dfbba51157b9160055442682
This commit is contained in:
Mark Vandevoorde
2010-02-11 12:50:34 -08:00
parent 111c178bc4
commit 9384b145e6
3 changed files with 35 additions and 20 deletions

View File

@@ -25,13 +25,18 @@ import android.telephony.CellLocation;
public class CdmaCellLocation extends CellLocation {
private int mBaseStationId = -1;
/**
* @hide
*/
public final static int INVALID_LAT_LONG = Integer.MAX_VALUE;
/**
* 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;
private int mBaseStationLatitude = INVALID_LAT_LONG;
/**
* Longitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
@@ -39,7 +44,7 @@ public class CdmaCellLocation extends CellLocation {
* 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 mBaseStationLongitude = INVALID_LAT_LONG;
private int mSystemId = -1;
private int mNetworkId = -1;
@@ -51,8 +56,8 @@ public class CdmaCellLocation extends CellLocation {
*/
public CdmaCellLocation() {
this.mBaseStationId = -1;
this.mBaseStationLatitude = Integer.MAX_VALUE;
this.mBaseStationLongitude = Integer.MAX_VALUE;
this.mBaseStationLatitude = INVALID_LAT_LONG;
this.mBaseStationLongitude = INVALID_LAT_LONG;
this.mSystemId = -1;
this.mNetworkId = -1;
}
@@ -60,12 +65,12 @@ public class CdmaCellLocation extends CellLocation {
/**
* Initialize the object from a bundle.
*/
public CdmaCellLocation(Bundle bundleWithValues) {
this.mBaseStationId = bundleWithValues.getInt("baseStationId");
this.mBaseStationLatitude = bundleWithValues.getInt("baseStationLatitude");
this.mBaseStationLongitude = bundleWithValues.getInt("baseStationLongitude");
this.mSystemId = bundleWithValues.getInt("systemId");
this.mNetworkId = bundleWithValues.getInt("networkId");
public CdmaCellLocation(Bundle bundle) {
this.mBaseStationId = bundle.getInt("baseStationId", mBaseStationId);
this.mBaseStationLatitude = bundle.getInt("baseStationLatitude", mBaseStationLatitude);
this.mBaseStationLongitude = bundle.getInt("baseStationLongitude", mBaseStationLongitude);
this.mSystemId = bundle.getInt("systemId", mSystemId);
this.mNetworkId = bundle.getInt("networkId", mNetworkId);
}
/**
@@ -108,8 +113,8 @@ public class CdmaCellLocation extends CellLocation {
*/
public void setStateInvalid() {
this.mBaseStationId = -1;
this.mBaseStationLatitude = Integer.MAX_VALUE;
this.mBaseStationLongitude = Integer.MAX_VALUE;
this.mBaseStationLatitude = INVALID_LAT_LONG;
this.mBaseStationLongitude = INVALID_LAT_LONG;
this.mSystemId = -1;
this.mNetworkId = -1;
}

View File

@@ -38,8 +38,8 @@ public class GsmCellLocation extends CellLocation {
* Initialize the object from a bundle.
*/
public GsmCellLocation(Bundle bundle) {
mLac = bundle.getInt("lac");
mCid = bundle.getInt("cid");
mLac = bundle.getInt("lac", mLac);
mCid = bundle.getInt("cid", mCid);
}
/**
@@ -120,5 +120,3 @@ public class GsmCellLocation extends CellLocation {
m.putInt("cid", mCid);
}
}

View File

@@ -357,8 +357,8 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
if (ar.exception == null) {
String states[] = (String[])ar.result;
int baseStationId = -1;
int baseStationLatitude = Integer.MAX_VALUE;
int baseStationLongitude = Integer.MAX_VALUE;
int baseStationLatitude = CdmaCellLocation.INVALID_LAT_LONG;
int baseStationLongitude = CdmaCellLocation.INVALID_LAT_LONG;
int systemId = -1;
int networkId = -1;
@@ -373,6 +373,11 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
if (states[6] != null) {
baseStationLongitude = Integer.parseInt(states[6]);
}
// Some carriers only return lat-lngs of 0,0
if (baseStationLatitude == 0 && baseStationLongitude == 0) {
baseStationLatitude = CdmaCellLocation.INVALID_LAT_LONG;
baseStationLongitude = CdmaCellLocation.INVALID_LAT_LONG;
}
if (states[8] != null) {
systemId = Integer.parseInt(states[8]);
}
@@ -662,8 +667,10 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
int registrationState = 4; //[0] registrationState
int radioTechnology = -1; //[3] radioTechnology
int baseStationId = -1; //[4] baseStationId
int baseStationLatitude = Integer.MAX_VALUE; //[5] baseStationLatitude
int baseStationLongitude = Integer.MAX_VALUE; //[6] baseStationLongitude
//[5] baseStationLatitude
int baseStationLatitude = CdmaCellLocation.INVALID_LAT_LONG;
//[6] baseStationLongitude
int baseStationLongitude = CdmaCellLocation.INVALID_LAT_LONG;
int cssIndicator = 0; //[7] init with 0, because it is treated as a boolean
int systemId = 0; //[8] systemId
int networkId = 0; //[9] networkId
@@ -689,6 +696,11 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
if (states[6] != null) {
baseStationLongitude = Integer.parseInt(states[6]);
}
// Some carriers only return lat-lngs of 0,0
if (baseStationLatitude == 0 && baseStationLongitude == 0) {
baseStationLatitude = CdmaCellLocation.INVALID_LAT_LONG;
baseStationLongitude = CdmaCellLocation.INVALID_LAT_LONG;
}
if (states[7] != null) {
cssIndicator = Integer.parseInt(states[7]);
}