diff --git a/mobile/android/app/mobile.js b/mobile/android/app/mobile.js index d7ab8aecfc1b..028e4a6a69a6 100644 --- a/mobile/android/app/mobile.js +++ b/mobile/android/app/mobile.js @@ -145,7 +145,7 @@ pref("browser.sessionhistory.max_entries", 50); /* session store */ pref("browser.sessionstore.resume_session_once", false); -pref("browser.sessionstore.resume_from_crash", true); +pref("browser.sessionstore.resume_from_crash", false); pref("browser.sessionstore.resume_from_crash_timeout", 60); // minutes pref("browser.sessionstore.interval", 10000); // milliseconds pref("browser.sessionstore.max_tabs_undo", 1); diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index 4436eec69fc1..e3e975939d6b 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -1677,9 +1677,10 @@ abstract public class GeckoApp if (uri != null && uri.length() > 0) passedUri = mLastTitle = uri; + mRestoreSession |= getProfile().shouldRestoreSession(); if (passedUri == null || passedUri.equals("about:home")) { // show about:home if we aren't restoring previous session - if (! getProfile().hasSession()) { + if (!mRestoreSession) { mBrowserToolbar.updateTabCount(1); showAboutHome(); } diff --git a/mobile/android/base/GeckoProfile.java b/mobile/android/base/GeckoProfile.java index 5e141d0d6888..f58a0de24d66 100644 --- a/mobile/android/base/GeckoProfile.java +++ b/mobile/android/base/GeckoProfile.java @@ -33,6 +33,9 @@ public final class GeckoProfile { private File mMozDir; private File mDir; + // this short timeout is a temporary fix until bug 735399 is implemented + private static final long SESSION_TIMEOUT = 30 * 1000; // 30 seconds + public static GeckoProfile get(Context context) { return get(context, null); } @@ -80,12 +83,19 @@ public final class GeckoProfile { return mDir; } - public boolean hasSession() { + public boolean shouldRestoreSession() { Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - start check sessionstore.js exists"); File dir = getDir(); - boolean hasSession = (dir != null && new File(dir, "sessionstore.js").exists()); + if (dir == null) + return false; + + File sessionFile = new File(dir, "sessionstore.js"); + if (!sessionFile.exists()) + return false; + + boolean shouldRestore = (System.currentTimeMillis() - sessionFile.lastModified() < SESSION_TIMEOUT); Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - finish check sessionstore.js exists"); - return hasSession; + return shouldRestore; } public String readSessionFile(boolean geckoReady) {