mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
Merge branch 'main' into fix/gamespace-launcher
This commit is contained in:
30 files changed
+692
-38
No files matched your search
+2
-2
@@ -122,8 +122,8 @@ android {
|
||||
applicationId "com.droiddeck.launcher"
|
||||
minSdkVersion 26
|
||||
targetSdkVersion 28
|
||||
versionCode 14
|
||||
versionName "0.5.0"
|
||||
versionCode 15
|
||||
versionName "0.6.0"
|
||||
buildConfigField "String", "BUILD_LABEL", "\"${escapedBuildLabel}\""
|
||||
buildConfigField "String", "SOURCE_COMMIT", "\"${sourceCommit}\""
|
||||
buildConfigField "int", "PR_NUMBER", "${prNumber}"
|
||||
|
||||
@@ -24,6 +24,11 @@ object StoreLogFiles {
|
||||
Thread({ android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND); r.run() }, "store-log-flush").apply { isDaemon = true }
|
||||
}
|
||||
|
||||
private val CLOCK = SimpleDateFormat("HH:mm:ss.SSS", Locale.US)
|
||||
|
||||
/** Appends [text] with a time stamp. Works in any of the app's processes. */
|
||||
fun stamped(context: Context, text: String) = append(context, "${synchronized(CLOCK) { CLOCK.format(Date()) }} $text")
|
||||
|
||||
fun append(context: Context, line: String) {
|
||||
val app = context.applicationContext
|
||||
pending.add(line)
|
||||
|
||||
@@ -10,9 +10,6 @@ import androidx.compose.runtime.mutableStateMapOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.droiddeck.launcher.stores.download.DownloadEntry
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
object StoresState {
|
||||
private const val TAG = "Stores"
|
||||
@@ -262,7 +259,7 @@ object StoresState {
|
||||
val text = StoreLog.redactLine(raw)
|
||||
Log.i(TAG, text)
|
||||
val app = appContext ?: return
|
||||
StoreLogFiles.append(app, "${synchronized(CLOCK) { CLOCK.format(Date()) }} $text")
|
||||
StoreLogFiles.stamped(app, text)
|
||||
}
|
||||
|
||||
private var appContext: Context? = null
|
||||
@@ -295,8 +292,6 @@ object StoresState {
|
||||
}
|
||||
}, name).start()
|
||||
}
|
||||
|
||||
private val CLOCK = SimpleDateFormat("HH:mm:ss.SSS", Locale.US)
|
||||
}
|
||||
|
||||
interface StoreBackend {
|
||||
|
||||
@@ -29,10 +29,16 @@ internal class XboxCredentials(private val app: Context, expectedGeneration: Str
|
||||
}
|
||||
|
||||
private fun rejected(reason: String): Boolean {
|
||||
android.util.Log.w("XboxCredentials", "Rejected credential peer: $reason")
|
||||
note("Rejected credential peer: $reason")
|
||||
return false
|
||||
}
|
||||
|
||||
/** Also written to the stores log: sign-in runs in its own process, where only that file reaches a shared log. */
|
||||
private fun note(text: String) {
|
||||
android.util.Log.w("XboxCredentials", text)
|
||||
com.droiddeck.launcher.stores.StoreLogFiles.stamped(app, "Xbox credentials: $text")
|
||||
}
|
||||
|
||||
private fun authorized(pid: Int): Boolean {
|
||||
if (!bound.await(5, java.util.concurrent.TimeUnit.SECONDS) || closed) return rejected("unbound")
|
||||
val process = backend ?: return rejected("missing-child")
|
||||
@@ -88,7 +94,7 @@ internal class XboxCredentials(private val app: Context, expectedGeneration: Str
|
||||
answer(request)
|
||||
}
|
||||
}.getOrElse {
|
||||
android.util.Log.w("XboxCredentials", "Credential request rejected: ${it.javaClass.simpleName}")
|
||||
note("Credential request rejected: ${it.javaClass.simpleName}")
|
||||
JSONObject().put("ok", false)
|
||||
}
|
||||
runCatching { it.outputStream.write((reply.toString() + "\n").toByteArray()) }
|
||||
|
||||
@@ -63,7 +63,8 @@ class XboxLoginActivity : ComponentActivity() {
|
||||
Xodus.start(applicationContext, listOf("--external-webview-stdio", "login"), credentialGeneration = accountGeneration).use { process ->
|
||||
child = process
|
||||
if (closed) return@use
|
||||
Xodus.diagnostics(process)
|
||||
// StoresState.logLine writes no file in this process, so the reason would miss the shared log.
|
||||
Xodus.diagnostics(process) { logStep(it) }
|
||||
progress("waiting for the Xbox helper", "Waiting for the Xbox helper…")
|
||||
val timer = Thread({
|
||||
runCatching { if (!process.process.waitFor(10, TimeUnit.MINUTES)) process.process.destroy() }
|
||||
@@ -153,8 +154,7 @@ class XboxLoginActivity : ComponentActivity() {
|
||||
private fun logStep(line: String) {
|
||||
val text = StoreLog.redactLine("Xbox sign-in: $line")
|
||||
Log.i(TAG, text)
|
||||
val time = java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", java.util.Locale.US).format(java.util.Date())
|
||||
StoreLogFiles.append(applicationContext, "$time $text")
|
||||
StoreLogFiles.stamped(applicationContext, text)
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
|
||||
@@ -133,11 +133,12 @@ internal object Xodus {
|
||||
}
|
||||
}
|
||||
|
||||
fun diagnostics(child: Child): Thread = Thread({
|
||||
/** Passes the backend's known stderr diagnostics to [report]; other stderr text never leaves the process. */
|
||||
fun diagnostics(child: Child, report: (String) -> Unit = { com.droiddeck.launcher.stores.StoresState.logLine("Xbox: $it") }): Thread = Thread({
|
||||
runCatching {
|
||||
child.process.errorStream.bufferedReader().useLines { lines -> lines.forEach { line ->
|
||||
if (line.matches(Regex("NEXUS_CREDENTIAL_ERROR_V1 [a-z-]{1,48}|NEXUS_LIBRARY_DIAGNOSTIC_V1 [a-z-]{1,48} [0-9]{1,3} [0-9]{1,6}|NEXUS_SESSION_DIAGNOSTIC_V1 [a-z-]{1,64}|Account library unavailable \\([a-z-]{1,64}\\); credentials and installed games are unchanged\\.|Account library timed out; installed games are unchanged\\.|Xbox profile is temporarily unavailable \\([a-z-]{1,48}\\); stored account is unchanged\\.|Xbox profile request timed out; stored account is unchanged\\.")))
|
||||
com.droiddeck.launcher.stores.StoresState.logLine("Xbox: $line")
|
||||
report(line)
|
||||
} }
|
||||
}
|
||||
}, "xbox-diagnostics").apply { start() }
|
||||
|
||||
Reference in new issue
Block a user