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

Commit f2a26055 authored by Chaohui Wang's avatar Chaohui Wang Committed by Android (Google) Code Review
Browse files

Merge "Clean up UiccInfoEntity unused fields" into main

parents ca7304ae f4b980a4
Loading
Loading
Loading
Loading
+0 −46
Original line number Diff line number Diff line
@@ -18,9 +18,7 @@ package com.android.settingslib.mobile.dataservice;

import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.UiccCardInfo;
import android.telephony.UiccPortInfo;
import android.telephony.UiccSlotInfo;
import android.telephony.UiccSlotMapping;

public class DataServiceUtils {
@@ -70,54 +68,10 @@ public class DataServiceUtils {
         */
        public static final String COLUMN_ID = "sudId";

        /**
         * The name of the physical slot index column, see
         * {@link UiccSlotMapping#getPhysicalSlotIndex()}.
         */
        public static final String COLUMN_PHYSICAL_SLOT_INDEX = "physicalSlotIndex";

        /**
         * The name of the logical slot index column, see
         * {@link UiccSlotMapping#getLogicalSlotIndex()}.
         */
        public static final String COLUMN_LOGICAL_SLOT_INDEX = "logicalSlotIndex";

        /**
         * The name of the card ID column, see {@link UiccCardInfo#getCardId()}.
         */
        public static final String COLUMN_CARD_ID = "cardId";

        /**
         * The name of the eUICC state column, see {@link UiccCardInfo#isEuicc()}.
         */
        public static final String COLUMN_IS_EUICC = "isEuicc";

        /**
         * The name of the multiple enabled profiles supported state column, see
         * {@link UiccCardInfo#isMultipleEnabledProfilesSupported()}.
         */
        public static final String COLUMN_IS_MULTIPLE_ENABLED_PROFILES_SUPPORTED =
                "isMultipleEnabledProfilesSupported";

        /**
         * The name of the card state column, see {@link UiccSlotInfo#getCardStateInfo()}.
         */
        public static final String COLUMN_CARD_STATE = "cardState";

        /**
         * The name of the removable state column, see {@link UiccSlotInfo#isRemovable()}.
         */
        public static final String COLUMN_IS_REMOVABLE = "isRemovable";

        /**
         * The name of the active state column, see {@link UiccPortInfo#isActive()}.
         */
        public static final String COLUMN_IS_ACTIVE = "isActive";

        /**
         * The name of the port index column, see {@link UiccPortInfo#getPortIndex()}.
         */
        public static final String COLUMN_PORT_INDEX = "portIndex";
    }

    /**
+3 −11
Original line number Diff line number Diff line
@@ -19,14 +19,13 @@ package com.android.settingslib.mobile.dataservice;
import android.content.Context;
import android.util.Log;

import java.util.List;
import java.util.Objects;

import androidx.lifecycle.LiveData;
import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.sqlite.db.SupportSQLiteDatabase;

import java.util.List;
import java.util.Objects;

@Database(entities = {SubscriptionInfoEntity.class, UiccInfoEntity.class,
        MobileNetworkInfoEntity.class}, exportSchema = false, version = 1)
@@ -131,13 +130,6 @@ public abstract class MobileNetworkDatabase extends RoomDatabase {
        return mUiccInfoDao().queryAllUiccInfos();
    }

    /**
     * Query the UICC info by the subscription ID from the UiccInfoEntity table.
     */
    public LiveData<UiccInfoEntity> queryUiccInfoById(String id) {
        return mUiccInfoDao().queryUiccInfoById(id);
    }

