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

Commit b5b81c00 authored by sangyun's avatar sangyun Committed by Sangyun Yun
Browse files

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
parent e207f934
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1044,7 +1044,7 @@ public class SubscriptionDatabaseManager extends Handler {
                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);
+19 −7
Original line number Diff line number Diff line
@@ -454,12 +454,13 @@ public class SubscriptionInfoInternal {
     */
    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 @@ public class SubscriptionInfoInternal {
                + "]";
    }

    @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 @@ public class SubscriptionInfoInternal {
                && 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(
@@ -1430,6 +1433,15 @@ public class SubscriptionInfoInternal {
                && mSatelliteEntitlementPlmns == that.mSatelliteEntitlementPlmns;
    }

    @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,