Another attempt fix for account preference screen.

Fix: 34219500
Test: RunSettingsRoboTests

Change-Id: I316e36496fc9d7eca9c718275c0f113b181d7f1e
This commit is contained in:
Fan Zhang
2017-01-13 14:57:01 -08:00
parent ce6bf59a9a
commit c7804c130b
2 changed files with 4 additions and 2 deletions

View File

@@ -63,7 +63,6 @@ import java.util.List;
import static android.content.Intent.EXTRA_USER; import static android.content.Intent.EXTRA_USER;
import static android.os.UserManager.DISALLOW_MODIFY_ACCOUNTS; import static android.os.UserManager.DISALLOW_MODIFY_ACCOUNTS;
import static android.os.UserManager.DISALLOW_REMOVE_MANAGED_PROFILE; import static android.os.UserManager.DISALLOW_REMOVE_MANAGED_PROFILE;
import static android.os.UserManager.DISALLOW_REMOVE_USER;
import static android.provider.Settings.EXTRA_AUTHORITIES; import static android.provider.Settings.EXTRA_AUTHORITIES;
public class AccountPreferenceController extends PreferenceController public class AccountPreferenceController extends PreferenceController
@@ -405,7 +404,8 @@ public class AccountPreferenceController extends PreferenceController
} }
private void updateAccountTypes(ProfileData profileData) { private void updateAccountTypes(ProfileData profileData) {
if (mParent.getPreferenceManager() == null) { if (mParent.getPreferenceManager() == null
|| profileData.preferenceGroup.getPreferenceManager() == null) {
// This could happen if activity is finishing // This could happen if activity is finishing
return; return;
} }

View File

@@ -25,6 +25,7 @@ import android.os.UserManager;
import android.support.v14.preference.PreferenceFragment; import android.support.v14.preference.PreferenceFragment;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.preference.PreferenceScreen; import android.support.v7.preference.PreferenceScreen;
import com.android.settings.AccessiblePreferenceCategory; import com.android.settings.AccessiblePreferenceCategory;
@@ -324,6 +325,7 @@ public class AccountPreferenceControllerTest {
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt())).thenReturn(authDescs); when(mAccountManager.getAuthenticatorTypesAsUser(anyInt())).thenReturn(authDescs);
AccessiblePreferenceCategory preferenceGroup = mock(AccessiblePreferenceCategory.class); AccessiblePreferenceCategory preferenceGroup = mock(AccessiblePreferenceCategory.class);
when(preferenceGroup.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
when(mAccountHelper.createAccessiblePreferenceCategory(any(Context.class))).thenReturn( when(mAccountHelper.createAccessiblePreferenceCategory(any(Context.class))).thenReturn(
preferenceGroup); preferenceGroup);