Merge "Query isEmergencySmsMode API when checking if emergency for GPS"
diff --git a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
index b531325..4c8d045 100644
--- a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
+++ b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
@@ -241,6 +241,8 @@
* 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 @@
(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 bafec5c..5e9d33a 100755
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -1535,6 +1535,21 @@
"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.
@@ -2745,6 +2760,7 @@
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 bf8eb0f..9dcadf1 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -6994,6 +6994,35 @@
}
/**
+ * 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 cbb9b88..209d35e 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -1699,6 +1699,11 @@
*/
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.
*/