Fix NPE in SettingsMainSwitchPreference.

- Check if the RestrictedPreferenceHelper is null to avoid NPE.

Fix: 190135868
Test: run robotest and manually test that page.
Change-Id: I746099260d8f53dc30513ccbb30aec5cbe3657e7
This commit is contained in:
Stanley Wang
2021-06-04 16:15:04 +08:00
parent 367fe0eae0
commit 481b3abe0d

View File

@@ -84,7 +84,9 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements
mMainSwitchBar = (SettingsMainSwitchBar) holder.findViewById(R.id.main_switch_bar); mMainSwitchBar = (SettingsMainSwitchBar) holder.findViewById(R.id.main_switch_bar);
mMainSwitchBar.show(); mMainSwitchBar.show();
mEnforcedAdmin = mRestrictedHelper.checkRestrictionEnforced(); if (mRestrictedHelper != null) {
mEnforcedAdmin = mRestrictedHelper.checkRestrictionEnforced();
}
updateStatus(isChecked()); updateStatus(isChecked());
registerListenerToSwitchBar(); registerListenerToSwitchBar();