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

Commit 8f1adbc3 authored by Brad Ebinger's avatar Brad Ebinger Committed by Gerrit Code Review
Browse files

Merge "CSFB SS: Implementation of CSFB SS"

parents d5b541f6 76b2ba32
Loading
Loading
Loading
Loading
+70 −59
Original line number Diff line number Diff line
@@ -2050,6 +2050,26 @@ public class GsmCdmaPhone extends Phone {
            && mImsPhone.isUtEnabled();
    }

    private boolean isCsRetry(Message onComplete) {
        if (onComplete != null) {
            return onComplete.getData().getBoolean(CS_FALLBACK_SS, false);
        }
        return false;
    }

    @Override
    public boolean useSsOverIms(Message onComplete) {
        boolean isUtEnabled = isUtEnabled();

        Rlog.d(LOG_TAG, "useSsOverIms: isUtEnabled()= " + isUtEnabled +
                " isCsRetry(onComplete))= " + isCsRetry(onComplete));

        if (isUtEnabled && !isCsRetry(onComplete)) {
            return true;
        }
        return false;
    }

    @Override
    public void getCallForwardingOption(int commandInterfaceCFReason, Message onComplete) {
        getCallForwardingOption(commandInterfaceCFReason,
@@ -2059,16 +2079,13 @@ public class GsmCdmaPhone extends Phone {
    @Override
    public void getCallForwardingOption(int commandInterfaceCFReason, int serviceClass,
            Message onComplete) {
        if (isPhoneTypeGsm() || isImsUtEnabledOverCdma()) {
        Phone imsPhone = mImsPhone;
            if ((imsPhone != null)
                    && ((imsPhone.getServiceState().getState() == ServiceState.STATE_IN_SERVICE)
                    || imsPhone.isUtEnabled())) {
                imsPhone.getCallForwardingOption(commandInterfaceCFReason, serviceClass,
                        onComplete);
        if (useSsOverIms(onComplete)) {
            imsPhone.getCallForwardingOption(commandInterfaceCFReason, serviceClass, onComplete);
            return;
        }

        if (isPhoneTypeGsm()) {
            if (isValidCommandInterfaceCFReason(commandInterfaceCFReason)) {
                if (DBG) logd("requesting call forwarding query.");
                Message resp;
@@ -2103,17 +2120,14 @@ public class GsmCdmaPhone extends Phone {
            int serviceClass,
            int timerSeconds,
            Message onComplete) {
        if (isPhoneTypeGsm() || isImsUtEnabledOverCdma()) {
        Phone imsPhone = mImsPhone;
            if ((imsPhone != null)
                    && ((imsPhone.getServiceState().getState() == ServiceState.STATE_IN_SERVICE)
                    || imsPhone.isUtEnabled())) {
                imsPhone.setCallForwardingOption(commandInterfaceCFAction,
                        commandInterfaceCFReason, dialingNumber, serviceClass,
                        timerSeconds, onComplete);
        if (useSsOverIms(onComplete)) {
            imsPhone.setCallForwardingOption(commandInterfaceCFAction, commandInterfaceCFReason,
                    dialingNumber, serviceClass, timerSeconds, onComplete);
            return;
        }

        if (isPhoneTypeGsm()) {
            if ((isValidCommandInterfaceCFAction(commandInterfaceCFAction)) &&
                    (isValidCommandInterfaceCFReason(commandInterfaceCFReason))) {

@@ -2154,12 +2168,13 @@ public class GsmCdmaPhone extends Phone {
    @Override
    public void getCallBarring(String facility, String password, Message onComplete,
            int serviceClass) {
        if (isPhoneTypeGsm()) {
        Phone imsPhone = mImsPhone;
            if ((imsPhone != null) && imsPhone.isUtEnabled()) {
        if (useSsOverIms(onComplete)) {
            imsPhone.getCallBarring(facility, password, onComplete, serviceClass);
            return;
        }

        if (isPhoneTypeGsm()) {
            mCi.queryFacilityLock(facility, password, serviceClass, onComplete);
        } else {
            loge("getCallBarringOption: not possible in CDMA");
@@ -2169,12 +2184,13 @@ public class GsmCdmaPhone extends Phone {
    @Override
    public void setCallBarring(String facility, boolean lockState, String password,
            Message onComplete, int serviceClass) {
        if (isPhoneTypeGsm()) {
        Phone imsPhone = mImsPhone;
            if ((imsPhone != null) && imsPhone.isUtEnabled()) {
        if (useSsOverIms(onComplete)) {
            imsPhone.setCallBarring(facility, lockState, password, onComplete, serviceClass);
            return;
        }

        if (isPhoneTypeGsm()) {
            mCi.setFacilityLock(facility, lockState, password, serviceClass, onComplete);
        } else {
            loge("setCallBarringOption: not possible in CDMA");
@@ -2200,14 +2216,13 @@ public class GsmCdmaPhone extends Phone {

    @Override
    public void getOutgoingCallerIdDisplay(Message onComplete) {
        if (isPhoneTypeGsm()) {
        Phone imsPhone = mImsPhone;
            if ((imsPhone != null)
                    && ((imsPhone.getServiceState().getState() == ServiceState.STATE_IN_SERVICE)
                    || imsPhone.isUtEnabled())) {
        if (useSsOverIms(onComplete)) {
            imsPhone.getOutgoingCallerIdDisplay(onComplete);
            return;
        }

        if (isPhoneTypeGsm()) {
            mCi.getCLIR(onComplete);
        } else {
            loge("getOutgoingCallerIdDisplay: not possible in CDMA");
@@ -2216,14 +2231,13 @@ public class GsmCdmaPhone extends Phone {

    @Override
    public void setOutgoingCallerIdDisplay(int commandInterfaceCLIRMode, Message onComplete) {
        if (isPhoneTypeGsm()) {
        Phone imsPhone = mImsPhone;
            if ((imsPhone != null)
                    && ((imsPhone.getServiceState().getState() == ServiceState.STATE_IN_SERVICE)
                    || imsPhone.isUtEnabled())) {
        if (useSsOverIms(onComplete)) {
            imsPhone.setOutgoingCallerIdDisplay(commandInterfaceCLIRMode, onComplete);
            return;
        }

        if (isPhoneTypeGsm()) {
            // Packing CLIR value in the message. This will be required for
            // SharedPreference caching, if the message comes back as part of
            // a success response.
@@ -2236,15 +2250,13 @@ public class GsmCdmaPhone extends Phone {

    @Override
    public void getCallWaiting(Message onComplete) {
        if (isPhoneTypeGsm() || isImsUtEnabledOverCdma()) {
        Phone imsPhone = mImsPhone;
            if ((imsPhone != null)
                    && ((imsPhone.getServiceState().getState() == ServiceState.STATE_IN_SERVICE)
                    || imsPhone.isUtEnabled())) {
        if (useSsOverIms(onComplete)) {
            imsPhone.getCallWaiting(onComplete);
            return;
        }

        if (isPhoneTypeGsm()) {
            //As per 3GPP TS 24.083, section 1.6 UE doesn't need to send service
            //class parameter in call waiting interrogation  to network
            mCi.queryCallWaiting(CommandsInterface.SERVICE_CLASS_NONE, onComplete);
@@ -2270,14 +2282,13 @@ public class GsmCdmaPhone extends Phone {

    @Override
    public void setCallWaiting(boolean enable, int serviceClass, Message onComplete) {
        if (isPhoneTypeGsm() || isImsUtEnabledOverCdma()) {
        Phone imsPhone = mImsPhone;
            if ((imsPhone != null)
                    && ((imsPhone.getServiceState().getState() == ServiceState.STATE_IN_SERVICE)
                    || imsPhone.isUtEnabled())) {
        if (useSsOverIms(onComplete)) {
            imsPhone.setCallWaiting(enable, onComplete);
            return;
        }

        if (isPhoneTypeGsm()) {
            mCi.setCallWaiting(enable, serviceClass, onComplete);
        } else {
            String cwPrefix = CdmaMmiCode.getCallWaitingPrefix(enable);
+8 −0
Original line number Diff line number Diff line
@@ -340,6 +340,10 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     * TODO: Replace this with a proper exception; {@link CallStateException} doesn't make sense.
     */
    public static final String CS_FALLBACK = "cs_fallback";

    // Used for retry over cs for supplementary services
    public static final String CS_FALLBACK_SS = "cs_fallback_ss";

    /**
     * @deprecated Use {@link android.telephony.ims.ImsManager#EXTRA_WFC_REGISTRATION_FAILURE_TITLE}
     * instead.
@@ -4249,6 +4253,10 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return mCarrierPrivilegesTracker;
    }

    public boolean useSsOverIms(Message onComplete) {
        return false;
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("Phone: subId=" + getSubId());
        pw.println(" mPhoneId=" + mPhoneId);
+193 −20
Original line number Diff line number Diff line
@@ -314,6 +314,85 @@ public class ImsPhone extends ImsPhoneBase {
        }
    }

    // Create SS (Supplementary Service) so that save SS params &
    // mOnComplete (Message object passed by client) can be packed
    // given as a single SS object as user data to UtInterface.
    @VisibleForTesting
    public static class SS {
        int mCfAction;
        int mCfReason;
        String mDialingNumber;
        int mTimerSeconds;
        boolean mEnable;
        int mClirMode;
        String mFacility;
        boolean mLockState;
        String mPassword;
        int mServiceClass;
        @VisibleForTesting
        public Message mOnComplete;

        // Default // Query CW, CLIR
        SS(Message onComplete) {
            mOnComplete = onComplete;
        }

        // Update CLIP
        SS(boolean enable, Message onComplete) {
            mEnable = enable;
            mOnComplete = onComplete;
        }

        // Update CLIR
        SS(int clirMode, Message onComplete) {
            mClirMode = clirMode;
            mOnComplete = onComplete;
        }

        // Update CW
        SS(boolean enable, int serviceClass, Message onComplete) {
            mEnable = enable;
            mServiceClass = serviceClass;
            mOnComplete = onComplete;
        }

        // Query CF
        SS(int cfReason, int serviceClass, Message onComplete) {
            mCfReason = cfReason;
            mServiceClass = serviceClass;
            mOnComplete = onComplete;
        }

        // Update CF
        SS(int cfAction, int cfReason, String dialingNumber,
           int serviceClass, int timerSeconds, Message onComplete) {
            mCfAction = cfAction;
            mCfReason = cfReason;
            mDialingNumber = dialingNumber;
            mServiceClass = serviceClass;
            mTimerSeconds = timerSeconds;
            mOnComplete = onComplete;
        }

        // Query CB
        SS(String facility, String password, int serviceClass, Message onComplete) {
            mFacility = facility;
            mPassword = password;
            mServiceClass = serviceClass;
            mOnComplete = onComplete;
        }

        // Update CB
        SS(String facility, boolean lockState, String password,
                int serviceClass, Message onComplete) {
            mFacility = facility;
            mLockState = lockState;
            mPassword = password;
            mServiceClass = serviceClass;
            mOnComplete = onComplete;
        }
    }

    // Constructors
    public ImsPhone(Context context, PhoneNotifier notifier, Phone defaultPhone) {
        this(context, notifier, defaultPhone, false);
@@ -1022,7 +1101,8 @@ public class ImsPhone extends ImsPhoneBase {
    public void getOutgoingCallerIdDisplay(Message onComplete) {
        if (DBG) logd("getCLIR");
        Message resp;
        resp = obtainMessage(EVENT_GET_CLIR_DONE, onComplete);
        SS ss = new SS(onComplete);
        resp = obtainMessage(EVENT_GET_CLIR_DONE, ss);

        try {
            ImsUtInterface ut = mCT.getUtInterface();
@@ -1039,7 +1119,8 @@ public class ImsPhone extends ImsPhoneBase {
        // Packing CLIR value in the message. This will be required for
        // SharedPreference caching, if the message comes back as part of
        // a success response.
        resp = obtainMessage(EVENT_SET_CLIR_DONE, clirMode, 0, onComplete);
        SS ss = new SS(clirMode, onComplete);
        resp = obtainMessage(EVENT_SET_CLIR_DONE, ss);
        try {
            ImsUtInterface ut = mCT.getUtInterface();
            ut.updateCLIR(clirMode, resp);
@@ -1063,7 +1144,8 @@ public class ImsPhone extends ImsPhoneBase {
        if (isValidCommandInterfaceCFReason(commandInterfaceCFReason)) {
            if (DBG) logd("requesting call forwarding query.");
            Message resp;
            resp = obtainMessage(EVENT_GET_CALL_FORWARD_DONE, onComplete);
            SS ss = new SS(commandInterfaceCFReason, serviceClass, onComplete);
            resp = obtainMessage(EVENT_GET_CALL_FORWARD_DONE, ss);

            try {
                ImsUtInterface ut = mCT.getUtInterface();
@@ -1101,10 +1183,9 @@ public class ImsPhone extends ImsPhoneBase {
        if ((isValidCommandInterfaceCFAction(commandInterfaceCFAction)) &&
                (isValidCommandInterfaceCFReason(commandInterfaceCFReason))) {
            Message resp;
            Cf cf = new Cf(dialingNumber, GsmMmiCode.isVoiceUnconditionalForwarding(
                    commandInterfaceCFReason, serviceClass), onComplete);
            resp = obtainMessage(EVENT_SET_CALL_FORWARD_DONE,
                    isCfEnable(commandInterfaceCFAction) ? 1 : 0, 0, cf);
            SS ss = new SS(commandInterfaceCFAction, commandInterfaceCFReason,
                    dialingNumber, serviceClass, timerSeconds, onComplete);
            resp = obtainMessage(EVENT_SET_CALL_FORWARD_DONE, ss);

            try {
                ImsUtInterface ut = mCT.getUtInterface();
@@ -1127,7 +1208,8 @@ public class ImsPhone extends ImsPhoneBase {
    public void getCallWaiting(Message onComplete) {
        if (DBG) logd("getCallWaiting");
        Message resp;
        resp = obtainMessage(EVENT_GET_CALL_WAITING_DONE, onComplete);
        SS ss = new SS(onComplete);
        resp = obtainMessage(EVENT_GET_CALL_WAITING_DONE, ss);

        try {
            ImsUtInterface ut = mCT.getUtInterface();
@@ -1154,7 +1236,8 @@ public class ImsPhone extends ImsPhoneBase {
    public void setCallWaiting(boolean enable, int serviceClass, Message onComplete) {
        if (DBG) logd("setCallWaiting enable=" + enable);
        Message resp;
        resp = obtainMessage(EVENT_SET_CALL_WAITING_DONE, onComplete);
        SS ss = new SS(enable, serviceClass, onComplete);
        resp = obtainMessage(EVENT_SET_CALL_WAITING_DONE, ss);

        try {
            ImsUtInterface ut = mCT.getUtInterface();
@@ -1201,7 +1284,8 @@ public class ImsPhone extends ImsPhoneBase {
            int serviceClass) {
        if (DBG) logd("getCallBarring facility=" + facility + ", serviceClass = " + serviceClass);
        Message resp;
        resp = obtainMessage(EVENT_GET_CALL_BARRING_DONE, onComplete);
        SS ss = new SS(facility, password, serviceClass, onComplete);
        resp = obtainMessage(EVENT_GET_CALL_BARRING_DONE, ss);

        try {
            ImsUtInterface ut = mCT.getUtInterface();
@@ -1226,7 +1310,8 @@ public class ImsPhone extends ImsPhoneBase {
                    + ", lockState=" + lockState + ", serviceClass = " + serviceClass);
        }
        Message resp;
        resp = obtainMessage(EVENT_SET_CALL_BARRING_DONE, onComplete);
        SS ss = new SS(facility, lockState, password, serviceClass, onComplete);
        resp = obtainMessage(EVENT_SET_CALL_BARRING_DONE, ss);

        int action;
        if (lockState) {
@@ -1561,18 +1646,96 @@ public class ImsPhone extends ImsPhoneBase {
        }
    }

    boolean isCsRetryException(Throwable e) {
        if ((e != null) && (e instanceof ImsException)
                && (((ImsException)e).getCode()
                    == ImsReasonInfo.CODE_LOCAL_CALL_CS_RETRY_REQUIRED)) {
            return true;
        }
        return false;
    }

    private Bundle setCsfbBundle(boolean isCsRetry) {
        Bundle b = new Bundle();
        b.putBoolean(CS_FALLBACK_SS, isCsRetry);
        return b;
    }

    private void sendResponseOrRetryOnCsfbSs(SS ss, int what, Throwable e, Object obj) {
        if (!isCsRetryException(e)) {
            sendResponse(ss.mOnComplete, obj, e);
            return;
        }

        Rlog.d(LOG_TAG, "Try CSFB: " + what);
        ss.mOnComplete.setData(setCsfbBundle(true));

        switch (what) {
            case EVENT_GET_CALL_FORWARD_DONE:
                mDefaultPhone.getCallForwardingOption(ss.mCfReason,
                                                      ss.mServiceClass,
                                                      ss.mOnComplete);
                break;
            case EVENT_SET_CALL_FORWARD_DONE:
                mDefaultPhone.setCallForwardingOption(ss.mCfAction,
                                                      ss.mCfReason,
                                                      ss.mDialingNumber,
                                                      ss.mServiceClass,
                                                      ss.mTimerSeconds,
                                                      ss.mOnComplete);
                break;
            case EVENT_GET_CALL_BARRING_DONE:
                mDefaultPhone.getCallBarring(ss.mFacility,
                                             ss.mPassword,
                                             ss.mOnComplete,
                                             ss.mServiceClass);
                break;
            case EVENT_SET_CALL_BARRING_DONE:
                mDefaultPhone.setCallBarring(ss.mFacility,
                                             ss.mLockState,
                                             ss.mPassword,
                                             ss.mOnComplete,
                                             ss.mServiceClass);
                break;
            case EVENT_GET_CALL_WAITING_DONE:
                mDefaultPhone.getCallWaiting(ss.mOnComplete);
                break;
            case EVENT_SET_CALL_WAITING_DONE:
                mDefaultPhone.setCallWaiting(ss.mEnable,
                                             ss.mServiceClass,
                                             ss.mOnComplete);
                break;
            case EVENT_GET_CLIR_DONE:
                mDefaultPhone.getOutgoingCallerIdDisplay(ss.mOnComplete);
                break;
            case EVENT_SET_CLIR_DONE:
                mDefaultPhone.setOutgoingCallerIdDisplay(ss.mClirMode, ss.mOnComplete);
                break;
            default:
                break;
        }
    }

    @Override
    public void handleMessage(Message msg) {
        AsyncResult ar = (AsyncResult) msg.obj;
        Message onComplete;
        SS ss = null;
        if (ar.userObj instanceof SS) {
            ss = (SS) ar.userObj;
        }

        if (DBG) logd("handleMessage what=" + msg.what);
        switch (msg.what) {
            case EVENT_SET_CALL_FORWARD_DONE:
                Cf cf = (Cf) ar.userObj;
                if (cf.mIsCfu && ar.exception == null) {
                    setVoiceCallForwardingFlag(getIccRecords(), 1, msg.arg1 == 1, cf.mSetCfNumber);
                if (ar.exception == null && ss != null &&
                    (ss.mCfReason == CF_REASON_UNCONDITIONAL)) {
                    setVoiceCallForwardingFlag(getIccRecords(), 1, isCfEnable(ss.mCfAction),
                                               ss.mDialingNumber);
                }
                if (ss != null) {
                    sendResponseOrRetryOnCsfbSs(ss, msg.what, ar.exception, null);
                }
                sendResponse(cf.mOnComplete, null, ar.exception);
                break;

            case EVENT_GET_CALL_FORWARD_DONE:
@@ -1580,7 +1743,9 @@ public class ImsPhone extends ImsPhoneBase {
                if (ar.exception == null) {
                    cfInfos = handleCfQueryResult((ImsCallForwardInfo[])ar.result);
                }
                sendResponse((Message) ar.userObj, cfInfos, ar.exception);
                if (ss != null) {
                    sendResponseOrRetryOnCsfbSs(ss, msg.what, ar.exception, cfInfos);
                }
                break;

            case EVENT_GET_CALL_BARRING_DONE:
@@ -1593,7 +1758,9 @@ public class ImsPhone extends ImsPhoneBase {
                        ssInfos = handleCwQueryResult((ImsSsInfo[])ar.result);
                    }
                }
                sendResponse((Message) ar.userObj, ssInfos, ar.exception);
                if (ss != null) {
                    sendResponseOrRetryOnCsfbSs(ss, msg.what, ar.exception, ssInfos);
                }
                break;

            case EVENT_GET_CLIR_DONE:
@@ -1604,17 +1771,23 @@ public class ImsPhone extends ImsPhoneBase {
                    // that for compatibility
                    clirInfo = ssInfo.getCompatArray(ImsSsData.SS_CLIR);
                }
                sendResponse((Message) ar.userObj, clirInfo, ar.exception);
                if (ss != null) {
                    sendResponseOrRetryOnCsfbSs(ss, msg.what, ar.exception, clirInfo);
                }
                break;

            case EVENT_SET_CLIR_DONE:
                if (ar.exception == null) {
                    saveClirSetting(msg.arg1);
                    if (ss != null) {
                        saveClirSetting(ss.mClirMode);
                    }
                }
                 // (Intentional fallthrough)
            case EVENT_SET_CALL_BARRING_DONE:
            case EVENT_SET_CALL_WAITING_DONE:
                sendResponse((Message) ar.userObj, null, ar.exception);
                if (ss != null) {
                    sendResponseOrRetryOnCsfbSs(ss, msg.what, ar.exception, null);
                }
                break;

            case EVENT_DEFAULT_PHONE_DATA_STATE_CHANGED:
+15 −7
Original line number Diff line number Diff line
@@ -1307,6 +1307,8 @@ public final class ImsPhoneMmiCode extends Handler implements MmiCode {
                return mContext.getText(com.android.internal.R.string.stk_cc_ss_to_ss);
            } else if (err.getCommandError() == CommandException.Error.SS_MODIFIED_TO_DIAL_VIDEO) {
                return mContext.getText(com.android.internal.R.string.stk_cc_ss_to_dial_video);
            } else if (err.getCommandError() == CommandException.Error.INTERNAL_ERR) {
                return mContext.getText(com.android.internal.R.string.mmiError);
            }
        }
        return null;
@@ -1592,8 +1594,11 @@ public final class ImsPhoneMmiCode extends Handler implements MmiCode {
            } else {
                Rlog.d(LOG_TAG, "onSuppSvcQueryComplete: Received Call Barring Response.");
                // Response for Call Barring queries.
                int[] cbInfos = (int[]) ar.result;
                if (cbInfos[0] == 1) {
                int[] infos = (int[]) ar.result;
                if (infos == null || infos.length == 0) {
                    sb.append(mContext.getText(com.android.internal.R.string.mmiError));
                } else {
                    if (infos[0] == 1) {
                        sb.append(mContext.getText(com.android.internal.R.string.serviceEnabled));
                        mState = State.COMPLETE;
                    } else {
@@ -1602,6 +1607,7 @@ public final class ImsPhoneMmiCode extends Handler implements MmiCode {
                    }
                }
            }
        }

        mMessage = sb;
        Rlog.d(LOG_TAG, "onSuppSvcQueryComplete mmi=" + this);
@@ -1661,6 +1667,8 @@ public final class ImsPhoneMmiCode extends Handler implements MmiCode {
        if (ar.exception != null) {
            if (ar.exception instanceof ImsException) {
                sb.append(getImsErrorMessage(ar));
            } else {
                sb.append(getErrorMessage(ar));
            }
        } else {
            ImsSsInfo ssInfo = (ImsSsInfo) ar.result;
@@ -1757,7 +1765,7 @@ public final class ImsPhoneMmiCode extends Handler implements MmiCode {
        } else {
            int[] ints = (int[])ar.result;

            if (ints.length != 0) {
            if (ints != null && ints.length != 0) {
                if (ints[0] == 0) {
                    sb.append(mContext.getText(com.android.internal.R.string.serviceDisabled));
                    mState = State.COMPLETE;
+22 −7

File changed.

Preview size limit exceeded, changes collapsed.