From cd5c46b432d29c182f9132804546e1749b2b71c2 Mon Sep 17 00:00:00 2001 From: Shinru Han Date: Fri, 14 Oct 2022 17:16:06 +0800 Subject: Correct requestRefLocation 1. Support LTE cell in AGnssRil_V1_0::setRefLocation(). 2. Use CellInfo#isRegistered() to get the cells being used or to be used as CellInfo#getCellConnectionStatus() doesn't work for 2G cells. Test: Manually on-device. Bug: b/253091197 Change-Id: I26ea0cb177de98bed56c438cd1452c929c73ad21 --- .../server/location/gnss/GnssLocationProvider.java | 7 +++-- services/core/jni/gnss/AGnssRil.cpp | 36 ++++++++++++---------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java b/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java index e653f0466863..6f637b83a694 100644 --- a/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java +++ b/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java @@ -1447,7 +1447,9 @@ public class GnssLocationProvider extends AbstractLocationProvider implements * @return the cell ID or -1 if invalid */ private static long getCidFromCellIdentity(CellIdentity id) { - if (id == null) return -1; + if (id == null) { + return -1; + } long cid = -1; switch(id.getType()) { case CellInfo.TYPE_GSM: cid = ((CellIdentityGsm) id).getCid(); break; @@ -1522,7 +1524,8 @@ public class GnssLocationProvider extends AbstractLocationProvider implements for (CellInfo ci : cil) { int status = ci.getCellConnectionStatus(); - if (status == CellInfo.CONNECTION_PRIMARY_SERVING + if (ci.isRegistered() + || status == CellInfo.CONNECTION_PRIMARY_SERVING || status == CellInfo.CONNECTION_SECONDARY_SERVING) { CellIdentity c = ci.getCellIdentity(); int t = getCellType(ci); diff --git a/services/core/jni/gnss/AGnssRil.cpp b/services/core/jni/gnss/AGnssRil.cpp index 424ffd463713..34e4976dcca0 100644 --- a/services/core/jni/gnss/AGnssRil.cpp +++ b/services/core/jni/gnss/AGnssRil.cpp @@ -55,13 +55,13 @@ jboolean AGnssRil::setRefLocation(jint type, jint mcc, jint mnc, jint lac, jlong case IAGnssRil::AGnssRefLocationType::UMTS_CELLID: case IAGnssRil::AGnssRefLocationType::LTE_CELLID: case IAGnssRil::AGnssRefLocationType::NR_CELLID: - location.cellID.mcc = mcc; - location.cellID.mnc = mnc; - location.cellID.lac = lac; - location.cellID.cid = cid; - location.cellID.tac = tac; - location.cellID.pcid = pcid; - location.cellID.arfcn = arfcn; + location.cellID.mcc = static_cast(mcc); + location.cellID.mnc = static_cast(mnc); + location.cellID.lac = static_cast(lac); + location.cellID.cid = static_cast(cid); + location.cellID.tac = static_cast(tac); + location.cellID.pcid = static_cast(pcid); + location.cellID.arfcn = static_cast(arfcn); break; default: ALOGE("Unknown cellid (%s:%d).", __FUNCTION__, __LINE__); @@ -106,20 +106,24 @@ jboolean AGnssRil_V1_0::setSetId(jint type, const jstring& setid_string) { return checkHidlReturn(result, "IAGnssRil_V1_0 setSetId() failed."); } -jboolean AGnssRil_V1_0::setRefLocation(jint type, jint mcc, jint mnc, jint lac, jlong cid, jint, - jint, jint) { +jboolean AGnssRil_V1_0::setRefLocation(jint type, jint mcc, jint mnc, jint lac, jlong cid, jint tac, + jint pcid, jint) { IAGnssRil_V1_0::AGnssRefLocation location; - switch (static_cast(type)) { + location.type = static_cast(type); + + switch (location.type) { case IAGnssRil_V1_0::AGnssRefLocationType::GSM_CELLID: case IAGnssRil_V1_0::AGnssRefLocationType::UMTS_CELLID: - location.type = static_cast(type); - location.cellID.mcc = mcc; - location.cellID.mnc = mnc; - location.cellID.lac = lac; - location.cellID.cid = cid; + case IAGnssRil_V1_0::AGnssRefLocationType::LTE_CELLID: + location.cellID.mcc = static_cast(mcc); + location.cellID.mnc = static_cast(mnc); + location.cellID.lac = static_cast(lac); + location.cellID.cid = static_cast(cid); + location.cellID.tac = static_cast(tac); + location.cellID.pcid = static_cast(pcid); break; default: - ALOGE("Neither a GSM nor a UMTS cellid (%s:%d).", __FUNCTION__, __LINE__); + ALOGE("Unknown cellid (%s:%d).", __FUNCTION__, __LINE__); return JNI_FALSE; break; } -- cgit v1.2.3-59-g8ed1b