WindowDecorActionBar name change fix.

In change id I7582e242c7564c32feeb044fc9eff6bfb5c56536,
WindowDecorActionBar's package name was changed. This breaks layoutlib.
Fix the issue by checking both package names when loading the class.

Change-Id: I5723a97f0f164d61c56061fef6cff18e3cdafaee
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/AppCompatActionBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/AppCompatActionBar.java
index 868c6d3..b67afeb 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/AppCompatActionBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/AppCompatActionBar.java
@@ -16,10 +16,13 @@
 
 package com.android.layoutlib.bridge.bars;
 
+import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.LayoutlibCallback;
 import com.android.ide.common.rendering.api.RenderResources;
 import com.android.ide.common.rendering.api.ResourceValue;
 import com.android.ide.common.rendering.api.SessionParams;
 import com.android.ide.common.rendering.api.StyleResourceValue;
+import com.android.layoutlib.bridge.Bridge;
 import com.android.layoutlib.bridge.android.BridgeContext;
 import com.android.layoutlib.bridge.impl.ResourceHelper;
 import com.android.resources.ResourceType;
@@ -45,6 +48,8 @@
 
     private Object mWindowDecorActionBar;
     private static final String WINDOW_ACTION_BAR_CLASS = "android.support.v7.internal.app.WindowDecorActionBar";
+    // This is used on v23.1.1 and later.
+    private static final String WINDOW_ACTION_BAR_CLASS_NEW = "android.support.v7.app.WindowDecorActionBar";
     private Class<?> mWindowActionBarClass;
 
     /**
@@ -70,14 +75,26 @@
         try {
             Class[] constructorParams = {View.class};
             Object[] constructorArgs = {getDecorContent()};
-            mWindowDecorActionBar = params.getLayoutlibCallback().loadView(WINDOW_ACTION_BAR_CLASS,
-                    constructorParams, constructorArgs);
+            LayoutlibCallback callback = params.getLayoutlibCallback();
+            // First try to load the class as was available before appcompat v23.1.1, without
+            // logging warnings.
+            try {
+                mWindowDecorActionBar = callback.loadClass(WINDOW_ACTION_BAR_CLASS,
+                        constructorParams, constructorArgs);
+            } catch (ClassNotFoundException ignore) {
+            }
+            if (mWindowDecorActionBar == null) {
+                // If failed, load the new class, while logging warnings.
+                mWindowDecorActionBar = callback.loadView(WINDOW_ACTION_BAR_CLASS_NEW,
+                        constructorParams, constructorArgs);
+            }
 
             mWindowActionBarClass = mWindowDecorActionBar == null ? null :
                     mWindowDecorActionBar.getClass();
             setupActionBar();
         } catch (Exception e) {
-            e.printStackTrace();
+            Bridge.getLog().warning(LayoutLog.TAG_BROKEN,
+                    "Failed to load AppCompat ActionBar with unknown error.", e);
         }
     }