Fix two crashes

- NPE: bug #4984219
- IllegalStateException: bug #4969695

Change-Id: Iaf02e669b26f9277388e0e7bffd532220ebf9bb1
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index ed408df..d3215f0 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -207,7 +207,10 @@
     /* LauncherTransitionable overrides */
     @Override
     public void onLauncherTransitionStart(Animator animation) {
-        if (animation != null) {
+        // isHardwareAccelerated() checks if we're attached to a window and if that
+        // window is HW accelerated-- we were sometimes not attached to a window
+        // and buildLayer was throwing an IllegalStateException
+        if (animation != null && isHardwareAccelerated()) {
             // Turn on hardware layers for performance
             setLayerType(LAYER_TYPE_HARDWARE, null);