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

Commit 19219779 authored by Zoey Chen's avatar Zoey Chen
Browse files

[SettingsLibs] Add mobile network room entities

Bug: 236919685
Test: manual
Change-Id: I09a5b52adc29348ae2a09304a6100bf900b92c5d
parent 782fdcc3
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -40,12 +40,6 @@ public class DataServiceUtils {
         */
        public static final String COLUMN_ID = "subId";

        /**
         * The name of the WFC provision column,
         * {@see MobileNetworkUtils#isWfcProvisionedOnDevice(int)}.
         */
        public static final String COLUMN_IS_WFC_PROVISIONED_ON_DEVICE = "isWfcProvisionedOnDevice";

        /**
         * The name of the contact discovery enabled state column,
         * {@see MobileNetworkUtils#isContactDiscoveryEnabled(Context, int)}.
+108 −0
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.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

@Entity(tableName = DataServiceUtils.MobileNetworkInfoData.TABLE_NAME)
public class MobileNetworkInfoEntity {

    public MobileNetworkInfoEntity(@NonNull String subId, boolean isContactDiscoveryEnabled,
            boolean isContactDiscoveryVisible, boolean isMobileDataEnabled, boolean isCdmaOptions,
            boolean isGsmOptions, boolean isWorldMode, boolean shouldDisplayNetworkSelectOptions,
            boolean isTdscdmaSupported, boolean activeNetworkIsCellular,
            boolean showToggleForPhysicalSim) {
        this.subId = subId;
        this.isContactDiscoveryEnabled = isContactDiscoveryEnabled;
        this.isContactDiscoveryVisible = isContactDiscoveryVisible;
        this.isMobileDataEnabled = isMobileDataEnabled;
        this.isCdmaOptions = isCdmaOptions;
        this.isGsmOptions = isGsmOptions;
        this.isWorldMode = isWorldMode;
        this.shouldDisplayNetworkSelectOptions = shouldDisplayNetworkSelectOptions;
        this.isTdscdmaSupported = isTdscdmaSupported;
        this.activeNetworkIsCellular = activeNetworkIsCellular;
        this.showToggleForPhysicalSim = showToggleForPhysicalSim;
    }

    @PrimaryKey
    @ColumnInfo(name = DataServiceUtils.MobileNetworkInfoData.COLUMN_ID, index = true)
    @NonNull
    public String subId;

    @ColumnInfo(name = DataServiceUtils.MobileNetworkInfoData.COLUMN_IS_CONTACT_DISCOVERY_ENABLED)
    public boolean isContactDiscoveryEnabled;

    @ColumnInfo(name = DataServiceUtils.MobileNetworkInfoData.COLUMN_IS_CONTACT_DISCOVERY_VISIBLE)
    public boolean isContactDiscoveryVisible;

    @ColumnInfo(name = DataServiceUtils.MobileNetworkInfoData.COLUMN_IS_MOBILE_DATA_ENABLED)
    public boolean isMobileDataEnabled;

    @ColumnInfo(name = DataServiceUtils.MobileNetworkInfoData.COLUMN_IS_CDMA_OPTIONS)
    public boolean isCdmaOptions;

    @ColumnInfo(name = DataServiceUtils.MobileNetworkInfoData.COLUMN_IS_GSM_OPTIONS)
    public boolean isGsmOptions;

    @ColumnInfo(name = DataServiceUtils.MobileNetworkInfoData.COLUMN_IS_WORLD_MODE)
    public boolean isWorldMode;

    @ColumnInfo(name =
            DataServiceUtils.MobileNetworkInfoData.COLUMN_SHOULD_DISPLAY_NETWORK_SELECT_OPTIONS)
    public boolean shouldDisplayNetworkSelectOptions;

    @ColumnInfo(name = DataServiceUtils.MobileNetworkInfoData.COLUMN_IS_TDSCDMA_SUPPORTED)
    public boolean isTdscdmaSupported;

    @ColumnInfo(name = DataServiceUtils.MobileNetworkInfoData.COLUMN_ACTIVE_NETWORK_IS_CELLULAR)
    public boolean activeNetworkIsCellular;

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

    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append(" {MobileNetworkInfoEntity(subId = ")
                .append(subId)
                .append(", isContactDiscoveryEnabled = ")
                .append(isContactDiscoveryEnabled)
                .append(", isContactDiscoveryVisible = ")
                .append(isContactDiscoveryVisible)
                .append(", isMobileDataEnabled = ")
                .append(isMobileDataEnabled)
                .append(", isCdmaOptions = ")
                .append(isCdmaOptions)
                .append(", isGsmOptions = ")
                .append(isGsmOptions)
                .append(", isWorldMode = ")
                .append(isWorldMode)
                .append(", shouldDisplayNetworkSelectOptions = ")
                .append(shouldDisplayNetworkSelectOptions)
                .append(", isTdscdmaSupported = ")
                .append(isTdscdmaSupported)
                .append(", activeNetworkIsCellular = ")
                .append(activeNetworkIsCellular)
                .append(", showToggleForPhysicalSim = ")
                .append(showToggleForPhysicalSim)
                .append(")}");
        return builder.toString();
    }
}
+323 −0
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 static androidx.room.ForeignKey.CASCADE;

import android.text.TextUtils;

import java.util.Objects;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Index;
import androidx.room.PrimaryKey;

@Entity(tableName = DataServiceUtils.SubscriptionInfoData.TABLE_NAME)
public class SubscriptionInfoEntity {
    public SubscriptionInfoEntity(@NonNull String subId, int simSlotIndex, int carrierId,
            String displayName, String carrierName, int dataRoaming, String mcc, String mnc,
            String countryIso, boolean isEmbedded, int cardId, int portIndex,
            boolean isOpportunistic, @Nullable String groupUUID, int subscriptionType,
            String uniqueName, boolean isSubscriptionVisible, String formattedPhoneNumber,
            boolean isFirstRemovableSubscription, String defaultSimConfig,
            boolean isDefaultSubscriptionSelection, boolean isValidSubscription,
            boolean isUsableSubscription, boolean isActiveSubscriptionId,
            boolean isAvailableSubscription, boolean isDefaultVoiceSubscription,
            boolean isDefaultSmsSubscription, boolean isDefaultDataSubscription,
            boolean isDefaultSubscription) {
        this.subId = subId;
        this.simSlotIndex = simSlotIndex;
        this.carrierId = carrierId;
        this.displayName = displayName;
        this.carrierName = carrierName;
        this.dataRoaming = dataRoaming;
        this.mcc = mcc;
        this.mnc = mnc;
        this.countryIso = countryIso;
        this.isEmbedded = isEmbedded;
        this.cardId = cardId;
        this.portIndex = portIndex;
        this.isOpportunistic = isOpportunistic;
        this.groupUUID = groupUUID;
        this.subscriptionType = subscriptionType;
        this.uniqueName = uniqueName;
        this.isSubscriptionVisible = isSubscriptionVisible;
        this.formattedPhoneNumber = formattedPhoneNumber;
        this.isFirstRemovableSubscription = isFirstRemovableSubscription;
        this.defaultSimConfig = defaultSimConfig;
        this.isDefaultSubscriptionSelection = isDefaultSubscriptionSelection;
        this.isValidSubscription = isValidSubscription;
        this.isUsableSubscription = isUsableSubscription;
        this.isActiveSubscriptionId = isActiveSubscriptionId;
        this.isAvailableSubscription = isAvailableSubscription;
        this.isDefaultVoiceSubscription = isDefaultVoiceSubscription;
        this.isDefaultSmsSubscription = isDefaultSmsSubscription;
        this.isDefaultDataSubscription = isDefaultDataSubscription;
        this.isDefaultSubscription = isDefaultSubscription;
    }

    @PrimaryKey
    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_ID, index = true)
    @NonNull
    public String subId;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_SIM_SLOT_INDEX)
    public int simSlotIndex;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_CARRIER_ID)
    public int carrierId;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_DISPLAY_NAME)
    public String displayName;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_CARRIER_NAME)
    public String carrierName;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_DATA_ROAMING)
    public int dataRoaming;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_MCC)
    public String mcc;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_MNC)
    public String mnc;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_COUNTRY_ISO)
    public String countryIso;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_IS_EMBEDDED)
    public boolean isEmbedded;

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

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

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_IS_OPPORTUNISTIC)
    public boolean isOpportunistic;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_GROUP_UUID)
    @Nullable
    public String groupUUID;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_SUBSCRIPTION_TYPE)
    public int subscriptionType;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_UNIQUE_NAME)
    public String uniqueName;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_IS_SUBSCRIPTION_VISIBLE)
    public boolean isSubscriptionVisible;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_FORMATTED_PHONE_NUMBER)
    public String formattedPhoneNumber;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_IS_FIRST_REMOVABLE_SUBSCRIPTION)
    public boolean isFirstRemovableSubscription;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_DEFAULT_SIM_CONFIG)
    public String defaultSimConfig;

    @ColumnInfo(name =
            DataServiceUtils.SubscriptionInfoData.COLUMN_IS_DEFAULT_SUBSCRIPTION_SELECTION)
    public boolean isDefaultSubscriptionSelection;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_IS_VALID_SUBSCRIPTION)
    public boolean isValidSubscription;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_IS_USABLE_SUBSCRIPTION)
    public boolean isUsableSubscription;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_IS_ACTIVE_SUBSCRIPTION_ID)
    public boolean isActiveSubscriptionId;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_IS_AVAILABLE_SUBSCRIPTION)
    public boolean isAvailableSubscription;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_IS_DEFAULT_VOICE_SUBSCRIPTION)
    public boolean isDefaultVoiceSubscription;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_IS_DEFAULT_SMS_SUBSCRIPTION)
    public boolean isDefaultSmsSubscription;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_IS_DEFAULT_DATA_SUBSCRIPTION)
    public boolean isDefaultDataSubscription;

    @ColumnInfo(name = DataServiceUtils.SubscriptionInfoData.COLUMN_IS_DEFAULT_SUBSCRIPTION)
    public boolean isDefaultSubscription;

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

    public CharSequence getUniqueDisplayName() {
        return uniqueName;
    }

    public boolean isActiveSubscription() {
        return isActiveSubscriptionId;
    }

    public boolean isSubscriptionVisible() {
        return isSubscriptionVisible;
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + subId.hashCode();
        result = 31 * result + simSlotIndex;
        result = 31 * result + carrierId;
        result = 31 * result + displayName.hashCode();
        result = 31 * result + carrierName.hashCode();
        result = 31 * result + dataRoaming;
        result = 31 * result + mcc.hashCode();
        result = 31 * result + mnc.hashCode();
        result = 31 * result + countryIso.hashCode();
        result = 31 * result + Boolean.hashCode(isEmbedded);
        result = 31 * result + cardId;
        result = 31 * result + portIndex;
        result = 31 * result + Boolean.hashCode(isOpportunistic);
        result = 31 * result + groupUUID.hashCode();
        result = 31 * result + subscriptionType;
        result = 31 * result + uniqueName.hashCode();
        result = 31 * result + Boolean.hashCode(isSubscriptionVisible);
        result = 31 * result + formattedPhoneNumber.hashCode();
        result = 31 * result + Boolean.hashCode(isFirstRemovableSubscription);
        result = 31 * result + defaultSimConfig.hashCode();
        result = 31 * result + Boolean.hashCode(isDefaultSubscriptionSelection);
        result = 31 * result + Boolean.hashCode(isValidSubscription);
        result = 31 * result + Boolean.hashCode(isUsableSubscription);
        result = 31 * result + Boolean.hashCode(isActiveSubscriptionId);
        result = 31 * result + Boolean.hashCode(isAvailableSubscription);
        result = 31 * result + Boolean.hashCode(isDefaultVoiceSubscription);
        result = 31 * result + Boolean.hashCode(isDefaultSmsSubscription);
        result = 31 * result + Boolean.hashCode(isDefaultDataSubscription);
        result = 31 * result + Boolean.hashCode(isDefaultSubscription);
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof SubscriptionInfoEntity)) {
            return false;
        }

        SubscriptionInfoEntity info = (SubscriptionInfoEntity) obj;
        return  TextUtils.equals(subId, info.subId)
                && simSlotIndex == info.simSlotIndex
                && carrierId == info.carrierId
                && TextUtils.equals(displayName, info.displayName)
                && TextUtils.equals(carrierName, info.carrierName)
                && dataRoaming == info.dataRoaming
                && TextUtils.equals(mcc, info.mcc)
                && TextUtils.equals(mnc, info.mnc)
                && TextUtils.equals(countryIso, info.countryIso)
                && isEmbedded == info.isEmbedded
                && cardId == info.cardId
                && portIndex == info.portIndex
                && isOpportunistic == info.isOpportunistic
                && TextUtils.equals(groupUUID, info.groupUUID)
                && subscriptionType == info.subscriptionType
                && TextUtils.equals(uniqueName, info.uniqueName)
                && isSubscriptionVisible == info.isSubscriptionVisible
                && TextUtils.equals(formattedPhoneNumber, info.formattedPhoneNumber)
                && isFirstRemovableSubscription == info.isFirstRemovableSubscription
                && TextUtils.equals(defaultSimConfig, info.defaultSimConfig)
                && isDefaultSubscriptionSelection == info.isDefaultSubscriptionSelection
                && isValidSubscription == info.isValidSubscription
                && isUsableSubscription == info.isUsableSubscription
                && isActiveSubscriptionId == info.isActiveSubscriptionId
                && isAvailableSubscription == info.isAvailableSubscription
                && isDefaultVoiceSubscription == info.isDefaultVoiceSubscription
                && isDefaultSmsSubscription == info.isDefaultSmsSubscription
                && isDefaultDataSubscription == info.isDefaultDataSubscription
                && isDefaultSubscription == info.isDefaultSubscription;
    }

    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append(" {SubscriptionInfoEntity(subId = ")
                .append(subId)
                .append(", simSlotIndex = ")
                .append(simSlotIndex)
                .append(", carrierId = ")
                .append(carrierId)
                .append(", displayName = ")
                .append(displayName)
                .append(", carrierName = ")
                .append(carrierName)
                .append(", dataRoaming = ")
                .append(dataRoaming)
                .append(", mcc = ")
                .append(mcc)
                .append(", mnc = ")
                .append(mnc)
                .append(", countryIso = ")
                .append(countryIso)
                .append(", isEmbedded = ")
                .append(isEmbedded)
                .append(", cardId = ")
                .append(cardId)
                .append(", portIndex = ")
                .append(portIndex)
                .append(", isOpportunistic = ")
                .append(isOpportunistic)
                .append(", groupUUID = ")
                .append(groupUUID)
                .append(", subscriptionType = ")
                .append(subscriptionType)
                .append(", uniqueName = ")
                .append(uniqueName)
                .append(", isSubscriptionVisible = ")
                .append(isSubscriptionVisible)
                .append(", formattedPhoneNumber = ")
                .append(formattedPhoneNumber)
                .append(", isFirstRemovableSubscription = ")
                .append(isFirstRemovableSubscription)
                .append(", defaultSimConfig = ")
                .append(defaultSimConfig)
                .append(", isDefaultSubscriptionSelection = ")
                .append(isDefaultSubscriptionSelection)
                .append(", isValidSubscription = ")
                .append(isValidSubscription)
                .append(", isUsableSubscription = ")
                .append(isUsableSubscription)
                .append(", isActiveSubscriptionId = ")
                .append(isActiveSubscriptionId)
                .append(", isAvailableSubscription = ")
                .append(isAvailableSubscription)
                .append(", isDefaultVoiceSubscription = ")
                .append(isDefaultVoiceSubscription)
                .append(", isDefaultSmsSubscription = ")
                .append(isDefaultSmsSubscription)
                .append(", isDefaultDataSubscription = ")
                .append(isDefaultDataSubscription)
                .append(", isDefaultSubscription = ")
                .append(isDefaultSubscription)
                .append(")}");
        return builder.toString();
    }
}
+101 −0
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.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
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) {
        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
    @ColumnInfo(name = DataServiceUtils.UiccInfoData.COLUMN_ID, index = true)
    @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;

    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();
    }
}