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

Commit 015f661f authored by Matt Pietal's avatar Matt Pietal
Browse files

Don't assume a non-null name on UserInfo

If the UserInfo record is present, the UI wants to display
a name. It looks like there are certain conditions where this
can be null, and it is allowed to be null. Instead of throwing
an exception, log the user info and return an empty string.

Fixes: 371365845
Test: manual - just added a null check
Flag: EXEMPT bugfix
Change-Id: If77c5ed962288f69c4da95832a78363d09b5fb12
parent a8354625
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
package com.android.systemui.user.legacyhelper.ui

import android.content.Context
import android.util.Log
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import com.android.systemui.res.R
@@ -32,6 +33,8 @@ import com.android.systemui.user.data.source.UserRecord
 */
object LegacyUserUiHelper {

    private const val TAG = "LegacyUserUiHelper"

    @JvmStatic
    @DrawableRes
    fun getUserSwitcherActionIconResourceId(
@@ -67,7 +70,9 @@ object LegacyUserUiHelper {
        val resourceId: Int? = getGuestUserRecordNameResourceId(record)
        return when {
            resourceId != null -> context.getString(resourceId)
            record.info != null -> checkNotNull(record.info.name)
            record.info != null ->
                record.info.name
                    ?: "".also { Log.i(TAG, "Expected display name for: ${record.info}") }
            else ->
                context.getString(
                    getUserSwitcherActionTextResourceId(