OSDN Git Service

Temp fix for NPE when race condition happens in TrustedCredentialsSettings
authorVictor Chang <vichang@google.com>
Tue, 17 May 2016 15:50:08 +0000 (16:50 +0100)
committerVictor Chang <vichang@google.com>
Fri, 20 May 2016 17:19:29 +0000 (17:19 +0000)
Bug: 28762124
Change-Id: I21e46c2008e106db1c43573171e0d852cbe0a68a

src/com/android/settings/TrustedCredentialsSettings.java

index c630ed6..4100e75 100644 (file)
@@ -695,16 +695,18 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
                     for (int i = 0; i < n; ++i) {
                         UserHandle profile = profiles.get(i);
                         int profileId = profile.getIdentifier();
-                        if (shouldSkipProfile(profile)) {
-                            certHoldersByProfile.put(profileId, new ArrayList<CertHolder>(0));
-                            continue;
-                        }
                         List<ParcelableString> aliases = aliasesByProfileId.get(profileId);
                         if (isCancelled()) {
                             return new SparseArray<List<CertHolder>>();
                         }
-                        IKeyChainService service = mKeyChainConnectionByProfileId.get(profileId)
-                                .getService();
+                        KeyChainConnection keyChainConnection = mKeyChainConnectionByProfileId.get(
+                                profileId);
+                        if (shouldSkipProfile(profile) || aliases == null
+                                || keyChainConnection == null) {
+                            certHoldersByProfile.put(profileId, new ArrayList<CertHolder>(0));
+                            continue;
+                        }
+                        IKeyChainService service = keyChainConnection.getService();
                         List<CertHolder> certHolders = new ArrayList<CertHolder>(max);
                         final int aliasMax = aliases.size();
                         for (int j = 0; j < aliasMax; ++j) {