Skip to content

Commit

Permalink
Use Uuid from Kotlin standard library (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
ykws authored Dec 6, 2024
1 parent 1fce4e2 commit 9333006
Show file tree
Hide file tree
Showing 42 changed files with 156 additions and 151 deletions.
1 change: 0 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-t
kotlinx-io = { module = "org.jetbrains.kotlinx:kotlinx-io-core", version = "0.5.4" }
tuulbox-collections = { module = "com.juul.tuulbox:collections", version.ref = "tuulbox" }
tuulbox-coroutines = { module = "com.juul.tuulbox:coroutines", version.ref = "tuulbox" }
uuid = { module = "com.benasher44:uuid", version = "0.8.4" }
wrappers-bom = { module = "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom", version = "1.0.0-pre.835" }
wrappers-web = { module = "org.jetbrains.kotlin-wrappers:kotlin-web" }

Expand Down
72 changes: 36 additions & 36 deletions kable-core/api/android/kable-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public abstract interface class com/juul/kable/Advertisement {
public abstract fun getUuids ()Ljava/util/List;
public abstract fun isConnectable ()Ljava/lang/Boolean;
public abstract fun manufacturerData (I)[B
public abstract fun serviceData (Ljava/util/UUID;)[B
public abstract fun serviceData (Lkotlin/uuid/Uuid;)[B
}

public abstract interface class com/juul/kable/AndroidPeripheral : com/juul/kable/Peripheral {
Expand Down Expand Up @@ -81,8 +81,8 @@ public final class com/juul/kable/Bluetooth$Availability$Unavailable : com/juul/

public final class com/juul/kable/Bluetooth$BaseUuid {
public static final field INSTANCE Lcom/juul/kable/Bluetooth$BaseUuid;
public final fun plus (I)Ljava/util/UUID;
public final fun plus (J)Ljava/util/UUID;
public final fun plus (I)Lkotlin/uuid/Uuid;
public final fun plus (J)Lkotlin/uuid/Uuid;
public fun toString ()Ljava/lang/String;
}

Expand All @@ -91,8 +91,8 @@ public final class com/juul/kable/BroadcastReceiverFlowKt {
}

public abstract interface class com/juul/kable/Characteristic {
public abstract fun getCharacteristicUuid ()Ljava/util/UUID;
public abstract fun getServiceUuid ()Ljava/util/UUID;
public abstract fun getCharacteristicUuid ()Lkotlin/uuid/Uuid;
public abstract fun getServiceUuid ()Lkotlin/uuid/Uuid;
}

public final class com/juul/kable/Characteristic$Properties {
Expand All @@ -109,20 +109,20 @@ public final class com/juul/kable/Characteristic$Properties {
}

public abstract interface class com/juul/kable/Descriptor {
public abstract fun getCharacteristicUuid ()Ljava/util/UUID;
public abstract fun getDescriptorUuid ()Ljava/util/UUID;
public abstract fun getServiceUuid ()Ljava/util/UUID;
public abstract fun getCharacteristicUuid ()Lkotlin/uuid/Uuid;
public abstract fun getDescriptorUuid ()Lkotlin/uuid/Uuid;
public abstract fun getServiceUuid ()Lkotlin/uuid/Uuid;
}

public final class com/juul/kable/DiscoveredCharacteristic : com/juul/kable/Characteristic {
public final fun copy (Landroid/bluetooth/BluetoothGattCharacteristic;)Lcom/juul/kable/DiscoveredCharacteristic;
public static synthetic fun copy$default (Lcom/juul/kable/DiscoveredCharacteristic;Landroid/bluetooth/BluetoothGattCharacteristic;ILjava/lang/Object;)Lcom/juul/kable/DiscoveredCharacteristic;
public fun equals (Ljava/lang/Object;)Z
public fun getCharacteristicUuid ()Ljava/util/UUID;
public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid;
public final fun getDescriptors ()Ljava/util/List;
public final fun getInstanceId ()I
public final fun getProperties-bty6q6U ()I
public fun getServiceUuid ()Ljava/util/UUID;
public fun getServiceUuid ()Lkotlin/uuid/Uuid;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
Expand All @@ -131,9 +131,9 @@ public final class com/juul/kable/DiscoveredDescriptor : com/juul/kable/Descript
public final fun copy (Landroid/bluetooth/BluetoothGattDescriptor;)Lcom/juul/kable/DiscoveredDescriptor;
public static synthetic fun copy$default (Lcom/juul/kable/DiscoveredDescriptor;Landroid/bluetooth/BluetoothGattDescriptor;ILjava/lang/Object;)Lcom/juul/kable/DiscoveredDescriptor;
public fun equals (Ljava/lang/Object;)Z
public fun getCharacteristicUuid ()Ljava/util/UUID;
public fun getDescriptorUuid ()Ljava/util/UUID;
public fun getServiceUuid ()Ljava/util/UUID;
public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid;
public fun getDescriptorUuid ()Lkotlin/uuid/Uuid;
public fun getServiceUuid ()Lkotlin/uuid/Uuid;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
Expand All @@ -144,7 +144,7 @@ public final class com/juul/kable/DiscoveredService : com/juul/kable/Service {
public fun equals (Ljava/lang/Object;)Z
public final fun getCharacteristics ()Ljava/util/List;
public final fun getInstanceId ()I
public fun getServiceUuid ()Ljava/util/UUID;
public fun getServiceUuid ()Lkotlin/uuid/Uuid;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
Expand Down Expand Up @@ -203,12 +203,12 @@ public final class com/juul/kable/Filter$Name$Prefix : com/juul/kable/Filter$Nam
}

public final class com/juul/kable/Filter$Service : com/juul/kable/Filter {
public fun <init> (Ljava/util/UUID;)V
public final fun component1 ()Ljava/util/UUID;
public final fun copy (Ljava/util/UUID;)Lcom/juul/kable/Filter$Service;
public static synthetic fun copy$default (Lcom/juul/kable/Filter$Service;Ljava/util/UUID;ILjava/lang/Object;)Lcom/juul/kable/Filter$Service;
public fun <init> (Lkotlin/uuid/Uuid;)V
public final fun component1 ()Lkotlin/uuid/Uuid;
public final fun copy (Lkotlin/uuid/Uuid;)Lcom/juul/kable/Filter$Service;
public static synthetic fun copy$default (Lcom/juul/kable/Filter$Service;Lkotlin/uuid/Uuid;ILjava/lang/Object;)Lcom/juul/kable/Filter$Service;
public fun equals (Ljava/lang/Object;)Z
public final fun getUuid ()Ljava/util/UUID;
public final fun getUuid ()Lkotlin/uuid/Uuid;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
Expand Down Expand Up @@ -261,28 +261,28 @@ public final class com/juul/kable/KableInitializer : androidx/startup/Initialize
}

public final class com/juul/kable/LazyCharacteristic : com/juul/kable/Characteristic {
public final fun component1 ()Ljava/util/UUID;
public final fun component2 ()Ljava/util/UUID;
public final fun copy (Ljava/util/UUID;Ljava/util/UUID;)Lcom/juul/kable/LazyCharacteristic;
public static synthetic fun copy$default (Lcom/juul/kable/LazyCharacteristic;Ljava/util/UUID;Ljava/util/UUID;ILjava/lang/Object;)Lcom/juul/kable/LazyCharacteristic;
public final fun component1 ()Lkotlin/uuid/Uuid;
public final fun component2 ()Lkotlin/uuid/Uuid;
public final fun copy (Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)Lcom/juul/kable/LazyCharacteristic;
public static synthetic fun copy$default (Lcom/juul/kable/LazyCharacteristic;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;ILjava/lang/Object;)Lcom/juul/kable/LazyCharacteristic;
public fun equals (Ljava/lang/Object;)Z
public fun getCharacteristicUuid ()Ljava/util/UUID;
public fun getServiceUuid ()Ljava/util/UUID;
public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid;
public fun getServiceUuid ()Lkotlin/uuid/Uuid;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/juul/kable/LazyDescriptor : com/juul/kable/Descriptor {
public fun <init> (Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;)V
public final fun component1 ()Ljava/util/UUID;
public final fun component2 ()Ljava/util/UUID;
public final fun component3 ()Ljava/util/UUID;
public final fun copy (Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;)Lcom/juul/kable/LazyDescriptor;
public static synthetic fun copy$default (Lcom/juul/kable/LazyDescriptor;Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;ILjava/lang/Object;)Lcom/juul/kable/LazyDescriptor;
public fun <init> (Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)V
public final fun component1 ()Lkotlin/uuid/Uuid;
public final fun component2 ()Lkotlin/uuid/Uuid;
public final fun component3 ()Lkotlin/uuid/Uuid;
public final fun copy (Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)Lcom/juul/kable/LazyDescriptor;
public static synthetic fun copy$default (Lcom/juul/kable/LazyDescriptor;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;ILjava/lang/Object;)Lcom/juul/kable/LazyDescriptor;
public fun equals (Ljava/lang/Object;)Z
public fun getCharacteristicUuid ()Ljava/util/UUID;
public fun getDescriptorUuid ()Ljava/util/UUID;
public fun getServiceUuid ()Ljava/util/UUID;
public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid;
public fun getDescriptorUuid ()Lkotlin/uuid/Uuid;
public fun getServiceUuid ()Lkotlin/uuid/Uuid;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
Expand Down Expand Up @@ -452,7 +452,7 @@ public final class com/juul/kable/ScannerKt {
}

public abstract interface class com/juul/kable/Service {
public abstract fun getServiceUuid ()Ljava/util/UUID;
public abstract fun getServiceUuid ()Lkotlin/uuid/Uuid;
}

public final class com/juul/kable/ServicesDiscoveredPeripheral {
Expand Down Expand Up @@ -639,7 +639,7 @@ public final class com/juul/kable/logs/Logging {
}

public abstract interface class com/juul/kable/logs/Logging$DataProcessor {
public abstract fun process ([BLcom/juul/kable/logs/Logging$DataProcessor$Operation;Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;)Ljava/lang/String;
public abstract fun process ([BLcom/juul/kable/logs/Logging$DataProcessor$Operation;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)Ljava/lang/String;
}

public final class com/juul/kable/logs/Logging$DataProcessor$Operation : java/lang/Enum {
Expand Down
72 changes: 36 additions & 36 deletions kable-core/api/jvm/kable-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public abstract interface class com/juul/kable/Advertisement {
public abstract fun getUuids ()Ljava/util/List;
public abstract fun isConnectable ()Ljava/lang/Boolean;
public abstract fun manufacturerData (I)[B
public abstract fun serviceData (Ljava/util/UUID;)[B
public abstract fun serviceData (Lkotlin/uuid/Uuid;)[B
}

public final class com/juul/kable/Bluetooth {
Expand Down Expand Up @@ -40,14 +40,14 @@ public final class com/juul/kable/Bluetooth$Availability$Unavailable : com/juul/

public final class com/juul/kable/Bluetooth$BaseUuid {
public static final field INSTANCE Lcom/juul/kable/Bluetooth$BaseUuid;
public final fun plus (I)Ljava/util/UUID;
public final fun plus (J)Ljava/util/UUID;
public final fun plus (I)Lkotlin/uuid/Uuid;
public final fun plus (J)Lkotlin/uuid/Uuid;
public fun toString ()Ljava/lang/String;
}

public abstract interface class com/juul/kable/Characteristic {
public abstract fun getCharacteristicUuid ()Ljava/util/UUID;
public abstract fun getServiceUuid ()Ljava/util/UUID;
public abstract fun getCharacteristicUuid ()Lkotlin/uuid/Uuid;
public abstract fun getServiceUuid ()Lkotlin/uuid/Uuid;
}

public final class com/juul/kable/Characteristic$Properties {
Expand All @@ -64,30 +64,30 @@ public final class com/juul/kable/Characteristic$Properties {
}

public abstract interface class com/juul/kable/Descriptor {
public abstract fun getCharacteristicUuid ()Ljava/util/UUID;
public abstract fun getDescriptorUuid ()Ljava/util/UUID;
public abstract fun getServiceUuid ()Ljava/util/UUID;
public abstract fun getCharacteristicUuid ()Lkotlin/uuid/Uuid;
public abstract fun getDescriptorUuid ()Lkotlin/uuid/Uuid;
public abstract fun getServiceUuid ()Lkotlin/uuid/Uuid;
}

public final class com/juul/kable/DiscoveredCharacteristic : com/juul/kable/Characteristic {
public fun <init> ()V
public fun getCharacteristicUuid ()Ljava/util/UUID;
public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid;
public final fun getDescriptors ()Ljava/util/List;
public final fun getProperties-bty6q6U ()I
public fun getServiceUuid ()Ljava/util/UUID;
public fun getServiceUuid ()Lkotlin/uuid/Uuid;
}

public final class com/juul/kable/DiscoveredDescriptor : com/juul/kable/Descriptor {
public fun <init> ()V
public fun getCharacteristicUuid ()Ljava/util/UUID;
public fun getDescriptorUuid ()Ljava/util/UUID;
public fun getServiceUuid ()Ljava/util/UUID;
public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid;
public fun getDescriptorUuid ()Lkotlin/uuid/Uuid;
public fun getServiceUuid ()Lkotlin/uuid/Uuid;
}

public final class com/juul/kable/DiscoveredService : com/juul/kable/Service {
public fun <init> ()V
public final fun getCharacteristics ()Ljava/util/List;
public fun getServiceUuid ()Ljava/util/UUID;
public fun getServiceUuid ()Lkotlin/uuid/Uuid;
}

public abstract interface annotation class com/juul/kable/ExperimentalApi : java/lang/annotation/Annotation {
Expand Down Expand Up @@ -144,12 +144,12 @@ public final class com/juul/kable/Filter$Name$Prefix : com/juul/kable/Filter$Nam
}

public final class com/juul/kable/Filter$Service : com/juul/kable/Filter {
public fun <init> (Ljava/util/UUID;)V
public final fun component1 ()Ljava/util/UUID;
public final fun copy (Ljava/util/UUID;)Lcom/juul/kable/Filter$Service;
public static synthetic fun copy$default (Lcom/juul/kable/Filter$Service;Ljava/util/UUID;ILjava/lang/Object;)Lcom/juul/kable/Filter$Service;
public fun <init> (Lkotlin/uuid/Uuid;)V
public final fun component1 ()Lkotlin/uuid/Uuid;
public final fun copy (Lkotlin/uuid/Uuid;)Lcom/juul/kable/Filter$Service;
public static synthetic fun copy$default (Lcom/juul/kable/Filter$Service;Lkotlin/uuid/Uuid;ILjava/lang/Object;)Lcom/juul/kable/Filter$Service;
public fun equals (Ljava/lang/Object;)Z
public final fun getUuid ()Ljava/util/UUID;
public final fun getUuid ()Lkotlin/uuid/Uuid;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
Expand Down Expand Up @@ -183,28 +183,28 @@ public final class com/juul/kable/InternalError : java/lang/Error {
}

public final class com/juul/kable/LazyCharacteristic : com/juul/kable/Characteristic {
public final fun component1 ()Ljava/util/UUID;
public final fun component2 ()Ljava/util/UUID;
public final fun copy (Ljava/util/UUID;Ljava/util/UUID;)Lcom/juul/kable/LazyCharacteristic;
public static synthetic fun copy$default (Lcom/juul/kable/LazyCharacteristic;Ljava/util/UUID;Ljava/util/UUID;ILjava/lang/Object;)Lcom/juul/kable/LazyCharacteristic;
public final fun component1 ()Lkotlin/uuid/Uuid;
public final fun component2 ()Lkotlin/uuid/Uuid;
public final fun copy (Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)Lcom/juul/kable/LazyCharacteristic;
public static synthetic fun copy$default (Lcom/juul/kable/LazyCharacteristic;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;ILjava/lang/Object;)Lcom/juul/kable/LazyCharacteristic;
public fun equals (Ljava/lang/Object;)Z
public fun getCharacteristicUuid ()Ljava/util/UUID;
public fun getServiceUuid ()Ljava/util/UUID;
public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid;
public fun getServiceUuid ()Lkotlin/uuid/Uuid;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class com/juul/kable/LazyDescriptor : com/juul/kable/Descriptor {
public fun <init> (Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;)V
public final fun component1 ()Ljava/util/UUID;
public final fun component2 ()Ljava/util/UUID;
public final fun component3 ()Ljava/util/UUID;
public final fun copy (Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;)Lcom/juul/kable/LazyDescriptor;
public static synthetic fun copy$default (Lcom/juul/kable/LazyDescriptor;Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;ILjava/lang/Object;)Lcom/juul/kable/LazyDescriptor;
public fun <init> (Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)V
public final fun component1 ()Lkotlin/uuid/Uuid;
public final fun component2 ()Lkotlin/uuid/Uuid;
public final fun component3 ()Lkotlin/uuid/Uuid;
public final fun copy (Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)Lcom/juul/kable/LazyDescriptor;
public static synthetic fun copy$default (Lcom/juul/kable/LazyDescriptor;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;ILjava/lang/Object;)Lcom/juul/kable/LazyDescriptor;
public fun equals (Ljava/lang/Object;)Z
public fun getCharacteristicUuid ()Ljava/util/UUID;
public fun getDescriptorUuid ()Ljava/util/UUID;
public fun getServiceUuid ()Ljava/util/UUID;
public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid;
public fun getDescriptorUuid ()Lkotlin/uuid/Uuid;
public fun getServiceUuid ()Lkotlin/uuid/Uuid;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
Expand Down Expand Up @@ -307,7 +307,7 @@ public final class com/juul/kable/ScannerKt {
}

public abstract interface class com/juul/kable/Service {
public abstract fun getServiceUuid ()Ljava/util/UUID;
public abstract fun getServiceUuid ()Lkotlin/uuid/Uuid;
}

public final class com/juul/kable/ServicesDiscoveredPeripheral {
Expand Down Expand Up @@ -470,7 +470,7 @@ public final class com/juul/kable/logs/Logging {
}

public abstract interface class com/juul/kable/logs/Logging$DataProcessor {
public abstract fun process ([BLcom/juul/kable/logs/Logging$DataProcessor$Operation;Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;)Ljava/lang/String;
public abstract fun process ([BLcom/juul/kable/logs/Logging$DataProcessor$Operation;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)Ljava/lang/String;
}

public final class com/juul/kable/logs/Logging$DataProcessor$Operation : java/lang/Enum {
Expand Down
7 changes: 6 additions & 1 deletion kable-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ kotlin {
jvm()

sourceSets {
all {
languageSettings {
optIn("kotlin.uuid.ExperimentalUuidApi")
}
}

commonMain.dependencies {
api(libs.kotlinx.coroutines.core)
api(libs.kotlinx.io)
api(libs.uuid)
implementation(libs.datetime)
implementation(libs.tuulbox.collections)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlin.coroutines.cancellation.CancellationException
import kotlin.time.Duration
import kotlin.uuid.toKotlinUuid

// Number of service discovery attempts to make if no services are discovered.
// https://github.com/JuulLabs/kable/issues/295
Expand Down Expand Up @@ -369,7 +370,7 @@ private val Priority.intValue: Int
}

private val PlatformCharacteristic.configDescriptor: PlatformDescriptor?
get() = descriptors.firstOrNull { clientCharacteristicConfigUuid == it.uuid }
get() = descriptors.firstOrNull { clientCharacteristicConfigUuid == it.uuid.toKotlinUuid() }

private val PlatformCharacteristic.supportsNotify: Boolean
get() = properties and PROPERTY_NOTIFY != 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import kotlinx.coroutines.channels.trySendBlocking
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.filter
import kotlin.uuid.toJavaUuid

internal class BluetoothLeScannerAndroidScanner(
private val filters: List<FilterPredicate>,
Expand Down Expand Up @@ -142,7 +143,7 @@ private fun FilterPredicate.toNativeScanFilter(): ScanFilter =
is Name.Exact -> setDeviceName(filter.exact)
is Address -> setDeviceAddress(filter.address)
is ManufacturerData -> setManufacturerData(filter.id, filter.data, filter.dataMask)
is Service -> setServiceUuid(ParcelUuid(filter.uuid))
is Service -> setServiceUuid(ParcelUuid(filter.uuid.toJavaUuid()))
else -> throw AssertionError("Unsupported filter element")
}
}
Expand Down
Loading

0 comments on commit 9333006

Please sign in to comment.