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

Commit e2b4641c authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Cancel stale FlagDependencies notification on start to avoid confusion

Flag: NA
Test: launch with bad config; fix config; crash systemui; validate notif disappears
Change-Id: Ic5a239cc96937c1b98a4a9c48dedad29786e8c01
parent 5011d41f
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.flags
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.NotificationManager.IMPORTANCE_DEFAULT
import android.content.Context
import android.util.Log
import com.android.systemui.CoreStartable
@@ -150,7 +151,7 @@ constructor(
        val title = "Invalid flag dependencies: ${unmet.size}"
        val details = unmet.joinToString("\n") { it.shortUnmetString() }
        Log.e("FlagDependencies", "$title:\n$details")
        val channel = NotificationChannel("FLAGS", "Flags", NotificationManager.IMPORTANCE_DEFAULT)
        val channel = NotificationChannel(CHANNEL_ID, CHANNEL_NAME, IMPORTANCE_DEFAULT)
        val notification =
            Notification.Builder(context, channel.id)
                .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
@@ -160,7 +161,18 @@ constructor(
                .setVisibility(Notification.VISIBILITY_PUBLIC)
                .build()
        notifManager.createNotificationChannel(channel)
        notifManager.notify("flags", 0, notification)
        notifManager.notify(NOTIF_TAG, NOTIF_ID, notification)
    }

    override fun onCollected(all: List<FlagDependenciesBase.Dependency>) {
        notifManager.cancel(NOTIF_TAG, NOTIF_ID)
    }

    companion object {
        private const val CHANNEL_ID = "FLAGS"
        private const val CHANNEL_NAME = "Flags"
        private const val NOTIF_TAG = "FlagDependenciesNotifier"
        private const val NOTIF_ID = 0
    }
}