Fix NPE in accountPrefController

Change-Id: I83dba35604c501780fa9a99d122b9d9bc8068661
Fix: 34193417
Test: RunSettingsRoboTests
This commit is contained in:
Fan Zhang
2017-01-10 11:50:01 -08:00
parent 6fbdb5df55
commit 424443bdb2
2 changed files with 25 additions and 1 deletions

View File

@@ -311,7 +311,10 @@ public class AccountPreferenceController extends PreferenceController
preferenceGroup.setContentDescription(
mContext.getString(R.string.accessibility_category_personal));
}
mParent.getPreferenceScreen().addPreference(preferenceGroup);
final PreferenceScreen screen = mParent.getPreferenceScreen();
if (screen != null) {
screen.addPreference(preferenceGroup);
}
profileData.preferenceGroup = preferenceGroup;
if (userInfo.isEnabled()) {
profileData.authenticatorHelper = new AuthenticatorHelper(context,
@@ -367,6 +370,9 @@ public class AccountPreferenceController extends PreferenceController
void cleanUpPreferences() {
PreferenceScreen screen = mParent.getPreferenceScreen();
if (screen == null) {
return;
}
for (int i = 0; i < mProfiles.size(); i++) {
final PreferenceGroup preferenceGroup = mProfiles.valueAt(i).preferenceGroup;
screen.removePreference(preferenceGroup);