Startup optimization

 Bug: 5019676
 Save one thread by letting CrashRecoveryHandler re-use the BrowserSettings
 startup thread

 Lazy initialize the wake lock only if we need it (avoids IPC overhead at startup)

 Slight ordering shuffle in BrowserActivity to maximize the usefulness of the
 BrowserSettings startup thread

Change-Id: I1fc7412d492f93e0630008fa6030da9e0d726ebb
diff --git a/src/com/android/browser/CrashRecoveryHandler.java b/src/com/android/browser/CrashRecoveryHandler.java
index 8d7f243..6e40ffd 100644
--- a/src/com/android/browser/CrashRecoveryHandler.java
+++ b/src/com/android/browser/CrashRecoveryHandler.java
@@ -25,9 +25,8 @@
 import android.content.SharedPreferences;
 import android.os.Bundle;
 import android.os.Handler;
-import android.os.HandlerThread;
+import android.os.Looper;
 import android.os.Parcel;
-import android.os.Process;
 import android.util.Log;
 
 import java.io.ByteArrayOutputStream;
@@ -73,10 +72,8 @@
     private CrashRecoveryHandler(Controller controller) {
         mController = controller;
         mForegroundHandler = new Handler();
-        HandlerThread thread = new HandlerThread(LOGTAG,
-                Process.THREAD_PRIORITY_BACKGROUND);
-        thread.start();
-        mBackgroundHandler = new Handler(thread.getLooper());
+        Looper looper = BrowserSettings.getInstance().getBackgroundLooper();
+        mBackgroundHandler = new Handler(looper);
     }
 
     public void backupState() {