Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ffd546f authored by Chaohui Wang's avatar Chaohui Wang
Browse files

Clean up UiccInfoEntity unused fields

It's safe since MobileNetworkDatabase is in memory only.

Bug: 348118234
Flag: EXEMPT clean up
Test: manual - check Mobile Settings
Change-Id: Icea406a3c2e633ee51160e51b1af553b4f3034dc
parent 1010a85e
Loading
Loading
Loading
Loading
+5 −37
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
import android.telephony.UiccCardInfo;
import android.telephony.UiccPortInfo;
import android.telephony.UiccSlotInfo;
import android.util.ArrayMap;
@@ -86,12 +85,6 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
    private AirplaneModeObserver mAirplaneModeObserver;
    private MetricsFeatureProvider mMetricsFeatureProvider;
    private int mPhysicalSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
    private int mLogicalSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
    private int mCardState = UiccSlotInfo.CARD_STATE_INFO_ABSENT;
    private int mPortIndex = TelephonyManager.INVALID_PORT_INDEX;
    private int mCardId = TelephonyManager.UNINITIALIZED_CARD_ID;
    private boolean mIsEuicc = false;
    private boolean mIsRemovable = false;
    private boolean mIsActive = false;
    private Map<Integer, SubscriptionInfo> mSubscriptionInfoMap = new ArrayMap<>();
    private Map<Integer, TelephonyManager> mTelephonyManagerMap = new HashMap<>();
@@ -301,19 +294,13 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
            UiccSlotInfo curSlotInfo = uiccSlotInfos[i];
            if (curSlotInfo != null && curSlotInfo.getCardStateInfo() == CARD_STATE_INFO_PRESENT) {
                final int index = i;
                mIsEuicc = curSlotInfo.getIsEuicc();
                mCardState = curSlotInfo.getCardStateInfo();
                mIsRemovable = curSlotInfo.isRemovable();
                mCardId = subInfo.getCardId();

                Collection<UiccPortInfo> uiccPortInfos = curSlotInfo.getPorts();
                uiccPortInfos.forEach(portInfo -> {
                    if (portInfo.getPortIndex() == subInfo.getPortIndex()
                            && portInfo.getLogicalSlotIndex() == subInfo.getSimSlotIndex()) {
                        mPhysicalSlotIndex = index;
                        mLogicalSlotIndex = portInfo.getLogicalSlotIndex();
                        mIsActive = portInfo.isActive();
                        mPortIndex = portInfo.getPortIndex();
                    } else if (DEBUG) {
                        Log.d(TAG, "Can not get port index and physicalSlotIndex for subId "
                                + subInfo.getSubscriptionId());
@@ -433,7 +420,7 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
                mMobileNetworkDatabase.insertSubsInfo(subInfoEntity);
                mMetricsFeatureProvider.action(mContext,
                        SettingsEnums.ACTION_MOBILE_NETWORK_DB_INSERT_SUB_INFO, subId);
                insertUiccInfo(subId, telephonyManager);
                insertUiccInfo(subId);
                insertMobileNetworkInfo(subId, telephonyManager);
            }
        } else if (DEBUG) {
@@ -488,8 +475,8 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
        }
    }

    private void insertUiccInfo(int subId, TelephonyManager telephonyManager) {
        UiccInfoEntity uiccInfoEntity = convertToUiccInfoEntity(subId, telephonyManager);
    private void insertUiccInfo(int subId) {
        UiccInfoEntity uiccInfoEntity = convertToUiccInfoEntity(subId);
        if (DEBUG) {
            Log.d(TAG, "uiccInfoEntity = " + uiccInfoEntity);
        }
@@ -532,27 +519,8 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
        );
    }

    private UiccInfoEntity convertToUiccInfoEntity(int subId, TelephonyManager telephonyManager) {
        return new UiccInfoEntity(String.valueOf(subId), String.valueOf(mPhysicalSlotIndex),
                mLogicalSlotIndex, mCardId, mIsEuicc,
                isMultipleEnabledProfilesSupported(telephonyManager), mCardState, mIsRemovable,
                mIsActive, mPortIndex
        );
    }

    private boolean isMultipleEnabledProfilesSupported(TelephonyManager telephonyManager) {
        if (telephonyManager == null) {
            Log.d(TAG, "TelephonyManager is null");
            return false;
        }

        List<UiccCardInfo> cardInfos = telephonyManager.getUiccCardsInfo();
        if (cardInfos == null) {
            Log.d(TAG, "UICC card info list is empty.");
            return false;
        }
        return cardInfos.stream().anyMatch(
                cardInfo -> cardInfo.isMultipleEnabledProfilesSupported());
    private UiccInfoEntity convertToUiccInfoEntity(int subId) {
        return new UiccInfoEntity(String.valueOf(subId), mIsActive);
    }

    @Override