cherry-picked "Add cardid to
requestEmbeddedSubscriptionInfoListRrefresh"
Bug: 112902036
Test: atest FrameworksTelephonysTests
Merged-In: I05b5248a80dd0375a0874cf027f5423116aef1ca
Change-Id: I05b5248a80dd0375a0874cf027f5423116aef1ca
(cherry picked from commit 269797b0f1152d1d7aa0b07e0adc7724c01ffcd9)
diff --git a/src/java/com/android/internal/telephony/PhoneFactory.java b/src/java/com/android/internal/telephony/PhoneFactory.java
index 5359941..01116a7 100644
--- a/src/java/com/android/internal/telephony/PhoneFactory.java
+++ b/src/java/com/android/internal/telephony/PhoneFactory.java
@@ -386,11 +386,13 @@
/**
* Request a refresh of the embedded subscription list.
*
+ * @param cardId the card ID of the eUICC.
* @param callback Optional callback to execute after the refresh completes. Must terminate
* quickly as it will be called from SubscriptionInfoUpdater's handler thread.
*/
- public static void requestEmbeddedSubscriptionInfoListRefresh(@Nullable Runnable callback) {
- sSubInfoRecordUpdater.requestEmbeddedSubscriptionInfoListRefresh(callback);
+ public static void requestEmbeddedSubscriptionInfoListRefresh(
+ int cardId, @Nullable Runnable callback) {
+ sSubInfoRecordUpdater.requestEmbeddedSubscriptionInfoListRefresh(cardId, callback);
}
/**
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java
index 0789c5e..edf8be2 100644
--- a/src/java/com/android/internal/telephony/SubscriptionController.java
+++ b/src/java/com/android/internal/telephony/SubscriptionController.java
@@ -857,26 +857,41 @@
}
@Override
- public void requestEmbeddedSubscriptionInfoListRefresh() {
+ public void requestEmbeddedSubscriptionInfoListRefresh(int cardId) {
mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS,
"requestEmbeddedSubscriptionInfoListRefresh");
long token = Binder.clearCallingIdentity();
try {
- PhoneFactory.requestEmbeddedSubscriptionInfoListRefresh(null /* callback */);
+ PhoneFactory.requestEmbeddedSubscriptionInfoListRefresh(cardId, null /* callback */);
} finally {
Binder.restoreCallingIdentity(token);
}
}
/**
- * Asynchronously refresh the embedded subscription info list.
+ * Asynchronously refresh the embedded subscription info list for the embedded card has the
+ * given card id {@code cardId}.
+ *
+ * @param callback Optional callback to execute after the refresh completes. Must terminate
+ * quickly as it will be called from SubscriptionInfoUpdater's handler thread.
+ */
+ // No permission check needed as this is not exposed via AIDL.
+ public void requestEmbeddedSubscriptionInfoListRefresh(
+ int cardId, @Nullable Runnable callback) {
+ PhoneFactory.requestEmbeddedSubscriptionInfoListRefresh(cardId, callback);
+ }
+
+ /**
+ * Asynchronously refresh the embedded subscription info list for the embedded card has the
+ * default card id return by {@link TelephonyManager#getCardIdForDefaultEuicc()}.
*
* @param callback Optional callback to execute after the refresh completes. Must terminate
* quickly as it will be called from SubscriptionInfoUpdater's handler thread.
*/
// No permission check needed as this is not exposed via AIDL.
public void requestEmbeddedSubscriptionInfoListRefresh(@Nullable Runnable callback) {
- PhoneFactory.requestEmbeddedSubscriptionInfoListRefresh(callback);
+ PhoneFactory.requestEmbeddedSubscriptionInfoListRefresh(
+ mTelephonyManager.getCardIdForDefaultEuicc(), callback);
}
/**
diff --git a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java
index 7611620..f1e3fec 100644
--- a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java
+++ b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java
@@ -53,10 +53,13 @@
import com.android.internal.telephony.euicc.EuiccController;
import com.android.internal.telephony.uicc.IccRecords;
import com.android.internal.telephony.uicc.IccUtils;
+import com.android.internal.telephony.uicc.UiccController;
+import com.android.internal.telephony.uicc.UiccSlot;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
/**
@@ -282,7 +285,7 @@
// intentional fall through
case EVENT_REFRESH_EMBEDDED_SUBSCRIPTIONS:
- if (updateEmbeddedSubscriptions()) {
+ if (updateEmbeddedSubscriptions(msg.arg1)) {
SubscriptionController.getInstance().notifySubscriptionInfoChanged();
}
if (msg.obj != null) {
@@ -295,8 +298,9 @@
}
}
- void requestEmbeddedSubscriptionInfoListRefresh(@Nullable Runnable callback) {
- sendMessage(obtainMessage(EVENT_REFRESH_EMBEDDED_SUBSCRIPTIONS, callback));
+ void requestEmbeddedSubscriptionInfoListRefresh(int cardId, @Nullable Runnable callback) {
+ sendMessage(obtainMessage(
+ EVENT_REFRESH_EMBEDDED_SUBSCRIPTIONS, cardId, 0 /* arg2 */, callback));
}
private void handleSimLocked(int slotId, String reason) {
@@ -690,21 +694,32 @@
mSubscriptionManager.getDefaultDataSubscriptionId());
// No need to check return value here as we notify for the above changes anyway.
- updateEmbeddedSubscriptions();
+ if (subInfos != null) {
+ UiccController uiccController = UiccController.getInstance();
+ UiccSlot[] uiccSlots = uiccController.getUiccSlots();
+ if (uiccSlots != null) {
+ Arrays.stream(uiccSlots)
+ .filter(uiccSlot -> uiccSlot.isEuicc() && uiccSlot.getUiccCard() != null)
+ .map(uiccSlot -> uiccController.convertToPublicCardId(
+ uiccSlot.getUiccCard().getCardId()))
+ .forEach(cardId -> updateEmbeddedSubscriptions(cardId));
+ }
+ }
SubscriptionController.getInstance().notifySubscriptionInfoChanged();
logd("updateSubscriptionInfoByIccId:- SubscriptionInfo update complete");
}
/**
- * Update the cached list of embedded subscriptions.
+ * Update the cached list of embedded subscription for the eUICC with the given card ID
+ * {@code cardId}.
*
* @return true if changes may have been made. This is not a guarantee that changes were made,
* but notifications about subscription changes may be skipped if this returns false as an
* optimization to avoid spurious notifications.
*/
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
- public boolean updateEmbeddedSubscriptions() {
+ public boolean updateEmbeddedSubscriptions(int cardId) {
if (DBG) logd("updateEmbeddedSubscriptions");
// Do nothing if eUICCs are disabled. (Previous entries may remain in the cache, but they
// are filtered out of list calls as long as EuiccManager.isEnabled returns false).
@@ -713,7 +728,7 @@
}
GetEuiccProfileInfoListResult result =
- EuiccController.get().blockingGetEuiccProfileInfoList();
+ EuiccController.get().blockingGetEuiccProfileInfoList(cardId);
if (result == null) {
// IPC to the eUICC controller failed.
return false;
diff --git a/src/java/com/android/internal/telephony/euicc/EuiccCardController.java b/src/java/com/android/internal/telephony/euicc/EuiccCardController.java
index 6de3984..4803240 100644
--- a/src/java/com/android/internal/telephony/euicc/EuiccCardController.java
+++ b/src/java/com/android/internal/telephony/euicc/EuiccCardController.java
@@ -478,7 +478,9 @@
@Override
public void onResult(Void result) {
Log.i(TAG, "Request subscription info list refresh after delete.");
- SubscriptionController.getInstance().requestEmbeddedSubscriptionInfoListRefresh();
+ SubscriptionController.getInstance()
+ .requestEmbeddedSubscriptionInfoListRefresh(
+ mUiccController.convertToPublicCardId(cardId));
try {
callback.onComplete(EuiccCardManager.RESULT_OK);
} catch (RemoteException exception) {
@@ -528,7 +530,9 @@
@Override
public void onResult(Void result) {
Log.i(TAG, "Request subscription info list refresh after reset memory.");
- SubscriptionController.getInstance().requestEmbeddedSubscriptionInfoListRefresh();
+ SubscriptionController.getInstance()
+ .requestEmbeddedSubscriptionInfoListRefresh(
+ mUiccController.convertToPublicCardId(cardId));
try {
callback.onComplete(EuiccCardManager.RESULT_OK);
} catch (RemoteException exception) {
@@ -1015,7 +1019,9 @@
@Override
public void onResult(byte[] result) {
Log.i(TAG, "Request subscription info list refresh after install.");
- SubscriptionController.getInstance().requestEmbeddedSubscriptionInfoListRefresh();
+ SubscriptionController.getInstance()
+ .requestEmbeddedSubscriptionInfoListRefresh(
+ mUiccController.convertToPublicCardId(cardId));
try {
callback.onComplete(EuiccCardManager.RESULT_OK, result);
} catch (RemoteException exception) {
diff --git a/src/java/com/android/internal/telephony/euicc/EuiccConnector.java b/src/java/com/android/internal/telephony/euicc/EuiccConnector.java
index 54e5691..a9fd2c5 100644
--- a/src/java/com/android/internal/telephony/euicc/EuiccConnector.java
+++ b/src/java/com/android/internal/telephony/euicc/EuiccConnector.java
@@ -432,8 +432,8 @@
sendMessage(CMD_DOWNLOAD_SUBSCRIPTION, request);
}
- void getEuiccProfileInfoList(GetEuiccProfileInfoListCommandCallback callback) {
- sendMessage(CMD_GET_EUICC_PROFILE_INFO_LIST, callback);
+ void getEuiccProfileInfoList(int cardId, GetEuiccProfileInfoListCommandCallback callback) {
+ sendMessage(CMD_GET_EUICC_PROFILE_INFO_LIST, cardId, 0 /* arg2 */, callback);
}
/** Asynchronously fetch the default downloadable subscription list. */
diff --git a/src/java/com/android/internal/telephony/euicc/EuiccController.java b/src/java/com/android/internal/telephony/euicc/EuiccController.java
index ca36cf0..c42f949 100644
--- a/src/java/com/android/internal/telephony/euicc/EuiccController.java
+++ b/src/java/com/android/internal/telephony/euicc/EuiccController.java
@@ -503,15 +503,17 @@
}
/**
- * Blocking call to {@link EuiccService#onGetEuiccProfileInfoList}.
+ * Blocking call to {@link EuiccService#onGetEuiccProfileInfoList} of the eUICC with card ID
+ * {@code cardId}.
*
* <p>Does not perform permission checks as this is not an exposed API and is only used within
* the phone process.
*/
- public GetEuiccProfileInfoListResult blockingGetEuiccProfileInfoList() {
+ public GetEuiccProfileInfoListResult blockingGetEuiccProfileInfoList(int cardId) {
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<GetEuiccProfileInfoListResult> resultRef = new AtomicReference<>();
mConnector.getEuiccProfileInfoList(
+ cardId,
new EuiccConnector.GetEuiccProfileInfoListCommandCallback() {
@Override
public void onListComplete(GetEuiccProfileInfoListResult result) {
diff --git a/tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java b/tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java
index 60bbff9..b47652c 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java
@@ -71,6 +71,7 @@
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_MCC_MNC_1 = "123456";
private static final String FAKE_MCC_MNC_2 = "456789";
@@ -448,7 +449,7 @@
new EuiccProfileInfo("1", null /* accessRules */, null /* nickname */),
new EuiccProfileInfo("3", null /* accessRules */, null /* nickname */),
};
- when(mEuiccController.blockingGetEuiccProfileInfoList()).thenReturn(
+ when(mEuiccController.blockingGetEuiccProfileInfoList(FAKE_CARD_ID)).thenReturn(
new GetEuiccProfileInfoListResult(
EuiccService.RESULT_OK, euiccProfiles, false /* removable */));
@@ -465,7 +466,7 @@
when(mSubscriptionController.getSubscriptionInfoListForEmbeddedSubscriptionUpdate(
new String[] { "1", "3"}, false /* removable */)).thenReturn(subInfoList);
- assertTrue(mUpdater.updateEmbeddedSubscriptions());
+ assertTrue(mUpdater.updateEmbeddedSubscriptions(FAKE_CARD_ID));
// 3 is new and so a new entry should have been created.
verify(mSubscriptionController).insertEmptySubInfoRecord(
@@ -499,7 +500,7 @@
@SmallTest
public void testUpdateEmbeddedSubscriptions_listFailure() throws Exception {
when(mEuiccManager.isEnabled()).thenReturn(true);
- when(mEuiccController.blockingGetEuiccProfileInfoList())
+ when(mEuiccController.blockingGetEuiccProfileInfoList(FAKE_CARD_ID))
.thenReturn(new GetEuiccProfileInfoListResult(
42, null /* subscriptions */, false /* removable */));
@@ -516,7 +517,7 @@
when(mSubscriptionController.getSubscriptionInfoListForEmbeddedSubscriptionUpdate(
new String[0], false /* removable */)).thenReturn(subInfoList);
- assertTrue(mUpdater.updateEmbeddedSubscriptions());
+ assertTrue(mUpdater.updateEmbeddedSubscriptions(FAKE_CARD_ID));
// No new entries should be created.
verify(mSubscriptionController, times(0)).clearSubInfo();
@@ -541,7 +542,7 @@
@SmallTest
public void testUpdateEmbeddedSubscriptions_emptyToEmpty() throws Exception {
when(mEuiccManager.isEnabled()).thenReturn(true);
- when(mEuiccController.blockingGetEuiccProfileInfoList())
+ when(mEuiccController.blockingGetEuiccProfileInfoList(FAKE_CARD_ID))
.thenReturn(new GetEuiccProfileInfoListResult(
42, null /* subscriptions */, true /* removable */));
@@ -554,7 +555,7 @@
when(mSubscriptionController.getSubscriptionInfoListForEmbeddedSubscriptionUpdate(
new String[0], false /* removable */)).thenReturn(subInfoList);
- assertFalse(mUpdater.updateEmbeddedSubscriptions());
+ assertFalse(mUpdater.updateEmbeddedSubscriptions(FAKE_CARD_ID));
// No new entries should be created.
verify(mSubscriptionController, never()).insertEmptySubInfoRecord(anyString(), anyInt());