Search in sources :

Example 1 with PhoneCapability

use of android.telephony.PhoneCapability 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 2 with PhoneCapability

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

the class RadioConfigResponse method getPhoneCapabilityResponse.

/**
 * Response function for IRadioConfig.getPhoneCapability().
 */
public void getPhoneCapabilityResponse(RadioResponseInfo responseInfo, android.hardware.radio.config.V1_1.PhoneCapability phoneCapability) {
    RILRequest rr = mRadioConfig.processResponse(responseInfo);
    if (rr != null) {
        PhoneCapability ret = convertHalPhoneCapability(phoneCapability);
        if (responseInfo.error == RadioError.NONE) {
            // send response
            RadioResponse.sendMessageResponse(rr.mResult, ret);
            Rlog.d(TAG, rr.serialString() + "< " + mRadioConfig.requestToString(rr.mRequest) + " " + ret.toString());
        } else {
            rr.onError(responseInfo.error, ret);
            Rlog.e(TAG, rr.serialString() + "< " + mRadioConfig.requestToString(rr.mRequest) + " error " + responseInfo.error);
        }
    } else {
        Rlog.e(TAG, "getPhoneCapabilityResponse: Error " + responseInfo.toString());
    }
}
Also used : PhoneCapability(android.telephony.PhoneCapability)

Example 3 with PhoneCapability

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

the class RadioConfigResponse method convertHalPhoneCapability.

private PhoneCapability convertHalPhoneCapability(android.hardware.radio.config.V1_1.PhoneCapability phoneCapability) {
    // TODO b/121394331: clean up V1_1.PhoneCapability fields.
    int maxActiveVoiceCalls = 0;
    int maxActiveData = phoneCapability.maxActiveData;
    int max5G = 0;
    boolean validationBeforeSwitchSupported = phoneCapability.isInternetLingeringSupported;
    List<ModemInfo> logicalModemList = new ArrayList();
    for (android.hardware.radio.config.V1_1.ModemInfo modemInfo : phoneCapability.logicalModemList) {
        logicalModemList.add(new ModemInfo(modemInfo.modemId));
    }
    return new PhoneCapability(maxActiveVoiceCalls, maxActiveData, max5G, logicalModemList, validationBeforeSwitchSupported);
}
Also used : PhoneCapability(android.telephony.PhoneCapability) ArrayList(java.util.ArrayList) ModemInfo(android.telephony.ModemInfo)

Example 4 with PhoneCapability

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

the class PhoneCapabilityTest method parcelReadWrite.

@Test
@SmallTest
public void parcelReadWrite() throws Exception {
    int maxActiveVoiceCalls = 1;
    int maxActiveData = 2;
    int max5G = 3;
    ModemInfo modemInfo = new ModemInfo(1, 2, true, false);
    List<ModemInfo> logicalModemList = new ArrayList<>();
    logicalModemList.add(modemInfo);
    PhoneCapability capability = new PhoneCapability(maxActiveVoiceCalls, maxActiveData, max5G, logicalModemList, false);
    Parcel parcel = Parcel.obtain();
    capability.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    PhoneCapability toCompare = PhoneCapability.CREATOR.createFromParcel(parcel);
    assertEquals(maxActiveVoiceCalls, toCompare.maxActiveVoiceCalls);
    assertEquals(maxActiveData, toCompare.maxActiveData);
    assertEquals(max5G, toCompare.max5G);
    assertEquals(1, toCompare.logicalModemList.size());
    assertEquals(modemInfo, toCompare.logicalModemList.get(0));
    assertEquals(capability, toCompare);
}
Also used : PhoneCapability(android.telephony.PhoneCapability) Parcel(android.os.Parcel) ArrayList(java.util.ArrayList) ModemInfo(android.telephony.ModemInfo) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 5 with PhoneCapability

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

the class TelephonyRegistryTest method testPhoneCapabilityChanged.

@Test
@SmallTest
public void testPhoneCapabilityChanged() {
    doReturn(mMockSubInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(anyInt());
    doReturn(0).when(mMockSubInfo).getSimSlotIndex();
    // mTelephonyRegistry.listen with notifyNow = true should trigger callback immediately.
    PhoneCapability phoneCapability = new PhoneCapability(1, 2, 3, null, false);
    mTelephonyRegistry.notifyPhoneCapabilityChanged(phoneCapability);
    mTelephonyRegistry.listenWithFeature(mContext.getOpPackageName(), mContext.getAttributionTag(), mPhoneStateListener.callback, LISTEN_PHONE_CAPABILITY_CHANGE, true);
    processAllMessages();
    assertEquals(phoneCapability, mPhoneCapability);
    // notifyPhoneCapabilityChanged with a new capability. Callback should be triggered.
    phoneCapability = new PhoneCapability(3, 2, 2, null, false);
    mTelephonyRegistry.notifyPhoneCapabilityChanged(phoneCapability);
    processAllMessages();
    assertEquals(phoneCapability, mPhoneCapability);
}
Also used : PhoneCapability(android.telephony.PhoneCapability) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

PhoneCapability (android.telephony.PhoneCapability)9 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)5 ModemInfo (android.telephony.ModemInfo)4 SmallTest (android.test.suitebuilder.annotation.SmallTest)3 NetworkScanRequest (android.telephony.NetworkScanRequest)2 RadioAccessSpecifier (android.telephony.RadioAccessSpecifier)2 Parcel (android.os.Parcel)1 Before (org.junit.Before)1