1) There was a regression in the outgoing multipart transport logic, such that the same 'identifier' byte would be used for all messages (0). This now works correctly. 2) Added some additional heuristics on the receiving side. Now mutlipart containers are only valid for 1hr, and are considered invalid if the container size is different from the multipart message size.
32 lines
711 B
Java
32 lines
711 B
Java
package org.thoughtcrime.securesms.sms;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
public class MultipartSmsIdentifier {
|
|
|
|
private static final MultipartSmsIdentifier instance = new MultipartSmsIdentifier();
|
|
|
|
public static MultipartSmsIdentifier getInstance() {
|
|
return instance;
|
|
}
|
|
|
|
private final HashMap<String, Integer> idMap = new HashMap<String, Integer>();
|
|
|
|
public synchronized byte getIdForRecipient(String recipient) {
|
|
Integer currentId;
|
|
|
|
if (idMap.containsKey(recipient)) {
|
|
currentId = idMap.get(recipient);
|
|
idMap.remove(recipient);
|
|
} else {
|
|
currentId = 0;
|
|
}
|
|
|
|
byte id = currentId.byteValue();
|
|
idMap.put(recipient, (currentId + 1) % 255);
|
|
|
|
return id;
|
|
}
|
|
|
|
}
|