зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1437382 - Part 2 - Allow triggering application-background earlier when possible. r=jchen
If onActivitySaveInstanceState is called, this normally happens just before onActivityStopped, which means we can attempt to use the same logic currently used for onActivityStopped to determine whether the whole app is going into the background or we're doing just an internal activity switch. This allows us to trigger our Gecko onPause/"application-background" handling *before* e.g. GeckoApp's onSaveInstanceState handling, meaning we still have time to update the private browsing data held in GeckoApp before it is passed off to the OS. MozReview-Commit-ID: 5TZ6uX0gyz1 --HG-- extra : rebase_source : eb5f636ab4df0dae6e60ebf4d03ff4f88f00e2f5
This commit is contained in:
Родитель
63dd3963e9
Коммит
9e0024ee26
|
@ -32,6 +32,17 @@ public class GeckoActivityMonitor implements Application.ActivityLifecycleCallba
|
|||
currentActivity = new WeakReference<>(activity);
|
||||
}
|
||||
|
||||
private void checkAppGoingIntoBackground(final Activity activity) {
|
||||
// For the previous activity, this is called after onStart/onResume for the
|
||||
// new/resumed activity, so if we're switching activities within our app,
|
||||
// currentActivity should already refer to the next activity at this point.
|
||||
// If it doesn't, it means we've been backgrounded.
|
||||
if (currentActivity.get() == activity) {
|
||||
currentActivity.clear();
|
||||
((GeckoApplication) activity.getApplication()).onApplicationBackground();
|
||||
}
|
||||
}
|
||||
|
||||
public Activity getCurrentActivity() {
|
||||
return currentActivity.get();
|
||||
}
|
||||
|
@ -57,20 +68,14 @@ public class GeckoActivityMonitor implements Application.ActivityLifecycleCallba
|
|||
public void onActivityPaused(Activity activity) { }
|
||||
|
||||
@Override
|
||||
public void onActivityStopped(Activity activity) {
|
||||
// onStop for the previous activity is called after onStart/onResume for
|
||||
// the new/resumed activity, so if we're switching activities within our
|
||||
// app, currentActivity should already refer to the next activity at
|
||||
// this point.
|
||||
// If it doesn't, it means we've been backgrounded.
|
||||
if (currentActivity.get() == activity) {
|
||||
currentActivity.clear();
|
||||
((GeckoApplication) activity.getApplication()).onApplicationBackground();
|
||||
}
|
||||
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
|
||||
checkAppGoingIntoBackground(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivitySaveInstanceState(Activity activity, Bundle outState) { }
|
||||
public void onActivityStopped(Activity activity) {
|
||||
checkAppGoingIntoBackground(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed(Activity activity) { }
|
||||
|
|
Загрузка…
Ссылка в новой задаче