diff options
8 files changed, 847 insertions, 6 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/DataServiceUtils.java b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/DataServiceUtils.java index 0d6e91183a34..03d9f2db01f2 100644 --- a/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/DataServiceUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/DataServiceUtils.java @@ -41,12 +41,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)}. */ diff --git a/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/MobileNetworkDatabase.java b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/MobileNetworkDatabase.java new file mode 100644 index 000000000000..3c75abf22b22 --- /dev/null +++ b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/MobileNetworkDatabase.java @@ -0,0 +1,154 @@ +/* + * 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 android.content.Context; +import android.util.Log; + +import java.util.List; + +import androidx.lifecycle.LiveData; +import androidx.room.Database; +import androidx.room.Room; +import androidx.room.RoomDatabase; +import androidx.sqlite.db.SupportSQLiteDatabase; + +@Database(entities = {SubscriptionInfoEntity.class, UiccInfoEntity.class, + MobileNetworkInfoEntity.class}, exportSchema = false, version = 1) +public abstract class MobileNetworkDatabase extends RoomDatabase { + + public static final String TAG = "MobileNetworkDatabase"; + public static final String DATABASE_NAME = "mobilenetworksettings_db"; + + public abstract SubscriptionInfoDao mSubscriptionInfoDao(); + + public abstract UiccInfoDao mUiccInfoDao(); + + public abstract MobileNetworkInfoDao mMobileNetworkInfoDao(); + + /** + * Create the MobileNetworkDatabase. + * + * @param context The context. + * @return The MobileNetworkDatabase. + */ + public static MobileNetworkDatabase createDatabase(Context context) { + return Room.databaseBuilder(context, + MobileNetworkDatabase.class, DATABASE_NAME) + .fallbackToDestructiveMigration() + .enableMultiInstanceInvalidation() + .build(); + } + + /** + * Insert the subscription info to the SubscriptionInfoEntity table. + * + * @param subscriptionInfo The subscriptionInfo. + */ + public void insertSubsInfo(SubscriptionInfoEntity... subscriptionInfo) { + Log.d(TAG, "insertSubInfo"); + 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. + * + * @param mobileNetworkInfoEntity The mobileNetworkInfoEntity. + */ + public void insertMobileNetworkInfo(MobileNetworkInfoEntity... mobileNetworkInfoEntity) { + Log.d(TAG, "insertMobileNetworkInfo"); + mMobileNetworkInfoDao().insertMobileNetworkInfo(mobileNetworkInfoEntity); + } + + /** + * Query available subscription infos from the SubscriptionInfoEntity table. + */ + public LiveData<List<SubscriptionInfoEntity>> queryAvailableSubInfos() { + return mSubscriptionInfoDao().queryAvailableSubInfos(); + } + + /** + * Query the subscription info by the subscription ID from the SubscriptionInfoEntity + * table. + */ + public LiveData<SubscriptionInfoEntity> querySubInfoById(String id) { + return mSubscriptionInfoDao().querySubInfoById(id); + } + + /** + * Query all mobileNetwork infos from the MobileNetworkInfoEntity + * table. + */ + public LiveData<List<MobileNetworkInfoEntity>> queryAllMobileNetworkInfo() { + return mMobileNetworkInfoDao().queryAllMobileNetworkInfos(); + } + + /** + * Query the mobileNetwork info by the subscription ID from the MobileNetworkInfoEntity + * table. + */ + public LiveData<MobileNetworkInfoEntity> queryMobileNetworkInfoById(String id) { + return mMobileNetworkInfoDao().queryMobileNetworkInfoBySubId(id); + } + + /** + * Query all UICC infos from the UiccInfoEntity table. + */ + public LiveData<List<UiccInfoEntity>> queryAllUiccInfo() { + 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. + */ + public void deleteSubInfoBySubId(String id) { + mSubscriptionInfoDao().deleteBySubId(id); + } + + /** + * Delete the mobileNetwork info by the subscription ID from the MobileNetworkInfoEntity + * table. + */ + 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); + } +} diff --git a/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/MobileNetworkInfoDao.java b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/MobileNetworkInfoDao.java new file mode 100644 index 000000000000..299a445e14a2 --- /dev/null +++ b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/MobileNetworkInfoDao.java @@ -0,0 +1,53 @@ +/* + * 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 java.util.List; + +import androidx.lifecycle.LiveData; +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; + +@Dao +public interface MobileNetworkInfoDao { + + @Insert(onConflict = OnConflictStrategy.REPLACE) + void insertMobileNetworkInfo(MobileNetworkInfoEntity... mobileNetworkInfo); + + @Query("SELECT * FROM " + DataServiceUtils.MobileNetworkInfoData.TABLE_NAME + " ORDER BY " + + DataServiceUtils.MobileNetworkInfoData.COLUMN_ID) + LiveData<List<MobileNetworkInfoEntity>> queryAllMobileNetworkInfos(); + + @Query("SELECT * FROM " + DataServiceUtils.MobileNetworkInfoData.TABLE_NAME + " WHERE " + + DataServiceUtils.MobileNetworkInfoData.COLUMN_ID + " = :subId") + LiveData<MobileNetworkInfoEntity> queryMobileNetworkInfoBySubId(String subId); + + @Query("SELECT * FROM " + DataServiceUtils.MobileNetworkInfoData.TABLE_NAME + " WHERE " + + DataServiceUtils.MobileNetworkInfoData.COLUMN_IS_MOBILE_DATA_ENABLED + + " = :isMobileDataEnabled") + LiveData<List<MobileNetworkInfoEntity>> queryMobileNetworkInfosByMobileDataStatus( + boolean isMobileDataEnabled); + + @Query("SELECT COUNT(*) FROM " + DataServiceUtils.MobileNetworkInfoData.TABLE_NAME) + int count(); + + @Query("DELETE FROM " + DataServiceUtils.MobileNetworkInfoData.TABLE_NAME + " WHERE " + + DataServiceUtils.MobileNetworkInfoData.COLUMN_ID + " = :subId") + void deleteBySubId(String subId); +} diff --git a/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/MobileNetworkInfoEntity.java b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/MobileNetworkInfoEntity.java new file mode 100644 index 000000000000..a12e0c846748 --- /dev/null +++ b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/MobileNetworkInfoEntity.java @@ -0,0 +1,108 @@ +/* + * 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(); + } +} diff --git a/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/SubscriptionInfoDao.java b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/SubscriptionInfoDao.java new file mode 100644 index 000000000000..45966376ea8a --- /dev/null +++ b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/SubscriptionInfoDao.java @@ -0,0 +1,57 @@ +/* + * 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 java.util.List; + +import androidx.lifecycle.LiveData; +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; +import androidx.room.Update; + +@Dao +public interface SubscriptionInfoDao { + + @Insert(onConflict = OnConflictStrategy.REPLACE) + void insertSubsInfo(SubscriptionInfoEntity... subscriptionInfo); + + @Query("SELECT * FROM " + DataServiceUtils.SubscriptionInfoData.TABLE_NAME + " ORDER BY " + + DataServiceUtils.SubscriptionInfoData.COLUMN_ID) + LiveData<List<SubscriptionInfoEntity>> queryAvailableSubInfos(); + + @Query("SELECT * FROM " + DataServiceUtils.SubscriptionInfoData.TABLE_NAME + " WHERE " + + DataServiceUtils.SubscriptionInfoData.COLUMN_ID + " = :subId") + LiveData<SubscriptionInfoEntity> querySubInfoById(String subId); + + @Query("SELECT * FROM " + DataServiceUtils.SubscriptionInfoData.TABLE_NAME + " WHERE " + + DataServiceUtils.SubscriptionInfoData.COLUMN_IS_ACTIVE_SUBSCRIPTION_ID + + " = :isActiveSubscription" + " AND " + + DataServiceUtils.SubscriptionInfoData.COLUMN_IS_SUBSCRIPTION_VISIBLE + + " = :isSubscriptionVisible") + LiveData<List<SubscriptionInfoEntity>> queryActiveSubInfos( + boolean isActiveSubscription, boolean isSubscriptionVisible); + + @Query("SELECT COUNT(*) FROM " + DataServiceUtils.SubscriptionInfoData.TABLE_NAME) + int count(); + + @Query("DELETE FROM " + DataServiceUtils.SubscriptionInfoData.TABLE_NAME + " WHERE " + + DataServiceUtils.SubscriptionInfoData.COLUMN_ID + " = :id") + void deleteBySubId(String id); + +} diff --git a/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/SubscriptionInfoEntity.java b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/SubscriptionInfoEntity.java new file mode 100644 index 000000000000..329bd9bfb9e7 --- /dev/null +++ b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/SubscriptionInfoEntity.java @@ -0,0 +1,323 @@ +/* + * 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(); + } +} diff --git a/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/UiccInfoDao.java b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/UiccInfoDao.java new file mode 100644 index 000000000000..7e60421d0ab4 --- /dev/null +++ b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/UiccInfoDao.java @@ -0,0 +1,51 @@ +/* + * 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 java.util.List; + +import androidx.lifecycle.LiveData; +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; + +@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 * 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(); + + @Query("DELETE FROM " + DataServiceUtils.UiccInfoData.TABLE_NAME + " WHERE " + + DataServiceUtils.UiccInfoData.COLUMN_ID + " = :id") + void deleteBySubId(String id); +} diff --git a/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/UiccInfoEntity.java b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/UiccInfoEntity.java new file mode 100644 index 000000000000..532462bec193 --- /dev/null +++ b/packages/SettingsLib/src/com/android/settingslib/mobile/dataservice/UiccInfoEntity.java @@ -0,0 +1,101 @@ +/* + * 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(); + } +} |