From dcc1e85a1b2def255253dcee81d0adcc062e740b Mon Sep 17 00:00:00 2001 From: cretin45 Date: Mon, 21 Dec 2015 10:10:47 -0800 Subject: Trebuchet: Prevent crashes on view id mess up Same fix as: https://github.com/CyanogenMod/android_packages_apps_Trebuchet/commit/33a152fa Issue-id: YAM-226 Change-Id: I558ef03b0299cefc3efd5e51f2ca6542836e66ff (cherry picked from commit d3d67745a76453ca4c259ef052b90b6edd588e4f) --- src/com/android/launcher3/Launcher.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 1dafd1245..d6704c81a 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2357,9 +2357,21 @@ public class Launcher extends Activity @Override public void onRestoreInstanceState(Bundle state) { - super.onRestoreInstanceState(state); - for (int page: mSynchronouslyBoundPages) { - mWorkspace.restoreInstanceStateForChild(page); + /* + * Prevent crashes on view id mess up + * See: https://github.com/CyanogenMod/android_packages_apps_Trebuchet/commit/33a152fa + */ + try { + super.onRestoreInstanceState(state); + for (int page: mSynchronouslyBoundPages) { + mWorkspace.restoreInstanceStateForChild(page); + } + } catch (IllegalArgumentException ex) { + if (LauncherAppState.isDogfoodBuild()) { + throw ex; + } + // Mismatched viewId / viewType preventing restore. Skip restore on production builds. + Log.e(TAG, "Ignoring an error while restoring a view instance state", ex); } } -- cgit v1.2.3