Merge f3e22de14e4463adb785fb797791bc826b765a10 into dc2a74e824327a85b7d2b9f699c6bf3019390954

This commit is contained in:
d-b-w-gain 2026-09-22 21:58:39 +03:00 committed by GitHub
commit 151634e0cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View File

@ -458,10 +458,14 @@ public class CallManager implements AutoCloseable {
}
private String buildConfig(CallState state) {
return buildConfig(state, account.getDeviceId());
}
static String buildConfig(CallState state, int localDeviceId) {
var config = mapper.createObjectNode();
config.put("call_id", Utils.callIdUnsigned(state.callId));
config.put("is_outgoing", state.isOutgoing);
config.put("local_device_id", 1);
config.put("local_device_id", localDeviceId);
return writeJson(config);
}

View File

@ -1,5 +1,6 @@
package org.asamk.signal.manager.helper;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.asamk.signal.manager.api.CallInfo;
import org.asamk.signal.manager.storage.recipients.TestRecipientId;
import org.asamk.signal.manager.util.Utils;
@ -23,6 +24,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
*/
class CallManagerTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
// --- Reflection helpers for private static methods ---
private static final MethodHandle GET_RAW_IDENTITY_KEY_BYTES;
@ -177,6 +180,17 @@ class CallManagerTest {
assertTrue(foundDifferent, "generateCallId returned same value 21 times in a row");
}
@Test
void buildConfig_usesProvidedLinkedDeviceId() throws Exception {
var state = makeCallState(123L, CallInfo.State.RINGING_OUTGOING);
var config = OBJECT_MAPPER.readTree(CallManager.buildConfig(state, 7));
assertEquals(7, config.get("local_device_id").intValue());
assertEquals(123L, config.get("call_id").longValue());
assertTrue(config.get("is_outgoing").booleanValue());
}
// ========================================================================
// handleStateChange state machine tests
//