diff options
4 files changed, 55 insertions, 1 deletions
diff --git a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java index b5313256e4dc..4c8d04549bed 100644 --- a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java +++ b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java @@ -241,6 +241,8 @@ public class GpsNetInitiatedHandler { * window after the end of that call. * 3. If the device is in a emergency callback state, this is provided by querying * TelephonyManager. + * 4. If the user has recently sent an Emergency SMS and telephony reports that it is in + * emergency SMS mode, this is provided by querying TelephonyManager. * @return true if is considered in user initiated emergency mode for NI purposes */ public boolean getInEmergency() { @@ -248,7 +250,9 @@ public class GpsNetInitiatedHandler { (SystemClock.elapsedRealtime() - mCallEndElapsedRealtimeMillis) < mEmergencyExtensionMillis; boolean isInEmergencyCallback = mTelephonyManager.getEmergencyCallbackMode(); - return mIsInEmergencyCall || isInEmergencyCallback || isInEmergencyExtension; + boolean isInEmergencySmsMode = mTelephonyManager.isInEmergencySmsMode(); + return mIsInEmergencyCall || isInEmergencyCallback || isInEmergencyExtension + || isInEmergencySmsMode; } public void setEmergencyExtensionSeconds(int emergencyExtensionSeconds) { diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 3454c1cbc14c..d3d282fd2d78 100755 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -1535,6 +1535,21 @@ public class CarrierConfigManager { "allow_non_emergency_calls_in_ecm_bool"; /** + * Time that the telephony framework stays in "emergency SMS mode" after an emergency SMS is + * sent to the network. This is used by carriers to configure the time + * {@link TelephonyManager#isInEmergencySmsMode()} will be true after an emergency SMS is sent. + * This is used by GNSS to override user location permissions so that the carrier network can + * get the user's location for emergency services. + * + * The default is 0, which means that this feature is disabled. The maximum value for this timer + * is 300000 mS (5 minutes). + * + * @hide + */ + public static final String KEY_EMERGENCY_SMS_MODE_TIMER_MS_INT = + "emergency_sms_mode_timer_ms_int"; + + /** * Flag indicating whether to allow carrier video calls to emergency numbers. * When {@code true}, video calls to emergency numbers will be allowed. When {@code false}, * video calls to emergency numbers will be initiated as audio-only calls instead. @@ -2733,6 +2748,7 @@ public class CarrierConfigManager { sDefaults.putString(KEY_MMS_UA_PROF_URL_STRING, ""); sDefaults.putString(KEY_MMS_USER_AGENT_STRING, ""); sDefaults.putBoolean(KEY_ALLOW_NON_EMERGENCY_CALLS_IN_ECM_BOOL, true); + sDefaults.putInt(KEY_EMERGENCY_SMS_MODE_TIMER_MS_INT, 0); sDefaults.putBoolean(KEY_USE_RCS_PRESENCE_BOOL, false); sDefaults.putBoolean(KEY_FORCE_IMEI_BOOL, false); sDefaults.putInt( diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 43dcc6b27c66..8a3a7f3ab009 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -6999,6 +6999,35 @@ public class TelephonyManager { } /** + * Query Telephony to see if there has recently been an emergency SMS sent to the network by the + * user and we are still within the time interval after the emergency SMS was sent that we are + * considered in Emergency SMS mode. + * + * <p>This mode is used by other applications to allow them to perform special functionality, + * such as allow the GNSS service to provide user location to the carrier network for emergency + * when an emergency SMS is sent. This interval is set by + * {@link CarrierConfigManager#KEY_EMERGENCY_SMS_MODE_TIMER_MS_INT}. If + * the carrier does not support this mode, this function will always return false. + * + * @return true if this device is in emergency SMS mode, false otherwise. + * + * @hide + */ + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + public boolean isInEmergencySmsMode() { + + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.isInEmergencySmsMode(); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "getNetworkSelectionMode RemoteException", ex); + } + return false; + } + + /** * Set the preferred network type. * * <p>Requires Permission: diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 02a5bc8937ee..1823338697bf 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1699,6 +1699,11 @@ interface ITelephony { */ int getNetworkSelectionMode(int subId); + /** + * Return true if the device is in emergency sms mode, false otherwise. + */ + boolean isInEmergencySmsMode(); + /** * Get a list of SMS apps on a user. */ |