Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[Merge M49] android: Fix select popup dialog Context edge case
Browse files Browse the repository at this point in the history
There is no way to tell ahead of time whether a Context can be used to
display a pop up window, due to hacks some apps uses. Instead, catch the
BadTokenException and respond correctly to that.

BUG=573294

Review URL: https://codereview.chromium.org/1616473002

Cr-Commit-Position: refs/heads/master@{#370567}
(cherry picked from commit 132bb92)

Review URL: https://codereview.chromium.org/1619833002 .

Cr-Commit-Position: refs/branch-heads/2623@{#45}
Cr-Branched-From: 92d7753-refs/heads/master@{#369907}
  • Loading branch information
Bo Liu committed Jan 21, 2016
1 parent 1f83af1 commit a66afe5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2449,7 +2449,7 @@ private void showSelectPopup(long nativeSelectPopupSourceFrame, Rect bounds, Str
} else {
if (getWindowAndroid() == null) return;
Context windowContext = getWindowAndroid().getContext().get();
if (WindowAndroid.activityFromContext(windowContext) == null) return;
if (windowContext == null) return;
mSelectPopup = new SelectPopupDialog(
this, windowContext, popupItems, multiple, selectedIndices);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.content.res.TypedArray;
import android.util.SparseBooleanArray;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
Expand Down Expand Up @@ -128,7 +129,11 @@ private void notifySelection(int[] indicies) {

@Override
public void show() {
mListBoxPopup.show();
try {
mListBoxPopup.show();
} catch (WindowManager.BadTokenException e) {
notifySelection(null);
}
}

@Override
Expand Down

0 comments on commit a66afe5

Please sign in to comment.