    /**
     * Delete the subscriptionInfo info by the subscription ID from the SubscriptionInfoEntity
     * table.
+2 −10
Original line number Diff line number Diff line
@@ -16,14 +16,14 @@

package com.android.settingslib.mobile.dataservice;

import java.util.List;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import java.util.List;

@Dao
public interface UiccInfoDao {

@@ -34,14 +34,6 @@ public interface UiccInfoDao {
            + DataServiceUtils.UiccInfoData.COLUMN_ID)
    LiveData<List<UiccInfoEntity>> queryAllUiccInfos();

    @Query("SELECT * FROM " + DataServiceUtils.UiccInfoData.TABLE_NAME + " WHERE "
            + DataServiceUtils.UiccInfoData.COLUMN_ID + " = :subId")
    LiveData<UiccInfoEntity> queryUiccInfoById(String subId);

    @Query("SELECT * FROM " + DataServiceUtils.UiccInfoData.TABLE_NAME + " WHERE "
            + DataServiceUtils.UiccInfoData.COLUMN_IS_EUICC + " = :isEuicc")
    LiveData<List<UiccInfoEntity>> queryUiccInfosByEuicc(boolean isEuicc);

    @Query("SELECT COUNT(*) FROM " + DataServiceUtils.UiccInfoData.TABLE_NAME)
    int count();

+2 −72
Original line number Diff line number Diff line
@@ -26,20 +26,9 @@ import androidx.room.PrimaryKey;
@Entity(tableName = DataServiceUtils.UiccInfoData.TABLE_NAME)
public class UiccInfoEntity {

    public UiccInfoEntity(@NonNull String subId, @NonNull String physicalSlotIndex,
            int logicalSlotIndex, int cardId, boolean isEuicc,
            boolean isMultipleEnabledProfilesSupported, int cardState, boolean isRemovable,
            boolean isActive, int portIndex) {
    public UiccInfoEntity(@NonNull String subId, boolean isActive) {
        this.subId = subId;
        this.physicalSlotIndex = physicalSlotIndex;
        this.logicalSlotIndex = logicalSlotIndex;
        this.cardId = cardId;
        this.isEuicc = isEuicc;
        this.isMultipleEnabledProfilesSupported = isMultipleEnabledProfilesSupported;
        this.cardState = cardState;
        this.isRemovable = isRemovable;
        this.isActive = isActive;
        this.portIndex = portIndex;
    }

    @PrimaryKey
@@ -47,48 +36,14 @@ public class UiccInfoEntity {
    @NonNull
    public String subId;

    @ColumnInfo(name = DataServiceUtils.UiccInfoData.COLUMN_PHYSICAL_SLOT_INDEX)
    @NonNull
    public String physicalSlotIndex;

    @ColumnInfo(name = DataServiceUtils.UiccInfoData.COLUMN_LOGICAL_SLOT_INDEX)
    public int logicalSlotIndex;

    @ColumnInfo(name = DataServiceUtils.UiccInfoData.COLUMN_CARD_ID)
    public int cardId;

    @ColumnInfo(name = DataServiceUtils.UiccInfoData.COLUMN_IS_EUICC)
    public boolean isEuicc;

    @ColumnInfo(name = DataServiceUtils.UiccInfoData.COLUMN_IS_MULTIPLE_ENABLED_PROFILES_SUPPORTED)
    public boolean isMultipleEnabledProfilesSupported;

    @ColumnInfo(name = DataServiceUtils.UiccInfoData.COLUMN_CARD_STATE)
    public int cardState;

    @ColumnInfo(name = DataServiceUtils.UiccInfoData.COLUMN_IS_REMOVABLE)
    public boolean isRemovable;

    @ColumnInfo(name = DataServiceUtils.UiccInfoData.COLUMN_IS_ACTIVE)
    public boolean isActive;

    @ColumnInfo(name = DataServiceUtils.UiccInfoData.COLUMN_PORT_INDEX)
    public int portIndex;


    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + subId.hashCode();
        result = 31 * result + physicalSlotIndex.hashCode();
        result = 31 * result + logicalSlotIndex;
        result = 31 * result + cardId;
        result = 31 * result + Boolean.hashCode(isEuicc);
        result = 31 * result + Boolean.hashCode(isMultipleEnabledProfilesSupported);
        result = 31 * result + cardState;
        result = 31 * result + Boolean.hashCode(isRemovable);
        result = 31 * result + Boolean.hashCode(isActive);
        result = 31 * result + portIndex;
        return result;
    }

@@ -102,40 +57,15 @@ public class UiccInfoEntity {
        }

        UiccInfoEntity info = (UiccInfoEntity) obj;
        return  TextUtils.equals(subId, info.subId)
                && TextUtils.equals(physicalSlotIndex, info.physicalSlotIndex)
                && logicalSlotIndex == info.logicalSlotIndex
                && cardId == info.cardId
                && isEuicc == info.isEuicc
                && isMultipleEnabledProfilesSupported == info.isMultipleEnabledProfilesSupported
                && cardState == info.cardState
                && isRemovable == info.isRemovable
                && isActive == info.isActive
                && portIndex == info.portIndex;
        return TextUtils.equals(subId, info.subId) && isActive == info.isActive;
    }

    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append(" {UiccInfoEntity(subId = ")
                .append(subId)
                .append(", logicalSlotIndex = ")
                .append(physicalSlotIndex)
                .append(", logicalSlotIndex = ")
                .append(logicalSlotIndex)
                .append(", cardId = ")
                .append(cardId)
                .append(", isEuicc = ")
                .append(isEuicc)
                .append(", isMultipleEnabledProfilesSupported = ")
                .append(isMultipleEnabledProfilesSupported)
                .append(", cardState = ")
                .append(cardState)
                .append(", isRemovable = ")
                .append(isRemovable)
                .append(", isActive = ")
                .append(isActive)
                .append(", portIndex = ")
                .append(portIndex)
                .append(")}");
        return builder.toString();
    }