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

Commit 585b2858 authored by Meng Wang's avatar Meng Wang Committed by Android (Google) Code Review
Browse files

Merge "Migrate GPS configs to carrier config"

parents aea24386 19b214dd
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -2842,19 +2842,6 @@

    <bool name="config_auto_attach_data_on_creation">true</bool>

    <!-- Values for GPS configuration -->
    <string-array translatable="false" name="config_gpsParameters">
        <item>SUPL_HOST=supl.google.com</item>
        <item>SUPL_PORT=7275</item>
        <item>SUPL_VER=0x20000</item>
        <item>SUPL_MODE=1</item>
        <item>SUPL_ES=1</item>
        <item>LPP_PROFILE=0</item>
        <item>USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL=1</item>
        <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>
        <item>GPS_LOCK=3</item>
    </string-array>

    <!-- Sprint need a 70 ms delay for 3way call -->
    <integer name="config_cdma_3waycall_flash_delay">0</integer>

+0 −1
Original line number Diff line number Diff line
@@ -1269,7 +1269,6 @@
  <java-symbol type="array" name="config_telephonyEuiccDeviceCapabilities" />
  <java-symbol type="array" name="config_telephonyHardware" />
  <java-symbol type="array" name="config_keySystemUuidMapping" />
  <java-symbol type="array" name="config_gpsParameters" />
  <java-symbol type="array" name="required_apps_managed_user" />
  <java-symbol type="array" name="required_apps_managed_profile" />
  <java-symbol type="array" name="required_apps_managed_device" />
+40 −32
Original line number Diff line number Diff line
@@ -188,7 +188,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
    private static final int ADD_LISTENER = 8;
    private static final int REMOVE_LISTENER = 9;
    private static final int DOWNLOAD_XTRA_DATA_FINISHED = 11;
    private static final int SUBSCRIPTION_OR_SIM_CHANGED = 12;
    private static final int SUBSCRIPTION_OR_CARRIER_CONFIG_CHANGED = 12;
    private static final int INITIALIZE_HANDLER = 13;
    private static final int REQUEST_SUPL_CONNECTION = 14;
    private static final int RELEASE_SUPL_CONNECTION = 15;
@@ -411,9 +411,6 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
    private final static String ALARM_WAKEUP = "com.android.internal.location.ALARM_WAKEUP";
    private final static String ALARM_TIMEOUT = "com.android.internal.location.ALARM_TIMEOUT";

    // SIM/Carrier info.
    private final static String SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";

    // Persist property for LPP_PROFILE
    private final static String LPP_PROFILE = "persist.sys.gps.lpp";

@@ -483,18 +480,20 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
                case Intent.ACTION_SCREEN_ON:
                    updateLowPowerMode();
                    break;
                case SIM_STATE_CHANGED:
                    subscriptionOrSimChanged(context);
                case CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED:
                    subscriptionOrCarrierConfigChanged(context);
                    break;
            }
        }
    };

    // TODO(b/119326010): replace OnSubscriptionsChangedListener with
    // ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED broadcast reseiver.
    private final OnSubscriptionsChangedListener mOnSubscriptionsChangedListener =
            new OnSubscriptionsChangedListener() {
                @Override
                public void onSubscriptionsChanged() {
                    sendMessage(SUBSCRIPTION_OR_SIM_CHANGED, 0, null);
                    sendMessage(SUBSCRIPTION_OR_CARRIER_CONFIG_CHANGED, 0, null);
                }
            };

