OSDN Git Service

Precreate a data structure so it's never null.
authorRobert Greenwalt <rgreenwalt@google.com>
Thu, 27 Sep 2012 18:21:12 +0000 (11:21 -0700)
committerRobert Greenwalt <rgreenwalt@google.com>
Thu, 27 Sep 2012 18:21:12 +0000 (11:21 -0700)
Fixes NPE that the fast-fingered monkey sometimes triggers.
bug:7084178

Change-Id: Ibeb5e1ce678f59207de5dd321e06ae88ccc52216

src/com/android/settings/vpn2/VpnSettings.java

index de7c034..9d15435 100644 (file)
@@ -73,7 +73,7 @@ public class VpnSettings extends SettingsPreferenceFragment implements
     private final KeyStore mKeyStore = KeyStore.getInstance();
     private boolean mUnlocking = false;
 
-    private HashMap<String, VpnPreference> mPreferences;
+    private HashMap<String, VpnPreference> mPreferences = new HashMap<String, VpnPreference>();
     private VpnDialog mDialog;
 
     private Handler mUpdater;
@@ -173,8 +173,7 @@ public class VpnSettings extends SettingsPreferenceFragment implements
         // Currently we are the only user of profiles in KeyStore.
         // Assuming KeyStore and KeyGuard do the right thing, we can
         // safely cache profiles in the memory.
-        if (mPreferences == null) {
-            mPreferences = new HashMap<String, VpnPreference>();
+        if (mPreferences.size() == 0) {
             PreferenceGroup group = getPreferenceScreen();
 
             final Context context = getActivity();