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

Commit fa07bc40 authored by Shinru Han's avatar Shinru Han Committed by Android (Google) Code Review
Browse files

Merge "Support carrier config for NI SUPL message injection" into main

parents 05f2be1e a7c0a268
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -44067,6 +44067,7 @@ package android.telephony {
  }
  public static final class CarrierConfigManager.Gps {
    field @FlaggedApi("android.location.flags.enable_ni_supl_message_injection_by_carrier_config") public static final String KEY_ENABLE_NI_SUPL_MESSAGE_INJECTION_BOOL = "gps.enable_ni_supl_message_injection_bool";
    field public static final String KEY_PERSIST_LPP_MODE_BOOL = "gps.persist_lpp_mode_bool";
    field public static final String KEY_PREFIX = "gps.";
  }
+8 −0
Original line number Diff line number Diff line
@@ -109,3 +109,11 @@ flag {
    description: "Flag for GNSS configuration from resource"
    bug: "317734846"
}

flag {
    name: "enable_ni_supl_message_injection_by_carrier_config"
    namespace: "location"
    description: "Flag for enabling NI SUPL message injection by carrier config"
    bug: "242105192"
    is_fixed_read_only: true
}
+4 −3
Original line number Diff line number Diff line
@@ -80,8 +80,8 @@ public class GnssConfiguration {
            "ENABLE_PSDS_PERIODIC_DOWNLOAD";
    private static final String CONFIG_ENABLE_ACTIVE_SIM_EMERGENCY_SUPL =
            "ENABLE_ACTIVE_SIM_EMERGENCY_SUPL";
    private static final String CONFIG_ENABLE_NI_SUPL_MESSAGE_INJECTION =
            "ENABLE_NI_SUPL_MESSAGE_INJECTION";
    private static final String CONFIG_ENABLE_NI_SUPL_MESSAGE_INJECTION_BOOL =
            "ENABLE_NI_SUPL_MESSAGE_INJECTION_BOOL";
    static final String CONFIG_LONGTERM_PSDS_SERVER_1 = "LONGTERM_PSDS_SERVER_1";
    static final String CONFIG_LONGTERM_PSDS_SERVER_2 = "LONGTERM_PSDS_SERVER_2";
    static final String CONFIG_LONGTERM_PSDS_SERVER_3 = "LONGTERM_PSDS_SERVER_3";
@@ -230,7 +230,8 @@ public class GnssConfiguration {
     * Default false if not set.
     */
    boolean isNiSuplMessageInjectionEnabled() {
        return getBooleanConfig(CONFIG_ENABLE_NI_SUPL_MESSAGE_INJECTION, false);
        return getBooleanConfig(CONFIG_ENABLE_NI_SUPL_MESSAGE_INJECTION_BOOL,
                false);
    }

    /**
+67 −22
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ import android.location.LocationManager;
import android.location.LocationRequest;
import android.location.LocationResult;
import android.location.LocationResult.BadLocationException;
import android.location.flags.Flags;
import android.location.provider.ProviderProperties;
import android.location.provider.ProviderRequest;
import android.location.util.identity.CallerIdentity;
@@ -310,6 +311,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
    private String mC2KServerHost;
    private int mC2KServerPort;
    private boolean mSuplEsEnabled = false;
    private boolean mNiSuplMessageListenerRegistered = false;

    private final LocationExtras mLocationExtras = new LocationExtras();
    private final NetworkTimeHelper mNetworkTimeHelper;
@@ -387,6 +389,10 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
            // Reload gnss config for no SIM case
            mGnssConfiguration.reloadGpsProperties();
        }
        if (Flags.enableNiSuplMessageInjectionByCarrierConfig()) {
            updateNiSuplMessageListenerRegistration(
                    mGnssConfiguration.isNiSuplMessageInjectionEnabled());
        }
    }

    private void reloadGpsProperties() {
@@ -532,28 +538,9 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        intentFilter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
        mContext.registerReceiver(mIntentReceiver, intentFilter, null, mHandler);

        if (mNetworkConnectivityHandler.isNativeAgpsRilSupported()
                && mGnssConfiguration.isNiSuplMessageInjectionEnabled()) {
            // Listen to WAP PUSH NI SUPL message.
            // See User Plane Location Protocol Candidate Version 3.0,
            // OMA-TS-ULP-V3_0-20110920-C, Section 8.3 OMA Push.
            intentFilter = new IntentFilter();
            intentFilter.addAction(Intents.WAP_PUSH_RECEIVED_ACTION);
            try {
                intentFilter.addDataType("application/vnd.omaloc-supl-init");
            } catch (IntentFilter.MalformedMimeTypeException e) {
                Log.w(TAG, "Malformed SUPL init mime type");
            }
            mContext.registerReceiver(mIntentReceiver, intentFilter, null, mHandler);

            // Listen to MT SMS NI SUPL message.
            // See User Plane Location Protocol Candidate Version 3.0,
            // OMA-TS-ULP-V3_0-20110920-C, Section 8.4 MT SMS.
            intentFilter = new IntentFilter();
            intentFilter.addAction(Intents.DATA_SMS_RECEIVED_ACTION);
            intentFilter.addDataScheme("sms");
            intentFilter.addDataAuthority("localhost", "7275");
            mContext.registerReceiver(mIntentReceiver, intentFilter, null, mHandler);
        if (!Flags.enableNiSuplMessageInjectionByCarrierConfig()) {
            updateNiSuplMessageListenerRegistration(
                    mGnssConfiguration.isNiSuplMessageInjectionEnabled());
        }

        mNetworkConnectivityHandler.registerNetworkCallbacks();
@@ -592,6 +579,20 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
                case TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED:
                    subscriptionOrCarrierConfigChanged();
                    break;
            }
        }
    };

    private BroadcastReceiver mNiSuplIntentReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (DEBUG) Log.d(TAG, "receive broadcast intent, action: " + action);
            if (action == null) {
                return;
            }

            switch (action) {
                case Intents.WAP_PUSH_RECEIVED_ACTION:
                case Intents.DATA_SMS_RECEIVED_ACTION:
                    injectSuplInit(intent);
@@ -1442,6 +1443,46 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        mGnssMetrics.logSvStatus(gnssStatus);
    }

    private void updateNiSuplMessageListenerRegistration(boolean shouldRegister) {
        if (!mNetworkConnectivityHandler.isNativeAgpsRilSupported()) {
            return;
        }
        if (mNiSuplMessageListenerRegistered == shouldRegister) {
            return;
        }

        // WAP PUSH NI SUPL message intent filter.
        // See User Plane Location Protocol Candidate Version 3.0,
        // OMA-TS-ULP-V3_0-20110920-C, Section 8.3 OMA Push.
        IntentFilter wapPushNiIntentFilter = new IntentFilter();
        wapPushNiIntentFilter.addAction(Intents.WAP_PUSH_RECEIVED_ACTION);
        try {
            wapPushNiIntentFilter
                .addDataType("application/vnd.omaloc-supl-init");
        } catch (IntentFilter.MalformedMimeTypeException e) {
            Log.w(TAG, "Malformed SUPL init mime type");
        }

        // MT SMS NI SUPL message intent filter.
        // See User Plane Location Protocol Candidate Version 3.0,
        // OMA-TS-ULP-V3_0-20110920-C, Section 8.4 MT SMS.
        IntentFilter mtSmsNiIntentFilter = new IntentFilter();
        mtSmsNiIntentFilter.addAction(Intents.DATA_SMS_RECEIVED_ACTION);
        mtSmsNiIntentFilter.addDataScheme("sms");
        mtSmsNiIntentFilter.addDataAuthority("localhost", "7275");

        if (shouldRegister) {
            mContext.registerReceiver(mNiSuplIntentReceiver,
                    wapPushNiIntentFilter, null, mHandler);
            mContext.registerReceiver(mNiSuplIntentReceiver,
                    mtSmsNiIntentFilter, null, mHandler);
            mNiSuplMessageListenerRegistered = true;
        } else {
            mContext.unregisterReceiver(mNiSuplIntentReceiver);
            mNiSuplMessageListenerRegistered = false;
        }
    }

    private void restartLocationRequest() {
        if (DEBUG) Log.d(TAG, "restartLocationRequest");
        setStarted(false);
@@ -1631,6 +1672,10 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        if (dumpAll) {
            mNetworkTimeHelper.dump(pw);
            pw.println("mSupportsPsds=" + mSupportsPsds);
            if (Flags.enableNiSuplMessageInjectionByCarrierConfig()) {
                pw.println("mNiSuplMessageListenerRegistered="
                        + mNiSuplMessageListenerRegistered);
            }
            pw.println(
                    "PsdsServerConfigured=" + mGnssConfiguration.isLongTermPsdsServerConfigured());
            pw.println("native internal state: ");
+15 −0
Original line number Diff line number Diff line
@@ -5030,6 +5030,18 @@ public class CarrierConfigManager {
        public static final String KEY_ES_SUPL_DATA_PLANE_ONLY_ROAMING_PLMN_STRING_ARRAY =
                KEY_PREFIX + "es_supl_data_plane_only_roaming_plmn_string_array";
        /**
         * Determine whether to enable Net Initiated SUPL (NI SUPL) message injection.
         * If enabled, the GnssLocationProvider will monitor for WAP PUSH or MT SMS NI SUPL intents
         * and subsequently inject the NI SUPL packet into the GNSS HAL.
         * {@code false} - Disable NI SUPL message injection. This is default.
         * {@code true} - Enable NI SUPL message injection.
         */
        @FlaggedApi(android.location.flags.Flags
                .FLAG_ENABLE_NI_SUPL_MESSAGE_INJECTION_BY_CARRIER_CONFIG)
        public static final String KEY_ENABLE_NI_SUPL_MESSAGE_INJECTION_BOOL =
                KEY_PREFIX + "enable_ni_supl_message_injection_bool";
        private static PersistableBundle getDefaults() {
            PersistableBundle defaults = new PersistableBundle();
            defaults.putBoolean(KEY_PERSIST_LPP_MODE_BOOL, true);
@@ -5047,6 +5059,9 @@ public class CarrierConfigManager {
            defaults.putInt(KEY_ES_SUPL_CONTROL_PLANE_SUPPORT_INT,
                    SUPL_EMERGENCY_MODE_TYPE_CP_ONLY);
            defaults.putStringArray(KEY_ES_SUPL_DATA_PLANE_ONLY_ROAMING_PLMN_STRING_ARRAY, null);
            if (android.location.flags.Flags.enableNiSuplMessageInjectionByCarrierConfig()) {
                defaults.putBoolean(KEY_ENABLE_NI_SUPL_MESSAGE_INJECTION_BOOL, false);
            }
            return defaults;
        }
    }