Search in sources :

Example 1 with CarrierRestrictions

use of android.hardware.radio.V1_0.CarrierRestrictions in project android_frameworks_opt_telephony by LineageOS.

the class RIL method setAllowedCarriers.

@Override
public void setAllowedCarriers(List<CarrierIdentifier> carriers, Message result) {
    checkNotNull(carriers, "Allowed carriers list cannot be null.");
    IRadio radioProxy = getRadioProxy(result);
    if (radioProxy != null) {
        RILRequest rr = obtainRequest(RIL_REQUEST_SET_ALLOWED_CARRIERS, result, mRILDefaultWorkSource);
        if (RILJ_LOGD) {
            String logStr = "";
            for (int i = 0; i < carriers.size(); i++) {
                logStr = logStr + carriers.get(i) + " ";
            }
            riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " carriers = " + logStr);
        }
        boolean allAllowed;
        if (carriers.size() == 0) {
            allAllowed = true;
        } else {
            allAllowed = false;
        }
        CarrierRestrictions carrierList = new CarrierRestrictions();
        for (CarrierIdentifier ci : carriers) {
            /* allowed carriers */
            Carrier c = new Carrier();
            c.mcc = convertNullToEmptyString(ci.getMcc());
            c.mnc = convertNullToEmptyString(ci.getMnc());
            int matchType = CarrierIdentifier.MatchType.ALL;
            String matchData = null;
            if (!TextUtils.isEmpty(ci.getSpn())) {
                matchType = CarrierIdentifier.MatchType.SPN;
                matchData = ci.getSpn();
            } else if (!TextUtils.isEmpty(ci.getImsi())) {
                matchType = CarrierIdentifier.MatchType.IMSI_PREFIX;
                matchData = ci.getImsi();
            } else if (!TextUtils.isEmpty(ci.getGid1())) {
                matchType = CarrierIdentifier.MatchType.GID1;
                matchData = ci.getGid1();
            } else if (!TextUtils.isEmpty(ci.getGid2())) {
                matchType = CarrierIdentifier.MatchType.GID2;
                matchData = ci.getGid2();
            }
            c.matchType = matchType;
            c.matchData = convertNullToEmptyString(matchData);
            carrierList.allowedCarriers.add(c);
        }
        try {
            radioProxy.setAllowedCarriers(rr.mSerial, allAllowed, carrierList);
        } catch (RemoteException | RuntimeException e) {
            handleRadioProxyExceptionForRR(rr, "setAllowedCarriers", e);
        }
    }
}
Also used : IRadio(android.hardware.radio.V1_0.IRadio) CarrierRestrictions(android.hardware.radio.V1_0.CarrierRestrictions) CarrierIdentifier(android.service.carrier.CarrierIdentifier) Carrier(android.hardware.radio.V1_0.Carrier) RemoteException(android.os.RemoteException)

Example 2 with CarrierRestrictions

use of android.hardware.radio.V1_0.CarrierRestrictions in project android_frameworks_opt_telephony by LineageOS.

the class RIL method setAllowedCarriers.

@Override
public void setAllowedCarriers(CarrierRestrictionRules carrierRestrictionRules, Message result, WorkSource workSource) {
    riljLog("RIL.java - setAllowedCarriers");
    checkNotNull(carrierRestrictionRules, "Carrier restriction cannot be null.");
    workSource = getDeafultWorkSourceIfInvalid(workSource);
    IRadio radioProxy = getRadioProxy(result);
    if (radioProxy == null)
        return;
    RILRequest rr = obtainRequest(RIL_REQUEST_SET_ALLOWED_CARRIERS, result, workSource);
    if (RILJ_LOGD) {
        riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " params: " + carrierRestrictionRules);
    }
    // Extract multisim policy
    int policy = SimLockMultiSimPolicy.NO_MULTISIM_POLICY;
    switch(carrierRestrictionRules.getMultiSimPolicy()) {
        case CarrierRestrictionRules.MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT:
            policy = SimLockMultiSimPolicy.ONE_VALID_SIM_MUST_BE_PRESENT;
            break;
    }
    if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) {
        riljLog("RIL.java - Using IRadio 1.4 or greater");
        android.hardware.radio.V1_4.IRadio radioProxy14 = (android.hardware.radio.V1_4.IRadio) radioProxy;
        // Prepare structure with allowed list, excluded list and priority
        CarrierRestrictionsWithPriority carrierRestrictions = new CarrierRestrictionsWithPriority();
        carrierRestrictions.allowedCarriers = createCarrierRestrictionList(carrierRestrictionRules.getAllowedCarriers());
        carrierRestrictions.excludedCarriers = createCarrierRestrictionList(carrierRestrictionRules.getExcludedCarriers());
        carrierRestrictions.allowedCarriersPrioritized = (carrierRestrictionRules.getDefaultCarrierRestriction() == CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED);
        try {
            radioProxy14.setAllowedCarriers_1_4(rr.mSerial, carrierRestrictions, policy);
        } catch (RemoteException | RuntimeException e) {
            handleRadioProxyExceptionForRR(rr, "setAllowedCarriers_1_4", e);
        }
    } else {
        boolean isAllCarriersAllowed = carrierRestrictionRules.isAllCarriersAllowed();
        boolean supported = (isAllCarriersAllowed || (carrierRestrictionRules.getExcludedCarriers().isEmpty() && (carrierRestrictionRules.getDefaultCarrierRestriction() == CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED)));
        supported = supported && (policy == SimLockMultiSimPolicy.NO_MULTISIM_POLICY);
        if (!supported) {
            // Feature is not supported by IRadio interface
            riljLoge("setAllowedCarriers does not support excluded list on IRadio version" + " less than 1.4");
            if (result != null) {
                AsyncResult.forMessage(result, null, CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
                result.sendToTarget();
            }
            return;
        }
        riljLog("RIL.java - Using IRadio 1.3 or lower");
        // Prepare structure with allowed list
        CarrierRestrictions carrierRestrictions = new CarrierRestrictions();
        carrierRestrictions.allowedCarriers = createCarrierRestrictionList(carrierRestrictionRules.getAllowedCarriers());
        try {
            radioProxy.setAllowedCarriers(rr.mSerial, isAllCarriersAllowed, carrierRestrictions);
        } catch (RemoteException | RuntimeException e) {
            handleRadioProxyExceptionForRR(rr, "setAllowedCarriers", e);
        }
    }
}
Also used : CarrierRestrictionsWithPriority(android.hardware.radio.V1_4.CarrierRestrictionsWithPriority) IRadio(android.hardware.radio.V1_0.IRadio) CarrierRestrictions(android.hardware.radio.V1_0.CarrierRestrictions) RemoteException(android.os.RemoteException)

Aggregations

CarrierRestrictions (android.hardware.radio.V1_0.CarrierRestrictions)2 IRadio (android.hardware.radio.V1_0.IRadio)2 RemoteException (android.os.RemoteException)2 Carrier (android.hardware.radio.V1_0.Carrier)1 CarrierRestrictionsWithPriority (android.hardware.radio.V1_4.CarrierRestrictionsWithPriority)1 CarrierIdentifier (android.service.carrier.CarrierIdentifier)1