diff options
| author | 2024-09-11 02:44:28 +0000 | |
|---|---|---|
| committer | 2024-09-11 02:44:28 +0000 | |
| commit | fa07bc40e06ec647ec759d9f5108cf90a71b1c94 (patch) | |
| tree | 55dbbb773e49ec4b3efecf8874b0560d8b8c0f9b | |
| parent | 05f2be1e9e1f8fd4bdebc2eaea06f4e9dcd0a3eb (diff) | |
| parent | a7c0a2685820bb8151c852bd2f3110d7af044858 (diff) | |
Merge "Support carrier config for NI SUPL message injection" into main
5 files changed, 95 insertions, 25 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index 9875c0276bf0..1865e8c55d80 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -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."; } diff --git a/location/java/android/location/flags/location.aconfig b/location/java/android/location/flags/location.aconfig index 3c387d33286a..bbd91fc19ee5 100644 --- a/location/java/android/location/flags/location.aconfig +++ b/location/java/android/location/flags/location.aconfig @@ -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 +} diff --git a/services/core/java/com/android/server/location/gnss/GnssConfiguration.java b/services/core/java/com/android/server/location/gnss/GnssConfiguration.java index a439f16e6d97..1740010a8d5f 100644 --- a/services/core/java/com/android/server/location/gnss/GnssConfiguration.java +++ b/services/core/java/com/android/server/location/gnss/GnssConfiguration.java @@ -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); } /** 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 19381509c7fe..4b2c12abe5bb 100644 --- a/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java +++ b/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java @@ -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: "); diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index aca0941cbcc5..41223db750c0 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -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; } } |