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

Commit 77ba51be authored by Karen Zhang's avatar Karen Zhang Committed by Tyler Gunn
Browse files

Add API for Call Barring

Add Call Barring API in telephony framework so that telephony app can
use to realize Call Barring UI. Since some operator requires the UI,
this feature is needed.

Bug: 30845125
Test: Manual
Change-Id: I5d80508afd8216f04f443c5a9e0dd83d5247788f
parent f0ebe5fc
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -1766,6 +1766,57 @@ 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.getServiceState().getState() == ServiceState.STATE_IN_SERVICE)
                    || imsPhone.isUtEnabled())) {
                imsPhone.getCallBarring(facility, password, onComplete, serviceClass);
                return;
            }
            mCi.queryFacilityLock(facility, password, serviceClass, onComplete);
        } else {
            loge("getCallBarringOption: not possible in CDMA");
        }
    }

    @Override
    public void setCallBarring(String facility, boolean lockState, String password,
            Message onComplete, int serviceClass) {
        if (isPhoneTypeGsm()) {
            Phone imsPhone = mImsPhone;
            if ((imsPhone != null)
                    && ((imsPhone.getServiceState().getState() == ServiceState.STATE_IN_SERVICE)
                    || imsPhone.isUtEnabled())) {
                imsPhone.setCallBarring(facility, lockState, password, onComplete, serviceClass);
                return;
            }
            mCi.setFacilityLock(facility, lockState, password, serviceClass, onComplete);
        } else {
            loge("setCallBarringOption: not possible in CDMA");
        }
    }

    /**
     * Changes access code used for call barring
     *
     * @param facility is one of CB_FACILTY_*
     * @param oldPwd is old password
     * @param newPwd is new password
     * @param onComplete is callback message when the action is completed.
     */
    public void changeCallBarringPassword(String facility, String oldPwd, String newPwd,
            Message onComplete) {
        if (isPhoneTypeGsm()) {
            mCi.changeBarringPassword(facility, oldPwd, newPwd, onComplete);
        } else {
            loge("changeCallBarringPassword: not possible in CDMA");
        }
    }

    @Override
    public void getOutgoingCallerIdDisplay(Message onComplete) {
        if (isPhoneTypeGsm()) {
+29 −0
Original line number Diff line number Diff line
@@ -591,6 +591,35 @@ public interface PhoneInternalInterface {
                                 int timerSeconds,
                                 Message onComplete);

    /**
     * Gets a call barring option. The return value of ((AsyncResult) onComplete.obj) will be an
     * Integer representing the sum of enabled serivice classes (sum of SERVICE_CLASS_*)
     *
     * @param facility is one of CB_FACILTY_*
     * @param password is password or "" if not required
     * @param serviceClass is a sum of SERVICE_CLASS_*
     * @param onComplete is callback message when the action is completed.
     */
    public void getCallBarring(String facility,
            String password,
            Message onComplete,
            int serviceClass);

    /**
     * Sets a call barring option.
     *
     * @param facility is one of CB_FACILTY_*
     * @param lockState is true means lock, false means unlock
     * @param password is password or "" if not required
     * @param serviceClass is a sum of SERVICE_CLASS_*
     * @param onComplete is callback message when the action is completed.
     */
    public void setCallBarring(String facility,
            boolean lockState,
            String password,
            Message onComplete,
            int serviceClass);

    /**
     * getOutgoingCallerIdDisplay
     * gets outgoing caller id display. The return value of
+8 −0
Original line number Diff line number Diff line
@@ -956,6 +956,12 @@ public class ImsPhone extends ImsPhoneBase {
    }

    public void getCallBarring(String facility, Message onComplete, int serviceClass) {
        getCallBarring(facility, "", onComplete, serviceClass);
    }

    @Override
    public void getCallBarring(String facility, String password, Message onComplete,
            int serviceClass) {
        if (DBG) {
            Rlog.d(LOG_TAG, "getCallBarring facility=" + facility
                    + ", serviceClass = " + serviceClass);
@@ -965,6 +971,7 @@ public class ImsPhone extends ImsPhoneBase {

        try {
            ImsUtInterface ut = mCT.getUtInterface();
            // password is not required with Ut interface
            ut.queryCallBarring(getCBTypeFromFacility(facility), resp, serviceClass);
        } catch (ImsException e) {
            sendErrorResponse(onComplete, e);
@@ -977,6 +984,7 @@ public class ImsPhone extends ImsPhoneBase {
                CommandsInterface.SERVICE_CLASS_NONE);
    }

    @Override
    public void setCallBarring(String facility, boolean lockState, String password,
            Message onComplete,  int serviceClass) {
        if (DBG) {
+10 −0
Original line number Diff line number Diff line
@@ -545,6 +545,16 @@ abstract class ImsPhoneBase extends Phone {
        return null;
    }

    @Override
    public void getCallBarring(String facility, String password, Message onComplete,
            int serviceClass) {
    }

    @Override
    public void setCallBarring(String facility, boolean lockState, String password,
            Message onComplete, int serviceClass) {
    }

    @Override
    protected void onUpdateIccAvailability() {
    }
+10 −0
Original line number Diff line number Diff line
@@ -552,4 +552,14 @@ abstract class SipPhoneBase extends Phone {
    @Override
    public void setBroadcastEmergencyCallStateChanges(boolean broadcast) {
    }

    @Override
    public void getCallBarring(String facility, String password, Message onComplete,
            int serviceClass) {
    }

    @Override
    public void setCallBarring(String facility, boolean lockState, String password,
            Message onComplete, int serviceClass) {
    }
}
Loading