Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03c1749f authored by Shinru Han's avatar Shinru Han
Browse files

Support GNSS configuration overlay from resource

Add GNSS configuration overlay from resource to override carrier config.

Bug: 317734846
Test: on device
Merged-In: I05e59c237202f7b486646a28377b6a8d5ff82c21
Change-Id: I05e59c237202f7b486646a28377b6a8d5ff82c21
(cherry picked from commit 08e28d98c98e1dfe2d2f25b46775d7802aaa69ed)
parent 99d20ad8
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -34,3 +34,10 @@ flag {
    description: "Flag for location validation"
    bug: "314328533"
}

flag {
    name: "gnss_configuration_from_resource"
    namespace: "location"
    description: "Flag for GNSS configuration from resource"
    bug: "317734846"
}
+26 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.location.gnss;

import android.content.Context;
import android.location.flags.Flags;
import android.os.PersistableBundle;
import android.os.SystemProperties;
import android.telephony.CarrierConfigManager;
@@ -36,6 +37,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
@@ -275,6 +277,11 @@ public class GnssConfiguration {
        }
        loadPropertiesFromCarrierConfig(inEmergency, activeSubId);

        if (Flags.gnssConfigurationFromResource()) {
            // Overlay carrier properties from resources.
            loadPropertiesFromResource(mContext, mProperties);
        }

        if (isSimAbsent(mContext)) {
            // Use the default SIM's LPP profile when SIM is absent.
            String lpp_prof = SystemProperties.get(LPP_PROFILE);
@@ -382,7 +389,7 @@ public class GnssConfiguration {
            if (configKey.startsWith(CarrierConfigManager.Gps.KEY_PREFIX)) {
                String key = configKey
                        .substring(CarrierConfigManager.Gps.KEY_PREFIX.length())
                        .toUpperCase();
                        .toUpperCase(Locale.ROOT);
                Object value = configs.get(configKey);
                if (DEBUG) Log.d(TAG, "Gps config: " + key + " = " + value);
                if (value instanceof String) {
@@ -410,6 +417,24 @@ public class GnssConfiguration {
        }
    }

    private void loadPropertiesFromResource(Context context,
            Properties properties) {
        String[] configValues = context.getResources().getStringArray(
                com.android.internal.R.array.config_gnssParameters);
        for (String item : configValues) {
            if (DEBUG) Log.d(TAG, "GnssParamsResource: " + item);
            // We need to support "KEY =", but not "=VALUE".
            int index = item.indexOf("=");
            if (index > 0 && index + 1 < item.length()) {
                String key = item.substring(0, index);
                String value = item.substring(index + 1);
                properties.setProperty(key.trim().toUpperCase(Locale.ROOT), value);
            } else {
                Log.w(TAG, "malformed contents: " + item);
            }
        }
    }

    private int getRangeCheckedConfigEsExtensionSec() {
        int emergencyExtensionSeconds = getIntConfig(CONFIG_ES_EXTENSION_SEC, 0);
        if (emergencyExtensionSeconds > MAX_EMERGENCY_MODE_EXTENSION_SECONDS) {