Loading src/java/com/android/internal/telephony/CarrierResolver.java +27 −16 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.IntentFilter; import android.database.ContentObserver; import android.database.Cursor; import android.net.Uri; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; import android.provider.Telephony; Loading Loading @@ -164,7 +165,7 @@ public class CarrierResolver extends Handler { updateCarrierIdAndName( carrierId, carrierName != null ? carrierName : "", specificCarrierId, specificCarrierName != null ? carrierName : "", mnoCarrierId); mnoCarrierId, false); } } }; Loading Loading @@ -215,12 +216,12 @@ public class CarrierResolver extends Handler { handleSimAbsent(); break; case IccCardConstants.INTENT_VALUE_ICC_LOADED: handleSimLoaded(); handleSimLoaded(false); break; } } private void handleSimLoaded() { private void handleSimLoaded(boolean isSimOverride) { if (mIccRecords != null) { /** * returns empty string to be consistent with Loading @@ -232,7 +233,9 @@ public class CarrierResolver extends Handler { loge("mIccRecords is null on SIM_LOAD_EVENT, could not get SPN"); } mPreferApn = getPreferApn(); loadCarrierMatchingRulesOnMccMnc(false /* update carrier config */); loadCarrierMatchingRulesOnMccMnc( false /* update carrier config */, isSimOverride); } private void handleSimAbsent() { Loading @@ -241,7 +244,7 @@ public class CarrierResolver extends Handler { mPreferApn = null; updateCarrierIdAndName(TelephonyManager.UNKNOWN_CARRIER_ID, null, TelephonyManager.UNKNOWN_CARRIER_ID, null, TelephonyManager.UNKNOWN_CARRIER_ID); TelephonyManager.UNKNOWN_CARRIER_ID, false); } private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() { Loading Loading @@ -274,19 +277,24 @@ public class CarrierResolver extends Handler { if (DBG) logd("handleMessage: " + msg.what); switch (msg.what) { case SIM_LOAD_EVENT: handleSimLoaded(); AsyncResult result = (AsyncResult) msg.obj; boolean isSimOverride = false; if (result != null) { isSimOverride = result.userObj instanceof Boolean && (Boolean) result.userObj; } handleSimLoaded(isSimOverride); break; case CARRIER_ID_DB_UPDATE_EVENT: // clean the cached carrier list version, so that a new one will be queried. mCarrierListVersion = null; loadCarrierMatchingRulesOnMccMnc(true /* update carrier config*/); loadCarrierMatchingRulesOnMccMnc(true /* update carrier config*/, false); break; case PREFER_APN_UPDATE_EVENT: String preferApn = getPreferApn(); if (!equals(mPreferApn, preferApn, true)) { logd("[updatePreferApn] from:" + mPreferApn + " to:" + preferApn); mPreferApn = preferApn; matchSubscriptionCarrier(true /* update carrier config*/); matchSubscriptionCarrier(true /* update carrier config*/, false); } break; case ICC_CHANGED_EVENT: Loading @@ -301,7 +309,8 @@ public class CarrierResolver extends Handler { } if (newIccRecords != null) { logd("new Icc object"); newIccRecords.registerForRecordsOverride(this, SIM_LOAD_EVENT, null); newIccRecords.registerForRecordsOverride(this, SIM_LOAD_EVENT, /* is sim override*/true); mIccRecords = newIccRecords; } } Loading @@ -312,7 +321,9 @@ public class CarrierResolver extends Handler { } } private void loadCarrierMatchingRulesOnMccMnc(boolean updateCarrierConfig) { private void loadCarrierMatchingRulesOnMccMnc( boolean updateCarrierConfig, boolean isSimOverride) { try { String mccmnc = mTelephonyMgr.getSimOperatorNumericForPhone(mPhone.getPhoneId()); Cursor cursor = mContext.getContentResolver().query( Loading @@ -330,7 +341,7 @@ public class CarrierResolver extends Handler { while (cursor.moveToNext()) { mCarrierMatchingRulesOnMccMnc.add(makeCarrierMatchingRule(cursor)); } matchSubscriptionCarrier(updateCarrierConfig); matchSubscriptionCarrier(updateCarrierConfig, isSimOverride); // Generate metrics related to carrier ID table version. CarrierIdMatchStats.sendCarrierIdTableVersion(getCarrierListVersion()); Loading Loading @@ -465,7 +476,7 @@ public class CarrierResolver extends Handler { private void updateCarrierIdAndName(int cid, String name, int specificCarrierId, String specificCarrierName, int mnoCid) { int mnoCid, boolean isSimOverride) { boolean update = false; if (specificCarrierId != mSpecificCarrierId) { logd("[updateSpecificCarrierId] from:" + mSpecificCarrierId + " to:" Loading Loading @@ -534,7 +545,7 @@ public class CarrierResolver extends Handler { // during esim profile switch, there is no sim absent thus carrier id will persist and // might not trigger an update if switch profiles for the same carrier. thus always update // subscriptioninfo db to make sure we have correct carrier id set. if (SubscriptionManager.isValidSubscriptionId(mPhone.getSubId())) { if (SubscriptionManager.isValidSubscriptionId(mPhone.getSubId()) && !isSimOverride) { // only persist carrier id to simInfo db when subId is valid. SubscriptionController.getInstance().setCarrierId(mCarrierId, mPhone.getSubId()); } Loading Loading @@ -827,7 +838,7 @@ public class CarrierResolver extends Handler { /** * find the best matching carrier from candidates with matched subscription MCCMNC. */ private void matchSubscriptionCarrier(boolean updateCarrierConfig) { private void matchSubscriptionCarrier(boolean updateCarrierConfig, boolean isSimOverride) { if (!SubscriptionManager.isValidSubscriptionId(mPhone.getSubId())) { logd("[matchSubscriptionCarrier]" + "skip before sim records loaded"); return; Loading Loading @@ -870,7 +881,7 @@ public class CarrierResolver extends Handler { + " name: " + null); updateCarrierIdAndName(TelephonyManager.UNKNOWN_CARRIER_ID, null, TelephonyManager.UNKNOWN_CARRIER_ID, null, TelephonyManager.UNKNOWN_CARRIER_ID); TelephonyManager.UNKNOWN_CARRIER_ID, isSimOverride); } else { // if there is a single matching result, check if this rule has parent cid assigned. if ((maxRule == maxRuleParent) Loading @@ -884,7 +895,7 @@ public class CarrierResolver extends Handler { + " name: " + maxRuleParent.mName); updateCarrierIdAndName(maxRuleParent.mCid, maxRuleParent.mName, maxRule.mCid, maxRule.mName, (mnoRule == null) ? maxRule.mCid : mnoRule.mCid); (mnoRule == null) ? maxRule.mCid : mnoRule.mCid, isSimOverride); if (updateCarrierConfig) { logd("[matchSubscriptionCarrier] - Calling updateCarrierConfig()"); Loading Loading
src/java/com/android/internal/telephony/CarrierResolver.java +27 −16 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.IntentFilter; import android.database.ContentObserver; import android.database.Cursor; import android.net.Uri; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; import android.provider.Telephony; Loading Loading @@ -164,7 +165,7 @@ public class CarrierResolver extends Handler { updateCarrierIdAndName( carrierId, carrierName != null ? carrierName : "", specificCarrierId, specificCarrierName != null ? carrierName : "", mnoCarrierId); mnoCarrierId, false); } } }; Loading Loading @@ -215,12 +216,12 @@ public class CarrierResolver extends Handler { handleSimAbsent(); break; case IccCardConstants.INTENT_VALUE_ICC_LOADED: handleSimLoaded(); handleSimLoaded(false); break; } } private void handleSimLoaded() { private void handleSimLoaded(boolean isSimOverride) { if (mIccRecords != null) { /** * returns empty string to be consistent with Loading @@ -232,7 +233,9 @@ public class CarrierResolver extends Handler { loge("mIccRecords is null on SIM_LOAD_EVENT, could not get SPN"); } mPreferApn = getPreferApn(); loadCarrierMatchingRulesOnMccMnc(false /* update carrier config */); loadCarrierMatchingRulesOnMccMnc( false /* update carrier config */, isSimOverride); } private void handleSimAbsent() { Loading @@ -241,7 +244,7 @@ public class CarrierResolver extends Handler { mPreferApn = null; updateCarrierIdAndName(TelephonyManager.UNKNOWN_CARRIER_ID, null, TelephonyManager.UNKNOWN_CARRIER_ID, null, TelephonyManager.UNKNOWN_CARRIER_ID); TelephonyManager.UNKNOWN_CARRIER_ID, false); } private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() { Loading Loading @@ -274,19 +277,24 @@ public class CarrierResolver extends Handler { if (DBG) logd("handleMessage: " + msg.what); switch (msg.what) { case SIM_LOAD_EVENT: handleSimLoaded(); AsyncResult result = (AsyncResult) msg.obj; boolean isSimOverride = false; if (result != null) { isSimOverride = result.userObj instanceof Boolean && (Boolean) result.userObj; } handleSimLoaded(isSimOverride); break; case CARRIER_ID_DB_UPDATE_EVENT: // clean the cached carrier list version, so that a new one will be queried. mCarrierListVersion = null; loadCarrierMatchingRulesOnMccMnc(true /* update carrier config*/); loadCarrierMatchingRulesOnMccMnc(true /* update carrier config*/, false); break; case PREFER_APN_UPDATE_EVENT: String preferApn = getPreferApn(); if (!equals(mPreferApn, preferApn, true)) { logd("[updatePreferApn] from:" + mPreferApn + " to:" + preferApn); mPreferApn = preferApn; matchSubscriptionCarrier(true /* update carrier config*/); matchSubscriptionCarrier(true /* update carrier config*/, false); } break; case ICC_CHANGED_EVENT: Loading @@ -301,7 +309,8 @@ public class CarrierResolver extends Handler { } if (newIccRecords != null) { logd("new Icc object"); newIccRecords.registerForRecordsOverride(this, SIM_LOAD_EVENT, null); newIccRecords.registerForRecordsOverride(this, SIM_LOAD_EVENT, /* is sim override*/true); mIccRecords = newIccRecords; } } Loading @@ -312,7 +321,9 @@ public class CarrierResolver extends Handler { } } private void loadCarrierMatchingRulesOnMccMnc(boolean updateCarrierConfig) { private void loadCarrierMatchingRulesOnMccMnc( boolean updateCarrierConfig, boolean isSimOverride) { try { String mccmnc = mTelephonyMgr.getSimOperatorNumericForPhone(mPhone.getPhoneId()); Cursor cursor = mContext.getContentResolver().query( Loading @@ -330,7 +341,7 @@ public class CarrierResolver extends Handler { while (cursor.moveToNext()) { mCarrierMatchingRulesOnMccMnc.add(makeCarrierMatchingRule(cursor)); } matchSubscriptionCarrier(updateCarrierConfig); matchSubscriptionCarrier(updateCarrierConfig, isSimOverride); // Generate metrics related to carrier ID table version. CarrierIdMatchStats.sendCarrierIdTableVersion(getCarrierListVersion()); Loading Loading @@ -465,7 +476,7 @@ public class CarrierResolver extends Handler { private void updateCarrierIdAndName(int cid, String name, int specificCarrierId, String specificCarrierName, int mnoCid) { int mnoCid, boolean isSimOverride) { boolean update = false; if (specificCarrierId != mSpecificCarrierId) { logd("[updateSpecificCarrierId] from:" + mSpecificCarrierId + " to:" Loading Loading @@ -534,7 +545,7 @@ public class CarrierResolver extends Handler { // during esim profile switch, there is no sim absent thus carrier id will persist and // might not trigger an update if switch profiles for the same carrier. thus always update // subscriptioninfo db to make sure we have correct carrier id set. if (SubscriptionManager.isValidSubscriptionId(mPhone.getSubId())) { if (SubscriptionManager.isValidSubscriptionId(mPhone.getSubId()) && !isSimOverride) { // only persist carrier id to simInfo db when subId is valid. SubscriptionController.getInstance().setCarrierId(mCarrierId, mPhone.getSubId()); } Loading Loading @@ -827,7 +838,7 @@ public class CarrierResolver extends Handler { /** * find the best matching carrier from candidates with matched subscription MCCMNC. */ private void matchSubscriptionCarrier(boolean updateCarrierConfig) { private void matchSubscriptionCarrier(boolean updateCarrierConfig, boolean isSimOverride) { if (!SubscriptionManager.isValidSubscriptionId(mPhone.getSubId())) { logd("[matchSubscriptionCarrier]" + "skip before sim records loaded"); return; Loading Loading @@ -870,7 +881,7 @@ public class CarrierResolver extends Handler { + " name: " + null); updateCarrierIdAndName(TelephonyManager.UNKNOWN_CARRIER_ID, null, TelephonyManager.UNKNOWN_CARRIER_ID, null, TelephonyManager.UNKNOWN_CARRIER_ID); TelephonyManager.UNKNOWN_CARRIER_ID, isSimOverride); } else { // if there is a single matching result, check if this rule has parent cid assigned. if ((maxRule == maxRuleParent) Loading @@ -884,7 +895,7 @@ public class CarrierResolver extends Handler { + " name: " + maxRuleParent.mName); updateCarrierIdAndName(maxRuleParent.mCid, maxRuleParent.mName, maxRule.mCid, maxRule.mName, (mnoRule == null) ? maxRule.mCid : mnoRule.mCid); (mnoRule == null) ? maxRule.mCid : mnoRule.mCid, isSimOverride); if (updateCarrierConfig) { logd("[matchSubscriptionCarrier] - Calling updateCarrierConfig()"); Loading