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....
This commit is contained in:
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -1,4 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||||
|
|||||||
2
app/.gitignore
vendored
2
app/.gitignore
vendored
@@ -44,7 +44,7 @@ captures/
|
|||||||
|
|
||||||
# Keystore files (NEVER commit these!)
|
# Keystore files (NEVER commit these!)
|
||||||
*.jks
|
*.jks
|
||||||
*.keystore
|
# *.keystore
|
||||||
*.pem
|
*.pem
|
||||||
|
|
||||||
# OS-specific files
|
# OS-specific files
|
||||||
|
|||||||
@@ -7,12 +7,22 @@ android {
|
|||||||
namespace = "net.mmanningau.speechtokeyboard"
|
namespace = "net.mmanningau.speechtokeyboard"
|
||||||
compileSdk = 36
|
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 {
|
defaultConfig {
|
||||||
applicationId = "net.mmanningau.speechtokeyboard"
|
applicationId = "net.mmanningau.speechtokeyboard"
|
||||||
minSdk = 28
|
minSdk = 28
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 12
|
versionCode = 13
|
||||||
versionName = "1.1"
|
versionName = "1.1.1"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@@ -29,6 +39,8 @@ android {
|
|||||||
applicationIdSuffix = ".streaming"
|
applicationIdSuffix = ".streaming"
|
||||||
// This changes the app name on your homescreen to "MyApp (Dev)"
|
// This changes the app name on your homescreen to "MyApp (Dev)"
|
||||||
resValue("string", "app_name", "Speech To Keyboard (Streaming)")
|
resValue("string", "app_name", "Speech To Keyboard (Streaming)")
|
||||||
|
// Explicitly tell the debug build to use the config we defined above
|
||||||
|
signingConfig = signingConfigs["debug"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
|||||||
BIN
app/debug.keystore
Normal file
BIN
app/debug.keystore
Normal file
Binary file not shown.
@@ -48,6 +48,7 @@ class TestModelActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
// USB Components
|
// USB Components
|
||||||
private var usbPort: UsbSerialPort? = null
|
private var usbPort: UsbSerialPort? = null
|
||||||
|
private val ACTION_USB_PERMISSION = "net.mmanningau.speechtokeyboard.USB_PERMISSION"
|
||||||
|
|
||||||
// Text History
|
// Text History
|
||||||
private var committedText = ""
|
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() {
|
private fun connectToPico() {
|
||||||
val usbManager = getSystemService(Context.USB_SERVICE) as UsbManager
|
val usbManager = getSystemService(Context.USB_SERVICE) as UsbManager
|
||||||
|
|
||||||
|
// Find the driver
|
||||||
val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(usbManager)
|
val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(usbManager)
|
||||||
if (availableDrivers.isEmpty()) return
|
if (availableDrivers.isEmpty()) {
|
||||||
|
outputText.append("\n> No USB Device Found")
|
||||||
val driver = availableDrivers[0]
|
return
|
||||||
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}")
|
|
||||||
}
|
}
|
||||||
|
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) {
|
private fun sendToPico(text: String) {
|
||||||
if (usbPort == null) return
|
if (usbPort == null) return
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user