Merge "Handle SubSettings instance leaks in Index.java" am: 527b2b220a am: bf4a67ec0f
am: 28688c3ba3

Change-Id: I31cd7f083c529342ac2b07f054d82b4a9191937b
diff --git a/src/com/android/settings/search/Index.java b/src/com/android/settings/search/Index.java
index ccedd62..084f9c3 100644
--- a/src/com/android/settings/search/Index.java
+++ b/src/com/android/settings/search/Index.java
@@ -217,20 +217,20 @@
      */
     public static Index getInstance(Context context) {
         if (sInstance == null) {
-            sInstance = new Index(context.getApplicationContext(), BASE_AUTHORITY);
+            synchronized (Index.class) {
+                if (sInstance == null) {
+                    sInstance = new Index(context.getApplicationContext(), BASE_AUTHORITY);
+                }
+            }
         }
         return sInstance;
     }
 
-    public Index(Context context, String baseAuthority) {
+    private Index(Context context, String baseAuthority) {
         mContext = context;
         mBaseAuthority = baseAuthority;
     }
 
-    public void setContext(Context context) {
-        mContext = context;
-    }
-
     public boolean isAvailable() {
         return mIsAvailable.get();
     }