From caaddc87f35de6f36f0c4858914d6b888445bcfc Mon Sep 17 00:00:00 2001 From: Chaohui Wang Date: Mon, 6 May 2024 13:51:12 +0800 Subject: [PATCH] Clean up unused params from SubscriptionAnnotation Bug: 338904413 Test: m Settings Change-Id: Ic714066e45bb0050361c8096394929828a871589 --- .../network/helper/QueryEsimCardId.java | 57 ------------------- .../helper/SelectableSubscriptions.java | 15 +---- .../helper/SubscriptionAnnotation.java | 29 ++-------- 3 files changed, 6 insertions(+), 95 deletions(-) delete mode 100644 src/com/android/settings/network/helper/QueryEsimCardId.java diff --git a/src/com/android/settings/network/helper/QueryEsimCardId.java b/src/com/android/settings/network/helper/QueryEsimCardId.java deleted file mode 100644 index 7ac73726070..00000000000 --- a/src/com/android/settings/network/helper/QueryEsimCardId.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 { - 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 cardInfos = mTelephonyManager.getUiccCardsInfo(); - if (cardInfos == null) { - return new AtomicIntegerArray(0); - } - return new AtomicIntegerArray(cardInfos.stream() - .filter(Objects::nonNull) - .filter(cardInfo -> (!cardInfo.isRemovable() && (cardInfo.getCardId() >= 0))) - .mapToInt(UiccCardInfo::getCardId) - .toArray()); - } -} \ No newline at end of file diff --git a/src/com/android/settings/network/helper/SelectableSubscriptions.java b/src/com/android/settings/network/helper/SelectableSubscriptions.java index b4a3b577575..419f4cd9226 100644 --- a/src/com/android/settings/network/helper/SelectableSubscriptions.java +++ b/src/com/android/settings/network/helper/SelectableSubscriptions.java @@ -24,7 +24,6 @@ import android.util.Log; import androidx.annotation.Keep; import androidx.annotation.VisibleForTesting; -import com.android.settings.network.helper.SubscriptionAnnotation; import com.android.settingslib.utils.ThreadUtils; import java.util.Collections; @@ -103,15 +102,6 @@ public class SelectableSubscriptions implements Callable eSimCardId = - ThreadUtils.postOnBackgroundThread(new QueryEsimCardId(telMgr)); - - // query in background thread - Future simSlotIndex = - ThreadUtils.postOnBackgroundThread( - new QuerySimSlotIndex(telMgr, true, true)); - // query in background thread Future activeSimSlotIndex = ThreadUtils.postOnBackgroundThread( @@ -120,16 +110,13 @@ public class SelectableSubscriptions implements Callable subInfoList = mSubscriptions.get(); // wait for result from background thread - List eSimCardIdList = atomicToList(eSimCardId.get()); - List simSlotIndexList = atomicToList(simSlotIndex.get()); List activeSimSlotIndexList = atomicToList(activeSimSlotIndex.get()); // build a list of SubscriptionAnnotation return IntStream.range(0, subInfoList.size()) .mapToObj(subInfoIndex -> new SubscriptionAnnotation.Builder(subInfoList, subInfoIndex)) - .map(annoBdr -> annoBdr.build(mContext, - eSimCardIdList, simSlotIndexList, activeSimSlotIndexList)) + .map(annoBdr -> annoBdr.build(mContext, activeSimSlotIndexList)) .filter(mFilter) .collect(Collectors.collectingAndThen(Collectors.toList(), mFinisher)); } catch (Exception exception) { diff --git a/src/com/android/settings/network/helper/SubscriptionAnnotation.java b/src/com/android/settings/network/helper/SubscriptionAnnotation.java index 79fbf68b6d9..96ce831515c 100644 --- a/src/com/android/settings/network/helper/SubscriptionAnnotation.java +++ b/src/com/android/settings/network/helper/SubscriptionAnnotation.java @@ -16,7 +16,6 @@ package com.android.settings.network.helper; import android.content.Context; -import android.os.ParcelUuid; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; @@ -35,14 +34,11 @@ public class SubscriptionAnnotation { private static final String TAG = "SubscriptionAnnotation"; private SubscriptionInfo mSubInfo; - private int mOrderWithinList; private int mType = TYPE_UNKNOWN; private boolean mIsExisted; private boolean mIsActive; private boolean mIsAllowToDisplay; - public static final ParcelUuid EMPTY_UUID = ParcelUuid.fromString("0-0-0-0-0"); - public static final int TYPE_UNKNOWN = 0x0; public static final int TYPE_PSIM = 0x1; public static final int TYPE_ESIM = 0x2; @@ -52,8 +48,8 @@ public class SubscriptionAnnotation { */ public static class Builder { - private List mSubInfoList; - private int mIndexWithinList; + private final List mSubInfoList; + private final int mIndexWithinList; /** * Constructor of builder @@ -65,10 +61,9 @@ public class SubscriptionAnnotation { mIndexWithinList = indexWithinList; } - public SubscriptionAnnotation build(Context context, List eSimCardId, - List simSlotIndex, List activeSimSlotIndex) { + public SubscriptionAnnotation build(Context context, List activeSimSlotIndex) { return new SubscriptionAnnotation(mSubInfoList, mIndexWithinList, context, - eSimCardId, simSlotIndex, activeSimSlotIndex); + activeSimSlotIndex); } } @@ -78,8 +73,7 @@ public class SubscriptionAnnotation { @Keep @VisibleForTesting protected SubscriptionAnnotation(List subInfoList, int subInfoIndex, - Context context, List eSimCardId, - List simSlotIndex, List activeSimSlotIndexList) { + Context context, List activeSimSlotIndexList) { if ((subInfoIndex < 0) || (subInfoIndex >= subInfoList.size())) { return; } @@ -88,7 +82,6 @@ public class SubscriptionAnnotation { return; } - mOrderWithinList = subInfoIndex; mType = mSubInfo.isEmbedded() ? TYPE_ESIM : TYPE_PSIM; mIsExisted = true; if (mType == TYPE_ESIM) { @@ -104,12 +97,6 @@ public class SubscriptionAnnotation { mIsAllowToDisplay = isDisplayAllowed(context); } - // the index provided during construction of Builder - @Keep - public int getOrderingInList() { - return mOrderWithinList; - } - // type of subscription @Keep public int getType() { @@ -141,12 +128,6 @@ public class SubscriptionAnnotation { mSubInfo.getSubscriptionId(); } - // the grouping UUID - @Keep - public ParcelUuid getGroupUuid() { - return (mSubInfo == null) ? null : mSubInfo.getGroupUuid(); - } - // the SubscriptionInfo @Keep public SubscriptionInfo getSubInfo() {