Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f0529e8a authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz
Browse files

Live Update: Fix ChronometerStub/Chronometer cast crash

Live Update AOD Template was offloaded to the bg thread and Live Update
uses the same AOD template if notification layout is not changed.
Chronometer is an exceptional View among the views in Notification
because we inflate it when it's necessary. When the same view is
re-used with Chronometer case, existing logic will throw casting
exception and crash.

Fixes: 442583001
Flag: EXEMPT bug fix
Test: manual (Enable AOD, post a Live Update that uses Chronometer,
interact with chip. Observe no crash)

Change-Id: I2abfc35b76573db4386c7eb2b256f2037206e147
parent 940d70b4
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@ fun AODPromotedNotificationView(
                if (notificationView.parent != null) {
                    (notificationView.parent as ViewGroup).removeView(notificationView)
                }

                val updater =
                    traceSection("$TAG.findViews") {
                        AODPromotedNotificationViewUpdater(notificationView)
@@ -261,7 +262,7 @@ private class AODPromotedNotificationViewUpdater(root: View) {
    private val appNameText: TextView? = root.findViewById(R.id.app_name_text)
    private val bigPicture: BigPictureNotificationImageView? = root.findViewById(R.id.big_picture)
    private val bigText: ImageFloatingTextView? = root.findViewById(R.id.big_text)
    private var chronometerStub: ViewStub? = root.findViewById(R.id.chronometer)
    private var chronometerStub: ViewStub? = null
    private var chronometer: Chronometer? = null
    private val closeButton: View? = root.findViewById(R.id.close_button)
    private val conversationIconBadge: View? = root.findViewById(R.id.conversation_icon_badge)
@@ -327,6 +328,12 @@ private class AODPromotedNotificationViewUpdater(root: View) {
    private var smallIconSavedState: SmallIconSavedState? = null

    init {
        val chronometerView = root.findViewById<View>(R.id.chronometer)
        if (chronometerView is ViewStub) {
            chronometerStub = chronometerView
        } else if (chronometerView is Chronometer) {
            chronometer = chronometerView
        }
        // Hide views that are never visible in the skeleton promoted notification.
        alternateExpandTarget?.visibility = GONE
        bigPicture?.visibility = GONE