From 73759e0750a9fd86b5fc423ea050131152b5668a Mon Sep 17 00:00:00 2001 From: Davinci9196 Date: Mon, 22 Jun 2026 10:47:40 +0800 Subject: [PATCH] Games: Catch network exceptions in GameDeletePlayAccountFragment to fix :ui crash on SSL handshake failure --- .../games/ui/GameDeletePlayAccountFragment.kt | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/play-services-core/src/main/kotlin/org/microg/gms/games/ui/GameDeletePlayAccountFragment.kt b/play-services-core/src/main/kotlin/org/microg/gms/games/ui/GameDeletePlayAccountFragment.kt index 1b74aa2e14..d63e6d2b44 100644 --- a/play-services-core/src/main/kotlin/org/microg/gms/games/ui/GameDeletePlayAccountFragment.kt +++ b/play-services-core/src/main/kotlin/org/microg/gms/games/ui/GameDeletePlayAccountFragment.kt @@ -84,28 +84,33 @@ class GameDeletePlayAccountFragment : Fragment() { private fun loadIndividualGames() { lifecycleScope.launchWhenStarted { - val response = withContext(Dispatchers.IO) { - val scopes = arrayListOf(Scope(Scopes.GAMES_LITE), Scope(Scopes.GAMES_FIRSTPARTY)) - val authToken = requestGameToken(requireContext(), lastChoosePlayer!!.first, scopes) ?: throw RuntimeException("authToken is null") - getApplicationsFirstPartyClient(requireContext(), authToken).ListApplicationsWithUserDataFirstParty().execute(ListApplicationsWithUserDataRequest.build { - locale = Locale.getDefault().language - androidSdk = "android:${SDK_INT}" - }) - } - val dataList = response.firstPartyApplication.map { - GameDataDeleteItem( - iconUrl = it.application?.gameIcon?.url, - gameName = it.application?.gameName, - gameId = it.application?.gameId, - tips = "${it.unlockAchievementsNum} / ${it.application?.achievementsNum} ${requireContext().getString(R.string.games_achievement_list_title)}" - ) - } - individualGameRecyclerView.layoutManager = LinearLayoutManager(requireContext()) - individualGameRecyclerView.adapter = GameDataDeleteAdapter(dataList) { item -> - showDeleteConfirmationDialog(item) + try { + val response = withContext(Dispatchers.IO) { + val scopes = arrayListOf(Scope(Scopes.GAMES_LITE), Scope(Scopes.GAMES_FIRSTPARTY)) + val authToken = requestGameToken(requireContext(), lastChoosePlayer!!.first, scopes) ?: throw RuntimeException("authToken is null") + getApplicationsFirstPartyClient(requireContext(), authToken).ListApplicationsWithUserDataFirstParty().execute(ListApplicationsWithUserDataRequest.build { + locale = Locale.getDefault().language + androidSdk = "android:${SDK_INT}" + }) + } + val dataList = response.firstPartyApplication.map { + GameDataDeleteItem( + iconUrl = it.application?.gameIcon?.url, + gameName = it.application?.gameName, + gameId = it.application?.gameId, + tips = "${it.unlockAchievementsNum} / ${it.application?.achievementsNum} ${requireContext().getString(R.string.games_achievement_list_title)}" + ) + } + individualGameRecyclerView.layoutManager = LinearLayoutManager(requireContext()) + individualGameRecyclerView.adapter = GameDataDeleteAdapter(dataList) { item -> + showDeleteConfirmationDialog(item) + } + individualGameRecyclerView.visibility = View.VISIBLE + loadingBar.visibility = View.GONE + } catch (e: Exception) { + Log.w(TAG, "loadIndividualGames: ", e) + loadingBar.visibility = View.GONE } - individualGameRecyclerView.visibility = View.VISIBLE - loadingBar.visibility = View.GONE } }