From 95c1583b461be3b0174da0c4930d495b88aa5197 Mon Sep 17 00:00:00 2001 From: Wes Johnston Date: Tue, 4 Feb 2014 07:49:30 -0800 Subject: [PATCH] Bug 967254 - Move uninstalled apps check to delayed startup. r=rnewman --- mobile/android/base/GeckoApp.java | 9 ++++----- .../base/webapp/UninstallListener.java | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index b9a4683c0604..02516a42c343 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -572,6 +572,8 @@ public abstract class GeckoApp } else if (event.equals("Reader:FaviconRequest")) { final String url = message.getString("url"); handleFaviconRequest(url); + } else if (event.equals("Gecko:DelayedStartup")) { + ThreadUtils.postToBackgroundThread(new UninstallListener.DelayedStartupTask(this)); } else if (event.equals("Gecko:Ready")) { mGeckoReadyStartupTimer.stop(); geckoConnected(); @@ -1325,11 +1327,6 @@ public abstract class GeckoApp GeckoApp.this.onLocaleReady(uiLocale); } }); - - // Perform webapp uninstalls as appropiate. - if (AppConstants.MOZ_ANDROID_SYNTHAPKS) { - UninstallListener.initUninstallPackageScan(getApplicationContext()); - } } }); @@ -1534,6 +1531,7 @@ public abstract class GeckoApp registerEventListener("Menu:Remove"); registerEventListener("Menu:Update"); registerEventListener("Gecko:Ready"); + registerEventListener("Gecko:DelayedStartup"); registerEventListener("Toast:Show"); registerEventListener("DOMFullScreen:Start"); registerEventListener("DOMFullScreen:Stop"); @@ -2063,6 +2061,7 @@ public abstract class GeckoApp unregisterEventListener("Menu:Remove"); unregisterEventListener("Menu:Update"); unregisterEventListener("Gecko:Ready"); + unregisterEventListener("Gecko:DelayedStartup"); unregisterEventListener("Toast:Show"); unregisterEventListener("DOMFullScreen:Start"); unregisterEventListener("DOMFullScreen:Stop"); diff --git a/mobile/android/base/webapp/UninstallListener.java b/mobile/android/base/webapp/UninstallListener.java index ddfd1e8f4da0..a7981540cbb5 100644 --- a/mobile/android/base/webapp/UninstallListener.java +++ b/mobile/android/base/webapp/UninstallListener.java @@ -5,8 +5,11 @@ package org.mozilla.gecko.webapp; +import org.mozilla.gecko.AppConstants; +import org.mozilla.gecko.GeckoApp; import org.mozilla.gecko.GeckoAppShell; import org.mozilla.gecko.GeckoEvent; +import org.mozilla.gecko.util.ThreadUtils; import android.content.BroadcastReceiver; import android.content.Context; @@ -23,6 +26,7 @@ import android.content.pm.PackageManager; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.ArrayList; @@ -91,4 +95,20 @@ public class UninstallListener extends BroadcastReceiver { } } } + + public static class DelayedStartupTask implements Runnable { + private GeckoApp mApp; + + public DelayedStartupTask(GeckoApp app) { + mApp = app; + } + + @Override + public void run() { + // Perform webapp uninstalls as appropiate. + if (AppConstants.MOZ_ANDROID_SYNTHAPKS) { + UninstallListener.initUninstallPackageScan(mApp.getApplicationContext()); + } + } + } }