Bug 989294 - Release index when app is uninstalled. r=mfinkle, a=sledru
authorMyk Melez <myk@mozilla.org>
Mon, 14 Apr 2014 10:23:12 -0400
changeset 183743 7872e02410a7012d625de794a319591540a1a38e
parent 183742 1be8ef9bf661db27b69e68ccbd9a66934c65c1d0
child 183744 13a97e892449319962dda00edfbf528e2ef01e5a
push id3467
push userryanvm@gmail.com
push dateMon, 14 Apr 2014 14:29:30 +0000
treeherdermozilla-beta@756b592c869f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, sledru
bugs989294
milestone29.0
Bug 989294 - Release index when app is uninstalled. r=mfinkle, a=sledru
mobile/android/base/webapp/UninstallListener.java
--- a/mobile/android/base/webapp/UninstallListener.java
+++ b/mobile/android/base/webapp/UninstallListener.java
@@ -47,18 +47,24 @@ public class UninstallListener extends B
             Log.i(LOGTAG, "No package name defined in intent");
             return;
         }
 
         Allocator allocator = Allocator.getInstance(context);
         ArrayList<String> installedPackages = allocator.getInstalledPackageNames();
 
         if (installedPackages.contains(packageName)) {
+            int index = allocator.getIndexForApp(packageName);
+            if (index != -1) {
+                allocator.releaseIndex(index);
+            }
+
             JSONObject message = new JSONObject();
             JSONArray packageNames = new JSONArray();
+
             try {
                 packageNames.put(packageName);
                 message.put("apkPackageNames", packageNames);
                 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Webapps:AutoUninstall", message.toString()));
             } catch (JSONException e) {
                 Log.e(LOGTAG, "JSON EXCEPTION " + e);
             }
         }
@@ -82,16 +88,23 @@ public class UninstallListener extends B
 
         for (String packageName : fennecPackages) {
             if (!allInstalledPackages.contains(packageName)) {
                 uninstalledPackages.add(packageName);
             }
         }
 
         if (uninstalledPackages.size() > 0) {
+            for (String packageName : uninstalledPackages) {
+                int index = allocator.getIndexForApp(packageName);
+                if (index != -1) {
+                    allocator.releaseIndex(index);
+                }
+            }
+
             JSONObject message = new JSONObject();
             JSONArray packageNames = new JSONArray();
             try {
                 for (String packageName : uninstalledPackages) {
                     packageNames.put(packageName);
                 }
                 message.put("apkPackageNames", packageNames);
                 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Webapps:AutoUninstall", message.toString()));