Set CDMA Location to Invalid if on Null Island

If the reported CDMA location is ~= (0, 0), which
is in the middle of the Gulf of Guinea, assert that
there are no CDMA cell towers within range (there
are not) and force the location to a saner default
value of Integer.MAX_VALUE which is out of the range
of valid lats+longs.

Bug: 32364031
Test: runtest frameworks-telephony
Change-Id: I3f50054dd37cf7cef56b1bd16c3313c02da34c31
This commit is contained in:
Nathan Harold
2018-02-26 20:31:04 -08:00
parent 3ffbf86e1e
commit 78eb48e536

View File

@@ -103,8 +103,12 @@ public final class CellIdentityCdma extends CellIdentity {
mNetworkId = nid;
mSystemId = sid;
mBasestationId = bid;
mLongitude = lon;
mLatitude = lat;
if (!isNullIsland(lat, lon)) {
mLongitude = lon;
mLatitude = lat;
} else {
mLongitude = mLatitude = Integer.MAX_VALUE;
}
mAlphaLong = alphal;
mAlphaShort = alphas;
}
@@ -118,6 +122,18 @@ public final class CellIdentityCdma extends CellIdentity {
return new CellIdentityCdma(this);
}
/**
* Take the latitude and longitude in 1/4 seconds and see if
* the reported location is on Null Island.
*
* @return whether the reported Lat/Long are for Null Island
*
* @hide
*/
private boolean isNullIsland(int lat, int lon) {
return Math.abs(lat) <= 1 && Math.abs(lon) <= 1;
}
/**
* @return Network Id 0..65535, Integer.MAX_VALUE if unknown
*/