Revert "Remove /activeProfile + /disableActiveProfile"

This reverts commit dda34b04bb.
This commit is contained in:
Laiteux
2025-10-31 13:14:29 +04:00
parent dda34b04bb
commit 787099479b

View File

@@ -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<String, String> args) throws Exception
{
List<LocalProfileInfo> profiles = withEuiccChannel
(
args,
(channel, _) -> channel.getLpa().getProfiles()
);
var enabledProfile = LPAUtilsKt.getEnabled(profiles);
if (enabledProfile == null)
return empty();
return profile(enabledProfile);
}
private MatrixCursor handleDownloadProfile(Map<String, String> args) throws Exception
{
String[] address = new String[1];
@@ -395,6 +421,41 @@ public class LpaBridgeProvider extends ContentProvider
return success(success);
}
private MatrixCursor handleDisableActiveProfile(Map<String, String> 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<LocalProfileInfo> 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<String, String> args) throws Exception
{
String[] iccid = new String[1];