Compare only values in database when updating SubsciptionInternal

The database threw an IllegalArgumentException due to empty content
when update SubscriptionInternal, which changes the card_id variable
only. To prevent this, Fixed this to compare only the Subscription-
Internal variables in the database and sync them if any different
variable is found.

Bug: 341039283
Test: atest SubscriptionInfoInternalTest, SubscriptionDatabaseManagerTest
Test: basic test data/call/sms/mms
Merged-In: I6b4f76665392763b2e33e1e88a58b6f4fc856f5b
Change-Id: I6b4f76665392763b2e33e1e88a58b6f4fc856f5b
diff --git a/src/java/com/android/internal/telephony/subscription/SubscriptionDatabaseManager.java b/src/java/com/android/internal/telephony/subscription/SubscriptionDatabaseManager.java
index 3d07d47..7596754 100644
--- a/src/java/com/android/internal/telephony/subscription/SubscriptionDatabaseManager.java
+++ b/src/java/com/android/internal/telephony/subscription/SubscriptionDatabaseManager.java
@@ -1044,7 +1044,7 @@
                 throw new IllegalArgumentException("updateSubscription: subscription does not "
                         + "exist. subId=" + subId);
             }
-            if (oldSubInfo.equals(newSubInfo)) return;
+            if (oldSubInfo.equalsDbItemsOnly(newSubInfo)) return;
 
             if (updateDatabase(subId, createDeltaContentValues(oldSubInfo, newSubInfo)) > 0) {
                 mAllSubscriptionInfoInternalCache.put(subId, newSubInfo);
diff --git a/src/java/com/android/internal/telephony/subscription/SubscriptionInfoInternal.java b/src/java/com/android/internal/telephony/subscription/SubscriptionInfoInternal.java
index bb77d5c..c6dee7c 100644
--- a/src/java/com/android/internal/telephony/subscription/SubscriptionInfoInternal.java
+++ b/src/java/com/android/internal/telephony/subscription/SubscriptionInfoInternal.java
@@ -454,12 +454,13 @@
      */
     private final int mIsOnlyNonTerrestrialNetwork;
 
-    // Below are the fields that do not exist in the SimInfo table.
+    // This field does not exist in the SimInfo table.
     /**
      * The card ID of the SIM card. This maps uniquely to {@link #mCardString}.
      */
     private final int mCardId;
 
+    // This field does not exist in the SimInfo table.
     /**
      * Whether group of the subscription is disabled. This is only useful if it's a grouped
      * opportunistic subscription. In this case, if all primary (non-opportunistic) subscriptions
@@ -1370,11 +1371,14 @@
                 + "]";
     }
 
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-        SubscriptionInfoInternal that = (SubscriptionInfoInternal) o;
+    /**
+     * Campare only the columns existing in the SimInfo table and the mapped variables to see if
+     * they are equal.
+     *
+     * @param that SubscriptionInfoInternal to be compared
+     * @return {@code true} if equals.
+     */
+    public boolean equalsDbItemsOnly(@NonNull SubscriptionInfoInternal that) {
         return mId == that.mId && mSimSlotIndex == that.mSimSlotIndex
                 && mDisplayNameSource == that.mDisplayNameSource && mIconTint == that.mIconTint
                 && mDataRoaming == that.mDataRoaming && mIsEmbedded == that.mIsEmbedded
@@ -1407,7 +1411,6 @@
                 && mPortIndex == that.mPortIndex && mUsageSetting == that.mUsageSetting
                 && mLastUsedTPMessageReference == that.mLastUsedTPMessageReference
                 && mUserId == that.mUserId && mIsSatelliteEnabled == that.mIsSatelliteEnabled
-                && mCardId == that.mCardId && mIsGroupDisabled == that.mIsGroupDisabled
                 && mIccId.equals(that.mIccId) && mDisplayName.equals(that.mDisplayName)
                 && mCarrierName.equals(that.mCarrierName) && mNumber.equals(that.mNumber)
                 && mMcc.equals(that.mMcc) && mMnc.equals(that.mMnc) && mEhplmns.equals(
@@ -1431,6 +1434,15 @@
     }
 
     @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        SubscriptionInfoInternal that = (SubscriptionInfoInternal) o;
+        return equalsDbItemsOnly(that)
+                && mCardId == that.mCardId && mIsGroupDisabled == that.mIsGroupDisabled;
+    }
+
+    @Override
     public int hashCode() {
         int result = Objects.hash(mId, mIccId, mSimSlotIndex, mDisplayName, mCarrierName,
                 mDisplayNameSource, mIconTint, mNumber, mDataRoaming, mMcc, mMnc, mEhplmns, mHplmns,