Bug 1551614 - Call BrowserApp's onCreate() before finish(); r=VladBaicu

Fix for the following scenario:
- "Don't keep activities" checked
- Change system language

Upon detecting a locale change in BrowserApp's onCreate() we would call
finish() and then return before calling super.onCreate().

This patch introdues the call to super.onCreate() before returning and ensures
that the app will die cleanly so that upon restarting Gecko can reinit add-ons
that touch the UI.

Differential Revision: https://phabricator.services.mozilla.com/D35402

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Petru Lingurar 2019-06-21 06:24:43 +00:00
Родитель 90ecafd3e1
Коммит 94080c4b79
2 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -1022,7 +1022,13 @@ public abstract class GeckoApp extends GeckoActivity
// no need to touch that here.
if (BrowserLocaleManager.getInstance().systemLocaleDidChange()) {
Log.i(LOGTAG, "System locale changed. Restarting.");
mIsAbortingAppLaunch = true;
// Call finish() asap so that other classes would know BrowserApp isFinishing()
finishAndShutdown(/* restart */ true);
super.onCreate(savedInstanceState);
return;
}
@ -2119,6 +2125,12 @@ public abstract class GeckoApp extends GeckoActivity
// This build does not support the Android version of the device:
// We did not initialize anything, so skip cleaning up.
super.onDestroy();
if (mShutdownOnDestroy) {
GeckoApplication.shutdown(!mRestartOnShutdown ? null : new Intent(
Intent.ACTION_MAIN, /* uri */ null, getApplicationContext(), getClass()));
}
return;
}

Просмотреть файл

@ -14,6 +14,7 @@ import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.support.annotation.UiThread;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.Loader;
import android.support.v4.widget.SwipeRefreshLayout;
@ -112,6 +113,15 @@ public class CombinedHistoryPanel extends HomeFragment implements RemoteClientsD
public void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
// BrowserApp's super.onCreate() as a FragmentActivity would dispatchCreate()
// for all fragments in it's savedInstanceState. This Fragment will be created.
// When BrowserApp does not complete it's onCreate() - like when finishing early and restarting
// our onCreate would try to access not yet initialized resources and would get a NPE.
final FragmentActivity parent = getActivity();
if (parent != null && parent.isFinishing()) {
return;
}
int cachedRecentTabsCount = 0;
if (mPanelStateChangeListener != null ) {
cachedRecentTabsCount = mPanelStateChangeListener.getCachedRecentTabsCount();