From b40a26c43d30f475682b59dbbe404bae932b68b0 Mon Sep 17 00:00:00 2001 From: Jun Yin Date: Wed, 24 Jan 2018 12:13:37 -0800 Subject: Adds stripTrailingFs This function removes padding 'F' characters in a string (e.g., ICCID). Bug: 38206971 Test: unit test in another cl Change-Id: If77604576c5bd26404cdc436f8297191664325a4 --- telephony/java/com/android/internal/telephony/uicc/IccUtils.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/telephony/java/com/android/internal/telephony/uicc/IccUtils.java b/telephony/java/com/android/internal/telephony/uicc/IccUtils.java index 9f8b3a822c81..c0954385a0a3 100644 --- a/telephony/java/com/android/internal/telephony/uicc/IccUtils.java +++ b/telephony/java/com/android/internal/telephony/uicc/IccUtils.java @@ -836,6 +836,13 @@ public class IccUtils { return new String(new char[] {HEX_CHARS[(b & 0xFF) >>> 4], HEX_CHARS[b & 0xF]}); } + /** + * Strip all the trailing 'F' characters of a string, e.g., an ICCID. + */ + public static String stripTrailingFs(String s) { + return s == null ? null : s.replaceAll("(?i)f*$", ""); + } + /** * Converts a character of [0-9a-aA-F] to its hex value in a byte. If the character is not a * hex number, 0 will be returned. -- cgit v1.2.3-59-g8ed1b