Loading src/java/com/android/internal/telephony/NetworkIndication.java +5 −5 Original line number Diff line number Diff line Loading @@ -258,13 +258,13 @@ public class NetworkIndication extends IRadioNetworkIndication.Stub { if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_NITZ_TIME_RECEIVED, nitzTime); // Ignore the NITZ if ageMs is not a valid time, e.g. negative or greater than // receivedTimeMs. if ((ageMs < 0) || (ageMs >= receivedTimeMs)) { // Ignore the NITZ if receivedTimeMs or ageMs is not a valid time. // e.g. receivedTimeMs is non-positive, ageMs is negative or greater than receivedTimeMs. if ((receivedTimeMs <= 0) || (ageMs < 0) || (ageMs >= receivedTimeMs)) { AnomalyReporter.reportAnomaly(UUID.fromString("fc7c56d4-485d-475a-aaff-394203c6cdfc"), "NITZ indication with invalid age"); "NITZ indication with invalid parameter"); mRil.riljLoge("age time is invalid, ignoring nitzTimeReceived indication. " mRil.riljLoge("NITZ parameter is invalid, ignoring nitzTimeReceived indication. " + "receivedTimeMs = " + receivedTimeMs + ", ageMs = " + ageMs); return; } Loading src/java/com/android/internal/telephony/data/DataNetwork.java +3 −0 Original line number Diff line number Diff line Loading @@ -1737,6 +1737,9 @@ public class DataNetwork extends StateMachine { .map(DataUtils::apnTypeToNetworkCapability) .filter(cap -> cap >= 0) .forEach(builder::addCapability); if (apnSetting.getApnTypes().contains(ApnSetting.TYPE_ENTERPRISE)) { builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); } } // If voice call is on-going, do not change MMTEL capability, which is an immutable Loading src/java/com/android/internal/telephony/data/DataProfileManager.java +45 −2 Original line number Diff line number Diff line Loading @@ -198,6 +198,36 @@ public class DataProfileManager extends Handler { //TODO: more works needed to be done here. } /** * Check if there are any Enterprise APN configured by DPC and return a data profile * with the same. * @return data profile with enterprise ApnSetting if available, else null */ @Nullable private DataProfile getEnterpriseDataProfile() { Cursor cursor = mPhone.getContext().getContentResolver().query( Telephony.Carriers.DPC_URI, null, null, null, null); if (cursor == null) { loge("Cannot access APN database through telephony provider."); return null; } DataProfile dataProfile = null; while (cursor.moveToNext()) { ApnSetting apn = ApnSetting.makeApnSetting(cursor); if (apn != null) { dataProfile = new DataProfile.Builder() .setApnSetting(apn) .setTrafficDescriptor(new TrafficDescriptor(apn.getApnName(), null)) .setPreferred(false) .build(); if (dataProfile.canSatisfy(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE)) { break; } } } cursor.close(); return dataProfile; } /** * Update all data profiles, including preferred data profile, and initial attach data profile. * Also send those profiles down to the modem if needed. Loading Loading @@ -228,6 +258,20 @@ public class DataProfileManager extends Handler { cursor.close(); } // Check if any of the profile already supports ENTERPRISE, if not, check if DPC has // configured one and retrieve the same. DataProfile dataProfile = profiles.stream() .filter(dp -> dp.canSatisfy(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE)) .findFirst() .orElse(null); if (dataProfile == null) { dataProfile = getEnterpriseDataProfile(); if (dataProfile != null) { profiles.add(dataProfile); log("Added enterprise profile " + dataProfile); } } // Check if any of the profile already supports IMS, if not, add the default one. DataProfile dataProfile = profiles.stream() .filter(dp -> dp.canSatisfy(NetworkCapabilities.NET_CAPABILITY_IMS)) Loading Loading @@ -565,8 +609,7 @@ public class DataProfileManager extends Handler { profileBuilder.setTrafficDescriptor(trafficDescriptor); DataProfile dataProfile = profileBuilder.build(); log("Added a new data profile " + dataProfile + " for " + networkRequest); mAllDataProfiles.add(dataProfile); log("Created data profile " + dataProfile + " for " + networkRequest); return dataProfile; } Loading src/java/com/android/internal/telephony/data/TelephonyNetworkRequest.java +12 −0 Original line number Diff line number Diff line Loading @@ -282,6 +282,18 @@ public class TelephonyNetworkRequest { .map(DataUtils::networkCapabilityToApnType) .filter(apnType -> apnType != ApnSetting.TYPE_NONE) .collect(Collectors.toList()); // In case of enterprise network request, the network request will have internet, // but APN type will not have default type as the enterprise apn should not be used // as default network. Ignore default type of the network request if it // has enterprise type as well. This will make sure the network request with // internet and enterprise will be satisfied with data profile with enterprise at the // same time default network request will not get satisfied with enterprise data // profile. // TODO b/232264746 if (apnTypes.contains(ApnSetting.TYPE_ENTERPRISE)) { apnTypes.remove((Integer) ApnSetting.TYPE_DEFAULT); } return apnTypes.stream().allMatch(dataProfile.getApnSetting()::canHandleType); } return false; Loading tests/telephonytests/src/com/android/internal/telephony/data/TelephonyNetworkRequestTest.java +51 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,23 @@ public class TelephonyNetworkRequestTest extends TelephonyTest { .setWaitTime(456) .setMaxConnsTime(789) .build(); private static final ApnSetting ENTERPRISE_APN_SETTING = new ApnSetting.Builder() .setId(2164) .setOperatorNumeric("12345") .setEntryName("enterprise") .setApnName("enterprise") .setUser("user") .setPassword("passwd") .setApnTypeBitmask(ApnSetting.TYPE_ENTERPRISE) .setProtocol(ApnSetting.PROTOCOL_IPV6) .setRoamingProtocol(ApnSetting.PROTOCOL_IP) .setCarrierEnabled(true) .setNetworkTypeBitmask(0) .setProfileId(1234) .setMaxConns(321) .setWaitTime(456) .setMaxConnsTime(789) .build(); @Before public void setUp() throws Exception { Loading Loading @@ -246,6 +263,40 @@ public class TelephonyNetworkRequestTest extends TelephonyTest { assertThat(enterpriseRequest2.canBeSatisfiedBy(enterpriseDataProfile2)).isTrue(); } @Test public void testCanBeSatisfiedByEnterpriseApnDataProfile() { TelephonyNetworkRequest enterpriseRequest1 = new TelephonyNetworkRequest( new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE) .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .build(), mPhone); TelephonyNetworkRequest enterpriseRequest2 = new TelephonyNetworkRequest( new NetworkRequest(new NetworkCapabilities() .addCapability(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE) .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .addEnterpriseId(2), ConnectivityManager.TYPE_NONE, 0, NetworkRequest.Type.REQUEST), mPhone); TelephonyNetworkRequest internetRequest = new TelephonyNetworkRequest( new NetworkRequest(new NetworkCapabilities() .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET), ConnectivityManager.TYPE_NONE, 0, NetworkRequest.Type.REQUEST), mPhone); DataProfile enterpriseDataProfile = new DataProfile.Builder() .setApnSetting(ENTERPRISE_APN_SETTING) .build(); DataProfile internetDataProfile = new DataProfile.Builder() .setApnSetting(INTERNET_APN_SETTING) .build(); assertThat(enterpriseRequest1.canBeSatisfiedBy(enterpriseDataProfile)).isTrue(); assertThat(enterpriseRequest1.canBeSatisfiedBy(internetDataProfile)).isFalse(); assertThat(enterpriseRequest2.canBeSatisfiedBy(enterpriseDataProfile)).isTrue(); assertThat(enterpriseRequest2.canBeSatisfiedBy(internetDataProfile)).isFalse(); assertThat(internetRequest.canBeSatisfiedBy(enterpriseDataProfile)).isFalse(); assertThat(internetRequest.canBeSatisfiedBy(internetDataProfile)).isTrue(); } @Test public void testCanBeSatisfiedByUrllcDataProfile() { TelephonyNetworkRequest urllcRequest = new TelephonyNetworkRequest( Loading Loading
src/java/com/android/internal/telephony/NetworkIndication.java +5 −5 Original line number Diff line number Diff line Loading @@ -258,13 +258,13 @@ public class NetworkIndication extends IRadioNetworkIndication.Stub { if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_NITZ_TIME_RECEIVED, nitzTime); // Ignore the NITZ if ageMs is not a valid time, e.g. negative or greater than // receivedTimeMs. if ((ageMs < 0) || (ageMs >= receivedTimeMs)) { // Ignore the NITZ if receivedTimeMs or ageMs is not a valid time. // e.g. receivedTimeMs is non-positive, ageMs is negative or greater than receivedTimeMs. if ((receivedTimeMs <= 0) || (ageMs < 0) || (ageMs >= receivedTimeMs)) { AnomalyReporter.reportAnomaly(UUID.fromString("fc7c56d4-485d-475a-aaff-394203c6cdfc"), "NITZ indication with invalid age"); "NITZ indication with invalid parameter"); mRil.riljLoge("age time is invalid, ignoring nitzTimeReceived indication. " mRil.riljLoge("NITZ parameter is invalid, ignoring nitzTimeReceived indication. " + "receivedTimeMs = " + receivedTimeMs + ", ageMs = " + ageMs); return; } Loading
src/java/com/android/internal/telephony/data/DataNetwork.java +3 −0 Original line number Diff line number Diff line Loading @@ -1737,6 +1737,9 @@ public class DataNetwork extends StateMachine { .map(DataUtils::apnTypeToNetworkCapability) .filter(cap -> cap >= 0) .forEach(builder::addCapability); if (apnSetting.getApnTypes().contains(ApnSetting.TYPE_ENTERPRISE)) { builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); } } // If voice call is on-going, do not change MMTEL capability, which is an immutable Loading
src/java/com/android/internal/telephony/data/DataProfileManager.java +45 −2 Original line number Diff line number Diff line Loading @@ -198,6 +198,36 @@ public class DataProfileManager extends Handler { //TODO: more works needed to be done here. } /** * Check if there are any Enterprise APN configured by DPC and return a data profile * with the same. * @return data profile with enterprise ApnSetting if available, else null */ @Nullable private DataProfile getEnterpriseDataProfile() { Cursor cursor = mPhone.getContext().getContentResolver().query( Telephony.Carriers.DPC_URI, null, null, null, null); if (cursor == null) { loge("Cannot access APN database through telephony provider."); return null; } DataProfile dataProfile = null; while (cursor.moveToNext()) { ApnSetting apn = ApnSetting.makeApnSetting(cursor); if (apn != null) { dataProfile = new DataProfile.Builder() .setApnSetting(apn) .setTrafficDescriptor(new TrafficDescriptor(apn.getApnName(), null)) .setPreferred(false) .build(); if (dataProfile.canSatisfy(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE)) { break; } } } cursor.close(); return dataProfile; } /** * Update all data profiles, including preferred data profile, and initial attach data profile. * Also send those profiles down to the modem if needed. Loading Loading @@ -228,6 +258,20 @@ public class DataProfileManager extends Handler { cursor.close(); } // Check if any of the profile already supports ENTERPRISE, if not, check if DPC has // configured one and retrieve the same. DataProfile dataProfile = profiles.stream() .filter(dp -> dp.canSatisfy(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE)) .findFirst() .orElse(null); if (dataProfile == null) { dataProfile = getEnterpriseDataProfile(); if (dataProfile != null) { profiles.add(dataProfile); log("Added enterprise profile " + dataProfile); } } // Check if any of the profile already supports IMS, if not, add the default one. DataProfile dataProfile = profiles.stream() .filter(dp -> dp.canSatisfy(NetworkCapabilities.NET_CAPABILITY_IMS)) Loading Loading @@ -565,8 +609,7 @@ public class DataProfileManager extends Handler { profileBuilder.setTrafficDescriptor(trafficDescriptor); DataProfile dataProfile = profileBuilder.build(); log("Added a new data profile " + dataProfile + " for " + networkRequest); mAllDataProfiles.add(dataProfile); log("Created data profile " + dataProfile + " for " + networkRequest); return dataProfile; } Loading
src/java/com/android/internal/telephony/data/TelephonyNetworkRequest.java +12 −0 Original line number Diff line number Diff line Loading @@ -282,6 +282,18 @@ public class TelephonyNetworkRequest { .map(DataUtils::networkCapabilityToApnType) .filter(apnType -> apnType != ApnSetting.TYPE_NONE) .collect(Collectors.toList()); // In case of enterprise network request, the network request will have internet, // but APN type will not have default type as the enterprise apn should not be used // as default network. Ignore default type of the network request if it // has enterprise type as well. This will make sure the network request with // internet and enterprise will be satisfied with data profile with enterprise at the // same time default network request will not get satisfied with enterprise data // profile. // TODO b/232264746 if (apnTypes.contains(ApnSetting.TYPE_ENTERPRISE)) { apnTypes.remove((Integer) ApnSetting.TYPE_DEFAULT); } return apnTypes.stream().allMatch(dataProfile.getApnSetting()::canHandleType); } return false; Loading
tests/telephonytests/src/com/android/internal/telephony/data/TelephonyNetworkRequestTest.java +51 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,23 @@ public class TelephonyNetworkRequestTest extends TelephonyTest { .setWaitTime(456) .setMaxConnsTime(789) .build(); private static final ApnSetting ENTERPRISE_APN_SETTING = new ApnSetting.Builder() .setId(2164) .setOperatorNumeric("12345") .setEntryName("enterprise") .setApnName("enterprise") .setUser("user") .setPassword("passwd") .setApnTypeBitmask(ApnSetting.TYPE_ENTERPRISE) .setProtocol(ApnSetting.PROTOCOL_IPV6) .setRoamingProtocol(ApnSetting.PROTOCOL_IP) .setCarrierEnabled(true) .setNetworkTypeBitmask(0) .setProfileId(1234) .setMaxConns(321) .setWaitTime(456) .setMaxConnsTime(789) .build(); @Before public void setUp() throws Exception { Loading Loading @@ -246,6 +263,40 @@ public class TelephonyNetworkRequestTest extends TelephonyTest { assertThat(enterpriseRequest2.canBeSatisfiedBy(enterpriseDataProfile2)).isTrue(); } @Test public void testCanBeSatisfiedByEnterpriseApnDataProfile() { TelephonyNetworkRequest enterpriseRequest1 = new TelephonyNetworkRequest( new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE) .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .build(), mPhone); TelephonyNetworkRequest enterpriseRequest2 = new TelephonyNetworkRequest( new NetworkRequest(new NetworkCapabilities() .addCapability(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE) .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .addEnterpriseId(2), ConnectivityManager.TYPE_NONE, 0, NetworkRequest.Type.REQUEST), mPhone); TelephonyNetworkRequest internetRequest = new TelephonyNetworkRequest( new NetworkRequest(new NetworkCapabilities() .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET), ConnectivityManager.TYPE_NONE, 0, NetworkRequest.Type.REQUEST), mPhone); DataProfile enterpriseDataProfile = new DataProfile.Builder() .setApnSetting(ENTERPRISE_APN_SETTING) .build(); DataProfile internetDataProfile = new DataProfile.Builder() .setApnSetting(INTERNET_APN_SETTING) .build(); assertThat(enterpriseRequest1.canBeSatisfiedBy(enterpriseDataProfile)).isTrue(); assertThat(enterpriseRequest1.canBeSatisfiedBy(internetDataProfile)).isFalse(); assertThat(enterpriseRequest2.canBeSatisfiedBy(enterpriseDataProfile)).isTrue(); assertThat(enterpriseRequest2.canBeSatisfiedBy(internetDataProfile)).isFalse(); assertThat(internetRequest.canBeSatisfiedBy(enterpriseDataProfile)).isFalse(); assertThat(internetRequest.canBeSatisfiedBy(internetDataProfile)).isTrue(); } @Test public void testCanBeSatisfiedByUrllcDataProfile() { TelephonyNetworkRequest urllcRequest = new TelephonyNetworkRequest( Loading