From 787099479bb331c05caa11df9a38c46877c7bafd Mon Sep 17 00:00:00 2001 From: Laiteux Date: Fri, 31 Oct 2025 13:14:29 +0400 Subject: [PATCH] Revert "Remove /activeProfile + /disableActiveProfile" This reverts commit dda34b04bb21f17853b79ff6b3aaf7f6effcd75c. --- .../openeuicc/bridge/LpaBridgeProvider.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/im/angry/openeuicc/bridge/LpaBridgeProvider.java b/src/im/angry/openeuicc/bridge/LpaBridgeProvider.java index e077422..8c6a5d8 100644 --- a/src/im/angry/openeuicc/bridge/LpaBridgeProvider.java +++ b/src/im/angry/openeuicc/bridge/LpaBridgeProvider.java @@ -106,6 +106,11 @@ public class LpaBridgeProvider extends ContentProvider // out (many, can be empty): string iccid, bool isEnabled, string name, string nickname rows = handleGetProfiles(args); break; + case "activeProfile": + // in: int slotId, int portId + // out (single, can be empty): string iccid, bool isEnabled, string name, string nickname + rows = handleGetActiveProfile(args); + break; case "downloadProfile": // in: int slotId, int portId, (either {string activationCode} or {string address, string? matchingId}), string? confirmationCode, string? imei // out (single, can be empty): string iccid, bool isEnabled, string name, string nickname @@ -126,6 +131,11 @@ public class LpaBridgeProvider extends ContentProvider // out: bool success rows = handleDisableProfile(args); break; + case "disableActiveProfile": + // in: int slotId, int portId, bool refresh=true + // out: bool success + rows = handleDisableActiveProfile(args); + break; case "switchProfile": // in: int slotId, int portId, string iccid, bool enable=true, bool refresh=true // out: bool success @@ -235,6 +245,22 @@ public class LpaBridgeProvider extends ContentProvider return profiles(profiles); } + private MatrixCursor handleGetActiveProfile(Map args) throws Exception + { + List profiles = withEuiccChannel + ( + args, + (channel, _) -> channel.getLpa().getProfiles() + ); + + var enabledProfile = LPAUtilsKt.getEnabled(profiles); + + if (enabledProfile == null) + return empty(); + + return profile(enabledProfile); + } + private MatrixCursor handleDownloadProfile(Map args) throws Exception { String[] address = new String[1]; @@ -395,6 +421,41 @@ public class LpaBridgeProvider extends ContentProvider return success(success); } + private MatrixCursor handleDisableActiveProfile(Map args) throws Exception + { + boolean[] refresh = new boolean[1]; + + if (!tryGetArgAsBoolean(args, "refresh", refresh)) + refresh[0] = true; + + String iccid = withEuiccChannel + ( + args, + (channel, _) -> LPAUtilsKt.disableActiveProfileKeepIccId(channel.getLpa(), refresh[0]) + ); + + return success(); + + // if (iccid == null) + // return empty(); + + // List profiles = withEuiccChannel + // ( + // args, + // (channel, _) -> channel.getLpa().getProfiles() + // ); + + // var profile = profiles.stream() + // .filter(p -> iccid.equals(p.getIccid())) + // .findFirst() + // .get(); + + // if (profile == null) + // return empty(); + + // return profile(profile); + } + private MatrixCursor handleSwitchProfile(Map args) throws Exception { String[] iccid = new String[1];