Loading src/java/com/android/internal/telephony/RIL.java +184 −70 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ import android.hardware.radio.V1_0.CellInfoLte; import android.hardware.radio.V1_0.CellInfoTdscdma; import android.hardware.radio.V1_0.CellInfoType; import android.hardware.radio.V1_0.CellInfoWcdma; import android.hardware.radio.V1_0.DataProfileInfo; import android.hardware.radio.V1_0.DataProfileId; import android.hardware.radio.V1_0.Dial; import android.hardware.radio.V1_0.GsmBroadcastSmsConfigInfo; import android.hardware.radio.V1_0.GsmSmsMessage; Loading Loading @@ -1156,12 +1156,14 @@ public class RIL extends BaseCommands implements CommandsInterface { } /** * Convert to DataProfileInfo defined in types.hal * Convert to DataProfileInfo defined in radio/1.0/types.hal * @param dp Data profile * @return A converted data profile */ private static DataProfileInfo convertToHalDataProfile(DataProfile dp) { DataProfileInfo dpi = new DataProfileInfo(); private static android.hardware.radio.V1_0.DataProfileInfo convertToHalDataProfile10( DataProfile dp) { android.hardware.radio.V1_0.DataProfileInfo dpi = new android.hardware.radio.V1_0.DataProfileInfo(); dpi.profileId = dp.getProfileId(); dpi.apn = dp.getApn(); Loading @@ -1178,8 +1180,41 @@ public class RIL extends BaseCommands implements CommandsInterface { dpi.supportedApnTypesBitmap = dp.getSupportedApnTypesBitmap(); dpi.bearerBitmap = dp.getBearerBitmap(); dpi.mtu = dp.getMtu(); dpi.mvnoType = convertToHalMvnoType(dp.getMvnoType()); dpi.mvnoMatchData = dp.getMvnoMatchData(); dpi.mvnoType = MvnoType.NONE; dpi.mvnoMatchData = ""; return dpi; } /** * Convert to DataProfileInfo defined in radio/1.3/types.hal * @param dp Data profile * @return A converted data profile */ private static android.hardware.radio.V1_3.DataProfileInfo convertToHalDataProfile13( DataProfile dp) { android.hardware.radio.V1_3.DataProfileInfo dpi = new android.hardware.radio.V1_3.DataProfileInfo(); dpi.apn = dp.getApn(); dpi.protocol = dp.getProtocol(); dpi.roamingProtocol = dp.getRoamingProtocol(); dpi.authType = dp.getAuthType(); dpi.user = dp.getUserName(); dpi.password = dp.getPassword(); dpi.type = dp.getType(); dpi.maxConnsTime = dp.getMaxConnsTime(); dpi.maxConns = dp.getMaxConns(); dpi.waitTime = dp.getWaitTime(); dpi.enabled = dp.isEnabled(); dpi.supportedApnTypesBitmap = dp.getSupportedApnTypesBitmap(); dpi.bearerBitmap = dp.getBearerBitmap(); dpi.mtu = dp.getMtu(); dpi.persistent = dp.isPersistent(); dpi.preferred = dp.isPreferred(); // profile id is only meaningful when it's persistent on the modem. dpi.profileId = (dpi.persistent) ? dp.getProfileId() : DataProfileId.INVALID; return dpi; } Loading Loading @@ -1209,44 +1244,16 @@ public class RIL extends BaseCommands implements CommandsInterface { boolean allowRoaming, int reason, LinkProperties linkProperties, Message result) { IRadio radioProxy = getRadioProxy(result); IRadio radioProxy10 = getRadioProxy(result); if (radioProxy != null) { if (radioProxy10 != null) { RILRequest rr = obtainRequest(RIL_REQUEST_SETUP_DATA_CALL, result, mRILDefaultWorkSource); // Convert to HAL data profile DataProfileInfo dpi = convertToHalDataProfile(dataProfile); android.hardware.radio.V1_2.IRadio radioProxy12 = android.hardware.radio.V1_2.IRadio.castFrom(radioProxy); try { if (radioProxy12 == null) { // IRadio V1.0 // Getting data RAT here is just a workaround to support the older 1.0 vendor // RIL. The new data service interface passes access network type instead of // RAT for setup data request. It is impossible to convert access network // type back to RAT here, so we directly get the data RAT from phone. int dataRat = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN; Phone phone = PhoneFactory.getPhone(mPhoneId); if (phone != null) { ServiceState ss = phone.getServiceState(); if (ss != null) { dataRat = ss.getRilDataRadioTechnology(); } } if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + ",dataRat=" + dataRat + ",isRoaming=" + isRoaming + ",allowRoaming=" + allowRoaming + "," + dataProfile); } android.hardware.radio.V1_3.IRadio radioProxy13 = android.hardware.radio.V1_3.IRadio.castFrom(radioProxy10); radioProxy.setupDataCall(rr.mSerial, dataRat, dpi, dataProfile.isModemCognitive(), allowRoaming, isRoaming); } else { // IRadio V1.2 ArrayList<String> addresses = new ArrayList<>(); ArrayList<String> dnses = new ArrayList<>(); if (linkProperties != null) { Loading @@ -1258,6 +1265,16 @@ public class RIL extends BaseCommands implements CommandsInterface { } } try { // Note that we should always try the highest version first. If the vendor IRadio // is v1.3, both radioProxy13 and radioProxy12 will be non-null. if (radioProxy13 != null) { // IRadio V1.3 // Convert to HAL data profile android.hardware.radio.V1_3.DataProfileInfo dpi = convertToHalDataProfile13(dataProfile); if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + ",accessNetworkType=" + accessNetworkType + ",isRoaming=" Loading @@ -1265,9 +1282,57 @@ public class RIL extends BaseCommands implements CommandsInterface { + ",addresses=" + addresses + ",dnses=" + dnses); } radioProxy13.setupDataCall_1_3(rr.mSerial, accessNetworkType, dpi, allowRoaming, reason, addresses, dnses); } else { android.hardware.radio.V1_2.IRadio radioProxy12 = android.hardware.radio.V1_2.IRadio.castFrom(radioProxy10); if (radioProxy12 != null) { // IRadio V1.2 // Convert to HAL data profile android.hardware.radio.V1_0.DataProfileInfo dpi = convertToHalDataProfile10(dataProfile); if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + ",accessNetworkType=" + accessNetworkType + ",isRoaming=" + isRoaming + ",allowRoaming=" + allowRoaming + "," + dataProfile + ",addresses=" + addresses + ",dnses=" + dnses); } radioProxy12.setupDataCall_1_2(rr.mSerial, accessNetworkType, dpi, dataProfile.isModemCognitive(), allowRoaming, isRoaming, reason, dataProfile.isPersistent(), allowRoaming, isRoaming, reason, addresses, dnses); } else { // IRadio V1.0 and IRadio V1.1 // Convert to HAL data profile android.hardware.radio.V1_0.DataProfileInfo dpi = convertToHalDataProfile10(dataProfile); // Getting data RAT here is just a workaround to support the older 1.0 // vendor RIL. The new data service interface passes access network type // instead of RAT for setup data request. It is impossible to convert access // network type back to RAT here, so we directly get the data RAT from // phone. int dataRat = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN; Phone phone = PhoneFactory.getPhone(mPhoneId); if (phone != null) { ServiceState ss = phone.getServiceState(); if (ss != null) { dataRat = ss.getRilDataRadioTechnology(); } } if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + ",dataRat=" + dataRat + ",isRoaming=" + isRoaming + ",allowRoaming=" + allowRoaming + "," + dataProfile); } radioProxy10.setupDataCall(rr.mSerial, dataRat, dpi, dataProfile.isPersistent(), allowRoaming, isRoaming); } } } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setupDataCall", e); Loading Loading @@ -3029,8 +3094,8 @@ public class RIL extends BaseCommands implements CommandsInterface { @Override public void setInitialAttachApn(DataProfile dataProfile, boolean isRoaming, Message result) { IRadio radioProxy = getRadioProxy(result); if (radioProxy != null) { IRadio radioProxy10 = getRadioProxy(result); if (radioProxy10 != null) { RILRequest rr = obtainRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, result, mRILDefaultWorkSource); Loading @@ -3038,9 +3103,23 @@ public class RIL extends BaseCommands implements CommandsInterface { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + dataProfile); } android.hardware.radio.V1_3.IRadio radioProxy13 = android.hardware.radio.V1_3.IRadio.castFrom(radioProxy10); try { radioProxy.setInitialAttachApn(rr.mSerial, convertToHalDataProfile(dataProfile), dataProfile.isModemCognitive(), isRoaming); // Note that we should always try the highest version first. If the vendor IRadio // is v1.3, both radioProxy13 and radioProxy10 will be non-null. if (radioProxy13 != null) { // v1.3 radioProxy13.setInitialAttachApn_1_3(rr.mSerial, convertToHalDataProfile13(dataProfile)); } else { // v1.2, v1.1, and v1.0 radioProxy10.setInitialAttachApn(rr.mSerial, convertToHalDataProfile10(dataProfile), dataProfile.isPersistent(), isRoaming); } } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setInitialAttachApn", e); } Loading Loading @@ -3424,11 +3503,25 @@ public class RIL extends BaseCommands implements CommandsInterface { @Override public void setDataProfile(DataProfile[] dps, boolean isRoaming, Message result) { IRadio radioProxy = getRadioProxy(result); if (radioProxy != null) { RILRequest rr = obtainRequest(RIL_REQUEST_SET_DATA_PROFILE, result, IRadio radioProxy10 = getRadioProxy(result); if (radioProxy10 != null) { android.hardware.radio.V1_3.IRadio radioProxy13 = android.hardware.radio.V1_3.IRadio.castFrom(radioProxy10); RILRequest rr = null; try { // Note that we should always try the highest version first. If the vendor IRadio // is v1.3, both radioProxy13 and radioProxy10 will be non-null. if (radioProxy13 != null) { // V1.3 rr = obtainRequest(RIL_REQUEST_SET_DATA_PROFILE, result, mRILDefaultWorkSource); ArrayList<android.hardware.radio.V1_3.DataProfileInfo> dpis = new ArrayList<>(); for (DataProfile dp : dps) { dpis.add(convertToHalDataProfile13(dp)); } if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " with data profiles : "); Loading @@ -3437,13 +3530,34 @@ public class RIL extends BaseCommands implements CommandsInterface { } } ArrayList<DataProfileInfo> dpis = new ArrayList<>(); radioProxy13.setDataProfile_1_3(rr.mSerial, dpis); } else { // V1.0, 1.1, and 1.2 ArrayList<android.hardware.radio.V1_0.DataProfileInfo> dpis = new ArrayList<>(); for (DataProfile dp : dps) { dpis.add(convertToHalDataProfile(dp)); // For v1.0 to v1.2, we only send data profiles that has the persistent // (a.k.a modem cognitive) bit set to true. if (dp.isPersistent()) { dpis.add(convertToHalDataProfile10(dp)); } } try { radioProxy.setDataProfile(rr.mSerial, dpis, isRoaming); if (!dpis.isEmpty()) { rr = obtainRequest(RIL_REQUEST_SET_DATA_PROFILE, result, mRILDefaultWorkSource); if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " with data profiles : "); for (DataProfile profile : dps) { riljLog(profile.toString()); } } radioProxy10.setDataProfile(rr.mSerial, dpis, isRoaming); } } } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setDataProfile", e); } Loading src/java/com/android/internal/telephony/dataconnection/DataConnection.java +2 −1 Original line number Diff line number Diff line Loading @@ -535,7 +535,8 @@ public class DataConnection extends StateMachine { Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp); msg.obj = cp; DataProfile dp = DcTracker.createDataProfile(mApnSetting, cp.mProfileId); DataProfile dp = DcTracker.createDataProfile(mApnSetting, cp.mProfileId, mApnSetting.equals(mDct.getPreferredApn())); // We need to use the actual modem roaming state instead of the framework roaming state // here. This flag is only passed down to ril_service for picking the correct protocol (for Loading src/java/com/android/internal/telephony/dataconnection/DcTracker.java +38 −38 Original line number Diff line number Diff line Loading @@ -18,6 +18,9 @@ package com.android.internal.telephony.dataconnection; import static android.Manifest.permission.READ_PHONE_STATE; import static com.android.internal.telephony.RILConstants.DATA_PROFILE_DEFAULT; import static com.android.internal.telephony.RILConstants.DATA_PROFILE_INVALID; import android.annotation.NonNull; import android.app.AlarmManager; import android.app.PendingIntent; Loading Loading @@ -536,19 +539,7 @@ public class DcTracker extends Handler { private int mDisconnectPendingCount = 0; /** Indicate if metered APNs are disabled. * set to block all the metered APNs from continuously sending requests, which causes * undesired network load */ private boolean mMeteredApnDisabled = false; /** * int to remember whether has setDataProfiles and with roaming or not. * 0: default, has never set data profile * 1: has set data profile with home protocol * 2: has set data profile with roaming protocol * This is not needed once RIL command is updated to support both home and roaming protocol. */ private int mSetDataProfileStatus = 0; private ArrayList<DataProfile> mLastDataProfileList = new ArrayList<>(); /** * Handles changes to the APN db. Loading Loading @@ -1919,10 +1910,14 @@ public class DcTracker extends Handler { return false; } int profileId = apnSetting.getProfileId(); if (profileId == 0) { // profile id is only meaningful when the profile is persistent on the modem. int profileId = DATA_PROFILE_INVALID; if (apnSetting.isPersistent()) { profileId = apnSetting.getProfileId(); if (profileId == DATA_PROFILE_DEFAULT) { profileId = getApnProfileID(apnContext.getApnType()); } } // On CDMA, if we're explicitly asking for DUN, we need have // a dun-profiled connection so we can't share an existing one Loading Loading @@ -2053,7 +2048,8 @@ public class DcTracker extends Handler { } else { if (DBG) log("setInitialAttachApn: X selected Apn=" + initialAttachApnSetting); mDataServiceManager.setInitialAttachApn(createDataProfile(initialAttachApnSetting), mDataServiceManager.setInitialAttachApn(createDataProfile(initialAttachApnSetting, initialAttachApnSetting.equals(getPreferredApn())), mPhone.getServiceState().getDataRoamingFromRegistration(), null); } } Loading Loading @@ -3218,17 +3214,22 @@ public class DcTracker extends Handler { private void setDataProfilesAsNeeded() { if (DBG) log("setDataProfilesAsNeeded"); ArrayList<DataProfile> dps = new ArrayList<DataProfile>(); ArrayList<DataProfile> dataProfileList = new ArrayList<>(); for (ApnSetting apn : mAllApnSettings) { if (apn.getModemCognitive()) { DataProfile dp = createDataProfile(apn); if (!dps.contains(dp)) { dps.add(dp); DataProfile dp = createDataProfile(apn, apn.equals(getPreferredApn())); if (!dataProfileList.contains(dp)) { dataProfileList.add(dp); } } } if (dps.size() > 0) { mDataServiceManager.setDataProfile(dps, // Check if the data profiles we are sending are same as we did last time. We don't want to // send the redundant profiles to the modem. Also if there the list is empty, we don't // send it to the modem. if (!dataProfileList.isEmpty() && (dataProfileList.size() != mLastDataProfileList.size() || !mLastDataProfileList.containsAll(dataProfileList))) { mDataServiceManager.setDataProfile(dataProfileList, mPhone.getServiceState().getDataRoamingFromRegistration(), null); } } Loading Loading @@ -3339,7 +3340,7 @@ public class DcTracker extends Handler { dest.getApnName(), proxy, port, mmsc, mmsProxy, mmsPort, dest.getUser(), dest.getPassword(), dest.getAuthType(), resultApnType, protocol, roamingProtocol, dest.isEnabled(), networkTypeBitmask, dest.getProfileId(), (dest.getModemCognitive() || src.getModemCognitive()), dest.getMaxConns(), (dest.isPersistent() || src.isPersistent()), dest.getMaxConns(), dest.getWaitTime(), dest.getMaxConnsTime(), dest.getMtu(), dest.getMvnoType(), dest.getMvnoMatchData(), dest.getApnSetId()); } Loading Loading @@ -3527,7 +3528,7 @@ public class DcTracker extends Handler { } } private ApnSetting getPreferredApn() { ApnSetting getPreferredApn() { if (mAllApnSettings == null || mAllApnSettings.isEmpty()) { log("getPreferredApn: mAllApnSettings is empty"); return null; Loading Loading @@ -4755,16 +4756,16 @@ public class DcTracker extends Handler { } } private static DataProfile createDataProfile(ApnSetting apn) { return createDataProfile(apn, apn.getProfileId()); private static DataProfile createDataProfile(ApnSetting apn, boolean isPreferred) { return createDataProfile(apn, apn.getProfileId(), isPreferred); } @VisibleForTesting public static DataProfile createDataProfile(ApnSetting apn, int profileId) { public static DataProfile createDataProfile(ApnSetting apn, int profileId, boolean isPreferred) { int profileType; int bearerBitmap = 0; bearerBitmap = ServiceState.convertNetworkTypeBitmaskToBearerBitmask( int bearerBitmap = ServiceState.convertNetworkTypeBitmaskToBearerBitmask( apn.getNetworkTypeBitmask()); if (bearerBitmap == 0) { Loading @@ -4780,8 +4781,7 @@ public class DcTracker extends Handler { apn.getUser(), apn.getPassword(), profileType, apn.getMaxConnsTime(), apn.getMaxConns(), apn.getWaitTime(), apn.isEnabled(), apn.getApnTypeBitmask(), ApnSetting.getProtocolStringFromInt(apn.getRoamingProtocol()), bearerBitmap, apn.getMtu(), ApnSetting.getMvnoTypeStringFromInt(apn.getMvnoType()), apn.getMvnoMatchData(), apn.getModemCognitive()); apn.getMtu(), apn.isPersistent(), isPreferred); } private void onDataServiceBindingChanged(boolean bound) { Loading tests/telephonytests/src/com/android/internal/telephony/RILTest.java +4 −6 Original line number Diff line number Diff line Loading @@ -229,7 +229,7 @@ public class RILTest extends TelephonyTest { private static final int MTU = 1234; private static final String MVNO_TYPE = ""; private static final String MVNO_MATCH_DATA = ""; private static final boolean MODEM_COGNITIVE = true; private static final boolean PERSISTENT = true; private class RILTestHandler extends HandlerThread { Loading Loading @@ -704,7 +704,7 @@ public class RILTest extends TelephonyTest { null, null, -1, "", "", 0, ApnSetting.TYPE_DUN, ApnSetting.PROTOCOL_IP, ApnSetting.PROTOCOL_IP, true, 0, 0, false, 0, 0, 0, 0, -1, ""); DataProfile dataProfile = DcTracker.createDataProfile( apnSetting, apnSetting.getProfileId()); apnSetting, apnSetting.getProfileId(), false); boolean isRoaming = false; mRILUnderTest.setInitialAttachApn(dataProfile, isRoaming, obtainMessage()); Loading @@ -715,7 +715,7 @@ public class RILTest extends TelephonyTest { "convertToHalDataProfile", new Class<?>[] {DataProfile.class}, new Object[] {dataProfile})), eq(dataProfile.isModemCognitive()), eq(dataProfile.isPersistent()), eq(isRoaming)); verifyRILResponse( mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SET_INITIAL_ATTACH_APN); Loading Loading @@ -1727,7 +1727,7 @@ public class RILTest extends TelephonyTest { DataProfile dp = new DataProfile(PROFILE_ID, APN, PROTOCOL, AUTH_TYPE, USER_NAME, PASSWORD, TYPE, MAX_CONNS_TIME, MAX_CONNS, WAIT_TIME, APN_ENABLED, SUPPORTED_APNT_YPES_BITMAP, ROAMING_PROTOCOL, BEARER_BITMAP, MTU, MVNO_TYPE, MVNO_MATCH_DATA, MODEM_COGNITIVE); ROAMING_PROTOCOL, BEARER_BITMAP, MTU, PERSISTENT, false); mRILUnderTest.setupDataCall(AccessNetworkConstants.AccessNetworkType.EUTRAN, dp, false, false, 0, null, obtainMessage()); ArgumentCaptor<DataProfileInfo> dpiCaptor = ArgumentCaptor.forClass(DataProfileInfo.class); Loading @@ -1752,7 +1752,5 @@ public class RILTest extends TelephonyTest { assertEquals(ROAMING_PROTOCOL, dpi.protocol); assertEquals(BEARER_BITMAP, dpi.bearerBitmap); assertEquals(MTU, dpi.mtu); assertEquals(0, dpi.mvnoType); assertEquals(MVNO_MATCH_DATA, dpi.mvnoMatchData); } } tests/telephonytests/src/com/android/internal/telephony/dataconnection/ApnSettingTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -120,7 +120,7 @@ public class ApnSettingTest extends TelephonyTest { assertEquals(a1.getApnTypeBitmask(), a2.getApnTypeBitmask()); assertEquals(a1.isEnabled(), a2.isEnabled()); assertEquals(a1.getProfileId(), a2.getProfileId()); assertEquals(a1.getModemCognitive(), a2.getModemCognitive()); assertEquals(a1.isPersistent(), a2.isPersistent()); assertEquals(a1.getMaxConns(), a2.getMaxConns()); assertEquals(a1.getWaitTime(), a2.getWaitTime()); assertEquals(a1.getMaxConnsTime(), a2.getMaxConnsTime()); Loading Loading
src/java/com/android/internal/telephony/RIL.java +184 −70 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ import android.hardware.radio.V1_0.CellInfoLte; import android.hardware.radio.V1_0.CellInfoTdscdma; import android.hardware.radio.V1_0.CellInfoType; import android.hardware.radio.V1_0.CellInfoWcdma; import android.hardware.radio.V1_0.DataProfileInfo; import android.hardware.radio.V1_0.DataProfileId; import android.hardware.radio.V1_0.Dial; import android.hardware.radio.V1_0.GsmBroadcastSmsConfigInfo; import android.hardware.radio.V1_0.GsmSmsMessage; Loading Loading @@ -1156,12 +1156,14 @@ public class RIL extends BaseCommands implements CommandsInterface { } /** * Convert to DataProfileInfo defined in types.hal * Convert to DataProfileInfo defined in radio/1.0/types.hal * @param dp Data profile * @return A converted data profile */ private static DataProfileInfo convertToHalDataProfile(DataProfile dp) { DataProfileInfo dpi = new DataProfileInfo(); private static android.hardware.radio.V1_0.DataProfileInfo convertToHalDataProfile10( DataProfile dp) { android.hardware.radio.V1_0.DataProfileInfo dpi = new android.hardware.radio.V1_0.DataProfileInfo(); dpi.profileId = dp.getProfileId(); dpi.apn = dp.getApn(); Loading @@ -1178,8 +1180,41 @@ public class RIL extends BaseCommands implements CommandsInterface { dpi.supportedApnTypesBitmap = dp.getSupportedApnTypesBitmap(); dpi.bearerBitmap = dp.getBearerBitmap(); dpi.mtu = dp.getMtu(); dpi.mvnoType = convertToHalMvnoType(dp.getMvnoType()); dpi.mvnoMatchData = dp.getMvnoMatchData(); dpi.mvnoType = MvnoType.NONE; dpi.mvnoMatchData = ""; return dpi; } /** * Convert to DataProfileInfo defined in radio/1.3/types.hal * @param dp Data profile * @return A converted data profile */ private static android.hardware.radio.V1_3.DataProfileInfo convertToHalDataProfile13( DataProfile dp) { android.hardware.radio.V1_3.DataProfileInfo dpi = new android.hardware.radio.V1_3.DataProfileInfo(); dpi.apn = dp.getApn(); dpi.protocol = dp.getProtocol(); dpi.roamingProtocol = dp.getRoamingProtocol(); dpi.authType = dp.getAuthType(); dpi.user = dp.getUserName(); dpi.password = dp.getPassword(); dpi.type = dp.getType(); dpi.maxConnsTime = dp.getMaxConnsTime(); dpi.maxConns = dp.getMaxConns(); dpi.waitTime = dp.getWaitTime(); dpi.enabled = dp.isEnabled(); dpi.supportedApnTypesBitmap = dp.getSupportedApnTypesBitmap(); dpi.bearerBitmap = dp.getBearerBitmap(); dpi.mtu = dp.getMtu(); dpi.persistent = dp.isPersistent(); dpi.preferred = dp.isPreferred(); // profile id is only meaningful when it's persistent on the modem. dpi.profileId = (dpi.persistent) ? dp.getProfileId() : DataProfileId.INVALID; return dpi; } Loading Loading @@ -1209,44 +1244,16 @@ public class RIL extends BaseCommands implements CommandsInterface { boolean allowRoaming, int reason, LinkProperties linkProperties, Message result) { IRadio radioProxy = getRadioProxy(result); IRadio radioProxy10 = getRadioProxy(result); if (radioProxy != null) { if (radioProxy10 != null) { RILRequest rr = obtainRequest(RIL_REQUEST_SETUP_DATA_CALL, result, mRILDefaultWorkSource); // Convert to HAL data profile DataProfileInfo dpi = convertToHalDataProfile(dataProfile); android.hardware.radio.V1_2.IRadio radioProxy12 = android.hardware.radio.V1_2.IRadio.castFrom(radioProxy); try { if (radioProxy12 == null) { // IRadio V1.0 // Getting data RAT here is just a workaround to support the older 1.0 vendor // RIL. The new data service interface passes access network type instead of // RAT for setup data request. It is impossible to convert access network // type back to RAT here, so we directly get the data RAT from phone. int dataRat = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN; Phone phone = PhoneFactory.getPhone(mPhoneId); if (phone != null) { ServiceState ss = phone.getServiceState(); if (ss != null) { dataRat = ss.getRilDataRadioTechnology(); } } if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + ",dataRat=" + dataRat + ",isRoaming=" + isRoaming + ",allowRoaming=" + allowRoaming + "," + dataProfile); } android.hardware.radio.V1_3.IRadio radioProxy13 = android.hardware.radio.V1_3.IRadio.castFrom(radioProxy10); radioProxy.setupDataCall(rr.mSerial, dataRat, dpi, dataProfile.isModemCognitive(), allowRoaming, isRoaming); } else { // IRadio V1.2 ArrayList<String> addresses = new ArrayList<>(); ArrayList<String> dnses = new ArrayList<>(); if (linkProperties != null) { Loading @@ -1258,6 +1265,16 @@ public class RIL extends BaseCommands implements CommandsInterface { } } try { // Note that we should always try the highest version first. If the vendor IRadio // is v1.3, both radioProxy13 and radioProxy12 will be non-null. if (radioProxy13 != null) { // IRadio V1.3 // Convert to HAL data profile android.hardware.radio.V1_3.DataProfileInfo dpi = convertToHalDataProfile13(dataProfile); if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + ",accessNetworkType=" + accessNetworkType + ",isRoaming=" Loading @@ -1265,9 +1282,57 @@ public class RIL extends BaseCommands implements CommandsInterface { + ",addresses=" + addresses + ",dnses=" + dnses); } radioProxy13.setupDataCall_1_3(rr.mSerial, accessNetworkType, dpi, allowRoaming, reason, addresses, dnses); } else { android.hardware.radio.V1_2.IRadio radioProxy12 = android.hardware.radio.V1_2.IRadio.castFrom(radioProxy10); if (radioProxy12 != null) { // IRadio V1.2 // Convert to HAL data profile android.hardware.radio.V1_0.DataProfileInfo dpi = convertToHalDataProfile10(dataProfile); if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + ",accessNetworkType=" + accessNetworkType + ",isRoaming=" + isRoaming + ",allowRoaming=" + allowRoaming + "," + dataProfile + ",addresses=" + addresses + ",dnses=" + dnses); } radioProxy12.setupDataCall_1_2(rr.mSerial, accessNetworkType, dpi, dataProfile.isModemCognitive(), allowRoaming, isRoaming, reason, dataProfile.isPersistent(), allowRoaming, isRoaming, reason, addresses, dnses); } else { // IRadio V1.0 and IRadio V1.1 // Convert to HAL data profile android.hardware.radio.V1_0.DataProfileInfo dpi = convertToHalDataProfile10(dataProfile); // Getting data RAT here is just a workaround to support the older 1.0 // vendor RIL. The new data service interface passes access network type // instead of RAT for setup data request. It is impossible to convert access // network type back to RAT here, so we directly get the data RAT from // phone. int dataRat = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN; Phone phone = PhoneFactory.getPhone(mPhoneId); if (phone != null) { ServiceState ss = phone.getServiceState(); if (ss != null) { dataRat = ss.getRilDataRadioTechnology(); } } if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + ",dataRat=" + dataRat + ",isRoaming=" + isRoaming + ",allowRoaming=" + allowRoaming + "," + dataProfile); } radioProxy10.setupDataCall(rr.mSerial, dataRat, dpi, dataProfile.isPersistent(), allowRoaming, isRoaming); } } } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setupDataCall", e); Loading Loading @@ -3029,8 +3094,8 @@ public class RIL extends BaseCommands implements CommandsInterface { @Override public void setInitialAttachApn(DataProfile dataProfile, boolean isRoaming, Message result) { IRadio radioProxy = getRadioProxy(result); if (radioProxy != null) { IRadio radioProxy10 = getRadioProxy(result); if (radioProxy10 != null) { RILRequest rr = obtainRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, result, mRILDefaultWorkSource); Loading @@ -3038,9 +3103,23 @@ public class RIL extends BaseCommands implements CommandsInterface { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + dataProfile); } android.hardware.radio.V1_3.IRadio radioProxy13 = android.hardware.radio.V1_3.IRadio.castFrom(radioProxy10); try { radioProxy.setInitialAttachApn(rr.mSerial, convertToHalDataProfile(dataProfile), dataProfile.isModemCognitive(), isRoaming); // Note that we should always try the highest version first. If the vendor IRadio // is v1.3, both radioProxy13 and radioProxy10 will be non-null. if (radioProxy13 != null) { // v1.3 radioProxy13.setInitialAttachApn_1_3(rr.mSerial, convertToHalDataProfile13(dataProfile)); } else { // v1.2, v1.1, and v1.0 radioProxy10.setInitialAttachApn(rr.mSerial, convertToHalDataProfile10(dataProfile), dataProfile.isPersistent(), isRoaming); } } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setInitialAttachApn", e); } Loading Loading @@ -3424,11 +3503,25 @@ public class RIL extends BaseCommands implements CommandsInterface { @Override public void setDataProfile(DataProfile[] dps, boolean isRoaming, Message result) { IRadio radioProxy = getRadioProxy(result); if (radioProxy != null) { RILRequest rr = obtainRequest(RIL_REQUEST_SET_DATA_PROFILE, result, IRadio radioProxy10 = getRadioProxy(result); if (radioProxy10 != null) { android.hardware.radio.V1_3.IRadio radioProxy13 = android.hardware.radio.V1_3.IRadio.castFrom(radioProxy10); RILRequest rr = null; try { // Note that we should always try the highest version first. If the vendor IRadio // is v1.3, both radioProxy13 and radioProxy10 will be non-null. if (radioProxy13 != null) { // V1.3 rr = obtainRequest(RIL_REQUEST_SET_DATA_PROFILE, result, mRILDefaultWorkSource); ArrayList<android.hardware.radio.V1_3.DataProfileInfo> dpis = new ArrayList<>(); for (DataProfile dp : dps) { dpis.add(convertToHalDataProfile13(dp)); } if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " with data profiles : "); Loading @@ -3437,13 +3530,34 @@ public class RIL extends BaseCommands implements CommandsInterface { } } ArrayList<DataProfileInfo> dpis = new ArrayList<>(); radioProxy13.setDataProfile_1_3(rr.mSerial, dpis); } else { // V1.0, 1.1, and 1.2 ArrayList<android.hardware.radio.V1_0.DataProfileInfo> dpis = new ArrayList<>(); for (DataProfile dp : dps) { dpis.add(convertToHalDataProfile(dp)); // For v1.0 to v1.2, we only send data profiles that has the persistent // (a.k.a modem cognitive) bit set to true. if (dp.isPersistent()) { dpis.add(convertToHalDataProfile10(dp)); } } try { radioProxy.setDataProfile(rr.mSerial, dpis, isRoaming); if (!dpis.isEmpty()) { rr = obtainRequest(RIL_REQUEST_SET_DATA_PROFILE, result, mRILDefaultWorkSource); if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " with data profiles : "); for (DataProfile profile : dps) { riljLog(profile.toString()); } } radioProxy10.setDataProfile(rr.mSerial, dpis, isRoaming); } } } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setDataProfile", e); } Loading
src/java/com/android/internal/telephony/dataconnection/DataConnection.java +2 −1 Original line number Diff line number Diff line Loading @@ -535,7 +535,8 @@ public class DataConnection extends StateMachine { Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp); msg.obj = cp; DataProfile dp = DcTracker.createDataProfile(mApnSetting, cp.mProfileId); DataProfile dp = DcTracker.createDataProfile(mApnSetting, cp.mProfileId, mApnSetting.equals(mDct.getPreferredApn())); // We need to use the actual modem roaming state instead of the framework roaming state // here. This flag is only passed down to ril_service for picking the correct protocol (for Loading
src/java/com/android/internal/telephony/dataconnection/DcTracker.java +38 −38 Original line number Diff line number Diff line Loading @@ -18,6 +18,9 @@ package com.android.internal.telephony.dataconnection; import static android.Manifest.permission.READ_PHONE_STATE; import static com.android.internal.telephony.RILConstants.DATA_PROFILE_DEFAULT; import static com.android.internal.telephony.RILConstants.DATA_PROFILE_INVALID; import android.annotation.NonNull; import android.app.AlarmManager; import android.app.PendingIntent; Loading Loading @@ -536,19 +539,7 @@ public class DcTracker extends Handler { private int mDisconnectPendingCount = 0; /** Indicate if metered APNs are disabled. * set to block all the metered APNs from continuously sending requests, which causes * undesired network load */ private boolean mMeteredApnDisabled = false; /** * int to remember whether has setDataProfiles and with roaming or not. * 0: default, has never set data profile * 1: has set data profile with home protocol * 2: has set data profile with roaming protocol * This is not needed once RIL command is updated to support both home and roaming protocol. */ private int mSetDataProfileStatus = 0; private ArrayList<DataProfile> mLastDataProfileList = new ArrayList<>(); /** * Handles changes to the APN db. Loading Loading @@ -1919,10 +1910,14 @@ public class DcTracker extends Handler { return false; } int profileId = apnSetting.getProfileId(); if (profileId == 0) { // profile id is only meaningful when the profile is persistent on the modem. int profileId = DATA_PROFILE_INVALID; if (apnSetting.isPersistent()) { profileId = apnSetting.getProfileId(); if (profileId == DATA_PROFILE_DEFAULT) { profileId = getApnProfileID(apnContext.getApnType()); } } // On CDMA, if we're explicitly asking for DUN, we need have // a dun-profiled connection so we can't share an existing one Loading Loading @@ -2053,7 +2048,8 @@ public class DcTracker extends Handler { } else { if (DBG) log("setInitialAttachApn: X selected Apn=" + initialAttachApnSetting); mDataServiceManager.setInitialAttachApn(createDataProfile(initialAttachApnSetting), mDataServiceManager.setInitialAttachApn(createDataProfile(initialAttachApnSetting, initialAttachApnSetting.equals(getPreferredApn())), mPhone.getServiceState().getDataRoamingFromRegistration(), null); } } Loading Loading @@ -3218,17 +3214,22 @@ public class DcTracker extends Handler { private void setDataProfilesAsNeeded() { if (DBG) log("setDataProfilesAsNeeded"); ArrayList<DataProfile> dps = new ArrayList<DataProfile>(); ArrayList<DataProfile> dataProfileList = new ArrayList<>(); for (ApnSetting apn : mAllApnSettings) { if (apn.getModemCognitive()) { DataProfile dp = createDataProfile(apn); if (!dps.contains(dp)) { dps.add(dp); DataProfile dp = createDataProfile(apn, apn.equals(getPreferredApn())); if (!dataProfileList.contains(dp)) { dataProfileList.add(dp); } } } if (dps.size() > 0) { mDataServiceManager.setDataProfile(dps, // Check if the data profiles we are sending are same as we did last time. We don't want to // send the redundant profiles to the modem. Also if there the list is empty, we don't // send it to the modem. if (!dataProfileList.isEmpty() && (dataProfileList.size() != mLastDataProfileList.size() || !mLastDataProfileList.containsAll(dataProfileList))) { mDataServiceManager.setDataProfile(dataProfileList, mPhone.getServiceState().getDataRoamingFromRegistration(), null); } } Loading Loading @@ -3339,7 +3340,7 @@ public class DcTracker extends Handler { dest.getApnName(), proxy, port, mmsc, mmsProxy, mmsPort, dest.getUser(), dest.getPassword(), dest.getAuthType(), resultApnType, protocol, roamingProtocol, dest.isEnabled(), networkTypeBitmask, dest.getProfileId(), (dest.getModemCognitive() || src.getModemCognitive()), dest.getMaxConns(), (dest.isPersistent() || src.isPersistent()), dest.getMaxConns(), dest.getWaitTime(), dest.getMaxConnsTime(), dest.getMtu(), dest.getMvnoType(), dest.getMvnoMatchData(), dest.getApnSetId()); } Loading Loading @@ -3527,7 +3528,7 @@ public class DcTracker extends Handler { } } private ApnSetting getPreferredApn() { ApnSetting getPreferredApn() { if (mAllApnSettings == null || mAllApnSettings.isEmpty()) { log("getPreferredApn: mAllApnSettings is empty"); return null; Loading Loading @@ -4755,16 +4756,16 @@ public class DcTracker extends Handler { } } private static DataProfile createDataProfile(ApnSetting apn) { return createDataProfile(apn, apn.getProfileId()); private static DataProfile createDataProfile(ApnSetting apn, boolean isPreferred) { return createDataProfile(apn, apn.getProfileId(), isPreferred); } @VisibleForTesting public static DataProfile createDataProfile(ApnSetting apn, int profileId) { public static DataProfile createDataProfile(ApnSetting apn, int profileId, boolean isPreferred) { int profileType; int bearerBitmap = 0; bearerBitmap = ServiceState.convertNetworkTypeBitmaskToBearerBitmask( int bearerBitmap = ServiceState.convertNetworkTypeBitmaskToBearerBitmask( apn.getNetworkTypeBitmask()); if (bearerBitmap == 0) { Loading @@ -4780,8 +4781,7 @@ public class DcTracker extends Handler { apn.getUser(), apn.getPassword(), profileType, apn.getMaxConnsTime(), apn.getMaxConns(), apn.getWaitTime(), apn.isEnabled(), apn.getApnTypeBitmask(), ApnSetting.getProtocolStringFromInt(apn.getRoamingProtocol()), bearerBitmap, apn.getMtu(), ApnSetting.getMvnoTypeStringFromInt(apn.getMvnoType()), apn.getMvnoMatchData(), apn.getModemCognitive()); apn.getMtu(), apn.isPersistent(), isPreferred); } private void onDataServiceBindingChanged(boolean bound) { Loading
tests/telephonytests/src/com/android/internal/telephony/RILTest.java +4 −6 Original line number Diff line number Diff line Loading @@ -229,7 +229,7 @@ public class RILTest extends TelephonyTest { private static final int MTU = 1234; private static final String MVNO_TYPE = ""; private static final String MVNO_MATCH_DATA = ""; private static final boolean MODEM_COGNITIVE = true; private static final boolean PERSISTENT = true; private class RILTestHandler extends HandlerThread { Loading Loading @@ -704,7 +704,7 @@ public class RILTest extends TelephonyTest { null, null, -1, "", "", 0, ApnSetting.TYPE_DUN, ApnSetting.PROTOCOL_IP, ApnSetting.PROTOCOL_IP, true, 0, 0, false, 0, 0, 0, 0, -1, ""); DataProfile dataProfile = DcTracker.createDataProfile( apnSetting, apnSetting.getProfileId()); apnSetting, apnSetting.getProfileId(), false); boolean isRoaming = false; mRILUnderTest.setInitialAttachApn(dataProfile, isRoaming, obtainMessage()); Loading @@ -715,7 +715,7 @@ public class RILTest extends TelephonyTest { "convertToHalDataProfile", new Class<?>[] {DataProfile.class}, new Object[] {dataProfile})), eq(dataProfile.isModemCognitive()), eq(dataProfile.isPersistent()), eq(isRoaming)); verifyRILResponse( mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SET_INITIAL_ATTACH_APN); Loading Loading @@ -1727,7 +1727,7 @@ public class RILTest extends TelephonyTest { DataProfile dp = new DataProfile(PROFILE_ID, APN, PROTOCOL, AUTH_TYPE, USER_NAME, PASSWORD, TYPE, MAX_CONNS_TIME, MAX_CONNS, WAIT_TIME, APN_ENABLED, SUPPORTED_APNT_YPES_BITMAP, ROAMING_PROTOCOL, BEARER_BITMAP, MTU, MVNO_TYPE, MVNO_MATCH_DATA, MODEM_COGNITIVE); ROAMING_PROTOCOL, BEARER_BITMAP, MTU, PERSISTENT, false); mRILUnderTest.setupDataCall(AccessNetworkConstants.AccessNetworkType.EUTRAN, dp, false, false, 0, null, obtainMessage()); ArgumentCaptor<DataProfileInfo> dpiCaptor = ArgumentCaptor.forClass(DataProfileInfo.class); Loading @@ -1752,7 +1752,5 @@ public class RILTest extends TelephonyTest { assertEquals(ROAMING_PROTOCOL, dpi.protocol); assertEquals(BEARER_BITMAP, dpi.bearerBitmap); assertEquals(MTU, dpi.mtu); assertEquals(0, dpi.mvnoType); assertEquals(MVNO_MATCH_DATA, dpi.mvnoMatchData); } }
tests/telephonytests/src/com/android/internal/telephony/dataconnection/ApnSettingTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -120,7 +120,7 @@ public class ApnSettingTest extends TelephonyTest { assertEquals(a1.getApnTypeBitmask(), a2.getApnTypeBitmask()); assertEquals(a1.isEnabled(), a2.isEnabled()); assertEquals(a1.getProfileId(), a2.getProfileId()); assertEquals(a1.getModemCognitive(), a2.getModemCognitive()); assertEquals(a1.isPersistent(), a2.isPersistent()); assertEquals(a1.getMaxConns(), a2.getMaxConns()); assertEquals(a1.getWaitTime(), a2.getWaitTime()); assertEquals(a1.getMaxConnsTime(), a2.getMaxConnsTime()); Loading