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

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

Fix notification app icon badging cloned and private profiles.

Fixes: 416218108
Test: manual testing of notifications with private space
Flag: android.app.notifications_redesign_app_icons
Reland: I6d3a45a252735e0df07f5710ca08b6b3da9dda93
Change-Id: I933f32d5f274ba6f32c43ed36eed58034a5e6e5a
parent 78ba7b47
Loading
Loading
Loading
Loading
+9 −16
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.os.UserHandle
import android.os.UserManager
import android.util.Log
import com.android.internal.R
import com.android.launcher3.icons.BaseIconFactory
@@ -221,7 +220,7 @@ constructor(

    private fun iconOptions(userHandle: UserHandle, allowProfileBadge: Boolean): IconOptions {
        return IconOptions().apply {
            setUser(userIconInfo(userHandle, allowProfileBadge))
            setUser(userIconInfo(userHandle, allowProfileBadge = allowProfileBadge))
            setBitmapGenerationMode(BaseIconFactory.MODE_HARDWARE)
            // This color will not be used, but we're just setting it so that the icon factory
            // doesn't try to extract colors from our bitmap (since it won't work, given it's a
@@ -230,19 +229,13 @@ constructor(
        }
    }

    private fun userIconInfo(userHandle: UserHandle, allowProfileBadge: Boolean): UserIconInfo {
        // TODO(b/423033161): use the correct badge for the type of managed profile
        val withWorkProfileBadge =
    private fun userIconInfo(userHandle: UserHandle, allowProfileBadge: Boolean): UserIconInfo =
        if (allowProfileBadge) {
                val userManager = sysuiContext.getSystemService(UserManager::class.java)
                userManager?.isManagedProfile(userHandle.identifier) == true
            // Look up the user to determine if it is a profile, and if so which badge to use
            Utils.fetchUserIconInfo(sysuiContext, userHandle)
        } else {
                false
            }
        return UserIconInfo(
            userHandle,
            if (withWorkProfileBadge) UserIconInfo.TYPE_WORK else UserIconInfo.TYPE_MAIN,
        )
            // For a main user the IconFactory does not add a badge
            UserIconInfo(/* user= */ userHandle, /* type= */ UserIconInfo.TYPE_MAIN)
        }

    override fun purgeCache(wantedPackages: Collection<String>) {