Add cross-platform BLE transport and Bluetooth settings
Integrate shared C transport with desktop and Android frontends, add radio probes and detailed Windows diagnostics, and fix GUI build dependencies and early configuration startup errors.
This commit is contained in:
1 parent
25cea8ca4c
commit
f5bac950d1
82 files changed
+6608
-146
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package com.utun.chat
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Instrumentation
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import com.utun.chat.data.BleRadio
|
||||
import com.utun.chat.data.NativeLib
|
||||
import com.utun.chat.headless.HeadlessService
|
||||
|
||||
/** Только ручной тест на физическом устройстве: временный echo общего C API. */
|
||||
class BlePeerProbe : Instrumentation() {
|
||||
private lateinit var args: Bundle
|
||||
override fun onCreate(arguments: Bundle) { super.onCreate(arguments); args = arguments; start() }
|
||||
override fun onStart() {
|
||||
val result = Bundle()
|
||||
var code = Activity.RESULT_OK
|
||||
try {
|
||||
startActivitySync(Intent(targetContext, MainActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||
targetContext.startForegroundService(Intent(targetContext, HeadlessService::class.java))
|
||||
val end = SystemClock.elapsedRealtime() + 30_000
|
||||
while (!NativeLib.isReady()) { check(SystemClock.elapsedRealtime() < end) { "core startup timeout" }; Thread.sleep(100) }
|
||||
Thread.sleep(1000) // Дождаться обычной политики SERVICE_STARTED перед тестовой.
|
||||
check(BleRadio.permitted()) { "Bluetooth permissions missing" }
|
||||
check(BleRadio.nativeConfigure(15 or if (args.getString("initiator") == "true") 16 else 0)) { "configure refused" }
|
||||
Thread.sleep((args.getString("seconds") ?: "100").toLong() * 1000)
|
||||
result.putString("stream", "BLE echo session completed; verify desktop RESULT\n")
|
||||
} catch (e: Exception) { code = Activity.RESULT_CANCELED; result.putString("stream", "BLE FAIL: $e\n") }
|
||||
finally { BleRadio.applySettings() }
|
||||
finish(code, result)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user