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

Commit 5eeb79d4 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Query isEmergencySmsMode API when checking if emergency for GPS

When location SUPL request comes in for GPS NI handler,
also check emergency SMS mode in telephony, which
is true for a carrier defined amount of time after an
emergency SMS is sent.

Bug: 126091115
Test: manual - send fake emergency sms, check api is true.
Change-Id: I34d26d2940af5b0c412e20ce3668344da8656339
parent 05a8e0b4
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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) {
+16 −0
Original line number Diff line number Diff line
@@ -1534,6 +1534,21 @@ public class CarrierConfigManager {
    public static final String KEY_ALLOW_NON_EMERGENCY_CALLS_IN_ECM_BOOL =
            "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},
@@ -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(
+29 −0
Original line number Diff line number Diff line
@@ -6998,6 +6998,35 @@ public class TelephonyManager {
        return mode;
    }

    /**
     * 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.
     *
+5 −0
Original line number Diff line number Diff line
@@ -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.
     */