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

Commit 70d5a07c authored by Winson Chung's avatar Winson Chung
Browse files

Prevent crash when flattening ComponentKey to string with invalid user.

Bug: 22658306
Change-Id: I213d44e0bb22ac0617d46c80ab8cfec8f750a2cc
parent fd69e0b5
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -64,8 +64,11 @@ public class ComponentKey {
     * Encodes a component key as a string of the form [flattenedComponentString#userId].
     */
    public String flattenToString(Context context) {
        return componentName.flattenToString() + "#" +
                UserManagerCompat.getInstance(context).getSerialNumberForUser(user);
        String flattened = componentName.flattenToString();
        if (user != null) {
            flattened += "#" + UserManagerCompat.getInstance(context).getSerialNumberForUser(user);
        }
        return flattened;
    }

    @Override