Search in sources :

Example 1 with CarrierRestrictionsWithPriority

use of android.hardware.radio.V1_4.CarrierRestrictionsWithPriority 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)

Example 2 with CarrierRestrictionsWithPriority

use of android.hardware.radio.V1_4.CarrierRestrictionsWithPriority in project android_frameworks_opt_telephony by LineageOS.

the class RadioResponse method getAllowedCarriersResponse.

/**
 * @param responseInfo Response info struct containing response type, serial no. and error
 * @param allAllowed true only when all carriers are allowed. Ignore "carriers" struct.
 *                   If false, consider "carriers" struct
 * @param carriers Carrier restriction information.
 */
public void getAllowedCarriersResponse(RadioResponseInfo responseInfo, boolean allAllowed, CarrierRestrictions carriers) {
    CarrierRestrictionsWithPriority carrierRestrictions = new CarrierRestrictionsWithPriority();
    carrierRestrictions.allowedCarriers = carriers.allowedCarriers;
    carrierRestrictions.excludedCarriers = carriers.excludedCarriers;
    carrierRestrictions.allowedCarriersPrioritized = true;
    responseCarrierRestrictions(responseInfo, allAllowed, carrierRestrictions, SimLockMultiSimPolicy.NO_MULTISIM_POLICY);
}
Also used : CarrierRestrictionsWithPriority(android.hardware.radio.V1_4.CarrierRestrictionsWithPriority)

Aggregations

CarrierRestrictionsWithPriority (android.hardware.radio.V1_4.CarrierRestrictionsWithPriority)2 CarrierRestrictions (android.hardware.radio.V1_0.CarrierRestrictions)1 IRadio (android.hardware.radio.V1_0.IRadio)1 RemoteException (android.os.RemoteException)1