PeerAdvertisementFactory { public static UUID generateNewProvideBluetoothMacAddressRequestUuid(UUID serviceUuid) { UUID provideBluetoothMacAddressRequestUuid = null; if (serviceUuid != null) { provideBluetoothMacAddressRequestUuid = serviceUuid; while (serviceUuid.compareTo(provideBluetoothMacAddressRequestUuid) == 0) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < BluetoothUtils.BLUETOOTH_ADDRESS_BYTE_COUNT; ++i) { stringBuilder.append(BlePeerDiscoveryUtils.generatedRandomByteAsHexString()); } provideBluetoothMacAddressRequestUuid = createProvideBluetoothMacAddressUuid(serviceUuid, stringBuilder.toString()); } } return provideBluetoothMacAddressRequestUuid; }  static AdvertiseData createAdvertiseDataToServiceData(
            UUID serviceUuid, int beaconAdExtraInformation, String bluetoothMacAddress); static AdvertiseData createAdvertiseDataToServiceData(
            UUID serviceUuid, int beaconAdExtraInformation, String bluetoothMacAddress,
            AdvertiseData.Builder builder); static AdvertiseData createAdvertiseDataToManufacturerData(
            int manufacturerId, int beaconAdLengthAndType, UUID serviceUuid,
            int beaconAdExtraInformation, String bluetoothMacAddress); static AdvertiseData createAdvertiseDataToManufacturerData(
            int manufacturerId, int beaconAdLengthAndType, UUID serviceUuid,
            int beaconAdExtraInformation, String bluetoothMacAddress,
            AdvertiseData.Builder builder, ByteArrayOutputStream byteArrayOutputStream,
            DataOutput dataOutputStream); static PeerProperties parsedAdvertisementToPeerProperties(
            BlePeerDiscoveryUtils.ParsedAdvertisement parsedAdvertisement); static PeerProperties manufacturerDataToPeerProperties(byte[] manufacturerData, UUID serviceUuid); static UUID createProvideBluetoothMacAddressUuid(UUID serviceUuid, String requestId); static UUID generateNewProvideBluetoothMacAddressRequestUuid(UUID serviceUuid); static String parseRequestIdFromUuid(UUID provideBluetoothMacAddressRequestUuid);  }
@Test public void testGenerateNewProvideBluetoothMacAddressRequestUuid() throws Exception { UUID serviceUuid = new UUID(1, 2); UUID genUUID = PeerAdvertisementFactory.generateNewProvideBluetoothMacAddressRequestUuid(serviceUuid); assertThat("The most significant bits are equal", genUUID.getMostSignificantBits(), is(serviceUuid.getMostSignificantBits())); assertThat("The least significant bits are different", genUUID.getLeastSignificantBits(), is(not(serviceUuid.getLeastSignificantBits()))); serviceUuid = new UUID(999999999, 999999999); genUUID = PeerAdvertisementFactory.generateNewProvideBluetoothMacAddressRequestUuid(serviceUuid); assertThat("The most significant bits are equal", genUUID.getMostSignificantBits(), is(serviceUuid.getMostSignificantBits())); assertThat("The least significant bits are different", genUUID.getLeastSignificantBits(), is(not(serviceUuid.getLeastSignificantBits()))); }