修复传输问题
This commit is contained in:
@@ -25,6 +25,11 @@ object DownloadClient {
|
|||||||
private const val TAG = "QftDownload"
|
private const val TAG = "QftDownload"
|
||||||
private const val BUFFER_SIZE = 1024 * 1024
|
private const val BUFFER_SIZE = 1024 * 1024
|
||||||
private const val ATTEMPTS = 5
|
private const val ATTEMPTS = 5
|
||||||
|
/** 整份重下的轮数。仅在 SHA-256 不匹配(缓存已损坏)时才会用到第二轮。 */
|
||||||
|
private const val VERIFY_ROUNDS = 2
|
||||||
|
|
||||||
|
/** 落盘阶段的失败与「下载失败」是两回事,用独立异常类型区分。 */
|
||||||
|
class SaveFailure(message: String, cause: Throwable?) : Exception(message, cause)
|
||||||
|
|
||||||
fun download(
|
fun download(
|
||||||
context: Context,
|
context: Context,
|
||||||
@@ -33,6 +38,11 @@ object DownloadClient {
|
|||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
pairing: PairingPayload,
|
pairing: PairingPayload,
|
||||||
deviceName: String,
|
deviceName: String,
|
||||||
|
/** 返回非 null 表示应立刻中止(例如 QFT 临时网络已断开),并以该原因报错。 */
|
||||||
|
abortReason: () -> String? = { null },
|
||||||
|
/** 阶段提示。传输完成后还有校验与落盘两步,必须让 UI 有反馈,
|
||||||
|
* 否则用户看到的就是「进度条停在 100% 然后报错」。 */
|
||||||
|
onPhase: (String) -> Unit = {},
|
||||||
onProgress: (received: Long, total: Long) -> Unit,
|
onProgress: (received: Long, total: Long) -> Unit,
|
||||||
): DownloadedFile {
|
): DownloadedFile {
|
||||||
require(pairing.direction == TransferDirection.DOWNLOAD_TO_PHONE)
|
require(pairing.direction == TransferDirection.DOWNLOAD_TO_PHONE)
|
||||||
@@ -43,24 +53,68 @@ object DownloadClient {
|
|||||||
partial.parentFile?.let { if (!it.exists() && !it.mkdirs()) error("无法创建接收缓存目录") }
|
partial.parentFile?.let { if (!it.exists() && !it.mkdirs()) error("无法创建接收缓存目录") }
|
||||||
if (partial.length() > expectedSize) partial.delete()
|
if (partial.length() > expectedSize) partial.delete()
|
||||||
|
|
||||||
|
// 落盘时缓存文件与目标文件同时存在,需要约 2 倍空间。
|
||||||
|
// 不预检的话,这里会在下载 100% 之后才失败,用户看到的是「快结束时失败」。
|
||||||
|
ensureSpaceForTransfer(partial, expectedSize)
|
||||||
|
|
||||||
|
repeat(VERIFY_ROUNDS) { round ->
|
||||||
|
receiveUntilComplete(network, baseUrl, pairing, deviceName, partial,
|
||||||
|
expectedSize, abortReason, onProgress)
|
||||||
|
|
||||||
|
onPhase("正在校验文件完整性…")
|
||||||
|
val actual = sha256(partial, onProgress)
|
||||||
|
if (actual.equals(expectedSha, ignoreCase = true)) {
|
||||||
|
onPhase("正在保存到 Downloads/QFT…")
|
||||||
|
ensureSpaceForSave(partial, expectedSize)
|
||||||
|
val result = try {
|
||||||
|
saveToDownloads(resolver, partial, expectedName, expectedSize, onProgress)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// 这一步失败与网络无关,重下多少次都没用,直接如实报错
|
||||||
|
throw SaveFailure("文件已完整收到,但保存到 Downloads/QFT 失败:${failureDetail(e)}", e)
|
||||||
|
}
|
||||||
|
partial.delete()
|
||||||
|
Log.i(TAG, "completed size=$expectedSize")
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.w(TAG, "sha mismatch round=${round + 1}/$VERIFY_ROUNDS expected=$expectedSha actual=$actual")
|
||||||
|
partial.delete()
|
||||||
|
if (round + 1 >= VERIFY_ROUNDS) {
|
||||||
|
error("文件校验失败:重新完整下载后 SHA-256 仍不匹配,请让电脑重新生成二维码")
|
||||||
|
}
|
||||||
|
onPhase("校验未通过,正在重新完整下载…")
|
||||||
|
}
|
||||||
|
error("下载未能完成")
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 传输阶段:断点续传 + 有限重试。只有这一段的失败才算「下载失败」。 */
|
||||||
|
private fun receiveUntilComplete(
|
||||||
|
network: Network?,
|
||||||
|
baseUrl: String,
|
||||||
|
pairing: PairingPayload,
|
||||||
|
deviceName: String,
|
||||||
|
partial: File,
|
||||||
|
expectedSize: Long,
|
||||||
|
abortReason: () -> String?,
|
||||||
|
onProgress: (received: Long, total: Long) -> Unit,
|
||||||
|
) {
|
||||||
var last: Exception? = null
|
var last: Exception? = null
|
||||||
repeat(ATTEMPTS) { attempt ->
|
repeat(ATTEMPTS) { attempt ->
|
||||||
|
abortReason()?.let { throw IllegalStateException(it, last) }
|
||||||
try {
|
try {
|
||||||
Log.i(TAG, "attempt=${attempt + 1}/$ATTEMPTS partial=${partial.length()}/$expectedSize endpoint=$baseUrl")
|
Log.i(TAG, "attempt=${attempt + 1}/$ATTEMPTS partial=${partial.length()}/$expectedSize endpoint=$baseUrl")
|
||||||
if (partial.length() < expectedSize) {
|
if (partial.length() < expectedSize) {
|
||||||
receiveAttempt(network, baseUrl, pairing, deviceName, partial, expectedSize, onProgress)
|
receiveAttempt(network, baseUrl, pairing, deviceName, partial,
|
||||||
|
expectedSize, abortReason, onProgress)
|
||||||
}
|
}
|
||||||
if (partial.length() != expectedSize) {
|
if (partial.length() != expectedSize) {
|
||||||
error("下载提前结束:${partial.length()}/$expectedSize")
|
error("下载提前结束:${partial.length()}/$expectedSize")
|
||||||
}
|
}
|
||||||
verifySha256(partial, expectedSha)
|
return
|
||||||
val result = saveToDownloads(resolver, partial, expectedName, expectedSize)
|
|
||||||
partial.delete()
|
|
||||||
Log.i(TAG, "completed size=$expectedSize")
|
|
||||||
return result
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
last = e
|
last = e
|
||||||
Log.w(TAG, "attempt=${attempt + 1}/$ATTEMPTS failed partial=${partial.length()}/$expectedSize: ${failureDetail(e)}", e)
|
Log.w(TAG, "attempt=${attempt + 1}/$ATTEMPTS failed partial=${partial.length()}/$expectedSize: ${failureDetail(e)}", e)
|
||||||
|
abortReason()?.let { throw IllegalStateException(it, e) }
|
||||||
if (attempt + 1 < ATTEMPTS) {
|
if (attempt + 1 < ATTEMPTS) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(250L * (attempt + 1))
|
Thread.sleep(250L * (attempt + 1))
|
||||||
@@ -71,7 +125,28 @@ object DownloadClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw IllegalStateException("从电脑下载失败,已重试 $ATTEMPTS 次:${failureDetail(last)}", last)
|
val progressed = partial.length()
|
||||||
|
throw IllegalStateException(
|
||||||
|
"从电脑下载失败,已重试 $ATTEMPTS 次(已收到 ${progressed}/$expectedSize 字节):${failureDetail(last)}",
|
||||||
|
last,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 传输 + 落盘阶段合计需要的可用空间。 */
|
||||||
|
private fun ensureSpaceForTransfer(partial: File, expectedSize: Long) {
|
||||||
|
val root = partial.parentFile ?: return
|
||||||
|
val needed = (expectedSize - partial.length()).coerceAtLeast(0L) + expectedSize
|
||||||
|
val usable = root.usableSpace
|
||||||
|
if (usable in 1 until needed) {
|
||||||
|
error("存储空间不足:本次接收约需 ${needed / 1024 / 1024} MB(含保存时的临时副本),当前可用 ${usable / 1024 / 1024} MB")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ensureSpaceForSave(partial: File, expectedSize: Long) {
|
||||||
|
val usable = partial.parentFile?.usableSpace ?: return
|
||||||
|
if (usable in 1 until expectedSize) {
|
||||||
|
error("存储空间不足:保存副本还需 ${expectedSize / 1024 / 1024} MB,当前可用 ${usable / 1024 / 1024} MB")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun receiveAttempt(
|
private fun receiveAttempt(
|
||||||
@@ -81,6 +156,7 @@ object DownloadClient {
|
|||||||
deviceName: String,
|
deviceName: String,
|
||||||
partial: File,
|
partial: File,
|
||||||
expectedSize: Long,
|
expectedSize: Long,
|
||||||
|
abortReason: () -> String?,
|
||||||
onProgress: (received: Long, total: Long) -> Unit,
|
onProgress: (received: Long, total: Long) -> Unit,
|
||||||
) {
|
) {
|
||||||
val requestedOffset = partial.length().coerceIn(0L, expectedSize)
|
val requestedOffset = partial.length().coerceIn(0L, expectedSize)
|
||||||
@@ -132,6 +208,9 @@ object DownloadClient {
|
|||||||
FileOutputStream(partial, offset > 0L).use { output ->
|
FileOutputStream(partial, offset > 0L).use { output ->
|
||||||
val buffer = ByteArray(BUFFER_SIZE)
|
val buffer = ByteArray(BUFFER_SIZE)
|
||||||
while (true) {
|
while (true) {
|
||||||
|
// 网络已断开时立刻收手:否则会在 readTimeout 上白等 12 秒,
|
||||||
|
// 再乘以 5 次重试,用户等一分钟才看到错误。
|
||||||
|
abortReason()?.let { error(it) }
|
||||||
val n = input.read(buffer)
|
val n = input.read(buffer)
|
||||||
if (n < 0) break
|
if (n < 0) break
|
||||||
if (n == 0) continue
|
if (n == 0) continue
|
||||||
@@ -154,28 +233,38 @@ object DownloadClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun verifySha256(file: File, expectedSha: String) {
|
/** 校验也要报进度:大文件读一整遍是好几秒,静默的话看起来就是卡在 100%。 */
|
||||||
|
private fun sha256(file: File, onProgress: (Long, Long) -> Unit): String {
|
||||||
val digest = MessageDigest.getInstance("SHA-256")
|
val digest = MessageDigest.getInstance("SHA-256")
|
||||||
|
val total = file.length()
|
||||||
|
var done = 0L
|
||||||
|
var lastReport = 0L
|
||||||
FileInputStream(file).use { input ->
|
FileInputStream(file).use { input ->
|
||||||
val buffer = ByteArray(BUFFER_SIZE)
|
val buffer = ByteArray(BUFFER_SIZE)
|
||||||
while (true) {
|
while (true) {
|
||||||
val n = input.read(buffer)
|
val n = input.read(buffer)
|
||||||
if (n < 0) break
|
if (n < 0) break
|
||||||
if (n > 0) digest.update(buffer, 0, n)
|
if (n > 0) {
|
||||||
|
digest.update(buffer, 0, n)
|
||||||
|
done += n.toLong()
|
||||||
|
val now = android.os.SystemClock.elapsedRealtime()
|
||||||
|
if (now - lastReport >= 80L) {
|
||||||
|
onProgress(done, total)
|
||||||
|
lastReport = now
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val actual = digest.digest().toHex()
|
|
||||||
if (!actual.equals(expectedSha, ignoreCase = true)) {
|
|
||||||
file.delete()
|
|
||||||
error("文件校验失败,已清除不完整缓存;请重试")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onProgress(total, total)
|
||||||
|
return digest.digest().toHex()
|
||||||
|
}
|
||||||
|
|
||||||
private fun saveToDownloads(
|
private fun saveToDownloads(
|
||||||
resolver: ContentResolver,
|
resolver: ContentResolver,
|
||||||
partial: File,
|
partial: File,
|
||||||
expectedName: String,
|
expectedName: String,
|
||||||
expectedSize: Long,
|
expectedSize: Long,
|
||||||
|
onProgress: (Long, Long) -> Unit,
|
||||||
): DownloadedFile {
|
): DownloadedFile {
|
||||||
var target: DownloadTarget? = null
|
var target: DownloadTarget? = null
|
||||||
try {
|
try {
|
||||||
@@ -185,12 +274,18 @@ object DownloadClient {
|
|||||||
createdTarget.output.use { output ->
|
createdTarget.output.use { output ->
|
||||||
val buffer = ByteArray(BUFFER_SIZE)
|
val buffer = ByteArray(BUFFER_SIZE)
|
||||||
var copied = 0L
|
var copied = 0L
|
||||||
|
var lastReport = 0L
|
||||||
while (true) {
|
while (true) {
|
||||||
val n = input.read(buffer)
|
val n = input.read(buffer)
|
||||||
if (n < 0) break
|
if (n < 0) break
|
||||||
if (n == 0) continue
|
if (n == 0) continue
|
||||||
output.write(buffer, 0, n)
|
output.write(buffer, 0, n)
|
||||||
copied += n.toLong()
|
copied += n.toLong()
|
||||||
|
val now = android.os.SystemClock.elapsedRealtime()
|
||||||
|
if (now - lastReport >= 80L) {
|
||||||
|
onProgress(copied, expectedSize)
|
||||||
|
lastReport = now
|
||||||
|
}
|
||||||
}
|
}
|
||||||
output.flush()
|
output.flush()
|
||||||
if (copied != expectedSize) error("保存下载文件时大小发生变化")
|
if (copied != expectedSize) error("保存下载文件时大小发生变化")
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ class MainActivity : ComponentActivity() {
|
|||||||
private var connectingStatusText: TextView? = null
|
private var connectingStatusText: TextView? = null
|
||||||
private var downloadStatusText: TextView? = null
|
private var downloadStatusText: TextView? = null
|
||||||
@Volatile private var downloadRunning = false
|
@Volatile private var downloadRunning = false
|
||||||
|
/** 非 null 表示当前传输应立刻中止(QFT 临时网络断开等)。
|
||||||
|
* 下载线程每读一个缓冲区就检查一次,避免在 readTimeout 上白等。 */
|
||||||
|
@Volatile private var transferAbortReason: String? = null
|
||||||
@Volatile private var pairConnectionAttempt = 0L
|
@Volatile private var pairConnectionAttempt = 0L
|
||||||
|
|
||||||
private val requestCamera = registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
|
private val requestCamera = registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
|
||||||
@@ -643,6 +646,10 @@ class MainActivity : ComponentActivity() {
|
|||||||
// HTTP/timeout cause instead of replacing it with this generic
|
// HTTP/timeout cause instead of replacing it with this generic
|
||||||
// message mid-retry.
|
// message mid-retry.
|
||||||
if (pair.direction == TransferDirection.DOWNLOAD_TO_PHONE && downloadRunning) {
|
if (pair.direction == TransferDirection.DOWNLOAD_TO_PHONE && downloadRunning) {
|
||||||
|
// 让下载线程立刻收手并如实报告断网,而不是继续跑完
|
||||||
|
// 5 次「重试 → 12 秒超时」,最后给出一个与真因无关的
|
||||||
|
// 「下载失败,已重试 N 次」。
|
||||||
|
transferAbortReason = message
|
||||||
downloadStatusText?.apply {
|
downloadStatusText?.apply {
|
||||||
text = "QFT 本地网络已断开,正在结束当前下载请求…"
|
text = "QFT 本地网络已断开,正在结束当前下载请求…"
|
||||||
setTextColor(WARNING)
|
setTextColor(WARNING)
|
||||||
@@ -765,9 +772,13 @@ class MainActivity : ComponentActivity() {
|
|||||||
setContentView(ScrollView(this).apply { setBackgroundColor(BG); addView(root) })
|
setContentView(ScrollView(this).apply { setBackgroundColor(BG); addView(root) })
|
||||||
|
|
||||||
downloadRunning = true
|
downloadRunning = true
|
||||||
|
transferAbortReason = null
|
||||||
transferExecutor.execute {
|
transferExecutor.execute {
|
||||||
|
// 「传输 / 校验 / 保存」三个阶段各自的速率含义不同,
|
||||||
|
// 每进入一个新阶段就重新计时,否则显示出来的速率毫无意义。
|
||||||
|
var phaseLabel = "正在接收"
|
||||||
|
var phaseStartedAt = android.os.SystemClock.elapsedRealtime()
|
||||||
try {
|
try {
|
||||||
val startedAt = android.os.SystemClock.elapsedRealtime()
|
|
||||||
val saved = DownloadClient.download(
|
val saved = DownloadClient.download(
|
||||||
context = this@MainActivity,
|
context = this@MainActivity,
|
||||||
resolver = contentResolver,
|
resolver = contentResolver,
|
||||||
@@ -775,13 +786,19 @@ class MainActivity : ComponentActivity() {
|
|||||||
baseUrl = baseUrl,
|
baseUrl = baseUrl,
|
||||||
pairing = pair,
|
pairing = pair,
|
||||||
deviceName = receiverDeviceLabel,
|
deviceName = receiverDeviceLabel,
|
||||||
|
abortReason = { transferAbortReason },
|
||||||
|
onPhase = { label ->
|
||||||
|
phaseLabel = label
|
||||||
|
phaseStartedAt = android.os.SystemClock.elapsedRealtime()
|
||||||
|
runOnUiThread { status.text = label }
|
||||||
|
},
|
||||||
) { received, expected ->
|
) { received, expected ->
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
val fraction = if (expected <= 0) 0 else ((received * 1000L) / expected).toInt().coerceIn(0, 1000)
|
val fraction = if (expected <= 0) 0 else ((received * 1000L) / expected).toInt().coerceIn(0, 1000)
|
||||||
val elapsed = (android.os.SystemClock.elapsedRealtime() - startedAt).coerceAtLeast(1L)
|
val elapsed = (android.os.SystemClock.elapsedRealtime() - phaseStartedAt).coerceAtLeast(1L)
|
||||||
val rate = received * 1000.0 / elapsed
|
val rate = received * 1000.0 / elapsed
|
||||||
bar.progress = fraction
|
bar.progress = fraction
|
||||||
status.text = "${humanBytes(received)} / ${humanBytes(expected)} · ${humanBytes(rate.toLong())}/s"
|
status.text = "$phaseLabel ${humanBytes(received)} / ${humanBytes(expected)} · ${humanBytes(rate.toLong())}/s"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
@@ -792,7 +809,9 @@ class MainActivity : ComponentActivity() {
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
downloadRunning = false
|
downloadRunning = false
|
||||||
showPairError(pair, "从电脑接收失败:${e.message}")
|
// 落盘失败时文件其实已经完整收到了,别再说「接收失败」误导用户
|
||||||
|
val prefix = if (e is DownloadClient.SaveFailure) "保存失败" else "从电脑接收失败"
|
||||||
|
showPairError(pair, "$prefix:${e.message}")
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
downloadRunning = false
|
downloadRunning = false
|
||||||
|
|||||||
@@ -30,49 +30,79 @@ class WifiConnector(context: Context) {
|
|||||||
private var legacyPreviousNetworkId: Int? = null
|
private var legacyPreviousNetworkId: Int? = null
|
||||||
private var legacyTargetNetworkId: Int? = null
|
private var legacyTargetNetworkId: Int? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回调经由这个可替换的收件人转发,而不是被 NetworkCallback 闭包捕获。
|
||||||
|
* 这样「用户点重试」时可以直接换掉 UI 回调、继续复用那个还挂着的
|
||||||
|
* WifiNetworkSpecifier 请求,不必 unregister —— 在系统选网弹窗还开着的
|
||||||
|
* 时候 unregister,Android 会弹「该应用已取消选择设备的请求」。
|
||||||
|
*/
|
||||||
|
private class Listener(
|
||||||
|
val onStatus: (String) -> Unit,
|
||||||
|
val onAvailable: (Network?) -> Unit,
|
||||||
|
val onUnavailable: (String) -> Unit,
|
||||||
|
)
|
||||||
|
|
||||||
|
private var listener: Listener? = null
|
||||||
|
private var pendingSsid: String? = null
|
||||||
|
private var pendingDelivered: AtomicBoolean? = null
|
||||||
|
private var pendingTerminal: AtomicBoolean? = null
|
||||||
|
private var pendingStartedAt = 0L
|
||||||
|
|
||||||
|
// 所有对外回调都只走这三个入口。直接调用捕获来的闭包会在「复用挂起请求」
|
||||||
|
// 时通知到上一次的界面,是很难查的一类 bug。
|
||||||
|
private fun notifyStatus(message: String) { listener?.onStatus?.invoke(message) }
|
||||||
|
private fun notifyAvailable(network: Network?) { listener?.onAvailable?.invoke(network) }
|
||||||
|
private fun notifyUnavailable(message: String) { listener?.onUnavailable?.invoke(message) }
|
||||||
|
|
||||||
fun connect(
|
fun connect(
|
||||||
pairing: PairingPayload,
|
pairing: PairingPayload,
|
||||||
onStatus: (String) -> Unit,
|
onStatus: (String) -> Unit,
|
||||||
onAvailable: (Network?) -> Unit,
|
onAvailable: (Network?) -> Unit,
|
||||||
onUnavailable: (String) -> Unit,
|
onUnavailable: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
|
val wifi = pairing.wifi
|
||||||
|
|
||||||
|
// 同一个 SSID 的请求还挂在系统那里且没有终结:换掉 UI 回调即可,
|
||||||
|
// 千万不要 unregister 再重新 requestNetwork。
|
||||||
|
if (wifi != null && callback != null && pendingSsid == wifi.ssid &&
|
||||||
|
pendingTerminal?.get() == false && pendingDelivered?.get() == false) {
|
||||||
|
Log.i(TAG, "reuse outstanding request SSID=${wifi.ssid}")
|
||||||
|
listener = Listener(onStatus, onAvailable, onUnavailable)
|
||||||
|
notifyStatus("系统配网请求仍在进行中,正在继续等待…")
|
||||||
|
scheduleWaitHints(generation, wifi.ssid)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
release(restoreLegacy = false)
|
release(restoreLegacy = false)
|
||||||
generation++
|
generation++
|
||||||
val run = generation
|
val run = generation
|
||||||
val wifi = pairing.wifi
|
listener = Listener(onStatus, onAvailable, onUnavailable)
|
||||||
if (wifi == null) {
|
if (wifi == null) {
|
||||||
onStatus("正在使用当前局域网发现电脑…")
|
notifyStatus("正在使用当前局域网发现电脑…")
|
||||||
val wifiNetwork = bestWifiNetwork()
|
val wifiNetwork = bestWifiNetwork()
|
||||||
onAvailable(wifiNetwork ?: connectivity.activeNetwork)
|
notifyAvailable(wifiNetwork ?: connectivity.activeNetwork)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 29) {
|
if (Build.VERSION.SDK_INT >= 29) {
|
||||||
connectModern(run, wifi, onStatus, onAvailable, onUnavailable)
|
connectModern(run, wifi)
|
||||||
} else {
|
} else {
|
||||||
connectLegacy(run, wifi, onStatus, onAvailable, onUnavailable)
|
connectLegacy(run, wifi)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(29)
|
@RequiresApi(29)
|
||||||
@Suppress("MissingPermission")
|
@Suppress("MissingPermission")
|
||||||
private fun connectModern(
|
private fun connectModern(run: Int, wifi: WifiCredentials) {
|
||||||
run: Int,
|
|
||||||
wifi: WifiCredentials,
|
|
||||||
onStatus: (String) -> Unit,
|
|
||||||
onAvailable: (Network?) -> Unit,
|
|
||||||
onUnavailable: (String) -> Unit,
|
|
||||||
) {
|
|
||||||
onStatus("正在请求连接 ${wifi.ssid}…")
|
|
||||||
Log.i(TAG, "attempt=$run request SSID=${wifi.ssid}")
|
Log.i(TAG, "attempt=$run request SSID=${wifi.ssid}")
|
||||||
onStatus("正在等待 Android 系统连接确认;确认后本页将继续显示进度")
|
notifyStatus("正在等待 Android 系统连接确认;确认后本页将继续显示进度")
|
||||||
val specifier = try {
|
val specifier = try {
|
||||||
WifiNetworkSpecifier.Builder()
|
WifiNetworkSpecifier.Builder()
|
||||||
.setSsid(wifi.ssid)
|
.setSsid(wifi.ssid)
|
||||||
.setWpa2Passphrase(wifi.passphrase)
|
.setWpa2Passphrase(wifi.passphrase)
|
||||||
.build()
|
.build()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
onUnavailable("配网参数无效:${e.message}")
|
notifyUnavailable("配网参数无效:${e.message}")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val request = NetworkRequest.Builder()
|
val request = NetworkRequest.Builder()
|
||||||
@@ -86,16 +116,22 @@ class WifiConnector(context: Context) {
|
|||||||
// launching a duplicate probe/download for the same Wi-Fi connection.
|
// launching a duplicate probe/download for the same Wi-Fi connection.
|
||||||
val delivered = AtomicBoolean(false)
|
val delivered = AtomicBoolean(false)
|
||||||
val terminal = AtomicBoolean(false)
|
val terminal = AtomicBoolean(false)
|
||||||
|
pendingSsid = wifi.ssid
|
||||||
|
pendingDelivered = delivered
|
||||||
|
pendingTerminal = terminal
|
||||||
|
pendingStartedAt = SystemClock.elapsedRealtime()
|
||||||
|
val startedAt = pendingStartedAt
|
||||||
|
|
||||||
val cb = object : ConnectivityManager.NetworkCallback() {
|
val cb = object : ConnectivityManager.NetworkCallback() {
|
||||||
override fun onAvailable(network: Network) {
|
override fun onAvailable(network: Network) {
|
||||||
if (run != generation || terminal.get()) return
|
if (run != generation || terminal.get()) return
|
||||||
Log.i(TAG, "attempt=$run framework onAvailable network=$network")
|
Log.i(TAG, "attempt=$run framework onAvailable network=$network")
|
||||||
onStatus("Wi-Fi 已关联,正在等待本地 IP/路由…")
|
notifyStatus("Wi-Fi 已关联,正在等待本地 IP/路由…")
|
||||||
waitUntilUsable(run, network, onStatus) {
|
waitUntilUsable(run, network, ::notifyStatus) {
|
||||||
if (run == generation && !terminal.get() && delivered.compareAndSet(false, true)) {
|
if (run == generation && !terminal.get() && delivered.compareAndSet(false, true)) {
|
||||||
Log.i(TAG, "attempt=$run route ready network=$network")
|
Log.i(TAG, "attempt=$run route ready network=$network")
|
||||||
onStatus("QFT 本地网络已就绪,正在快速发现电脑…")
|
notifyStatus("QFT 本地网络已就绪,正在快速发现电脑…")
|
||||||
onAvailable(network)
|
notifyAvailable(network)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,21 +140,33 @@ class WifiConnector(context: Context) {
|
|||||||
if (run != generation || terminal.get() || delivered.get()) return
|
if (run != generation || terminal.get() || delivered.get()) return
|
||||||
if (hasIpv4(linkProperties) && delivered.compareAndSet(false, true)) {
|
if (hasIpv4(linkProperties) && delivered.compareAndSet(false, true)) {
|
||||||
Log.i(TAG, "attempt=$run IPv4 ready network=$network")
|
Log.i(TAG, "attempt=$run IPv4 ready network=$network")
|
||||||
onStatus("QFT 本地网络已就绪,正在快速发现电脑…")
|
notifyStatus("QFT 本地网络已就绪,正在快速发现电脑…")
|
||||||
onAvailable(network)
|
notifyAvailable(network)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUnavailable() {
|
override fun onUnavailable() {
|
||||||
if (run != generation || !terminal.compareAndSet(false, true)) return
|
if (run != generation || !terminal.compareAndSet(false, true)) return
|
||||||
Log.w(TAG, "attempt=$run framework onUnavailable")
|
val waited = SystemClock.elapsedRealtime() - startedAt
|
||||||
if (run == generation) onUnavailable("未能连接 QFT 临时网络。请确认 Wi-Fi 已开启并批准系统连接请求。")
|
Log.w(TAG, "attempt=$run framework onUnavailable after ${waited}ms")
|
||||||
|
// Android 不区分「用户点了取消」和「始终没扫到这个热点」,
|
||||||
|
// 只能用等待时长推断,给出真正能指导用户下一步的提示。
|
||||||
|
notifyUnavailable(
|
||||||
|
if (waited < 4_000L) {
|
||||||
|
"已取消系统配网。请重新点击「重试连接」,并在系统弹窗里选择 ${wifi.ssid} 后点连接。"
|
||||||
|
} else {
|
||||||
|
"系统始终没有搜索到热点 ${wifi.ssid}。请确认:" +
|
||||||
|
"① 电脑上 QFT 接收页仍开着且显示 Direct 已启动;" +
|
||||||
|
"② 手机 Wi-Fi 列表里能看到这个名字;" +
|
||||||
|
"③ 电脑与手机距离不要太远。"
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLost(network: Network) {
|
override fun onLost(network: Network) {
|
||||||
if (run != generation || !delivered.get() || !terminal.compareAndSet(false, true)) return
|
if (run != generation || !delivered.get() || !terminal.compareAndSet(false, true)) return
|
||||||
Log.w(TAG, "attempt=$run network lost network=$network")
|
Log.w(TAG, "attempt=$run network lost network=$network")
|
||||||
if (run == generation && delivered.get()) onUnavailable("QFT 临时网络已断开")
|
notifyUnavailable("QFT 临时网络已断开")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
callback = cb
|
callback = cb
|
||||||
@@ -130,26 +178,37 @@ class WifiConnector(context: Context) {
|
|||||||
// system sheet; otherwise keep this request alive while our page
|
// system sheet; otherwise keep this request alive while our page
|
||||||
// continues to show connection progress.
|
// continues to show connection progress.
|
||||||
connectivity.requestNetwork(request, cb)
|
connectivity.requestNetwork(request, cb)
|
||||||
handler.postDelayed({
|
scheduleWaitHints(run, wifi.ssid)
|
||||||
if (run == generation && !terminal.get() && !delivered.get()) {
|
|
||||||
onStatus("仍在等待系统完成配网…")
|
|
||||||
}
|
|
||||||
}, 8_000)
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
callback = null
|
callback = null
|
||||||
onUnavailable("系统配网请求失败:${e.message}")
|
pendingSsid = null
|
||||||
|
notifyUnavailable("系统配网请求失败:${e.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 弹窗久久不出结果时逐级给出更具体的提示。
|
||||||
|
* 截图里那种「弹窗一直转圈」的情况,光说「仍在等待系统完成配网」
|
||||||
|
* 完全没有指导意义——真正的原因通常是电脑侧热点没起来。
|
||||||
|
*/
|
||||||
|
private fun scheduleWaitHints(run: Int, ssid: String) {
|
||||||
|
fun pending(): Boolean =
|
||||||
|
run == generation && pendingTerminal?.get() == false && pendingDelivered?.get() == false
|
||||||
|
|
||||||
|
handler.postDelayed({
|
||||||
|
if (pending()) listener?.onStatus?.invoke("仍在等待系统完成配网…")
|
||||||
|
}, 8_000)
|
||||||
|
handler.postDelayed({
|
||||||
|
if (pending()) listener?.onStatus?.invoke(
|
||||||
|
"系统仍在搜索 $ssid。若弹窗里一直没出现这个名字," +
|
||||||
|
"多半是电脑侧热点没启动——请检查 Windows 上 QFT 接收页是否显示 Direct 已就绪。"
|
||||||
|
)
|
||||||
|
}, 20_000)
|
||||||
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION", "MissingPermission")
|
@Suppress("DEPRECATION", "MissingPermission")
|
||||||
private fun connectLegacy(
|
private fun connectLegacy(run: Int, wifi: WifiCredentials) {
|
||||||
run: Int,
|
notifyStatus("Android ${Build.VERSION.RELEASE} 兼容配网:正在连接 ${wifi.ssid}…")
|
||||||
wifi: WifiCredentials,
|
|
||||||
onStatus: (String) -> Unit,
|
|
||||||
onAvailable: (Network?) -> Unit,
|
|
||||||
onUnavailable: (String) -> Unit,
|
|
||||||
) {
|
|
||||||
onStatus("Android ${Build.VERSION.RELEASE} 兼容配网:正在连接 ${wifi.ssid}…")
|
|
||||||
try {
|
try {
|
||||||
if (!wifiManager.isWifiEnabled) {
|
if (!wifiManager.isWifiEnabled) {
|
||||||
wifiManager.isWifiEnabled = true
|
wifiManager.isWifiEnabled = true
|
||||||
@@ -168,13 +227,13 @@ class WifiConnector(context: Context) {
|
|||||||
wifiManager.addNetwork(config)
|
wifiManager.addNetwork(config)
|
||||||
}
|
}
|
||||||
if (targetId < 0) {
|
if (targetId < 0) {
|
||||||
onUnavailable("Android 7~9 无法写入 QFT Wi-Fi 配置;请确认已授予位置权限。")
|
notifyUnavailable("Android 7~9 无法写入 QFT Wi-Fi 配置;请确认已授予位置权限。")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
legacyTargetNetworkId = targetId
|
legacyTargetNetworkId = targetId
|
||||||
wifiManager.disconnect()
|
wifiManager.disconnect()
|
||||||
if (!wifiManager.enableNetwork(targetId, true)) {
|
if (!wifiManager.enableNetwork(targetId, true)) {
|
||||||
onUnavailable("系统拒绝启用 QFT Wi-Fi 网络")
|
notifyUnavailable("系统拒绝启用 QFT Wi-Fi 网络")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
wifiManager.reconnect()
|
wifiManager.reconnect()
|
||||||
@@ -186,20 +245,20 @@ class WifiConnector(context: Context) {
|
|||||||
if (matches) {
|
if (matches) {
|
||||||
val network = bestWifiNetwork()
|
val network = bestWifiNetwork()
|
||||||
if (network != null && hasIpv4(connectivity.getLinkProperties(network))) {
|
if (network != null && hasIpv4(connectivity.getLinkProperties(network))) {
|
||||||
onStatus("QFT Wi-Fi 已连接,正在快速发现电脑…")
|
notifyStatus("QFT Wi-Fi 已连接,正在快速发现电脑…")
|
||||||
onAvailable(network)
|
notifyAvailable(network)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SystemClock.elapsedRealtime() - started > 15_000) {
|
if (SystemClock.elapsedRealtime() - started > 15_000) {
|
||||||
onUnavailable("连接 QFT Wi-Fi 超时。请确认电脑热点仍在运行。")
|
notifyUnavailable("连接 QFT Wi-Fi 超时。请确认电脑热点仍在运行。")
|
||||||
} else {
|
} else {
|
||||||
handler.postDelayed({ poll() }, 250)
|
handler.postDelayed({ poll() }, 250)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handler.postDelayed({ poll() }, 250)
|
handler.postDelayed({ poll() }, 250)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
onUnavailable("Android 7~9 配网失败:${e.message}")
|
notifyUnavailable("Android 7~9 配网失败:${e.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,6 +375,10 @@ class WifiConnector(context: Context) {
|
|||||||
try { connectivity.unregisterNetworkCallback(it) } catch (_: Exception) {}
|
try { connectivity.unregisterNetworkCallback(it) } catch (_: Exception) {}
|
||||||
}
|
}
|
||||||
callback = null
|
callback = null
|
||||||
|
listener = null
|
||||||
|
pendingSsid = null
|
||||||
|
pendingDelivered = null
|
||||||
|
pendingTerminal = null
|
||||||
handler.removeCallbacksAndMessages(null)
|
handler.removeCallbacksAndMessages(null)
|
||||||
if (restoreLegacy && Build.VERSION.SDK_INT < 29) {
|
if (restoreLegacy && Build.VERSION.SDK_INT < 29) {
|
||||||
val previous = legacyPreviousNetworkId
|
val previous = legacyPreviousNetworkId
|
||||||
|
|||||||
@@ -7,35 +7,35 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
0469B1106E6746B3BE56007D /* UploadClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8FB8A4A9482DB8F1234AE39 /* UploadClient.swift */; };
|
||||||
|
38E462342111ACFA8775D17B /* PairingProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5459D124A555B0E4121361E5 /* PairingProtocol.swift */; };
|
||||||
|
4D2B05655C76F69F32349834 /* PeerPairing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06E1A38EC22BBFED928C8EB6 /* PeerPairing.swift */; };
|
||||||
554512A1FC8A6F66E2784787 /* QFTApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 453B172D654B3AEDE4E36D1E /* QFTApp.swift */; };
|
554512A1FC8A6F66E2784787 /* QFTApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 453B172D654B3AEDE4E36D1E /* QFTApp.swift */; };
|
||||||
|
6B2EB3BCEDA4855168DB4ACE /* HostDiscovery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3776FFCC2817EF6BF3EEC4FD /* HostDiscovery.swift */; };
|
||||||
78FD5CF5E04D7E2483B90BAA /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B6863D13BC7270D7FCE21E7 /* HomeView.swift */; };
|
78FD5CF5E04D7E2483B90BAA /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B6863D13BC7270D7FCE21E7 /* HomeView.swift */; };
|
||||||
|
978F01FFFFF69591E44C8528 /* DownloadClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA81C375609633BD8DB42F3 /* DownloadClient.swift */; };
|
||||||
|
A80B2E7BF8035E27D115EF59 /* PeerLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DD16686BB19417EDC0B611A /* PeerLink.swift */; };
|
||||||
BDCF0D82F0BD0328770A8ABD /* ScannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3B15455554D7647B44D5038 /* ScannerView.swift */; };
|
BDCF0D82F0BD0328770A8ABD /* ScannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3B15455554D7647B44D5038 /* ScannerView.swift */; };
|
||||||
|
C0C0B5440A627CE758643A9F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C628A05E9C83375781E165EB /* Assets.xcassets */; };
|
||||||
E26487D1146FDF6DD5F92D80 /* TransferModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3017489412A6FCAE8995B32E /* TransferModel.swift */; };
|
E26487D1146FDF6DD5F92D80 /* TransferModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3017489412A6FCAE8995B32E /* TransferModel.swift */; };
|
||||||
EE5510DAC5BBB7F9D41A8F26 /* Base64URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848334DC6B2D30622C7E2A45 /* Base64URL.swift */; };
|
EE5510DAC5BBB7F9D41A8F26 /* Base64URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848334DC6B2D30622C7E2A45 /* Base64URL.swift */; };
|
||||||
38E462342111ACFA8775D17B /* PairingProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5459D124A555B0E4121361E5 /* PairingProtocol.swift */; };
|
|
||||||
6B2EB3BCEDA4855168DB4ACE /* HostDiscovery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3776FFCC2817EF6BF3EEC4FD /* HostDiscovery.swift */; };
|
|
||||||
978F01FFFFF69591E44C8528 /* DownloadClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA81C375609633BD8DB42F3 /* DownloadClient.swift */; };
|
|
||||||
0469B1106E6746B3BE56007D /* UploadClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8FB8A4A9482DB8F1234AE39 /* UploadClient.swift */; };
|
|
||||||
4D2B05655C76F69F32349834 /* PeerPairing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06E1A38EC22BBFED928C8EB6 /* PeerPairing.swift */; };
|
|
||||||
A80B2E7BF8035E27D115EF59 /* PeerLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DD16686BB19417EDC0B611A /* PeerLink.swift */; };
|
|
||||||
C0C0B5440A627CE758643A9F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C628A05E9C83375781E165EB /* Assets.xcassets */; };
|
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
928818DCDA72C62B2D8288D5 /* QFT.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QFT.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
||||||
453B172D654B3AEDE4E36D1E /* QFTApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QFTApp.swift; sourceTree = "<group>"; };
|
|
||||||
0B6863D13BC7270D7FCE21E7 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
|
|
||||||
F3B15455554D7647B44D5038 /* ScannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScannerView.swift; sourceTree = "<group>"; };
|
|
||||||
3017489412A6FCAE8995B32E /* TransferModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransferModel.swift; sourceTree = "<group>"; };
|
|
||||||
848334DC6B2D30622C7E2A45 /* Base64URL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base64URL.swift; sourceTree = "<group>"; };
|
|
||||||
5459D124A555B0E4121361E5 /* PairingProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PairingProtocol.swift; sourceTree = "<group>"; };
|
|
||||||
3776FFCC2817EF6BF3EEC4FD /* HostDiscovery.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostDiscovery.swift; sourceTree = "<group>"; };
|
|
||||||
EAA81C375609633BD8DB42F3 /* DownloadClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadClient.swift; sourceTree = "<group>"; };
|
|
||||||
B8FB8A4A9482DB8F1234AE39 /* UploadClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadClient.swift; sourceTree = "<group>"; };
|
|
||||||
06E1A38EC22BBFED928C8EB6 /* PeerPairing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeerPairing.swift; sourceTree = "<group>"; };
|
06E1A38EC22BBFED928C8EB6 /* PeerPairing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeerPairing.swift; sourceTree = "<group>"; };
|
||||||
8DD16686BB19417EDC0B611A /* PeerLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeerLink.swift; sourceTree = "<group>"; };
|
0B6863D13BC7270D7FCE21E7 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
|
||||||
C628A05E9C83375781E165EB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
3017489412A6FCAE8995B32E /* TransferModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransferModel.swift; sourceTree = "<group>"; };
|
||||||
|
3776FFCC2817EF6BF3EEC4FD /* HostDiscovery.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostDiscovery.swift; sourceTree = "<group>"; };
|
||||||
|
453B172D654B3AEDE4E36D1E /* QFTApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QFTApp.swift; sourceTree = "<group>"; };
|
||||||
|
5459D124A555B0E4121361E5 /* PairingProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PairingProtocol.swift; sourceTree = "<group>"; };
|
||||||
7E4A60F8CA5D515103446ED3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
7E4A60F8CA5D515103446ED3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
848334DC6B2D30622C7E2A45 /* Base64URL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base64URL.swift; sourceTree = "<group>"; };
|
||||||
|
8DD16686BB19417EDC0B611A /* PeerLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeerLink.swift; sourceTree = "<group>"; };
|
||||||
|
928818DCDA72C62B2D8288D5 /* QFT.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QFT.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
B8FB8A4A9482DB8F1234AE39 /* UploadClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadClient.swift; sourceTree = "<group>"; };
|
||||||
|
C628A05E9C83375781E165EB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
|
EAA81C375609633BD8DB42F3 /* DownloadClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadClient.swift; sourceTree = "<group>"; };
|
||||||
|
F3B15455554D7647B44D5038 /* ScannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScannerView.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -60,20 +60,6 @@
|
|||||||
path = App;
|
path = App;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
EC599E8CF455428A5E3179CE /* Core */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
848334DC6B2D30622C7E2A45 /* Base64URL.swift */,
|
|
||||||
EAA81C375609633BD8DB42F3 /* DownloadClient.swift */,
|
|
||||||
3776FFCC2817EF6BF3EEC4FD /* HostDiscovery.swift */,
|
|
||||||
5459D124A555B0E4121361E5 /* PairingProtocol.swift */,
|
|
||||||
8DD16686BB19417EDC0B611A /* PeerLink.swift */,
|
|
||||||
06E1A38EC22BBFED928C8EB6 /* PeerPairing.swift */,
|
|
||||||
B8FB8A4A9482DB8F1234AE39 /* UploadClient.swift */,
|
|
||||||
);
|
|
||||||
path = Core;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
36EDFB66685EBD501D3910CE /* QFT */ = {
|
36EDFB66685EBD501D3910CE /* QFT */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@@ -101,12 +87,26 @@
|
|||||||
name = Products;
|
name = Products;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
EC599E8CF455428A5E3179CE /* Core */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
848334DC6B2D30622C7E2A45 /* Base64URL.swift */,
|
||||||
|
EAA81C375609633BD8DB42F3 /* DownloadClient.swift */,
|
||||||
|
3776FFCC2817EF6BF3EEC4FD /* HostDiscovery.swift */,
|
||||||
|
5459D124A555B0E4121361E5 /* PairingProtocol.swift */,
|
||||||
|
8DD16686BB19417EDC0B611A /* PeerLink.swift */,
|
||||||
|
06E1A38EC22BBFED928C8EB6 /* PeerPairing.swift */,
|
||||||
|
B8FB8A4A9482DB8F1234AE39 /* UploadClient.swift */,
|
||||||
|
);
|
||||||
|
path = Core;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
497CBF7ECF21FFA362230876 /* QFT */ = {
|
497CBF7ECF21FFA362230876 /* QFT */ = {
|
||||||
isa = PBXNativeTarget;
|
isa = PBXNativeTarget;
|
||||||
buildConfigurationList = A886B50DF087AEF7B87CDC65;
|
buildConfigurationList = A886B50DF087AEF7B87CDC65 /* Build configuration list for PBXNativeTarget "QFT" */;
|
||||||
buildPhases = (
|
buildPhases = (
|
||||||
C2511B36F0F0E810A9E46328 /* Sources */,
|
C2511B36F0F0E810A9E46328 /* Sources */,
|
||||||
019BAB185F97B56993A7087D /* Frameworks */,
|
019BAB185F97B56993A7087D /* Frameworks */,
|
||||||
@@ -136,7 +136,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
buildConfigurationList = 26E84C2B3712F7DFAC8AD93F;
|
buildConfigurationList = 26E84C2B3712F7DFAC8AD93F /* Build configuration list for PBXProject "QFT" */;
|
||||||
compatibilityVersion = "Xcode 14.0";
|
compatibilityVersion = "Xcode 14.0";
|
||||||
developmentRegion = en;
|
developmentRegion = en;
|
||||||
hasScannedForEncodings = 0;
|
hasScannedForEncodings = 0;
|
||||||
@@ -188,6 +188,29 @@
|
|||||||
/* End PBXSourcesBuildPhase section */
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
/* Begin XCBuildConfiguration section */
|
/* Begin XCBuildConfiguration section */
|
||||||
|
032222C0BAA33BC7119DFAF1 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
ENABLE_PREVIEWS = YES;
|
||||||
|
GENERATE_INFOPLIST_FILE = NO;
|
||||||
|
INFOPLIST_FILE = QFT/Info.plist;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 18.6;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
MARKETING_VERSION = 0.1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.qft.transfer;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
70DCC1EB255A5F3C8D9ED349 /* Debug */ = {
|
70DCC1EB255A5F3C8D9ED349 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
@@ -203,8 +226,11 @@
|
|||||||
ENABLE_TESTABILITY = YES;
|
ENABLE_TESTABILITY = YES;
|
||||||
GCC_NO_COMMON_BLOCKS = YES;
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
GCC_OPTIMIZATION_LEVEL = 0;
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1 $(inherited)";
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 18.6;
|
||||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
@@ -215,25 +241,6 @@
|
|||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
DB189EBE9D4E38495C3C7EF5 /* Debug */ = {
|
|
||||||
isa = XCBuildConfiguration;
|
|
||||||
buildSettings = {
|
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
|
||||||
CODE_SIGN_STYLE = Automatic;
|
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
|
||||||
ENABLE_PREVIEWS = YES;
|
|
||||||
GENERATE_INFOPLIST_FILE = NO;
|
|
||||||
INFOPLIST_FILE = QFT/Info.plist;
|
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
|
||||||
MARKETING_VERSION = 0.1.0;
|
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.qft.transfer;
|
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
||||||
SWIFT_EMIT_LOC_STRINGS = NO;
|
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
|
||||||
};
|
|
||||||
name = Debug;
|
|
||||||
};
|
|
||||||
C3DCEEC1E0EB17A5583B8E94 /* Release */ = {
|
C3DCEEC1E0EB17A5583B8E94 /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
@@ -248,9 +255,10 @@
|
|||||||
ENABLE_NS_ASSERTIONS = NO;
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
GCC_NO_COMMON_BLOCKS = YES;
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 18.6;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
SWIFT_COMPILATION_MODE = wholemodule;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
@@ -258,7 +266,7 @@
|
|||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
032222C0BAA33BC7119DFAF1 /* Release */ = {
|
DB189EBE9D4E38495C3C7EF5 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
@@ -268,19 +276,23 @@
|
|||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = NO;
|
GENERATE_INFOPLIST_FILE = NO;
|
||||||
INFOPLIST_FILE = QFT/Info.plist;
|
INFOPLIST_FILE = QFT/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
IPHONEOS_DEPLOYMENT_TARGET = 18.6;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
MARKETING_VERSION = 0.1.0;
|
MARKETING_VERSION = 0.1.0;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.qft.transfer;
|
PRODUCT_BUNDLE_IDENTIFIER = com.qft.transfer;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = NO;
|
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Debug;
|
||||||
};
|
};
|
||||||
/* End XCBuildConfiguration section */
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
/* Begin XCConfigurationList section */
|
/* Begin XCConfigurationList section */
|
||||||
26E84C2B3712F7DFAC8AD93F = {
|
26E84C2B3712F7DFAC8AD93F /* Build configuration list for PBXProject "QFT" */ = {
|
||||||
isa = XCConfigurationList;
|
isa = XCConfigurationList;
|
||||||
buildConfigurations = (
|
buildConfigurations = (
|
||||||
70DCC1EB255A5F3C8D9ED349 /* Debug */,
|
70DCC1EB255A5F3C8D9ED349 /* Debug */,
|
||||||
@@ -289,7 +301,7 @@
|
|||||||
defaultConfigurationIsVisible = 0;
|
defaultConfigurationIsVisible = 0;
|
||||||
defaultConfigurationName = Release;
|
defaultConfigurationName = Release;
|
||||||
};
|
};
|
||||||
A886B50DF087AEF7B87CDC65 = {
|
A886B50DF087AEF7B87CDC65 /* Build configuration list for PBXNativeTarget "QFT" */ = {
|
||||||
isa = XCConfigurationList;
|
isa = XCConfigurationList;
|
||||||
buildConfigurations = (
|
buildConfigurations = (
|
||||||
DB189EBE9D4E38495C3C7EF5 /* Debug */,
|
DB189EBE9D4E38495C3C7EF5 /* Debug */,
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "self:">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
||||||
Reference in New Issue
Block a user