diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-05-19 23:01:09 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-05-19 23:01:09 +0000 |
commit | 46eb13d53b7bf0dc4769a088b645b8366c3cbfd1 (patch) | |
tree | ca2256cbf91038532db13ef547b3f63cc0336d56 | |
parent | cc792b5142af3a210477465d93fbd5d02f52b382 (diff) | |
parent | 40902b3cb040eb9ed35c174e41bca9feefe41b73 (diff) | |
download | android_packages_apps_Trebuchet-46eb13d53b7bf0dc4769a088b645b8366c3cbfd1.tar.gz android_packages_apps_Trebuchet-46eb13d53b7bf0dc4769a088b645b8366c3cbfd1.tar.bz2 android_packages_apps_Trebuchet-46eb13d53b7bf0dc4769a088b645b8366c3cbfd1.zip |
Merge "Preventing unnecessary options update to QSB provider by checking if the options have changed before calling update" into ub-launcher3-calgary
am: 40902b3cb0
* commit '40902b3cb040eb9ed35c174e41bca9feefe41b73':
Preventing unnecessary options update to QSB provider by checking if the options have changed before calling update
Change-Id: Iccda4c7921683cd7124a629ebd19c5fc33081f74
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 7 | ||||
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 20 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 88e1532d3..f487b12f6 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -3552,7 +3552,12 @@ public class Launcher extends Activity if (widgetId != -1) { mQsb = mAppWidgetHost.createView(this, widgetId, searchProvider); mQsb.setId(R.id.qsb_widget); - mQsb.updateAppWidgetOptions(opts); + if (!Utilities.containsAll( + AppWidgetManager.getInstance(this).getAppWidgetOptions(widgetId), opts)) { + // Launcher should not be updating the options often. + FileLog.d(TAG, "Options for QSB were not same"); + mQsb.updateAppWidgetOptions(opts); + } mQsb.setPadding(0, 0, 0, 0); mSearchDropTargetBar.addView(mQsb); mSearchDropTargetBar.setQsbSearchBar(mQsb); diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index e3b959b39..00ee387b3 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -869,6 +869,26 @@ public final class Utilities { } /** + * Returns true if {@param original} contains all entries defined in {@param updates} and + * have the same value. + * The comparison uses {@link Object#equals(Object)} to compare the values. + */ + public static boolean containsAll(Bundle original, Bundle updates) { + for (String key : updates.keySet()) { + Object value1 = updates.get(key); + Object value2 = original.get(key); + if (value1 == null) { + if (value2 != null) { + return false; + } + } else if (!value1.equals(value2)) { + return false; + } + } + return true; + } + + /** * An extension of {@link BitmapDrawable} which returns the bitmap pixel size as intrinsic size. * This allows the badging to be done based on the action bitmap size rather than * the scaled bitmap size. |