From bc97964aad6cdaad92336a64684058cb780a6896 Mon Sep 17 00:00:00 2001 From: yoonjeong Jang Date: Mon, 28 Oct 2019 14:40:01 +0900 Subject: [PATCH] Addition of 'XorEqualsString' method for comparing String Previously, ApnSetting compared two APNs using String with 'XorEqual' method and the result of it used for 'dedupeApnSettings' for DcTracker. For instance, a MMS APN for the specific operator shall be merged with the default(Internet) APN of the same operator's(mccmnc) APN once the result of 'similar' is true. But recently, it didn't merge two similar APNs properly due to 'UNSPECIFIED_STRING' case. So we've added XorEquals for String(XorEqualsString) case. The Issue will happen in the circumstance below. 1.A network operator's similar APNs are saved separately at the APN database(apns-conf.xml) For instance, Add two APNs like below and check the result of merging APNs at DcTracker. :q 2. Two similar APNs shall be merged on the result of ApnSetting's 'similar' method. P => merged Q => not merged Test: Manual Change-Id: I0584310765e246ef16163201282d7db48c44e451 Signed-off-by: yoonjeong Jang --- telephony/java/android/telephony/data/ApnSetting.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/telephony/java/android/telephony/data/ApnSetting.java b/telephony/java/android/telephony/data/ApnSetting.java index 116c05129a96f..e65e032c0cd42 100644 --- a/telephony/java/android/telephony/data/ApnSetting.java +++ b/telephony/java/android/telephony/data/ApnSetting.java @@ -1206,7 +1206,7 @@ public class ApnSetting implements Parcelable { && !other.canHandleType(TYPE_DUN) && Objects.equals(this.mApnName, other.mApnName) && !typeSameAny(this, other) - && xorEquals(this.mProxyAddress, other.mProxyAddress) + && xorEqualsString(this.mProxyAddress, other.mProxyAddress) && xorEqualsInt(this.mProxyPort, other.mProxyPort) && xorEquals(this.mProtocol, other.mProtocol) && xorEquals(this.mRoamingProtocol, other.mRoamingProtocol) @@ -1215,7 +1215,7 @@ public class ApnSetting implements Parcelable { && Objects.equals(this.mMvnoType, other.mMvnoType) && Objects.equals(this.mMvnoMatchData, other.mMvnoMatchData) && xorEquals(this.mMmsc, other.mMmsc) - && xorEquals(this.mMmsProxyAddress, other.mMmsProxyAddress) + && xorEqualsString(this.mMmsProxyAddress, other.mMmsProxyAddress) && xorEqualsInt(this.mMmsProxyPort, other.mMmsProxyPort)) && Objects.equals(this.mNetworkTypeBitmask, other.mNetworkTypeBitmask) && Objects.equals(mApnSetId, other.mApnSetId) @@ -1228,6 +1228,11 @@ public class ApnSetting implements Parcelable { return first == null || second == null || first.equals(second); } + // Equal or one is null. + private boolean xorEqualsString(String first, String second) { + return TextUtils.isEmpty(first) || TextUtils.isEmpty(second) || first.equals(second); + } + // Equal or one is not specified. private boolean xorEqualsInt(int first, int second) { return first == UNSPECIFIED_INT || second == UNSPECIFIED_INT