Search in sources :

Example 1 with RadioAccessSpecifier

use of android.telephony.RadioAccessSpecifier 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);
}
Also used : NetworkScanRequest(android.telephony.NetworkScanRequest) CellInfo(android.telephony.CellInfo) ArrayList(java.util.ArrayList) RadioAccessSpecifier(android.telephony.RadioAccessSpecifier)

Example 2 with RadioAccessSpecifier

use of android.telephony.RadioAccessSpecifier 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());
}
Also used : PhoneCapability(android.telephony.PhoneCapability) NetworkScanRequest(android.telephony.NetworkScanRequest) ArrayList(java.util.ArrayList) RadioAccessSpecifier(android.telephony.RadioAccessSpecifier) Test(org.junit.Test)

Example 3 with RadioAccessSpecifier

use of android.telephony.RadioAccessSpecifier 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);
}
Also used : NetworkScanRequest(android.telephony.NetworkScanRequest) ArrayList(java.util.ArrayList) RadioAccessSpecifier(android.telephony.RadioAccessSpecifier) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 4 with RadioAccessSpecifier

use of android.telephony.RadioAccessSpecifier 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());
}
Also used : PhoneCapability(android.telephony.PhoneCapability) NetworkScanRequest(android.telephony.NetworkScanRequest) ArrayList(java.util.ArrayList) RadioAccessSpecifier(android.telephony.RadioAccessSpecifier) Test(org.junit.Test)

Example 5 with RadioAccessSpecifier

use of android.telephony.RadioAccessSpecifier in project android_frameworks_opt_telephony by LineageOS.

the class RILTest method getRadioAccessSpecifier.

private RadioAccessSpecifier getRadioAccessSpecifier(CellInfo cellInfo) {
    RadioAccessSpecifier ras;
    if (cellInfo instanceof CellInfoLte) {
        int ranLte = AccessNetworkConstants.AccessNetworkType.EUTRAN;
        int[] lteChannels = { ((CellInfoLte) cellInfo).getCellIdentity().getEarfcn() };
        ras = new RadioAccessSpecifier(ranLte, null, /* bands */
        lteChannels);
    } else if (cellInfo instanceof CellInfoWcdma) {
        int ranLte = AccessNetworkConstants.AccessNetworkType.UTRAN;
        int[] wcdmaChannels = { ((CellInfoWcdma) cellInfo).getCellIdentity().getUarfcn() };
        ras = new RadioAccessSpecifier(ranLte, null, /* bands */
        wcdmaChannels);
    } else if (cellInfo instanceof CellInfoGsm) {
        int ranGsm = AccessNetworkConstants.AccessNetworkType.GERAN;
        int[] gsmChannels = { ((CellInfoGsm) cellInfo).getCellIdentity().getArfcn() };
        ras = new RadioAccessSpecifier(ranGsm, null, /* bands */
        gsmChannels);
    } else {
        ras = null;
    }
    return ras;
}
Also used : CellInfoLte(android.telephony.CellInfoLte) CellInfoWcdma(android.telephony.CellInfoWcdma) RadioAccessSpecifier(android.telephony.RadioAccessSpecifier) CellInfoGsm(android.telephony.CellInfoGsm)

Aggregations

RadioAccessSpecifier (android.telephony.RadioAccessSpecifier)9 NetworkScanRequest (android.telephony.NetworkScanRequest)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)4 IRadio (android.hardware.radio.V1_0.IRadio)2 Parcel (android.os.Parcel)2 RemoteException (android.os.RemoteException)2 PhoneCapability (android.telephony.PhoneCapability)2 SmallTest (androidx.test.filters.SmallTest)2 CellInfo (android.telephony.CellInfo)1 CellInfoGsm (android.telephony.CellInfoGsm)1 CellInfoLte (android.telephony.CellInfoLte)1 CellInfoWcdma (android.telephony.CellInfoWcdma)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1