OSDN Git Service

Avoid potential NPE if storage manager is not properly initialized.
authorShimeng (Simon) Wang <swang@google.com>
Tue, 9 Mar 2010 22:30:07 +0000 (14:30 -0800)
committerShimeng (Simon) Wang <swang@google.com>
Wed, 10 Mar 2010 22:38:51 +0000 (14:38 -0800)
Bug: 2498939
Change-Id: I92a14fdcb949d748bebec0a357d8baad37aeb46e

src/com/android/browser/Browser.java
src/com/android/browser/BrowserActivity.java
src/com/android/browser/BrowserSettings.java

index 524f789..7822ec8 100644 (file)
@@ -57,6 +57,7 @@ public class Browser extends Application {
         CookieSyncManager.createInstance(this);
         // remove all expired cookies
         CookieManager.getInstance().removeExpiredCookie();
+        BrowserSettings.getInstance().loadFromDb(this);
     }
 
     static Intent createBrowserViewIntent() {
index 1903713..2f4f39a 100644 (file)
@@ -301,7 +301,6 @@ public class BrowserActivity extends Activity
         // Keep a settings instance handy.
         mSettings = BrowserSettings.getInstance();
         mSettings.setTabControl(mTabControl);
-        mSettings.loadFromDb(this);
 
         PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
         mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Browser");
index 81f1d72..2cbfa29 100644 (file)
@@ -223,9 +223,7 @@ class BrowserSettings extends Observable {
             s.setDatabasePath(b.databasePath);
             s.setGeolocationDatabasePath(b.geolocationDatabasePath);
 
-            // Enable/Disable the error console.
-            b.mTabControl.getBrowserActivity().setShouldShowErrorConsole(
-                    b.showDebugSettings && b.showConsole);
+            b.updateTabControlSettings();
         }
     }
 
@@ -310,9 +308,6 @@ class BrowserSettings extends Observable {
                 p.getBoolean("landscape_only", landscapeOnly);
         if (landscapeOnlyTemp != landscapeOnly) {
             landscapeOnly = landscapeOnlyTemp;
-            mTabControl.getBrowserActivity().setRequestedOrientation(
-                    landscapeOnly ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
-                    : ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
         }
         useWideViewPort = true; // use wide view port for either setting
         if (autoFitPage) {
@@ -359,8 +354,6 @@ class BrowserSettings extends Observable {
         // regardless of the setting we read here. This setting is only used after debug
         // is enabled.
         showConsole = p.getBoolean("javascript_console", showConsole);
-        mTabControl.getBrowserActivity().setShouldShowErrorConsole(
-                showDebugSettings && showConsole);
 
         // HTML5 API flags
         appCacheEnabled = p.getBoolean("enable_appcache", appCacheEnabled);
@@ -488,6 +481,7 @@ class BrowserSettings extends Observable {
      */
     /* package */void setTabControl(TabControl tabControl) {
         mTabControl = tabControl;
+        updateTabControlSettings();
     }
 
     /*
@@ -531,6 +525,15 @@ class BrowserSettings extends Observable {
         db.clearHttpAuthUsernamePassword();
     }
 
+    private void updateTabControlSettings() {
+        // Enable/disable the error console.
+        mTabControl.getBrowserActivity().setShouldShowErrorConsole(
+            showDebugSettings && showConsole);
+        mTabControl.getBrowserActivity().setRequestedOrientation(
+            landscapeOnly ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
+            : ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+    }
+
     private void maybeDisableWebsiteSettings(Context context) {
         PreferenceActivity activity = (PreferenceActivity) context;
         final PreferenceScreen screen = (PreferenceScreen)