Adding compareIgnoreTrailingFs helper method to compare IccId's

Test: build, manual
Bug: 213434330
Change-Id: I20c37c4178c269b71864220852ba067ff70191ba
This commit is contained in:
sandeepjs
2022-01-24 06:20:31 +00:00
parent 2cebd2b9c9
commit 9560590d89

View File

@@ -24,6 +24,7 @@ import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Build;
import android.telephony.UiccPortInfo;
import android.text.TextUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.GsmAlphabet;
@@ -933,6 +934,13 @@ public class IccUtils {
return s == null ? null : s.replaceAll("(?i)f*$", "");
}
/**
* Strip all the trailing 'F' characters of a string if exists and compare.
*/
public static boolean compareIgnoreTrailingFs(String a, String b) {
return TextUtils.equals(a, b) || TextUtils.equals(stripTrailingFs(a), stripTrailingFs(b));
}
/**
* Converts a character of [0-9a-fA-F] to its hex value in a byte. If the character is not a
* hex number, 0 will be returned.