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

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

Merge "Add disconnect cause when outgoing call fails due to ongoing OTASP prov."

parents 4c59f9b7 52fd531a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ public class CallStateException extends Exception
    public static final int ERROR_CALL_RINGING = 4;
    public static final int ERROR_CALLING_DISABLED = 5;
    public static final int ERROR_TOO_MANY_CALLS = 6;
    public static final int ERROR_OTASP_PROVISIONING_IN_PROCESS = 7;

    public
    CallStateException()
+15 −1
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.util.Log;

import java.lang.Override;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -1000,6 +999,21 @@ public abstract class Connection {
        mDialString = oriNumber;
    }

    /**
     * Changes the address and presentation for this call.
     * @param newAddress The new address.
     * @param numberPresentation The number presentation for the address.
     */
    public void setAddress(String newAddress, int numberPresentation) {
        Rlog.i(TAG, "setAddress = " + newAddress);
        mAddress = newAddress;
        mNumberPresentation = numberPresentation;
    }

    public void setDialString(String newDialString) {
        mDialString = newDialString;
    }

    /**
     * Notifies listeners of a change to conference participant(s).
     *
+25 −7
Original line number Diff line number Diff line
@@ -275,7 +275,9 @@ public class GsmCdmaCallTracker extends CallTracker {
        clearDisconnected();

        // Check for issues which would preclude dialing and throw a CallStateException.
        checkForDialIssues();
        boolean isEmergencyCall = PhoneNumberUtils.isLocalEmergencyNumber(mPhone.getContext(),
                dialString);
        checkForDialIssues(isEmergencyCall);

        String origNumber = dialString;
        dialString = convertNumberIfNecessary(mPhone, dialString);
@@ -309,8 +311,7 @@ public class GsmCdmaCallTracker extends CallTracker {
            //we should have failed in !canDial() above before we get here
            throw new CallStateException("cannot dial in current state");
        }
        boolean isEmergencyCall = PhoneNumberUtils.isLocalEmergencyNumber(mPhone.getContext(),
                dialString);

        mPendingMO = new GsmCdmaConnection(mPhone, checkForTestEmergencyNumber(dialString),
                this, mForegroundCall, isEmergencyCall);
        mHangupPendingMO = false;
@@ -384,8 +385,11 @@ public class GsmCdmaCallTracker extends CallTracker {
        // note that this triggers call state changed notif
        clearDisconnected();

        boolean isEmergencyCall =
                PhoneNumberUtils.isLocalEmergencyNumber(mPhone.getContext(), dialString);

        // Check for issues which would preclude dialing and throw a CallStateException.
        checkForDialIssues();
        checkForDialIssues(isEmergencyCall);

        TelephonyManager tm =
                (TelephonyManager) mPhone.getContext().getSystemService(Context.TELEPHONY_SERVICE);
@@ -407,8 +411,6 @@ public class GsmCdmaCallTracker extends CallTracker {
        }

        boolean isPhoneInEcmMode = mPhone.isInEcm();
        boolean isEmergencyCall =
                PhoneNumberUtils.isLocalEmergencyNumber(mPhone.getContext(), dialString);

        // Cancel Ecm timer if a second emergency call is originating in Ecm mode
        if (isPhoneInEcmMode && isEmergencyCall) {
@@ -616,7 +618,7 @@ public class GsmCdmaCallTracker extends CallTracker {
     * {@link CallStateException} if there is an issue.
     * @throws CallStateException
     */
    public void checkForDialIssues() throws CallStateException {
    public void checkForDialIssues(boolean isEmergencyCall) throws CallStateException {
        String disableCall = SystemProperties.get(
                TelephonyProperties.PROPERTY_DISABLE_CALL, "false");

@@ -651,6 +653,10 @@ public class GsmCdmaCallTracker extends CallTracker {
            throw new CallStateException(CallStateException.ERROR_TOO_MANY_CALLS,
                    "There is already a foreground and background call.");
        }
        if (!isEmergencyCall && isInOtaspCall()) {
            throw new CallStateException(CallStateException.ERROR_OTASP_PROVISIONING_IN_PROCESS,
                    "OTASP provisioning is in process.");
        }
    }

    public boolean canTransfer() {
@@ -1672,6 +1678,18 @@ public class GsmCdmaCallTracker extends CallTracker {
        return mIsInEmergencyCall;
    }

    /**
     * @return {@code true} if the pending outgoing call or active call is an OTASP call,
     * {@code false} otherwise.
     */
    public boolean isInOtaspCall() {
        return mPendingMO != null && mPendingMO.isOtaspCall()
                || (mForegroundCall.getConnections().stream()
                .filter(connection -> ((connection instanceof GsmCdmaConnection)
                        && (((GsmCdmaConnection) connection).isOtaspCall())))
                .count() > 0);
    }

    private boolean isPhoneTypeGsm() {
        return mPhone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM;
    }
+9 −0
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ public class GsmCdmaConnection extends Connection {
    private static final boolean DBG = true;
    private static final boolean VDBG = false;

    public static final String OTASP_NUMBER = "*22899";

    //***** Instance Variables

    GsmCdmaCallTracker mOwner;
@@ -1157,4 +1159,11 @@ public class GsmCdmaConnection extends Connection {

        return false;
    }

    /**
     * @return {@code true} if this call is an OTASP activation call, {@code false} otherwise.
     */
    public boolean isOtaspCall() {
        return mAddress != null && OTASP_NUMBER.equals(mAddress);
    }
}
+36 −1
Original line number Diff line number Diff line
@@ -111,6 +111,13 @@ public class TelephonyTester {
    private static final String ACTION_TEST_IMS_E_CALL =
            "com.android.internal.telephony.TestImsECall";

    /**
     * Test-only intent used to trigger a change to the current call's phone number.
     * Use the {@link #EXTRA_NUMBER} extra to specify the new phone number.
     */
    private static final String ACTION_TEST_CHANGE_NUMBER =
            "com.android.internal.telephony.TestChangeNumber";

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

@@ -171,6 +178,9 @@ public class TelephonyTester {
                } else if (action.equals(ACTION_TEST_IMS_E_CALL)) {
                    log("handle test IMS ecall intent");
                    testImsECall();
                } else if (action.equals(ACTION_TEST_CHANGE_NUMBER)) {
                    log("handle test change number intent");
                    testChangeNumber(intent);
                } else {
                    if (DBG) log("onReceive: unknown action=" + action);
                }
@@ -205,7 +215,7 @@ public class TelephonyTester {
                filter.addAction(ACTION_TEST_SERVICE_STATE);
                log("register for intent action=" + ACTION_TEST_SERVICE_STATE);
            }

            filter.addAction(ACTION_TEST_CHANGE_NUMBER);
            phone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone.getHandler());
        }
    }
@@ -414,4 +424,29 @@ public class TelephonyTester {
        imsCall.getImsCallSessionListenerProxy().callSessionUpdated(imsCall.getSession(),
                callProfile);
    }

    void testChangeNumber(Intent intent) {
        if (!intent.hasExtra(EXTRA_NUMBER)) {
            return;
        }

        String newNumber = intent.getStringExtra(EXTRA_NUMBER);

        // Update all the calls.
        mPhone.getForegroundCall().getConnections()
                .stream()
                .forEach(c -> {
                    c.setAddress(newNumber, PhoneConstants.PRESENTATION_ALLOWED);
                    c.setDialString(newNumber);
                });

        // <sigh>
        if (mPhone instanceof GsmCdmaPhone) {
            ((GsmCdmaPhone) mPhone).notifyPhoneStateChanged();
            ((GsmCdmaPhone) mPhone).notifyPreciseCallStateChanged();
        } else if (mPhone instanceof ImsPhone) {
            ((ImsPhone) mPhone).notifyPhoneStateChanged();
            ((ImsPhone) mPhone).notifyPreciseCallStateChanged();
        }
    }
}
 No newline at end of file
Loading