feat: 真实连接链路、移除虚拟数据、全量打包脚本
This commit is contained in:
1 parent
31b9a52eb4
commit
34340f4126
16 files changed
+601
-204
No files matched your search
@@ -10,13 +10,13 @@ import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import com.ttstd.lancast.receiver.session.PairingCode
|
||||
import com.ttstd.lancast.receiver.session.TlsSession
|
||||
import java.net.NetworkInterface
|
||||
|
||||
class MainActivity : Activity() {
|
||||
companion object {
|
||||
private const val REQUEST_CAPTURE = 1001
|
||||
private const val FINGERPRINT = "sha256:ab12cd34ef567890"
|
||||
const val EXTRA_HOST = "com.ttstd.lancast.receiver.HOST"
|
||||
const val EXTRA_SIGNALING = "com.ttstd.lancast.receiver.SIGNALING"
|
||||
}
|
||||
|
||||
private var session: ReceiverSession? = null
|
||||
@@ -28,18 +28,29 @@ class MainActivity : Activity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
status = TextView(this).apply { text = "状态:未开始" }
|
||||
val initialHost = intent?.getStringExtra(EXTRA_HOST)?.takeIf { it.isNotBlank() } ?: ""
|
||||
val initialSignaling = intent?.getStringExtra(EXTRA_SIGNALING)?.takeIf { it.isNotBlank() } ?: ""
|
||||
hostInput = EditText(this).apply {
|
||||
hint = "主控端 IP"
|
||||
setText("192.168.1.5")
|
||||
setText(initialHost)
|
||||
}
|
||||
signalingInput = EditText(this).apply {
|
||||
hint = "信令服务器"
|
||||
setText("http://192.168.1.5:8080")
|
||||
hint = "信令服务器(可选)"
|
||||
setText(initialSignaling)
|
||||
}
|
||||
val pairing = TextView(this).apply {
|
||||
text = "配对码:\n${PairingCode.build(localIp(), 41001, FINGERPRINT)}"
|
||||
text = "配对码:生成中..."
|
||||
textSize = 13f
|
||||
}
|
||||
Thread {
|
||||
val ip = try { localIp() } catch (_: Exception) { "" }
|
||||
val text = if (ip.isEmpty()) {
|
||||
"配对码:无法获取本机 IP"
|
||||
} else {
|
||||
"配对码:\n${PairingCode.build(ip, 41001, "")}"
|
||||
}
|
||||
runOnUiThread { pairing.text = text }
|
||||
}.start()
|
||||
val start = Button(this).apply { text = "授权并开始投屏" }
|
||||
val stop = Button(this).apply { text = "停止" }
|
||||
|
||||
@@ -55,6 +66,10 @@ class MainActivity : Activity() {
|
||||
})
|
||||
|
||||
start.setOnClickListener {
|
||||
if (hostInput.text.toString().trim().isEmpty()) {
|
||||
Toast.makeText(this, "请先填写主控端 IP", Toast.LENGTH_SHORT).show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
val manager = getSystemService(MediaProjectionManager::class.java)
|
||||
startActivityForResult(manager.createScreenCaptureIntent(), REQUEST_CAPTURE)
|
||||
}
|
||||
@@ -81,8 +96,15 @@ class MainActivity : Activity() {
|
||||
signalingUrl = signalingInput.text.toString().trim(),
|
||||
certificatePem = "",
|
||||
)
|
||||
session?.start()
|
||||
status.text = "状态:采集中 · 指纹 ${TlsSession.sha256Hex(FINGERPRINT.toByteArray()).take(16)}"
|
||||
status.text = "状态:连接中..."
|
||||
Thread {
|
||||
try {
|
||||
session?.start()
|
||||
runOnUiThread { status.text = "状态:采集中" }
|
||||
} catch (error: Exception) {
|
||||
runOnUiThread { status.text = "状态:连接失败 - ${error.message}" }
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@@ -94,5 +116,5 @@ class MainActivity : Activity() {
|
||||
private fun localIp(): String = NetworkInterface.getNetworkInterfaces().toList()
|
||||
.flatMap { it.inetAddresses.toList() }
|
||||
.firstOrNull { !it.isLoopbackAddress && it is java.net.Inet4Address }
|
||||
?.hostAddress ?: "192.168.1.10"
|
||||
?.hostAddress ?: ""
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import com.ttstd.lancast.receiver.file.FileService
|
||||
import com.ttstd.lancast.receiver.input.InputInjector
|
||||
import com.ttstd.lancast.receiver.protocol.ControlEvent
|
||||
import com.ttstd.lancast.receiver.session.ReceiverTransport
|
||||
import com.ttstd.lancast.receiver.session.TlsSession
|
||||
import java.io.File
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.Executors
|
||||
@@ -35,7 +34,7 @@ class ReceiverSession(
|
||||
private val injector = InputInjector(context)
|
||||
private val fileService = FileService(File(context.filesDir, "file-inbox"))
|
||||
private val opusEncoder = OpusEncoder()
|
||||
private val fingerprint = TlsSession.sha256Hex(certificatePem.toByteArray()).take(16)
|
||||
private val fingerprint: String = ""
|
||||
private val transport = ReceiverTransport(
|
||||
host,
|
||||
41001,
|
||||
@@ -117,5 +116,5 @@ class ReceiverSession(
|
||||
get() = java.net.NetworkInterface.getNetworkInterfaces().toList()
|
||||
.flatMap { it.inetAddresses.toList() }
|
||||
.firstOrNull { !it.isLoopbackAddress && it is java.net.Inet4Address }
|
||||
?.hostAddress ?: "192.168.1.10"
|
||||
?.hostAddress ?: ""
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
android {
|
||||
signingConfigs {
|
||||
create("keypub") {
|
||||
storeFile = file("E:/TongTongStudio/TTSTD/key/keypub.jks")
|
||||
storePassword = "123456"
|
||||
keyAlias = "publickey"
|
||||
keyPassword = "123456"
|
||||
}
|
||||
create("crosshatch") {
|
||||
storeFile = file("E:/TongTongStudio/TTSTD/key/AospCrosshatch.keystore")
|
||||
storePassword = "Fan1996"
|
||||
keyAlias = "AospCrosshatch"
|
||||
keyPassword = "Fan1996"
|
||||
}
|
||||
create("zhanxun") {
|
||||
storeFile = file("E:/TongTongStudio/TTSTD/key/zhanxun.keystore")
|
||||
storePassword = "123456"
|
||||
keyAlias = "zhanxun"
|
||||
keyPassword = "123456"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user