Merge "Fix preferred apn not selected when back from edit" into main
diff --git a/src/com/android/settings/network/apn/ApnSettings.java b/src/com/android/settings/network/apn/ApnSettings.java
index 5249eb2..2debba1 100644
--- a/src/com/android/settings/network/apn/ApnSettings.java
+++ b/src/com/android/settings/network/apn/ApnSettings.java
@@ -99,6 +99,8 @@
     private UserManager mUserManager;
     private int mSubId;
     private PreferredApnRepository mPreferredApnRepository;
+    @Nullable
+    private String mPreferredApnKey;
     private String mMvnoType;
     private String mMvnoMatchData;
 
@@ -175,6 +177,7 @@
                 });
 
         mPreferredApnRepository.collectPreferredApn(viewLifecycleOwner, (preferredApn) -> {
+            mPreferredApnKey = preferredApn;
             final PreferenceGroup apnPreferenceList = findPreference(APN_LIST);
             for (int i = 0; i < apnPreferenceList.getPreferenceCount(); i++) {
                 ApnPreference apnPreference = (ApnPreference) apnPreferenceList.getPreference(i);
@@ -259,6 +262,7 @@
                         ((type == null) || type.contains(ApnSetting.TYPE_DEFAULT_STRING));
                 pref.setDefaultSelectable(defaultSelectable);
                 if (defaultSelectable) {
+                    pref.setIsChecked(key.equals(mPreferredApnKey));
                     apnList.add(pref);
                 } else {
                     mmsApnList.add(pref);