--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -1158,46 +1158,55 @@ public class BrowserApp extends GeckoApp
for (BrowserAppDelegate delegate : delegates) {
delegate.onResume(this);
}
}
@Override
protected void restoreLastSelectedTab() {
+ Log.d(LOGTAG, "GeckoTabs, restore selected, mIsRestoringActivity: " + mIsRestoringActivity +
+ " mResumingAfterOnCreate: " + mResumingAfterOnCreate);
if (mResumingAfterOnCreate && !mIsRestoringActivity) {
// We're the first activity to run, so our startup code will (have) handle(d) tab selection.
return;
}
+ Log.d(LOGTAG, "GeckoTabs, restore selected, mLastSelectedTabId: " + mLastSelectedTabId);
if (mLastSelectedTabId < 0) {
// Normally, session restore will select the correct tab when starting up, however this
// is linked to Gecko powering up. If we're not the first activity to launch, the
// previously running activity might have already overwritten this by selecting a tab of
// its own.
// Therefore we check whether the session file parser has left a note for us with the
// correct tab to be initially selected on *BrowserApp* startup.
SharedPreferences prefs = getSharedPreferencesForProfile();
mLastSelectedTabId = prefs.getInt(STARTUP_SELECTED_TAB, INVALID_TAB_ID);
mLastSessionUUID = prefs.getString(STARTUP_SESSION_UUID, null);
+ Log.d(LOGTAG, "GeckoTabs, read from prefs, mLastSelectedTabId: " + mLastSelectedTabId +
+ " mLastSessionUUID: " + (mLastSessionUUID != null ? mLastSessionUUID.toString() : "<none>"));
SharedPreferences.Editor editor = prefs.edit();
editor.remove(STARTUP_SELECTED_TAB);
editor.remove(STARTUP_SESSION_UUID);
editor.apply();
}
final Tabs tabs = Tabs.getInstance();
final Tab tabToSelect = tabs.getTab(mLastSelectedTabId);
+ Log.d(LOGTAG, "GeckoTabs, found tab: " + (tabToSelect != null ? tabToSelect.getId() : "<none>"));
if (tabToSelect != null && GeckoApplication.getSessionUUID().equals(mLastSessionUUID) &&
tabToSelect.getType() == TabType.BROWSING) {
+ Log.d(LOGTAG, "GeckoTabs, selecting found tab");
tabs.selectTab(mLastSelectedTabId);
} else {
+ Log.d(LOGTAG, "GeckoTabs, selecting fallback");
if (!tabs.selectLastTab(TabType.BROWSING)) {
+ Log.d(LOGTAG, "GeckoTabs, opening fallback");
tabs.loadUrl(Tabs.getHomepageForStartupTab(this), Tabs.LOADURL_NEW_TAB);
}
}
}
@Override
public void onPause() {
super.onPause();
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -1302,23 +1302,25 @@ public abstract class GeckoApp
mResumingAfterOnCreate = true;
if (sAlreadyLoaded) {
// This happens when the GeckoApp activity is destroyed by Android
// without killing the entire application (see Bug 769269).
// Now that we've got multiple GeckoApp-based activities, this can
// also happen if we're not the first activity to run within a session.
mIsRestoringActivity = true;
+ Log.d("LOGTAG", "GeckoTabs onCreate, this = " + getClass().getName() + ", setting mIsRestoringActivity = true");
Telemetry.addToHistogram("FENNEC_RESTORING_ACTIVITY", 1);
} else {
final String action = intent.getAction();
final String args = intent.getStringExtra("args");
sAlreadyLoaded = true;
+ Log.d("LOGTAG", "GeckoTabs onCreate, this = " + getClass().getName() + ", setting sAlreadyLoaded = true");
GeckoThread.initMainProcess(/* profile */ null, args,
/* debugging */ ACTION_DEBUG.equals(action));
// Speculatively pre-fetch the profile in the background.
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
public void run() {
getProfile();
@@ -2399,16 +2401,19 @@ public abstract class GeckoApp
return;
}
foregrounded = true;
GeckoAppShell.setGeckoInterface(this);
GeckoAppShell.setScreenOrientationDelegate(this);
+ Log.d(LOGTAG, "GeckoTabs resuming, this = " + getClass().getName() +
+ ", last active = " + (mLastActiveGeckoApp != null ? mLastActiveGeckoApp.get().getClass().getName() :
+ "none" + ", check on resume = " + mCheckTabSelectionOnResume));
if (mLastActiveGeckoApp == null || mLastActiveGeckoApp.get() != this ||
mCheckTabSelectionOnResume) {
mCheckTabSelectionOnResume = false;
restoreLastSelectedTab();
}
int newOrientation = getResources().getConfiguration().orientation;
if (GeckoScreenOrientation.getInstance().update(newOrientation)) {