diff --git a/CHANGELOG.md b/CHANGELOG.md index 3749f2071028..c7e327254e98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,9 @@ Line wrap the file at 100 chars. Th - Fix pointless API access method rotations for concurrent requests. - Fix daemon rotating logs on startup even if another daemon is already running. +#### Android +- Fix crash in Split Tunneling screen caused by apps provding icons bigger than 100MB. + ### Security #### Android - Change from singleTask to singleInstance to fix Task Affinity Vulnerability in Android 8. diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SplitTunnelingCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SplitTunnelingCell.kt index 98c376739393..1bf8acf73189 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SplitTunnelingCell.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SplitTunnelingCell.kt @@ -28,6 +28,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import net.mullvad.mullvadvpn.R import net.mullvad.mullvadvpn.compose.component.SpacedColumn +import net.mullvad.mullvadvpn.compose.util.isBelowMaxBitmapSize import net.mullvad.mullvadvpn.lib.theme.AppTheme import net.mullvad.mullvadvpn.lib.theme.Dimens import net.mullvad.mullvadvpn.lib.theme.color.Alpha40 @@ -75,7 +76,9 @@ fun SplitTunnelingCell( LaunchedEffect(packageName) { launch(Dispatchers.IO) { val bitmap = onResolveIcon(packageName ?: "") - icon = bitmap?.asImageBitmap() + if (bitmap != null && bitmap.isBelowMaxBitmapSize()) { + icon = bitmap.asImageBitmap() + } } } BaseCell( diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Bitmap.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Bitmap.kt new file mode 100644 index 000000000000..9a3d03078066 --- /dev/null +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Bitmap.kt @@ -0,0 +1,7 @@ +package net.mullvad.mullvadvpn.compose.util + +import android.graphics.Bitmap + +private const val MAX_BITMAP_SIZE_BYTES = 100 * 1024 * 1024 + +fun Bitmap.isBelowMaxBitmapSize(): Boolean = byteCount < MAX_BITMAP_SIZE_BYTES diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/PackageManagerExtensions.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/PackageManagerExtensions.kt index c5bf7965caa7..1e7721710eef 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/PackageManagerExtensions.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/PackageManagerExtensions.kt @@ -13,4 +13,7 @@ fun PackageManager.getApplicationIconBitmapOrNull(packageName: String): Bitmap? } catch (e: IllegalArgumentException) { // IllegalArgumentException is thrown if the application has an invalid icon null + } catch (e: OutOfMemoryError) { + // OutOfMemoryError is thrown if the icon is too large + null }