Loading src/java/com/android/internal/telephony/dataconnection/DcTracker.java +37 −72 Original line number Diff line number Diff line Loading @@ -132,6 +132,7 @@ import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; Loading Loading @@ -2123,88 +2124,52 @@ public class DcTracker extends Handler { return true; } protected void setInitialAttachApn() { ApnSetting iaApnSetting = null; ApnSetting defaultApnSetting = null; ApnSetting firstNonEmergencyApnSetting = null; log("setInitialApn: E mPreferredApn=" + mPreferredApn); if (mPreferredApn != null && mPreferredApn.canHandleType(ApnSetting.TYPE_IA)) { iaApnSetting = mPreferredApn; } else if (!mAllApnSettings.isEmpty()) { // Search for Initial APN setting and the first apn that can handle default int preferredApnSetId = getPreferredApnSetId(); for (ApnSetting apn : mAllApnSettings) { if (preferredApnSetId != apn.getApnSetId()) { if (VDBG) { log("setInitialApn: APN set id " + apn.getApnSetId() + " does not match the preferred set id " + preferredApnSetId); } continue; // Get the allowed APN types for initial attach. The order in the returned list represent // the order of APN types that should be used for initial attach. private @NonNull @ApnType List<Integer> getAllowedInitialAttachApnTypes() { PersistableBundle bundle = getCarrierConfig(); if (bundle != null) { String[] apnTypesArray = bundle.getStringArray( CarrierConfigManager.KEY_ALLOWED_INITIAL_ATTACH_APN_TYPES_STRING_ARRAY); if (apnTypesArray != null) { return Arrays.stream(apnTypesArray) .map(ApnSetting::getApnTypesBitmaskFromString) .collect(Collectors.toList()); } if (firstNonEmergencyApnSetting == null && !apn.isEmergencyApn()) { firstNonEmergencyApnSetting = apn; log("setInitialApn: firstNonEmergencyApnSetting=" + firstNonEmergencyApnSetting); } if (apn.canHandleType(ApnSetting.TYPE_IA)) { // The Initial Attach APN is highest priority so use it if there is one log("setInitialApn: iaApnSetting=" + apn); iaApnSetting = apn; break; } else if ((defaultApnSetting == null) && (apn.canHandleType(ApnSetting.TYPE_DEFAULT))) { // Use the first default apn if no better choice log("setInitialApn: defaultApnSetting=" + apn); defaultApnSetting = apn; } return Collections.emptyList(); } protected void setInitialAttachApn() { ApnSetting apnSetting = null; // Get the allowed APN types for initial attach. Note that if none of the APNs has the // allowed APN types, then the initial attach will not be performed. List<Integer> allowedApnTypes = getAllowedInitialAttachApnTypes(); for (int allowedApnType : allowedApnTypes) { apnSetting = mAllApnSettings.stream() .filter(apn -> apn.canHandleType(allowedApnType)) .findFirst() .orElse(null); if (apnSetting != null) break; } if ((iaApnSetting == null) && (defaultApnSetting == null) && !allowInitialAttachForOperator()) { log("Abort Initial attach"); return; if (DBG) { log("setInitialAttachApn: Allowed APN types=" + allowedApnTypes.stream() .map(ApnSetting::getApnTypeString) .collect(Collectors.joining(","))); } // The priority of apn candidates from highest to lowest is: // 1) APN_TYPE_IA (Initial Attach) // 2) mPreferredApn, i.e. the current preferred apn // 3) The first apn that than handle APN_TYPE_DEFAULT // 4) The first APN we can find. ApnSetting initialAttachApnSetting = null; if (iaApnSetting != null) { if (DBG) log("setInitialAttachApn: using iaApnSetting"); initialAttachApnSetting = iaApnSetting; } else if (mPreferredApn != null) { if (DBG) log("setInitialAttachApn: using mPreferredApn"); initialAttachApnSetting = mPreferredApn; } else if (defaultApnSetting != null) { if (DBG) log("setInitialAttachApn: using defaultApnSetting"); initialAttachApnSetting = defaultApnSetting; } else if (firstNonEmergencyApnSetting != null) { if (DBG) log("setInitialAttachApn: using firstNonEmergencyApnSetting"); initialAttachApnSetting = firstNonEmergencyApnSetting; } if (initialAttachApnSetting == null) { if (DBG) log("setInitialAttachApn: X There in no available apn"); if (apnSetting == null) { if (DBG) log("setInitialAttachApn: X There in no available apn."); } else { if (DBG) log("setInitialAttachApn: X selected Apn=" + initialAttachApnSetting); mDataServiceManager.setInitialAttachApn(createDataProfile(initialAttachApnSetting, initialAttachApnSetting.equals(getPreferredApn())), if (DBG) log("setInitialAttachApn: X selected APN=" + apnSetting); mDataServiceManager.setInitialAttachApn(createDataProfile(apnSetting, apnSetting.equals(getPreferredApn())), mPhone.getServiceState().getDataRoamingFromRegistration(), null); } } protected boolean allowInitialAttachForOperator() { return true; } /** * Handles changes to the APN database. */ Loading src/java/com/android/internal/telephony/vendor/dataconnection/VendorDcTracker.java +0 −32 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import com.android.internal.telephony.dataconnection.ApnContext; import com.android.internal.telephony.dataconnection.DcTracker; import java.util.HashSet; import java.util.Iterator; public class VendorDcTracker extends DcTracker { private String LOG_TAG = "VendorDCT"; Loading Loading @@ -64,37 +63,6 @@ public class VendorDcTracker extends DcTracker { LOG_TAG = LOG_TAG + "-" + ((transportType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) ? "C" : "I"); if (DBG) log(LOG_TAG + ".constructor"); fillIccIdSet(); } @Override protected boolean allowInitialAttachForOperator() { String iccId = mPhone.getIccSerialNumber(); if (iccId != null) { Iterator<String> itr = mIccidSet.iterator(); while (itr.hasNext()) { if (iccId.contains(itr.next())) { return false; } } } return true; } private void fillIccIdSet() { mIccidSet.add("8991840"); mIccidSet.add("8991854"); mIccidSet.add("8991855"); mIccidSet.add("8991856"); mIccidSet.add("8991857"); mIccidSet.add("8991858"); mIccidSet.add("8991859"); mIccidSet.add("899186"); mIccidSet.add("8991870"); mIccidSet.add("8991871"); mIccidSet.add("8991872"); mIccidSet.add("8991873"); mIccidSet.add("8991874"); } @Override Loading Loading
src/java/com/android/internal/telephony/dataconnection/DcTracker.java +37 −72 Original line number Diff line number Diff line Loading @@ -132,6 +132,7 @@ import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; Loading Loading @@ -2123,88 +2124,52 @@ public class DcTracker extends Handler { return true; } protected void setInitialAttachApn() { ApnSetting iaApnSetting = null; ApnSetting defaultApnSetting = null; ApnSetting firstNonEmergencyApnSetting = null; log("setInitialApn: E mPreferredApn=" + mPreferredApn); if (mPreferredApn != null && mPreferredApn.canHandleType(ApnSetting.TYPE_IA)) { iaApnSetting = mPreferredApn; } else if (!mAllApnSettings.isEmpty()) { // Search for Initial APN setting and the first apn that can handle default int preferredApnSetId = getPreferredApnSetId(); for (ApnSetting apn : mAllApnSettings) { if (preferredApnSetId != apn.getApnSetId()) { if (VDBG) { log("setInitialApn: APN set id " + apn.getApnSetId() + " does not match the preferred set id " + preferredApnSetId); } continue; // Get the allowed APN types for initial attach. The order in the returned list represent // the order of APN types that should be used for initial attach. private @NonNull @ApnType List<Integer> getAllowedInitialAttachApnTypes() { PersistableBundle bundle = getCarrierConfig(); if (bundle != null) { String[] apnTypesArray = bundle.getStringArray( CarrierConfigManager.KEY_ALLOWED_INITIAL_ATTACH_APN_TYPES_STRING_ARRAY); if (apnTypesArray != null) { return Arrays.stream(apnTypesArray) .map(ApnSetting::getApnTypesBitmaskFromString) .collect(Collectors.toList()); } if (firstNonEmergencyApnSetting == null && !apn.isEmergencyApn()) { firstNonEmergencyApnSetting = apn; log("setInitialApn: firstNonEmergencyApnSetting=" + firstNonEmergencyApnSetting); } if (apn.canHandleType(ApnSetting.TYPE_IA)) { // The Initial Attach APN is highest priority so use it if there is one log("setInitialApn: iaApnSetting=" + apn); iaApnSetting = apn; break; } else if ((defaultApnSetting == null) && (apn.canHandleType(ApnSetting.TYPE_DEFAULT))) { // Use the first default apn if no better choice log("setInitialApn: defaultApnSetting=" + apn); defaultApnSetting = apn; } return Collections.emptyList(); } protected void setInitialAttachApn() { ApnSetting apnSetting = null; // Get the allowed APN types for initial attach. Note that if none of the APNs has the // allowed APN types, then the initial attach will not be performed. List<Integer> allowedApnTypes = getAllowedInitialAttachApnTypes(); for (int allowedApnType : allowedApnTypes) { apnSetting = mAllApnSettings.stream() .filter(apn -> apn.canHandleType(allowedApnType)) .findFirst() .orElse(null); if (apnSetting != null) break; } if ((iaApnSetting == null) && (defaultApnSetting == null) && !allowInitialAttachForOperator()) { log("Abort Initial attach"); return; if (DBG) { log("setInitialAttachApn: Allowed APN types=" + allowedApnTypes.stream() .map(ApnSetting::getApnTypeString) .collect(Collectors.joining(","))); } // The priority of apn candidates from highest to lowest is: // 1) APN_TYPE_IA (Initial Attach) // 2) mPreferredApn, i.e. the current preferred apn // 3) The first apn that than handle APN_TYPE_DEFAULT // 4) The first APN we can find. ApnSetting initialAttachApnSetting = null; if (iaApnSetting != null) { if (DBG) log("setInitialAttachApn: using iaApnSetting"); initialAttachApnSetting = iaApnSetting; } else if (mPreferredApn != null) { if (DBG) log("setInitialAttachApn: using mPreferredApn"); initialAttachApnSetting = mPreferredApn; } else if (defaultApnSetting != null) { if (DBG) log("setInitialAttachApn: using defaultApnSetting"); initialAttachApnSetting = defaultApnSetting; } else if (firstNonEmergencyApnSetting != null) { if (DBG) log("setInitialAttachApn: using firstNonEmergencyApnSetting"); initialAttachApnSetting = firstNonEmergencyApnSetting; } if (initialAttachApnSetting == null) { if (DBG) log("setInitialAttachApn: X There in no available apn"); if (apnSetting == null) { if (DBG) log("setInitialAttachApn: X There in no available apn."); } else { if (DBG) log("setInitialAttachApn: X selected Apn=" + initialAttachApnSetting); mDataServiceManager.setInitialAttachApn(createDataProfile(initialAttachApnSetting, initialAttachApnSetting.equals(getPreferredApn())), if (DBG) log("setInitialAttachApn: X selected APN=" + apnSetting); mDataServiceManager.setInitialAttachApn(createDataProfile(apnSetting, apnSetting.equals(getPreferredApn())), mPhone.getServiceState().getDataRoamingFromRegistration(), null); } } protected boolean allowInitialAttachForOperator() { return true; } /** * Handles changes to the APN database. */ Loading
src/java/com/android/internal/telephony/vendor/dataconnection/VendorDcTracker.java +0 −32 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import com.android.internal.telephony.dataconnection.ApnContext; import com.android.internal.telephony.dataconnection.DcTracker; import java.util.HashSet; import java.util.Iterator; public class VendorDcTracker extends DcTracker { private String LOG_TAG = "VendorDCT"; Loading Loading @@ -64,37 +63,6 @@ public class VendorDcTracker extends DcTracker { LOG_TAG = LOG_TAG + "-" + ((transportType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) ? "C" : "I"); if (DBG) log(LOG_TAG + ".constructor"); fillIccIdSet(); } @Override protected boolean allowInitialAttachForOperator() { String iccId = mPhone.getIccSerialNumber(); if (iccId != null) { Iterator<String> itr = mIccidSet.iterator(); while (itr.hasNext()) { if (iccId.contains(itr.next())) { return false; } } } return true; } private void fillIccIdSet() { mIccidSet.add("8991840"); mIccidSet.add("8991854"); mIccidSet.add("8991855"); mIccidSet.add("8991856"); mIccidSet.add("8991857"); mIccidSet.add("8991858"); mIccidSet.add("8991859"); mIccidSet.add("899186"); mIccidSet.add("8991870"); mIccidSet.add("8991871"); mIccidSet.add("8991872"); mIccidSet.add("8991873"); mIccidSet.add("8991874"); } @Override Loading