From 78eb48e53600198b04517210bc23977e59484e2c Mon Sep 17 00:00:00 2001 From: Nathan Harold Date: Mon, 26 Feb 2018 20:31:04 -0800 Subject: [PATCH] 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 --- .../android/telephony/CellIdentityCdma.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/telephony/java/android/telephony/CellIdentityCdma.java b/telephony/java/android/telephony/CellIdentityCdma.java index 2e1d1dc343cd8..105ddb0e8f255 100644 --- a/telephony/java/android/telephony/CellIdentityCdma.java +++ b/telephony/java/android/telephony/CellIdentityCdma.java @@ -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 */