Merge "Fixing issue where package updates were not getting propagated properly" into ub-now-master
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatV16.java b/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
index f30c28b..de9f3a0 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
@@ -174,13 +174,18 @@
                     }
                 }
             } else if (Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(action)) {
-                final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
+                // EXTRA_REPLACING is available Kitkat onwards. For lower devices, it is broadcasted
+                // when moving a package or mounting/un-mounting external storage. Assume that
+                // it is a replacing operation.
+                final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING,
+                        Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT);
                 String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
                 for (OnAppsChangedCallbackCompat callback : getCallbacks()) {
                     callback.onPackagesAvailable(packages, user, replacing);
                 }
             } else if (Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) {
-                final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
+                final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING,
+                        Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT);
                 String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
                 for (OnAppsChangedCallbackCompat callback : getCallbacks()) {
                     callback.onPackagesUnavailable(packages, user, replacing);