Mahmud0808 / ColorBlendr

An Android app for customizing Material You colors on devices with Android 12+. It lets you tweak accent colors, background saturation, and more for a personalized look.
GNU General Public License v3.0
765 stars 14 forks source link

LineageOS dialer crashes with theming enabled #105

Closed tatokis closed 1 month ago

tatokis commented 1 month ago

On LineageOS 21 with ColorBlendr v1.5 (F-Droid) enabled, the Dialer app crashes when someone is calling:

--------- beginning of crash
07-16 14:03:52.175 16409 16409 E AndroidRuntime: FATAL EXCEPTION: main
07-16 14:03:52.175 16409 16409 E AndroidRuntime: Process: com.android.dialer, PID: 16409
07-16 14:03:52.175 16409 16409 E AndroidRuntime: java.lang.IllegalArgumentException
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at com.android.dialer.common.Assert.checkArgument(PG:103)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at com.android.dialer.common.Assert.checkArgument(PG:89)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at com.android.dialer.theme.base.impl.AospThemeImpl.getColorPrimary(PG:143)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at com.android.incallui.InCallUIMaterialColorMapUtils.getDefaultPrimaryAndSecondaryColors(PG:47)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at com.android.incallui.InCallUIMaterialColorMapUtils.calculatePrimaryAndSecondaryColor(PG:59)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at com.android.incallui.ThemeColorManager.updateThemeColors(PG:66)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at com.android.incallui.ThemeColorManager.onForegroundCallChanged(PG:52)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at com.android.incallui.InCallPresenter.onForegroundCallChanged(PG:1614)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at com.android.incallui.InCallPresenter.onCallListChange(PG:656)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at com.android.incallui.InCallPresenter.updateActivity(PG:478)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at com.android.incallui.InCallPresenter.setActivity(PG:1633)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at com.android.incallui.InCallActivity.onStart(PG:426)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1701)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at android.app.Activity.performStart(Activity.java:9003)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at android.app.ActivityThread.handleStartActivity(ActivityThread.java:4018)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:327)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:307)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at android.app.servertransaction.TransactionExecutor.executeLifecycleItem(TransactionExecutor.java:279)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:150)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:93)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2595)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:107)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:232)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:317)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:8592)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
07-16 14:03:52.175 16409 16409 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
07-16 14:03:52.179  1804  3783 W ActivityTaskManager:   Force finishing activity com.android.dialer/com.android.incallui.InCallActivity

Simply opening the Dialer app does not cause this. There needs to be an incoming call and the screen needs to be locked.

Relevant source line from the Dialer https://github.com/LineageOS/android_packages_apps_Dialer/blob/a03a34689dc9bf832854a1daa71260c0becf4a65/java/com/android/dialer/theme/base/impl/AospThemeImpl.java#L143

Turning off "ColorBlendr service" from the settings prevents the crash. Applying "Force per app theme" to the Dialer itself does not change anything.

Mahmud0808 commented 1 month ago

Does this happen in both dark and light mode? Is it reproducible if Lineage OS dialer is not a system app?

tatokis commented 1 month ago

I ended up debugging this further and figured it out. This has nothing to do with ColorBlendr and is a bug in Lineage's Dialer. I thought the Dialer at first was unable to get the theme colours for some reason, but it actually did get them successfully.

What happens is that the dialer uses -1 as a fallback value and then asserts that the colours it got from the theme are != -1.

https://github.com/LineageOS/android_packages_apps_Dialer/blob/a03a34689dc9bf832854a1daa71260c0becf4a65/java/com/android/dialer/theme/base/impl/AospThemeImpl.java#L79-L92

The problem with that is that -1 is actually white (0xFFFFFFFF). https://developer.android.com/reference/android/graphics/Color#WHITE

I had set a bunch of shades to be fully white, which triggered this bug. Setting them to 0xFEFEFE instead made the crash go away.

Apologies for the noise, but hopefully this helps someone in the future.