mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 21:29:54 +01:00
Use the same method as Android to generate the Bluetooth UUID.
This commit is contained in:
@@ -8,6 +8,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
@@ -126,7 +127,7 @@ class BluetoothPlugin implements DuplexPlugin {
|
|||||||
// Generate a (weakly) random UUID and store it
|
// Generate a (weakly) random UUID and store it
|
||||||
byte[] b = new byte[16];
|
byte[] b = new byte[16];
|
||||||
new Random().nextBytes(b);
|
new Random().nextBytes(b);
|
||||||
uuid = StringUtils.toHexString(b);
|
uuid = generateUuid(b);
|
||||||
p.put("uuid", uuid);
|
p.put("uuid", uuid);
|
||||||
callback.setLocalProperties(p);
|
callback.setLocalProperties(p);
|
||||||
}
|
}
|
||||||
@@ -321,7 +322,7 @@ class BluetoothPlugin implements DuplexPlugin {
|
|||||||
if(!running) return null;
|
if(!running) return null;
|
||||||
}
|
}
|
||||||
// Use the invitation code to generate the UUID
|
// Use the invitation code to generate the UUID
|
||||||
String uuid = StringUtils.toHexString(r.nextBytes(16));
|
String uuid = generateUuid(r.nextBytes(16));
|
||||||
// The invitee's device may not be discoverable, so both parties must
|
// The invitee's device may not be discoverable, so both parties must
|
||||||
// try to initiate connections
|
// try to initiate connections
|
||||||
final ConnectionCallback c = new ConnectionCallback(uuid, timeout);
|
final ConnectionCallback c = new ConnectionCallback(uuid, timeout);
|
||||||
@@ -346,6 +347,11 @@ class BluetoothPlugin implements DuplexPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String generateUuid(byte[] b) {
|
||||||
|
UUID uuid = UUID.nameUUIDFromBytes(b);
|
||||||
|
return uuid.toString().replaceAll("-", "");
|
||||||
|
}
|
||||||
|
|
||||||
private void createInvitationConnection(ConnectionCallback c) {
|
private void createInvitationConnection(ConnectionCallback c) {
|
||||||
LocalDevice localDevice;
|
LocalDevice localDevice;
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
|
|||||||
Reference in New Issue
Block a user