use of android.service.carrier.CarrierIdentifier 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);
}
}
}
use of android.service.carrier.CarrierIdentifier in project android_frameworks_opt_telephony by LineageOS.
the class RadioResponse method responseCarrierIdentifiers.
private void responseCarrierIdentifiers(RadioResponseInfo responseInfo, boolean allAllowed, CarrierRestrictions carriers) {
RILRequest rr = mRil.processResponse(responseInfo);
if (rr != null) {
List<CarrierIdentifier> ret = new ArrayList<CarrierIdentifier>();
for (int i = 0; i < carriers.allowedCarriers.size(); i++) {
String mcc = carriers.allowedCarriers.get(i).mcc;
String mnc = carriers.allowedCarriers.get(i).mnc;
String spn = null, imsi = null, gid1 = null, gid2 = null;
int matchType = carriers.allowedCarriers.get(i).matchType;
String matchData = carriers.allowedCarriers.get(i).matchData;
if (matchType == CarrierIdentifier.MatchType.SPN) {
spn = matchData;
} else if (matchType == CarrierIdentifier.MatchType.IMSI_PREFIX) {
imsi = matchData;
} else if (matchType == CarrierIdentifier.MatchType.GID1) {
gid1 = matchData;
} else if (matchType == CarrierIdentifier.MatchType.GID2) {
gid2 = matchData;
}
ret.add(new CarrierIdentifier(mcc, mnc, spn, imsi, gid1, gid2));
}
if (responseInfo.error == RadioError.NONE) {
/* TODO: Handle excluded carriers */
sendMessageResponse(rr.mResult, ret);
}
mRil.processResponseDone(rr, responseInfo, ret);
}
}
Aggregations