refactor: return boolean values from LocalProfileAssistantImpl

This commit is contained in:
Peter Cai 2022-05-12 19:09:01 -04:00
parent 6032d381d3
commit 3cc1421905
3 changed files with 16 additions and 13 deletions

View file

@ -103,7 +103,7 @@ class OpenEuiccService : EuiccService() {
return RESULT_FIRST_USER return RESULT_FIRST_USER
} }
return if (channel.lpa.deleteProfile(iccid, Progress()) == "0") { return if (channel.lpa.deleteProfile(iccid, Progress())) {
RESULT_OK RESULT_OK
} else { } else {
RESULT_FIRST_USER RESULT_FIRST_USER
@ -135,13 +135,13 @@ class OpenEuiccService : EuiccService() {
it.state == LocalProfileInfo.State.Enabled it.state == LocalProfileInfo.State.Enabled
} ?: return RESULT_OK } ?: return RESULT_OK
return if (channel.lpa.disableProfile(activeProfile.iccid, Progress()) == "0") { return if (channel.lpa.disableProfile(activeProfile.iccid, Progress())) {
RESULT_OK RESULT_OK
} else { } else {
RESULT_FIRST_USER RESULT_FIRST_USER
} }
} else { } else {
return if (channel.lpa.enableProfile(iccid, Progress()) == "0") { return if (channel.lpa.enableProfile(iccid, Progress())) {
RESULT_OK RESULT_OK
} else { } else {
RESULT_FIRST_USER RESULT_FIRST_USER

View file

@ -8,11 +8,11 @@ import java.util.Map;
public interface LocalProfileAssistant { public interface LocalProfileAssistant {
String enableProfile(String iccid, Progress progress); boolean enableProfile(String iccid, Progress progress);
String disableProfile(String iccid, Progress progress); boolean disableProfile(String iccid, Progress progress);
String deleteProfile(String iccid, Progress progress); boolean deleteProfile(String iccid, Progress progress);
String getDefaultSMDP(); String getDefaultSMDP();

View file

@ -25,7 +25,6 @@ import java.util.logging.Logger;
public class LocalProfileAssistantImpl implements LocalProfileAssistant { public class LocalProfileAssistantImpl implements LocalProfileAssistant {
static final String PROFILE_RESULT_SUCESS = "0"; static final String PROFILE_RESULT_SUCESS = "0";
static final String TRIGGER_PROFILE_REFRESH = "FF"; static final String TRIGGER_PROFILE_REFRESH = "FF";
static final String DISABLED_STATE = PROFILE_RESULT_SUCESS;
private static final Logger LOG = Logger.getLogger(LocalProfileAssistantImpl.class.getName()); private static final Logger LOG = Logger.getLogger(LocalProfileAssistantImpl.class.getName());
@ -44,21 +43,25 @@ public class LocalProfileAssistantImpl implements LocalProfileAssistant {
} }
@Override @Override
public String enableProfile(final String iccid, public boolean enableProfile(final String iccid,
final Progress progress) { final Progress progress) {
return new EnableProfileWorker(TextUtil.iccidLittleToBig(iccid), progress, apduChannel).run(); return PROFILE_RESULT_SUCESS.equals(
new EnableProfileWorker(TextUtil.iccidLittleToBig(iccid), progress, apduChannel).run()
);
} }
@Override @Override
public String disableProfile(final String iccid, public boolean disableProfile(final String iccid,
final Progress progress) { final Progress progress) {
return new DisableProfileWorker(TextUtil.iccidLittleToBig(iccid), progress, apduChannel).run(); return PROFILE_RESULT_SUCESS.equals(
new DisableProfileWorker(TextUtil.iccidLittleToBig(iccid), progress, apduChannel).run()
);
} }
@Override @Override
public String deleteProfile(final String iccid, public boolean deleteProfile(final String iccid,
final Progress progress) { final Progress progress) {
DeleteProfileWorker deleteProfileWorker = new DeleteProfileWorker(progress, apduChannel); DeleteProfileWorker deleteProfileWorker = new DeleteProfileWorker(progress, apduChannel);
@ -66,7 +69,7 @@ public class LocalProfileAssistantImpl implements LocalProfileAssistant {
LpadWorkerExchange<DeleteProfileWorker.DeleteProfileInputParams> exchange = LpadWorkerExchange<DeleteProfileWorker.DeleteProfileInputParams> exchange =
new LpadWorkerExchange<>(deleteProfileWorker.new DeleteProfileInputParams(TextUtil.iccidLittleToBig(iccid))); new LpadWorkerExchange<>(deleteProfileWorker.new DeleteProfileInputParams(TextUtil.iccidLittleToBig(iccid)));
return deleteProfileWorker.run(exchange); return PROFILE_RESULT_SUCESS.equals(deleteProfileWorker.run(exchange));
} }