Fix the NPE in the Settings Tile lib

Move the key checker after ensureMetadataNotStale() since it might
update the key to null.

Fix: 286690307
Test: robotest
Change-Id: I6eaae2ca798d2deccea44137846fe9a4e294f26e
This commit is contained in:
Jason Chiu
2023-07-04 17:57:47 +08:00
parent 5a1cad4f3f
commit f730153b58

View File

@@ -284,10 +284,10 @@ public abstract class Tile implements Parcelable {
* Optional key to use for this tile. * Optional key to use for this tile.
*/ */
public String getKey(Context context) { public String getKey(Context context) {
ensureMetadataNotStale(context);
if (!hasKey()) { if (!hasKey()) {
return null; return null;
} }
ensureMetadataNotStale(context);
if (mMetaData.get(META_DATA_PREFERENCE_KEYHINT) instanceof Integer) { if (mMetaData.get(META_DATA_PREFERENCE_KEYHINT) instanceof Integer) {
return context.getResources().getString(mMetaData.getInt(META_DATA_PREFERENCE_KEYHINT)); return context.getResources().getString(mMetaData.getInt(META_DATA_PREFERENCE_KEYHINT));
} else { } else {