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

Commit b220fde2 authored by Nathan Harold's avatar Nathan Harold
Browse files

Update ServiceState.hashCode()

hashCode() was missing about 10 fields and was
using some unnecessary bespoke logic to generate
hashes for individual fields. This CL simplifies
the hashCode() implementation and adds the missing
fields.

Bug: 8675309
Test: compilation
Change-Id: I1424973b11fcc6480d6f8c83d5fd0eb1b5533c7f
parent af228ca9
Loading
Loading
Loading
Loading
+29 −17
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * Contains phone state and service related information.
@@ -723,23 +724,34 @@ public class ServiceState implements Parcelable {

    @Override
    public int hashCode() {
        return ((mVoiceRegState * 31)
                + (mDataRegState * 37)
                + mVoiceRoamingType
                + mDataRoamingType
                + mChannelNumber
                + Arrays.hashCode(mCellBandwidths)
                + (mIsManualNetworkSelection ? 1 : 0)
                + ((null == mVoiceOperatorAlphaLong) ? 0 : mVoiceOperatorAlphaLong.hashCode())
                + ((null == mVoiceOperatorAlphaShort) ? 0 : mVoiceOperatorAlphaShort.hashCode())
                + ((null == mVoiceOperatorNumeric) ? 0 : mVoiceOperatorNumeric.hashCode())
                + ((null == mDataOperatorAlphaLong) ? 0 : mDataOperatorAlphaLong.hashCode())
                + ((null == mDataOperatorAlphaShort) ? 0 : mDataOperatorAlphaShort.hashCode())
                + ((null == mDataOperatorNumeric) ? 0 : mDataOperatorNumeric.hashCode())
                + mCdmaRoamingIndicator
                + mCdmaDefaultRoamingIndicator
                + (mIsEmergencyOnly ? 1 : 0)
                + (mIsDataRoamingFromRegistration ? 1 : 0));
        return Objects.hash(
                mVoiceRegState,
                mDataRegState,
                mVoiceRoamingType,
                mDataRoamingType,
                mChannelNumber,
                mCellBandwidths,
                mVoiceOperatorAlphaLong,
                mVoiceOperatorAlphaShort,
                mVoiceOperatorNumeric,
                mDataOperatorAlphaLong,
                mDataOperatorAlphaShort,
                mDataOperatorNumeric,
                mIsManualNetworkSelection,
                mRilVoiceRadioTechnology,
                mRilDataRadioTechnology,
                mCssIndicator,
                mNetworkId,
                mSystemId,
                mCdmaRoamingIndicator,
                mCdmaDefaultRoamingIndicator,
                mCdmaEriIconIndex,
                mCdmaEriIconMode,
                mIsEmergencyOnly,
                mIsDataRoamingFromRegistration,
                mIsUsingCarrierAggregation,
                mLteEarfcnRsrpBoost,
                mNetworkRegistrationStates);
    }

    @Override