Finish mobile settings if sub id not exists
Could be test with, adb shell am start \ -a android.settings.NETWORK_OPERATOR_SETTINGS \ --ei android.provider.extra.SUB_ID 999 Bug: 336232487 Test: manual - on MobileNetworkSettings Change-Id: I74d5d5b743c40375ceba1ba6e761da901d0d5e65
This commit is contained in:
@@ -65,10 +65,7 @@ import com.android.settingslib.utils.ThreadUtils;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -107,7 +104,7 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
|
|||||||
|
|
||||||
private MobileNetworkRepository mMobileNetworkRepository;
|
private MobileNetworkRepository mMobileNetworkRepository;
|
||||||
private List<SubscriptionInfoEntity> mSubInfoEntityList = new ArrayList<>();
|
private List<SubscriptionInfoEntity> mSubInfoEntityList = new ArrayList<>();
|
||||||
private Map<Integer, SubscriptionInfoEntity> mSubscriptionInfoMap = new HashMap<>();
|
@Nullable
|
||||||
private SubscriptionInfoEntity mSubscriptionInfoEntity;
|
private SubscriptionInfoEntity mSubscriptionInfoEntity;
|
||||||
private MobileNetworkInfoEntity mMobileNetworkInfoEntity;
|
private MobileNetworkInfoEntity mMobileNetworkInfoEntity;
|
||||||
|
|
||||||
@@ -512,38 +509,27 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAvailableSubInfoChanged(List<SubscriptionInfoEntity> subInfoEntityList) {
|
public void onAvailableSubInfoChanged(List<SubscriptionInfoEntity> subInfoEntityList) {
|
||||||
// Check the current subId is existed or not, if so, finish it.
|
|
||||||
if (!mSubscriptionInfoMap.isEmpty()) {
|
|
||||||
|
|
||||||
// Check each subInfo and remove it in the map based on the new list.
|
|
||||||
for (SubscriptionInfoEntity entity : subInfoEntityList) {
|
|
||||||
mSubscriptionInfoMap.remove(Integer.parseInt(entity.subId));
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterator<Integer> iterator = mSubscriptionInfoMap.keySet().iterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
if (iterator.next() == mSubId && getActivity() != null) {
|
|
||||||
finishFragment();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mSubInfoEntityList = subInfoEntityList;
|
mSubInfoEntityList = subInfoEntityList;
|
||||||
SubscriptionInfoEntity[] entityArray = mSubInfoEntityList.toArray(
|
SubscriptionInfoEntity[] entityArray = mSubInfoEntityList.toArray(
|
||||||
new SubscriptionInfoEntity[0]);
|
new SubscriptionInfoEntity[0]);
|
||||||
|
mSubscriptionInfoEntity = null;
|
||||||
for (SubscriptionInfoEntity entity : entityArray) {
|
for (SubscriptionInfoEntity entity : entityArray) {
|
||||||
int subId = Integer.parseInt(entity.subId);
|
int subId = Integer.parseInt(entity.subId);
|
||||||
mSubscriptionInfoMap.put(subId, entity);
|
if (subId == mSubId) {
|
||||||
if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID && subId == mSubId) {
|
|
||||||
mSubscriptionInfoEntity = entity;
|
mSubscriptionInfoEntity = entity;
|
||||||
Log.d(LOG_TAG, "Set subInfo for subId " + mSubId);
|
Log.d(LOG_TAG, "Set subInfo for subId " + mSubId);
|
||||||
break;
|
break;
|
||||||
} else if (entity.isDefaultSubscriptionSelection) {
|
} else if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID
|
||||||
|
&& entity.isDefaultSubscriptionSelection) {
|
||||||
mSubscriptionInfoEntity = entity;
|
mSubscriptionInfoEntity = entity;
|
||||||
Log.d(LOG_TAG, "Set subInfo to default subInfo.");
|
Log.d(LOG_TAG, "Set subInfo to default subInfo.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mSubscriptionInfoEntity == null && getActivity() != null) {
|
||||||
|
// If the current subId is not existed, finish it.
|
||||||
|
finishFragment();
|
||||||
|
return;
|
||||||
|
}
|
||||||
onSubscriptionDetailChanged();
|
onSubscriptionDetailChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user