From 9ca3255c2d0c30b8c56f734f221b30bd2cacecc0 Mon Sep 17 00:00:00 2001 From: Zoey Chen Date: Thu, 8 Dec 2022 22:01:13 +0000 Subject: [PATCH] [Settings] Fix crash and UI error when turn ON/OFF SIM 1. Should update the UI when turn off SIM 2. Fix ConcurrentModificationException Bug: 259487637 Test: manual Change-Id: If30a6b6323ac0237c92dc210bf3953ce86a199ae --- .../settings/network/MobileNetworkRepository.java | 15 +++++++++------ .../network/telephony/MobileNetworkSettings.java | 8 ++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/com/android/settings/network/MobileNetworkRepository.java b/src/com/android/settings/network/MobileNetworkRepository.java index 5de4c726f45..42f15c824b1 100644 --- a/src/com/android/settings/network/MobileNetworkRepository.java +++ b/src/com/android/settings/network/MobileNetworkRepository.java @@ -264,8 +264,7 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions mIsActive = portInfo.isActive(); mPortIndex = portInfo.getPortIndex(); } else if (DEBUG) { - Log.d(TAG, - "Can not get port index and physicalSlotIndex for subId " + Log.d(TAG, "Can not get port index and physicalSlotIndex for subId " + mSubId); } }); @@ -297,8 +296,7 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions setActiveSubInfoList(mActiveSubInfoEntityList); } - private void setActiveSubInfoList( - List activeSubInfoEntityList) { + private void setActiveSubInfoList(List activeSubInfoEntityList) { if (DEBUG) { Log.d(TAG, "onActiveSubInfoChanged, activeSubInfoEntityList = " + activeSubInfoEntityList); @@ -460,11 +458,16 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions if (DEBUG) { Log.d(TAG, "availableSudInfoList from framework is empty, remove all subs"); } - for (SubscriptionInfoEntity info : mAvailableSubInfoEntityList) { + + SubscriptionInfoEntity[] availableInfoArray = mAvailableSubInfoEntityList.toArray( + new SubscriptionInfoEntity[0]); + for (SubscriptionInfoEntity info : availableInfoArray) { deleteAllInfoBySubId(info.subId); } + } else if (availableInfoList != null) { - for (SubscriptionInfo subInfo : availableInfoList) { + SubscriptionInfo[] infoArray = availableInfoList.toArray(new SubscriptionInfo[0]); + for (SubscriptionInfo subInfo : infoArray) { mSubscriptionInfoMap.remove(subInfo.getSubscriptionId()); if (DEBUG) { Log.d(TAG, diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java index 88c365654e5..60f35cd1290 100644 --- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java +++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java @@ -464,10 +464,6 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme @Override public void onAvailableSubInfoChanged(List subInfoEntityList) { - } - - @Override - public void onActiveSubInfoChanged(List subInfoEntityList) { if (DataServiceUtils.shouldUpdateEntityList(mSubInfoEntityList, subInfoEntityList)) { // Check the current subId is existed or not, if so, finish it. @@ -499,6 +495,10 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme } } + @Override + public void onActiveSubInfoChanged(List subInfoEntityList) { + } + @Override public void onAllUiccInfoChanged(List uiccInfoEntityList) { }