mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 07:46:01 +00:00
Merge main (67b82ad9) into feat/bionic-runtime
No conflicts. EnhancedSessionLogShare.kt keeps main's RPCS3 log entries (#3130) next to this branch's bionic ones; SessionService.kt changes are apart. (The previous sync,cc5de0ba, merged main at7c8f5c27, notc298da6fas its message says.)
This commit is contained in:
commit
fbed69cef9
57 files changed
+1053
-98
No files matched your search
@@ -53,6 +53,8 @@ import com.droiddeck.launcher.session.SessionLogShare
|
|||||||
import com.droiddeck.launcher.session.SessionPaths
|
import com.droiddeck.launcher.session.SessionPaths
|
||||||
import com.droiddeck.launcher.session.SessionPrefs
|
import com.droiddeck.launcher.session.SessionPrefs
|
||||||
import com.droiddeck.launcher.session.SteamRepair
|
import com.droiddeck.launcher.session.SteamRepair
|
||||||
|
import com.droiddeck.launcher.session.LaunchCoordinator
|
||||||
|
import com.droiddeck.launcher.session.LaunchTicket
|
||||||
import com.droiddeck.launcher.core.CpuCores
|
import com.droiddeck.launcher.core.CpuCores
|
||||||
import com.droiddeck.launcher.core.DownloadSource
|
import com.droiddeck.launcher.core.DownloadSource
|
||||||
import com.droiddeck.launcher.core.PhantomProcessLimit
|
import com.droiddeck.launcher.core.PhantomProcessLimit
|
||||||
@@ -215,7 +217,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
private var soundtracksLoaded by mutableStateOf(false)
|
private var soundtracksLoaded by mutableStateOf(false)
|
||||||
private var gameStoresSpeedTier by mutableStateOf("fast")
|
private var gameStoresSpeedTier by mutableStateOf("fast")
|
||||||
private var navRequest by mutableStateOf<String?>(null)
|
private var navRequest by mutableStateOf<String?>(null)
|
||||||
private val gameLaunchRequest = java.util.concurrent.atomic.AtomicLong()
|
private val launchCoordinator = LaunchCoordinator<Intent, com.droiddeck.launcher.frontend.GameRequest>()
|
||||||
private var preparingGames by mutableStateOf(emptySet<String>())
|
private var preparingGames by mutableStateOf(emptySet<String>())
|
||||||
private var storesShowMature by mutableStateOf(false)
|
private var storesShowMature by mutableStateOf(false)
|
||||||
private var storesSort by mutableStateOf(SessionPrefs.STORES_SORTS.first())
|
private var storesSort by mutableStateOf(SessionPrefs.STORES_SORTS.first())
|
||||||
@@ -897,7 +899,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
runCatching { com.droiddeck.launcher.frontend.AutoComponents.restoreMissing(this) }.onFailure { Log.w(TAG, "components: restore failed", it) }
|
runCatching { com.droiddeck.launcher.frontend.AutoComponents.restoreMissing(this) }.onFailure { Log.w(TAG, "components: restore failed", it) }
|
||||||
}, "components-restore").start()
|
}, "components-restore").start()
|
||||||
}
|
}
|
||||||
private var pendingGameLink: com.droiddeck.launcher.frontend.GameRequest? = null
|
|
||||||
private var gameLinkReading = false
|
private var gameLinkReading = false
|
||||||
private var gameLinkTried = false
|
private var gameLinkTried = false
|
||||||
private var gameSyncFolder by mutableStateOf<String?>(null)
|
private var gameSyncFolder by mutableStateOf<String?>(null)
|
||||||
@@ -951,7 +952,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
else "settings:" + (com.droiddeck.launcher.ui.SettingsSection.of(section) ?: com.droiddeck.launcher.ui.SettingsSection.OVERVIEW).key
|
else "settings:" + (com.droiddeck.launcher.ui.SettingsSection.of(section) ?: com.droiddeck.launcher.ui.SettingsSection.OVERVIEW).key
|
||||||
request.data = null
|
request.data = null
|
||||||
gameLinkReading = false
|
gameLinkReading = false
|
||||||
pendingGameLink = null
|
|
||||||
syncDualPanel()
|
syncDualPanel()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -964,7 +964,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
steamGames = emptyList()
|
steamGames = emptyList()
|
||||||
shortcutLibraryScanning = true
|
shortcutLibraryScanning = true
|
||||||
} else shortcutLibraryScanning = false
|
} else shortcutLibraryScanning = false
|
||||||
pendingGameLink = null
|
|
||||||
gameLinkReading = false
|
gameLinkReading = false
|
||||||
gameLinkTried = false
|
gameLinkTried = false
|
||||||
soundtrackLaunch = false
|
soundtrackLaunch = false
|
||||||
@@ -977,6 +976,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (GameLaunchIntent.accepts(request.action)) {
|
if (GameLaunchIntent.accepts(request.action)) {
|
||||||
|
val ticket = launchCoordinator.beginLink(request)
|
||||||
gameLinkReading = true
|
gameLinkReading = true
|
||||||
com.droiddeck.launcher.ui.DualScreenPanel.hide(taskId)
|
com.droiddeck.launcher.ui.DualScreenPanel.hide(taskId)
|
||||||
val copy = Intent(request)
|
val copy = Intent(request)
|
||||||
@@ -985,12 +985,17 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
ui.post {
|
ui.post {
|
||||||
if (intent === request && !isDestroyed) {
|
if (intent === request && !isDestroyed) {
|
||||||
gameLinkReading = false
|
gameLinkReading = false
|
||||||
pendingGameLink = game
|
if (!launchCoordinator.resolve(ticket, game)) {
|
||||||
|
clearGameLinkIntent(request)
|
||||||
|
syncDualPanel()
|
||||||
|
return@post
|
||||||
|
}
|
||||||
if (game == null) {
|
if (game == null) {
|
||||||
|
launchCoordinator.consume(ticket)
|
||||||
syncDualPanel()
|
syncDualPanel()
|
||||||
android.widget.Toast.makeText(this, R.string.game_link_invalid, android.widget.Toast.LENGTH_LONG).show()
|
android.widget.Toast.makeText(this, R.string.game_link_invalid, android.widget.Toast.LENGTH_LONG).show()
|
||||||
} else {
|
} else {
|
||||||
handleGameLink(steamGames, scanned = false)
|
handleGameLink(steamGames, scanned = false, ticket = ticket)
|
||||||
refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -999,37 +1004,66 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun launchGame(game: Library.SteamGame, returnHome: Boolean = false, onHandled: () -> Unit = {}, onSettled: () -> Unit = {}) {
|
private fun beginUiLaunch(): LaunchTicket {
|
||||||
val request = gameLaunchRequest.incrementAndGet()
|
val dropped = launchCoordinator.pendingLink()
|
||||||
|
val ticket = launchCoordinator.beginLaunch()
|
||||||
|
dropped?.let { if (intent === it.owner) clearGameLinkIntent(it.owner) }
|
||||||
|
return ticket
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun clearGameLinkIntent(link: Intent) {
|
||||||
|
link.data = null
|
||||||
|
link.action = Intent.ACTION_MAIN
|
||||||
|
link.removeExtra(GameLaunchIntent.EXTRA_APP_ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun launchGame(
|
||||||
|
game: Library.SteamGame,
|
||||||
|
returnHome: Boolean = false,
|
||||||
|
onHandled: () -> Unit = {},
|
||||||
|
onSettled: () -> Unit = {},
|
||||||
|
ticket: LaunchTicket? = null,
|
||||||
|
) {
|
||||||
if (!SessionPrefs.soundtracksIngame(this)) com.droiddeck.launcher.playback.SoundtrackController.pause(this)
|
if (!SessionPrefs.soundtracksIngame(this)) com.droiddeck.launcher.playback.SoundtrackController.pause(this)
|
||||||
if (pkgStage != null) {
|
if (pkgStage != null) {
|
||||||
|
ticket?.let(launchCoordinator::releaseHandling)
|
||||||
onHandled()
|
onHandled()
|
||||||
android.widget.Toast.makeText(this, R.string.main_wait_install_game, android.widget.Toast.LENGTH_SHORT).show()
|
android.widget.Toast.makeText(this, R.string.main_wait_install_game, android.widget.Toast.LENGTH_SHORT).show()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
val request = ticket ?: beginUiLaunch()
|
||||||
|
if (!launchCoordinator.isCurrent(request)) {
|
||||||
|
onHandled()
|
||||||
|
return
|
||||||
|
}
|
||||||
val files = game.gameFiles
|
val files = game.gameFiles
|
||||||
if (game.source != com.droiddeck.launcher.stores.Store.XBOX.id || files == null) {
|
if (game.source != com.droiddeck.launcher.stores.Store.XBOX.id || files == null) {
|
||||||
if (startGame(game, returnHome, onHandled)) onSettled()
|
if (startGame(game, returnHome, onHandled, request)) onSettled()
|
||||||
|
else launchCoordinator.releaseHandling(request)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Thread({
|
Thread({
|
||||||
val refused = com.droiddeck.launcher.stores.xbox.XboxManifest.needsAppModel(files)
|
val refused = com.droiddeck.launcher.stores.xbox.XboxManifest.needsAppModel(files)
|
||||||
ui.post {
|
ui.post {
|
||||||
when {
|
when {
|
||||||
request != gameLaunchRequest.get() || isFinishing || isDestroyed -> onHandled()
|
!launchCoordinator.isCurrent(request) || isFinishing || isDestroyed -> {
|
||||||
|
launchCoordinator.releaseHandling(request)
|
||||||
|
onHandled()
|
||||||
|
}
|
||||||
refused -> {
|
refused -> {
|
||||||
onHandled()
|
onHandled()
|
||||||
android.widget.Toast.makeText(this, getString(R.string.game_needs_app_model, game.name), android.widget.Toast.LENGTH_LONG).show()
|
android.widget.Toast.makeText(this, getString(R.string.game_needs_app_model, game.name), android.widget.Toast.LENGTH_LONG).show()
|
||||||
onSettled()
|
onSettled()
|
||||||
}
|
}
|
||||||
startGame(game, returnHome, onHandled) -> onSettled()
|
startGame(game, returnHome, onHandled, request) -> onSettled()
|
||||||
|
else -> launchCoordinator.releaseHandling(request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "xbox-app-model").start()
|
}, "xbox-app-model").start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startGame(game: Library.SteamGame, returnHome: Boolean, onHandled: () -> Unit): Boolean {
|
private fun startGame(game: Library.SteamGame, returnHome: Boolean, onHandled: () -> Unit, ticket: LaunchTicket): Boolean {
|
||||||
if (com.droiddeck.launcher.session.NoSteamLaunch.enabled(this, game)) return launchWithoutSteam(game, returnHome, onHandled)
|
if (com.droiddeck.launcher.session.NoSteamLaunch.enabled(this, game)) return launchWithoutSteam(game, returnHome, onHandled, ticket)
|
||||||
onHandled()
|
onHandled()
|
||||||
if (SessionState.running) {
|
if (SessionState.running) {
|
||||||
if (SessionState.mode != SessionService.MODE_STEAM || SessionState.stopRequested) {
|
if (SessionState.mode != SessionService.MODE_STEAM || SessionState.stopRequested) {
|
||||||
@@ -1074,15 +1108,34 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
.apply { if (returnHome) putExtra(SessionActivity.EXTRA_LINK_TASK, task) }
|
.apply { if (returnHome) putExtra(SessionActivity.EXTRA_LINK_TASK, task) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun launchWithoutSteam(game: Library.SteamGame, returnHome: Boolean, onHandled: () -> Unit = {}): Boolean {
|
private fun launchWithoutSteam(
|
||||||
|
game: Library.SteamGame,
|
||||||
|
returnHome: Boolean,
|
||||||
|
onHandled: () -> Unit = {},
|
||||||
|
ticket: LaunchTicket? = null,
|
||||||
|
): Boolean {
|
||||||
|
if (pkgStage != null) {
|
||||||
|
onHandled()
|
||||||
|
android.widget.Toast.makeText(this, R.string.main_wait_install_game, android.widget.Toast.LENGTH_SHORT).show()
|
||||||
|
return false
|
||||||
|
}
|
||||||
val app = applicationContext
|
val app = applicationContext
|
||||||
|
val request = ticket ?: beginUiLaunch()
|
||||||
|
if (!launchCoordinator.isCurrent(request)) {
|
||||||
|
onHandled()
|
||||||
|
return false
|
||||||
|
}
|
||||||
Thread({
|
Thread({
|
||||||
val added = if (com.droiddeck.launcher.session.NoSteamLaunch.needsAddedGame(game)) runCatching { com.droiddeck.launcher.session.NoSteamLaunch.addedGame(app, game) }.getOrNull() else null
|
val added = if (com.droiddeck.launcher.session.NoSteamLaunch.needsAddedGame(game)) runCatching { com.droiddeck.launcher.session.NoSteamLaunch.addedGame(app, game) }.getOrNull() else null
|
||||||
val command = com.droiddeck.launcher.session.NoSteamLaunch.command(game, added)
|
val command = com.droiddeck.launcher.session.NoSteamLaunch.command(game, added)
|
||||||
ui.post {
|
ui.post {
|
||||||
onHandled()
|
onHandled()
|
||||||
if (isDestroyed) return@post
|
if (!launchCoordinator.isCurrent(request) || isFinishing || isDestroyed) {
|
||||||
|
launchCoordinator.releaseHandling(request)
|
||||||
|
return@post
|
||||||
|
}
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
|
launchCoordinator.releaseHandling(request)
|
||||||
android.widget.Toast.makeText(this, R.string.game_link_failed, android.widget.Toast.LENGTH_LONG).show()
|
android.widget.Toast.makeText(this, R.string.game_link_failed, android.widget.Toast.LENGTH_LONG).show()
|
||||||
return@post
|
return@post
|
||||||
}
|
}
|
||||||
@@ -1234,22 +1287,27 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
ui.postDelayed(poll, SESSION_SWITCH_POLL_MS)
|
ui.postDelayed(poll, SESSION_SWITCH_POLL_MS)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleGameLink(games: List<Library.SteamGame>, scanned: Boolean = true) {
|
private fun handleGameLink(games: List<Library.SteamGame>, scanned: Boolean = true, ticket: LaunchTicket? = null) {
|
||||||
if (!lifecycle.currentState.isAtLeast(androidx.lifecycle.Lifecycle.State.RESUMED)) return
|
if (!lifecycle.currentState.isAtLeast(androidx.lifecycle.Lifecycle.State.RESUMED)) return
|
||||||
val request = pendingGameLink ?: return
|
val link = launchCoordinator.pendingLink() ?: return
|
||||||
|
if (ticket != null && link.ticket !== ticket) return
|
||||||
|
val request = link.request ?: return
|
||||||
|
if (launchCoordinator.isHandling(link.ticket)) return
|
||||||
|
if (ticket == null && !link.ownedBy(intent)) {
|
||||||
|
// A refresh may only finish the link that belongs to the intent this activity shows.
|
||||||
|
launchCoordinator.consume(link.ticket)
|
||||||
|
return
|
||||||
|
}
|
||||||
val game = request.find(games, byTitle = scanned)
|
val game = request.find(games, byTitle = scanned)
|
||||||
if (!scanned && game == null) return
|
if (!scanned && game == null) return
|
||||||
gameLinkTried = true
|
gameLinkTried = true
|
||||||
ui.postDelayed({
|
ui.postDelayed({
|
||||||
if (!isDestroyed && lifecycle.currentState.isAtLeast(androidx.lifecycle.Lifecycle.State.RESUMED)) syncDualPanel()
|
if (!isDestroyed && lifecycle.currentState.isAtLeast(androidx.lifecycle.Lifecycle.State.RESUMED)) syncDualPanel()
|
||||||
}, LINK_PANEL_MS)
|
}, LINK_PANEL_MS)
|
||||||
val link = intent
|
val linkIntent = link.owner
|
||||||
fun consume() {
|
fun consume() {
|
||||||
if (intent !== link || pendingGameLink !== request) return
|
if (!launchCoordinator.consume(link.ticket)) return
|
||||||
pendingGameLink = null
|
if (intent === linkIntent) clearGameLinkIntent(linkIntent)
|
||||||
link.data = null
|
|
||||||
link.action = Intent.ACTION_MAIN
|
|
||||||
link.removeExtra(GameLaunchIntent.EXTRA_APP_ID)
|
|
||||||
}
|
}
|
||||||
if (game == null) {
|
if (game == null) {
|
||||||
consume()
|
consume()
|
||||||
@@ -1257,7 +1315,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
android.widget.Toast.makeText(this,
|
android.widget.Toast.makeText(this,
|
||||||
if (request.program != null) R.string.game_link_program_unknown else R.string.game_link_missing,
|
if (request.program != null) R.string.game_link_program_unknown else R.string.game_link_missing,
|
||||||
android.widget.Toast.LENGTH_LONG).show()
|
android.widget.Toast.LENGTH_LONG).show()
|
||||||
} else launchGame(game, returnHome = true, onSettled = ::consume)
|
} else {
|
||||||
|
if (!launchCoordinator.beginHandling(link.ticket)) return
|
||||||
|
launchGame(game, returnHome = true, onSettled = ::consume, ticket = link.ticket)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun chooseGameShortcut(game: Library.SteamGame) {
|
private fun chooseGameShortcut(game: Library.SteamGame) {
|
||||||
@@ -1448,16 +1509,20 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
},
|
},
|
||||||
onStoreGame = { store, id ->
|
onStoreGame = { store, id ->
|
||||||
val key = "${store.id}:$id"
|
val key = "${store.id}:$id"
|
||||||
if (key !in preparingGames) {
|
if (pkgStage != null) {
|
||||||
|
android.widget.Toast.makeText(this, R.string.main_wait_install_game, android.widget.Toast.LENGTH_SHORT).show()
|
||||||
|
} else if (key !in preparingGames) {
|
||||||
preparingGames = preparingGames + key
|
preparingGames = preparingGames + key
|
||||||
|
val ticket = beginUiLaunch()
|
||||||
val app = applicationContext
|
val app = applicationContext
|
||||||
Thread({
|
Thread({
|
||||||
val g = runCatching { com.droiddeck.launcher.stores.StoreLaunch.installedGame(app, store, id) }.getOrNull()
|
val g = runCatching { com.droiddeck.launcher.stores.StoreLaunch.installedGame(app, store, id) }.getOrNull()
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (g != null && !isFinishing && !isDestroyed) prepareAndLaunch(g, key)
|
if (g != null && launchCoordinator.isCurrent(ticket) && !isFinishing && !isDestroyed) {
|
||||||
else {
|
prepareAndLaunch(g, key, ticket)
|
||||||
|
} else {
|
||||||
preparingGames = preparingGames - key
|
preparingGames = preparingGames - key
|
||||||
if (g == null && !isFinishing && !isDestroyed) android.widget.Toast.makeText(this, R.string.stores_launch_not_registered, android.widget.Toast.LENGTH_LONG).show()
|
if (g == null && launchCoordinator.isCurrent(ticket) && !isFinishing && !isDestroyed) android.widget.Toast.makeText(this, R.string.stores_launch_not_registered, android.widget.Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "store-play").start()
|
}, "store-play").start()
|
||||||
@@ -1960,10 +2025,9 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
override fun onNewIntent(intent: Intent) {
|
override fun onNewIntent(intent: Intent) {
|
||||||
super.onNewIntent(intent)
|
super.onNewIntent(intent)
|
||||||
setIntent(intent)
|
setIntent(intent)
|
||||||
gameLaunchRequest.incrementAndGet()
|
supersedeUncommittedLaunch()
|
||||||
if (intent.action == SteamIntegration.ACTION_SETUP) {
|
if (intent.action == SteamIntegration.ACTION_SETUP) {
|
||||||
gameLinkReading = false
|
gameLinkReading = false
|
||||||
pendingGameLink = null
|
|
||||||
syncDualPanel()
|
syncDualPanel()
|
||||||
readIntegrationIntent(intent)
|
readIntegrationIntent(intent)
|
||||||
return
|
return
|
||||||
@@ -1973,6 +2037,11 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
startSteamAtStartupIfEnabled()
|
startSteamAtStartupIfEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A replacement activity intent supersedes anything this activity has not dispatched yet. */
|
||||||
|
private fun supersedeUncommittedLaunch() {
|
||||||
|
launchCoordinator.cancelAll()
|
||||||
|
}
|
||||||
|
|
||||||
private var soundtrackLaunch = false
|
private var soundtrackLaunch = false
|
||||||
|
|
||||||
// A restarted launcher starts before the old one stops, so each clears the hooks only if they are still its own.
|
// A restarted launcher starts before the old one stops, so each clears the hooks only if they are still its own.
|
||||||
@@ -2251,13 +2320,22 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
if (Build.VERSION.SDK_INT >= 33) state.getParcelable(key, Intent::class.java)
|
if (Build.VERSION.SDK_INT >= 33) state.getParcelable(key, Intent::class.java)
|
||||||
else @Suppress("DEPRECATION") state.getParcelable(key)
|
else @Suppress("DEPRECATION") state.getParcelable(key)
|
||||||
|
|
||||||
private fun prepareAndLaunch(g: Library.SteamGame, key: String) {
|
private fun prepareAndLaunch(g: Library.SteamGame, key: String, ticket: LaunchTicket? = null) {
|
||||||
val request = gameLaunchRequest.incrementAndGet()
|
if (pkgStage != null) {
|
||||||
|
preparingGames = preparingGames - key
|
||||||
|
android.widget.Toast.makeText(this, R.string.main_wait_install_game, android.widget.Toast.LENGTH_SHORT).show()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val request = ticket ?: beginUiLaunch()
|
||||||
|
if (!launchCoordinator.isCurrent(request)) {
|
||||||
|
preparingGames = preparingGames - key
|
||||||
|
return
|
||||||
|
}
|
||||||
val done = { preparingGames = preparingGames - key }
|
val done = { preparingGames = preparingGames - key }
|
||||||
com.droiddeck.launcher.frontend.AutoComponents.beforeLaunch(this, g, onBlocked = done) {
|
com.droiddeck.launcher.frontend.AutoComponents.beforeLaunch(this, g, onBlocked = done) {
|
||||||
if (request != gameLaunchRequest.get() || isFinishing || isDestroyed) { done(); return@beforeLaunch }
|
if (!launchCoordinator.isCurrent(request) || isFinishing || isDestroyed) { done(); return@beforeLaunch }
|
||||||
com.droiddeck.launcher.stores.StoreLaunch.prepare(this, g) {
|
com.droiddeck.launcher.stores.StoreLaunch.prepare(this, g) {
|
||||||
if (request == gameLaunchRequest.get() && !isFinishing && !isDestroyed) launchGame(g, onHandled = done)
|
if (launchCoordinator.isCurrent(request) && !isFinishing && !isDestroyed) launchGame(g, onHandled = done, ticket = request)
|
||||||
else done()
|
else done()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2267,7 +2345,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
// The queued launch was saved before this; a restored activity keeps its copy, and this one must not start it too.
|
// The queued launch was saved before this; a restored activity keeps its copy, and this one must not start it too.
|
||||||
queuedLaunchRunner.destroy()
|
queuedLaunchRunner.destroy()
|
||||||
triggerKeys.cancel()
|
triggerKeys.cancel()
|
||||||
gameLaunchRequest.incrementAndGet()
|
launchCoordinator.cancelAll()
|
||||||
cancelCompatLaunch()
|
cancelCompatLaunch()
|
||||||
updates.unregister()
|
updates.unregister()
|
||||||
runCatching { unregisterReceiver(shortcutsInstallStatus) }
|
runCatching { unregisterReceiver(shortcutsInstallStatus) }
|
||||||
@@ -2346,7 +2424,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
else com.droiddeck.launcher.ui.DualScreenPanel.hide(taskId)
|
else com.droiddeck.launcher.ui.DualScreenPanel.hide(taskId)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun launchPending(): Boolean = gameLinkReading || (pendingGameLink != null && !gameLinkTried)
|
private fun launchPending(): Boolean = gameLinkReading || (launchCoordinator.hasPending() && !gameLinkTried)
|
||||||
|
|
||||||
private fun launchAndroidApp(app: HomeApp.LaunchableApp, displayId: Int?) {
|
private fun launchAndroidApp(app: HomeApp.LaunchableApp, displayId: Int?) {
|
||||||
val onOwnScreen = displayId == null || displayId == (display?.displayId ?: Display.DEFAULT_DISPLAY)
|
val onOwnScreen = displayId == null || displayId == (display?.displayId ?: Display.DEFAULT_DISPLAY)
|
||||||
|
|||||||
@@ -875,9 +875,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
|||||||
cornerTap = SessionPrefs.drawerCornerTap(this)
|
cornerTap = SessionPrefs.drawerCornerTap(this)
|
||||||
applyOutputPacing()
|
applyOutputPacing()
|
||||||
if (!SessionState.running) {
|
if (!SessionState.running) {
|
||||||
SessionState.followScreen = followChoice()
|
SessionState.followScales = SessionPrefs.followScales(this, displayMode(),
|
||||||
SessionState.followScale = followScale()
|
com.droiddeck.launcher.session.SessionDisplay.panelSize(this))
|
||||||
}
|
}
|
||||||
|
applyFollowChoice()
|
||||||
applyFollowOrientation(resources.configuration)
|
applyFollowOrientation(resources.configuration)
|
||||||
goFullscreen()
|
goFullscreen()
|
||||||
volumeControlStream = android.media.AudioManager.STREAM_MUSIC
|
volumeControlStream = android.media.AudioManager.STREAM_MUSIC
|
||||||
@@ -2995,16 +2996,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
|||||||
|
|
||||||
private fun followPortrait(): Boolean = glassesScreen == null && SessionPrefs.portrait(this)
|
private fun followPortrait(): Boolean = glassesScreen == null && SessionPrefs.portrait(this)
|
||||||
|
|
||||||
private fun followScale(): Float {
|
private fun applyFollowChoice() {
|
||||||
val mode = displayMode()
|
val scale = SessionState.followScales.let { if (followPortrait()) it.second else it.first }
|
||||||
val choice = SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), followPortrait())
|
SessionState.followScreen = scale != null
|
||||||
return com.droiddeck.launcher.session.SessionDisplay.followScale(choice) ?: 1f
|
SessionState.followScale = scale ?: 1f
|
||||||
}
|
|
||||||
|
|
||||||
private fun followChoice(): Boolean {
|
|
||||||
val mode = displayMode()
|
|
||||||
return com.droiddeck.launcher.session.SessionDisplay.isFollow(
|
|
||||||
SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), followPortrait()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun applyFollowOrientation(config: android.content.res.Configuration) {
|
private fun applyFollowOrientation(config: android.content.res.Configuration) {
|
||||||
@@ -3018,6 +3013,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
|||||||
SessionService.setActivityDisplay(this, sessionActivityDisplayId)
|
SessionService.setActivityDisplay(this, sessionActivityDisplayId)
|
||||||
}
|
}
|
||||||
cancelTouchGestures()
|
cancelTouchGestures()
|
||||||
|
applyFollowChoice()
|
||||||
applyFollowOrientation(newConfig)
|
applyFollowOrientation(newConfig)
|
||||||
applyNotchInset()
|
applyNotchInset()
|
||||||
applyUnfoldedControls()
|
applyUnfoldedControls()
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.droiddeck.launcher.input
|
||||||
|
|
||||||
|
internal class AxisPacing(private val intervalMs: Long) {
|
||||||
|
private var lastWriteAt = 0L
|
||||||
|
private var written = false
|
||||||
|
private var heldUntil = NOT_HELD
|
||||||
|
|
||||||
|
fun dueAt(now: Long, axesOnly: Boolean): Long =
|
||||||
|
if (axesOnly && written && now - lastWriteAt < intervalMs) lastWriteAt + intervalMs else now
|
||||||
|
|
||||||
|
fun wrote(at: Long) {
|
||||||
|
lastWriteAt = at
|
||||||
|
written = true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hold(due: Long): Boolean {
|
||||||
|
if (heldUntil != NOT_HELD) return false
|
||||||
|
heldUntil = due
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun release(now: Long): Boolean {
|
||||||
|
if (heldUntil == NOT_HELD || now < heldUntil) return false
|
||||||
|
heldUntil = NOT_HELD
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun cancel(): Boolean {
|
||||||
|
if (heldUntil == NOT_HELD) return false
|
||||||
|
heldUntil = NOT_HELD
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val NOT_HELD = Long.MIN_VALUE
|
||||||
|
|
||||||
|
@JvmStatic fun keepsMoving(before: Int, after: Int): Boolean = before == after || (before != 0 && after != 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
package com.droiddeck.launcher.input;
|
package com.droiddeck.launcher.input;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.HandlerThread;
|
||||||
|
import android.os.Process;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -128,6 +132,16 @@ public class FakeInputWriter {
|
|||||||
|
|
||||||
private static final Object RING_LOCK = new Object();
|
private static final Object RING_LOCK = new Object();
|
||||||
private static final RingSlot[] RING_SLOTS = new RingSlot[MAX_FAKE_INPUT_SLOTS];
|
private static final RingSlot[] RING_SLOTS = new RingSlot[MAX_FAKE_INPUT_SLOTS];
|
||||||
|
private static final long AXIS_REPORT_INTERVAL_MS = 4;
|
||||||
|
|
||||||
|
private static final class Pacing {
|
||||||
|
static final Handler HANDLER;
|
||||||
|
static {
|
||||||
|
HandlerThread thread = new HandlerThread("pad-pacing", Process.THREAD_PRIORITY_DISPLAY);
|
||||||
|
thread.start();
|
||||||
|
HANDLER = new Handler(thread.getLooper());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("sdnative");
|
System.loadLibrary("sdnative");
|
||||||
@@ -156,6 +170,9 @@ public class FakeInputWriter {
|
|||||||
private boolean hasChanges = false;
|
private boolean hasChanges = false;
|
||||||
private boolean pendingFullResend = false;
|
private boolean pendingFullResend = false;
|
||||||
private boolean forceResend = false;
|
private boolean forceResend = false;
|
||||||
|
private final AxisPacing axisPacing = new AxisPacing(AXIS_REPORT_INTERVAL_MS);
|
||||||
|
private final PadState pacedPad = new PadState();
|
||||||
|
private final Runnable pacedWrite = this::writePacedPad;
|
||||||
|
|
||||||
public FakeInputWriter(String fakeInputPath, int slot) {
|
public FakeInputWriter(String fakeInputPath, int slot) {
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
@@ -711,10 +728,12 @@ public class FakeInputWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void close() {
|
public synchronized void close() {
|
||||||
|
cancelPacedWrite();
|
||||||
isOpen = false;
|
isOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void reset() {
|
public synchronized void reset() {
|
||||||
|
cancelPacedWrite();
|
||||||
if (!isOpen && !open())
|
if (!isOpen && !open())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -822,6 +841,53 @@ public class FakeInputWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void writePad(PadState state) {
|
public synchronized void writePad(PadState state) {
|
||||||
|
long now = SystemClock.uptimeMillis();
|
||||||
|
long due = axisPacing.dueAt(now, !pendingFullResend && onlyAxesMove(state));
|
||||||
|
if (due > now) {
|
||||||
|
pacedPad.copyFrom(state);
|
||||||
|
if (axisPacing.hold(due))
|
||||||
|
Pacing.HANDLER.postAtTime(pacedWrite, due);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cancelPacedWrite();
|
||||||
|
writePadNow(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void writePacedPad() {
|
||||||
|
if (axisPacing.release(SystemClock.uptimeMillis()))
|
||||||
|
writePadNow(pacedPad);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelPacedWrite() {
|
||||||
|
if (axisPacing.cancel())
|
||||||
|
Pacing.HANDLER.removeCallbacks(pacedWrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean onlyAxesMove(PadState state) {
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
if (prevButtonStates[i] != state.isDown(i))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return prevButtonStates[SNAPSHOT_IDX_MODE] == state.isDown(PadState.GUIDE)
|
||||||
|
&& prevQam == state.isDown(PadState.QAM)
|
||||||
|
&& prevHatX == state.hatX() && prevHatY == state.hatY()
|
||||||
|
&& AxisPacing.keepsMoving(prevThumbLX, stickValue(state.leftX))
|
||||||
|
&& AxisPacing.keepsMoving(prevThumbLY, stickValue(state.leftY))
|
||||||
|
&& AxisPacing.keepsMoving(prevThumbRX, stickValue(state.rightX))
|
||||||
|
&& AxisPacing.keepsMoving(prevThumbRY, stickValue(state.rightY))
|
||||||
|
&& AxisPacing.keepsMoving(prevTriggerL, triggerValue(state.leftTrigger))
|
||||||
|
&& AxisPacing.keepsMoving(prevTriggerR, triggerValue(state.rightTrigger));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int stickValue(float value) {
|
||||||
|
return (int) (value * 32767);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int triggerValue(float value) {
|
||||||
|
return (int) (value * 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writePadNow(PadState state) {
|
||||||
if (!isOpen && !open())
|
if (!isOpen && !open())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -845,10 +911,10 @@ public class FakeInputWriter {
|
|||||||
hasChanges = true;
|
hasChanges = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lx = (int) (state.leftX * 32767);
|
int lx = stickValue(state.leftX);
|
||||||
int ly = (int) (state.leftY * 32767);
|
int ly = stickValue(state.leftY);
|
||||||
int rx = (int) (state.rightX * 32767);
|
int rx = stickValue(state.rightX);
|
||||||
int ry = (int) (state.rightY * 32767);
|
int ry = stickValue(state.rightY);
|
||||||
|
|
||||||
if (forceResend || lx != prevThumbLX) {
|
if (forceResend || lx != prevThumbLX) {
|
||||||
prevThumbLX = lx;
|
prevThumbLX = lx;
|
||||||
@@ -867,8 +933,8 @@ public class FakeInputWriter {
|
|||||||
writeEvent(EV_ABS, ABS_RY, ry);
|
writeEvent(EV_ABS, ABS_RY, ry);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tl = (int) (state.leftTrigger * 255);
|
int tl = triggerValue(state.leftTrigger);
|
||||||
int tr = (int) (state.rightTrigger * 255);
|
int tr = triggerValue(state.rightTrigger);
|
||||||
if (forceResend || tl != prevTriggerL) {
|
if (forceResend || tl != prevTriggerL) {
|
||||||
prevTriggerL = tl;
|
prevTriggerL = tl;
|
||||||
writeEvent(EV_ABS, ABS_BRAKE, tl);
|
writeEvent(EV_ABS, ABS_BRAKE, tl);
|
||||||
@@ -895,6 +961,8 @@ public class FakeInputWriter {
|
|||||||
if (!flushBuffer()) {
|
if (!flushBuffer()) {
|
||||||
Log.e(TAG, "Gamepad write error: fake input mmap ring unavailable");
|
Log.e(TAG, "Gamepad write error: fake input mmap ring unavailable");
|
||||||
pendingFullResend = true;
|
pendingFullResend = true;
|
||||||
|
} else {
|
||||||
|
axisPacing.wrote(SystemClock.uptimeMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
forceResend = false;
|
forceResend = false;
|
||||||
|
|||||||
@@ -935,7 +935,7 @@ internal object EnhancedSessionLogShare {
|
|||||||
|
|
||||||
private fun category(entry: String): Category {
|
private fun category(entry: String): Category {
|
||||||
val value = entry.lowercase(Locale.US)
|
val value = entry.lowercase(Locale.US)
|
||||||
if (value.startsWith("battlenet/") || value.startsWith("stores/") || value.startsWith("tools/") ||
|
if (value.startsWith("battlenet/") || value.startsWith("stores/") || value.startsWith("tools/") || value.startsWith("rpcs3/") ||
|
||||||
value.contains("droiddeck-esync/") || GAME_LOG.matches(value.substringAfterLast('/')) ||
|
value.contains("droiddeck-esync/") || GAME_LOG.matches(value.substringAfterLast('/')) ||
|
||||||
listOf("proton", "wine", "dxvk", "vkd3d", "battle.net", "game-debug", "bionic").any(value::contains)) return Category.GAMES
|
listOf("proton", "wine", "dxvk", "vkd3d", "battle.net", "game-debug", "bionic").any(value::contains)) return Category.GAMES
|
||||||
if (listOf("wayland", "gamescope", "xwayland", "vulkan", "gpu", "mesa", "egl", "glx", "drm", "compositor", "frame-trace").any(value::contains)) return Category.GRAPHICS
|
if (listOf("wayland", "gamescope", "xwayland", "vulkan", "gpu", "mesa", "egl", "glx", "drm", "compositor", "frame-trace").any(value::contains)) return Category.GRAPHICS
|
||||||
@@ -950,6 +950,7 @@ internal object EnhancedSessionLogShare {
|
|||||||
"frame-trace.log", "process-trace.log", "game-lifecycle.log", "launches.log", "tools.tsv", "wanted.tsv", "prefixes.json",
|
"frame-trace.log", "process-trace.log", "game-lifecycle.log", "launches.log", "tools.tsv", "wanted.tsv", "prefixes.json",
|
||||||
"battlenet.log", "spawned.log", "flatpak-install.log", "cef_log.txt", "cef_log.previous.txt", "droiddeck-bionic.log",
|
"battlenet.log", "spawned.log", "flatpak-install.log", "cef_log.txt", "cef_log.previous.txt", "droiddeck-bionic.log",
|
||||||
"console_log.txt", "webhelper_js.txt", "controller_support.txt", "systemperfmanager.txt",
|
"console_log.txt", "webhelper_js.txt", "controller_support.txt", "systemperfmanager.txt",
|
||||||
|
"rpcs3", "RPCS3.log",
|
||||||
)
|
)
|
||||||
private val KNOWN_COMPONENT_PATTERNS = listOf(
|
private val KNOWN_COMPONENT_PATTERNS = listOf(
|
||||||
Regex("[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2,}-[a-z0-9-]{1,24}"),
|
Regex("[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2,}-[a-z0-9-]{1,24}"),
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package com.droiddeck.launcher.session
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Orders launch attempts and at most one pending game link.
|
||||||
|
*
|
||||||
|
* This is main-thread state: call it from the UI thread. A ticket is an identity,
|
||||||
|
* not a counter comparison, so a stale callback can only act on its own request.
|
||||||
|
*/
|
||||||
|
internal class LaunchTicket internal constructor(val serial: Long)
|
||||||
|
|
||||||
|
internal class LaunchCoordinator<O : Any, R : Any> {
|
||||||
|
internal class Link<O : Any, R : Any> internal constructor(
|
||||||
|
val ticket: LaunchTicket,
|
||||||
|
val owner: O,
|
||||||
|
val request: R?,
|
||||||
|
) {
|
||||||
|
/** Only the activity intent that delivered this link may finish it by a refresh. */
|
||||||
|
fun ownedBy(owner: O?): Boolean = this.owner === owner
|
||||||
|
}
|
||||||
|
|
||||||
|
private var next = 0L
|
||||||
|
private var current: LaunchTicket? = null
|
||||||
|
private var pending: Link<O, R>? = null
|
||||||
|
private var handling: LaunchTicket? = null
|
||||||
|
|
||||||
|
/** A launch that is allowed to proceed; it supersedes any pending link. */
|
||||||
|
fun beginLaunch(): LaunchTicket {
|
||||||
|
val ticket = LaunchTicket(++next)
|
||||||
|
current = ticket
|
||||||
|
pending = null
|
||||||
|
handling = null
|
||||||
|
return ticket
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A game-link intent; it supersedes any earlier launch or link. */
|
||||||
|
fun beginLink(owner: O): LaunchTicket {
|
||||||
|
val ticket = LaunchTicket(++next)
|
||||||
|
current = ticket
|
||||||
|
pending = Link(ticket, owner, null)
|
||||||
|
handling = null
|
||||||
|
return ticket
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The asynchronous link read returned; false means a newer request won. */
|
||||||
|
fun resolve(ticket: LaunchTicket, request: R?): Boolean {
|
||||||
|
val link = pending ?: return false
|
||||||
|
if (link.ticket !== ticket) return false
|
||||||
|
pending = Link(ticket, link.owner, request)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun beginHandling(ticket: LaunchTicket): Boolean {
|
||||||
|
val link = pending ?: return false
|
||||||
|
if (link.ticket !== ticket || link.request == null) return false
|
||||||
|
handling = ticket
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun releaseHandling(ticket: LaunchTicket) {
|
||||||
|
if (handling === ticket) handling = null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isHandling(ticket: LaunchTicket): Boolean = handling === ticket
|
||||||
|
fun isCurrent(ticket: LaunchTicket): Boolean = current === ticket
|
||||||
|
fun hasPending(): Boolean = pending != null
|
||||||
|
fun pendingLink(): Link<O, R>? = pending
|
||||||
|
|
||||||
|
fun consume(ticket: LaunchTicket): Boolean {
|
||||||
|
val link = pending ?: return false
|
||||||
|
if (link.ticket !== ticket) return false
|
||||||
|
pending = null
|
||||||
|
handling = null
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun cancelAll() {
|
||||||
|
next++
|
||||||
|
current = null
|
||||||
|
pending = null
|
||||||
|
handling = null
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -75,6 +75,7 @@ object SessionArtifacts {
|
|||||||
LogRedactor.learnFromRuntime(LinuxRuntime.rootDir(context))
|
LogRedactor.learnFromRuntime(LinuxRuntime.rootDir(context))
|
||||||
val record = Record(dir)
|
val record = Record(dir)
|
||||||
copySteamLogs(context, dir, record, steamArch)
|
copySteamLogs(context, dir, record, steamArch)
|
||||||
|
copyRpcs3Log(context, dir, record)
|
||||||
VacDiagnostics.collect(context, dir)
|
VacDiagnostics.collect(context, dir)
|
||||||
SessionLogCapture.dumpCrashBuffer(File(dir, "crash.log"))
|
SessionLogCapture.dumpCrashBuffer(File(dir, "crash.log"))
|
||||||
SessionLogCapture.dumpMemoryPressure(File(dir, "memory-pressure.log"))
|
SessionLogCapture.dumpMemoryPressure(File(dir, "memory-pressure.log"))
|
||||||
@@ -321,6 +322,9 @@ object SessionArtifacts {
|
|||||||
runCatching { File(dir, CLIENT_FILE).readText().trim() }.getOrNull()?.takeIf { it == "arm64" || it == "x86_64" }
|
runCatching { File(dir, CLIENT_FILE).readText().trim() }.getOrNull()?.takeIf { it == "arm64" || it == "x86_64" }
|
||||||
|
|
||||||
private const val LOG_MARKS = "steam-log-marks.txt"
|
private const val LOG_MARKS = "steam-log-marks.txt"
|
||||||
|
private const val RPCS3_LOG_MARKS = "rpcs3-log-marks.txt"
|
||||||
|
private const val RPCS3_LOGS = "root/.cache/rpcs3"
|
||||||
|
private const val RPCS3_LOG = "RPCS3.log"
|
||||||
private const val MAX_STEAM_LOG = 8L * 1024 * 1024
|
private const val MAX_STEAM_LOG = 8L * 1024 * 1024
|
||||||
private const val HEAD = 4096L
|
private const val HEAD = 4096L
|
||||||
|
|
||||||
@@ -328,11 +332,19 @@ object SessionArtifacts {
|
|||||||
private class CopyResult(val files: List<File>, val failed: Boolean, val deferred: Boolean)
|
private class CopyResult(val files: List<File>, val failed: Boolean, val deferred: Boolean)
|
||||||
|
|
||||||
fun markSteamLogs(dir: File, logs: File) {
|
fun markSteamLogs(dir: File, logs: File) {
|
||||||
val lines = logs.listFiles { f -> f.isFile }?.mapNotNull { f ->
|
logs.listFiles { f -> f.isFile }?.let { markLogs(dir, LOG_MARKS, it.toList()) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun markRpcs3Log(dir: File, root: File) {
|
||||||
|
markLogs(dir, RPCS3_LOG_MARKS, listOf(File(root, "$RPCS3_LOGS/$RPCS3_LOG")).filter { it.isFile })
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun markLogs(dir: File, marks: String, files: List<File>) {
|
||||||
|
val lines = files.mapNotNull { f ->
|
||||||
val size = f.length()
|
val size = f.length()
|
||||||
head(f, size)?.let { "$size\t$it\t${f.name}" }
|
head(f, size)?.let { "$size\t$it\t${f.name}" }
|
||||||
} ?: return
|
}
|
||||||
runCatching { File(dir, LOG_MARKS).writeText(lines.joinToString("") { "$it\n" }) }
|
runCatching { File(dir, marks).writeText(lines.joinToString("") { "$it\n" }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun head(f: File, length: Long): String? = runCatching {
|
private fun head(f: File, length: Long): String? = runCatching {
|
||||||
@@ -348,8 +360,8 @@ object SessionArtifacts {
|
|||||||
java.security.MessageDigest.getInstance("SHA-1").digest(buf).joinToString("") { "%02x".format(it) }
|
java.security.MessageDigest.getInstance("SHA-1").digest(buf).joinToString("") { "%02x".format(it) }
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
|
|
||||||
private fun steamLogMarks(dir: File): List<Mark>? = runCatching {
|
private fun logMarks(dir: File, marks: String): List<Mark>? = runCatching {
|
||||||
File(dir, LOG_MARKS).readLines().mapNotNull { line ->
|
File(dir, marks).readLines().mapNotNull { line ->
|
||||||
val parts = line.split('\t', limit = 3)
|
val parts = line.split('\t', limit = 3)
|
||||||
parts.getOrNull(0)?.toLongOrNull()?.let { size -> parts.getOrNull(1)?.let { Mark(size, it) } }
|
parts.getOrNull(0)?.toLongOrNull()?.let { size -> parts.getOrNull(1)?.let { Mark(size, it) } }
|
||||||
}
|
}
|
||||||
@@ -371,11 +383,32 @@ object SessionArtifacts {
|
|||||||
val logs = File(steamArch?.let { SessionPrefs.steamRoot(context, it) } ?: SessionPrefs.activeSteamRoot(context), "logs")
|
val logs = File(steamArch?.let { SessionPrefs.steamRoot(context, it) } ?: SessionPrefs.activeSteamRoot(context), "logs")
|
||||||
if (!logs.isDirectory) return
|
if (!logs.isDirectory) return
|
||||||
val out = File(dir, "steam").apply { mkdirs() }
|
val out = File(dir, "steam").apply { mkdirs() }
|
||||||
val result = copySessionLogsResult(logs, dir, out) { stopWhenSessionStarts && SessionState.running }
|
addCopied(record, copySessionLogsResult(logs, dir, out) { stopWhenSessionStarts && SessionState.running })
|
||||||
|
Log.i(TAG, "collected ${out.listFiles()?.size ?: 0} Steam log(s), scrubbed, into $out")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun copyRpcs3Log(context: Context, dir: File, record: Record, stopWhenSessionStarts: Boolean = false) {
|
||||||
|
val out = File(dir, "rpcs3")
|
||||||
|
val logs = File(LinuxRuntime.rootDir(context), RPCS3_LOGS)
|
||||||
|
val copied = copyRpcs3LogResult(logs, dir, out) { stopWhenSessionStarts && SessionState.running } ?: return
|
||||||
|
addCopied(record, copied)
|
||||||
|
if (copied.files.isNotEmpty()) Log.i(TAG, "collected RPCS3's log, scrubbed, into $out")
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun copyRpcs3Log(logs: File, dir: File, out: File): List<File> = copyRpcs3LogResult(logs, dir, out) { false }?.files.orEmpty()
|
||||||
|
|
||||||
|
private fun copyRpcs3LogResult(logs: File, dir: File, out: File, shouldStop: () -> Boolean): CopyResult? {
|
||||||
|
if (!File(dir, RPCS3_LOG_MARKS).isFile || !File(logs, RPCS3_LOG).isFile) return null
|
||||||
|
out.mkdirs()
|
||||||
|
val result = copySessionLogsResult(logs, dir, out, marksName = RPCS3_LOG_MARKS, accept = { it.name == RPCS3_LOG }, shouldStop = shouldStop)
|
||||||
|
if (result.files.isEmpty()) out.delete()
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addCopied(record: Record, result: CopyResult) {
|
||||||
result.files.forEach { dst -> record.files[dst] = Scrubbed(dst.length(), dst.lastModified()) }
|
result.files.forEach { dst -> record.files[dst] = Scrubbed(dst.length(), dst.lastModified()) }
|
||||||
record.failed = record.failed || result.failed
|
record.failed = record.failed || result.failed
|
||||||
record.deferred = record.deferred || result.deferred
|
record.deferred = record.deferred || result.deferred
|
||||||
Log.i(TAG, "collected ${out.listFiles()?.size ?: 0} Steam log(s), scrubbed, into $out")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun copySessionLogs(
|
internal fun copySessionLogs(
|
||||||
@@ -383,20 +416,22 @@ object SessionArtifacts {
|
|||||||
dir: File,
|
dir: File,
|
||||||
out: File,
|
out: File,
|
||||||
openWriter: (File) -> Writer = { it.bufferedWriter() },
|
openWriter: (File) -> Writer = { it.bufferedWriter() },
|
||||||
): List<File> = copySessionLogsResult(logs, dir, out, openWriter) { false }.files
|
): List<File> = copySessionLogsResult(logs, dir, out, openWriter = openWriter) { false }.files
|
||||||
|
|
||||||
private fun copySessionLogsResult(
|
private fun copySessionLogsResult(
|
||||||
logs: File,
|
logs: File,
|
||||||
dir: File,
|
dir: File,
|
||||||
out: File,
|
out: File,
|
||||||
|
marksName: String = LOG_MARKS,
|
||||||
|
accept: (File) -> Boolean = { true },
|
||||||
openWriter: (File) -> Writer = { it.bufferedWriter() },
|
openWriter: (File) -> Writer = { it.bufferedWriter() },
|
||||||
shouldStop: () -> Boolean,
|
shouldStop: () -> Boolean,
|
||||||
): CopyResult {
|
): CopyResult {
|
||||||
val marks = steamLogMarks(dir)
|
val marks = logMarks(dir, marksName)
|
||||||
val copied = ArrayList<File>()
|
val copied = ArrayList<File>()
|
||||||
var failed = false
|
var failed = false
|
||||||
var deferred = false
|
var deferred = false
|
||||||
val sources = logs.listFiles { f -> f.isFile } ?: return CopyResult(copied, true, false)
|
val sources = logs.listFiles { f -> f.isFile && accept(f) } ?: return CopyResult(copied, true, false)
|
||||||
for (src in sources) {
|
for (src in sources) {
|
||||||
if (shouldStop()) {
|
if (shouldStop()) {
|
||||||
failed = true
|
failed = true
|
||||||
@@ -567,6 +602,7 @@ object SessionArtifacts {
|
|||||||
steamArch = recordedClient(dir),
|
steamArch = recordedClient(dir),
|
||||||
stopWhenSessionStarts = stopWhenSessionStarts,
|
stopWhenSessionStarts = stopWhenSessionStarts,
|
||||||
)
|
)
|
||||||
|
copyRpcs3Log(context, dir, record, stopWhenSessionStarts)
|
||||||
if (!record.deferred && (!stopWhenSessionStarts || !SessionState.running)) {
|
if (!record.deferred && (!stopWhenSessionStarts || !SessionState.running)) {
|
||||||
if (!record.failed && VacDiagnostics.collect(context, dir)) {
|
if (!record.failed && VacDiagnostics.collect(context, dir)) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1343,6 +1343,10 @@ object SessionPrefs {
|
|||||||
SessionDisplay.effectiveChoice(
|
SessionDisplay.effectiveChoice(
|
||||||
resolutionStored(context, mode, panel, false), resolutionStored(context, mode, panel, true), portrait)
|
resolutionStored(context, mode, panel, false), resolutionStored(context, mode, panel, true), portrait)
|
||||||
|
|
||||||
|
fun followScales(context: Context, mode: String, panel: Pair<Int, Int>): Pair<Float?, Float?> =
|
||||||
|
SessionDisplay.followScale(resolutionChoice(context, mode, panel, false)) to
|
||||||
|
SessionDisplay.followScale(resolutionChoice(context, mode, panel, true))
|
||||||
|
|
||||||
fun resolutionStored(context: Context, mode: String, panel: Pair<Int, Int>, portrait: Boolean): String {
|
fun resolutionStored(context: Context, mode: String, panel: Pair<Int, Int>, portrait: Boolean): String {
|
||||||
if (!portrait) return landscapeResolutionStored(context, mode, panel)
|
if (!portrait) return landscapeResolutionStored(context, mode, panel)
|
||||||
val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return SessionDisplay.LINK_LANDSCAPE
|
val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return SessionDisplay.LINK_LANDSCAPE
|
||||||
|
|||||||
@@ -1073,6 +1073,7 @@ class SessionService : Service() {
|
|||||||
guest.addAll(GpuStatsComponent.guestEnv(LinuxRuntime.rootDir(this)))
|
guest.addAll(GpuStatsComponent.guestEnv(LinuxRuntime.rootDir(this)))
|
||||||
guest.add("GLIBC_TUNABLES=glibc.pthread.rseq=0:glibc.malloc.top_pad=16777216")
|
guest.add("GLIBC_TUNABLES=glibc.pthread.rseq=0:glibc.malloc.top_pad=16777216")
|
||||||
if (SessionState.mode == MODE_STEAM) guest.add("DD_MANGOAPP=" + (if (SessionPrefs.mangoapp(this)) "1" else "0"))
|
if (SessionState.mode == MODE_STEAM) guest.add("DD_MANGOAPP=" + (if (SessionPrefs.mangoapp(this)) "1" else "0"))
|
||||||
|
SessionPaths.current()?.let { SessionArtifacts.markRpcs3Log(it, LinuxRuntime.rootDir(this)) }
|
||||||
SessionState.steamClientArch = if (steamHere) SessionPrefs.steamClientArch(this) else null
|
SessionState.steamClientArch = if (steamHere) SessionPrefs.steamClientArch(this) else null
|
||||||
SessionState.steamClientArch?.let { arch ->
|
SessionState.steamClientArch?.let { arch ->
|
||||||
guest.add("DD_STEAM_CLIENT_ARCH=$arch")
|
guest.add("DD_STEAM_CLIENT_ARCH=$arch")
|
||||||
|
|||||||
@@ -148,6 +148,9 @@ object SessionState {
|
|||||||
@Volatile
|
@Volatile
|
||||||
var outputSize: Pair<Int, Int> = Pair(1920, 1080)
|
var outputSize: Pair<Int, Int> = Pair(1920, 1080)
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
var followScales: Pair<Float?, Float?> = null to null
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
var followScreen = false
|
var followScreen = false
|
||||||
var followScale = 1f
|
var followScale = 1f
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ class StoreLoginActivity : ComponentActivity() {
|
|||||||
val readsPage: Boolean get() = false
|
val readsPage: Boolean get() = false
|
||||||
val pageScript: String get() = "(function(){ try { return document.body.innerText; } catch(e){ return ''; } })()"
|
val pageScript: String get() = "(function(){ try { return document.body.innerText; } catch(e){ return ''; } })()"
|
||||||
fun pageReady(result: String): Boolean = true
|
fun pageReady(result: String): Boolean = true
|
||||||
|
fun browserStep(page: String): String? = null
|
||||||
fun forgetSignIn(done: () -> Unit) = done()
|
fun forgetSignIn(done: () -> Unit) = done()
|
||||||
fun pageFinished(view: WebView, url: String) {}
|
fun pageFinished(view: WebView, url: String) {}
|
||||||
}
|
}
|
||||||
@@ -72,6 +73,7 @@ class StoreLoginActivity : ComponentActivity() {
|
|||||||
private var store: Store? = null
|
private var store: Store? = null
|
||||||
private var clientUrl: String? = null
|
private var clientUrl: String? = null
|
||||||
private var flow: Flow? = null
|
private var flow: Flow? = null
|
||||||
|
private var pendingBrowserStep: String? = null
|
||||||
private var webViewRef: WebView? = null
|
private var webViewRef: WebView? = null
|
||||||
private var popupWebView: WebView? = null
|
private var popupWebView: WebView? = null
|
||||||
private lateinit var contentHost: FrameLayout
|
private lateinit var contentHost: FrameLayout
|
||||||
@@ -211,6 +213,7 @@ class StoreLoginActivity : ComponentActivity() {
|
|||||||
|
|
||||||
private fun reloadLogin() {
|
private fun reloadLogin() {
|
||||||
dismissPopup(); clearError()
|
dismissPopup(); clearError()
|
||||||
|
pendingBrowserStep = null
|
||||||
captured.set(false)
|
captured.set(false)
|
||||||
val fresh = generateState()
|
val fresh = generateState()
|
||||||
oauthState = fresh
|
oauthState = fresh
|
||||||
@@ -332,9 +335,13 @@ class StoreLoginActivity : ComponentActivity() {
|
|||||||
|
|
||||||
private fun readPage(view: WebView, f: Flow, left: Int) {
|
private fun readPage(view: WebView, f: Flow, left: Int) {
|
||||||
view.evaluateJavascript(f.pageScript) { json ->
|
view.evaluateJavascript(f.pageScript) { json ->
|
||||||
|
if (flow !== f) return@evaluateJavascript
|
||||||
val result = json ?: ""
|
val result = json ?: ""
|
||||||
if (!f.pageReady(result) && left > 0) view.postDelayed({ readPage(view, f, left - 1) }, PAGE_RETRY_MS)
|
if (!f.pageReady(result) && left > 0) view.postDelayed({ readPage(view, f, left - 1) }, PAGE_RETRY_MS)
|
||||||
else Thread({ settle(f.finish(this, view, result)) }, "store-login").start()
|
else {
|
||||||
|
val step = f.browserStep(result)
|
||||||
|
if (step == null || !continueInBrowser(step)) Thread({ settle(f.finish(this, view, result)) }, "store-login").start()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,6 +357,21 @@ class StoreLoginActivity : ComponentActivity() {
|
|||||||
if (f.readsPage) readPage(view, f, PAGE_TRIES) else Thread({ settle(f.finish(this, view, url)) }, "store-login").start()
|
if (f.readsPage) readPage(view, f, PAGE_TRIES) else Thread({ settle(f.finish(this, view, url)) }, "store-login").start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun continueInBrowser(url: String): Boolean {
|
||||||
|
if (isFinishing || isDestroyed) return false
|
||||||
|
if (!lifecycle.currentState.isAtLeast(androidx.lifecycle.Lifecycle.State.STARTED)) {
|
||||||
|
pendingBrowserStep = url
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
val opened = runCatching { startActivity(android.content.Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url))) }
|
||||||
|
.onFailure { Log.w(TAG, "no browser took the sign-in step: ${it.javaClass.simpleName}") }
|
||||||
|
.isSuccess
|
||||||
|
if (!opened) return false
|
||||||
|
titleText.text = getString(R.string.stores_login_title, store?.label ?: "")
|
||||||
|
showError(getString(R.string.stores_login_continue_in_browser, store?.label ?: ""))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
private fun settle(problem: String?) {
|
private fun settle(problem: String?) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (problem == null) { StoresState.refresh(this); finish(); return@runOnUiThread }
|
if (problem == null) { StoresState.refresh(this); finish(); return@runOnUiThread }
|
||||||
@@ -367,6 +389,10 @@ class StoreLoginActivity : ComponentActivity() {
|
|||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
|
pendingBrowserStep?.let { step ->
|
||||||
|
pendingBrowserStep = null
|
||||||
|
if (!continueInBrowser(step)) reloadLogin()
|
||||||
|
}
|
||||||
if (clientUrl != null && !isFinishing) com.droiddeck.launcher.session.SessionService.holdForSignIn(this, true)
|
if (clientUrl != null && !isFinishing) com.droiddeck.launcher.session.SessionService.holdForSignIn(this, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ import android.webkit.WebView
|
|||||||
import com.droiddeck.launcher.R
|
import com.droiddeck.launcher.R
|
||||||
import com.droiddeck.launcher.stores.StoreLoginActivity
|
import com.droiddeck.launcher.stores.StoreLoginActivity
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import org.json.JSONTokener
|
||||||
|
|
||||||
internal class EpicLogin private constructor(
|
internal class EpicLogin internal constructor(
|
||||||
override val startUrl: String,
|
override val startUrl: String,
|
||||||
override val userAgent: String,
|
override val userAgent: String,
|
||||||
private val redirectPrefix: String,
|
private val redirectPrefix: String,
|
||||||
@@ -15,6 +16,12 @@ internal class EpicLogin private constructor(
|
|||||||
|
|
||||||
override fun isRedirect(url: String): Boolean = url.startsWith(redirectPrefix)
|
override fun isRedirect(url: String): Boolean = url.startsWith(redirectPrefix)
|
||||||
|
|
||||||
|
override fun browserStep(page: String): String? {
|
||||||
|
val action = correctiveAction(page) ?: return null
|
||||||
|
Log.i(TAG, "the redirect page asks for a corrective action: $action")
|
||||||
|
return ACCOUNT_SIGN_IN_URL
|
||||||
|
}
|
||||||
|
|
||||||
override fun finish(activity: StoreLoginActivity, view: WebView, url: String): String? {
|
override fun finish(activity: StoreLoginActivity, view: WebView, url: String): String? {
|
||||||
val code = EpicNative.call("auth.codeFromPage", JSONObject().put("text", url))?.optString("code", "").orEmpty()
|
val code = EpicNative.call("auth.codeFromPage", JSONObject().put("text", url))?.optString("code", "").orEmpty()
|
||||||
if (code.isEmpty()) {
|
if (code.isEmpty()) {
|
||||||
@@ -38,6 +45,15 @@ internal class EpicLogin private constructor(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "EpicLogin"
|
private const val TAG = "EpicLogin"
|
||||||
|
private const val CORRECTIVE_ACTION_REQUIRED = "errors.com.epicgames.oauth.corrective_action_required"
|
||||||
|
internal const val ACCOUNT_SIGN_IN_URL = "https://www.epicgames.com/id/login?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Faccount%2Fpersonal"
|
||||||
|
|
||||||
|
internal fun correctiveAction(page: String): String? {
|
||||||
|
val text = runCatching { JSONTokener(page).nextValue() }.getOrNull() as? String ?: page
|
||||||
|
val body = runCatching { JSONObject(text.trim()) }.getOrNull() ?: return null
|
||||||
|
if (body.optString("errorCode") != CORRECTIVE_ACTION_REQUIRED) return null
|
||||||
|
return body.optJSONObject("metadata")?.optString("correctiveAction").orEmpty().ifEmpty { "unknown" }
|
||||||
|
}
|
||||||
|
|
||||||
fun create(): StoreLoginActivity.Flow? {
|
fun create(): StoreLoginActivity.Flow? {
|
||||||
val config = EpicNative.call("auth.config") ?: return null
|
val config = EpicNative.call("auth.config") ?: return null
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ import com.droiddeck.launcher.IconPack
|
|||||||
import android.content.pm.ShortcutInfo
|
import android.content.pm.ShortcutInfo
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.flow.drop
|
import kotlinx.coroutines.flow.drop
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import com.droiddeck.launcher.HomeWidgets
|
import com.droiddeck.launcher.HomeWidgets
|
||||||
@@ -388,21 +389,49 @@ internal fun AndroidAppsPage(s: FrontEndState, a: FrontEndActions, modifier: Mod
|
|||||||
}
|
}
|
||||||
val front = LocalFrontFocus.current
|
val front = LocalFrontFocus.current
|
||||||
val steer = rememberCoroutineScope()
|
val steer = rememberCoroutineScope()
|
||||||
// Down goes to the tile straight below. The grid's own search only sees the tiles laid out so far, so above a short or
|
// The tile a move is heading to, by its id so that a list update cannot shift it, and the number of the latest move.
|
||||||
|
val aim = remember { arrayOfNulls<String>(1) }
|
||||||
|
val moves = remember { intArrayOf(0) }
|
||||||
|
val move = remember { arrayOfNulls<Job>(1) }
|
||||||
|
// Up and Down go to the tile straight above or below. The grid's own search works from where the tiles are drawn at that
|
||||||
|
// moment, so while a scroll is still catching up with fast presses it skips a row or drifts a column, and above a short or
|
||||||
// unseen last row it lands on a tile further left; above a gap in a short last row the row's last tile takes it.
|
// unseen last row it lands on a tile further left; above a gap in a short last row the row's last tile takes it.
|
||||||
|
// Presses aim from the tile a move is already heading to, so none is lost before the focus lands.
|
||||||
Box(Modifier.weight(1f).fillMaxWidth().onPreviewKeyEvent { event ->
|
Box(Modifier.weight(1f).fillMaxWidth().onPreviewKeyEvent { event ->
|
||||||
val k = event.nativeKeyEvent
|
val k = event.nativeKeyEvent
|
||||||
if (k.keyCode != KeyEvent.KEYCODE_DPAD_DOWN || front == null) return@onPreviewKeyEvent false
|
val down = k.keyCode == KeyEvent.KEYCODE_DPAD_DOWN
|
||||||
val from = entries.indexOfFirst { tileId(it) == front.last }
|
if ((!down && k.keyCode != KeyEvent.KEYCODE_DPAD_UP) || front == null) return@onPreviewKeyEvent false
|
||||||
|
val aimed = aim[0]?.let { id -> entries.indexOfFirst { tileId(it) == id } } ?: -1
|
||||||
|
if (aim[0] != null && aimed < 0) {
|
||||||
|
// The tile a move was heading to has left the list: that move is dropped and the press aims from the focus.
|
||||||
|
move[0]?.cancel()
|
||||||
|
aim[0] = null
|
||||||
|
}
|
||||||
|
val from = aimed.takeIf { it >= 0 } ?: entries.indexOfFirst { tileId(it) == front.last }
|
||||||
val columns = (grid.layoutInfo.visibleItemsInfo.maxOfOrNull { it.column } ?: 0) + 1
|
val columns = (grid.layoutInfo.visibleItemsInfo.maxOfOrNull { it.column } ?: 0) + 1
|
||||||
if (from < 0 || from / columns == entries.lastIndex / columns) return@onPreviewKeyEvent false
|
if (from < 0) return@onPreviewKeyEvent false
|
||||||
|
// At the first or last row the press leaves the grid, unless a move has not landed yet: then it waits for it.
|
||||||
|
val edge = if (down) from / columns == entries.lastIndex / columns else from < columns
|
||||||
|
if (edge) return@onPreviewKeyEvent aim[0] != null
|
||||||
if (k.action == KeyEvent.ACTION_DOWN) {
|
if (k.action == KeyEvent.ACTION_DOWN) {
|
||||||
val id = tileId(entries[minOf(from + columns, entries.lastIndex)])
|
val to = if (down) minOf(from + columns, entries.lastIndex) else from - columns
|
||||||
val shown = (front.attached[id] ?: 0) > 0
|
val id = tileId(entries[to])
|
||||||
if (!shown || runCatching { front.items.getValue(id).requestFocus() }.isFailure) steer.launch {
|
aim[0] = id
|
||||||
// The row below is not laid out yet: bring it in, then take it.
|
val mine = ++moves[0]
|
||||||
if (!shown) grid.scrollBy((grid.layoutInfo.visibleItemsInfo.firstOrNull { it.index == from + leadItems }?.size?.height ?: 0).toFloat())
|
// A newer move replaces the one still on its way, so an older target cannot take focus after it lands.
|
||||||
|
move[0]?.cancel()
|
||||||
|
move[0] = steer.launch {
|
||||||
|
try {
|
||||||
|
// Show the row before it takes focus. The grid composes rows ahead of the view without placing them, and a
|
||||||
|
// tile focused there neither scrolls in nor has a place for the next search to start from.
|
||||||
|
grid.reveal(to + leadItems)
|
||||||
|
if (moves[0] != mine) return@launch
|
||||||
focusSoon { front.items.getValue(id) }
|
focusSoon { front.items.getValue(id) }
|
||||||
|
} finally {
|
||||||
|
// Also when a touch scroll cancels the reveal, so the edge rows do not keep waiting for a move that ended.
|
||||||
|
// Only the latest move clears it: a cancelled one finishing late must not clear a newer move's target.
|
||||||
|
if (moves[0] == mine) aim[0] = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
@@ -558,6 +587,26 @@ private fun HeaderChoiceButton(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Scrolls the least that shows item [index] whole inside the padding, a row at a time while it is still outside the laid out items. */
|
||||||
|
private suspend fun LazyGridState.reveal(index: Int) {
|
||||||
|
repeat(4) {
|
||||||
|
val info = layoutInfo
|
||||||
|
val shown = info.visibleItemsInfo
|
||||||
|
val item = shown.firstOrNull { it.index == index }
|
||||||
|
val by = when {
|
||||||
|
item != null -> {
|
||||||
|
val bottom = item.offset.y + item.size.height - (info.viewportEndOffset - info.afterContentPadding)
|
||||||
|
if (item.offset.y < 0) item.offset.y else maxOf(bottom, 0)
|
||||||
|
}
|
||||||
|
index > (shown.lastOrNull() ?: return).index -> shown.last().size.height
|
||||||
|
index < shown.first().index -> -shown.first().size.height
|
||||||
|
else -> return
|
||||||
|
}
|
||||||
|
if (by == 0) return
|
||||||
|
scrollBy(by.toFloat())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun AlphabetScroller(entries: List<AppEntry>, grid: LazyGridState, leadItems: Int, modifier: Modifier) {
|
private fun AlphabetScroller(entries: List<AppEntry>, grid: LazyGridState, leadItems: Int, modifier: Modifier) {
|
||||||
val colors = MaterialTheme.colorScheme
|
val colors = MaterialTheme.colorScheme
|
||||||
|
|||||||
@@ -1098,8 +1098,6 @@ internal fun GameSettingsMenus(host: MenuHost, game: com.droiddeck.launcher.fron
|
|||||||
|
|
||||||
internal const val GAME_SETTINGS_MENU = "game-settings"
|
internal const val GAME_SETTINGS_MENU = "game-settings"
|
||||||
|
|
||||||
private const val EPIC_RESOLVE_URL = "https://www.epicgames.com/id/login?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Faccount%2Fpersonal"
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun StoreLaunchCard(host: MenuHost, folder: java.io.File, store: com.droiddeck.launcher.stores.Store) {
|
private fun StoreLaunchCard(host: MenuHost, folder: java.io.File, store: com.droiddeck.launcher.stores.Store) {
|
||||||
val appContext = androidx.compose.ui.platform.LocalContext.current.applicationContext
|
val appContext = androidx.compose.ui.platform.LocalContext.current.applicationContext
|
||||||
@@ -1149,7 +1147,7 @@ private fun StoreLaunchCard(host: MenuHost, folder: java.io.File, store: com.dro
|
|||||||
MenuItem(stringResource(R.string.epic_resolve), checked = false) {
|
MenuItem(stringResource(R.string.epic_resolve), checked = false) {
|
||||||
host.open = null
|
host.open = null
|
||||||
runCatching {
|
runCatching {
|
||||||
appContext.startActivity(android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(EPIC_RESOLVE_URL)).addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK))
|
appContext.startActivity(android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(com.droiddeck.launcher.stores.epic.EpicLogin.ACCOUNT_SIGN_IN_URL)).addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2818,6 +2818,7 @@
|
|||||||
<string name="stores_login_error_ssl">الاتصال بصفحة تسجيل الدخول غير آمن.</string>
|
<string name="stores_login_error_ssl">الاتصال بصفحة تسجيل الدخول غير آمن.</string>
|
||||||
<string name="stores_login_error_verification">تعذّر التحقّق من تسجيل الدخول. حاوِل مرة أخرى.</string>
|
<string name="stores_login_error_verification">تعذّر التحقّق من تسجيل الدخول. حاوِل مرة أخرى.</string>
|
||||||
<string name="stores_login_error_generic">فشل تسجيل الدخول. حاوِل مرة أخرى.</string>
|
<string name="stores_login_error_generic">فشل تسجيل الدخول. حاوِل مرة أخرى.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">يحتاج %1$s إلى خطوة أخرى. أكملها في المتصفح الذي فُتح، ثم حاول مرة أخرى.</string>
|
||||||
<string name="common_close">إغلاق</string>
|
<string name="common_close">إغلاق</string>
|
||||||
<string name="common_back">رجوع</string>
|
<string name="common_back">رجوع</string>
|
||||||
<string name="common_edit">تعديل</string>
|
<string name="common_edit">تعديل</string>
|
||||||
|
|||||||
@@ -2784,6 +2784,7 @@
|
|||||||
<string name="stores_login_error_ssl">La conexión con la página de inicio de sesión no es segura.</string>
|
<string name="stores_login_error_ssl">La conexión con la página de inicio de sesión no es segura.</string>
|
||||||
<string name="stores_login_error_verification">No se pudo verificar el inicio de sesión. Inténtalo de nuevo.</string>
|
<string name="stores_login_error_verification">No se pudo verificar el inicio de sesión. Inténtalo de nuevo.</string>
|
||||||
<string name="stores_login_error_generic">No se pudo iniciar sesión. Inténtalo de nuevo.</string>
|
<string name="stores_login_error_generic">No se pudo iniciar sesión. Inténtalo de nuevo.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s necesita un paso más. Complétalo en el navegador que se abrió y vuelve a intentarlo.</string>
|
||||||
<string name="common_close">Cerrar</string>
|
<string name="common_close">Cerrar</string>
|
||||||
<string name="common_back">Atrás</string>
|
<string name="common_back">Atrás</string>
|
||||||
<string name="common_edit">Editar</string>
|
<string name="common_edit">Editar</string>
|
||||||
|
|||||||
@@ -2714,6 +2714,7 @@
|
|||||||
<string name="stores_login_error_ssl">Връзката със страницата за вход не е защитена.</string>
|
<string name="stores_login_error_ssl">Връзката със страницата за вход не е защитена.</string>
|
||||||
<string name="stores_login_error_verification">Входът не можа да бъде потвърден. Опитай отново.</string>
|
<string name="stores_login_error_verification">Входът не можа да бъде потвърден. Опитай отново.</string>
|
||||||
<string name="stores_login_error_generic">Входът се провали. Опитай отново.</string>
|
<string name="stores_login_error_generic">Входът се провали. Опитай отново.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s изисква още една стъпка. Завърши я в браузъра, който се отвори, и опитай отново.</string>
|
||||||
<string name="common_close">Затвори</string>
|
<string name="common_close">Затвори</string>
|
||||||
<string name="common_back">Назад</string>
|
<string name="common_back">Назад</string>
|
||||||
<string name="common_edit">Редактирай</string>
|
<string name="common_edit">Редактирай</string>
|
||||||
|
|||||||
@@ -2766,6 +2766,7 @@
|
|||||||
<string name="stores_login_error_ssl">Spojení s přihlašovací stránkou není zabezpečené.</string>
|
<string name="stores_login_error_ssl">Spojení s přihlašovací stránkou není zabezpečené.</string>
|
||||||
<string name="stores_login_error_verification">Přihlášení se nepodařilo ověřit. Zkuste to znovu.</string>
|
<string name="stores_login_error_verification">Přihlášení se nepodařilo ověřit. Zkuste to znovu.</string>
|
||||||
<string name="stores_login_error_generic">Přihlášení se nezdařilo. Zkuste to znovu.</string>
|
<string name="stores_login_error_generic">Přihlášení se nezdařilo. Zkuste to znovu.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s vyžaduje ještě jeden krok. Dokončete ho v prohlížeči, který se otevřel, a zkuste to znovu.</string>
|
||||||
<string name="common_close">Zavřít</string>
|
<string name="common_close">Zavřít</string>
|
||||||
<string name="common_back">Zpět</string>
|
<string name="common_back">Zpět</string>
|
||||||
<string name="common_edit">Upravit</string>
|
<string name="common_edit">Upravit</string>
|
||||||
|
|||||||
@@ -2714,6 +2714,7 @@
|
|||||||
<string name="stores_login_error_ssl">Forbindelsen til loginsiden er ikke sikker.</string>
|
<string name="stores_login_error_ssl">Forbindelsen til loginsiden er ikke sikker.</string>
|
||||||
<string name="stores_login_error_verification">Login kunne ikke bekræftes. Forsøg igen.</string>
|
<string name="stores_login_error_verification">Login kunne ikke bekræftes. Forsøg igen.</string>
|
||||||
<string name="stores_login_error_generic">Login mislykkedes. Forsøg igen.</string>
|
<string name="stores_login_error_generic">Login mislykkedes. Forsøg igen.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s kræver et trin mere. Fuldfør det i browseren, der blev åbnet, og prøv igen.</string>
|
||||||
<string name="common_close">Luk</string>
|
<string name="common_close">Luk</string>
|
||||||
<string name="common_back">Tilbage</string>
|
<string name="common_back">Tilbage</string>
|
||||||
<string name="common_edit">Rediger</string>
|
<string name="common_edit">Rediger</string>
|
||||||
|
|||||||
@@ -2703,6 +2703,7 @@
|
|||||||
<string name="stores_login_error_ssl">Die Verbindung zur Anmeldeseite ist nicht sicher.</string>
|
<string name="stores_login_error_ssl">Die Verbindung zur Anmeldeseite ist nicht sicher.</string>
|
||||||
<string name="stores_login_error_verification">Die Anmeldung konnte nicht bestätigt werden. Versuche es erneut.</string>
|
<string name="stores_login_error_verification">Die Anmeldung konnte nicht bestätigt werden. Versuche es erneut.</string>
|
||||||
<string name="stores_login_error_generic">Anmeldung fehlgeschlagen. Versuche es erneut.</string>
|
<string name="stores_login_error_generic">Anmeldung fehlgeschlagen. Versuche es erneut.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s braucht noch einen Schritt. Schließe ihn im geöffneten Browser ab und versuche es dann erneut.</string>
|
||||||
<string name="common_close">Schließen</string>
|
<string name="common_close">Schließen</string>
|
||||||
<string name="common_back">Zurück</string>
|
<string name="common_back">Zurück</string>
|
||||||
<string name="common_edit">Bearbeiten</string>
|
<string name="common_edit">Bearbeiten</string>
|
||||||
|
|||||||
@@ -2714,6 +2714,7 @@
|
|||||||
<string name="stores_login_error_ssl">Η σύνδεση με τη σελίδα σύνδεσης δεν είναι ασφαλής.</string>
|
<string name="stores_login_error_ssl">Η σύνδεση με τη σελίδα σύνδεσης δεν είναι ασφαλής.</string>
|
||||||
<string name="stores_login_error_verification">Δεν ήταν δυνατή η επαλήθευση της σύνδεσης. Δοκιμάστε ξανά.</string>
|
<string name="stores_login_error_verification">Δεν ήταν δυνατή η επαλήθευση της σύνδεσης. Δοκιμάστε ξανά.</string>
|
||||||
<string name="stores_login_error_generic">Η σύνδεση απέτυχε. Δοκιμάστε ξανά.</string>
|
<string name="stores_login_error_generic">Η σύνδεση απέτυχε. Δοκιμάστε ξανά.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">Το %1$s χρειάζεται ένα ακόμη βήμα. Ολοκληρώστε το στο πρόγραμμα περιήγησης που άνοιξε και δοκιμάστε ξανά.</string>
|
||||||
<string name="common_close">Κλείσιμο</string>
|
<string name="common_close">Κλείσιμο</string>
|
||||||
<string name="common_back">Πίσω</string>
|
<string name="common_back">Πίσω</string>
|
||||||
<string name="common_edit">Επεξεργασία</string>
|
<string name="common_edit">Επεξεργασία</string>
|
||||||
|
|||||||
@@ -2737,6 +2737,7 @@
|
|||||||
<string name="stores_login_error_ssl">La conexión con la página de inicio de sesión no es segura.</string>
|
<string name="stores_login_error_ssl">La conexión con la página de inicio de sesión no es segura.</string>
|
||||||
<string name="stores_login_error_verification">No se pudo verificar el inicio de sesión. Inténtalo de nuevo.</string>
|
<string name="stores_login_error_verification">No se pudo verificar el inicio de sesión. Inténtalo de nuevo.</string>
|
||||||
<string name="stores_login_error_generic">No se pudo iniciar sesión. Inténtalo de nuevo.</string>
|
<string name="stores_login_error_generic">No se pudo iniciar sesión. Inténtalo de nuevo.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s necesita un paso más. Complétalo en el navegador que se abrió y vuelve a intentarlo.</string>
|
||||||
<string name="common_close">Cerrar</string>
|
<string name="common_close">Cerrar</string>
|
||||||
<string name="common_back">Atrás</string>
|
<string name="common_back">Atrás</string>
|
||||||
<string name="common_edit">Editar</string>
|
<string name="common_edit">Editar</string>
|
||||||
|
|||||||
@@ -2714,6 +2714,7 @@
|
|||||||
<string name="stores_login_error_ssl">Yhteys kirjautumissivulle ei ole suojattu.</string>
|
<string name="stores_login_error_ssl">Yhteys kirjautumissivulle ei ole suojattu.</string>
|
||||||
<string name="stores_login_error_verification">Kirjautumista ei voitu vahvistaa. Yritä uudelleen.</string>
|
<string name="stores_login_error_verification">Kirjautumista ei voitu vahvistaa. Yritä uudelleen.</string>
|
||||||
<string name="stores_login_error_generic">Kirjautuminen epäonnistui. Yritä uudelleen.</string>
|
<string name="stores_login_error_generic">Kirjautuminen epäonnistui. Yritä uudelleen.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s vaatii vielä yhden vaiheen. Viimeistele se avautuneessa selaimessa ja yritä sitten uudelleen.</string>
|
||||||
<string name="common_close">Sulje</string>
|
<string name="common_close">Sulje</string>
|
||||||
<string name="common_back">Takaisin</string>
|
<string name="common_back">Takaisin</string>
|
||||||
<string name="common_edit">Muokkaa</string>
|
<string name="common_edit">Muokkaa</string>
|
||||||
|
|||||||
@@ -2736,6 +2736,7 @@
|
|||||||
<string name="stores_login_error_ssl">La liaison avec la page de connexion n\'est pas sécurisée.</string>
|
<string name="stores_login_error_ssl">La liaison avec la page de connexion n\'est pas sécurisée.</string>
|
||||||
<string name="stores_login_error_verification">Impossible de vérifier la connexion. Réessayez.</string>
|
<string name="stores_login_error_verification">Impossible de vérifier la connexion. Réessayez.</string>
|
||||||
<string name="stores_login_error_generic">Échec de la connexion. Réessayez.</string>
|
<string name="stores_login_error_generic">Échec de la connexion. Réessayez.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s demande une étape de plus. Terminez-la dans le navigateur qui s\'est ouvert, puis réessayez.</string>
|
||||||
<string name="common_close">Fermer</string>
|
<string name="common_close">Fermer</string>
|
||||||
<string name="common_back">Retour</string>
|
<string name="common_back">Retour</string>
|
||||||
<string name="common_edit">Modifier</string>
|
<string name="common_edit">Modifier</string>
|
||||||
|
|||||||
@@ -2714,6 +2714,7 @@
|
|||||||
<string name="stores_login_error_ssl">साइन-इन पेज से कनेक्शन सुरक्षित नहीं है।</string>
|
<string name="stores_login_error_ssl">साइन-इन पेज से कनेक्शन सुरक्षित नहीं है।</string>
|
||||||
<string name="stores_login_error_verification">साइन-इन सत्यापित नहीं हो सका। फिर कोशिश करें।</string>
|
<string name="stores_login_error_verification">साइन-इन सत्यापित नहीं हो सका। फिर कोशिश करें।</string>
|
||||||
<string name="stores_login_error_generic">साइन-इन विफल रहा। फिर कोशिश करें।</string>
|
<string name="stores_login_error_generic">साइन-इन विफल रहा। फिर कोशिश करें।</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s को एक और चरण चाहिए। खुले हुए ब्राउज़र में इसे पूरा करें, फिर दोबारा कोशिश करें।</string>
|
||||||
<string name="common_close">बंद करें</string>
|
<string name="common_close">बंद करें</string>
|
||||||
<string name="common_back">बैक</string>
|
<string name="common_back">बैक</string>
|
||||||
<string name="common_edit">संपादित करें</string>
|
<string name="common_edit">संपादित करें</string>
|
||||||
|
|||||||
@@ -2714,6 +2714,7 @@
|
|||||||
<string name="stores_login_error_ssl">A kapcsolat a bejelentkezési oldalhoz nem biztonságos.</string>
|
<string name="stores_login_error_ssl">A kapcsolat a bejelentkezési oldalhoz nem biztonságos.</string>
|
||||||
<string name="stores_login_error_verification">A bejelentkezést nem sikerült ellenőrizni. Próbálja újra.</string>
|
<string name="stores_login_error_verification">A bejelentkezést nem sikerült ellenőrizni. Próbálja újra.</string>
|
||||||
<string name="stores_login_error_generic">A bejelentkezés sikertelen. Próbálja újra.</string>
|
<string name="stores_login_error_generic">A bejelentkezés sikertelen. Próbálja újra.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">A(z) %1$s még egy lépést kér. Fejezze be a megnyílt böngészőben, majd próbálja újra.</string>
|
||||||
<string name="common_close">Bezárás</string>
|
<string name="common_close">Bezárás</string>
|
||||||
<string name="common_back">Vissza</string>
|
<string name="common_back">Vissza</string>
|
||||||
<string name="common_edit">Szerkesztés</string>
|
<string name="common_edit">Szerkesztés</string>
|
||||||
|
|||||||
@@ -2689,6 +2689,7 @@
|
|||||||
<string name="stores_login_error_ssl">Koneksi ke halaman masuk tidak aman.</string>
|
<string name="stores_login_error_ssl">Koneksi ke halaman masuk tidak aman.</string>
|
||||||
<string name="stores_login_error_verification">Proses masuk tidak dapat diverifikasi. Coba lagi.</string>
|
<string name="stores_login_error_verification">Proses masuk tidak dapat diverifikasi. Coba lagi.</string>
|
||||||
<string name="stores_login_error_generic">Proses masuk gagal. Coba lagi.</string>
|
<string name="stores_login_error_generic">Proses masuk gagal. Coba lagi.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s memerlukan satu langkah lagi. Selesaikan di browser yang terbuka, lalu coba lagi.</string>
|
||||||
<string name="common_close">Tutup</string>
|
<string name="common_close">Tutup</string>
|
||||||
<string name="common_back">Kembali</string>
|
<string name="common_back">Kembali</string>
|
||||||
<string name="common_edit">Edit</string>
|
<string name="common_edit">Edit</string>
|
||||||
|
|||||||
@@ -2728,6 +2728,7 @@
|
|||||||
<string name="stores_login_error_ssl">La connessione alla pagina di accesso non è sicura.</string>
|
<string name="stores_login_error_ssl">La connessione alla pagina di accesso non è sicura.</string>
|
||||||
<string name="stores_login_error_verification">Impossibile verificare l\'accesso. Riprova.</string>
|
<string name="stores_login_error_verification">Impossibile verificare l\'accesso. Riprova.</string>
|
||||||
<string name="stores_login_error_generic">Accesso non riuscito. Riprova.</string>
|
<string name="stores_login_error_generic">Accesso non riuscito. Riprova.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s richiede un altro passaggio. Completalo nel browser che si è aperto, poi riprova.</string>
|
||||||
<string name="common_close">Chiudi</string>
|
<string name="common_close">Chiudi</string>
|
||||||
<string name="common_back">Indietro</string>
|
<string name="common_back">Indietro</string>
|
||||||
<string name="common_edit">Modifica</string>
|
<string name="common_edit">Modifica</string>
|
||||||
|
|||||||
@@ -2689,6 +2689,7 @@
|
|||||||
<string name="stores_login_error_ssl">ログインページへの接続は安全ではありません。</string>
|
<string name="stores_login_error_ssl">ログインページへの接続は安全ではありません。</string>
|
||||||
<string name="stores_login_error_verification">ログインを確認できませんでした。もう一度お試しください。</string>
|
<string name="stores_login_error_verification">ログインを確認できませんでした。もう一度お試しください。</string>
|
||||||
<string name="stores_login_error_generic">ログインに失敗しました。もう一度お試しください。</string>
|
<string name="stores_login_error_generic">ログインに失敗しました。もう一度お試しください。</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s で追加の手順が必要です。開いたブラウザーで完了してから、もう一度お試しください。</string>
|
||||||
<string name="common_close">閉じる</string>
|
<string name="common_close">閉じる</string>
|
||||||
<string name="common_back">戻る</string>
|
<string name="common_back">戻る</string>
|
||||||
<string name="common_edit">編集</string>
|
<string name="common_edit">編集</string>
|
||||||
|
|||||||
@@ -2689,6 +2689,7 @@
|
|||||||
<string name="stores_login_error_ssl">로그인 페이지 연결이 안전하지 않습니다.</string>
|
<string name="stores_login_error_ssl">로그인 페이지 연결이 안전하지 않습니다.</string>
|
||||||
<string name="stores_login_error_verification">로그인을 확인할 수 없습니다. 다시 시도하세요.</string>
|
<string name="stores_login_error_verification">로그인을 확인할 수 없습니다. 다시 시도하세요.</string>
|
||||||
<string name="stores_login_error_generic">로그인에 실패했습니다. 다시 시도하세요.</string>
|
<string name="stores_login_error_generic">로그인에 실패했습니다. 다시 시도하세요.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s에서 한 단계가 더 필요합니다. 열린 브라우저에서 완료한 다음 다시 시도하세요.</string>
|
||||||
<string name="common_close">닫기</string>
|
<string name="common_close">닫기</string>
|
||||||
<string name="common_back">뒤로</string>
|
<string name="common_back">뒤로</string>
|
||||||
<string name="common_edit">편집</string>
|
<string name="common_edit">편집</string>
|
||||||
|
|||||||
@@ -2689,6 +2689,7 @@
|
|||||||
<string name="stores_login_error_ssl">Sambungan ke halaman log masuk tidak selamat.</string>
|
<string name="stores_login_error_ssl">Sambungan ke halaman log masuk tidak selamat.</string>
|
||||||
<string name="stores_login_error_verification">Log masuk tidak dapat disahkan. Cuba lagi.</string>
|
<string name="stores_login_error_verification">Log masuk tidak dapat disahkan. Cuba lagi.</string>
|
||||||
<string name="stores_login_error_generic">Log masuk gagal. Cuba lagi.</string>
|
<string name="stores_login_error_generic">Log masuk gagal. Cuba lagi.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s memerlukan satu langkah lagi. Selesaikannya dalam pelayar yang dibuka, kemudian cuba lagi.</string>
|
||||||
<string name="common_close">Tutup</string>
|
<string name="common_close">Tutup</string>
|
||||||
<string name="common_back">Kembali</string>
|
<string name="common_back">Kembali</string>
|
||||||
<string name="common_edit">Sunting</string>
|
<string name="common_edit">Sunting</string>
|
||||||
|
|||||||
@@ -2714,6 +2714,7 @@
|
|||||||
<string name="stores_login_error_ssl">Tilkoblingen til innloggingssiden er ikke sikker.</string>
|
<string name="stores_login_error_ssl">Tilkoblingen til innloggingssiden er ikke sikker.</string>
|
||||||
<string name="stores_login_error_verification">Innloggingen kunne ikke verifiseres. Prøv igjen.</string>
|
<string name="stores_login_error_verification">Innloggingen kunne ikke verifiseres. Prøv igjen.</string>
|
||||||
<string name="stores_login_error_generic">Innlogging mislyktes. Prøv igjen.</string>
|
<string name="stores_login_error_generic">Innlogging mislyktes. Prøv igjen.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s trenger ett trinn til. Fullfør det i nettleseren som ble åpnet, og prøv igjen.</string>
|
||||||
<string name="common_close">Lukk</string>
|
<string name="common_close">Lukk</string>
|
||||||
<string name="common_back">Tilbake</string>
|
<string name="common_back">Tilbake</string>
|
||||||
<string name="common_edit">Rediger</string>
|
<string name="common_edit">Rediger</string>
|
||||||
|
|||||||
@@ -2714,6 +2714,7 @@
|
|||||||
<string name="stores_login_error_ssl">De verbinding met de aanmeldpagina is niet beveiligd.</string>
|
<string name="stores_login_error_ssl">De verbinding met de aanmeldpagina is niet beveiligd.</string>
|
||||||
<string name="stores_login_error_verification">De aanmelding kon niet worden geverifieerd. Probeer het opnieuw.</string>
|
<string name="stores_login_error_verification">De aanmelding kon niet worden geverifieerd. Probeer het opnieuw.</string>
|
||||||
<string name="stores_login_error_generic">Aanmelden mislukt. Probeer het opnieuw.</string>
|
<string name="stores_login_error_generic">Aanmelden mislukt. Probeer het opnieuw.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s vraagt nog één stap. Rond die af in de browser die is geopend en probeer het opnieuw.</string>
|
||||||
<string name="common_close">Sluiten</string>
|
<string name="common_close">Sluiten</string>
|
||||||
<string name="common_back">Terug</string>
|
<string name="common_back">Terug</string>
|
||||||
<string name="common_edit">Bewerken</string>
|
<string name="common_edit">Bewerken</string>
|
||||||
|
|||||||
@@ -2766,6 +2766,7 @@
|
|||||||
<string name="stores_login_error_ssl">Połączenie ze stroną logowania nie jest bezpieczne.</string>
|
<string name="stores_login_error_ssl">Połączenie ze stroną logowania nie jest bezpieczne.</string>
|
||||||
<string name="stores_login_error_verification">Nie udało się zweryfikować logowania. Spróbuj ponownie.</string>
|
<string name="stores_login_error_verification">Nie udało się zweryfikować logowania. Spróbuj ponownie.</string>
|
||||||
<string name="stores_login_error_generic">Logowanie nie powiodło się. Spróbuj ponownie.</string>
|
<string name="stores_login_error_generic">Logowanie nie powiodło się. Spróbuj ponownie.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s wymaga jeszcze jednego kroku. Dokończ go w otwartej przeglądarce, a potem spróbuj ponownie.</string>
|
||||||
<string name="common_close">Zamknij</string>
|
<string name="common_close">Zamknij</string>
|
||||||
<string name="common_back">Wstecz</string>
|
<string name="common_back">Wstecz</string>
|
||||||
<string name="common_edit">Edytuj</string>
|
<string name="common_edit">Edytuj</string>
|
||||||
|
|||||||
@@ -2742,6 +2742,7 @@
|
|||||||
<string name="stores_login_error_ssl">A ligação à página de início de sessão não é segura.</string>
|
<string name="stores_login_error_ssl">A ligação à página de início de sessão não é segura.</string>
|
||||||
<string name="stores_login_error_verification">Não foi possível verificar o início de sessão. Tente novamente.</string>
|
<string name="stores_login_error_verification">Não foi possível verificar o início de sessão. Tente novamente.</string>
|
||||||
<string name="stores_login_error_generic">Falha no início de sessão. Tente novamente.</string>
|
<string name="stores_login_error_generic">Falha no início de sessão. Tente novamente.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s precisa de mais um passo. Conclua-o no navegador que foi aberto e tente novamente.</string>
|
||||||
<string name="common_close">Fechar</string>
|
<string name="common_close">Fechar</string>
|
||||||
<string name="common_back">Voltar</string>
|
<string name="common_back">Voltar</string>
|
||||||
<string name="common_edit">Editar</string>
|
<string name="common_edit">Editar</string>
|
||||||
|
|||||||
@@ -2750,6 +2750,7 @@
|
|||||||
<string name="stores_login_error_ssl">A conexão com a página de login não é segura.</string>
|
<string name="stores_login_error_ssl">A conexão com a página de login não é segura.</string>
|
||||||
<string name="stores_login_error_verification">Não foi possível verificar o login. Tente de novo.</string>
|
<string name="stores_login_error_verification">Não foi possível verificar o login. Tente de novo.</string>
|
||||||
<string name="stores_login_error_generic">Falha no login. Tente de novo.</string>
|
<string name="stores_login_error_generic">Falha no login. Tente de novo.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s precisa de mais uma etapa. Conclua no navegador que foi aberto e tente novamente.</string>
|
||||||
<string name="common_close">Fechar</string>
|
<string name="common_close">Fechar</string>
|
||||||
<string name="common_back">Voltar</string>
|
<string name="common_back">Voltar</string>
|
||||||
<string name="common_edit">Editar</string>
|
<string name="common_edit">Editar</string>
|
||||||
|
|||||||
@@ -2740,6 +2740,7 @@
|
|||||||
<string name="stores_login_error_ssl">Conexiunea la pagina de autentificare nu este sigură.</string>
|
<string name="stores_login_error_ssl">Conexiunea la pagina de autentificare nu este sigură.</string>
|
||||||
<string name="stores_login_error_verification">Autentificarea nu a putut fi verificată. Încearcă din nou.</string>
|
<string name="stores_login_error_verification">Autentificarea nu a putut fi verificată. Încearcă din nou.</string>
|
||||||
<string name="stores_login_error_generic">Autentificarea a eșuat. Încearcă din nou.</string>
|
<string name="stores_login_error_generic">Autentificarea a eșuat. Încearcă din nou.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s mai cere un pas. Finalizează-l în browserul care s-a deschis, apoi încearcă din nou.</string>
|
||||||
<string name="common_close">Închide</string>
|
<string name="common_close">Închide</string>
|
||||||
<string name="common_back">Înapoi</string>
|
<string name="common_back">Înapoi</string>
|
||||||
<string name="common_edit">Editează</string>
|
<string name="common_edit">Editează</string>
|
||||||
|
|||||||
@@ -2764,6 +2764,7 @@
|
|||||||
<string name="stores_login_error_ssl">Подключение к странице входа не защищено.</string>
|
<string name="stores_login_error_ssl">Подключение к странице входа не защищено.</string>
|
||||||
<string name="stores_login_error_verification">Не удалось подтвердить вход. Повторите попытку.</string>
|
<string name="stores_login_error_verification">Не удалось подтвердить вход. Повторите попытку.</string>
|
||||||
<string name="stores_login_error_generic">Ошибка входа. Повторите попытку.</string>
|
<string name="stores_login_error_generic">Ошибка входа. Повторите попытку.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s требует ещё один шаг. Завершите его в открывшемся браузере и попробуйте снова.</string>
|
||||||
<string name="common_close">Закрыть</string>
|
<string name="common_close">Закрыть</string>
|
||||||
<string name="common_back">Назад</string>
|
<string name="common_back">Назад</string>
|
||||||
<string name="common_edit">Изменить</string>
|
<string name="common_edit">Изменить</string>
|
||||||
|
|||||||
@@ -2714,6 +2714,7 @@
|
|||||||
<string name="stores_login_error_ssl">Anslutningen till inloggningssidan är inte säker.</string>
|
<string name="stores_login_error_ssl">Anslutningen till inloggningssidan är inte säker.</string>
|
||||||
<string name="stores_login_error_verification">Inloggningen kunde inte verifieras. Försök igen.</string>
|
<string name="stores_login_error_verification">Inloggningen kunde inte verifieras. Försök igen.</string>
|
||||||
<string name="stores_login_error_generic">Inloggningen misslyckades. Försök igen.</string>
|
<string name="stores_login_error_generic">Inloggningen misslyckades. Försök igen.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s behöver ett steg till. Slutför det i webbläsaren som öppnades och försök sedan igen.</string>
|
||||||
<string name="common_close">Stäng</string>
|
<string name="common_close">Stäng</string>
|
||||||
<string name="common_back">Tillbaka</string>
|
<string name="common_back">Tillbaka</string>
|
||||||
<string name="common_edit">Redigera</string>
|
<string name="common_edit">Redigera</string>
|
||||||
|
|||||||
@@ -2689,6 +2689,7 @@
|
|||||||
<string name="stores_login_error_ssl">การเชื่อมต่อไปยังหน้าลงชื่อเข้าใช้ไม่ปลอดภัย</string>
|
<string name="stores_login_error_ssl">การเชื่อมต่อไปยังหน้าลงชื่อเข้าใช้ไม่ปลอดภัย</string>
|
||||||
<string name="stores_login_error_verification">ไม่สามารถยืนยันการลงชื่อเข้าใช้ได้ ลองใหม่</string>
|
<string name="stores_login_error_verification">ไม่สามารถยืนยันการลงชื่อเข้าใช้ได้ ลองใหม่</string>
|
||||||
<string name="stores_login_error_generic">ลงชื่อเข้าใช้ล้มเหลว ลองใหม่</string>
|
<string name="stores_login_error_generic">ลงชื่อเข้าใช้ล้มเหลว ลองใหม่</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s ต้องการอีกหนึ่งขั้นตอน ทำให้เสร็จในเบราว์เซอร์ที่เปิดขึ้น แล้วลองอีกครั้ง</string>
|
||||||
<string name="common_close">ปิด</string>
|
<string name="common_close">ปิด</string>
|
||||||
<string name="common_back">กลับ</string>
|
<string name="common_back">กลับ</string>
|
||||||
<string name="common_edit">แก้ไข</string>
|
<string name="common_edit">แก้ไข</string>
|
||||||
|
|||||||
@@ -2703,6 +2703,7 @@
|
|||||||
<string name="stores_login_error_ssl">Oturum açma sayfasına bağlantı güvenli değil.</string>
|
<string name="stores_login_error_ssl">Oturum açma sayfasına bağlantı güvenli değil.</string>
|
||||||
<string name="stores_login_error_verification">Oturum açma doğrulanamadı. Yeniden deneyin.</string>
|
<string name="stores_login_error_verification">Oturum açma doğrulanamadı. Yeniden deneyin.</string>
|
||||||
<string name="stores_login_error_generic">Oturum açma başarısız oldu. Yeniden deneyin.</string>
|
<string name="stores_login_error_generic">Oturum açma başarısız oldu. Yeniden deneyin.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s bir adım daha istiyor. Açılan tarayıcıda tamamlayın, ardından yeniden deneyin.</string>
|
||||||
<string name="common_close">Kapat</string>
|
<string name="common_close">Kapat</string>
|
||||||
<string name="common_back">Geri</string>
|
<string name="common_back">Geri</string>
|
||||||
<string name="common_edit">Düzenle</string>
|
<string name="common_edit">Düzenle</string>
|
||||||
|
|||||||
@@ -2766,6 +2766,7 @@
|
|||||||
<string name="stores_login_error_ssl">З’єднання зі сторінкою входу не захищене.</string>
|
<string name="stores_login_error_ssl">З’єднання зі сторінкою входу не захищене.</string>
|
||||||
<string name="stores_login_error_verification">Не вдалося підтвердити вхід. Спробуйте ще раз.</string>
|
<string name="stores_login_error_verification">Не вдалося підтвердити вхід. Спробуйте ще раз.</string>
|
||||||
<string name="stores_login_error_generic">Вхід не вдався. Спробуйте ще раз.</string>
|
<string name="stores_login_error_generic">Вхід не вдався. Спробуйте ще раз.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s потребує ще одного кроку. Завершіть його у відкритому браузері та спробуйте ще раз.</string>
|
||||||
<string name="common_close">Закрити</string>
|
<string name="common_close">Закрити</string>
|
||||||
<string name="common_back">Назад</string>
|
<string name="common_back">Назад</string>
|
||||||
<string name="common_edit">Редагувати</string>
|
<string name="common_edit">Редагувати</string>
|
||||||
|
|||||||
@@ -2689,6 +2689,7 @@
|
|||||||
<string name="stores_login_error_ssl">Kết nối đến trang đăng nhập không an toàn.</string>
|
<string name="stores_login_error_ssl">Kết nối đến trang đăng nhập không an toàn.</string>
|
||||||
<string name="stores_login_error_verification">Không thể xác minh đăng nhập. Hãy thử lại.</string>
|
<string name="stores_login_error_verification">Không thể xác minh đăng nhập. Hãy thử lại.</string>
|
||||||
<string name="stores_login_error_generic">Đăng nhập thất bại. Hãy thử lại.</string>
|
<string name="stores_login_error_generic">Đăng nhập thất bại. Hãy thử lại.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s cần thêm một bước. Hãy hoàn tất trong trình duyệt vừa mở, rồi thử lại.</string>
|
||||||
<string name="common_close">Đóng</string>
|
<string name="common_close">Đóng</string>
|
||||||
<string name="common_back">Quay lại</string>
|
<string name="common_back">Quay lại</string>
|
||||||
<string name="common_edit">Sửa</string>
|
<string name="common_edit">Sửa</string>
|
||||||
|
|||||||
@@ -2763,6 +2763,7 @@
|
|||||||
<string name="stores_login_error_ssl">与登录页面的连接不安全。</string>
|
<string name="stores_login_error_ssl">与登录页面的连接不安全。</string>
|
||||||
<string name="stores_login_error_verification">无法验证登录。请重试。</string>
|
<string name="stores_login_error_verification">无法验证登录。请重试。</string>
|
||||||
<string name="stores_login_error_generic">登录失败。请重试。</string>
|
<string name="stores_login_error_generic">登录失败。请重试。</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s 还需要一个步骤。请在已打开的浏览器中完成,然后重试。</string>
|
||||||
<string name="common_close">关闭</string>
|
<string name="common_close">关闭</string>
|
||||||
<string name="common_back">返回</string>
|
<string name="common_back">返回</string>
|
||||||
<string name="common_edit">编辑</string>
|
<string name="common_edit">编辑</string>
|
||||||
|
|||||||
@@ -2686,6 +2686,7 @@
|
|||||||
<string name="stores_login_error_ssl">與登入頁面的連線不安全。</string>
|
<string name="stores_login_error_ssl">與登入頁面的連線不安全。</string>
|
||||||
<string name="stores_login_error_verification">無法驗證登入,請再試一次。</string>
|
<string name="stores_login_error_verification">無法驗證登入,請再試一次。</string>
|
||||||
<string name="stores_login_error_generic">登入失敗,請再試一次。</string>
|
<string name="stores_login_error_generic">登入失敗,請再試一次。</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s 還需要一個步驟。請在已開啟的瀏覽器中完成,然後再試一次。</string>
|
||||||
<string name="common_close">關閉</string>
|
<string name="common_close">關閉</string>
|
||||||
<string name="common_back">返回</string>
|
<string name="common_back">返回</string>
|
||||||
<string name="common_edit">編輯</string>
|
<string name="common_edit">編輯</string>
|
||||||
|
|||||||
@@ -2686,6 +2686,7 @@
|
|||||||
<string name="stores_login_error_ssl">與登入頁面的連線不安全。</string>
|
<string name="stores_login_error_ssl">與登入頁面的連線不安全。</string>
|
||||||
<string name="stores_login_error_verification">無法驗證登入。請再試一次。</string>
|
<string name="stores_login_error_verification">無法驗證登入。請再試一次。</string>
|
||||||
<string name="stores_login_error_generic">登入失敗。請再試一次。</string>
|
<string name="stores_login_error_generic">登入失敗。請再試一次。</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s 還需要一個步驟。請在已開啟的瀏覽器中完成,然後再試一次。</string>
|
||||||
<string name="common_close">關閉</string>
|
<string name="common_close">關閉</string>
|
||||||
<string name="common_back">返回</string>
|
<string name="common_back">返回</string>
|
||||||
<string name="common_edit">編輯</string>
|
<string name="common_edit">編輯</string>
|
||||||
|
|||||||
@@ -3034,6 +3034,7 @@
|
|||||||
<string name="stores_login_error_ssl">The connection to the sign-in page is not secure.</string>
|
<string name="stores_login_error_ssl">The connection to the sign-in page is not secure.</string>
|
||||||
<string name="stores_login_error_verification">The sign-in could not be verified. Try again.</string>
|
<string name="stores_login_error_verification">The sign-in could not be verified. Try again.</string>
|
||||||
<string name="stores_login_error_generic">Sign-in failed. Try again.</string>
|
<string name="stores_login_error_generic">Sign-in failed. Try again.</string>
|
||||||
|
<string name="stores_login_continue_in_browser">%1$s needs one more step. Finish it in the browser that opened, then try again.</string>
|
||||||
<string name="common_close">Close</string>
|
<string name="common_close">Close</string>
|
||||||
<string name="common_back">Back</string>
|
<string name="common_back">Back</string>
|
||||||
<string name="common_edit">Edit</string>
|
<string name="common_edit">Edit</string>
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package com.droiddeck.launcher
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import com.droiddeck.launcher.core.SteamIntegration
|
||||||
|
import com.droiddeck.launcher.frontend.GameRequest
|
||||||
|
import com.droiddeck.launcher.session.LaunchCoordinator
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertNull
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.robolectric.Robolectric
|
||||||
|
import org.robolectric.RobolectricTestRunner
|
||||||
|
import org.robolectric.Shadows.shadowOf
|
||||||
|
import org.robolectric.annotation.Config
|
||||||
|
import org.robolectric.util.ReflectionHelpers
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A replacement activity intent invalidates everything this activity has not dispatched yet: a
|
||||||
|
* resolved but unhandled game link, and an accepted launch that is still waiting for its session.
|
||||||
|
*/
|
||||||
|
@RunWith(RobolectricTestRunner::class)
|
||||||
|
@Config(sdk = [28], manifest = Config.NONE)
|
||||||
|
class FrontEndIntentSupersedeTest {
|
||||||
|
private lateinit var activity: FrontEndActivity
|
||||||
|
private lateinit var coordinator: LaunchCoordinator<Intent, GameRequest>
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setUp() {
|
||||||
|
activity = Robolectric.buildActivity(FrontEndActivity::class.java).get()
|
||||||
|
coordinator = ReflectionHelpers.getField(activity, "launchCoordinator")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aReplacementIntentDropsAResolvedPendingLink() {
|
||||||
|
val owner = Intent(activity, FrontEndActivity::class.java)
|
||||||
|
val ticket = coordinator.beginLink(owner)
|
||||||
|
assertTrue(coordinator.resolve(ticket, GameRequest(id = "app")))
|
||||||
|
|
||||||
|
supersede()
|
||||||
|
|
||||||
|
assertFalse(coordinator.hasPending())
|
||||||
|
assertNull(coordinator.pendingLink())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aReplacementIntentInvalidatesAnAcceptedLaunch() {
|
||||||
|
val ticket = coordinator.beginLaunch()
|
||||||
|
assertTrue(coordinator.isCurrent(ticket))
|
||||||
|
|
||||||
|
supersede()
|
||||||
|
|
||||||
|
assertFalse(coordinator.isCurrent(ticket))
|
||||||
|
assertNull(shadowOf(activity).nextStartedActivity)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun anActionSetupIntentSupersedesTheGameLinkItReplaced() {
|
||||||
|
val owner = Intent(activity, FrontEndActivity::class.java)
|
||||||
|
val ticket = coordinator.beginLink(owner)
|
||||||
|
assertTrue(coordinator.resolve(ticket, GameRequest(id = "app")))
|
||||||
|
|
||||||
|
deliver(Intent(activity, FrontEndActivity::class.java).setAction(SteamIntegration.ACTION_SETUP))
|
||||||
|
|
||||||
|
assertFalse(coordinator.hasPending())
|
||||||
|
assertFalse(coordinator.isCurrent(ticket))
|
||||||
|
assertNull(shadowOf(activity).nextStartedActivity)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun supersede() {
|
||||||
|
ReflectionHelpers.callInstanceMethod<Void>(activity, "supersedeUncommittedLaunch")
|
||||||
|
}
|
||||||
|
|
||||||
|
/** onNewIntent() is protected, which is exactly how the platform delivers a replacement intent. */
|
||||||
|
private fun deliver(intent: Intent) {
|
||||||
|
val method = FrontEndActivity::class.java.getDeclaredMethod("onNewIntent", Intent::class.java)
|
||||||
|
method.isAccessible = true
|
||||||
|
try {
|
||||||
|
method.invoke(activity, intent)
|
||||||
|
} finally {
|
||||||
|
method.isAccessible = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
package com.droiddeck.launcher.input
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class AxisPacingTest {
|
||||||
|
@Test fun theFirstReportIsWrittenAtOnce() {
|
||||||
|
assertEquals(100L, AxisPacing(4).dueAt(100, true))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun stickMotionInsideTheIntervalWaitsForItsEnd() {
|
||||||
|
val pacing = AxisPacing(4)
|
||||||
|
pacing.wrote(100)
|
||||||
|
assertEquals(104L, pacing.dueAt(101, true))
|
||||||
|
assertEquals(104L, pacing.dueAt(103, true))
|
||||||
|
assertEquals(104L, pacing.dueAt(104, true))
|
||||||
|
assertEquals(110L, pacing.dueAt(110, true))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun buttonsAndRestTransitionsAreNeverHeldBack() {
|
||||||
|
val pacing = AxisPacing(4)
|
||||||
|
pacing.wrote(100)
|
||||||
|
assertEquals(101L, pacing.dueAt(101, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun onlyMotionThatStaysOffRestIsPaced() {
|
||||||
|
assertTrue(AxisPacing.keepsMoving(0, 0))
|
||||||
|
assertTrue(AxisPacing.keepsMoving(1200, 1300))
|
||||||
|
assertTrue(AxisPacing.keepsMoving(-40, 25))
|
||||||
|
assertFalse(AxisPacing.keepsMoving(0, 900))
|
||||||
|
assertFalse(AxisPacing.keepsMoving(900, 0))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun theIntervalRunsFromTheFlushNotFromTheRequest() {
|
||||||
|
val pacing = AxisPacing(4)
|
||||||
|
assertEquals(100L, pacing.dueAt(100, true))
|
||||||
|
pacing.wrote(110)
|
||||||
|
assertEquals(114L, pacing.dueAt(111, true))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun aHeldReportIsReleasedOnlyAtItsDeadline() {
|
||||||
|
val pacing = AxisPacing(4)
|
||||||
|
assertTrue(pacing.hold(104))
|
||||||
|
assertFalse(pacing.hold(104))
|
||||||
|
assertFalse(pacing.release(103))
|
||||||
|
assertTrue(pacing.release(104))
|
||||||
|
assertFalse(pacing.release(105))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun aCallbackFromACancelledHoldCannotPublishTheNextHoldEarly() {
|
||||||
|
val pacing = AxisPacing(4)
|
||||||
|
assertTrue(pacing.hold(104))
|
||||||
|
assertTrue(pacing.cancel())
|
||||||
|
pacing.wrote(104)
|
||||||
|
assertTrue(pacing.hold(pacing.dueAt(105, true)))
|
||||||
|
assertFalse(pacing.release(105))
|
||||||
|
assertTrue(pacing.release(108))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun cancellingWithNothingHeldRemovesNoCallback() {
|
||||||
|
val pacing = AxisPacing(4)
|
||||||
|
assertFalse(pacing.cancel())
|
||||||
|
assertTrue(pacing.hold(104))
|
||||||
|
assertTrue(pacing.release(104))
|
||||||
|
assertFalse(pacing.cancel())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun aThousandHertzPadReachesTheGuestAtTheIntervalRate() {
|
||||||
|
val writes = feed(AxisPacing(4), sampleMs = 1, durationMs = 1000)
|
||||||
|
assertTrue("$writes writes", writes in 249..251)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun aPadSlowerThanTheIntervalIsNeverDelayed() {
|
||||||
|
val pacing = AxisPacing(4)
|
||||||
|
for (now in 0L until 1000L step 5) {
|
||||||
|
assertEquals(now, pacing.dueAt(now, true))
|
||||||
|
pacing.wrote(now)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun feed(pacing: AxisPacing, sampleMs: Long, durationMs: Long): Int {
|
||||||
|
var writes = 0
|
||||||
|
var pendingAt = -1L
|
||||||
|
for (now in 0L until durationMs step sampleMs) {
|
||||||
|
if (pendingAt in 0..now) {
|
||||||
|
pacing.wrote(pendingAt)
|
||||||
|
writes++
|
||||||
|
pendingAt = -1
|
||||||
|
}
|
||||||
|
val due = pacing.dueAt(now, true)
|
||||||
|
if (due <= now) {
|
||||||
|
pacing.wrote(now)
|
||||||
|
writes++
|
||||||
|
} else if (pendingAt < 0) {
|
||||||
|
pendingAt = due
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return writes
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -419,6 +419,23 @@ class EnhancedSessionLogShareTest {
|
|||||||
SessionLogShare.clear(app)
|
SessionLogShare.clear(app)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun rpcs3LogIsSharedByNameWithTheGameLogs() {
|
||||||
|
val session = tmp.newFolder("2026-11-24-05-rpcs3")
|
||||||
|
session.resolve("session.log").writeText("session\n")
|
||||||
|
session.resolve("rpcs3").mkdirs()
|
||||||
|
session.resolve("rpcs3/RPCS3.log").writeText("PPU: compiling\n")
|
||||||
|
|
||||||
|
val zips = EnhancedSessionLogShare.create(app, session)
|
||||||
|
fun entries(suffix: String) = ZipFile(zips.single { it.name.endsWith("-$suffix.zip") }).use { archive ->
|
||||||
|
archive.entries().toList().map { it.name }
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(entries("games").contains("${session.name}/rpcs3/RPCS3.log"))
|
||||||
|
assertTrue(entries("session").contains("${session.name}/session.log"))
|
||||||
|
assertFalse(entries("games").contains("${session.name}/session.log"))
|
||||||
|
SessionLogShare.clear(app)
|
||||||
|
}
|
||||||
|
|
||||||
@Test fun unreadableDiscoverySubtreeKeepsOtherLogsAndMarksTheManifestPartial() {
|
@Test fun unreadableDiscoverySubtreeKeepsOtherLogsAndMarksTheManifestPartial() {
|
||||||
assumeFilePermissionsEnforced()
|
assumeFilePermissionsEnforced()
|
||||||
assumeFalse(System.getProperty("os.name").startsWith("Windows"))
|
assumeFalse(System.getProperty("os.name").startsWith("Windows"))
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
package com.droiddeck.launcher.session
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertNull
|
||||||
|
import org.junit.Assert.assertSame
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class LaunchCoordinatorTest {
|
||||||
|
@Test
|
||||||
|
fun aNewLaunchSupersedesAnOlderLaunch() {
|
||||||
|
val coordinator = LaunchCoordinator<String, String>()
|
||||||
|
val first = coordinator.beginLaunch()
|
||||||
|
val second = coordinator.beginLaunch()
|
||||||
|
assertFalse(coordinator.isCurrent(first))
|
||||||
|
assertTrue(coordinator.isCurrent(second))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun anAllowedLaunchDropsThePendingLink() {
|
||||||
|
val coordinator = LaunchCoordinator<String, String>()
|
||||||
|
coordinator.beginLink("link")
|
||||||
|
coordinator.beginLaunch()
|
||||||
|
assertFalse(coordinator.hasPending())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aLinkReadResolvesAndIsConsumed() {
|
||||||
|
val coordinator = LaunchCoordinator<String, String>()
|
||||||
|
val ticket = coordinator.beginLink("link")
|
||||||
|
assertTrue(coordinator.resolve(ticket, "game"))
|
||||||
|
assertEquals("game", coordinator.pendingLink()?.request)
|
||||||
|
assertTrue(coordinator.consume(ticket))
|
||||||
|
assertFalse(coordinator.hasPending())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aStaleLinkReadCannotReplaceTheNewLink() {
|
||||||
|
val coordinator = LaunchCoordinator<String, String>()
|
||||||
|
val first = coordinator.beginLink("first")
|
||||||
|
val second = coordinator.beginLink("second")
|
||||||
|
assertFalse(coordinator.resolve(first, "old"))
|
||||||
|
assertTrue(coordinator.resolve(second, "new"))
|
||||||
|
assertEquals("new", coordinator.pendingLink()?.request)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun handlingNeedsAResolvedLink() {
|
||||||
|
val coordinator = LaunchCoordinator<String, String>()
|
||||||
|
val ticket = coordinator.beginLink("link")
|
||||||
|
assertFalse(coordinator.beginHandling(ticket))
|
||||||
|
coordinator.resolve(ticket, "game")
|
||||||
|
assertTrue(coordinator.beginHandling(ticket))
|
||||||
|
assertTrue(coordinator.isHandling(ticket))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aStaleCompletionCannotConsumeTheNewLink() {
|
||||||
|
val coordinator = LaunchCoordinator<String, String>()
|
||||||
|
val first = coordinator.beginLink("first")
|
||||||
|
val second = coordinator.beginLink("second")
|
||||||
|
coordinator.resolve(second, "new")
|
||||||
|
assertFalse(coordinator.consume(first))
|
||||||
|
assertTrue(coordinator.hasPending())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aUiLaunchDropsThePendingLinkBeforeItLaunches() {
|
||||||
|
val coordinator = LaunchCoordinator<String, String>()
|
||||||
|
coordinator.beginLink("link")
|
||||||
|
val launch = coordinator.beginLaunch()
|
||||||
|
assertNull(coordinator.pendingLink())
|
||||||
|
assertTrue(coordinator.isCurrent(launch))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aSecondLinkReplacesTheFirst() {
|
||||||
|
val coordinator = LaunchCoordinator<String, String>()
|
||||||
|
val first = coordinator.beginLink("first")
|
||||||
|
val second = coordinator.beginLink("second")
|
||||||
|
assertFalse(coordinator.isCurrent(first))
|
||||||
|
assertTrue(coordinator.isCurrent(second))
|
||||||
|
assertEquals("second", coordinator.pendingLink()?.owner)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aLinkKeepsItsOwnerForIntentCleanup() {
|
||||||
|
val coordinator = LaunchCoordinator<String, String>()
|
||||||
|
val ticket = coordinator.beginLink("intent-a")
|
||||||
|
coordinator.resolve(ticket, "game")
|
||||||
|
assertSame("intent-a", coordinator.pendingLink()?.owner)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aLinkIsOwnedOnlyByItsIntent() {
|
||||||
|
val coordinator = LaunchCoordinator<String, String>()
|
||||||
|
val ticket = coordinator.beginLink("intent-a")
|
||||||
|
coordinator.resolve(ticket, "game")
|
||||||
|
val link = requireNotNull(coordinator.pendingLink())
|
||||||
|
assertTrue(link.ownedBy("intent-a"))
|
||||||
|
assertFalse(link.ownedBy("intent-b"))
|
||||||
|
assertFalse(link.ownedBy(null))
|
||||||
|
assertTrue(coordinator.consume(ticket))
|
||||||
|
assertNull(coordinator.pendingLink())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun cancelAllInvalidatesEveryOutstandingTicket() {
|
||||||
|
val coordinator = LaunchCoordinator<String, String>()
|
||||||
|
coordinator.beginLaunch()
|
||||||
|
val link = coordinator.beginLink("link")
|
||||||
|
assertTrue(coordinator.isCurrent(link))
|
||||||
|
coordinator.cancelAll()
|
||||||
|
assertFalse(coordinator.isCurrent(link))
|
||||||
|
assertFalse(coordinator.hasPending())
|
||||||
|
assertNull(coordinator.pendingLink())
|
||||||
|
assertFalse(coordinator.resolve(link, "late"))
|
||||||
|
assertFalse(coordinator.consume(link))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.droiddeck.launcher.session
|
package com.droiddeck.launcher.session
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.pm.ActivityInfo
|
||||||
import org.junit.Assert.*
|
import org.junit.Assert.*
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@@ -74,6 +75,35 @@ class PortraitResolutionTest {
|
|||||||
assertEquals("1440x2560", SessionPrefs.resolutionStored(app, "steam", panel, true))
|
assertEquals("1440x2560", SessionPrefs.resolutionStored(app, "steam", panel, true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun followScreenInLandscapeLeavesAFixedPortraitSizeFixed() {
|
||||||
|
SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.FOLLOW_SCREEN)
|
||||||
|
SessionPrefs.setResolutionChoice(app, "steam", "1024x768", portrait = true)
|
||||||
|
assertEquals(1f to null, SessionPrefs.followScales(app, "steam", panel))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun followScreenInPortraitLeavesAFixedLandscapeSizeFixed() {
|
||||||
|
SessionPrefs.setResolutionChoice(app, "steam", "1080p")
|
||||||
|
SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.followScaled(2f), portrait = true)
|
||||||
|
assertEquals(null to 2f, SessionPrefs.followScales(app, "steam", panel))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun followScalesKeepLinkedAndFixedChoices() {
|
||||||
|
SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.followScaled(1.5f))
|
||||||
|
assertEquals(1.5f to 1.5f, SessionPrefs.followScales(app, "steam", panel))
|
||||||
|
SessionPrefs.setResolutionChoice(app, "steam", "1024x768", portrait = true)
|
||||||
|
SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.LINK_PORTRAIT)
|
||||||
|
assertEquals(null to null, SessionPrefs.followScales(app, "steam", panel))
|
||||||
|
app.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear().commit()
|
||||||
|
assertEquals(null to null, SessionPrefs.followScales(app, "steam", panel))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun anAutoOrientationIsNotChangedByFollowScreen() {
|
||||||
|
assertFalse(SessionPrefs.portrait(app))
|
||||||
|
SessionPrefs.setOrientation(app, ActivityInfo.SCREEN_ORIENTATION_USER)
|
||||||
|
assertEquals(ActivityInfo.SCREEN_ORIENTATION_USER, SessionPrefs.windowOrientation(app, true, 700))
|
||||||
|
assertEquals(ActivityInfo.SCREEN_ORIENTATION_USER, SessionPrefs.windowOrientation(app, false, 700))
|
||||||
|
}
|
||||||
|
|
||||||
@Test fun modesKeepSeparateChoices() {
|
@Test fun modesKeepSeparateChoices() {
|
||||||
SessionPrefs.setResolutionChoice(app, "steam", "1080p", portrait = true)
|
SessionPrefs.setResolutionChoice(app, "steam", "1080p", portrait = true)
|
||||||
assertEquals(SessionDisplay.LINK_LANDSCAPE, SessionPrefs.resolutionStored(app, "lxqt", panel, true))
|
assertEquals(SessionDisplay.LINK_LANDSCAPE, SessionPrefs.resolutionStored(app, "lxqt", panel, true))
|
||||||
|
|||||||
@@ -63,6 +63,70 @@ class SessionSteamLogsTest {
|
|||||||
assertFalse(File(out, "web.txt").readText().contains("abcdef123456"))
|
assertFalse(File(out, "web.txt").readText().contains("abcdef123456"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun rpcs3Root(): Pair<File, File> {
|
||||||
|
val root = tmp.newFolder("rootfs")
|
||||||
|
return root to File(root, "root/.cache/rpcs3").apply { mkdirs() }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun rpcs3LogRewrittenThisSessionIsCollectedAloneAndRedacted() {
|
||||||
|
val (root, logs) = rpcs3Root()
|
||||||
|
val session = tmp.newFolder("session")
|
||||||
|
val out = File(session, "rpcs3")
|
||||||
|
File(logs, "RPCS3.log").writeText("earlier run\n")
|
||||||
|
File(logs, "RPCS3.log.gz").writeBytes(byteArrayOf(0x1f, 0x8b.toByte(), 8, 0))
|
||||||
|
File(logs, "RPCS3.buf").writeText("lock\n")
|
||||||
|
SessionArtifacts.markRpcs3Log(session, root)
|
||||||
|
|
||||||
|
File(logs, "RPCS3.log").writeText("PPU: compiling\nGET /x?sessionid=abcdef123456 200\n")
|
||||||
|
File(logs, "RPCS3.log.gz").appendBytes(byteArrayOf(1, 2, 3))
|
||||||
|
File(logs, "RPCS3.buf").appendText("more\n")
|
||||||
|
|
||||||
|
val copied = SessionArtifacts.copyRpcs3Log(logs, session, out)
|
||||||
|
assertEquals(listOf("RPCS3.log"), names(copied))
|
||||||
|
val text = File(out, "RPCS3.log").readText()
|
||||||
|
assertTrue(text.startsWith("PPU: compiling\n"))
|
||||||
|
assertFalse(text.contains("abcdef123456"))
|
||||||
|
assertEquals(listOf("RPCS3.log"), out.list()!!.sorted())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun rpcs3LogFirstWrittenThisSessionIsCollected() {
|
||||||
|
val (root, logs) = rpcs3Root()
|
||||||
|
val session = tmp.newFolder("session")
|
||||||
|
val out = File(session, "rpcs3")
|
||||||
|
SessionArtifacts.markRpcs3Log(session, root)
|
||||||
|
|
||||||
|
File(logs, "RPCS3.log").writeText("first boot\n")
|
||||||
|
|
||||||
|
assertEquals(listOf("RPCS3.log"), names(SessionArtifacts.copyRpcs3Log(logs, session, out)))
|
||||||
|
assertEquals("first boot\n", File(out, "RPCS3.log").readText())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun anRpcs3LogFromAnEarlierSessionIsNotCollected() {
|
||||||
|
val (root, logs) = rpcs3Root()
|
||||||
|
val session = tmp.newFolder("session")
|
||||||
|
val out = File(session, "rpcs3")
|
||||||
|
File(logs, "RPCS3.log").writeText("earlier run\n")
|
||||||
|
SessionArtifacts.markRpcs3Log(session, root)
|
||||||
|
|
||||||
|
assertTrue(SessionArtifacts.copyRpcs3Log(logs, session, out).isEmpty())
|
||||||
|
assertFalse(out.exists())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun anUnmarkedSessionCollectsNoRpcs3LogEvenWithSteamMarks() {
|
||||||
|
val (_, logs) = rpcs3Root()
|
||||||
|
val steam = tmp.newFolder("steam-logs")
|
||||||
|
val session = tmp.newFolder("session")
|
||||||
|
val out = File(session, "rpcs3")
|
||||||
|
File(steam, "console_log.txt").writeText("steam\n")
|
||||||
|
SessionArtifacts.markSteamLogs(session, steam)
|
||||||
|
File(logs, "RPCS3.log").writeText("another session's run\n")
|
||||||
|
|
||||||
|
assertTrue(SessionArtifacts.copyRpcs3Log(logs, session, out).isEmpty())
|
||||||
|
assertFalse(out.exists())
|
||||||
|
File(steam, "console_log.txt").appendText("new\n")
|
||||||
|
assertEquals(listOf("console_log.txt"), names(SessionArtifacts.copySessionLogs(steam, session, tmp.newFolder("out"))))
|
||||||
|
}
|
||||||
|
|
||||||
@Test fun aCopyFailurePreservesThePreviousSnapshotAndRemovesPartialStaging() {
|
@Test fun aCopyFailurePreservesThePreviousSnapshotAndRemovesPartialStaging() {
|
||||||
val logs = tmp.newFolder("logs")
|
val logs = tmp.newFolder("logs")
|
||||||
val session = tmp.newFolder("session")
|
val session = tmp.newFolder("session")
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.droiddeck.launcher.stores.epic
|
||||||
|
|
||||||
|
import org.json.JSONObject
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertNull
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.robolectric.RobolectricTestRunner
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner::class)
|
||||||
|
class EpicLoginTest {
|
||||||
|
private fun innerText(body: String): String = JSONObject.quote(body)
|
||||||
|
|
||||||
|
private fun corrective(action: String) =
|
||||||
|
"""{"errorCode":"errors.com.epicgames.oauth.corrective_action_required","metadata":{"correctiveAction":"$action"}}"""
|
||||||
|
|
||||||
|
private fun epicLogin() = EpicLogin("https://www.epicgames.com/id/authorize", "test-agent", "http://127.0.0.1/launcher/authorized")
|
||||||
|
|
||||||
|
@Test fun aRedirectPageAskingForTermsIsACorrectiveAction() {
|
||||||
|
assertEquals("PRIVACY_POLICY_ACCEPTANCE", EpicLogin.correctiveAction(innerText(corrective("PRIVACY_POLICY_ACCEPTANCE"))))
|
||||||
|
assertEquals("EULA_ACCEPTANCE", EpicLogin.correctiveAction(innerText(corrective("EULA_ACCEPTANCE"))))
|
||||||
|
assertEquals("EULA_ACCEPTANCE", EpicLogin.correctiveAction(corrective("EULA_ACCEPTANCE")))
|
||||||
|
assertEquals(EpicLogin.ACCOUNT_SIGN_IN_URL, epicLogin().browserStep(innerText(corrective("EULA_ACCEPTANCE"))))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun aCorrectiveActionWithoutItsNameStillSelectsTheBrowserStep() {
|
||||||
|
val body = """{"errorCode":"errors.com.epicgames.oauth.corrective_action_required"}"""
|
||||||
|
assertEquals("unknown", EpicLogin.correctiveAction(innerText(body)))
|
||||||
|
assertEquals(EpicLogin.ACCOUNT_SIGN_IN_URL, epicLogin().browserStep(innerText(body)))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun anAuthorizationCodeOrAnotherErrorStaysInTheSignInPage() {
|
||||||
|
val pages = listOf(
|
||||||
|
innerText("""{"warning":"Do not share this code with any 3rd party service.","redirectUrl":"https://localhost/launcher/authorized?code=c1","authorizationCode":"c1","sid":null}"""),
|
||||||
|
innerText("""{"errorCode":"errors.com.epicgames.common.authentication.authentication_failed","message":"Sorry"}"""),
|
||||||
|
innerText("Sign in"),
|
||||||
|
"null",
|
||||||
|
"",
|
||||||
|
)
|
||||||
|
for (page in pages) {
|
||||||
|
assertNull(page, EpicLogin.correctiveAction(page))
|
||||||
|
assertNull(page, epicLogin().browserStep(page))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun otherSignInFlowsHaveNoBrowserStep() {
|
||||||
|
val url = "https://www.epicgames.com/id/authorize?client_id=c85f4c6238b04d3399bc0080e83b83fd&response_type=code&redirect_uri=http%3A%2F%2F127.0.0.1%3A41234%2Flauncher%2Fauthorized&state=x"
|
||||||
|
val flow = EpicClient.loginFlow(url, "test-browser")!!
|
||||||
|
assertNull(flow.browserStep(innerText(corrective("EULA_ACCEPTANCE"))))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,7 +31,7 @@ static int store_root(char *out, size_t size) {
|
|||||||
return n > 0 && (size_t)n < size ? n : -1;
|
return n > 0 && (size_t)n < size ? n : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int store_exists(void) {
|
static __attribute__((noinline)) int store_exists(void) {
|
||||||
char root[PATH_MAX];
|
char root[PATH_MAX];
|
||||||
|
|
||||||
if (store_seen) return 1;
|
if (store_seen) return 1;
|
||||||
@@ -223,10 +223,18 @@ int fremovexattr(int fd, const char *name) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int watched(void) {
|
||||||
|
int saved = errno, found;
|
||||||
|
|
||||||
|
found = dd_is_wineserver() && store_exists();
|
||||||
|
errno = saved;
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
static int tracked(const char *path, char *out, size_t size) {
|
static int tracked(const char *path, char *out, size_t size) {
|
||||||
int saved = errno, found;
|
int saved = errno, found;
|
||||||
|
|
||||||
found = dd_is_wineserver() && store_exists() && resolved(path, out, size) == 0;
|
found = resolved(path, out, size) == 0;
|
||||||
errno = saved;
|
errno = saved;
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
@@ -258,22 +266,30 @@ static void follow(const char *from, const char *to) {
|
|||||||
errno = saved;
|
errno = saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((visibility("hidden")))
|
static __attribute__((noinline)) int removed(const char *path, int (*real)(const char *), int folder) {
|
||||||
int dd_descriptor_unlink(const char *path, int (*real)(const char *)) {
|
|
||||||
char target[PATH_MAX];
|
char target[PATH_MAX];
|
||||||
int known = tracked(path, target, sizeof(target)), result = real(path);
|
int known = tracked(path, target, sizeof(target)), result = real(path);
|
||||||
|
|
||||||
if (result == 0 && known) forget(target, 0);
|
if (result == 0 && known) forget(target, folder);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __attribute__((noinline)) int moved(const char *from, const char *to, int (*real)(const char *, const char *)) {
|
||||||
|
char old[PATH_MAX], new[PATH_MAX];
|
||||||
|
int known = tracked(from, old, sizeof(old)), result = real(from, to);
|
||||||
|
|
||||||
|
if (result == 0 && known && tracked(to, new, sizeof(new))) follow(old, new);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((visibility("hidden")))
|
__attribute__((visibility("hidden")))
|
||||||
int dd_descriptor_rmdir(const char *path, int (*real)(const char *)) {
|
int dd_descriptor_unlink(const char *path, int (*real)(const char *)) {
|
||||||
char target[PATH_MAX];
|
return watched() ? removed(path, real, 0) : real(path);
|
||||||
int known = tracked(path, target, sizeof(target)), result = real(path);
|
}
|
||||||
|
|
||||||
if (result == 0 && known) forget(target, 1);
|
__attribute__((visibility("hidden")))
|
||||||
return result;
|
int dd_descriptor_rmdir(const char *path, int (*real)(const char *)) {
|
||||||
|
return watched() ? removed(path, real, 1) : real(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((visibility("hidden")))
|
__attribute__((visibility("hidden")))
|
||||||
@@ -283,9 +299,5 @@ int dd_descriptor_remove(const char *path, int (*real)(const char *)) {
|
|||||||
|
|
||||||
__attribute__((visibility("hidden")))
|
__attribute__((visibility("hidden")))
|
||||||
int dd_descriptor_rename(const char *from, const char *to, int (*real)(const char *, const char *)) {
|
int dd_descriptor_rename(const char *from, const char *to, int (*real)(const char *, const char *)) {
|
||||||
char old[PATH_MAX], new[PATH_MAX];
|
return watched() ? moved(from, to, real) : real(from, to);
|
||||||
int known = tracked(from, old, sizeof(old)), result = real(from, to);
|
|
||||||
|
|
||||||
if (result == 0 && known && tracked(to, new, sizeof(new))) follow(old, new);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
@@ -72,15 +72,12 @@ static int read_only_copy(const char *data, size_t len, int flags) {
|
|||||||
return ro;
|
return ro;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((visibility("hidden"))) int dd_status_without_tracer(const char *path, int flags, const void *caller) {
|
static __attribute__((noinline)) int status_copy(const char *path, int flags, long pid) {
|
||||||
char text[STATUS_MAX];
|
char text[STATUS_MAX];
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
int saved = errno;
|
int saved = errno;
|
||||||
int out = -1;
|
int out = -1;
|
||||||
|
|
||||||
long pid;
|
|
||||||
if ((flags & O_ACCMODE) != O_RDONLY || (pid = status_pid(path)) < 0 || is_web_helper(caller) || dd_from_ntdll(caller))
|
|
||||||
return -1;
|
|
||||||
// through the next open(): the native userland's hook gives the app's ids as root's there
|
// through the next open(): the native userland's hook gives the app's ids as root's there
|
||||||
static int (*next_open)(const char *, int, ...) = NULL;
|
static int (*next_open)(const char *, int, ...) = NULL;
|
||||||
if (!next_open) next_open = (int (*)(const char *, int, ...))dlsym(RTLD_NEXT, "open");
|
if (!next_open) next_open = (int (*)(const char *, int, ...))dlsym(RTLD_NEXT, "open");
|
||||||
@@ -116,3 +113,10 @@ done:
|
|||||||
errno = saved;
|
errno = saved;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__((visibility("hidden"))) int dd_status_without_tracer(const char *path, int flags, const void *caller) {
|
||||||
|
long pid;
|
||||||
|
if ((flags & O_ACCMODE) != O_RDONLY || (pid = status_pid(path)) < 0 || is_web_helper(caller) || dd_from_ntdll(caller))
|
||||||
|
return -1;
|
||||||
|
return status_copy(path, flags, pid);
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
PRELOAD = Path(__file__).resolve().parents[1] / "linuxfs/preload"
|
||||||
|
LIMIT = 1024
|
||||||
|
WRAPPERS = {
|
||||||
|
"descriptor.c": ("dd_descriptor_unlink", "dd_descriptor_rmdir", "dd_descriptor_remove", "dd_descriptor_rename"),
|
||||||
|
"tracer.c": ("dd_status_without_tracer",),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def frames(source, build):
|
||||||
|
obj = build / (source + ".o")
|
||||||
|
subprocess.run(["cc", "-c", "-fPIC", "-O2", "-Wall", "-fstack-usage", "-o", str(obj), str(PRELOAD / source)],
|
||||||
|
check=True)
|
||||||
|
sizes = {}
|
||||||
|
for line in obj.with_suffix(".su").read_text().splitlines():
|
||||||
|
place, size, _ = line.split("\t")
|
||||||
|
sizes[place.rsplit(":", 1)[-1]] = int(size)
|
||||||
|
return sizes
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipUnless(shutil.which("cc"), "needs a C compiler")
|
||||||
|
class PreloadWrapperStackTest(unittest.TestCase):
|
||||||
|
def test_wrappers_keep_path_buffers_off_their_frames(self):
|
||||||
|
with tempfile.TemporaryDirectory() as build:
|
||||||
|
for source, names in WRAPPERS.items():
|
||||||
|
sizes = frames(source, Path(build))
|
||||||
|
for name in names:
|
||||||
|
with self.subTest(function=name):
|
||||||
|
self.assertIn(name, sizes)
|
||||||
|
self.assertLess(sizes[name], LIMIT)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
Reference in new issue
Block a user