use of android.telephony.NetworkScanRequest in project android_frameworks_opt_telephony by LineageOS.
the class RILTest method testStartNetworkScanWithUnsupportedResponse.
@FlakyTest
@Test
public void testStartNetworkScanWithUnsupportedResponse() throws Exception {
// Use Radio HAL v1.5
try {
replaceInstance(RIL.class, "mRadioVersion", mRILUnderTest, mRadioVersionV15);
} catch (Exception e) {
}
NetworkScanRequest nsr = getNetworkScanRequestForTesting();
mRILUnderTest.startNetworkScan(nsr, obtainMessage());
// Verify the v1.5 HAL methed is called firstly
verify(mRadioProxy).startNetworkScan_1_5(mSerialNumberCaptor.capture(), any());
// Before we find a way to trigger real RadioResponse method, emulate the behaivor.
Consumer<RILRequest> unsupportedResponseEmulator = rr -> {
mRILUnderTest.setCompatVersion(rr.getRequest(), RIL.RADIO_HAL_VERSION_1_4);
mRILUnderTest.startNetworkScan(nsr, Message.obtain(rr.getResult()));
};
verifyRILUnsupportedResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_START_NETWORK_SCAN, unsupportedResponseEmulator);
// Verify the fallback method is invoked
verify(mRadioProxy).startNetworkScan_1_4(eq(mSerialNumberCaptor.getValue() + 1), any());
}
use of android.telephony.NetworkScanRequest in project android_frameworks_opt_telephony by LineageOS.
the class RILTest method getNetworkScanRequestForTesting.
private NetworkScanRequest getNetworkScanRequestForTesting() {
// Construct a NetworkScanRequest for testing
List<CellInfo> allCellInfo = mTelephonyManager.getAllCellInfo();
List<RadioAccessSpecifier> radioAccessSpecifier = new ArrayList<>();
for (int i = 0; i < allCellInfo.size(); i++) {
RadioAccessSpecifier ras = getRadioAccessSpecifier(allCellInfo.get(i));
if (ras != null) {
radioAccessSpecifier.add(ras);
}
}
if (radioAccessSpecifier.size() == 0) {
RadioAccessSpecifier gsm = new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.GERAN, null, /* bands */
null);
radioAccessSpecifier.add(gsm);
}
RadioAccessSpecifier[] radioAccessSpecifierArray = new RadioAccessSpecifier[radioAccessSpecifier.size()];
return new NetworkScanRequest(NetworkScanRequest.SCAN_TYPE_ONE_SHOT, /* scan type */
radioAccessSpecifier.toArray(radioAccessSpecifierArray), 5, /* search periodicity */
60, /* max search time */
true, /*enable incremental results*/
5, /* incremental results periodicity */
null);
}
use of android.telephony.NetworkScanRequest in project android_packages_apps_Settings by omnirom.
the class NetworkScanHelperTest method createNetworkScanForPreferredAccessNetworks_deviceHasNrSa_hasNgran.
@Test
public void createNetworkScanForPreferredAccessNetworks_deviceHasNrSa_hasNgran() {
int[] deviceNrCapabilities = new int[] { PhoneCapability.DEVICE_NR_CAPABILITY_NSA, PhoneCapability.DEVICE_NR_CAPABILITY_SA };
PhoneCapability phoneCapability = createPhoneCapability(deviceNrCapabilities);
doReturn(TelephonyManager.NETWORK_CLASS_BITMASK_2G | TelephonyManager.NETWORK_CLASS_BITMASK_3G | TelephonyManager.NETWORK_CLASS_BITMASK_4G | TelephonyManager.NETWORK_CLASS_BITMASK_5G).when(mTelephonyManager).getPreferredNetworkTypeBitmask();
doReturn(phoneCapability).when(mTelephonyManager).getPhoneCapability();
List<RadioAccessSpecifier> radioAccessSpecifiers = new ArrayList<>();
radioAccessSpecifiers.add(new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.GERAN, null, null));
radioAccessSpecifiers.add(new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.UTRAN, null, null));
radioAccessSpecifiers.add(new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.EUTRAN, null, null));
radioAccessSpecifiers.add(new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.NGRAN, null, null));
NetworkScanRequest expectedNetworkScanRequest = createNetworkScanRequest(radioAccessSpecifiers);
assertEquals(expectedNetworkScanRequest, mNetworkScanHelper.createNetworkScanForPreferredAccessNetworks());
}
use of android.telephony.NetworkScanRequest in project android_packages_apps_Settings by omnirom.
the class NetworkScanHelper method createNetworkScanForPreferredAccessNetworks.
@VisibleForTesting
NetworkScanRequest createNetworkScanForPreferredAccessNetworks() {
long networkTypeBitmap3gpp = mTelephonyManager.getPreferredNetworkTypeBitmask() & TelephonyManager.NETWORK_STANDARDS_FAMILY_BITMASK_3GPP;
List<RadioAccessSpecifier> radioAccessSpecifiers = new ArrayList<>();
// that they can't connect to.
if (networkTypeBitmap3gpp == 0 || (networkTypeBitmap3gpp & TelephonyManager.NETWORK_CLASS_BITMASK_2G) != 0) {
radioAccessSpecifiers.add(new RadioAccessSpecifier(AccessNetworkType.GERAN, null, null));
}
if (networkTypeBitmap3gpp == 0 || (networkTypeBitmap3gpp & TelephonyManager.NETWORK_CLASS_BITMASK_3G) != 0) {
radioAccessSpecifiers.add(new RadioAccessSpecifier(AccessNetworkType.UTRAN, null, null));
}
if (networkTypeBitmap3gpp == 0 || (networkTypeBitmap3gpp & TelephonyManager.NETWORK_CLASS_BITMASK_4G) != 0) {
radioAccessSpecifiers.add(new RadioAccessSpecifier(AccessNetworkType.EUTRAN, null, null));
}
//
if (networkTypeBitmap3gpp == 0 || (hasNrSaCapability() && (networkTypeBitmap3gpp & TelephonyManager.NETWORK_CLASS_BITMASK_5G) != 0)) {
radioAccessSpecifiers.add(new RadioAccessSpecifier(AccessNetworkType.NGRAN, null, null));
Log.d(TAG, "radioAccessSpecifiers add NGRAN.");
}
return new NetworkScanRequest(NetworkScanRequest.SCAN_TYPE_ONE_SHOT, radioAccessSpecifiers.toArray(new RadioAccessSpecifier[radioAccessSpecifiers.size()]), SEARCH_PERIODICITY_SEC, MAX_SEARCH_TIME_SEC, INCREMENTAL_RESULTS, INCREMENTAL_RESULTS_PERIODICITY_SEC, null);
}
use of android.telephony.NetworkScanRequest in project android_packages_apps_Settings by omnirom.
the class NetworkScanHelperTest method createNetworkScanForPreferredAccessNetworks_deviceNoNrSa_noNgran.
@Test
public void createNetworkScanForPreferredAccessNetworks_deviceNoNrSa_noNgran() {
int[] deviceNrCapabilities = new int[] { PhoneCapability.DEVICE_NR_CAPABILITY_NSA };
PhoneCapability phoneCapability = createPhoneCapability(deviceNrCapabilities);
doReturn(TelephonyManager.NETWORK_CLASS_BITMASK_2G | TelephonyManager.NETWORK_CLASS_BITMASK_3G | TelephonyManager.NETWORK_CLASS_BITMASK_4G | TelephonyManager.NETWORK_CLASS_BITMASK_5G).when(mTelephonyManager).getPreferredNetworkTypeBitmask();
doReturn(phoneCapability).when(mTelephonyManager).getPhoneCapability();
List<RadioAccessSpecifier> radioAccessSpecifiers = new ArrayList<>();
radioAccessSpecifiers.add(new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.GERAN, null, null));
radioAccessSpecifiers.add(new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.UTRAN, null, null));
radioAccessSpecifiers.add(new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.EUTRAN, null, null));
NetworkScanRequest expectedNetworkScanRequest = createNetworkScanRequest(radioAccessSpecifiers);
assertEquals(expectedNetworkScanRequest, mNetworkScanHelper.createNetworkScanForPreferredAccessNetworks());
}
Aggregations