forked from mirror/monocles_chat_clean
Fix ColorResourcesTableCreator creation exception.
A java.lang.ArrayIndexOutOfBoundsException is thrown the third, and subsequent times, ThemeHelper.applyCustomColors() is called. ,---- | java.lang.ArrayIndexOutOfBoundsException: src.length=128 srcPos=0 dst.length=131 dstPos=2 length=-128 `---- One way to trigger this is to call ConversationsOverviewFragment.onStart() three times. For example, open the app then, three dot menu -> Settings, back, three dot menu -> Settings, back. The exception is raised at line ColorResourcesTableCreator.java:616. So, stringToByteArrayUtf8() is ill prepared to deal with a string longer than 127 bytes. While the cast to signed byte is the immediate cause of the exception, the root cause is growth of the ColorResource name string as the package name is prepended to the color resource name on each pass through ColorResourceTableCreator.create(). Using Resource.getResourceEntryName() instead of Resource.getResourceName() prevents this. For the record, here’s the Exception stack trace: 2023-03-23 23:18:34.592 622-622 ColorResou...derCreator com.cheogram.android E Failed to create the ColorResourcesTableCreator. java.lang.ArrayIndexOutOfBoundsException: src.length=128 srcPos=0 dst.length=131 dstPos=2 length=-128 at java.lang.System.arraycopy(Native Method) at com.cheogram.android.ColorResourcesTableCreator.stringToByteArrayUtf8(ColorResourcesTableCreator.java:616) at com.cheogram.android.ColorResourcesTableCreator.access$800(ColorResourcesTableCreator.java:40) at com.cheogram.android.ColorResourcesTableCreator$StringPoolChunk.processString(ColorResourcesTableCreator.java:299) at com.cheogram.android.ColorResourcesTableCreator$StringPoolChunk.<init>(ColorResourcesTableCreator.java:223) at com.cheogram.android.ColorResourcesTableCreator$PackageChunk.<init>(ColorResourcesTableCreator.java:347) at com.cheogram.android.ColorResourcesTableCreator$ResTable.<init>(ColorResourcesTableCreator.java:140) at com.cheogram.android.ColorResourcesTableCreator.create(ColorResourcesTableCreator.java:114) at com.cheogram.android.ColorResourcesLoaderCreator.create(ColorResourcesLoaderCreator.java:45) at eu.siacs.conversations.utils.ThemeHelper.applyCustomColors(ThemeHelper.java:67) at eu.siacs.conversations.ui.ConversationsActivity.onStart(ConversationsActivity.java:658) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1455) at android.app.Activity.performStart(Activity.java:8076) at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3660) at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221) at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2210) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7839) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) (cherry picked from commit bdafe2ca8f95fc8702d07008838140f09191bf1d)
This commit is contained in:
parent
4ff2fb2be8
commit
2801211e0c
1 changed files with 1 additions and 1 deletions
|
@ -77,7 +77,7 @@ final class ColorResourcesTableCreator {
|
|||
colorResource =
|
||||
new ColorResource(
|
||||
entry.getKey(),
|
||||
context.getResources().getResourceName(entry.getKey()),
|
||||
context.getResources().getResourceEntryName(entry.getKey()),
|
||||
entry.getValue());
|
||||
if (!context
|
||||
.getResources()
|
||||
|
|
Loading…
Reference in a new issue