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

Commit 63ad79f9 authored by Jang Hayeong's avatar Jang Hayeong Committed by Sungjae
Browse files

callforwarding: Support cdma call forwarding setting



CDMA call forwarding should be supported by setting UI
regarding CDMA VoLTE case.
Getting query call forwarding is useless in no VoLTE case.
SS_STATUS_UNKNOWN will be returned for empty result.
Place call to set call forwarding with prefix
regarding reason and action.

Bug: 146533000

Change-Id: Id7a2122692fcc1801b1c0548d74c98bdc20b95da
Signed-off-by: default avatarJang Hayeong <hayeong.jang@samsung.com>
Signed-off-by: default avatarSungjae <sung_jae.kim@samsung.com>
parent dc11c8e6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ public interface CommandsInterface {
    static final int CLIR_INVOCATION = 1;   // (restrict CLI presentation)
    static final int CLIR_SUPPRESSION = 2;  // (allow CLI presentation)

    // Used as return value for CDMA SS query
    static final int SS_STATUS_UNKNOWN          = 0xff;

    // Used as parameters for call forward methods below
    static final int CF_ACTION_DISABLE          = 0;
+50 −6
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ import android.preference.PreferenceManager;
import android.provider.Settings;
import android.provider.Telephony;
import android.sysprop.TelephonyProperties;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
import android.telephony.AccessNetworkConstants;
@@ -111,6 +113,7 @@ import com.android.internal.telephony.imsphone.ImsPhoneMmiCode;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -2063,9 +2066,8 @@ public class GsmCdmaPhone extends Phone {
                mCi.queryCallForwardStatus(commandInterfaceCFReason, serviceClass, null, resp);
            }
        } else {
            loge("getCallForwardingOption: not possible in CDMA without IMS");
            AsyncResult.forMessage(onComplete, null,
                    CommandException.fromRilErrno(RILConstants.REQUEST_NOT_SUPPORTED));
            loge("getCallForwardingOption: not possible in CDMA, just return empty result");
            AsyncResult.forMessage(onComplete, makeEmptyCallForward(), null);
            onComplete.sendToTarget();
        }
    }
@@ -2117,9 +2119,20 @@ public class GsmCdmaPhone extends Phone {
                        resp);
            }
        } else {
            loge("setCallForwardingOption: not possible in CDMA without IMS");
            AsyncResult.forMessage(onComplete, null,
                    CommandException.fromRilErrno(RILConstants.REQUEST_NOT_SUPPORTED));
            String formatNumber = GsmCdmaConnection.formatDialString(dialingNumber);
            String cfNumber = CdmaMmiCode.getCallForwardingPrefixAndNumber(
                    commandInterfaceCFAction, commandInterfaceCFReason, formatNumber);
            loge("setCallForwardingOption: dial for set call forwarding"
                    + " prefixWithNumber= " + cfNumber + " number= " + dialingNumber);

            PhoneAccountHandle phoneAccountHandle = subscriptionIdToPhoneAccountHandle(getSubId());
            Bundle extras = new Bundle();
            extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);

            final TelecomManager telecomManager = TelecomManager.from(mContext);
            telecomManager.placeCall(Uri.parse(PhoneAccount.SCHEME_TEL + cfNumber), extras);

            AsyncResult.forMessage(onComplete, CommandsInterface.SS_STATUS_UNKNOWN, null);
            onComplete.sendToTarget();
        }
    }
@@ -4121,6 +4134,37 @@ public class GsmCdmaPhone extends Phone {
        }
    }

    private CallForwardInfo[] makeEmptyCallForward() {
        CallForwardInfo infos[] = new CallForwardInfo[1];

        infos[0] = new CallForwardInfo();
        infos[0].status = CommandsInterface.SS_STATUS_UNKNOWN;
        infos[0].reason = 0;
        infos[0].serviceClass = CommandsInterface.SERVICE_CLASS_VOICE;
        infos[0].toa = PhoneNumberUtils.TOA_Unknown;
        infos[0].number = "";
        infos[0].timeSeconds = 0;

        return infos;
    }

    private PhoneAccountHandle subscriptionIdToPhoneAccountHandle(final int subId) {
        final TelecomManager telecomManager = TelecomManager.from(mContext);
        final TelephonyManager telephonyManager = TelephonyManager.from(mContext);
        final Iterator<PhoneAccountHandle> phoneAccounts =
            telecomManager.getCallCapablePhoneAccounts(true).listIterator();

        while (phoneAccounts.hasNext()) {
            final PhoneAccountHandle phoneAccountHandle = phoneAccounts.next();
            final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
            if (subId == telephonyManager.getSubIdForPhoneAccount(phoneAccount)) {
                return phoneAccountHandle;
            }
        }

        return null;
    }

    @UnsupportedAppUsage
    private void logd(String s) {
        Rlog.d(LOG_TAG, "[" + mPhoneId + "] " + s);
+49 −0
Original line number Diff line number Diff line
@@ -16,6 +16,13 @@

package com.android.internal.telephony.cdma;

import static com.android.internal.telephony.CommandsInterface.CF_ACTION_DISABLE;
import static com.android.internal.telephony.CommandsInterface.CF_ACTION_REGISTRATION;
import static com.android.internal.telephony.CommandsInterface.CF_REASON_BUSY;
import static com.android.internal.telephony.CommandsInterface.CF_REASON_NOT_REACHABLE;
import static com.android.internal.telephony.CommandsInterface.CF_REASON_NO_REPLY;
import static com.android.internal.telephony.CommandsInterface.CF_REASON_UNCONDITIONAL;

import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.os.AsyncResult;
@@ -380,4 +387,46 @@ public final class CdmaMmiCode extends Handler implements MmiCode {
    public ResultReceiver getUssdCallbackReceiver() {
        return null;
    }

    public static String getCallForwardingPrefixAndNumber(int action, int reason, String number) {
        String prefixWithNum = "";
        switch(reason) {
            case CF_REASON_UNCONDITIONAL: {
                if (action == CF_ACTION_REGISTRATION) {
                    prefixWithNum = "*72" + number;
                } else if (action == CF_ACTION_DISABLE) {
                    prefixWithNum = "*720";
                }
                break;
            }
            case CF_REASON_BUSY: {
                if (action == CF_ACTION_REGISTRATION) {
                    prefixWithNum = "*90" + number;
                } else if (action == CF_ACTION_DISABLE) {
                    prefixWithNum = "*900";
                }
                break;
            }
            case CF_REASON_NO_REPLY: {
                if (action == CF_ACTION_REGISTRATION) {
                    prefixWithNum = "*92" + number;
                } else if (action == CF_ACTION_DISABLE) {
                    prefixWithNum = "*920";
                }
                break;
            }
            case CF_REASON_NOT_REACHABLE: {
                if (action == CF_ACTION_REGISTRATION) {
                    prefixWithNum = "*68" + number;
                } else if (action == CF_ACTION_DISABLE) {
                    prefixWithNum = "*680";
                }
                break;
            }
            default:
                Rlog.d(LOG_TAG, "getCallForwardingPrefix not match any prefix");
                break;
        }
        return prefixWithNum;
    }
}