Snap for 7537202 from 33fd185692dde5005fa743ca8a01b3633b68dc12 to sc-v2-release
Change-Id: I5fec606c86c41606e57d3e7cc8efc55fc650fec4
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index 4303823..0ff9fc6 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -3891,6 +3891,31 @@
}
/**
+ * This method syncs PREF_FILE_FULL_APN with the db based on the current preferred apn ids.
+ */
+ private void updatePreferredApns() {
+ SharedPreferences spApn = getContext().getSharedPreferences(PREF_FILE_APN,
+ Context.MODE_PRIVATE);
+
+ Map<String, ?> allPrefApnId = spApn.getAll();
+ for (String key : allPrefApnId.keySet()) {
+ if (key.startsWith(COLUMN_APN_ID)) {
+ int subId;
+ try {
+ subId = Integer.parseInt(key.substring(COLUMN_APN_ID.length()));
+ } catch (NumberFormatException e) {
+ loge("updatePreferredApns: NumberFormatException for key=" + key);
+ continue;
+ }
+ long preferredApnId = getPreferredApnId(subId, false);
+ if (preferredApnId != INVALID_APN_ID) {
+ setPreferredApn(preferredApnId, subId);
+ }
+ }
+ }
+ }
+
+ /**
* To find the current sim APN. Query APN based on {MCC, MNC, MVNO} and {Carrier_ID}.
*
* There has three steps:
@@ -4638,6 +4663,19 @@
}
}
+ // if APNs (CARRIERS_TABLE) have been updated, some of them may be preferred APN for
+ // different subs. So update the APN field values saved in SharedPref for all subIds.
+ switch (match) {
+ case URL_TELEPHONY_USING_SUBID:
+ case URL_TELEPHONY:
+ case URL_CURRENT_USING_SUBID:
+ case URL_CURRENT:
+ case URL_ID:
+ case URL_DPC_ID:
+ updatePreferredApns();
+ break;
+ }
+
if (count > 0) {
boolean usingSubId = false;
switch (uriType) {