Show ICCID as little-endian string

We use ICCID as big-endian internally to match the eUICC chip itself,
but the user (and the OS) would prefer the little-endian representation.
This commit is contained in:
Peter Cai 2022-05-02 10:04:15 -04:00
parent 0fdac11e79
commit 5756c48d3d
3 changed files with 13 additions and 1 deletions

View File

@ -147,7 +147,7 @@ class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfilesCh
}
)
binding.provider.text = profile[PROVIDER_NAME.name]
binding.iccid.text = profile[ICCID.name]
binding.iccid.text = profile[ICCID_LITTLE.name]!!
binding.iccid.transformationMethod = PasswordTransformationMethod.getInstance()
}

View File

@ -41,6 +41,7 @@ class ListProfilesWorker {
profileMap.put(ProfileKey.STATE.name(), LocalProfileAssistantImpl.DISABLED_STATE.equals(info.getProfileState().toString()) ? "Disabled" : "Enabled");
profileMap.put(ProfileKey.ICCID.name(), info.getIccid().toString());
profileMap.put(ProfileKey.ICCID_LITTLE.name(), iccidBigToLittle(info.getIccid().toString()));
profileMap.put(ProfileKey.NAME.name(), (info.getProfileName()!=null)?info.getProfileName().toString():"");
profileMap.put(ProfileKey.NICKNAME.name(), (info.getProfileNickname()!=null)?info.getProfileNickname().toString():"");
profileMap.put(ProfileKey.PROVIDER_NAME.name(), (info.getServiceProviderName()!=null)?info.getServiceProviderName().toString():"");
@ -93,4 +94,14 @@ class ListProfilesWorker {
return apduChannel.transmitAPDU(apdu);
}
private String iccidBigToLittle(String iccid) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < iccid.length() / 2; i++) {
builder.append(iccid.charAt(i * 2 + 1));
if (iccid.charAt(i * 2) != 'F')
builder.append(iccid.charAt(i * 2));
}
return builder.toString();
}
}

View File

@ -2,6 +2,7 @@ package com.truphone.lpa.impl;
public enum ProfileKey {
ICCID,
ICCID_LITTLE, // Little Endian
STATE,
NAME,
NICKNAME,