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

Commit c5707a59 authored by Chaohui Wang's avatar Chaohui Wang
Browse files

Clean up UiccInfoEntity

It's not used any more.

Bug: 348118234
Flag: EXEMPT clean up
Test: manual - on Mobile Settings
Test: atest DefaultSubscriptionControllerTest
Change-Id: Ia287f9171235ff8ab198cdca61deba57981c2a3f
parent f40bd9f5
Loading
Loading
Loading
Loading
+0 −38
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@ package com.android.settingslib.mobile.dataservice;

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

public class DataServiceUtils {

@@ -43,35 +41,6 @@ public class DataServiceUtils {
         * {@see MobileNetworkUtils#isMobileDataEnabled(Context)}.
         */
        public static final String COLUMN_IS_MOBILE_DATA_ENABLED = "isMobileDataEnabled";

        /**
         * The name of the show toggle for physicalSim state column,
         * {@see SubscriptionUtil#showToggleForPhysicalSim(SubscriptionManager)}.
         */
        public static final String COLUMN_SHOW_TOGGLE_FOR_PHYSICAL_SIM = "showToggleForPhysicalSim";
    }

    /**
     * Represents columns of the UiccInfoData table, define these columns from
     * {@link android.telephony.UiccSlotInfo}, {@link android.telephony.UiccCardInfo},
     * {@link UiccSlotMapping} and {@link android.telephony.UiccPortInfo}.If columns of these 4
     * classes are changed, we should also update the table except PII data.
     */
    public static final class UiccInfoData {

        /** The name of the UiccInfoData table. */
        public static final String TABLE_NAME = "uiccInfo";

        /**
         * The name of the ID column, set the {@link SubscriptionInfo#getSubscriptionId()}
         * as the primary key.
         */
        public static final String COLUMN_ID = "sudId";

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

    /**
@@ -139,12 +108,5 @@ public class DataServiceUtils {
         * {@link SubscriptionManager#isActiveSubscriptionId(int)}.
         */
        public static final String COLUMN_IS_ACTIVE_SUBSCRIPTION_ID = "isActiveSubscription";

        /**
         * The name of the active data subscription state column, see
         * {@link SubscriptionManager#getActiveDataSubscriptionId()}.
         */
        public static final String COLUMN_IS_ACTIVE_DATA_SUBSCRIPTION =
                "isActiveDataSubscriptionId";
    }
}
+1 −43
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ import androidx.room.RoomDatabase;
import java.util.List;
import java.util.Objects;

@Database(entities = {SubscriptionInfoEntity.class, UiccInfoEntity.class,
@Database(entities = {SubscriptionInfoEntity.class,
        MobileNetworkInfoEntity.class}, exportSchema = false, version = 1)
public abstract class MobileNetworkDatabase extends RoomDatabase {

@@ -35,8 +35,6 @@ public abstract class MobileNetworkDatabase extends RoomDatabase {

    public abstract SubscriptionInfoDao mSubscriptionInfoDao();

    public abstract UiccInfoDao mUiccInfoDao();

    public abstract MobileNetworkInfoDao mMobileNetworkInfoDao();

    private static MobileNetworkDatabase sInstance;
@@ -72,16 +70,6 @@ public abstract class MobileNetworkDatabase extends RoomDatabase {
        mSubscriptionInfoDao().insertSubsInfo(subscriptionInfo);
    }

    /**
     * Insert the UICC info to the UiccInfoEntity table.
     *
     * @param uiccInfoEntity The uiccInfoEntity.
     */
    public void insertUiccInfo(UiccInfoEntity... uiccInfoEntity) {
        Log.d(TAG, "insertUiccInfo");
        mUiccInfoDao().insertUiccInfo(uiccInfoEntity);
    }

    /**
     * Insert the mobileNetwork info to the MobileNetworkInfoEntity table.
     *
@@ -99,14 +87,6 @@ public abstract class MobileNetworkDatabase extends RoomDatabase {
        return mSubscriptionInfoDao().queryAvailableSubInfos();
    }

    /**
     * Query the subscription info by the subscription ID from the SubscriptionInfoEntity
     * table.
     */
    public SubscriptionInfoEntity querySubInfoById(String id) {
        return mSubscriptionInfoDao().querySubInfoById(id);
    }

    /**
     * Query all mobileNetwork infos from the MobileNetworkInfoEntity
     * table.
@@ -115,21 +95,6 @@ public abstract class MobileNetworkDatabase extends RoomDatabase {
        return mMobileNetworkInfoDao().queryAllMobileNetworkInfos();
    }

    /**
     * Query the mobileNetwork info by the subscription ID from the MobileNetworkInfoEntity
     * table.
     */
    public MobileNetworkInfoEntity queryMobileNetworkInfoById(String id) {
        return mMobileNetworkInfoDao().queryMobileNetworkInfoBySubId(id);
    }

    /**
     * Query all UICC infos from the UiccInfoEntity table.
     */
    public LiveData<List<UiccInfoEntity>> queryAllUiccInfo() {
        return mUiccInfoDao().queryAllUiccInfos();
    }

    /**
     * Delete the subscriptionInfo info by the subscription ID from the SubscriptionInfoEntity
     * table.
@@ -145,11 +110,4 @@ public abstract class MobileNetworkDatabase extends RoomDatabase {
    public void deleteMobileNetworkInfoBySubId(String id) {
        mMobileNetworkInfoDao().deleteBySubId(id);
    }

    /**
     * Delete the UICC info by the subscription ID from the UiccInfoEntity table.
     */
    public void deleteUiccInfoBySubId(String id) {
        mUiccInfoDao().deleteBySubId(id);
    }
}
+2 −11
Original line number Diff line number Diff line
@@ -26,11 +26,9 @@ import androidx.room.PrimaryKey;
@Entity(tableName = DataServiceUtils.MobileNetworkInfoData.TABLE_NAME)
public class MobileNetworkInfoEntity {

    public MobileNetworkInfoEntity(@NonNull String subId, boolean isMobileDataEnabled,
            boolean showToggleForPhysicalSim) {
    public MobileNetworkInfoEntity(@NonNull String subId, boolean isMobileDataEnabled) {
        this.subId = subId;
        this.isMobileDataEnabled = isMobileDataEnabled;
        this.showToggleForPhysicalSim = showToggleForPhysicalSim;
    }

    @PrimaryKey
@@ -41,15 +39,11 @@ public class MobileNetworkInfoEntity {
    @ColumnInfo(name = DataServiceUtils.MobileNetworkInfoData.COLUMN_IS_MOBILE_DATA_ENABLED)
    public boolean isMobileDataEnabled;

    @ColumnInfo(name = DataServiceUtils.MobileNetworkInfoData.COLUMN_SHOW_TOGGLE_FOR_PHYSICAL_SIM)
    public boolean showToggleForPhysicalSim;

    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + subId.hashCode();
        result = 31 * result + Boolean.hashCode(isMobileDataEnabled);
        result = 31 * result + Boolean.hashCode(showToggleForPhysicalSim);
        return result;
    }

@@ -64,8 +58,7 @@ public class MobileNetworkInfoEntity {

        MobileNetworkInfoEntity info = (MobileNetworkInfoEntity) obj;
        return  TextUtils.equals(subId, info.subId)
                && isMobileDataEnabled == info.isMobileDataEnabled
                && showToggleForPhysicalSim == info.showToggleForPhysicalSim;
                && isMobileDataEnabled == info.isMobileDataEnabled;
    }

    public String toString() {
@@ -74,8 +67,6 @@ public class MobileNetworkInfoEntity {
                .append(subId)
                .append(", isMobileDataEnabled = ")
                .append(isMobileDataEnabled)
                .append(", activeNetworkIsCellular = ")
                .append(showToggleForPhysicalSim)
                .append(")}");
        return builder.toString();
    }
+3 −15
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ public class SubscriptionInfoEntity {
    public SubscriptionInfoEntity(@NonNull String subId, int simSlotIndex, boolean isEmbedded,
            boolean isOpportunistic, String uniqueName, boolean isSubscriptionVisible,
            boolean isDefaultSubscriptionSelection, boolean isValidSubscription,
            boolean isActiveSubscriptionId, boolean isActiveDataSubscriptionId) {
            boolean isActiveSubscriptionId) {
        this.subId = subId;
        this.simSlotIndex = simSlotIndex;
        this.isEmbedded = isEmbedded;
@@ -40,7 +40,6 @@ public class SubscriptionInfoEntity {
        this.isDefaultSubscriptionSelection = isDefaultSubscriptionSelection;
        this.isValidSubscription = isValidSubscription;
        this.isActiveSubscriptionId = isActiveSubscriptionId;
        this.isActiveDataSubscriptionId = isActiveDataSubscriptionId;
    }

    @PrimaryKey
@@ -73,17 +72,10 @@ public class SubscriptionInfoEntity {
    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_IS_ACTIVE_SUBSCRIPTION_ID)
    public boolean isActiveSubscriptionId;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_IS_ACTIVE_DATA_SUBSCRIPTION)
    public boolean isActiveDataSubscriptionId;

    public int getSubId() {
        return Integer.valueOf(subId);
    }

    public CharSequence getUniqueDisplayName() {
        return uniqueName;
    }

    public boolean isActiveSubscription() {
        return isActiveSubscriptionId;
    }
@@ -103,8 +95,7 @@ public class SubscriptionInfoEntity {
                isSubscriptionVisible,
                isDefaultSubscriptionSelection,
                isValidSubscription,
                isActiveSubscriptionId,
                isActiveDataSubscriptionId);
                isActiveSubscriptionId);
    }

    @Override
@@ -125,8 +116,7 @@ public class SubscriptionInfoEntity {
                && isSubscriptionVisible == info.isSubscriptionVisible
                && isDefaultSubscriptionSelection == info.isDefaultSubscriptionSelection
                && isValidSubscription == info.isValidSubscription
                && isActiveSubscriptionId == info.isActiveSubscriptionId
                && isActiveDataSubscriptionId == info.isActiveDataSubscriptionId;
                && isActiveSubscriptionId == info.isActiveSubscriptionId;
    }

    public String toString() {
@@ -149,8 +139,6 @@ public class SubscriptionInfoEntity {
                .append(isValidSubscription)
                .append(", isActiveSubscriptionId = ")
                .append(isActiveSubscriptionId)
                .append(", isActiveDataSubscriptionId = ")
                .append(isActiveDataSubscriptionId)
                .append(")}");
        return builder.toString();
    }
+0 −43
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.settingslib.mobile.dataservice;

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 {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertUiccInfo(UiccInfoEntity... uiccInfo);

    @Query("SELECT * FROM " + DataServiceUtils.UiccInfoData.TABLE_NAME + " ORDER BY "
            + DataServiceUtils.UiccInfoData.COLUMN_ID)
    LiveData<List<UiccInfoEntity>> queryAllUiccInfos();

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

    @Query("DELETE FROM " + DataServiceUtils.UiccInfoData.TABLE_NAME + " WHERE "
            + DataServiceUtils.UiccInfoData.COLUMN_ID + " = :id")
    void deleteBySubId(String id);
}
Loading