diff options
author | Shinru Han <shinruhan@google.com> | 2022-10-14 17:16:06 +0800 |
---|---|---|
committer | Yu-Han Yang <yuhany@google.com> | 2022-10-24 18:12:23 +0000 |
commit | 580183984a2bdce0d1596776652da698958d89e2 (patch) | |
tree | a4ef3d514425d00ec46553460076eb056203d493 | |
parent | e2386caff0bc7f0158880dc305002465b8d7991f (diff) | |
download | base-580183984a2bdce0d1596776652da698958d89e2.tar.gz |
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
-rw-r--r-- | services/core/java/com/android/server/location/gnss/GnssLocationProvider.java | 7 | ||||
-rw-r--r-- | 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 f5c2bbc8d5a2..59c4f50e732f 100644 --- a/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java +++ b/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java @@ -1420,7 +1420,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; @@ -1495,7 +1497,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<int>(mcc); + location.cellID.mnc = static_cast<int>(mnc); + location.cellID.lac = static_cast<int>(lac); + location.cellID.cid = static_cast<long>(cid); + location.cellID.tac = static_cast<int>(tac); + location.cellID.pcid = static_cast<int>(pcid); + location.cellID.arfcn = static_cast<int>(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<IAGnssRil_V1_0::AGnssRefLocationType>(type)) { + location.type = static_cast<IAGnssRil_V1_0::AGnssRefLocationType>(type); + + switch (location.type) { case IAGnssRil_V1_0::AGnssRefLocationType::GSM_CELLID: case IAGnssRil_V1_0::AGnssRefLocationType::UMTS_CELLID: - location.type = static_cast<IAGnssRil_V1_0::AGnssRefLocationType>(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<uint16_t>(mcc); + location.cellID.mnc = static_cast<uint16_t>(mnc); + location.cellID.lac = static_cast<uint16_t>(lac); + location.cellID.cid = static_cast<uint32_t>(cid); + location.cellID.tac = static_cast<uint16_t>(tac); + location.cellID.pcid = static_cast<uint16_t>(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; } |