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

Commit c0d55b80 authored by Tyler Gunn's avatar Tyler Gunn Committed by Gerrit Code Review
Browse files

Merge "Add support for network identified IMS emergency calls."

parents 272b083b 811cbae1
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ public abstract class Connection {
        public void onRttInitiated();
        public void onRttTerminated();
        public void onOriginalConnectionReplaced(Connection newConnection);
        public void onIsNetworkEmergencyCallChanged(boolean isEmergencyCall);
    }

    /**
@@ -156,6 +157,8 @@ public abstract class Connection {
        public void onRttTerminated() {}
        @Override
        public void onOriginalConnectionReplaced(Connection newConnection) {}
        @Override
        public void onIsNetworkEmergencyCallChanged(boolean isEmergencyCall) {}
    }

    public static final int AUDIO_QUALITY_STANDARD = 1;
@@ -224,6 +227,11 @@ public abstract class Connection {
    private boolean mAnsweringDisconnectsActiveCall;
    private boolean mAllowAddCallDuringVideoCall;

    /**
     * When {@code true}, the network has indicated that this is an emergency call.
     */
    private boolean mIsNetworkIdentifiedEmergencyCall;

    /**
     * Used to indicate that this originated from pulling a {@link android.telecom.Connection} with
     * {@link android.telecom.Connection#PROPERTY_IS_EXTERNAL_CALL}.
@@ -1139,6 +1147,25 @@ public abstract class Connection {
        }
    }

    /**
     * Sets whether this {@link Connection} has been identified by the network as an emergency call.
     * @param isNetworkIdentifiedEmergencyCall {@code true} if ecall, {@code false} otherwise.
     */
    public void setIsNetworkIdentifiedEmergencyCall(boolean isNetworkIdentifiedEmergencyCall) {
        mIsNetworkIdentifiedEmergencyCall = isNetworkIdentifiedEmergencyCall;
        for (Listener l : mListeners) {
            l.onIsNetworkEmergencyCallChanged(isNetworkIdentifiedEmergencyCall);
        }
    }

    /**
     * @return Whether this {@link Connection} has been identified by the network as an emergency
     * call.
     */
    public boolean isNetworkIdentifiedEmergencyCall() {
        return mIsNetworkIdentifiedEmergencyCall;
    }

    /**
     * Build a human representation of a connection instance, suitable for debugging.
     * Don't log personal stuff unless in debug mode.
+39 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.IntentFilter;
import android.net.Uri;
import android.os.BadParcelableException;
import android.os.Build;
import android.os.Bundle;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.ims.ImsCallProfile;
@@ -104,6 +105,12 @@ public class TelephonyTester {
    private static final String EXTRA_CODE = "code";
    private static final String EXTRA_TYPE = "type";

    /**
     * Test-only intent used to trigger signalling that an IMS call is an emergency call.
     */
    private static final String ACTION_TEST_IMS_E_CALL =
            "com.android.internal.telephony.TestImsECall";

    private static final String ACTION_TEST_SERVICE_STATE =
            "com.android.internal.telephony.TestServiceState";

@@ -161,6 +168,9 @@ public class TelephonyTester {
                    mServiceStateTestIntent = intent;
                    mPhone.getServiceStateTracker().sendEmptyMessage(
                            ServiceStateTracker.EVENT_NETWORK_STATE_CHANGED);
                } else if (action.equals(ACTION_TEST_IMS_E_CALL)) {
                    log("handle test IMS ecall intent");
                    testImsECall();
                } else {
                    if (DBG) log("onReceive: unknown action=" + action);
                }
@@ -189,6 +199,7 @@ public class TelephonyTester {
                filter.addAction(ACTION_TEST_SUPP_SRVC_FAIL);
                filter.addAction(ACTION_TEST_HANDOVER_FAIL);
                filter.addAction(ACTION_TEST_SUPP_SRVC_NOTIFICATION);
                filter.addAction(ACTION_TEST_IMS_E_CALL);
                mImsExternalCallStates = new ArrayList<ImsExternalCallState>();
            } else {
                filter.addAction(ACTION_TEST_SERVICE_STATE);
@@ -375,4 +386,32 @@ public class TelephonyTester {
            log("Override operator with " + operator);
        }
    }

    void testImsECall() {
        // Attempt to get the active IMS call before parsing the test XML file.
        ImsPhone imsPhone = (ImsPhone) mPhone;
        if (imsPhone == null) {
            return;
        }

        ImsPhoneCall imsPhoneCall = imsPhone.getForegroundCall();
        if (imsPhoneCall == null) {
            return;
        }

        ImsCall imsCall = imsPhoneCall.getImsCall();
        if (imsCall == null) {
            return;
        }

        ImsCallProfile callProfile = imsCall.getCallProfile();
        Bundle extras = callProfile.getCallExtras();
        if (extras == null) {
            extras = new Bundle();
        }
        extras.putBoolean(ImsCallProfile.EXTRA_E_CALL, true);
        callProfile.mCallExtras = extras;
        imsCall.getImsCallSessionListenerProxy().callSessionUpdated(imsCall.getSession(),
                callProfile);
    }
}
 No newline at end of file
+7 −1
Original line number Diff line number Diff line
@@ -1079,6 +1079,12 @@ public class ImsPhoneConnection extends Connection implements
        }
    }

    private void updateEmergencyCallFromExtras(Bundle extras) {
        if (extras.getBoolean(ImsCallProfile.EXTRA_E_CALL)) {
            setIsNetworkIdentifiedEmergencyCall(true);
        }
    }

    /**
     * Check for a change in call extras of {@link ImsCall}, and
     * update the {@link ImsPhoneConnection} accordingly.
@@ -1100,7 +1106,7 @@ public class ImsPhoneConnection extends Connection implements
        final boolean changed = !areBundlesEqual(extras, mExtras);
        if (changed) {
            updateImsCallRatFromExtras(extras);

            updateEmergencyCallFromExtras(extras);
            mExtras.clear();
            mExtras.putAll(extras);
            setConnectionExtras(mExtras);