use of android.telephony.NetworkScanRequest in project android_frameworks_opt_telephony by LineageOS.
the class NetworkScanRequestTest method testParcel.
@Test
@SmallTest
public void testParcel() {
int ranGsm = AccessNetworkType.GERAN;
int[] gsmBands = { GeranBand.BAND_T380, GeranBand.BAND_T410 };
int[] gsmChannels = { 1, 2, 3, 4 };
RadioAccessSpecifier gsm = new RadioAccessSpecifier(ranGsm, gsmBands, gsmChannels);
int ranLte = AccessNetworkType.EUTRAN;
int[] lteBands = { EutranBand.BAND_10, EutranBand.BAND_11 };
int[] lteChannels = { 5, 6, 7, 8 };
RadioAccessSpecifier lte = new RadioAccessSpecifier(ranLte, lteBands, lteChannels);
RadioAccessSpecifier[] ras = { gsm, lte };
int searchPeriodicity = 70;
int maxSearchTime = 200;
boolean incrementalResults = true;
int incrementalResultsPeriodicity = 7;
ArrayList<String> mccmncs = new ArrayList<String>();
mccmncs.add("310480");
mccmncs.add("21002");
NetworkScanRequest nsq = new NetworkScanRequest(NetworkScanRequest.SCAN_TYPE_ONE_SHOT, ras, searchPeriodicity, maxSearchTime, incrementalResults, incrementalResultsPeriodicity, mccmncs);
Parcel p = Parcel.obtain();
nsq.writeToParcel(p, 0);
p.setDataPosition(0);
NetworkScanRequest newNsq = NetworkScanRequest.CREATOR.createFromParcel(p);
assertEquals(nsq, newNsq);
}
use of android.telephony.NetworkScanRequest in project android_frameworks_opt_telephony by LineageOS.
the class RIL method startNetworkScan.
/**
* Radio HAL fallback compatibility feature (b/151106728) assumes that the input parameter
* networkScanRequest is immutable (read-only) here. Once the caller invokes the method, the
* parameter networkScanRequest should not be modified. This helps us keep a consistent and
* simple data model that avoid copying it in the scan result.
*/
@Override
public void startNetworkScan(NetworkScanRequest networkScanRequest, Message result) {
final NetworkScanRequest nsr = networkScanRequest;
IRadio radioProxy = getRadioProxy(result);
if (radioProxy != null) {
HalVersion overrideHalVersion = getCompatVersion(RIL_REQUEST_START_NETWORK_SCAN);
if (RILJ_LOGD) {
riljLog("startNetworkScan: overrideHalVersion=" + overrideHalVersion);
}
if ((overrideHalVersion == null || overrideHalVersion.greaterOrEqual(RADIO_HAL_VERSION_1_5)) && mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_5)) {
android.hardware.radio.V1_5.NetworkScanRequest request = new android.hardware.radio.V1_5.NetworkScanRequest();
request.type = nsr.getScanType();
request.interval = nsr.getSearchPeriodicity();
request.maxSearchTime = nsr.getMaxSearchTime();
request.incrementalResultsPeriodicity = nsr.getIncrementalResultsPeriodicity();
request.incrementalResults = nsr.getIncrementalResults();
for (RadioAccessSpecifier ras : nsr.getSpecifiers()) {
android.hardware.radio.V1_5.RadioAccessSpecifier rasInHalFormat = convertRadioAccessSpecifierToRadioHAL_1_5(ras);
if (rasInHalFormat == null) {
AsyncResult.forMessage(result, null, CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
result.sendToTarget();
return;
}
request.specifiers.add(rasInHalFormat);
}
request.mccMncs.addAll(nsr.getPlmns());
RILRequest rr = obtainRequest(RIL_REQUEST_START_NETWORK_SCAN, result, mRILDefaultWorkSource, nsr);
if (RILJ_LOGD) {
riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
}
try {
android.hardware.radio.V1_5.IRadio radioProxy15 = (android.hardware.radio.V1_5.IRadio) radioProxy;
radioProxy15.startNetworkScan_1_5(rr.mSerial, request);
} catch (RemoteException | RuntimeException e) {
handleRadioProxyExceptionForRR(rr, "startNetworkScan", e);
}
} else if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_2)) {
android.hardware.radio.V1_2.NetworkScanRequest request = new android.hardware.radio.V1_2.NetworkScanRequest();
request.type = nsr.getScanType();
request.interval = nsr.getSearchPeriodicity();
request.maxSearchTime = nsr.getMaxSearchTime();
request.incrementalResultsPeriodicity = nsr.getIncrementalResultsPeriodicity();
request.incrementalResults = nsr.getIncrementalResults();
for (RadioAccessSpecifier ras : nsr.getSpecifiers()) {
android.hardware.radio.V1_1.RadioAccessSpecifier rasInHalFormat = convertRadioAccessSpecifierToRadioHAL(ras);
if (rasInHalFormat == null) {
AsyncResult.forMessage(result, null, CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
result.sendToTarget();
return;
}
request.specifiers.add(rasInHalFormat);
}
request.mccMncs.addAll(nsr.getPlmns());
RILRequest rr = obtainRequest(RIL_REQUEST_START_NETWORK_SCAN, result, mRILDefaultWorkSource);
if (RILJ_LOGD) {
riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
}
try {
if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) {
android.hardware.radio.V1_4.IRadio radioProxy14 = (android.hardware.radio.V1_4.IRadio) radioProxy;
radioProxy14.startNetworkScan_1_4(rr.mSerial, request);
} else {
android.hardware.radio.V1_2.IRadio radioProxy12 = (android.hardware.radio.V1_2.IRadio) radioProxy;
radioProxy12.startNetworkScan_1_2(rr.mSerial, request);
}
} catch (RemoteException | RuntimeException e) {
handleRadioProxyExceptionForRR(rr, "startNetworkScan", e);
}
} else if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_1)) {
android.hardware.radio.V1_1.IRadio radioProxy11 = (android.hardware.radio.V1_1.IRadio) radioProxy;
android.hardware.radio.V1_1.NetworkScanRequest request = new android.hardware.radio.V1_1.NetworkScanRequest();
request.type = nsr.getScanType();
request.interval = nsr.getSearchPeriodicity();
for (RadioAccessSpecifier ras : nsr.getSpecifiers()) {
android.hardware.radio.V1_1.RadioAccessSpecifier rasInHalFormat = convertRadioAccessSpecifierToRadioHAL(ras);
if (rasInHalFormat == null) {
AsyncResult.forMessage(result, null, CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
result.sendToTarget();
return;
}
request.specifiers.add(rasInHalFormat);
}
RILRequest rr = obtainRequest(RIL_REQUEST_START_NETWORK_SCAN, result, mRILDefaultWorkSource);
if (RILJ_LOGD) {
riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
}
try {
radioProxy11.startNetworkScan(rr.mSerial, request);
} catch (RemoteException | RuntimeException e) {
handleRadioProxyExceptionForRR(rr, "startNetworkScan", e);
}
} else if (result != null) {
AsyncResult.forMessage(result, null, CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
result.sendToTarget();
}
}
}
use of android.telephony.NetworkScanRequest in project android_frameworks_opt_telephony by LineageOS.
the class RadioResponse method responseScanStatus.
private void responseScanStatus(RadioResponseInfo responseInfo, HalVersion fallbackHalVersion) {
RILRequest rr = mRil.processResponse(responseInfo);
if (rr == null) {
return;
}
final boolean needFallback = responseInfo.error == RadioError.REQUEST_NOT_SUPPORTED && fallbackHalVersion != null && rr.mArguments != null && rr.mArguments.length > 0 && rr.mArguments[0] instanceof NetworkScanRequest;
if (needFallback) {
// Move the data needed for fallback call from rr which will be released soon
final int request = rr.getRequest();
final Message result = rr.getResult();
final NetworkScanRequest scanRequest = (NetworkScanRequest) rr.mArguments[0];
mRil.mRilHandler.post(() -> {
mRil.setCompatVersion(request, RIL.RADIO_HAL_VERSION_1_4);
mRil.startNetworkScan(scanRequest, result);
});
mRil.processResponseFallback(rr, responseInfo, null);
return;
}
NetworkScanResult nsr = null;
if (responseInfo.error == RadioError.NONE) {
nsr = new NetworkScanResult(NetworkScanResult.SCAN_STATUS_PARTIAL, RadioError.NONE, null);
sendMessageResponse(rr.mResult, nsr);
}
mRil.processResponseDone(rr, responseInfo, nsr);
}
Aggregations