Skip to content

Commit e859f00

Browse files
committed
Merge branch 'crash-in-split-tunneling-due-to-too-large-app-icon-droid-846'
2 parents 5d94293 + 380080c commit e859f00

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ Line wrap the file at 100 chars. Th
5252
- Fix pointless API access method rotations for concurrent requests.
5353
- Fix daemon rotating logs on startup even if another daemon is already running.
5454

55+
#### Android
56+
- Fix crash in Split Tunneling screen caused by apps provding icons bigger than 100MB.
57+
5558
### Security
5659
#### Android
5760
- Change from singleTask to singleInstance to fix Task Affinity Vulnerability in Android 8.

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SplitTunnelingCell.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import kotlinx.coroutines.Dispatchers
2828
import kotlinx.coroutines.launch
2929
import net.mullvad.mullvadvpn.R
3030
import net.mullvad.mullvadvpn.compose.component.SpacedColumn
31+
import net.mullvad.mullvadvpn.compose.util.isBelowMaxBitmapSize
3132
import net.mullvad.mullvadvpn.lib.theme.AppTheme
3233
import net.mullvad.mullvadvpn.lib.theme.Dimens
3334
import net.mullvad.mullvadvpn.lib.theme.color.Alpha40
@@ -75,7 +76,9 @@ fun SplitTunnelingCell(
7576
LaunchedEffect(packageName) {
7677
launch(Dispatchers.IO) {
7778
val bitmap = onResolveIcon(packageName ?: "")
78-
icon = bitmap?.asImageBitmap()
79+
if (bitmap != null && bitmap.isBelowMaxBitmapSize()) {
80+
icon = bitmap.asImageBitmap()
81+
}
7982
}
8083
}
8184
BaseCell(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package net.mullvad.mullvadvpn.compose.util
2+
3+
import android.graphics.Bitmap
4+
5+
private const val MAX_BITMAP_SIZE_BYTES = 100 * 1024 * 1024
6+
7+
fun Bitmap.isBelowMaxBitmapSize(): Boolean = byteCount < MAX_BITMAP_SIZE_BYTES

android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/PackageManagerExtensions.kt

+3
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ fun PackageManager.getApplicationIconBitmapOrNull(packageName: String): Bitmap?
1313
} catch (e: IllegalArgumentException) {
1414
// IllegalArgumentException is thrown if the application has an invalid icon
1515
null
16+
} catch (e: OutOfMemoryError) {
17+
// OutOfMemoryError is thrown if the icon is too large
18+
null
1619
}

0 commit comments

Comments
 (0)