Debug settings changes

 Bug: 3250498
 Makes OpenGL rendering and user agent normally visible in settings->debug
 Changing the OpenGL setting now automatically restarts the browser

Change-Id: I04036b580f2463f77376edb4bee2dfefe3d123ed
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index a8c393a..1c15153 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -39,6 +39,9 @@
 
 public class BrowserActivity extends Activity {
 
+    public static final String ACTION_RESTART = "--restart--";
+    private static final String EXTRA_STATE = "state";
+
     private final static String LOGTAG = "browser";
 
     private final static boolean LOGV_ENABLED =
@@ -94,6 +97,10 @@
         mController.setUi(mUi);
         mController.setWebViewFactory((BaseUi) mUi);
 
+        Bundle state = getIntent().getBundleExtra(EXTRA_STATE);
+        if (state != null && icicle == null) {
+            icicle = state;
+        }
         mController.start(icicle, getIntent());
     }
 
@@ -104,6 +111,16 @@
 
     @Override
     protected void onNewIntent(Intent intent) {
+        if (ACTION_RESTART.equals(intent.getAction())) {
+            Bundle outState = new Bundle();
+            mController.onSaveInstanceState(outState);
+            finish();
+            getApplicationContext().startActivity(
+                    new Intent(getApplicationContext(), BrowserActivity.class)
+                    .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+                    .putExtra(EXTRA_STATE, outState));
+            return;
+        }
         mController.handleNewIntent(intent);
     }