Solve NPE.

`secondaryLabel` is public and may be changed from other threads, therefore make a local reference and use the local reference.

Bug: 271270746
Test: build SystemUI and verify the secondary label works properly
Change-Id: I71c79bcf380ce46ad5f0be6b8e2a7647df55f5bf
This commit is contained in:
Holly Sun
2023-03-03 09:27:56 -08:00
parent 2b9ee44d55
commit 4c76f8db29

View File

@@ -189,10 +189,12 @@ public interface QSTile {
/** Get the text for secondaryLabel. */
public String getSecondaryLabel(String stateText) {
if (TextUtils.isEmpty(secondaryLabel)) {
// Use a local reference as the value might change from other threads
CharSequence localSecondaryLabel = secondaryLabel;
if (TextUtils.isEmpty(localSecondaryLabel)) {
return stateText;
}
return secondaryLabel.toString();
return localSecondaryLabel.toString();
}
public boolean copyTo(State other) {