Loading src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +16 −5 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.telephony.TelephonyManager; import android.telephony.UiccAccessRule; import android.telephony.euicc.EuiccManager; import android.text.TextUtils; import android.util.Pair; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.euicc.EuiccController; Loading Loading @@ -714,19 +715,20 @@ public class SubscriptionInfoUpdater extends Handler { } mBackgroundHandler.post(() -> { List<GetEuiccProfileInfoListResult> results = new ArrayList<>(); List<Pair<Integer, GetEuiccProfileInfoListResult>> results = new ArrayList<>(); for (int cardId : cardIds) { GetEuiccProfileInfoListResult result = EuiccController.get().blockingGetEuiccProfileInfoList(cardId); if (DBG) logd("blockingGetEuiccProfileInfoList cardId " + cardId); results.add(result); results.add(Pair.create(cardId, result)); } // The runnable will be executed in the main thread. this.post(() -> { boolean hasChanges = false; for (GetEuiccProfileInfoListResult result : results) { if (updateEmbeddedSubscriptionsCache(result)) { for (Pair<Integer, GetEuiccProfileInfoListResult> cardIdAndResult : results) { if (updateEmbeddedSubscriptionsCache(cardIdAndResult.first, cardIdAndResult.second)) { hasChanges = true; } } Loading @@ -747,7 +749,8 @@ public class SubscriptionInfoUpdater extends Handler { * but notifications about subscription changes may be skipped if this returns false as an * optimization to avoid spurious notifications. */ private boolean updateEmbeddedSubscriptionsCache(GetEuiccProfileInfoListResult result) { private boolean updateEmbeddedSubscriptionsCache(int cardId, GetEuiccProfileInfoListResult result) { if (DBG) logd("updateEmbeddedSubscriptionsCache"); if (result == null) { Loading Loading @@ -852,6 +855,14 @@ public class SubscriptionInfoUpdater extends Handler { values.put(SubscriptionManager.MNC_STRING, mnc); values.put(SubscriptionManager.MNC, mnc); } // If cardId = unsupported or unitialized, we have no reason to update DB. // Additionally, if the device does not support cardId for default eUICC, the CARD_ID // field should not contain the EID if (cardId >= 0 && UiccController.getInstance().getCardIdForDefaultEuicc() != TelephonyManager.UNSUPPORTED_CARD_ID) { values.put(SubscriptionManager.CARD_ID, mEuiccManager.createForCardId(cardId).getEid()); } hasChanges = true; contentResolver.update(SubscriptionManager.CONTENT_URI, values, SubscriptionManager.ICC_ID + "=\"" + embeddedProfile.getIccid() + "\"", null); Loading tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { private static final int FAKE_SUB_ID_1 = 0; private static final int FAKE_SUB_ID_2 = 1; private static final int FAKE_CARD_ID = 0; private static final String FAKE_EID = "89049032000001000000031328322874"; private static final String FAKE_MCC_MNC_1 = "123456"; private static final String FAKE_MCC_MNC_2 = "456789"; Loading Loading @@ -485,6 +486,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { @SmallTest public void testUpdateEmbeddedSubscriptions_listSuccess() throws Exception { when(mEuiccManager.isEnabled()).thenReturn(true); when(mEuiccManager.createForCardId(anyInt())).thenReturn(mEuiccManager); when(mEuiccManager.getEid()).thenReturn(FAKE_EID); EuiccProfileInfo[] euiccProfiles = new EuiccProfileInfo[] { new EuiccProfileInfo("1", null /* accessRules */, null /* nickname */), Loading Loading
src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +16 −5 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.telephony.TelephonyManager; import android.telephony.UiccAccessRule; import android.telephony.euicc.EuiccManager; import android.text.TextUtils; import android.util.Pair; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.euicc.EuiccController; Loading Loading @@ -714,19 +715,20 @@ public class SubscriptionInfoUpdater extends Handler { } mBackgroundHandler.post(() -> { List<GetEuiccProfileInfoListResult> results = new ArrayList<>(); List<Pair<Integer, GetEuiccProfileInfoListResult>> results = new ArrayList<>(); for (int cardId : cardIds) { GetEuiccProfileInfoListResult result = EuiccController.get().blockingGetEuiccProfileInfoList(cardId); if (DBG) logd("blockingGetEuiccProfileInfoList cardId " + cardId); results.add(result); results.add(Pair.create(cardId, result)); } // The runnable will be executed in the main thread. this.post(() -> { boolean hasChanges = false; for (GetEuiccProfileInfoListResult result : results) { if (updateEmbeddedSubscriptionsCache(result)) { for (Pair<Integer, GetEuiccProfileInfoListResult> cardIdAndResult : results) { if (updateEmbeddedSubscriptionsCache(cardIdAndResult.first, cardIdAndResult.second)) { hasChanges = true; } } Loading @@ -747,7 +749,8 @@ public class SubscriptionInfoUpdater extends Handler { * but notifications about subscription changes may be skipped if this returns false as an * optimization to avoid spurious notifications. */ private boolean updateEmbeddedSubscriptionsCache(GetEuiccProfileInfoListResult result) { private boolean updateEmbeddedSubscriptionsCache(int cardId, GetEuiccProfileInfoListResult result) { if (DBG) logd("updateEmbeddedSubscriptionsCache"); if (result == null) { Loading Loading @@ -852,6 +855,14 @@ public class SubscriptionInfoUpdater extends Handler { values.put(SubscriptionManager.MNC_STRING, mnc); values.put(SubscriptionManager.MNC, mnc); } // If cardId = unsupported or unitialized, we have no reason to update DB. // Additionally, if the device does not support cardId for default eUICC, the CARD_ID // field should not contain the EID if (cardId >= 0 && UiccController.getInstance().getCardIdForDefaultEuicc() != TelephonyManager.UNSUPPORTED_CARD_ID) { values.put(SubscriptionManager.CARD_ID, mEuiccManager.createForCardId(cardId).getEid()); } hasChanges = true; contentResolver.update(SubscriptionManager.CONTENT_URI, values, SubscriptionManager.ICC_ID + "=\"" + embeddedProfile.getIccid() + "\"", null); Loading
tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { private static final int FAKE_SUB_ID_1 = 0; private static final int FAKE_SUB_ID_2 = 1; private static final int FAKE_CARD_ID = 0; private static final String FAKE_EID = "89049032000001000000031328322874"; private static final String FAKE_MCC_MNC_1 = "123456"; private static final String FAKE_MCC_MNC_2 = "456789"; Loading Loading @@ -485,6 +486,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { @SmallTest public void testUpdateEmbeddedSubscriptions_listSuccess() throws Exception { when(mEuiccManager.isEnabled()).thenReturn(true); when(mEuiccManager.createForCardId(anyInt())).thenReturn(mEuiccManager); when(mEuiccManager.getEid()).thenReturn(FAKE_EID); EuiccProfileInfo[] euiccProfiles = new EuiccProfileInfo[] { new EuiccProfileInfo("1", null /* accessRules */, null /* nickname */), Loading