Bug 1238763 - Part 1: Don't run onPromptFinished on the UI thread. r=liuche
--- a/mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java
+++ b/mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java
@@ -477,30 +477,35 @@ public class Prompt implements OnClickLi
addInputValues(ret);
notifyClosing(ret);
}
/* Called any time we're closing the dialog to cleanup and notify listeners that the dialog
* is closing.
*/
- private void notifyClosing(JSONObject aReturn) {
+ private void notifyClosing(final JSONObject aReturn) {
try {
aReturn.put("guid", mGuid);
} catch(JSONException ex) { }
if (mTabId != Tabs.INVALID_TAB_ID) {
Tabs.unregisterOnTabsChangedListener(this);
}
// poke the Gecko thread in case it's waiting for new events
GeckoAppShell.sendEventToGecko(GeckoEvent.createNoOpEvent());
if (mCallback != null) {
- mCallback.onPromptFinished(aReturn.toString());
+ ThreadUtils.postToBackgroundThread(new Runnable() {
+ @Override
+ public void run() {
+ mCallback.onPromptFinished(aReturn.toString());
+ }
+ });
}
}
// Called when the prompt inputs on the dialog change
@Override
public void onChange(PromptInput input) {
// If there are no buttons on this dialog, assuming that "changing" an input
// means something was selected and we can close. This provides a way to tap