Loading src/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -237,7 +237,7 @@ public class IccPhoneBookInterfaceManager { Request updateRequest = new Request(); synchronized (updateRequest) { Message response = mBaseHandler.obtainMessage(EVENT_UPDATE_DONE, updateRequest); AdnRecord newAdn = new AdnRecord(newTag, newPhoneNumber); AdnRecord newAdn = new AdnRecord(efid, index, newTag, newPhoneNumber); if (mAdnCache != null) { mAdnCache.updateAdnByIndex(efid, newAdn, index, pin2, response); waitForResult(updateRequest); Loading src/java/com/android/internal/telephony/uicc/AdnRecord.java +41 −3 Original line number Diff line number Diff line Loading @@ -104,6 +104,45 @@ public class AdnRecord implements Parcelable { } }; /** * Returns the maximum number of characters that supported by the alpha tag for a record with * the specified maximum size. */ public static int getMaxAlphaTagBytes(int maxRecordLength) { return Math.max(0, maxRecordLength - FOOTER_SIZE_BYTES); } /** * Encodes the alphaTag to a binary representation supported by the SIM. * * <p>This is the same representation as is used for this field in buildAdnString but there * is no restriction on the length. */ public static byte[] encodeAlphaTag(String alphaTag) { return !TextUtils.isEmpty(alphaTag) ? GsmAlphabet.stringToGsm8BitPacked(alphaTag) : new byte[0]; } /** * Decodes an encoded alphaTag from a record or encoded tag. * * <p>This is the same as is used to construct an AdnRecord from byte[] */ public static String decodeAlphaTag(byte[] encodedTagOrRecord, int offset, int length) { return IccUtils.adnStringFieldToString(encodedTagOrRecord, offset, length); } /** * Returns the maximum number of digits (or other dialable characters) that can be stored in * the phone number. * * <p>Additional length is supported via the ext1 entity file but the current implementation * doesn't support writing of that file so it is not included in this calculation. */ public static int getMaxPhoneNumberDigits() { // Multiply by 2 because it is packed BCD encoded (2 digits per byte). return (ADN_DIALING_NUMBER_END - ADN_DIALING_NUMBER_START + 1) * 2; } //***** Constructor @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) Loading Loading @@ -260,8 +299,7 @@ public class AdnRecord implements Parcelable { return null; } byteTag = !TextUtils.isEmpty(mAlphaTag) ? GsmAlphabet.stringToGsm8BitPacked(mAlphaTag) : new byte[0]; byteTag = encodeAlphaTag(mAlphaTag); if (byteTag.length > footerOffset) { Rlog.w(LOG_TAG, "[buildAdnString] Max length of tag is " + footerOffset); Loading Loading @@ -329,7 +367,7 @@ public class AdnRecord implements Parcelable { private void parseRecord(byte[] record) { try { mAlphaTag = IccUtils.adnStringFieldToString( mAlphaTag = decodeAlphaTag( record, 0, record.length - FOOTER_SIZE_BYTES); int footerOffset = record.length - FOOTER_SIZE_BYTES; Loading src/java/com/android/internal/telephony/uicc/AdnRecordCache.java +3 −1 Original line number Diff line number Diff line Loading @@ -124,7 +124,9 @@ public class AdnRecordCache extends Handler implements IccConstants { case EF_FDN: return EF_EXT2; case EF_MSISDN: return EF_EXT1; case EF_PBR: return 0; // The EF PBR doesn't have an extension record default: return -1; default: // See TS 131.102 4.4.2.1 '4FXX' are entity files from EF PBR return (0x4FFF & efid) == efid ? 0 : -1; } } Loading tests/telephonytests/src/com/android/internal/telephony/AdnRecordTest.java +21 −3 Original line number Diff line number Diff line Loading @@ -16,14 +16,18 @@ package com.android.internal.telephony; import static com.google.common.truth.Truth.assertThat; import android.os.Parcel; import java.util.Arrays; import junit.framework.TestCase; import android.test.suitebuilder.annotation.SmallTest; import com.android.internal.telephony.uicc.AdnRecord; import com.android.internal.telephony.uicc.IccUtils; import junit.framework.TestCase; import java.util.Arrays; /** * {@hide} */ Loading Loading @@ -189,6 +193,20 @@ public class AdnRecordTest extends TestCase { assertEquals(adn.getNumber(), copy.getNumber()); assertTrue(Arrays.equals(adn.getEmails(), copy.getEmails())); } public void testGetMaxAlphaTagBytes() { assertThat(AdnRecord.getMaxAlphaTagBytes(-1)).isEqualTo(0); assertThat(AdnRecord.getMaxAlphaTagBytes(0)).isEqualTo(0); assertThat(AdnRecord.getMaxAlphaTagBytes(5)).isEqualTo(0); assertThat(AdnRecord.getMaxAlphaTagBytes(14)).isEqualTo(0); assertThat(AdnRecord.getMaxAlphaTagBytes(15)).isEqualTo(1); assertThat(AdnRecord.getMaxAlphaTagBytes(25)).isEqualTo(11); assertThat(AdnRecord.getMaxAlphaTagBytes(30)).isEqualTo(16); } public void testGetMaxPhoneNumberDigits() { assertThat(AdnRecord.getMaxPhoneNumberDigits()).isEqualTo(20); } } Loading
src/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -237,7 +237,7 @@ public class IccPhoneBookInterfaceManager { Request updateRequest = new Request(); synchronized (updateRequest) { Message response = mBaseHandler.obtainMessage(EVENT_UPDATE_DONE, updateRequest); AdnRecord newAdn = new AdnRecord(newTag, newPhoneNumber); AdnRecord newAdn = new AdnRecord(efid, index, newTag, newPhoneNumber); if (mAdnCache != null) { mAdnCache.updateAdnByIndex(efid, newAdn, index, pin2, response); waitForResult(updateRequest); Loading
src/java/com/android/internal/telephony/uicc/AdnRecord.java +41 −3 Original line number Diff line number Diff line Loading @@ -104,6 +104,45 @@ public class AdnRecord implements Parcelable { } }; /** * Returns the maximum number of characters that supported by the alpha tag for a record with * the specified maximum size. */ public static int getMaxAlphaTagBytes(int maxRecordLength) { return Math.max(0, maxRecordLength - FOOTER_SIZE_BYTES); } /** * Encodes the alphaTag to a binary representation supported by the SIM. * * <p>This is the same representation as is used for this field in buildAdnString but there * is no restriction on the length. */ public static byte[] encodeAlphaTag(String alphaTag) { return !TextUtils.isEmpty(alphaTag) ? GsmAlphabet.stringToGsm8BitPacked(alphaTag) : new byte[0]; } /** * Decodes an encoded alphaTag from a record or encoded tag. * * <p>This is the same as is used to construct an AdnRecord from byte[] */ public static String decodeAlphaTag(byte[] encodedTagOrRecord, int offset, int length) { return IccUtils.adnStringFieldToString(encodedTagOrRecord, offset, length); } /** * Returns the maximum number of digits (or other dialable characters) that can be stored in * the phone number. * * <p>Additional length is supported via the ext1 entity file but the current implementation * doesn't support writing of that file so it is not included in this calculation. */ public static int getMaxPhoneNumberDigits() { // Multiply by 2 because it is packed BCD encoded (2 digits per byte). return (ADN_DIALING_NUMBER_END - ADN_DIALING_NUMBER_START + 1) * 2; } //***** Constructor @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) Loading Loading @@ -260,8 +299,7 @@ public class AdnRecord implements Parcelable { return null; } byteTag = !TextUtils.isEmpty(mAlphaTag) ? GsmAlphabet.stringToGsm8BitPacked(mAlphaTag) : new byte[0]; byteTag = encodeAlphaTag(mAlphaTag); if (byteTag.length > footerOffset) { Rlog.w(LOG_TAG, "[buildAdnString] Max length of tag is " + footerOffset); Loading Loading @@ -329,7 +367,7 @@ public class AdnRecord implements Parcelable { private void parseRecord(byte[] record) { try { mAlphaTag = IccUtils.adnStringFieldToString( mAlphaTag = decodeAlphaTag( record, 0, record.length - FOOTER_SIZE_BYTES); int footerOffset = record.length - FOOTER_SIZE_BYTES; Loading
src/java/com/android/internal/telephony/uicc/AdnRecordCache.java +3 −1 Original line number Diff line number Diff line Loading @@ -124,7 +124,9 @@ public class AdnRecordCache extends Handler implements IccConstants { case EF_FDN: return EF_EXT2; case EF_MSISDN: return EF_EXT1; case EF_PBR: return 0; // The EF PBR doesn't have an extension record default: return -1; default: // See TS 131.102 4.4.2.1 '4FXX' are entity files from EF PBR return (0x4FFF & efid) == efid ? 0 : -1; } } Loading
tests/telephonytests/src/com/android/internal/telephony/AdnRecordTest.java +21 −3 Original line number Diff line number Diff line Loading @@ -16,14 +16,18 @@ package com.android.internal.telephony; import static com.google.common.truth.Truth.assertThat; import android.os.Parcel; import java.util.Arrays; import junit.framework.TestCase; import android.test.suitebuilder.annotation.SmallTest; import com.android.internal.telephony.uicc.AdnRecord; import com.android.internal.telephony.uicc.IccUtils; import junit.framework.TestCase; import java.util.Arrays; /** * {@hide} */ Loading Loading @@ -189,6 +193,20 @@ public class AdnRecordTest extends TestCase { assertEquals(adn.getNumber(), copy.getNumber()); assertTrue(Arrays.equals(adn.getEmails(), copy.getEmails())); } public void testGetMaxAlphaTagBytes() { assertThat(AdnRecord.getMaxAlphaTagBytes(-1)).isEqualTo(0); assertThat(AdnRecord.getMaxAlphaTagBytes(0)).isEqualTo(0); assertThat(AdnRecord.getMaxAlphaTagBytes(5)).isEqualTo(0); assertThat(AdnRecord.getMaxAlphaTagBytes(14)).isEqualTo(0); assertThat(AdnRecord.getMaxAlphaTagBytes(15)).isEqualTo(1); assertThat(AdnRecord.getMaxAlphaTagBytes(25)).isEqualTo(11); assertThat(AdnRecord.getMaxAlphaTagBytes(30)).isEqualTo(16); } public void testGetMaxPhoneNumberDigits() { assertThat(AdnRecord.getMaxPhoneNumberDigits()).isEqualTo(20); } }