Commit 82ccb5f1 authored by twellington's avatar twellington Committed by Commit bot

Only allow one instance of Preferences to show at a time in Android N+ multi-window

BUG=603343, 651317

Review-Url: https://codereview.chromium.org/2386753002
Cr-Commit-Position: refs/heads/master@{#422546}
parent 1ba5bcd1
......@@ -157,13 +157,14 @@ public class Preferences extends AppCompatActivity implements
// Prevent the user from interacting with multiple instances of Preferences at the same time
// (e.g. in multi-instance mode on a Samsung device), which would cause many fun bugs.
if (sResumedInstance != null && !mIsNewlyCreated) {
if (sResumedInstance != null && sResumedInstance != this && !mIsNewlyCreated) {
// This activity was unpaused or recreated while another instance of Preferences was
// already showing. The existing instance takes precedence.
finish();
} else {
// This activity was newly created and takes precedence over sResumedInstance.
if (sResumedInstance != null) sResumedInstance.finish();
if (sResumedInstance != null && sResumedInstance != this) sResumedInstance.finish();
sResumedInstance = this;
mIsNewlyCreated = false;
}
......@@ -172,10 +173,15 @@ public class Preferences extends AppCompatActivity implements
@Override
protected void onPause() {
super.onPause();
if (sResumedInstance == this) sResumedInstance = null;
ChromeApplication.flushPersistentData();
}
@Override
protected void onStop() {
super.onStop();
if (sResumedInstance == this) sResumedInstance = null;
}
/**
* Returns the fragment showing as this activity's main content, typically a PreferenceFragment.
* This does not include DialogFragments or other Fragments shown on top of the main content.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment