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

Commit 1370a5d9 authored by Aishwarya Mallampati's avatar Aishwarya Mallampati Committed by Automerger Merge Worker
Browse files
parents b1a615f4 bc22faed
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -74,6 +74,29 @@ public class FdnUtils {
        return app.getIccFdnEnabled();
    }

    /**
     * If FDN is enabled, check to see if the given supplementary service control strings are
     * blocked due to FDN.
     * @param phoneId The phone object id for which the FDN check is performed
     * @param controlStrings control strings associated with the supplementary service request
     * @param defaultCountryIso country ISO for the subscription associated with this phone
     * @return {@code true} if the FDN list does not contain any of the control strings.
     */
    public static boolean isSuppServiceRequestBlockedByFdn(int phoneId,
            ArrayList<String> controlStrings, String defaultCountryIso) {
        if (!isFdnEnabled(phoneId)) {
            return false;
        }

        ArrayList<AdnRecord> fdnList = getFdnList(phoneId);
        for(String controlString : controlStrings) {
            if(isFDN(controlString, defaultCountryIso, fdnList)) {
                return false;
            }
        }
        return true;
    }

    /**
     * Checks if dialStr is part of FDN list.
     *
+115 −1
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ import com.android.internal.telephony.data.DataNetworkController;
import com.android.internal.telephony.data.LinkBandwidthEstimator;
import com.android.internal.telephony.emergency.EmergencyNumberTracker;
import com.android.internal.telephony.gsm.GsmMmiCode;
import com.android.internal.telephony.gsm.SsData;
import com.android.internal.telephony.gsm.SuppServiceNotification;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
@@ -1590,6 +1591,13 @@ public class GsmCdmaPhone extends Phone {
            return true;
        }

        // Perform FDN check
        if(FdnUtils.isNumberBlockedByFDN(mPhoneId, ussdRequest, getCountryIso())) {
            sendUssdResponse(ussdRequest, null, TelephonyManager.USSD_RETURN_FAILURE,
                    wrappedCallback );
            return true;
        }

        // Try over IMS if possible.
        Phone imsPhone = mImsPhone;
        if ((imsPhone != null)
@@ -2233,6 +2241,15 @@ public class GsmCdmaPhone extends Phone {
    @Override
    public void getCallForwardingOption(int commandInterfaceCFReason, int serviceClass,
            Message onComplete) {
        // Perform FDN check
        SsData.ServiceType serviceType = GsmMmiCode.cfReasonToServiceType(commandInterfaceCFReason);
        if(isRequestBlockedByFDN(SsData.RequestType.SS_INTERROGATION, serviceType)) {
            AsyncResult.forMessage(onComplete, null,
                    new CommandException(CommandException.Error.FDN_CHECK_FAILURE));
            onComplete.sendToTarget();
            return;
        }

        Phone imsPhone = mImsPhone;
        if (useSsOverIms(onComplete)) {
            imsPhone.getCallForwardingOption(commandInterfaceCFReason, serviceClass, onComplete);
@@ -2282,6 +2299,16 @@ public class GsmCdmaPhone extends Phone {
            int serviceClass,
            int timerSeconds,
            Message onComplete) {
        // Perform FDN check
        SsData.RequestType requestType = GsmMmiCode.cfActionToRequestType(commandInterfaceCFAction);
        SsData.ServiceType serviceType = GsmMmiCode.cfReasonToServiceType(commandInterfaceCFReason);
        if(isRequestBlockedByFDN(requestType, serviceType)) {
            AsyncResult.forMessage(onComplete, null,
                    new CommandException(CommandException.Error.FDN_CHECK_FAILURE));
            onComplete.sendToTarget();
            return;
        }

        Phone imsPhone = mImsPhone;
        if (useSsOverIms(onComplete)) {
            imsPhone.setCallForwardingOption(commandInterfaceCFAction, commandInterfaceCFReason,
@@ -2335,6 +2362,15 @@ public class GsmCdmaPhone extends Phone {
    @Override
    public void getCallBarring(String facility, String password, Message onComplete,
            int serviceClass) {
        // Perform FDN check
        SsData.ServiceType serviceType = GsmMmiCode.cbFacilityToServiceType(facility);
        if (isRequestBlockedByFDN(SsData.RequestType.SS_INTERROGATION, serviceType)) {
            AsyncResult.forMessage(onComplete, null,
                    new CommandException(CommandException.Error.FDN_CHECK_FAILURE));
            onComplete.sendToTarget();
            return;
        }

        Phone imsPhone = mImsPhone;
        if (useSsOverIms(onComplete)) {
            imsPhone.getCallBarring(facility, password, onComplete, serviceClass);
@@ -2351,6 +2387,17 @@ public class GsmCdmaPhone extends Phone {
    @Override
    public void setCallBarring(String facility, boolean lockState, String password,
            Message onComplete, int serviceClass) {
        // Perform FDN check
        SsData.RequestType requestType = lockState ? SsData.RequestType.SS_ACTIVATION :
                SsData.RequestType.SS_DEACTIVATION;
        SsData.ServiceType serviceType = GsmMmiCode.cbFacilityToServiceType(facility);
        if (isRequestBlockedByFDN(requestType, serviceType)) {
            AsyncResult.forMessage(onComplete, null,
                    new CommandException(CommandException.Error.FDN_CHECK_FAILURE));
            onComplete.sendToTarget();
            return;
        }

        Phone imsPhone = mImsPhone;
        if (useSsOverIms(onComplete)) {
            imsPhone.setCallBarring(facility, lockState, password, onComplete, serviceClass);
@@ -2374,6 +2421,18 @@ public class GsmCdmaPhone extends Phone {
     */
    public void changeCallBarringPassword(String facility, String oldPwd, String newPwd,
            Message onComplete) {
        // Perform FDN check
        SsData.ServiceType serviceType = GsmMmiCode.cbFacilityToServiceType(facility);
        ArrayList<String> controlStrings = GsmMmiCode.getControlStringsForPwd(
                SsData.RequestType.SS_REGISTRATION,
                serviceType);
        if(FdnUtils.isSuppServiceRequestBlockedByFdn(mPhoneId, controlStrings, getCountryIso())) {
            AsyncResult.forMessage(onComplete, null,
                    new CommandException(CommandException.Error.FDN_CHECK_FAILURE));
            onComplete.sendToTarget();
            return;
        }

        if (isPhoneTypeGsm()) {
            mCi.changeBarringPassword(facility, oldPwd, newPwd, onComplete);
        } else {
@@ -2383,6 +2442,14 @@ public class GsmCdmaPhone extends Phone {

    @Override
    public void getOutgoingCallerIdDisplay(Message onComplete) {
        // Perform FDN check
        if(isRequestBlockedByFDN(SsData.RequestType.SS_INTERROGATION, SsData.ServiceType.SS_CLIR)){
            AsyncResult.forMessage(onComplete, null,
                    new CommandException(CommandException.Error.FDN_CHECK_FAILURE));
            onComplete.sendToTarget();
            return;
        }

        Phone imsPhone = mImsPhone;
        if (useSsOverIms(onComplete)) {
            imsPhone.getOutgoingCallerIdDisplay(onComplete);
@@ -2401,6 +2468,15 @@ public class GsmCdmaPhone extends Phone {

    @Override
    public void setOutgoingCallerIdDisplay(int commandInterfaceCLIRMode, Message onComplete) {
        // Perform FDN check
        SsData.RequestType requestType = GsmMmiCode.clirModeToRequestType(commandInterfaceCLIRMode);
        if (isRequestBlockedByFDN(requestType, SsData.ServiceType.SS_CLIR)) {
            AsyncResult.forMessage(onComplete, null,
                    new CommandException(CommandException.Error.FDN_CHECK_FAILURE));
            onComplete.sendToTarget();
            return;
        }

        Phone imsPhone = mImsPhone;
        if (useSsOverIms(onComplete)) {
            imsPhone.setOutgoingCallerIdDisplay(commandInterfaceCLIRMode, onComplete);
@@ -2423,6 +2499,14 @@ public class GsmCdmaPhone extends Phone {

    @Override
    public void queryCLIP(Message onComplete) {
        // Perform FDN check
        if(isRequestBlockedByFDN(SsData.RequestType.SS_INTERROGATION, SsData.ServiceType.SS_CLIP)){
            AsyncResult.forMessage(onComplete, null,
                    new CommandException(CommandException.Error.FDN_CHECK_FAILURE));
            onComplete.sendToTarget();
            return;
        }

        Phone imsPhone = mImsPhone;
        if (useSsOverIms(onComplete)) {
            imsPhone.queryCLIP(onComplete);
@@ -2441,6 +2525,14 @@ public class GsmCdmaPhone extends Phone {

    @Override
    public void getCallWaiting(Message onComplete) {
        // Perform FDN check
        if(isRequestBlockedByFDN(SsData.RequestType.SS_INTERROGATION, SsData.ServiceType.SS_WAIT)){
            AsyncResult.forMessage(onComplete, null,
                    new CommandException(CommandException.Error.FDN_CHECK_FAILURE));
            onComplete.sendToTarget();
            return;
        }

        Phone imsPhone = mImsPhone;
        if (useSsOverIms(onComplete)) {
            imsPhone.getCallWaiting(onComplete);
@@ -2482,6 +2574,16 @@ public class GsmCdmaPhone extends Phone {

    @Override
    public void setCallWaiting(boolean enable, int serviceClass, Message onComplete) {
        // Perform FDN check
        SsData.RequestType requestType = enable ? SsData.RequestType.SS_ACTIVATION :
                SsData.RequestType.SS_DEACTIVATION;
        if (isRequestBlockedByFDN(requestType, SsData.ServiceType.SS_WAIT)) {
            AsyncResult.forMessage(onComplete, null,
                    new CommandException(CommandException.Error.FDN_CHECK_FAILURE));
            onComplete.sendToTarget();
            return;
        }

        Phone imsPhone = mImsPhone;
        if (useSsOverIms(onComplete)) {
            imsPhone.setCallWaiting(enable, onComplete);
@@ -4747,4 +4849,16 @@ public class GsmCdmaPhone extends Phone {
    public InboundSmsHandler getInboundSmsHandler(boolean is3gpp2) {
        return mIccSmsInterfaceManager.getInboundSmsHandler(is3gpp2);
    }

    /**
     * The following function checks if supplementary service request is blocked due to FDN.
     * @param requestType request type associated with the supplementary service
     * @param serviceType supplementary service type
     * @return {@code true} if request is blocked due to FDN.
     */
    private boolean isRequestBlockedByFDN(SsData.RequestType requestType,
            SsData.ServiceType serviceType) {
        ArrayList<String> controlStrings = GsmMmiCode.getControlStrings(requestType, serviceType);
        return FdnUtils.isSuppServiceRequestBlockedByFdn(mPhoneId, controlStrings, getCountryIso());
    }
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -902,7 +902,7 @@ public class SmsController extends ISmsImplBase {
     */
    private boolean isNumberBlockedByFDN(int subId, String destAddr, String callingPackage) {
        int phoneId = SubscriptionManager.getPhoneId(subId);
        if (!FdnUtils.isFdnEnabled(subId)) {
        if (!FdnUtils.isFdnEnabled(phoneId)) {
            return false;
        }

+184 −1
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ import com.android.internal.telephony.uicc.UiccCardApplication;
import com.android.internal.telephony.util.ArrayUtils;
import com.android.telephony.Rlog;

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@@ -455,7 +456,7 @@ public final class GsmMmiCode extends Handler implements MmiCode {
        return "";
    }

    private String getActionStringFromReqType(SsData.RequestType rType) {
    private static String getActionStringFromReqType(SsData.RequestType rType) {
        switch (rType) {
            case SS_ACTIVATION:
                return ACTION_ACTIVATE;
@@ -520,6 +521,40 @@ public final class GsmMmiCode extends Handler implements MmiCode {
        }
    }

    public static SsData.ServiceType cfReasonToServiceType(int commandInterfaceCFReason) {
        switch (commandInterfaceCFReason) {
            case CommandsInterface.CF_REASON_UNCONDITIONAL:
                return  SsData.ServiceType.SS_CFU;
            case CommandsInterface.CF_REASON_BUSY:
                return SsData.ServiceType.SS_CF_BUSY;
            case CommandsInterface.CF_REASON_NO_REPLY:
                return SsData.ServiceType.SS_CF_NO_REPLY;
            case CommandsInterface.CF_REASON_NOT_REACHABLE:
                return SsData.ServiceType.SS_CF_NOT_REACHABLE;
            case CommandsInterface.CF_REASON_ALL:
                return SsData.ServiceType.SS_CF_ALL;
            case CommandsInterface.CF_REASON_ALL_CONDITIONAL:
                return SsData.ServiceType.SS_CF_ALL_CONDITIONAL;
            default:
                return null;
        }
    }

    public static SsData.RequestType cfActionToRequestType(int commandInterfaceCFAction) {
        switch (commandInterfaceCFAction) {
            case CommandsInterface.CF_ACTION_DISABLE:
                return SsData.RequestType.SS_DEACTIVATION;
            case CommandsInterface.CF_ACTION_ENABLE:
                return SsData.RequestType.SS_ACTIVATION;
            case CommandsInterface.CF_ACTION_REGISTRATION:
                return SsData.RequestType.SS_REGISTRATION;
            case CommandsInterface.CF_ACTION_ERASURE:
                return SsData.RequestType.SS_ERASURE;
            default:
                return null;
        }
    }

    @UnsupportedAppUsage
    private static int
    siToServiceClass(String si) {
@@ -623,6 +658,29 @@ public final class GsmMmiCode extends Handler implements MmiCode {
        }
    }

    public static SsData.ServiceType cbFacilityToServiceType(String commandInterfaceCBFacility) {
        switch(commandInterfaceCBFacility) {
            case CommandsInterface.CB_FACILITY_BAOC:
                return SsData.ServiceType.SS_BAOC;
            case CommandsInterface.CB_FACILITY_BAOIC:
                return SsData.ServiceType.SS_BAOIC;
            case CommandsInterface.CB_FACILITY_BAOICxH:
                return SsData.ServiceType.SS_BAOIC_EXC_HOME;
            case CommandsInterface.CB_FACILITY_BAIC:
                return SsData.ServiceType.SS_BAIC;
            case CommandsInterface.CB_FACILITY_BAICr:
                return SsData.ServiceType.SS_BAIC_ROAMING;
            case CommandsInterface.CB_FACILITY_BA_ALL:
                return SsData.ServiceType.SS_ALL_BARRING;
            case CommandsInterface.CB_FACILITY_BA_MO:
                return SsData.ServiceType.SS_OUTGOING_BARRING;
            case CommandsInterface.CB_FACILITY_BA_MT:
                return SsData.ServiceType.SS_INCOMING_BARRING;
            default:
                return null;
        }
    }

    //***** Constructor

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
@@ -892,6 +950,17 @@ public final class GsmMmiCode extends Handler implements MmiCode {
        return CommandsInterface.CLIR_DEFAULT;
    }

    public static SsData.RequestType clirModeToRequestType(int commandInterfaceCLIRMode) {
        switch (commandInterfaceCLIRMode) {
            case CommandsInterface.CLIR_SUPPRESSION:
                return SsData.RequestType.SS_ACTIVATION;
            case CommandsInterface.CLIR_INVOCATION:
                return SsData.RequestType.SS_DEACTIVATION;
            default:
                return null;
        }
    }

    /**
     * Returns true if the Service Code is FAC to dial as a normal call.
     *
@@ -1834,6 +1903,120 @@ public final class GsmMmiCode extends Handler implements MmiCode {
        return this.mCallbackReceiver;
    }

    /**
     * Returns list of control strings for a supplementary service request
     * as defined in TS 22.030 6.5
     * @param requestType request type associated with the supplementary service
     * @param serviceType supplementary service type
     * @return list of control strings associated with the supplementary service.
     */
    public static ArrayList<String> getControlStrings(SsData.RequestType requestType,
            SsData.ServiceType serviceType) {
        ArrayList<String> controlStrings = new ArrayList<>();
        if (requestType == null || serviceType == null) {
            return controlStrings;
        }

        String actionStr = getActionStringFromReqType(requestType);
        switch (serviceType) {
            case SS_CFU:
                controlStrings.add(actionStr + SC_CFU);
                controlStrings.add(actionStr + SC_CF_All);
                break;
            case SS_CF_BUSY:
                controlStrings.add(actionStr + SC_CFB);
                controlStrings.add(actionStr + SC_CF_All_Conditional);
                controlStrings.add(actionStr + SC_CF_All);
                break;
            case SS_CF_NO_REPLY:
                controlStrings.add(actionStr + SC_CFNRy);
                controlStrings.add(actionStr + SC_CF_All_Conditional);
                controlStrings.add(actionStr + SC_CF_All);
                break;
            case SS_CF_NOT_REACHABLE:
                controlStrings.add(actionStr + SC_CFNR);
                controlStrings.add(actionStr + SC_CF_All_Conditional);
                controlStrings.add(actionStr + SC_CF_All);
                break;
            case SS_CF_ALL:
                controlStrings.add(actionStr + SC_CF_All);
                break;
            case SS_CF_ALL_CONDITIONAL:
                controlStrings.add(actionStr + SC_CF_All_Conditional);
                controlStrings.add(actionStr + SC_CF_All);
                break;
            case SS_CLIP:
                controlStrings.add(actionStr + SC_CLIP);
                break;
            case SS_CLIR:
                controlStrings.add(actionStr + SC_CLIR);
                break;
            case SS_WAIT:
                controlStrings.add(actionStr + SC_WAIT);
                break;
            case SS_BAOC:
                controlStrings.add(actionStr + SC_BAOC);
                controlStrings.add(actionStr + SC_BA_MO);
                controlStrings.add(actionStr + SC_BA_ALL);
                break;
            case SS_BAOIC:
                controlStrings.add(actionStr + SC_BAOIC);
                controlStrings.add(actionStr + SC_BA_MO);
                controlStrings.add(actionStr + SC_BA_ALL);
                break;
            case SS_BAOIC_EXC_HOME:
                controlStrings.add(actionStr + SC_BAOICxH);
                controlStrings.add(actionStr + SC_BA_MO);
                controlStrings.add(actionStr + SC_BA_ALL);
                break;
            case SS_BAIC:
                controlStrings.add(actionStr + SC_BAIC);
                controlStrings.add(actionStr + SC_BA_MT);
                controlStrings.add(actionStr + SC_BA_ALL);
                break;
            case SS_BAIC_ROAMING:
                controlStrings.add(actionStr + SC_BAICr);
                controlStrings.add(actionStr + SC_BA_MT);
                controlStrings.add(actionStr + SC_BA_ALL);
                break;
            case SS_ALL_BARRING:
                controlStrings.add(actionStr + SC_BA_ALL);
                break;
            case SS_OUTGOING_BARRING:
                controlStrings.add(actionStr + SC_BA_MO);
                controlStrings.add(actionStr + SC_BA_ALL);
                break;
            case SS_INCOMING_BARRING:
                controlStrings.add(actionStr + SC_BA_MT);
                controlStrings.add(actionStr + SC_BA_ALL);
                break;
        }
       return controlStrings;
    }

    /**
     * Returns control strings for registration of new password as per TS 22.030 6.5.4
     * @param requestType request type associated with the supplementary service
     * @param serviceType supplementary service type
     * @return list of control strings for new password registration.
     */
    public static ArrayList<String> getControlStringsForPwd(SsData.RequestType requestType,
            SsData.ServiceType serviceType) {
        ArrayList<String> controlStrings = new ArrayList<>();
        if (requestType == null || serviceType == null) {
            return controlStrings;
        }

        controlStrings = getControlStrings(SsData.RequestType.SS_ACTIVATION, serviceType);
        String actionStr = getActionStringFromReqType(requestType);
        ArrayList<String> controlStringsPwd = new ArrayList<>();
        for(String controlString : controlStrings) {
            // Prepend each control string with **SC_PWD
            controlStringsPwd.add(actionStr + SC_PWD + controlString);
        }
        return controlStringsPwd;
    }

    /***
     * TODO: It would be nice to have a method here that can take in a dialstring and
     * figure out if there is an MMI code embedded within it.  This code would replace
+305 −0

File changed.

Preview size limit exceeded, changes collapsed.

Loading