From df4111c2ab8b0f77435f96d13db5b737232fa439 Mon Sep 17 00:00:00 2001 From: Roman Hakh Date: Thu, 13 Aug 2020 17:08:53 +0300 Subject: [PATCH] DO NOT MERGE: GNSS: Add a check of SIM presence to GnssConfig There are functions in the GnssConfiguration class that load and apply GNSS properties from a carrier configuration file. But these properties are related to SUPL and LPP that are used in cell phones. Therefore, need to check the presence of SIM in device before printing error messages. Bug: 163993486 Test: $ adb logcat | grep 'Unable to set ES_EXTENSION_SEC: 0' to make sure that properties weren't applied. Signed-off-by: Roman Hakh Change-Id: I173c8d614c1e2923f478698ffd6a806b04dcbf27 --- .../com/android/server/location/GnssConfiguration.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/location/GnssConfiguration.java b/services/core/java/com/android/server/location/GnssConfiguration.java index 18d9f69c9735c..9c7adab922310 100644 --- a/services/core/java/com/android/server/location/GnssConfiguration.java +++ b/services/core/java/com/android/server/location/GnssConfiguration.java @@ -21,6 +21,7 @@ import android.os.PersistableBundle; import android.os.SystemProperties; import android.telephony.CarrierConfigManager; import android.telephony.SubscriptionManager; +import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; import android.util.StatsLog; @@ -236,6 +237,13 @@ class GnssConfiguration { logConfigurations(); final HalInterfaceVersion gnssConfigurationIfaceVersion = getHalInterfaceVersion(); + + TelephonyManager phone = (TelephonyManager) + mContext.getSystemService(Context.TELEPHONY_SERVICE); + int ddSubId = SubscriptionManager.getDefaultDataSubscriptionId(); + String simOperator = SubscriptionManager.isValidSubscriptionId(ddSubId) + ? phone.getSimOperator(ddSubId) : phone.getSimOperator(); + if (gnssConfigurationIfaceVersion != null) { // Set to a range checked value. if (isConfigEsExtensionSecSupported(gnssConfigurationIfaceVersion) @@ -271,7 +279,7 @@ class GnssConfiguration { try { int propertyValueInt = Integer.decode(propertyValueString); boolean result = entry.getValue().set(propertyValueInt); - if (!result) { + if (!result && !TextUtils.isEmpty(simOperator)) { Log.e(TAG, "Unable to set " + propertyName); } } catch (NumberFormatException e) {