From 9f6d67a56730e1ed4cfd9ea08db7f08f19cd3a4e Mon Sep 17 00:00:00 2001 From: mmanningau Date: Fri, 30 Jan 2026 16:40:42 +1100 Subject: [PATCH] Added the debug.keystore to the repo so that I can move between devices and build the app without getting installation errors on the phone. Also updated the testModelActivity to a more robust USB connection permissions testing and connection testing.... --- .idea/misc.xml | 1 - app/.gitignore | 2 +- app/build.gradle.kts | 16 +++++- app/debug.keystore | Bin 0 -> 2618 bytes .../speechtokeyboard/TestModelActivity.kt | 52 +++++++++++++----- 5 files changed, 54 insertions(+), 17 deletions(-) create mode 100644 app/debug.keystore diff --git a/.idea/misc.xml b/.idea/misc.xml index 74dd639..b2c751a 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/app/.gitignore b/app/.gitignore index 6de5218..c970f09 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -44,7 +44,7 @@ captures/ # Keystore files (NEVER commit these!) *.jks -*.keystore +# *.keystore *.pem # OS-specific files diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 99a51ec..47994d1 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -7,12 +7,22 @@ android { namespace = "net.mmanningau.speechtokeyboard" compileSdk = 36 + signingConfigs { + getByName("debug") { + // This tells Gradle to look for the key in the same folder as this build file + storeFile = file("debug.keystore") + storePassword = "android" + keyAlias = "androiddebugkey" + keyPassword = "android" + } + } + defaultConfig { applicationId = "net.mmanningau.speechtokeyboard" minSdk = 28 targetSdk = 36 - versionCode = 12 - versionName = "1.1" + versionCode = 13 + versionName = "1.1.1" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } @@ -29,6 +39,8 @@ android { applicationIdSuffix = ".streaming" // This changes the app name on your homescreen to "MyApp (Dev)" resValue("string", "app_name", "Speech To Keyboard (Streaming)") + // Explicitly tell the debug build to use the config we defined above + signingConfig = signingConfigs["debug"] } } compileOptions { diff --git a/app/debug.keystore b/app/debug.keystore new file mode 100644 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kT=>G=yem#MTr6>f4`=JD=KUY01g+<23JRysw3S9TdjFa2s$CfS|ZN86#4 zG%;{@^Vz1lLsJ%^d6z)R&|(Ul>x)T*_o@^#}$6lt!)72Ti-;d@n3LUgWZc!$^ z5nhP4u&NhsM-z7nuA9g6lX*g{N+R0_o}k&EY?*H|BgcD;ilEYcuWStFDB%T800QJa z9jhk#>Fr44!gYdyxx9A7=CxTTErofX?7`Lr~c>-V_K%yLZJ!*Oa@V0oeT63bPMLDfP1wy@wI zBahYnGtdJc1qOd|zgZ>vr3N7TUwadlv{J95uqZU@%&&h61cU&*W6iRtB!t literal 0 HcmV?d00001 diff --git a/app/src/main/java/net/mmanningau/speechtokeyboard/TestModelActivity.kt b/app/src/main/java/net/mmanningau/speechtokeyboard/TestModelActivity.kt index efaaacd..f5fc30a 100644 --- a/app/src/main/java/net/mmanningau/speechtokeyboard/TestModelActivity.kt +++ b/app/src/main/java/net/mmanningau/speechtokeyboard/TestModelActivity.kt @@ -48,6 +48,7 @@ class TestModelActivity : AppCompatActivity() { // USB Components private var usbPort: UsbSerialPort? = null + private val ACTION_USB_PERMISSION = "net.mmanningau.speechtokeyboard.USB_PERMISSION" // Text History private var committedText = "" @@ -260,26 +261,51 @@ class TestModelActivity : AppCompatActivity() { } // ---------------------------------------------------------------- - // 3. USB LOGIC (Unchanged from before) + // REVISED USB LOGIC (With Permission Request) // ---------------------------------------------------------------- private fun connectToPico() { val usbManager = getSystemService(Context.USB_SERVICE) as UsbManager + + // Find the driver val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(usbManager) - if (availableDrivers.isEmpty()) return - - val driver = availableDrivers[0] - val connection = usbManager.openDevice(driver.device) ?: return - - usbPort = driver.ports[0] - try { - usbPort?.open(connection) - usbPort?.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE) - outputText.append("\n> USB Connected") - } catch (e: Exception) { - outputText.append("\n> USB Error: ${e.message}") + if (availableDrivers.isEmpty()) { + outputText.append("\n> No USB Device Found") + return } + val driver = availableDrivers[0] + + // CHECK PERMISSION + if (!usbManager.hasPermission(driver.device)) { + outputText.append("\n> Requesting Permission...") + val pendingIntent = android.app.PendingIntent.getBroadcast( + this, + 0, + android.content.Intent(ACTION_USB_PERMISSION), + android.app.PendingIntent.FLAG_IMMUTABLE + ) + usbManager.requestPermission(driver.device, pendingIntent) + return + } + + // OPEN DEVICE + openUsbDevice(driver, usbManager) } + private fun openUsbDevice(driver: com.hoho.android.usbserial.driver.UsbSerialDriver, manager: UsbManager) { + try { + val connection = manager.openDevice(driver.device) ?: return + usbPort = driver.ports[0] + usbPort?.open(connection) + + // CRITICAL: MATCHING BAUD RATE + // We are sticking with 115200. You MUST update your Pico code to match this. + usbPort?.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE) + + outputText.append("\n> USB Connected (115200)!") + } catch (e: Exception) { + outputText.append("\n> Connection Failed: ${e.message}") + } + } private fun sendToPico(text: String) { if (usbPort == null) return try {