Dynamic Injection into PreferenceCategory

- Avoid NPE when groupkey is null

Bug: 335592049
Change-Id: I810220d18e55351a280cff08b74b37130607168c
Test: robotest & manual
This commit is contained in:
Edgar Wang
2024-04-19 00:18:11 +00:00
parent ea89a3cb1d
commit aec1d97788

View File

@@ -545,9 +545,13 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
getActivity(), this, forceRoundedIcons, pref, tile, key, getActivity(), this, forceRoundedIcons, pref, tile, key,
mPlaceholderPreferenceController.getOrder()); mPlaceholderPreferenceController.getOrder());
if (Flags.dynamicInjectionCategory()) { if (Flags.dynamicInjectionCategory()) {
Preference group = screen.findPreference(tile.getGroupKey()); if (tile.hasGroupKey()) {
if (tile.hasGroupKey() && group instanceof PreferenceCategory) { Preference group = screen.findPreference(tile.getGroupKey());
((PreferenceCategory) group).addPreference(pref); if (group instanceof PreferenceCategory) {
((PreferenceCategory) group).addPreference(pref);
} else {
screen.addPreference(pref);
}
} else { } else {
screen.addPreference(pref); screen.addPreference(pref);
} }