Skip to content

Commit

Permalink
Fix crash when no apps in enterprise policy
Browse files Browse the repository at this point in the history
  • Loading branch information
fynngodau committed Oct 19, 2024
1 parent f14124c commit 655cc6f
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ class VendingActivity : ComponentActivity() {

Log.v(TAG, "app policy: ${apps.joinToString { "${it.packageName}: ${it.policy}" }}")

if (apps.isEmpty()) {
// Don't fetch details of empty app list (otherwise HTTP 400)
networkState = NetworkState.PASSIVE
this@VendingActivity.apps.clear()
return@runBlocking
}

// Fetch details about all available apps
val details = client.post(
url = URL_ITEM_DETAILS,
Expand Down Expand Up @@ -257,7 +264,7 @@ class VendingActivity : ComponentActivity() {
networkState = NetworkState.ERROR
Log.e(TAG, "Network error: ${e.message}")
e.printStackTrace()
} catch (e: NullPointerException) {
} catch (e: Exception) {
networkState = NetworkState.ERROR
Log.e(TAG, "Unexpected network response, cannot process")
e.printStackTrace()
Expand Down

0 comments on commit 655cc6f

Please sign in to comment.