Skip to content

Commit ff548d2

Browse files
authored
Fix crash when max shortcuts count is exceeded (#8644)
1 parent ec9a066 commit ff548d2

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
# Enrich gradle.properties for CI/CD
99
env:
10-
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false
10+
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError -XX:MaxMetaspaceSize=1g" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false
1111
CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon
1212

1313
jobs:

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- cron: "0 4 * * *"
88

99
env:
10-
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false
10+
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError -XX:MaxMetaspaceSize=1g" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false
1111
CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon
1212

1313
jobs:

.github/workflows/nightly_er.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- cron: "0 4 * * *"
77

88
env:
9-
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false
9+
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError -XX:MaxMetaspaceSize=1g" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false
1010
CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon
1111

1212
jobs:

changelog.d/8644.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix crash when max shortcuts count is exceeded

vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,19 @@ class ShortcutsHandler @Inject constructor(
139139
}
140140

141141
private fun createShortcuts(rooms: List<RoomSummary>) {
142-
if (hasPinCode.get()) {
143-
// No shortcut in this case (privacy)
144-
ShortcutManagerCompat.removeAllDynamicShortcuts(context)
145-
} else {
146-
val shortcuts = rooms
147-
.take(maxShortcutCountPerActivity)
148-
.mapIndexed { index, room ->
149-
shortcutCreator.create(room, index)
150-
}
142+
ShortcutManagerCompat.removeAllDynamicShortcuts(context)
151143

152-
shortcuts.forEach { shortcut ->
153-
ShortcutManagerCompat.pushDynamicShortcut(context, shortcut)
154-
}
144+
// No shortcut in this case (privacy)
145+
if (hasPinCode.get()) return
146+
147+
val shortcuts = rooms
148+
.take(maxShortcutCountPerActivity)
149+
.mapIndexed { index, room ->
150+
shortcutCreator.create(room, index)
151+
}
152+
153+
shortcuts.forEach { shortcut ->
154+
ShortcutManagerCompat.pushDynamicShortcut(context, shortcut)
155155
}
156156
}
157157

vector/src/main/java/im/vector/app/features/rageshake/VectorUncaughtExceptionHandler.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import android.content.SharedPreferences
2020
import android.os.Build
2121
import androidx.core.content.edit
2222
import im.vector.app.core.di.DefaultPreferences
23+
import im.vector.app.core.resources.AppNameProvider
2324
import im.vector.app.core.resources.VersionCodeProvider
2425
import im.vector.app.features.version.VersionProvider
2526
import org.matrix.android.sdk.api.Matrix
@@ -36,6 +37,7 @@ class VectorUncaughtExceptionHandler @Inject constructor(
3637
private val bugReporter: BugReporter,
3738
private val versionProvider: VersionProvider,
3839
private val versionCodeProvider: VersionCodeProvider,
40+
private val appNameProvider: AppNameProvider,
3941
) : Thread.UncaughtExceptionHandler {
4042

4143
// key to save the crash status
@@ -67,12 +69,12 @@ class VectorUncaughtExceptionHandler @Inject constructor(
6769
putBoolean(PREFS_CRASH_KEY, true)
6870
}
6971
val b = StringBuilder()
70-
val appName = "Element" // TODO Matrix.getApplicationName()
72+
val appName = appNameProvider.getAppName()
7173

72-
b.append(appName + " Build : " + versionCodeProvider.getVersionCode() + "\n")
74+
b.append("$appName Build : ${versionCodeProvider.getVersionCode()}\n")
7375
b.append("$appName Version : ${versionProvider.getVersion(longFormat = true)}\n")
7476
b.append("SDK Version : ${Matrix.getSdkVersion()}\n")
75-
b.append("Phone : " + Build.MODEL.trim() + " (" + Build.VERSION.INCREMENTAL + " " + Build.VERSION.RELEASE + " " + Build.VERSION.CODENAME + ")\n")
77+
b.append("Phone : ${Build.MODEL.trim()} (${Build.VERSION.INCREMENTAL} ${Build.VERSION.RELEASE} ${Build.VERSION.CODENAME})\n")
7678

7779
b.append("Memory statuses \n")
7880

0 commit comments

Comments
 (0)