For non-active subscriptions, the one inserted in slot but turned off need to be visible to the user. However, the one un-plugged need to be invisble. Since SubscriptionUtil#getSelectableSubscriptionInfoList() didn't cover all the cases required. Create this one to fit into the criteria required here. Bug: 191228344 Test: local Change-Id: Ia68c23b007164b7520456cb6c7427ca142558b59
58 lines
1.9 KiB
Java
58 lines
1.9 KiB
Java
/*
|
|
* Copyright (C) 2021 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
package com.android.settings.network.helper;
|
|
|
|
import android.telephony.TelephonyManager;
|
|
import android.telephony.UiccCardInfo;
|
|
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.atomic.AtomicIntegerArray;
|
|
|
|
/**
|
|
* This is a Callable class which queries valid card ID for eSIM
|
|
*/
|
|
public class QueryEsimCardId implements Callable<AtomicIntegerArray> {
|
|
private static final String TAG = "QueryEsimCardId";
|
|
|
|
private TelephonyManager mTelephonyManager;
|
|
|
|
/**
|
|
* Constructor of class
|
|
* @param TelephonyManager
|
|
*/
|
|
public QueryEsimCardId(TelephonyManager telephonyManager) {
|
|
mTelephonyManager = telephonyManager;
|
|
}
|
|
|
|
/**
|
|
* Implementation of Callable
|
|
* @return card ID(s) in AtomicIntegerArray
|
|
*/
|
|
public AtomicIntegerArray call() {
|
|
List<UiccCardInfo> cardInfos = mTelephonyManager.getUiccCardsInfo();
|
|
if (cardInfos == null) {
|
|
return new AtomicIntegerArray(0);
|
|
}
|
|
return new AtomicIntegerArray(cardInfos.stream()
|
|
.filter(Objects::nonNull)
|
|
.filter(cardInfo -> (!cardInfo.isRemovable()
|
|
&& (cardInfo.getCardId() != TelephonyManager.UNSUPPORTED_CARD_ID)))
|
|
.mapToInt(UiccCardInfo::getCardId)
|
|
.toArray());
|
|
}
|
|
} |