Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ flutter {
source '../..'
}

def libpebblecommon_version = '0.1.4'
def coroutinesVersion = "1.6.0"
def libpebblecommon_version = '0.1.7'
def coroutinesVersion = "1.6.4"
def lifecycleVersion = "2.2.0"
def timberVersion = "4.7.1"
def androidxCoreVersion = '1.3.2'
Expand All @@ -108,6 +108,7 @@ def serializationJsonVersion = '1.3.2'

def junitVersion = '4.13.2'
def androidxTestVersion = "1.4.0"
def mockitoVersion = "3.11.1"

dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
Expand All @@ -129,6 +130,10 @@ dependencies {

androidTestImplementation "androidx.test:runner:$androidxTestVersion"
androidTestImplementation "androidx.test:rules:$androidxTestVersion"
androidTestImplementation "androidx.test:monitor:$androidxTestVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "org.mockito:mockito-inline:$mockitoVersion"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion"
}

android.buildTypes.release.ndk.debugSymbolLevel = 'FULL'

This file was deleted.

7 changes: 7 additions & 0 deletions android/app/src/main/kotlin/io/rebble/cobble/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.os.Bundle
import android.os.StrictMode
import android.provider.Settings
import android.text.TextUtils
import android.widget.Toast
Expand All @@ -21,6 +22,12 @@ import java.net.URI

@OptIn(ExperimentalUnsignedTypes::class)
class MainActivity : FlutterActivity() {
init {
StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder()
.detectLeakedClosableObjects()
.penaltyLog()
.build())
}
lateinit var coroutineScope: CoroutineScope
private lateinit var flutterBridges: Set<FlutterBridge>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothDevice
import android.content.Context
import io.rebble.cobble.bluetooth.classic.BlueSerialDriver
import io.rebble.cobble.bluetooth.gatt.PPoGATTServer
import io.rebble.cobble.bluetooth.scan.BleScanner
import io.rebble.cobble.bluetooth.scan.ClassicScanner
import io.rebble.cobble.datasources.FlutterPreferences
Expand All @@ -26,6 +27,7 @@ class BlueCommon @Inject constructor(
private var driver: BlueIO? = null

private var externalIncomingPacketHandler: (suspend (ByteArray) -> Unit)? = null
private var leServer: PPoGATTServer? = null

fun startSingleWatchConnection(macAddress: String): Flow<SingleConnectionStatus> {
bleScanner.stopScan()
Expand All @@ -45,7 +47,10 @@ class BlueCommon @Inject constructor(
fun getTargetTransport(device: BluetoothDevice): BlueIO {
return when {
device.type == BluetoothDevice.DEVICE_TYPE_LE -> { // LE only device
BlueLEDriver(context, protocolHandler, flutterPreferences, incomingPacketsListener)
if (leServer == null) {
leServer = PPoGATTServer(context)
}
BlueLEDriver(context, this.leServer!!, protocolHandler, flutterPreferences, incomingPacketsListener)
}
device.type != BluetoothDevice.DEVICE_TYPE_UNKNOWN -> { // Serial only device or serial/LE
BlueSerialDriver(
Expand Down

This file was deleted.

Loading