@@ -506,7 +505,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        mHandler.post(() -> native_set_satellite_blacklist(constellations, svids));
    }

    private void subscriptionOrSimChanged(Context context) {
    private void subscriptionOrCarrierConfigChanged(Context context) {
        if (DEBUG) Log.d(TAG, "received SIM related action: ");
        TelephonyManager phone = (TelephonyManager)
                mContext.getSystemService(Context.TELEPHONY_SERVICE);
@@ -521,12 +520,12 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
                    PersistableBundle b = configManager.getConfig();
                    if (b != null) {
                        isKeepLppProfile =
                                b.getBoolean(CarrierConfigManager.KEY_PERSIST_LPP_MODE_BOOL);
                                b.getBoolean(CarrierConfigManager.Gps.KEY_PERSIST_LPP_MODE_BOOL);
                    }
                }
                if (isKeepLppProfile) {
                    // load current properties for the carrier
                    loadPropertiesFromResource(context, mProperties);
                    loadPropertiesFromCarrierConfig(context, mProperties);
                    String lpp_profile = mProperties.getProperty("LPP_PROFILE");
                    // set the persist property LPP_PROFILE for the value
                    if (lpp_profile != null) {
@@ -571,7 +570,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements

    private void reloadGpsProperties(Context context, Properties properties) {
        if (DEBUG) Log.d(TAG, "Reset GPS properties, previous size = " + properties.size());
        loadPropertiesFromResource(context, properties);
        loadPropertiesFromCarrierConfig(context, properties);

        String lpp_prof = SystemProperties.get(LPP_PROFILE);
        if (!TextUtils.isEmpty(lpp_prof)) {
@@ -581,7 +580,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        /*
         * Overlay carrier properties from a debug configuration file.
         */
        loadPropertiesFromFile(properties);
        loadPropertiesFromGpsDebugConfig(properties);
        // TODO: we should get rid of C2K specific setting.
        setSuplHostPort(properties.getProperty("SUPL_HOST"),
                properties.getProperty("SUPL_PORT"));
@@ -651,25 +650,34 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        }
    }

    private void loadPropertiesFromResource(Context context,
            Properties properties) {
        String[] configValues = context.getResources().getStringArray(
                com.android.internal.R.array.config_gpsParameters);
        for (String item : configValues) {
            if (DEBUG) Log.d(TAG, "GpsParamsResource: " + 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(), value);
            } else {
                Log.w(TAG, "malformed contents: " + item);
    private void loadPropertiesFromCarrierConfig(Context context, Properties properties) {
        CarrierConfigManager configManager = (CarrierConfigManager)
                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        if (configManager == null) {
            return;
        }
        PersistableBundle configs = configManager.getConfigForSubId(
                SubscriptionManager.getDefaultDataSubscriptionId());
        if (configs == null) {
            if (DEBUG) Log.d(TAG, "SIM not ready, use default carrier config.");
            configs = CarrierConfigManager.getDefaultConfig();
        }
        for (String configKey : configs.keySet()) {
            if (configKey.startsWith(CarrierConfigManager.Gps.KEY_PREFIX)) {
                String key = configKey
                        .substring(CarrierConfigManager.Gps.KEY_PREFIX.length())
                        .toUpperCase();
                Object value = configs.get(configKey);
                if (value instanceof String) {
                    // All GPS properties are of String type; convert so.
                    if (DEBUG) Log.d(TAG, "Gps config: " + key + " = " + value);
                    properties.setProperty(key, (String) value);
                }
            }
        }
    }

    private void loadPropertiesFromFile(Properties properties) {
    private void loadPropertiesFromGpsDebugConfig(Properties properties) {
        try {
            File file = new File(DEBUG_PROPERTIES_FILE);
            FileInputStream stream = null;
@@ -2017,8 +2025,8 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
                case UPDATE_LOCATION:
                    handleUpdateLocation((Location) msg.obj);
                    break;
                case SUBSCRIPTION_OR_SIM_CHANGED:
                    subscriptionOrSimChanged(mContext);
                case SUBSCRIPTION_OR_CARRIER_CONFIG_CHANGED:
                    subscriptionOrCarrierConfigChanged(mContext);
                    break;
                case INITIALIZE_HANDLER:
                    handleInitialize();
@@ -2085,7 +2093,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
            intentFilter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
            intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
            intentFilter.addAction(Intent.ACTION_SCREEN_ON);
            intentFilter.addAction(SIM_STATE_CHANGED);
            intentFilter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
            mContext.registerReceiver(mBroadcastReceiver, intentFilter, null, this);

            mNetworkConnectivityHandler.registerNetworkCallbacks();
@@ -2167,8 +2175,8 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
                return "DOWNLOAD_XTRA_DATA_FINISHED";
            case UPDATE_LOCATION:
                return "UPDATE_LOCATION";
            case SUBSCRIPTION_OR_SIM_CHANGED:
                return "SUBSCRIPTION_OR_SIM_CHANGED";
            case SUBSCRIPTION_OR_CARRIER_CONFIG_CHANGED:
                return "SUBSCRIPTION_OR_CARRIER_CONFIG_CHANGED";
            case INITIALIZE_HANDLER:
                return "INITIALIZE_HANDLER";
            case REPORT_LOCATION:
+109 −12
Original line number Diff line number Diff line
@@ -1792,17 +1792,6 @@ public class CarrierConfigManager {
    public static final String KEY_EDITABLE_WFC_ROAMING_MODE_BOOL =
            "editable_wfc_roaming_mode_bool";

    /**
     * Determine whether current lpp_mode used for E-911 needs to be kept persistently.
     * {@code false} - not keeping the lpp_mode means using default configuration of gps.conf
     *                 when sim is not presented.
     * {@code true}  - current lpp_profile of carrier will be kepted persistently
     *                 even after sim is removed.
     *
     * @hide
     */
    public static final String KEY_PERSIST_LPP_MODE_BOOL = "persist_lpp_mode_bool";

    /**
     * Carrier specified WiFi networks.
     * @hide
@@ -2432,6 +2421,114 @@ public class CarrierConfigManager {
    public static final String KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_RSSNR_INT =
            "opportunistic_network_exit_threshold_rssnr_int";

    /**
     * GPS configs. See android.hardware.gnss@1.0 IGnssConfiguration.
     * @hide
     */
    public static final class Gps {
        /** Prefix of all Gps.KEY_* constants. */
        public static final String KEY_PREFIX = "gps.";

        /**
         * Determine whether current lpp_mode used for E-911 needs to be kept persistently.
         * {@code false} - not keeping the lpp_mode means using default configuration of gps.conf
         *                 when sim is not presented.
         * {@code true}  - current lpp_profile of carrier will be kepted persistently
         *                 even after sim is removed. This is default.
         */
        public static final String KEY_PERSIST_LPP_MODE_BOOL = KEY_PREFIX + "persist_lpp_mode_bool";

        /**
         * SUPL server host for SET Initiated & non-ES Network-Initiated SUPL requests.
         * Default to supl.google.com
         */
        public static final String KEY_SUPL_HOST_STRING = KEY_PREFIX + "supl_host";

        /** SUPL server port. Default to 7275. */
        public static final String KEY_SUPL_PORT_STRING = KEY_PREFIX + "supl_port";

        /**
         * The SUPL version requested by Carrier. This is a bit mask
         * with bits 0:7 representing a service indicator field, bits 8:15
         * representing the minor version and bits 16:23 representing the
         * major version. Default to 0x20000.
         */
        public static final String KEY_SUPL_VER_STRING = KEY_PREFIX + "supl_ver";

        /**
         * SUPL_MODE configuration bit mask
         * 1 - Mobile Station Based. This is default.
         * 2 - Mobile Station Assisted.
         */
        public static final String KEY_SUPL_MODE_STRING = KEY_PREFIX + "supl_mode";

        /**
         * Whether to limit responses to SUPL ES mode requests only during user emergency sessions
         * (e.g. E911), and SUPL non-ES requests to only outside of non user emergency sessions.
         * 0 - no.
         * 1 - yes. This is default.
         */
        // TODO(b/119567985): name this key properly
        public static final String KEY_SUPL_ES_STRING = KEY_PREFIX + "supl_es";

        /**
         * LTE Positioning Profile settings bit mask.
         * 0 - Radio Resource Location Protocol in user plane and control plane. This is default.
         * 1 - Enable LTE Positioning Protocol in user plane.
         * 2 - Enable LTE Positioning Protocol in control plane.
         */
        public static final String KEY_LPP_PROFILE_STRING = KEY_PREFIX + "lpp_profile";

        /**
         * Determine whether to use emergency PDN for emergency SUPL.
         * 0 - no.
         * 1 - yes. This is default.
         */
        public static final String KEY_USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_STRING =
                KEY_PREFIX + "use_emergency_pdn_for_emergency_supl";

        /**
         * A_GLONASS_POS_PROTOCOL_SELECT bit mask.
         * 0 - Don't use A-GLONASS. This is default.
         * 1 - Use A-GLONASS in Radio Resource Control(RRC) control-plane.
         * 2 - Use A-GLONASS in Radio Resource Location user-plane.
         * 4 - Use A-GLONASS in LTE Positioning Protocol User plane.
         */
        public static final String KEY_A_GLONASS_POS_PROTOCOL_SELECT_STRING =
                KEY_PREFIX + "a_glonass_pos_protocol_select";

        /**
         * GPS_LOCK configuration bit mask to specify GPS device behavior toward other services,
         * when Location Settings are off.
         * "0" - No lock.
         * "1" - Lock Mobile Originated GPS functionalities.
         * "2" - Lock Network initiated GPS functionalities.
         * "3" - Lock both. This is default.
         */
        public static final String KEY_GPS_LOCK_STRING = KEY_PREFIX + "gps_lock";

        /**
         * SUPL NI emergency extension time in seconds. Default to "0".
         */
        public static final String KEY_ES_EXTENSION_SEC = KEY_PREFIX + "es_extension_sec";

        private static PersistableBundle getDefaults() {
            PersistableBundle defaults = new PersistableBundle();
            defaults.putBoolean(KEY_PERSIST_LPP_MODE_BOOL, true);
            defaults.putString(KEY_SUPL_HOST_STRING, "supl.google.com");
            defaults.putString(KEY_SUPL_PORT_STRING, "7275");
            defaults.putString(KEY_SUPL_VER_STRING, "0x20000");
            defaults.putString(KEY_SUPL_MODE_STRING, "1");
            defaults.putString(KEY_SUPL_ES_STRING, "1");
            defaults.putString(KEY_LPP_PROFILE_STRING, "0");
            defaults.putString(KEY_USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_STRING, "1");
            defaults.putString(KEY_A_GLONASS_POS_PROTOCOL_SELECT_STRING, "0");
            defaults.putString(KEY_GPS_LOCK_STRING, "3");
            defaults.putString(KEY_ES_EXTENSION_SEC, "0");
            return defaults;
        }
    }

    /** The default value for every variable. */
    private final static PersistableBundle sDefaults;

@@ -2724,7 +2821,6 @@ public class CarrierConfigManager {
        sDefaults.putStringArray(KEY_FILTERED_CNAP_NAMES_STRING_ARRAY, null);
        sDefaults.putBoolean(KEY_EDITABLE_WFC_ROAMING_MODE_BOOL, false);
        sDefaults.putBoolean(KEY_STK_DISABLE_LAUNCH_BROWSER_BOOL, false);
        sDefaults.putBoolean(KEY_PERSIST_LPP_MODE_BOOL, true);
        sDefaults.putStringArray(KEY_CARRIER_WIFI_STRING_ARRAY, null);
        sDefaults.putInt(KEY_PREF_NETWORK_NOTIFICATION_DELAY_INT, -1);
        sDefaults.putInt(KEY_EMERGENCY_NOTIFICATION_DELAY_INT, -1);
@@ -2801,6 +2897,7 @@ public class CarrierConfigManager {
        sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_RSSNR_INT, 45);
        /* Default value is minimum RSSNR level needed for SIGNAL_STRENGTH_MODERATE */
        sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_RSSNR_INT, 10);
        sDefaults.putAll(Gps.getDefaults());
    }

    /**