Merge changes I0d635067,I1424973b
* changes: Simplify equals() method of ServiceState Update ServiceState.hashCode()
This commit is contained in:
@@ -30,6 +30,7 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains phone state and service related information.
|
* Contains phone state and service related information.
|
||||||
@@ -723,38 +724,40 @@ public class ServiceState implements Parcelable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return ((mVoiceRegState * 31)
|
return Objects.hash(
|
||||||
+ (mDataRegState * 37)
|
mVoiceRegState,
|
||||||
+ mVoiceRoamingType
|
mDataRegState,
|
||||||
+ mDataRoamingType
|
mVoiceRoamingType,
|
||||||
+ mChannelNumber
|
mDataRoamingType,
|
||||||
+ Arrays.hashCode(mCellBandwidths)
|
mChannelNumber,
|
||||||
+ (mIsManualNetworkSelection ? 1 : 0)
|
mCellBandwidths,
|
||||||
+ ((null == mVoiceOperatorAlphaLong) ? 0 : mVoiceOperatorAlphaLong.hashCode())
|
mVoiceOperatorAlphaLong,
|
||||||
+ ((null == mVoiceOperatorAlphaShort) ? 0 : mVoiceOperatorAlphaShort.hashCode())
|
mVoiceOperatorAlphaShort,
|
||||||
+ ((null == mVoiceOperatorNumeric) ? 0 : mVoiceOperatorNumeric.hashCode())
|
mVoiceOperatorNumeric,
|
||||||
+ ((null == mDataOperatorAlphaLong) ? 0 : mDataOperatorAlphaLong.hashCode())
|
mDataOperatorAlphaLong,
|
||||||
+ ((null == mDataOperatorAlphaShort) ? 0 : mDataOperatorAlphaShort.hashCode())
|
mDataOperatorAlphaShort,
|
||||||
+ ((null == mDataOperatorNumeric) ? 0 : mDataOperatorNumeric.hashCode())
|
mDataOperatorNumeric,
|
||||||
+ mCdmaRoamingIndicator
|
mIsManualNetworkSelection,
|
||||||
+ mCdmaDefaultRoamingIndicator
|
mRilVoiceRadioTechnology,
|
||||||
+ (mIsEmergencyOnly ? 1 : 0)
|
mRilDataRadioTechnology,
|
||||||
+ (mIsDataRoamingFromRegistration ? 1 : 0));
|
mCssIndicator,
|
||||||
|
mNetworkId,
|
||||||
|
mSystemId,
|
||||||
|
mCdmaRoamingIndicator,
|
||||||
|
mCdmaDefaultRoamingIndicator,
|
||||||
|
mCdmaEriIconIndex,
|
||||||
|
mCdmaEriIconMode,
|
||||||
|
mIsEmergencyOnly,
|
||||||
|
mIsDataRoamingFromRegistration,
|
||||||
|
mIsUsingCarrierAggregation,
|
||||||
|
mLteEarfcnRsrpBoost,
|
||||||
|
mNetworkRegistrationStates);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals (Object o) {
|
public boolean equals (Object o) {
|
||||||
ServiceState s;
|
if (!(o instanceof ServiceState)) return false;
|
||||||
|
ServiceState s = (ServiceState) o;
|
||||||
try {
|
|
||||||
s = (ServiceState) o;
|
|
||||||
} catch (ClassCastException ex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (o == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (mVoiceRegState == s.mVoiceRegState
|
return (mVoiceRegState == s.mVoiceRegState
|
||||||
&& mDataRegState == s.mDataRegState
|
&& mDataRegState == s.mDataRegState
|
||||||
|
|||||||
Reference in New Issue
Block a user