Add /setNickname

This commit is contained in:
Laiteux
2025-10-31 11:09:35 +04:00
parent ac9fdd0b75
commit 43ef013211

View File

@@ -81,7 +81,7 @@ public class LpaBridgeProvider extends ContentProvider
break; break;
case "profiles": case "profiles":
// in: slotId, portId // in: slotId, portId
// out (many, can be empty): iccid, isEnabled, displayName // out (many, can be empty): iccid, isEnabled, name, nickname
rows = handleGetProfiles(args); rows = handleGetProfiles(args);
break; break;
case "downloadProfile": case "downloadProfile":
@@ -106,12 +106,12 @@ public class LpaBridgeProvider extends ContentProvider
break; break;
case "activeProfile": case "activeProfile":
// in: slotId, portId // in: slotId, portId
// out (single, can be empty): iccid, isEnabled, displayName // out (single, can be empty): iccid, isEnabled, name, nickname
rows = handleGetActiveProfile(args); rows = handleGetActiveProfile(args);
break; break;
case "disableActiveProfile": case "disableActiveProfile":
// in: slotId, portId, refresh(true) // in: slotId, portId, refresh(true)
// out (single, can be empty): iccid, isEnabled, displayName // out (single, can be empty): iccid, isEnabled, name, nickname
rows = handleDisableActiveProfile(args); rows = handleDisableActiveProfile(args);
break; break;
case "switchProfile": case "switchProfile":
@@ -119,6 +119,11 @@ public class LpaBridgeProvider extends ContentProvider
// out: success // out: success
rows = handleSwitchProfile(args); rows = handleSwitchProfile(args);
break; break;
case "setNickname":
// in: slotId, portId, iccid, nickname
// out: success
rows = handleSetNickname(args);
break;
default: default:
rows = error("unknown_path"); rows = error("unknown_path");
break; break;
@@ -241,7 +246,7 @@ public class LpaBridgeProvider extends ContentProvider
matchingId[0], matchingId[0],
imei, imei,
confirmationCode[0], confirmationCode[0],
new ProfileDownloadCallback() // TODO: move to a static or smth? unsure as this will only be used here anyway new ProfileDownloadCallback()
{ {
@Override @Override
public void onStateUpdate(ProfileDownloadCallback.DownloadState state) public void onStateUpdate(ProfileDownloadCallback.DownloadState state)
@@ -382,7 +387,7 @@ public class LpaBridgeProvider extends ContentProvider
); );
var profile = profiles.stream() var profile = profiles.stream()
.filter(profile -> profile.getIccid().equals(iccid)) .filter(p -> p.getIccid().equals(iccid))
.findFirst() .findFirst()
.orElse(null); // should never be null .orElse(null); // should never be null
@@ -416,6 +421,30 @@ public class LpaBridgeProvider extends ContentProvider
return success(success); return success(success);
} }
private MatrixCursor handleSetNickname(Map<String, String> args) throws Exception
{
String[] iccid = new String[1];
String[] nickname = new String[1];
if (!tryGetArgAsString(args, "iccid", iccid))
return missingArgError("iccid");
if (!tryGetArgAsString(args, "nickname", nickname))
return missingArgError("nickname");
withEuiccChannel
(
args,
(channel, _) ->
{
channel.getLpa().setNickname(iccid[0], nickname[0]);
return null;
}
);
return success();
}
// endregion // endregion
// region LPA Helpers // region LPA Helpers
@@ -593,15 +622,17 @@ public class LpaBridgeProvider extends ContentProvider
{ {
"iccid", "iccid",
"isEnabled", "isEnabled",
"displayName" "name",
"nickname"
}; };
Object[][] rows = profiles.stream() Object[][] rows = profiles.stream()
.map(profile -> new Object[] .map(p -> new Object[]
{ {
profile.getIccid(), p.getIccid(),
LPAUtilsKt.isEnabled(profile), LPAUtilsKt.isEnabled(p),
LPAUtilsKt.getDisplayName(profile) p.getName(),
p.getNickName()
}) })
.toArray(Object[][]::new); .toArray(Object[][]::new);