Loading src/java/com/android/internal/telephony/CarrierResolver.java +24 −6 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.os.Handler; import android.os.Message; import android.provider.Telephony; import android.service.carrier.CarrierIdentifier; import android.telephony.CarrierConfigManager; import android.telephony.PhoneStateListener; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading Loading @@ -231,7 +232,7 @@ public class CarrierResolver extends Handler { loge("mIccRecords is null on SIM_LOAD_EVENT, could not get SPN"); } mPreferApn = getPreferApn(); loadCarrierMatchingRulesOnMccMnc(); loadCarrierMatchingRulesOnMccMnc(false /* update carrier config */); } private void handleSimAbsent() { Loading Loading @@ -278,14 +279,14 @@ public class CarrierResolver extends Handler { case CARRIER_ID_DB_UPDATE_EVENT: // clean the cached carrier list version, so that a new one will be queried. mCarrierListVersion = null; loadCarrierMatchingRulesOnMccMnc(); loadCarrierMatchingRulesOnMccMnc(true /* update carrier config*/); break; case PREFER_APN_UPDATE_EVENT: String preferApn = getPreferApn(); if (!equals(mPreferApn, preferApn, true)) { logd("[updatePreferApn] from:" + mPreferApn + " to:" + preferApn); mPreferApn = preferApn; matchSubscriptionCarrier(); matchSubscriptionCarrier(true /* update carrier config*/); } break; case ICC_CHANGED_EVENT: Loading @@ -311,7 +312,7 @@ public class CarrierResolver extends Handler { } } private void loadCarrierMatchingRulesOnMccMnc() { private void loadCarrierMatchingRulesOnMccMnc(boolean updateCarrierConfig) { try { String mccmnc = mTelephonyMgr.getSimOperatorNumericForPhone(mPhone.getPhoneId()); Cursor cursor = mContext.getContentResolver().query( Loading @@ -329,7 +330,7 @@ public class CarrierResolver extends Handler { while (cursor.moveToNext()) { mCarrierMatchingRulesOnMccMnc.add(makeCarrierMatchingRule(cursor)); } matchSubscriptionCarrier(); matchSubscriptionCarrier(updateCarrierConfig); // Generate metrics related to carrier ID table version. CarrierIdMatchStats.sendCarrierIdTableVersion(getCarrierListVersion()); Loading Loading @@ -811,10 +812,22 @@ public class CarrierResolver extends Handler { TelephonyManager.UNKNOWN_CARRIER_ID); } private void updateCarrierConfig() { IccCard iccCard = mPhone.getIccCard(); IccCardConstants.State simState = IccCardConstants.State.UNKNOWN; if (iccCard != null) { simState = iccCard.getState(); } CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE); configManager.updateConfigForPhoneId(mPhone.getPhoneId(), UiccController.getIccStateIntentString(simState)); } /** * find the best matching carrier from candidates with matched subscription MCCMNC. */ private void matchSubscriptionCarrier() { private void matchSubscriptionCarrier(boolean updateCarrierConfig) { if (!SubscriptionManager.isValidSubscriptionId(mPhone.getSubId())) { logd("[matchSubscriptionCarrier]" + "skip before sim records loaded"); return; Loading Loading @@ -872,6 +885,11 @@ public class CarrierResolver extends Handler { updateCarrierIdAndName(maxRuleParent.mCid, maxRuleParent.mName, maxRule.mCid, maxRule.mName, (mnoRule == null) ? maxRule.mCid : mnoRule.mCid); if (updateCarrierConfig) { logd("[matchSubscriptionCarrier] - Calling updateCarrierConfig()"); updateCarrierConfig(); } } /* Loading src/java/com/android/internal/telephony/uicc/UiccController.java +7 −1 Original line number Diff line number Diff line Loading @@ -624,7 +624,13 @@ public class UiccController extends Handler { } } static String getIccStateIntentString(IccCardConstants.State state) { /** * Convert IccCardConstants.State enum values to corresponding IccCardConstants String * constants * @param state IccCardConstants.State enum value * @return IccCardConstants String constant representing ICC state */ public static String getIccStateIntentString(IccCardConstants.State state) { switch (state) { case ABSENT: return IccCardConstants.INTENT_VALUE_ICC_ABSENT; case PIN_REQUIRED: return IccCardConstants.INTENT_VALUE_ICC_LOCKED; Loading tests/telephonytests/src/com/android/internal/telephony/CarrierResolverTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import android.database.Cursor; import android.database.MatrixCursor; Loading Loading @@ -257,12 +258,15 @@ public class CarrierResolverTest extends TelephonyTest { assertEquals(CID_VZW, mCarrierResolver.getCarrierId()); assertEquals(NAME, mCarrierResolver.getCarrierName()); // mock apn doReturn(IccCardConstants.State.LOADED).when(mUiccProfile).getState(); ((MockContentResolver) mContext.getContentResolver()).addProvider( Carriers.CONTENT_URI.getAuthority(), new CarrierIdContentProvider()); mCarrierResolver.sendEmptyMessage(PREFER_APN_SET_EVENT); processAllMessages(); assertEquals(CID_DOCOMO, mCarrierResolver.getCarrierId()); assertEquals(NAME_DOCOMO, mCarrierResolver.getCarrierName()); verify(mCarrierConfigManager).updateConfigForPhoneId(phoneId, IccCardConstants.INTENT_VALUE_ICC_LOADED); } private class CarrierIdContentProvider extends MockContentProvider { Loading Loading
src/java/com/android/internal/telephony/CarrierResolver.java +24 −6 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.os.Handler; import android.os.Message; import android.provider.Telephony; import android.service.carrier.CarrierIdentifier; import android.telephony.CarrierConfigManager; import android.telephony.PhoneStateListener; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading Loading @@ -231,7 +232,7 @@ public class CarrierResolver extends Handler { loge("mIccRecords is null on SIM_LOAD_EVENT, could not get SPN"); } mPreferApn = getPreferApn(); loadCarrierMatchingRulesOnMccMnc(); loadCarrierMatchingRulesOnMccMnc(false /* update carrier config */); } private void handleSimAbsent() { Loading Loading @@ -278,14 +279,14 @@ public class CarrierResolver extends Handler { case CARRIER_ID_DB_UPDATE_EVENT: // clean the cached carrier list version, so that a new one will be queried. mCarrierListVersion = null; loadCarrierMatchingRulesOnMccMnc(); loadCarrierMatchingRulesOnMccMnc(true /* update carrier config*/); break; case PREFER_APN_UPDATE_EVENT: String preferApn = getPreferApn(); if (!equals(mPreferApn, preferApn, true)) { logd("[updatePreferApn] from:" + mPreferApn + " to:" + preferApn); mPreferApn = preferApn; matchSubscriptionCarrier(); matchSubscriptionCarrier(true /* update carrier config*/); } break; case ICC_CHANGED_EVENT: Loading @@ -311,7 +312,7 @@ public class CarrierResolver extends Handler { } } private void loadCarrierMatchingRulesOnMccMnc() { private void loadCarrierMatchingRulesOnMccMnc(boolean updateCarrierConfig) { try { String mccmnc = mTelephonyMgr.getSimOperatorNumericForPhone(mPhone.getPhoneId()); Cursor cursor = mContext.getContentResolver().query( Loading @@ -329,7 +330,7 @@ public class CarrierResolver extends Handler { while (cursor.moveToNext()) { mCarrierMatchingRulesOnMccMnc.add(makeCarrierMatchingRule(cursor)); } matchSubscriptionCarrier(); matchSubscriptionCarrier(updateCarrierConfig); // Generate metrics related to carrier ID table version. CarrierIdMatchStats.sendCarrierIdTableVersion(getCarrierListVersion()); Loading Loading @@ -811,10 +812,22 @@ public class CarrierResolver extends Handler { TelephonyManager.UNKNOWN_CARRIER_ID); } private void updateCarrierConfig() { IccCard iccCard = mPhone.getIccCard(); IccCardConstants.State simState = IccCardConstants.State.UNKNOWN; if (iccCard != null) { simState = iccCard.getState(); } CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE); configManager.updateConfigForPhoneId(mPhone.getPhoneId(), UiccController.getIccStateIntentString(simState)); } /** * find the best matching carrier from candidates with matched subscription MCCMNC. */ private void matchSubscriptionCarrier() { private void matchSubscriptionCarrier(boolean updateCarrierConfig) { if (!SubscriptionManager.isValidSubscriptionId(mPhone.getSubId())) { logd("[matchSubscriptionCarrier]" + "skip before sim records loaded"); return; Loading Loading @@ -872,6 +885,11 @@ public class CarrierResolver extends Handler { updateCarrierIdAndName(maxRuleParent.mCid, maxRuleParent.mName, maxRule.mCid, maxRule.mName, (mnoRule == null) ? maxRule.mCid : mnoRule.mCid); if (updateCarrierConfig) { logd("[matchSubscriptionCarrier] - Calling updateCarrierConfig()"); updateCarrierConfig(); } } /* Loading
src/java/com/android/internal/telephony/uicc/UiccController.java +7 −1 Original line number Diff line number Diff line Loading @@ -624,7 +624,13 @@ public class UiccController extends Handler { } } static String getIccStateIntentString(IccCardConstants.State state) { /** * Convert IccCardConstants.State enum values to corresponding IccCardConstants String * constants * @param state IccCardConstants.State enum value * @return IccCardConstants String constant representing ICC state */ public static String getIccStateIntentString(IccCardConstants.State state) { switch (state) { case ABSENT: return IccCardConstants.INTENT_VALUE_ICC_ABSENT; case PIN_REQUIRED: return IccCardConstants.INTENT_VALUE_ICC_LOCKED; Loading
tests/telephonytests/src/com/android/internal/telephony/CarrierResolverTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import android.database.Cursor; import android.database.MatrixCursor; Loading Loading @@ -257,12 +258,15 @@ public class CarrierResolverTest extends TelephonyTest { assertEquals(CID_VZW, mCarrierResolver.getCarrierId()); assertEquals(NAME, mCarrierResolver.getCarrierName()); // mock apn doReturn(IccCardConstants.State.LOADED).when(mUiccProfile).getState(); ((MockContentResolver) mContext.getContentResolver()).addProvider( Carriers.CONTENT_URI.getAuthority(), new CarrierIdContentProvider()); mCarrierResolver.sendEmptyMessage(PREFER_APN_SET_EVENT); processAllMessages(); assertEquals(CID_DOCOMO, mCarrierResolver.getCarrierId()); assertEquals(NAME_DOCOMO, mCarrierResolver.getCarrierName()); verify(mCarrierConfigManager).updateConfigForPhoneId(phoneId, IccCardConstants.INTENT_VALUE_ICC_LOADED); } private class CarrierIdContentProvider extends MockContentProvider { Loading