Merge "Add accessorytest Linux host tool for testing USB accessory audio and HID support." into lmp-dev
diff --git a/api/current.txt b/api/current.txt
index 851d20f..5f23a36 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -29262,12 +29262,12 @@
 
   public class MessagingConfigurationManager {
     method public boolean getCarrierConfigBoolean(java.lang.String, boolean);
+    method public boolean getCarrierConfigBoolean(long, java.lang.String, boolean);
     method public int getCarrierConfigInt(java.lang.String, int);
+    method public int getCarrierConfigInt(long, java.lang.String, int);
     method public java.lang.String getCarrierConfigString(java.lang.String, java.lang.String);
+    method public java.lang.String getCarrierConfigString(long, java.lang.String, java.lang.String);
     method public static android.telephony.MessagingConfigurationManager getDefault();
-    method public void setCarrierConfigBoolean(java.lang.String, boolean);
-    method public void setCarrierConfigInt(java.lang.String, int);
-    method public void setCarrierConfigString(java.lang.String, java.lang.String);
     field public static final java.lang.String CONF_ALIAS_ENABLED = "aliasEnabled";
     field public static final java.lang.String CONF_ALIAS_MAX_CHARS = "aliasMaxChars";
     field public static final java.lang.String CONF_ALIAS_MIN_CHARS = "aliasMinChars";
@@ -29446,19 +29446,19 @@
     method public boolean deleteStoredConversation(long);
     method public boolean deleteStoredMessage(android.net.Uri);
     method public java.util.ArrayList<java.lang.String> divideMessage(java.lang.String);
-    method public void downloadMultimediaMessage(java.lang.String, android.app.PendingIntent);
-    method public void downloadMultimediaMessage(long, java.lang.String, android.app.PendingIntent);
+    method public void downloadMultimediaMessage(java.lang.String, android.content.ContentValues, android.app.PendingIntent);
+    method public void downloadMultimediaMessage(long, java.lang.String, android.content.ContentValues, android.app.PendingIntent);
     method public boolean getAutoPersisting();
     method public static android.telephony.SmsManager getDefault();
     method public android.net.Uri importMultimediaMessage(byte[], java.lang.String, long, boolean, boolean);
     method public android.net.Uri importTextMessage(java.lang.String, int, java.lang.String, long, boolean, boolean);
     method public void injectSmsPdu(byte[], java.lang.String, android.app.PendingIntent);
     method public void sendDataMessage(java.lang.String, java.lang.String, short, byte[], android.app.PendingIntent, android.app.PendingIntent);
-    method public void sendMultimediaMessage(byte[], java.lang.String, android.app.PendingIntent);
-    method public void sendMultimediaMessage(long, byte[], java.lang.String, android.app.PendingIntent);
+    method public void sendMultimediaMessage(byte[], java.lang.String, android.content.ContentValues, android.app.PendingIntent);
+    method public void sendMultimediaMessage(long, byte[], java.lang.String, android.content.ContentValues, android.app.PendingIntent);
     method public void sendMultipartTextMessage(java.lang.String, java.lang.String, java.util.ArrayList<java.lang.String>, java.util.ArrayList<android.app.PendingIntent>, java.util.ArrayList<android.app.PendingIntent>);
-    method public void sendStoredMultimediaMessage(android.net.Uri, android.app.PendingIntent);
-    method public void sendStoredMultimediaMessage(long, android.net.Uri, android.app.PendingIntent);
+    method public void sendStoredMultimediaMessage(android.net.Uri, android.content.ContentValues, android.app.PendingIntent);
+    method public void sendStoredMultimediaMessage(long, android.net.Uri, android.content.ContentValues, android.app.PendingIntent);
     method public void sendStoredMultipartTextMessage(android.net.Uri, java.lang.String, java.util.ArrayList<android.app.PendingIntent>, java.util.ArrayList<android.app.PendingIntent>);
     method public void sendStoredMultipartTextMessage(long, android.net.Uri, java.lang.String, java.util.ArrayList<android.app.PendingIntent>, java.util.ArrayList<android.app.PendingIntent>);
     method public void sendStoredTextMessage(android.net.Uri, java.lang.String, android.app.PendingIntent, android.app.PendingIntent);
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 1bec285..7e1c069 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -1126,18 +1126,17 @@
          * import android.provider.ContactsContract.Contacts;
          *
          * Uri uri = Contacts.CONTENT_URI.buildUpon()
-         *          .appendQueryParameter(ContactCounts.ADDRESS_BOOK_INDEX_EXTRAS, "true")
+         *          .appendQueryParameter(Contacts.ADDRESS_BOOK_INDEX_EXTRAS, "true")
          *          .build();
          * Cursor cursor = getContentResolver().query(uri,
          *          new String[] {Contacts.DISPLAY_NAME},
          *          null, null, null);
          * Bundle bundle = cursor.getExtras();
-         * if (bundle.containsKey(Contacts.ContactCounts.EXTRA_ADDRESS_BOOK_INDEX_TITLES) &&
-         *         bundle.containsKey(Contacts.ContactCounts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS)) {
+         * if (bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES) &&
+         *         bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS)) {
          *     String sections[] =
-         *             bundle.getStringArray(Contacts.ContactCounts.EXTRA_ADDRESS_BOOK_INDEX_TITLES);
-         *     int counts[] = bundle.getIntArray(
-         *             Contacts.ContactCounts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS);
+         *             bundle.getStringArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES);
+         *     int counts[] = bundle.getIntArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS);
          * }
          * </pre>
          * </p>
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 5d5be4a..4b7e615 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -4607,6 +4607,12 @@
         public static final String WAKE_GESTURE_ENABLED = "wake_gesture_enabled";
 
         /**
+         * Whether the device should doze if configured.
+         * @hide
+         */
+        public static final String DOZE_ENABLED = "doze_enabled";
+
+        /**
          * The current night mode that has been selected by the user.  Owned
          * and controlled by UiModeManagerService.  Constants are as per
          * UiModeManager.
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 7e16c7d..a8d2bef 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -10830,13 +10830,14 @@
         // Unattached views ignore this signal, and outline is recomputed in onAttachedToWindow()
         if (mAttachInfo == null) return;
 
-        final Outline outline = mAttachInfo.mTmpOutline;
-        outline.setEmpty();
-
         if (mOutlineProvider == null) {
             // no provider, remove outline
             mRenderNode.setOutline(null);
         } else {
+            final Outline outline = mAttachInfo.mTmpOutline;
+            outline.setEmpty();
+            outline.setAlpha(1.0f);
+
             mOutlineProvider.getOutline(this, outline);
             mRenderNode.setOutline(outline);
         }
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index c09440b..6b46174 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -3265,21 +3265,29 @@
             final View child = children[i];
             if (((child.mViewFlags & VISIBILITY_MASK) == VISIBLE || child.getAnimation() != null) &&
                     child.hasStaticLayer()) {
-                child.mRecreateDisplayList = (child.mPrivateFlags & PFLAG_INVALIDATED)
-                        == PFLAG_INVALIDATED;
-                child.mPrivateFlags &= ~PFLAG_INVALIDATED;
-                child.getDisplayList();
-                child.mRecreateDisplayList = false;
+                recreateChildDisplayList(child);
             }
         }
         if (mOverlay != null) {
             View overlayView = mOverlay.getOverlayView();
-            overlayView.mRecreateDisplayList = (overlayView.mPrivateFlags & PFLAG_INVALIDATED)
-                    == PFLAG_INVALIDATED;
-            overlayView.mPrivateFlags &= ~PFLAG_INVALIDATED;
-            overlayView.getDisplayList();
-            overlayView.mRecreateDisplayList = false;
+            recreateChildDisplayList(overlayView);
         }
+        if (mDisappearingChildren != null) {
+            final ArrayList<View> disappearingChildren = mDisappearingChildren;
+            final int disappearingCount = disappearingChildren.size();
+            for (int i = 0; i < disappearingCount; ++i) {
+                final View child = disappearingChildren.get(i);
+                recreateChildDisplayList(child);
+            }
+        }
+    }
+
+    private void recreateChildDisplayList(View child) {
+        child.mRecreateDisplayList = (child.mPrivateFlags & PFLAG_INVALIDATED)
+                == PFLAG_INVALIDATED;
+        child.mPrivateFlags &= ~PFLAG_INVALIDATED;
+        child.getDisplayList();
+        child.mRecreateDisplayList = false;
     }
 
     /**
diff --git a/core/java/android/view/ViewOutlineProvider.java b/core/java/android/view/ViewOutlineProvider.java
index 4054031..170c5d8 100644
--- a/core/java/android/view/ViewOutlineProvider.java
+++ b/core/java/android/view/ViewOutlineProvider.java
@@ -37,7 +37,6 @@
             if (background != null) {
                 background.getOutline(outline);
             } else {
-
                 outline.setRect(0, 0, view.getWidth(), view.getHeight());
                 outline.setAlpha(0.0f);
             }
@@ -51,6 +50,8 @@
      * View's size changes, or if {@link View#invalidateOutline()} is called
      * explicitly.
      *
+     * The input outline is empty and has an alpha of <code>1.0f</code>.
+     *
      * @param view The view building the outline.
      * @param outline The empty outline to be populated.
      */
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 2a96580..e3504fa 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2812,7 +2812,13 @@
          @hide This is not a third-party API (intended for system apps). -->
     <permission android:name="android.permission.READ_INSTALL_SESSIONS"
         android:label="@string/permlab_readInstallSessions"
-        android:description="@string/permdesc_readInstallSessions"
+        android:description="@string/permdesc_readInstallSessions" />
+
+    <!-- @SystemApi Allows an application to remove DRM certificates
+         @hide This is not a third-party API (intended for system apps). -->
+    <permission android:name="android.permission.REMOVE_DRM_CERTIFICATES"
+        android:label="@string/permlab_removeDrmCertificates"
+        android:description="@string/permdesc_removeDrmCertificates"
         android:protectionLevel="signature|system" />
 
     <!-- The system process is explicitly the only one allowed to launch the
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 8e626e3..3f6cd95 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2167,6 +2167,11 @@
     <string name="permlab_handoverStatus">Receive Android Beam transfer status</string>
     <string name="permdesc_handoverStatus">Allows this application to receive information about current Android Beam transfers</string>
 
+    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permlab_removeDrmCertificates">remove DRM certificates</string>
+    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permdesc_removeDrmCertificates">Allows an application to remove DRM certficates. Should never be needed for normal apps.</string>
+
     <!-- Policy administration -->
 
     <!-- Title of policy access to limiting the user's password choices -->
diff --git a/docs/html/training/sync-adapters/creating-stub-provider.jd b/docs/html/training/sync-adapters/creating-stub-provider.jd
index 8f6eba0..b8190d1 100644
--- a/docs/html/training/sync-adapters/creating-stub-provider.jd
+++ b/docs/html/training/sync-adapters/creating-stub-provider.jd
@@ -190,7 +190,7 @@
     &lt;provider
         android:name="com.example.android.datasync.provider.StubProvider"
         android:authorities="com.example.android.datasync.provider"
-        android:export="false"
+        android:exported="false"
         android:syncable="true"/&gt;
     ...
     &lt;/application&gt;
diff --git a/docs/html/training/sync-adapters/creating-sync-adapter.jd b/docs/html/training/sync-adapters/creating-sync-adapter.jd
index 7c59c8c..b13ce07 100644
--- a/docs/html/training/sync-adapters/creating-sync-adapter.jd
+++ b/docs/html/training/sync-adapters/creating-sync-adapter.jd
@@ -619,7 +619,7 @@
                 android:name="com.example.android.datasync.SyncService"
                 android:exported="true"
                 android:process=":sync"&gt;
-            &lt;intent-filter&gt;com.example.android.datasync.provider
+            &lt;intent-filter&gt;
                 &lt;action android:name="android.content.SyncAdapter"/&gt;
             &lt;/intent-filter&gt;
             &lt;meta-data android:name="android.content.SyncAdapter"
diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java
index be02c9b..d5ffa58 100644
--- a/graphics/java/android/graphics/drawable/VectorDrawable.java
+++ b/graphics/java/android/graphics/drawable/VectorDrawable.java
@@ -708,7 +708,7 @@
             mRootGroup = new VGroup(copy.mRootGroup, mVGTargetsMap);
             mBaseWidth = copy.mBaseWidth;
             mBaseHeight = copy.mBaseHeight;
-            mViewportWidth = copy.mViewportHeight;
+            mViewportWidth = copy.mViewportWidth;
             mViewportHeight = copy.mViewportHeight;
             mChangingConfigurations = copy.mChangingConfigurations;
             mRootAlpha = copy.mRootAlpha;
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index 548ec91..7bd0798 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -699,9 +699,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 void Caches::initTempProperties() {
-    propertyAmbientShadowStrength = 12;
-    propertySpotShadowStrength = 48;
-
     propertyLightDiameter = -1.0f;
     propertyLightPosY = -1.0f;
     propertyLightPosZ = -1.0f;
@@ -710,15 +707,7 @@
 
 void Caches::setTempProperty(const char* name, const char* value) {
     ALOGD("setting property %s to %s", name, value);
-    if (!strcmp(name, "ambientShadowStrength")) {
-        propertyAmbientShadowStrength = atoi(value);
-        ALOGD("ambient shadow strength = 0x%x out of 0xff", propertyAmbientShadowStrength);
-        return;
-    } else if (!strcmp(name, "spotShadowStrength")) {
-        propertySpotShadowStrength = atoi(value);
-        ALOGD("spot shadow strength = 0x%x out of 0xff", propertySpotShadowStrength);
-        return;
-    } else if (!strcmp(name, "ambientRatio")) {
+    if (!strcmp(name, "ambientRatio")) {
         propertyAmbientRatio = fmin(fmax(atof(value), 0.0), 10.0);
         ALOGD("ambientRatio = %.2f", propertyAmbientRatio);
         return;
@@ -734,10 +723,6 @@
         propertyLightPosZ = fmin(fmax(atof(value), 0.0), 3000.0);
         ALOGD("lightPos Z = %.2f", propertyLightPosZ);
         return;
-    } else if (!strcmp(name, "extraRasterBucket")) {
-        float bucket = atof(value);
-        propertyExtraRasterBuckets.push_back(bucket);
-        return;
     }
     ALOGD("    failed");
 }
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index 8727941..e00cb0b 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -366,9 +366,6 @@
     float propertyLightPosY;
     float propertyLightPosZ;
     float propertyAmbientRatio;
-    int propertyAmbientShadowStrength;
-    int propertySpotShadowStrength;
-    std::vector<float> propertyExtraRasterBuckets;
 private:
     enum OverdrawColorSet {
         kColorSet_Default = 0,
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 5e6ae3f..5fbef2e 100755
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -2809,31 +2809,15 @@
     }
 
     /**
-     * Input is a non-perspective, scaling transform. Generate a scale-only transform, based upon
-     * bucketed scale values. Special case for 'extra raster buckets' - disable filtration in the
-     * case of an exact match, and isSimple() transform
+     * Input is a non-perspective, scaling transform. Generate a scale-only transform,
+     * with values rounded to the nearest int.
      */
     float sx, sy;
     transform.decomposeScale(sx, sy);
-
-    float bestSx = roundf(fmaxf(1.0f, sx));
-    float bestSy = roundf(fmaxf(1.0f, sy));
-    bool filter = true;
-
-    for (unsigned int i = 0; i < mCaches.propertyExtraRasterBuckets.size(); i++) {
-        float bucket = mCaches.propertyExtraRasterBuckets[i];
-        if (sx == bucket && sy == bucket) {
-            bestSx = bestSy = bucket;
-            filter = !transform.isSimple(); // disable filter, if simple
-            break;
-        }
-
-        if (fabs(bucket - sx) < fabs(bestSx - sx)) bestSx = sx;
-        if (fabs(bucket - sy) < fabs(bestSy - sy)) bestSy = sy;
-    }
-
-    outMatrix->setScale(bestSx, bestSy);
-    return filter;
+    outMatrix->setScale(
+            roundf(fmaxf(1.0f, sx)),
+            roundf(fmaxf(1.0f, sy)));
+    return true;
 }
 
 status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count, float x, float y,
diff --git a/media/java/android/media/MediaDrm.java b/media/java/android/media/MediaDrm.java
index 25f10d2..ca707d8 100644
--- a/media/java/android/media/MediaDrm.java
+++ b/media/java/android/media/MediaDrm.java
@@ -20,6 +20,7 @@
 import java.util.UUID;
 import java.util.HashMap;
 import java.util.List;
+import android.annotation.SystemApi;
 import android.os.Binder;
 import android.os.Debug;
 import android.os.Handler;
@@ -521,6 +522,18 @@
             throws DeniedByServerException;
 
     /**
+     * Remove provisioning from a device.  Only system apps may unprovision a
+     * device.  Note that removing provisioning will invalidate any keys saved
+     * for offline use (KEY_TYPE_OFFLINE), which may render downloaded content
+     * unplayable until new licenses are acquired.  Since provisioning is global
+     * to the device, license invalidation will apply to all content downloaded
+     * by any app, so appropriate warnings should be given to the user.
+     * @hide
+     */
+    @SystemApi
+    public native void unprovisionDevice();
+
+    /**
      * A means of enforcing limits on the number of concurrent streams per subscriber
      * across devices is provided via SecureStop. This is achieved by securely
      * monitoring the lifetime of sessions.
diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp
index 5f27b16..c678ac7 100644
--- a/media/jni/android_media_MediaDrm.cpp
+++ b/media/jni/android_media_MediaDrm.cpp
@@ -966,6 +966,22 @@
     return certificateObj;
 }
 
+static void android_media_MediaDrm_unprovisionDeviceNative(
+    JNIEnv *env, jobject thiz) {
+    sp<IDrm> drm = GetDrm(env, thiz);
+
+    if (drm == NULL) {
+        jniThrowException(env, "java/lang/IllegalStateException",
+                          "MediaDrm obj is null");
+        return;
+    }
+
+    status_t err = drm->unprovisionDevice();
+
+    throwExceptionAsNecessary(env, err, "Failed to handle provision response");
+    return;
+}
+
 static jobject android_media_MediaDrm_getSecureStops(
     JNIEnv *env, jobject thiz) {
     sp<IDrm> drm = GetDrm(env, thiz);
@@ -1362,6 +1378,9 @@
     { "provideProvisionResponseNative", "([B)Landroid/media/MediaDrm$Certificate;",
       (void *)android_media_MediaDrm_provideProvisionResponseNative },
 
+    { "unprovisionDevice", "()V",
+      (void *)android_media_MediaDrm_unprovisionDeviceNative },
+
     { "getSecureStops", "()Ljava/util/List;",
       (void *)android_media_MediaDrm_getSecureStops },
 
@@ -1408,4 +1427,3 @@
     return AndroidRuntime::registerNativeMethods(env,
                 "android/media/MediaDrm", gMethods, NELEM(gMethods));
 }
-
diff --git a/packages/SystemUI/res/layout/qs_panel.xml b/packages/SystemUI/res/layout/qs_panel.xml
index 087bf07..c76d442 100644
--- a/packages/SystemUI/res/layout/qs_panel.xml
+++ b/packages/SystemUI/res/layout/qs_panel.xml
@@ -19,6 +19,8 @@
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:background="@drawable/qs_background_primary"
+        android:paddingTop="8dp"
+        android:paddingBottom="8dp"
         android:elevation="2dp">
 
     <com.android.systemui.qs.QSPanel
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
index 986df91..57f1274 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -428,11 +428,11 @@
 
     @Override
     public void computeScroll() {
+        mStackScroller.computeScroll();
         // Synchronize the views
         if (synchronizeStackViewsWithModel()) {
             clipTaskViews();
         }
-        mStackScroller.computeScroll();
     }
 
     /** Computes the stack and task rects */
@@ -632,12 +632,6 @@
         }
     }
 
-    @Override
-    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
-        super.onScrollChanged(l, t, oldl, oldt);
-        requestSynchronizeStackViewsWithModel();
-    }
-
     public boolean isTransformedTouchPointInView(float x, float y, View child) {
         return isTransformedTouchPointInView(x, y, child, null);
     }
@@ -889,7 +883,7 @@
     public void onScrollChanged(float p) {
         mUIDozeTrigger.poke();
         requestSynchronizeStackViewsWithModel();
-        invalidate();
+        postInvalidateOnAnimation();
     }
 
     /**** RecentsPackageMonitor.PackageCallbacks Implementation ****/
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
index 4cf6b82..374a27f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
@@ -185,6 +185,7 @@
 
     /** Handles touch events once we have intercepted them */
     public boolean onTouchEvent(MotionEvent ev) {
+
         // Short circuit if we have no children
         boolean hasChildren = (mSv.getChildCount() > 0);
         if (!hasChildren) {
@@ -278,7 +279,6 @@
                 final VelocityTracker velocityTracker = mVelocityTracker;
                 velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
                 int velocity = (int) velocityTracker.getYVelocity(mActivePointerId);
-
                 if (mIsScrolling && (Math.abs(velocity) > mMinimumVelocity)) {
                     // XXX: Should this be calculated as a percentage of a curve?
                     int overscrollRange = (int) (Math.min(1f,
diff --git a/services/core/java/com/android/server/MmsServiceBroker.java b/services/core/java/com/android/server/MmsServiceBroker.java
index 898b6f1..df54c7f 100644
--- a/services/core/java/com/android/server/MmsServiceBroker.java
+++ b/services/core/java/com/android/server/MmsServiceBroker.java
@@ -191,25 +191,28 @@
     private final class BinderService extends IMms.Stub {
         @Override
         public void sendMessage(long subId, String callingPkg, byte[] pdu, String locationUrl,
-                PendingIntent sentIntent) throws RemoteException {
+                ContentValues configOverrides, PendingIntent sentIntent) throws RemoteException {
             mContext.enforceCallingPermission(Manifest.permission.SEND_SMS, "Send MMS message");
             if (getAppOpsManager().noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(),
                     callingPkg) != AppOpsManager.MODE_ALLOWED) {
                 return;
             }
-            getServiceGuarded().sendMessage(subId, callingPkg, pdu, locationUrl, sentIntent);
+            getServiceGuarded().sendMessage(subId, callingPkg, pdu, locationUrl, configOverrides,
+                    sentIntent);
         }
 
         @Override
         public void downloadMessage(long subId, String callingPkg, String locationUrl,
-                PendingIntent downloadedIntent) throws RemoteException {
+                ContentValues configOverrides, PendingIntent downloadedIntent)
+                throws RemoteException {
             mContext.enforceCallingPermission(Manifest.permission.RECEIVE_MMS,
                     "Download MMS message");
             if (getAppOpsManager().noteOp(AppOpsManager.OP_RECEIVE_MMS, Binder.getCallingUid(),
                     callingPkg) != AppOpsManager.MODE_ALLOWED) {
                 return;
             }
-            getServiceGuarded().downloadMessage(subId, callingPkg, locationUrl, downloadedIntent);
+            getServiceGuarded().downloadMessage(subId, callingPkg, locationUrl, configOverrides,
+                    downloadedIntent);
         }
 
         @Override
@@ -225,53 +228,21 @@
         }
 
         @Override
-        public boolean getCarrierConfigBoolean(String name, boolean defaultValue)
+        public boolean getCarrierConfigBoolean(long subId, String name, boolean defaultValue)
                 throws RemoteException {
-            return getServiceGuarded().getCarrierConfigBoolean(name, defaultValue);
+            return getServiceGuarded().getCarrierConfigBoolean(subId, name, defaultValue);
         }
 
         @Override
-        public int getCarrierConfigInt(String name, int defaultValue) throws RemoteException {
-            return getServiceGuarded().getCarrierConfigInt(name, defaultValue);
+        public int getCarrierConfigInt(long subId, String name, int defaultValue)
+                throws RemoteException {
+            return getServiceGuarded().getCarrierConfigInt(subId, name, defaultValue);
         }
 
         @Override
-        public String getCarrierConfigString(String name, String defaultValue)
+        public String getCarrierConfigString(long subId, String name, String defaultValue)
                 throws RemoteException {
-            return getServiceGuarded().getCarrierConfigString(name, defaultValue);
-        }
-
-        @Override
-        public void setCarrierConfigBoolean(String callingPkg, String name, boolean value)
-                throws RemoteException {
-            mContext.enforceCallingPermission(Manifest.permission.SEND_SMS, "Set MMS config");
-            if (getAppOpsManager().noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(),
-                    callingPkg) != AppOpsManager.MODE_ALLOWED) {
-                return;
-            }
-            getServiceGuarded().setCarrierConfigBoolean(callingPkg, name, value);
-        }
-
-        @Override
-        public void setCarrierConfigInt(String callingPkg, String name, int value)
-                throws RemoteException {
-            mContext.enforceCallingPermission(Manifest.permission.SEND_SMS, "Set MMS config");
-            if (getAppOpsManager().noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(),
-                    callingPkg) != AppOpsManager.MODE_ALLOWED) {
-                return;
-            }
-            getServiceGuarded().setCarrierConfigInt(callingPkg, name, value);
-        }
-
-        @Override
-        public void setCarrierConfigString(String callingPkg, String name, String value)
-                throws RemoteException {
-            mContext.enforceCallingPermission(Manifest.permission.SEND_SMS, "Set MMS config");
-            if (getAppOpsManager().noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(),
-                    callingPkg) != AppOpsManager.MODE_ALLOWED) {
-                return;
-            }
-            getServiceGuarded().setCarrierConfigString(callingPkg, name, value);
+            return getServiceGuarded().getCarrierConfigString(subId, name, defaultValue);
         }
 
         @Override
@@ -370,14 +341,15 @@
 
         @Override
         public void sendStoredMessage(long subId, String callingPkg, Uri messageUri,
-                PendingIntent sentIntent) throws RemoteException {
+                ContentValues configOverrides, PendingIntent sentIntent) throws RemoteException {
             mContext.enforceCallingPermission(Manifest.permission.SEND_SMS,
                     "Send stored MMS message");
             if (getAppOpsManager().noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(),
                     callingPkg) != AppOpsManager.MODE_ALLOWED) {
                 return;
             }
-            getServiceGuarded().sendStoredMessage(subId, callingPkg, messageUri, sentIntent);
+            getServiceGuarded().sendStoredMessage(subId, callingPkg, messageUri, configOverrides,
+                    sentIntent);
         }
 
         @Override
diff --git a/services/core/java/com/android/server/dreams/DreamManagerService.java b/services/core/java/com/android/server/dreams/DreamManagerService.java
index b894304..985f77a 100644
--- a/services/core/java/com/android/server/dreams/DreamManagerService.java
+++ b/services/core/java/com/android/server/dreams/DreamManagerService.java
@@ -249,7 +249,7 @@
 
     private ComponentName chooseDreamForUser(boolean doze, int userId) {
         if (doze) {
-            ComponentName dozeComponent = getDozeComponent();
+            ComponentName dozeComponent = getDozeComponent(userId);
             return validateDream(dozeComponent) ? dozeComponent : null;
         }
         ComponentName[] dreams = getDreamComponentsForUser(userId);
@@ -314,6 +314,10 @@
     }
 
     private ComponentName getDozeComponent() {
+        return getDozeComponent(ActivityManager.getCurrentUser());
+    }
+
+    private ComponentName getDozeComponent(int userId) {
         // Read the component from a system property to facilitate debugging.
         // Note that for production devices, the dream should actually be declared in
         // a config.xml resource.
@@ -324,7 +328,9 @@
             name = mContext.getResources().getString(
                     com.android.internal.R.string.config_dozeComponent);
         }
-        return TextUtils.isEmpty(name) ? null : ComponentName.unflattenFromString(name);
+        boolean enabled = Settings.Secure.getIntForUser(mContext.getContentResolver(),
+                Settings.Secure.DOZE_ENABLED, 1, userId) != 0;
+        return TextUtils.isEmpty(name) || !enabled ? null : ComponentName.unflattenFromString(name);
     }
 
     private ServiceInfo getServiceInfo(ComponentName name) {
diff --git a/telephony/java/com/android/internal/telephony/IMms.aidl b/telephony/java/com/android/internal/telephony/IMms.aidl
index 30ef725..cbcef25 100644
--- a/telephony/java/com/android/internal/telephony/IMms.aidl
+++ b/telephony/java/com/android/internal/telephony/IMms.aidl
@@ -31,11 +31,14 @@
      * @param callingPkg the package name of the calling app
      * @param pdu the MMS message encoded in standard MMS PDU format
      * @param locationUrl the optional location url for where this message should be sent to
+     * @param configOverrides the carrier-specific messaging configuration values to override for
+     *  sending the message. See {@link android.telephony.MessagingConfigurationManager} for the
+     *  value names and types.
      * @param sentIntent if not NULL this <code>PendingIntent</code> is
      *  broadcast when the message is successfully sent, or failed
      */
     void sendMessage(long subId, String callingPkg, in byte[] pdu, String locationUrl,
-            in PendingIntent sentIntent);
+            in ContentValues configOverrides, in PendingIntent sentIntent);
 
     /**
      * Download an MMS message using known location and transaction id
@@ -44,11 +47,14 @@
      * @param callingPkg the package name of the calling app
      * @param locationUrl the location URL of the MMS message to be downloaded, usually obtained
      *  from the MMS WAP push notification
+     * @param configOverrides the carrier-specific messaging configuration values to override for
+     *  downloading the message. See {@link android.telephony.MessagingConfigurationManager} for the
+     *  value names and types.
      * @param downloadedIntent if not NULL this <code>PendingIntent</code> is
      *  broadcast when the message is downloaded, or the download is failed
      */
     void downloadMessage(long subId, String callingPkg, String locationUrl,
-            in PendingIntent downloadedIntent);
+            in ContentValues configOverrides, in PendingIntent downloadedIntent);
 
     /**
      * Update the status of a pending (send-by-IP) MMS message handled by the carrier app.
@@ -75,53 +81,30 @@
      * Get carrier-dependent configuration value as boolean. For example, if multipart SMS
      * is supported.
      *
+     * @param subId the SIM id
      * @param name the configuration name
      * @param defaultValue the default value if fail to find the name
      */
-    boolean getCarrierConfigBoolean(String name, boolean defaultValue);
+    boolean getCarrierConfigBoolean(long subId, String name, boolean defaultValue);
 
     /**
      * Get carrier-dependent configuration value as int. For example, the MMS message size limit.
      *
+     * @param subId the SIM id
      * @param name the configuration name
      * @param defaultValue the default value if fail to find the name
      */
-    int getCarrierConfigInt(String name, int defaultValue);
+    int getCarrierConfigInt(long subId, String name, int defaultValue);
 
     /**
      * Get carrier-dependent configuration value as String. For example, extra HTTP headers for
      * MMS request.
      *
+     * @param subId the SIM id
      * @param name the configuration name
      * @param defaultValue the default value if fail to find the name
      */
-    String getCarrierConfigString(String name, String defaultValue);
-
-    /**
-     * Set carrier-dependent configuration value as boolean. For example, if multipart SMS
-     * is supported.
-     *
-     * @param name the configuration name
-     * @param value the configuration value
-     */
-    void setCarrierConfigBoolean(String callingPkg, String name, boolean value);
-
-    /**
-     * Set carrier-dependent configuration value as int. For example, the MMS message size limit.
-     *
-     * @param name the configuration name
-     * @param value the configuration value
-     */
-    void setCarrierConfigInt(String callingPkg, String name, int value);
-
-    /**
-     * Set carrier-dependent configuration value as String. For example, extra HTTP headers for
-     * MMS request.
-     *
-     * @param name the configuration name
-     * @param value the configuration value
-     */
-    void setCarrierConfigString(String callingPkg, String name, String value);
+    String getCarrierConfigString(long subId, String name, String defaultValue);
 
     /**
      * Import a text message into system's SMS store
@@ -220,11 +203,14 @@
      * @param subId the SIM id
      * @param callingPkg the package name of the calling app
      * @param messageUri the URI of the stored message
+     * @param configOverrides the carrier-specific messaging configuration values to override for
+     *  sending the message. See {@link android.telephony.MessagingConfigurationManager} for the
+     *  value names and types.
      * @param sentIntent if not NULL this <code>PendingIntent</code> is
      *  broadcast when the message is successfully sent, or failed
      */
     void sendStoredMessage(long subId, String callingPkg, in Uri messageUri,
-            in PendingIntent sentIntent);
+            in ContentValues configOverrides, in PendingIntent sentIntent);
 
     /**
      * Turns on/off the flag to automatically write sent/received SMS/MMS messages into system
diff --git a/tests/VectorDrawableTest/res/anim/animation_linear_progress_bar_rect1_scale.xml b/tests/VectorDrawableTest/res/anim/animation_linear_progress_bar_rect1_scale.xml
new file mode 100644
index 0000000..7347220
--- /dev/null
+++ b/tests/VectorDrawableTest/res/anim/animation_linear_progress_bar_rect1_scale.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <objectAnimator
+        android:duration="2016"
+        android:pathData="
+        M 0.1 1 l 0 0 l 0.00882427215576 0 l 0.00982859611511 0 l 0.01086503982544 0 l 0.01193084716797 0 l 0.0130220413208 0 l 0.01413340568542 0 l 0.01525821685791 0 l 0.01638801574707 0 l 0.01751272201538 0 l 0.01862035751343 0 l 0.01969732284546 0 l 0.02072854995728 0 l 0.02169786453247 0 l 0.02258871078491 0 l 0.02338474273682 0 l 0.02407070159912 0 l 0.02463348388672 0 l 0.0250626373291 0 l 0.02535140991211 0 l 0.02549694061279 0 l 0.02550048828125 0 l 0.02536708831787 0 l 0.02510528564453 0 l 0.02472625732422 0 l 0.0242431640625 0 l 0.02367015838623 0 l 0.02302188873291 0 l 0.02231246948242 0 l 0.02155555725098 0 l 0.02076324462891 0 l 0.01994682312012 0 l 0.01911575317383 0 l 0.01827827453613 0 l 0.01732414245605 0 l 0.01522109985352 0 l 0.01262580871582 0 l 0.00973388671875 0 l 0.00647575378418 0 l 0.0027661895752 0 l -0.00149223327637 0 l -0.00639404296875 0 l -0.01199066162109 0 l -0.01820671081543 0 l -0.02470901489258 0 l -0.03080444335937 0 l -0.0355574798584 0 l -0.03823974609375 0 l -0.03876884460449 0 l -0.03766212463379 0 l -0.03562252044678 0 l -0.03321434020996 0 l -0.03078151702881 0 l -0.02849582672119 0 l -0.02642543792725 0 l -0.02458423614502 0 l -0.02296115875244 0 l -0.02153518676758 0 l -0.02028285980225 0 l -0.01918155670166 0 l -0.01821084976196 0 l -0.01735286712646 0 l -0.01659231185913 0 l -0.01591604232788 0 l -0.0153129196167 0 l -0.01477350234985 0 l -0.01413362503052 0 l -0.01339265823364 0 l -0.01270362854004 0 l -0.01206108093262 0 l -0.01146033287048 0 l -0.01089729309082 0 l -0.01036835670471 0 l -0.00987038612366 0 l -0.00940062522888 0 l -0.00895661354065 0 l -0.00853617668152 0"
+        android:propertyXName="scaleX"
+        android:repeatCount="-1" />
+
+</set>
\ No newline at end of file
diff --git a/tests/VectorDrawableTest/res/anim/animation_linear_progress_bar_rect1_translate.xml b/tests/VectorDrawableTest/res/anim/animation_linear_progress_bar_rect1_translate.xml
new file mode 100644
index 0000000..4781ba8
--- /dev/null
+++ b/tests/VectorDrawableTest/res/anim/animation_linear_progress_bar_rect1_translate.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <objectAnimator
+        android:duration="2016"
+        android:pathData="
+        M -522.599975585938 0 l 0 0 l 0.12939453125 0 l 0.33831787109375 0 l 0.55450439453125 0 l 0.7708740234375 0 l 0.98065185546875 0 l 1.1964111328125 0 l 1.41351318359375 0 l 1.63153076171875 0 l 1.85052490234375 0 l 2.07052612304688 0 l 2.29080200195312 0 l 2.51150512695312 0 l 2.73260498046875 0 l 2.95355224609375 0 l 3.17404174804688 0 l 3.39422607421875 0 l 3.61355590820312 0 l 3.83163452148438 0 l 4.04849243164062 0 l 4.263671875 0 l 5.74725341796875 0 l 6.1026611328125 0 l 6.45980834960938 0 l 6.81781005859375 0 l 7.17654418945312 0 l 7.53366088867188 0 l 7.88861083984375 0 l 8.23974609375 0 l 8.58447265625 0 l 8.92156982421875 0 l 9.24810791015625 0 l 9.56137084960938 0 l 9.85906982421875 0 l 10.1377868652344 0 l 10.3955688476562 0 l 10.6287536621094 0 l 10.8357238769531 0 l 11.0149230957031 0 l 11.1639709472656 0 l 11.2832336425781 0 l 11.3713989257812 0 l 11.4301147460938 0 l 11.4596557617188 0 l 11.4611053466797 0 l 11.4369049072266 0 l 11.3887786865234 0 l 11.3183441162109 0 l 11.2276000976562 0 l 11.1185607910156 0 l 10.9933776855469 0 l 10.8534698486328 0 l 10.6995391845703 0 l 10.533935546875 0 l 10.3744659423828 0 l 10.3707733154297 0 l 10.4309463500977 0 l 10.5275726318359 0 l 10.671501159668 0 l 10.8763961791992 0 l 11.1566543579102 0 l 11.5270767211914 0 l 11.9947967529297 0 l 12.5502433776855 0 l 13.1453399658203 0 l 13.680793762207 0 l 14.0223298072815 0 l 14.0650296211243 0 l 13.798041343689 0 l 13.2949924468994 0 l 12.6584892272949 0 l 11.9693031311035 0 l 11.2772979736328 0 l 10.607666015625 0 l 9.97052764892578 0 l 9.36723327636719 0 l 8.79751586914062 0 l 8.25792694091797 0 l 7.74495697021484 0 l 7.25632476806641 0 l 6.78855895996094 0 l 6.33934020996094 0 l 5.9071044921875 0 l 5.48941040039062 0 l 5.08502197265625 0 l 4.69291687011719 0 l 4.33430480957031 0 l 4.00733947753906 0 l 3.68829345703125 0 l 3.37684631347656 0 l 3.07246398925781 0 l 2.77439880371094 0 l 2.48252868652344 0 l 2.20101928710938 0 l 1.91748046875 0 l 1.63726806640625 0 l 1.36772155761719 0"
+        android:propertyXName="translateX"
+        android:repeatCount="-1" />
+
+</set>
\ No newline at end of file
diff --git a/tests/VectorDrawableTest/res/anim/animation_linear_progress_bar_rect2_scale.xml b/tests/VectorDrawableTest/res/anim/animation_linear_progress_bar_rect2_scale.xml
new file mode 100644
index 0000000..a61af8f
--- /dev/null
+++ b/tests/VectorDrawableTest/res/anim/animation_linear_progress_bar_rect2_scale.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <objectAnimator
+        android:duration="2016"
+        android:pathData="
+        M 0.1 1 l 0.00930031776428 0 l 0.01123028755188 0 l 0.01313143730164 0 l 0.01497107505798 0 l 0.01671510696411 0 l 0.01833034515381 0 l 0.01978672027588 0 l 0.02105976104736 0 l 0.02213228225708 0 l 0.02299520492554 0 l 0.02364795684814 0 l 0.02409727096558 0 l 0.02435619354248 0 l 0.02444213867188 0 l 0.02437515258789 0 l 0.02417644500732 0 l 0.02386695861816 0 l 0.02346652984619 0 l 0.02299335479736 0 l 0.0224634552002 0 l 0.02189086914062 0 l 0.02128746032715 0 l 0.02066318511963 0 l 0.02002624511719 0 l 0.01938335418701 0 l 0.01873977661133 0 l 0.01809989929199 0 l 0.01746696472168 0 l 0.01684349060059 0 l 0.01623161315918 0 l 0.0156324005127 0 l 0.0150471496582 0 l 0.01447631835938 0 l 0.01392051696777 0 l 0.01337966918945 0 l 0.0128540802002 0 l 0.01234344482422 0 l 0.01184753417969 0 l 0.0113663482666 0 l 0.01089920043945 0 l 0.01044593811035 0 l 0.00998542785645 0 l 0.00933837890625 0 l 0.00863349914551 0 l 0.00791206359863 0 l 0.00717010498047 0 l 0.00640274047852 0 l 0.00560478210449 0 l 0.00477012634277 0 l 0.00389221191406 0 l 0.00296325683594 0 l 0.0019751739502 0 l 0.00091903686523 0 l -0.00021408081055 0 l -0.00143287658691 0 l -0.00274444580078 0 l -0.00415267944336 0 l -0.00565589904785 0 l -0.00724327087402 0 l -0.00889205932617 0 l -0.01056480407715 0 l -0.01220878601074 0 l -0.01376045227051 0 l -0.01515449523926 0 l -0.01633560180664 0 l -0.01726905822754 0 l -0.01794639587402 0 l -0.0183829498291 0 l -0.01861137390137 0 l -0.01867179870605 0 l -0.01860504150391 0 l -0.01844764709473 0 l -0.01822959899902 0 l -0.01797431945801 0 l -0.0176993560791 0 l -0.0174169921875 0 l -0.01713603973389 0 l -0.01686214447021 0 l -0.01651359558105 0 l -0.01609485626221 0 l -0.01569358825684 0 l -0.01531024932861 0 l -0.0149446105957 0 l -0.01459632873535 0 l -0.01426464080811 0 l -0.0139489364624 0 l -0.01364833831787 0 l -0.01336200714111 0 l -0.01308917999268 0 l -0.01282897949219 0 l -0.01258075714111 0 l -0.01234363555908 0 l -0.01211700439453 0 l -0.01190029144287 0 l -0.01169273376465 0 l -0.01149394989014 0 l -0.01130325317383 0 l -0.01112024307251 0 l -0.01094444274902 0 l -0.01077545166016 0 l -0.0106128692627 0 l -0.01045631408691 0 l -0.01030544281006 0 l -0.01016000747681 0 l -0.01001962661743 0 l -0.0098840713501 0 l -0.00975311279297 0 l -0.00962644577026 0 l -0.00950393676758 0 l -0.00938529968262 0 l -0.00927038192749 0 l -0.00915899276733 0 l -0.00905097961426 0 l -0.00894614219666 0 l -0.00884438514709 0 l -0.00874552726746 0 l -0.00864946365356 0 l -0.00855606079102 0 l -0.00846519470215 0 l -0.00837676048279 0 "
+        android:propertyXName="scaleX"
+        android:repeatCount="-1" />
+
+</set>
\ No newline at end of file
diff --git a/tests/VectorDrawableTest/res/anim/animation_linear_progress_bar_rect2_translate.xml b/tests/VectorDrawableTest/res/anim/animation_linear_progress_bar_rect2_translate.xml
new file mode 100644
index 0000000..31fa795
--- /dev/null
+++ b/tests/VectorDrawableTest/res/anim/animation_linear_progress_bar_rect2_translate.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <objectAnimator
+        android:duration="2016"
+        android:pathData="
+        M -197.600006103516 0 l 1.42625427246094 0 l 1.80754089355469 0 l 2.18778991699219 0 l 2.56109619140625 0 l 2.91810607910156 0 l 3.25482177734375 0 l 3.57159423828125 0 l 3.862548828125 0 l 4.12493896484375 0 l 4.35758972167969 0 l 4.56034851074219 0 l 4.73426818847656 0 l 4.88090515136719 0 l 5.00271606445312 0 l 5.10273742675781 0 l 5.18400573730469 0 l 5.24911499023438 0 l 5.30097961425781 0 l 5.34226226806641 0 l 5.37535095214844 0 l 5.40180206298828 0 l 5.42322540283203 0 l 5.44123077392578 0 l 5.45704650878906 0 l 5.47099304199219 0 l 5.48395538330078 0 l 5.4967041015625 0 l 5.50949859619141 0 l 5.52214813232422 0 l 5.53528594970703 0 l 5.54912567138672 0 l 5.56306457519531 0 l 5.57742691040039 0 l 5.59244155883789 0 l 5.60744094848633 0 l 5.62243270874023 0 l 5.6376781463623 0 l 5.65262794494629 0 l 5.66689777374268 0 l 5.68069934844971 0 l 5.69401162862778 0 l 5.70898681879044 0 l 5.75169992446899 0 l 5.80327129364014 0 l 5.85710144042969 0 l 5.91399765014648 0 l 5.97450065612793 0 l 6.03849411010742 0 l 6.10729217529297 0 l 6.18125534057617 0 l 6.26116561889648 0 l 6.34840393066406 0 l 6.44406127929688 0 l 6.54866790771484 0 l 6.66371917724609 0 l 6.79020690917969 0 l 6.92859649658203 0 l 7.07807159423828 0 l 7.23712158203125 0 l 7.40253448486328 0 l 7.56884765625 0 l 7.72840881347656 0 l 7.87199401855469 0 l 7.98992919921875 0 l 8.07417297363281 0 l 8.12013244628906 0 l 8.12655639648438 0 l 8.09510803222656 0 l 8.03091430664062 0 l 7.93995666503906 0 l 7.827880859375 0 l 7.69976806640625 0 l 7.56065368652344 0 l 7.41322326660156 0 l 7.26063537597656 0 l 7.10470581054688 0 l 6.94624328613281 0 l 6.78694152832031 0 l 6.6390380859375 0 l 6.50302124023438 0 l 6.36688232421875 0 l 6.23043823242188 0 l 6.09356689453125 0 l 5.95706176757812 0 l 5.82064819335938 0 l 5.6839599609375 0 l 5.5477294921875 0 l 5.41143798828125 0 l 5.27532958984375 0 l 5.13922119140625 0 l 5.00347900390625 0 l 4.8680419921875 0 l 4.73251342773438 0 l 4.59732055664062 0 l 4.46258544921875 0 l 4.328125 0 l 4.1937255859375 0 l 4.0599365234375 0 l 3.92672729492188 0 l 3.79376220703125 0 l 3.66119384765625 0 l 3.52935791015625 0 l 3.398193359375 0 l 3.26748657226562 0 l 3.13726806640625 0 l 3.00796508789062 0 l 2.87939453125 0 l 2.7515869140625 0 l 2.62445068359375 0 l 2.49810791015625 0 l 2.3726806640625 0 l 2.2481689453125 0 l 2.12457275390625 0 l 2.00173950195312 0 l 1.87997436523438 0 l 1.7618408203125 0 l 1.64154052734375 0 l 1.51962280273438 0 l 1.40017700195312 0 l 1.28421020507812 0 "
+        android:propertyXName="translateX"
+        android:repeatCount="-1" />
+
+</set>
\ No newline at end of file
diff --git a/tests/VectorDrawableTest/res/drawable/animation_vector_linear_progress_bar.xml b/tests/VectorDrawableTest/res/drawable/animation_vector_linear_progress_bar.xml
new file mode 100644
index 0000000..05bf833
--- /dev/null
+++ b/tests/VectorDrawableTest/res/drawable/animation_vector_linear_progress_bar.xml
@@ -0,0 +1,32 @@
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:drawable="@drawable/vector_drawable_linear_progress_bar" >
+
+    <target
+        android:name="path1"
+        android:animation="@anim/animation_linear_progress_bar_rect1_translate" />
+    <target
+        android:name="path1"
+        android:animation="@anim/animation_linear_progress_bar_rect1_scale" />
+
+    <target
+        android:name="path2"
+        android:animation="@anim/animation_linear_progress_bar_rect2_translate" />
+    <target
+        android:name="path2"
+        android:animation="@anim/animation_linear_progress_bar_rect2_scale" />
+</animated-vector>
\ No newline at end of file
diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable_linear_progress_bar.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable_linear_progress_bar.xml
new file mode 100644
index 0000000..96fd70e
--- /dev/null
+++ b/tests/VectorDrawableTest/res/drawable/vector_drawable_linear_progress_bar.xml
@@ -0,0 +1,46 @@
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:height="4dp"
+    android:viewportHeight="4"
+    android:viewportWidth="360"
+    android:width="360dp" >
+
+    <group
+        android:name="linear_indeterminate"
+        android:translateX="180.0"
+        android:translateY="0.0" >
+        <group
+            android:name="path1"
+            android:scaleX="0.1"
+            android:translateX="-522.59" >
+            <path
+                android:name="rect1"
+                android:fillColor="#FF000000"
+                android:pathData="l 288 0 l 0 4 l -288 0 z" />
+        </group>
+        <group
+            android:name="path2"
+            android:scaleX="0.1"
+            android:translateX="-197.6" >
+            <path
+                android:name="rect2"
+                android:fillColor="#FF000000"
+                android:pathData="l 288 0 l 0 4 l -288 0 z" />
+        </group>
+    </group>
+
+</vector>
\ No newline at end of file
diff --git a/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java b/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java
index b1ba0dd..f165cde 100644
--- a/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java
+++ b/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java
@@ -22,10 +22,11 @@
 import android.widget.GridLayout;
 import android.widget.ScrollView;
 
-public class AnimatedVectorDrawableTest extends Activity implements View.OnClickListener{
+public class AnimatedVectorDrawableTest extends Activity implements View.OnClickListener {
     private static final String LOGCAT = "AnimatedVectorDrawableTest";
 
     protected int[] icon = {
+            R.drawable.animation_vector_linear_progress_bar,
             R.drawable.animation_vector_drawable_grouping_1,
             R.drawable.animation_vector_progress_bar,
             R.drawable.animation_vector_drawable_favorite,
diff --git a/tools/layoutlib/.gitignore b/tools/layoutlib/.gitignore
index c5e82d7..eb52b64 100644
--- a/tools/layoutlib/.gitignore
+++ b/tools/layoutlib/.gitignore
@@ -1 +1,3 @@
-bin
\ No newline at end of file
+bin
+/.idea/workspace.xml
+/out
diff --git a/tools/layoutlib/.idea/.name b/tools/layoutlib/.idea/.name
new file mode 100644
index 0000000..10eb5c1
--- /dev/null
+++ b/tools/layoutlib/.idea/.name
@@ -0,0 +1 @@
+layoutlib
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/codeStyleSettings.xml b/tools/layoutlib/.idea/codeStyleSettings.xml
new file mode 100644
index 0000000..33937b3
--- /dev/null
+++ b/tools/layoutlib/.idea/codeStyleSettings.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectCodeStyleSettingsManager">
+    <option name="PER_PROJECT_SETTINGS">
+      <value>
+        <option name="FIELD_NAME_PREFIX" value="m" />
+        <option name="STATIC_FIELD_NAME_PREFIX" value="s" />
+        <option name="USE_FQ_CLASS_NAMES_IN_JAVADOC" value="false" />
+        <option name="INSERT_INNER_CLASS_IMPORTS" value="true" />
+        <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
+        <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
+        <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
+          <value />
+        </option>
+        <option name="IMPORT_LAYOUT_TABLE">
+          <value>
+            <package name="com.android" withSubpackages="true" static="false" />
+            <emptyLine />
+            <package name="org" withSubpackages="true" static="false" />
+            <emptyLine />
+            <package name="android" withSubpackages="true" static="false" />
+            <emptyLine />
+            <package name="java" withSubpackages="true" static="false" />
+            <emptyLine />
+            <package name="" withSubpackages="true" static="false" />
+            <emptyLine />
+            <package name="" withSubpackages="true" static="true" />
+          </value>
+        </option>
+        <option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" />
+        <option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
+        <option name="JD_ADD_BLANK_AFTER_PARM_COMMENTS" value="true" />
+        <option name="JD_ADD_BLANK_AFTER_RETURN" value="true" />
+        <option name="JD_DO_NOT_WRAP_ONE_LINE_COMMENTS" value="true" />
+        <option name="RIGHT_MARGIN" value="100" />
+        <option name="WRAP_COMMENTS" value="true" />
+        <XML>
+          <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
+        </XML>
+        <codeStyleSettings language="JAVA">
+          <option name="INDENT_CASE_FROM_SWITCH" value="false" />
+          <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
+          <option name="CALL_PARAMETERS_WRAP" value="1" />
+          <option name="METHOD_PARAMETERS_WRAP" value="1" />
+          <option name="THROWS_LIST_WRAP" value="1" />
+          <option name="EXTENDS_KEYWORD_WRAP" value="1" />
+          <option name="THROWS_KEYWORD_WRAP" value="1" />
+          <option name="BINARY_OPERATION_WRAP" value="1" />
+          <option name="TERNARY_OPERATION_WRAP" value="1" />
+          <option name="ARRAY_INITIALIZER_WRAP" value="1" />
+          <option name="ASSIGNMENT_WRAP" value="1" />
+          <option name="ASSERT_STATEMENT_WRAP" value="1" />
+          <option name="IF_BRACE_FORCE" value="3" />
+          <option name="DOWHILE_BRACE_FORCE" value="3" />
+          <option name="WHILE_BRACE_FORCE" value="3" />
+          <option name="FOR_BRACE_FORCE" value="3" />
+          <arrangement>
+            <groups>
+              <group>
+                <type>GETTERS_AND_SETTERS</type>
+                <order>KEEP</order>
+              </group>
+              <group>
+                <type>OVERRIDDEN_METHODS</type>
+                <order>KEEP</order>
+              </group>
+            </groups>
+          </arrangement>
+        </codeStyleSettings>
+      </value>
+    </option>
+    <option name="USE_PER_PROJECT_SETTINGS" value="true" />
+  </component>
+</project>
+
diff --git a/tools/layoutlib/.idea/compiler.xml b/tools/layoutlib/.idea/compiler.xml
new file mode 100644
index 0000000..5aaaf18
--- /dev/null
+++ b/tools/layoutlib/.idea/compiler.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <option name="DEFAULT_COMPILER" value="Javac" />
+    <excludeFromCompile>
+      <directory url="file://$PROJECT_DIR$/create/tests/mock_data" includeSubdirectories="true" />
+    </excludeFromCompile>
+    <resourceExtensions />
+    <wildcardResourcePatterns>
+      <entry name="!?*.java" />
+      <entry name="!?*.form" />
+      <entry name="!?*.class" />
+      <entry name="!?*.groovy" />
+      <entry name="!?*.scala" />
+      <entry name="!?*.flex" />
+      <entry name="!?*.kt" />
+      <entry name="!?*.clj" />
+    </wildcardResourcePatterns>
+    <annotationProcessing>
+      <profile default="true" name="Default" enabled="false">
+        <processorPath useClasspath="true" />
+      </profile>
+    </annotationProcessing>
+    <bytecodeTargetLevel target="1.6" />
+  </component>
+</project>
+
diff --git a/tools/layoutlib/.idea/copyright/Android.xml b/tools/layoutlib/.idea/copyright/Android.xml
new file mode 100644
index 0000000..d81d75d
--- /dev/null
+++ b/tools/layoutlib/.idea/copyright/Android.xml
@@ -0,0 +1,9 @@
+<component name="CopyrightManager">
+  <copyright>
+    <option name="notice" value="Copyright (C) &amp;#36;today.year The Android Open Source Project&#10;&#10;Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&#10;you may not use this file except in compliance with the License.&#10;You may obtain a copy of the License at&#10;&#10;     http://www.apache.org/licenses/LICENSE-2.0&#10;&#10;Unless required by applicable law or agreed to in writing, software&#10;distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&#10;WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&#10;See the License for the specific language governing permissions and&#10;limitations under the License." />
+    <option name="keyword" value="Copyright" />
+    <option name="allowReplaceKeyword" value="" />
+    <option name="myName" value="Android" />
+    <option name="myLocal" value="true" />
+  </copyright>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/copyright/profiles_settings.xml b/tools/layoutlib/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/tools/layoutlib/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+<component name="CopyrightManager">
+  <settings default="" />
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/encodings.xml b/tools/layoutlib/.idea/encodings.xml
new file mode 100644
index 0000000..e206d70
--- /dev/null
+++ b/tools/layoutlib/.idea/encodings.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
+</project>
+
diff --git a/tools/layoutlib/.idea/inspectionProfiles/Project_Default.xml b/tools/layoutlib/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..0ac7a44
--- /dev/null
+++ b/tools/layoutlib/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,11 @@
+<component name="InspectionProjectProfileManager">
+  <profile version="1.0" is_locked="false">
+    <option name="myName" value="Project Default" />
+    <option name="myLocal" value="false" />
+    <inspection_tool class="DefaultFileTemplate" enabled="false" level="WARNING" enabled_by_default="false">
+      <option name="CHECK_FILE_HEADER" value="true" />
+      <option name="CHECK_TRY_CATCH_SECTION" value="true" />
+      <option name="CHECK_METHOD_BODY" value="true" />
+    </inspection_tool>
+  </profile>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/inspectionProfiles/profiles_settings.xml b/tools/layoutlib/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..3b31283
--- /dev/null
+++ b/tools/layoutlib/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,7 @@
+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="PROJECT_PROFILE" value="Project Default" />
+    <option name="USE_PROJECT_PROFILE" value="true" />
+    <version value="1.0" />
+  </settings>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/libraries/asm_4_0.xml b/tools/layoutlib/.idea/libraries/asm_4_0.xml
new file mode 100644
index 0000000..578a7bf
--- /dev/null
+++ b/tools/layoutlib/.idea/libraries/asm_4_0.xml
@@ -0,0 +1,11 @@
+<component name="libraryTable">
+  <library name="asm-4.0">
+    <CLASSES>
+      <root url="jar://$ANDROID_BUILD_TOP$/prebuilts/misc/common/asm/asm-4.0.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES>
+      <root url="jar://$ANDROID_BUILD_TOP$/prebuilts/misc/common/asm/src.zip!/" />
+    </SOURCES>
+  </library>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/libraries/framework_jar.xml b/tools/layoutlib/.idea/libraries/framework_jar.xml
new file mode 100644
index 0000000..11f5b89
--- /dev/null
+++ b/tools/layoutlib/.idea/libraries/framework_jar.xml
@@ -0,0 +1,13 @@
+<component name="libraryTable">
+  <library name="framework.jar">
+    <CLASSES>
+      <root url="jar://$ANDROID_BUILD_TOP$/out/host/common/obj/JAVA_LIBRARIES/temp_layoutlib_intermediates/javalib.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES>
+      <root url="file://$ANDROID_BUILD_TOP$/frameworks/base/core/java" />
+      <root url="file://$ANDROID_BUILD_TOP$/frameworks/base/graphics/java" />
+      <root url="file://$ANDROID_BUILD_TOP$/libcore/luni/src/main/java" />
+    </SOURCES>
+  </library>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/libraries/guava.xml b/tools/layoutlib/.idea/libraries/guava.xml
new file mode 100644
index 0000000..de5607e
--- /dev/null
+++ b/tools/layoutlib/.idea/libraries/guava.xml
@@ -0,0 +1,11 @@
+<component name="libraryTable">
+  <library name="guava">
+    <CLASSES>
+      <root url="jar://$ANDROID_BUILD_TOP$/out/host/common/obj/JAVA_LIBRARIES/guavalib_intermediates/javalib.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES>
+      <root url="file://$ANDROID_BUILD_TOP$/external/guava/guava/src" />
+    </SOURCES>
+  </library>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/libraries/icu4j.xml b/tools/layoutlib/.idea/libraries/icu4j.xml
new file mode 100644
index 0000000..8d9a318
--- /dev/null
+++ b/tools/layoutlib/.idea/libraries/icu4j.xml
@@ -0,0 +1,11 @@
+<component name="libraryTable">
+  <library name="icu4j">
+    <CLASSES>
+      <root url="jar://$ANDROID_BUILD_TOP$/prebuilts/misc/common/icu4j/icu4j.jar!/" />
+    </CLASSES>
+    <JAVADOC>
+      <root url="http://icu-project.org/apiref/icu4j50rc/" />
+    </JAVADOC>
+    <SOURCES />
+  </library>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/libraries/kxml2_2_3_0.xml b/tools/layoutlib/.idea/libraries/kxml2_2_3_0.xml
new file mode 100644
index 0000000..91feaea
--- /dev/null
+++ b/tools/layoutlib/.idea/libraries/kxml2_2_3_0.xml
@@ -0,0 +1,11 @@
+<component name="libraryTable">
+  <library name="kxml2-2.3.0">
+    <CLASSES>
+      <root url="jar://$ANDROID_BUILD_TOP$/prebuilts/misc/common/kxml2/kxml2-2.3.0.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES>
+      <root url="file://$ANDROID_BUILD_TOP$/libcore/xml/src/main/java" />
+    </SOURCES>
+  </library>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/libraries/layoutlib_api_prebuilt.xml b/tools/layoutlib/.idea/libraries/layoutlib_api_prebuilt.xml
new file mode 100644
index 0000000..be928da
--- /dev/null
+++ b/tools/layoutlib/.idea/libraries/layoutlib_api_prebuilt.xml
@@ -0,0 +1,11 @@
+<component name="libraryTable">
+  <library name="layoutlib_api-prebuilt">
+    <CLASSES>
+      <root url="jar://$ANDROID_BUILD_TOP$/prebuilts/misc/common/layoutlib_api/layoutlib_api-prebuilt.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES>
+      <root url="file://$ANDROID_SRC$/tools/base/layoutlib-api/src/main/java" />
+    </SOURCES>
+  </library>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/libraries/ninepatch_prebuilt.xml b/tools/layoutlib/.idea/libraries/ninepatch_prebuilt.xml
new file mode 100644
index 0000000..338137b
--- /dev/null
+++ b/tools/layoutlib/.idea/libraries/ninepatch_prebuilt.xml
@@ -0,0 +1,11 @@
+<component name="libraryTable">
+  <library name="ninepatch-prebuilt">
+    <CLASSES>
+      <root url="jar://$ANDROID_BUILD_TOP$/prebuilts/misc/common/ninepatch/ninepatch-prebuilt.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES>
+      <root url="file://$ANDROID_SRC$/tools/base/ninepatch/src/main/java" />
+    </SOURCES>
+  </library>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/libraries/tools_common_prebuilt.xml b/tools/layoutlib/.idea/libraries/tools_common_prebuilt.xml
new file mode 100644
index 0000000..6479886
--- /dev/null
+++ b/tools/layoutlib/.idea/libraries/tools_common_prebuilt.xml
@@ -0,0 +1,14 @@
+<component name="libraryTable">
+  <library name="tools-common-prebuilt">
+    <ANNOTATIONS>
+      <root url="file://$PROJECT_DIR$" />
+    </ANNOTATIONS>
+    <CLASSES>
+      <root url="jar://$ANDROID_BUILD_TOP$/prebuilts/misc/common/tools-common/tools-common-prebuilt.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES>
+      <root url="file://$ANDROID_SRC$/tools/base/common/src/main/java" />
+    </SOURCES>
+  </library>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/misc.xml b/tools/layoutlib/.idea/misc.xml
new file mode 100644
index 0000000..fd63e6c
--- /dev/null
+++ b/tools/layoutlib/.idea/misc.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="EntryPointsManager">
+    <entry_points version="2.0" />
+    <list size="1">
+      <item index="0" class="java.lang.String" itemvalue="com.android.tools.layoutlib.annotations.LayoutlibDelegate" />
+    </list>
+  </component>
+  <component name="FrameworkDetectionExcludesConfiguration">
+    <type id="android" />
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>
+
diff --git a/tools/layoutlib/.idea/modules.xml b/tools/layoutlib/.idea/modules.xml
new file mode 100644
index 0000000..684f4fd
--- /dev/null
+++ b/tools/layoutlib/.idea/modules.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/bridge/bridge.iml" filepath="$PROJECT_DIR$/bridge/bridge.iml" />
+      <module fileurl="file://$PROJECT_DIR$/create/create.iml" filepath="$PROJECT_DIR$/create/create.iml" />
+    </modules>
+  </component>
+</project>
+
diff --git a/tools/layoutlib/.idea/runConfigurations/All_in_bridge.xml b/tools/layoutlib/.idea/runConfigurations/All_in_bridge.xml
new file mode 100644
index 0000000..badbbab
--- /dev/null
+++ b/tools/layoutlib/.idea/runConfigurations/All_in_bridge.xml
@@ -0,0 +1,31 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="All in bridge" type="JUnit" factoryName="JUnit" singleton="true" nameIsGenerated="true">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <module name="bridge" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+    <option name="ALTERNATIVE_JRE_PATH" value="" />
+    <option name="PACKAGE_NAME" value="" />
+    <option name="MAIN_CLASS_NAME" value="" />
+    <option name="METHOD_NAME" value="" />
+    <option name="TEST_OBJECT" value="package" />
+    <option name="VM_PARAMETERS" value="-ea -Dplatform.dir=&quot;$ANDROID_BUILD_TOP$/out/host/linux-x86/sdk/sdk/android-sdk_eng.deepanshu_linux-x86/platforms/android-L&quot; -Dtest_res.dir=&quot;$PROJECT_DIR$/bridge/tests/res&quot;" />
+    <option name="PARAMETERS" value="" />
+    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <option name="TEST_SEARCH_SCOPE">
+      <value defaultName="singleModule" />
+    </option>
+    <envs />
+    <patterns />
+    <RunnerSettings RunnerId="Debug">
+      <option name="DEBUG_PORT" value="" />
+      <option name="TRANSPORT" value="0" />
+      <option name="LOCAL" value="true" />
+    </RunnerSettings>
+    <RunnerSettings RunnerId="Run" />
+    <ConfigurationWrapper RunnerId="Debug" />
+    <ConfigurationWrapper RunnerId="Run" />
+    <method />
+  </configuration>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/runConfigurations/All_in_create.xml b/tools/layoutlib/.idea/runConfigurations/All_in_create.xml
new file mode 100644
index 0000000..b9cd419d
--- /dev/null
+++ b/tools/layoutlib/.idea/runConfigurations/All_in_create.xml
@@ -0,0 +1,31 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="All in create" type="JUnit" factoryName="JUnit" singleton="false" nameIsGenerated="true">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <module name="create" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+    <option name="ALTERNATIVE_JRE_PATH" value="" />
+    <option name="PACKAGE_NAME" value="" />
+    <option name="MAIN_CLASS_NAME" value="" />
+    <option name="METHOD_NAME" value="" />
+    <option name="TEST_OBJECT" value="package" />
+    <option name="VM_PARAMETERS" value="-ea" />
+    <option name="PARAMETERS" value="" />
+    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <option name="TEST_SEARCH_SCOPE">
+      <value defaultName="singleModule" />
+    </option>
+    <envs />
+    <patterns />
+    <RunnerSettings RunnerId="Debug">
+      <option name="DEBUG_PORT" value="" />
+      <option name="TRANSPORT" value="0" />
+      <option name="LOCAL" value="true" />
+    </RunnerSettings>
+    <RunnerSettings RunnerId="Run" />
+    <ConfigurationWrapper RunnerId="Debug" />
+    <ConfigurationWrapper RunnerId="Run" />
+    <method />
+  </configuration>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/runConfigurations/Create.xml b/tools/layoutlib/.idea/runConfigurations/Create.xml
new file mode 100644
index 0000000..e62925b
--- /dev/null
+++ b/tools/layoutlib/.idea/runConfigurations/Create.xml
@@ -0,0 +1,25 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="Create" type="Application" factoryName="Application" singleton="true">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <option name="MAIN_CLASS_NAME" value="com.android.tools.layoutlib.create.Main" />
+    <option name="VM_PARAMETERS" value="" />
+    <option name="PROGRAM_PARAMETERS" value="out/host/common/obj/JAVA_LIBRARIES/temp_layoutlib_intermediates/javalib.jar out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/javalib.jar" />
+    <option name="WORKING_DIRECTORY" value="file://$ANDROID_BUILD_TOP$/" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
+    <option name="ALTERNATIVE_JRE_PATH" value="1.6" />
+    <option name="ENABLE_SWING_INSPECTOR" value="false" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <module name="create" />
+    <envs />
+    <RunnerSettings RunnerId="Debug">
+      <option name="DEBUG_PORT" value="" />
+      <option name="TRANSPORT" value="0" />
+      <option name="LOCAL" value="true" />
+    </RunnerSettings>
+    <RunnerSettings RunnerId="Run" />
+    <ConfigurationWrapper RunnerId="Debug" />
+    <ConfigurationWrapper RunnerId="Run" />
+    <method />
+  </configuration>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/scopes/scope_settings.xml b/tools/layoutlib/.idea/scopes/scope_settings.xml
new file mode 100644
index 0000000..922003b
--- /dev/null
+++ b/tools/layoutlib/.idea/scopes/scope_settings.xml
@@ -0,0 +1,5 @@
+<component name="DependencyValidationManager">
+  <state>
+    <option name="SKIP_IMPORT_STATEMENTS" value="false" />
+  </state>
+</component>
\ No newline at end of file
diff --git a/tools/layoutlib/.idea/uiDesigner.xml b/tools/layoutlib/.idea/uiDesigner.xml
new file mode 100644
index 0000000..3b00020
--- /dev/null
+++ b/tools/layoutlib/.idea/uiDesigner.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Palette2">
+    <group name="Swing">
+      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
+      </item>
+      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
+        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
+        <initial-values>
+          <property name="text" value="Button" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="RadioButton" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="CheckBox" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="Label" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
+          <preferred-size width="-1" height="20" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
+      </item>
+    </group>
+  </component>
+</project>
+
diff --git a/tools/layoutlib/.idea/vcs.xml b/tools/layoutlib/.idea/vcs.xml
new file mode 100644
index 0000000..8114960
--- /dev/null
+++ b/tools/layoutlib/.idea/vcs.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$ANDROID_BUILD_TOP$/frameworks/base" vcs="Git" />
+  </component>
+</project>
+
diff --git a/tools/layoutlib/bridge/.classpath b/tools/layoutlib/bridge/.classpath
index aef3efa..9c4160c 100644
--- a/tools/layoutlib/bridge/.classpath
+++ b/tools/layoutlib/bridge/.classpath
@@ -10,5 +10,7 @@
 	<classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilts/misc/common/tools-common/tools-common-prebuilt.jar"/>
 	<classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilts/misc/common/icu4j/icu4j.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+	<classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilts/misc/common/sdk-common/sdk-common.jar"/>
+	<classpathentry kind="var" path="ANDROID_PLAT_SRC/out/host/common/obj/JAVA_LIBRARIES/guavalib_intermediates/javalib.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/tools/layoutlib/bridge/bridge.iml b/tools/layoutlib/bridge/bridge.iml
new file mode 100644
index 0000000..7553b59
--- /dev/null
+++ b/tools/layoutlib/bridge/bridge.iml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/tests/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/tests/src" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/.settings" />
+      <excludeFolder url="file://$MODULE_DIR$/bin" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/res/testApp/MyApplication/.gradle" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/res/testApp/MyApplication/.idea" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/res/testApp/MyApplication/build/generated" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/res/testApp/MyApplication/build/intermediates/assets" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/res/testApp/MyApplication/build/intermediates/dependency-cache" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/res/testApp/MyApplication/build/intermediates/incremental" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/res/testApp/MyApplication/build/intermediates/libs" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/res/testApp/MyApplication/build/intermediates/manifests" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/res/testApp/MyApplication/build/intermediates/res" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/res/testApp/MyApplication/build/intermediates/rs" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/res/testApp/MyApplication/build/intermediates/symbols" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/res/testApp/MyApplication/gradle" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="icu4j" level="project" />
+    <orderEntry type="library" name="kxml2-2.3.0" level="project" />
+    <orderEntry type="library" name="layoutlib_api-prebuilt" level="project" />
+    <orderEntry type="library" name="ninepatch-prebuilt" level="project" />
+    <orderEntry type="library" name="tools-common-prebuilt" level="project" />
+    <orderEntry type="library" name="framework.jar" level="project" />
+    <orderEntry type="library" scope="TEST" name="guava" level="project" />
+    <orderEntry type="module-library" scope="TEST">
+      <library>
+        <CLASSES>
+          <root url="jar://$ANDROID_BUILD_TOP$/prebuilts/misc/common/sdk-common/sdk-common.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$ANDROID_BUILD_TOP$/prebuilts/misc/common/sdk-common/sdk-common-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="library" scope="TEST" name="JUnit4" level="application" />
+  </component>
+</module>
+
diff --git a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
index 2ff0fc1..be75dde 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
@@ -132,20 +132,6 @@
     }
 
     @LayoutlibDelegate
-    /*package*/ static long initCanvas(long nativeCanvas) {
-        // get the delegate from the native int.
-        Canvas_Delegate nativeCanvasDelegate = sManager.getDelegate(nativeCanvas);
-        if (nativeCanvasDelegate == null) {
-            return 0;
-        }
-
-        Canvas_Delegate newDelegate = new Canvas_Delegate();
-
-        // TODO: actually copy the canvas state.
-        return sManager.addNewDelegate(newDelegate);
-    }
-
-    @LayoutlibDelegate
     /*package*/
     static void native_setBitmap(long canvas, long bitmap, boolean copyState) {
         Canvas_Delegate canvasDelegate = sManager.getDelegate(canvas);
@@ -498,24 +484,6 @@
     }
 
     @LayoutlibDelegate
-    /*package*/ static void native_drawRGB(long nativeCanvas, int r, int g, int b) {
-        native_drawColor(nativeCanvas, 0xFF000000 | r << 16 | (g&0xFF) << 8 | (b&0xFF),
-                PorterDuff.Mode.SRC_OVER.nativeInt);
-
-    }
-
-    @LayoutlibDelegate
-    /*package*/ static void native_drawARGB(long nativeCanvas, int a, int r, int g, int b) {
-        native_drawColor(nativeCanvas, a << 24 | (r&0xFF) << 16 | (g&0xFF) << 8 | (b&0xFF),
-                PorterDuff.Mode.SRC_OVER.nativeInt);
-    }
-
-    @LayoutlibDelegate
-    /*package*/ static void native_drawColor(long nativeCanvas, int color) {
-        native_drawColor(nativeCanvas, color, PorterDuff.Mode.SRC_OVER.nativeInt);
-    }
-
-    @LayoutlibDelegate
     /*package*/ static void native_drawColor(long nativeCanvas, final int color, final int mode) {
         // get the delegate from the native int.
         Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
@@ -772,52 +740,18 @@
 
     @LayoutlibDelegate
     /*package*/ static void native_drawBitmap(Canvas thisCanvas, long nativeCanvas, long bitmap,
-                                                 Rect src, RectF dst,
-                                                 long nativePaintOrZero,
-                                                 int screenDensity,
-                                                 int bitmapDensity) {
+                                 float srcLeft, float srcTop, float srcRight, float srcBottom,
+                                 float dstLeft, float dstTop, float dstRight, float dstBottom,
+                                 long nativePaintOrZero, int screenDensity, int bitmapDensity) {
         // get the delegate from the native int.
         Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(bitmap);
         if (bitmapDelegate == null) {
             return;
         }
 
-        BufferedImage image = bitmapDelegate.getImage();
-
-        if (src == null) {
-            drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero,
-                    0, 0, image.getWidth(), image.getHeight(),
-                    (int)dst.left, (int)dst.top, (int)dst.right, (int)dst.bottom);
-        } else {
-            drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero,
-                    src.left, src.top, src.width(), src.height(),
-                    (int)dst.left, (int)dst.top, (int)dst.right, (int)dst.bottom);
-        }
-    }
-
-    @LayoutlibDelegate
-    /*package*/ static void native_drawBitmap(long nativeCanvas, long bitmap,
-                                                 Rect src, Rect dst,
-                                                 long nativePaintOrZero,
-                                                 int screenDensity,
-                                                 int bitmapDensity) {
-        // get the delegate from the native int.
-        Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(bitmap);
-        if (bitmapDelegate == null) {
-            return;
-        }
-
-        BufferedImage image = bitmapDelegate.getImage();
-
-        if (src == null) {
-            drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero,
-                    0, 0, image.getWidth(), image.getHeight(),
-                    dst.left, dst.top, dst.right, dst.bottom);
-        } else {
-            drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero,
-                    src.left, src.top, src.width(), src.height(),
-                    dst.left, dst.top, dst.right, dst.bottom);
-        }
+        drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero,
+                (int)srcLeft, (int)srcTop, (int)srcRight, (int)srcBottom,
+                (int)dstLeft, (int)dstTop, (int)dstRight, (int)dstBottom);
     }
 
     @LayoutlibDelegate
diff --git a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
index 74b2893..e16dbda 100644
--- a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
@@ -215,9 +215,9 @@
         if (c == null) {
             // not a 9-patch?
             BufferedImage image = bitmap_delegate.getImage();
-            Canvas_Delegate.native_drawBitmap(canvas_instance, bitmap_instance,
-                    new Rect(0, 0, image.getWidth(), image.getHeight()),
-                    new Rect(left, top, right, bottom),
+            Canvas_Delegate.native_drawBitmap(null, canvas_instance, bitmap_instance,
+                    0f, 0f, (float)image.getWidth(), (float)image.getHeight(),
+                    (float)left, (float)top, (float)right, (float)bottom,
                     paint_instance_or_null, destDensity, srcDensity);
             return;
         }
diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
index 24ef189..73d67a7 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
@@ -1084,6 +1084,22 @@
         sManager.removeJavaReferenceFor(nativePaint);
     }
 
+    @LayoutlibDelegate
+    /*package*/ static float native_getLetterSpacing(long nativePaint) {
+        // TODO: throw a fidelity warning.
+        return 0;
+    }
+
+    @LayoutlibDelegate
+    /*package*/ static void native_setLetterSpacing(long nativePaint, float letterSpacing) {
+        // pass.
+    }
+
+    @LayoutlibDelegate
+    /*package*/ static void native_setFontFeatureSettings(long nativePaint, String settings) {
+        // pass.
+    }
+
     // ---- Private delegate/helper methods ----
 
     /*package*/ Paint_Delegate() {
diff --git a/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java
index 14e9960..832d0a3 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java
@@ -76,19 +76,22 @@
     // ---- native methods ----
 
     @LayoutlibDelegate
-    /*package*/ static void nativeDestructor(long native_shader) {
+    /*package*/ static void nativeDestructor(long native_shader, long native_with_local_matrix) {
+        // TODO: check what's native_with_local_matrix
         sManager.removeJavaReferenceFor(native_shader);
     }
 
     @LayoutlibDelegate
-    /*package*/ static void nativeSetLocalMatrix(long native_shader, long matrix_instance) {
+    /*package*/ static long nativeSetLocalMatrix(long native_shader,
+            long native_with_local_matrix, long matrix_instance) {
         // get the delegate from the native int.
         Shader_Delegate shaderDelegate = sManager.getDelegate(native_shader);
         if (shaderDelegate == null) {
-            return;
+            return 0;
         }
 
         shaderDelegate.mLocalMatrix = Matrix_Delegate.getDelegate(matrix_instance);
+        return 0;
     }
 
     // ---- Private delegate/helper methods ----
diff --git a/tools/layoutlib/bridge/src/android/text/format/Time_Delegate.java b/tools/layoutlib/bridge/src/android/text/format/Time_Delegate.java
index 320dd0d..ed8498f 100644
--- a/tools/layoutlib/bridge/src/android/text/format/Time_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/text/format/Time_Delegate.java
@@ -39,91 +39,6 @@
     // Format used by toString()
     private static final String FORMAT = "%1$tY%1$tm%1$tdT%1$tH%1$tM%1$tS<%1$tZ>";
 
-    @LayoutlibDelegate
-    /*package*/ static long normalize(Time thisTime, boolean ignoreDst) {
-        long millis = toMillis(thisTime, ignoreDst);
-        set(thisTime, millis);
-        return millis;
-    }
-
-    @LayoutlibDelegate
-    /*package*/ static void switchTimezone(Time thisTime, String timezone) {
-        Calendar c = timeToCalendar(thisTime);
-        c.setTimeZone(TimeZone.getTimeZone(timezone));
-        calendarToTime(c, thisTime);
-    }
-
-    @LayoutlibDelegate
-    /*package*/ static int nativeCompare(Time a, Time b) {
-      return timeToCalendar(a).compareTo(timeToCalendar(b));
-    }
-
-    @LayoutlibDelegate
-    /*package*/ static String format1(Time thisTime, String format) {
-
-        try {
-            // Change the format by adding changing '%' to "%1$t". This is required to tell the
-            // formatter which argument to use from the argument list. '%%' is left as is. In the
-            // replacement string, $0 refers to matched pattern. \\1 means '1', written this way to
-            // separate it from 0. \\$ means '$', written this way to suppress the special meaning
-            // of $.
-            return String.format(
-                    p.matcher(format).replaceAll("$0\\1\\$t"),
-                    timeToCalendar(thisTime));
-        } catch (UnknownFormatConversionException e) {
-            Bridge.getLog().fidelityWarning(LayoutLog.TAG_STRFTIME, "Unrecognized format", e, format);
-            return format;
-        }
-    }
-
-    /**
-     * Return the current time in YYYYMMDDTHHMMSS<tz> format
-     */
-    @LayoutlibDelegate
-    /*package*/ static String toString(Time thisTime) {
-        Calendar c = timeToCalendar(thisTime);
-        return String.format(FORMAT, c);
-    }
-
-    @LayoutlibDelegate
-    /*package*/ static boolean nativeParse(Time thisTime, String s) {
-        Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
-                "android.text.format.Time.parse() not supported.", null);
-        return false;
-    }
-
-    @LayoutlibDelegate
-    /*package*/ static boolean nativeParse3339(Time thisTime, String s) {
-        Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
-                "android.text.format.Time.parse3339() not supported.", null);
-        return false;
-    }
-
-    @LayoutlibDelegate
-    /*package*/ static void setToNow(Time thisTime) {
-        calendarToTime(getCalendarInstance(thisTime), thisTime);
-    }
-
-    @LayoutlibDelegate
-    /*package*/ static long toMillis(Time thisTime, boolean ignoreDst) {
-        // TODO: Respect ignoreDst.
-        return timeToCalendar(thisTime).getTimeInMillis();
-    }
-
-    @LayoutlibDelegate
-    /*package*/ static void set(Time thisTime, long millis) {
-        Calendar c = getCalendarInstance(thisTime);
-        c.setTimeInMillis(millis);
-        calendarToTime(c,thisTime);
-    }
-
-    @LayoutlibDelegate
-    /*package*/ static String format2445(Time thisTime) {
-        Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
-                "android.text.format.Time.format2445() not supported.", null);
-        return "";
-    }
-
     // ---- private helper methods ----
 
     private static Calendar timeToCalendar(Time time) {
diff --git a/tools/layoutlib/bridge/src/android/view/accessibility/AccessibilityManager.java b/tools/layoutlib/bridge/src/android/view/accessibility/AccessibilityManager.java
index 1fd7836..d5170aa 100644
--- a/tools/layoutlib/bridge/src/android/view/accessibility/AccessibilityManager.java
+++ b/tools/layoutlib/bridge/src/android/view/accessibility/AccessibilityManager.java
@@ -16,6 +16,8 @@
 
 package android.view.accessibility;
 
+import com.android.annotations.NonNull;
+
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.content.Context;
 import android.content.pm.ServiceInfo;
@@ -31,14 +33,16 @@
  * for example an {@link android.app.Activity} starts, the focus or selection of a
  * {@link android.view.View} changes etc. Parties interested in handling accessibility
  * events implement and register an accessibility service which extends
- * {@link android.accessibilityservice.AccessibilityService}.
+ * {@code android.accessibilityservice.AccessibilityService}.
  *
  * @see AccessibilityEvent
- * @see android.accessibilityservice.AccessibilityService
  * @see android.content.Context#getSystemService
  */
+@SuppressWarnings("UnusedDeclaration")
 public final class AccessibilityManager {
-    private static AccessibilityManager sInstance = new AccessibilityManager();
+
+    private static AccessibilityManager sInstance = new AccessibilityManager(null, null, 0);
+
 
     /**
      * Listener for the accessibility state.
@@ -54,9 +58,46 @@
     }
 
     /**
+     * Listener for the system touch exploration state. To listen for changes to
+     * the touch exploration state on the device, implement this interface and
+     * register it with the system by calling
+     * {@link #addTouchExplorationStateChangeListener}.
+     */
+    public interface TouchExplorationStateChangeListener {
+
+        /**
+         * Called when the touch exploration enabled state changes.
+         *
+         * @param enabled Whether touch exploration is enabled.
+         */
+        public void onTouchExplorationStateChanged(boolean enabled);
+    }
+
+    /**
+     * Listener for the system high text contrast state. To listen for changes to
+     * the high text contrast state on the device, implement this interface and
+     * register it with the system by calling
+     * {@link #addHighTextContrastStateChangeListener}.
+     */
+    public interface HighTextContrastChangeListener {
+
+        /**
+         * Called when the high text contrast enabled state changes.
+         *
+         * @param enabled Whether high text contrast is enabled.
+         */
+        public void onHighTextContrastStateChanged(boolean enabled);
+    }
+
+    private final IAccessibilityManagerClient.Stub mClient =
+            new IAccessibilityManagerClient.Stub() {
+                public void setState(int state) {
+                }
+            };
+
+    /**
      * Get an AccessibilityManager instance (create one if necessary).
      *
-     * @hide
      */
     public static AccessibilityManager getInstance(Context context) {
         return sInstance;
@@ -67,7 +108,11 @@
      *
      * @param context A {@link Context}.
      */
-    private AccessibilityManager() {
+    public AccessibilityManager(Context context, IAccessibilityManager service, int userId) {
+    }
+
+    public IAccessibilityManagerClient getClient() {
+        return mClient;
     }
 
     /**
@@ -80,13 +125,28 @@
     }
 
     /**
-     * Sends an {@link AccessibilityEvent}. If this {@link AccessibilityManager} is not
-     * enabled the call is a NOOP.
+     * Returns if the touch exploration in the system is enabled.
      *
-     * @param event The {@link AccessibilityEvent}.
+     * @return True if touch exploration is enabled, false otherwise.
+     */
+    public boolean isTouchExplorationEnabled() {
+        return true;
+    }
+
+    /**
+     * Returns if the high text contrast in the system is enabled.
+     * <p>
+     * <strong>Note:</strong> You need to query this only if you application is
+     * doing its own rendering and does not rely on the platform rendering pipeline.
+     * </p>
      *
-     * @throws IllegalStateException if a client tries to send an {@link AccessibilityEvent}
-     *         while accessibility is not enabled.
+     */
+    public boolean isHighTextContrastEnabled() {
+        return false;
+    }
+
+    /**
+     * Sends an {@link AccessibilityEvent}.
      */
     public void sendAccessibilityEvent(AccessibilityEvent event) {
     }
@@ -102,20 +162,40 @@
      *
      * @return An unmodifiable list with {@link ServiceInfo}s.
      */
+    @Deprecated
     public List<ServiceInfo> getAccessibilityServiceList() {
-        // normal implementation does this in some case, so let's do the same
-        // (unmodifiableList wrapped around null).
-        List<ServiceInfo> services = null;
-        return Collections.unmodifiableList(services);
+        return Collections.emptyList();
     }
 
     public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList() {
-        // normal implementation does this in some case, so let's do the same
-        // (unmodifiableList wrapped around null).
-        List<AccessibilityServiceInfo> services = null;
-        return Collections.unmodifiableList(services);
+        return Collections.emptyList();
     }
 
+    /**
+     * Returns the {@link AccessibilityServiceInfo}s of the enabled accessibility services
+     * for a given feedback type.
+     *
+     * @param feedbackTypeFlags The feedback type flags.
+     * @return An unmodifiable list with {@link AccessibilityServiceInfo}s.
+     *
+     * @see AccessibilityServiceInfo#FEEDBACK_AUDIBLE
+     * @see AccessibilityServiceInfo#FEEDBACK_GENERIC
+     * @see AccessibilityServiceInfo#FEEDBACK_HAPTIC
+     * @see AccessibilityServiceInfo#FEEDBACK_SPOKEN
+     * @see AccessibilityServiceInfo#FEEDBACK_VISUAL
+     */
+    public List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList(
+            int feedbackTypeFlags) {
+        return Collections.emptyList();
+    }
+
+    /**
+     * Registers an {@link AccessibilityStateChangeListener} for changes in
+     * the global accessibility state of the system.
+     *
+     * @param listener The listener.
+     * @return True if successfully registered.
+     */
     public boolean addAccessibilityStateChangeListener(
             AccessibilityStateChangeListener listener) {
         return true;
@@ -126,6 +206,62 @@
         return true;
     }
 
+    /**
+     * Registers a {@link TouchExplorationStateChangeListener} for changes in
+     * the global touch exploration state of the system.
+     *
+     * @param listener The listener.
+     * @return True if successfully registered.
+     */
+    public boolean addTouchExplorationStateChangeListener(
+            @NonNull TouchExplorationStateChangeListener listener) {
+        return true;
+    }
+
+    /**
+     * Unregisters a {@link TouchExplorationStateChangeListener}.
+     *
+     * @param listener The listener.
+     * @return True if successfully unregistered.
+     */
+    public boolean removeTouchExplorationStateChangeListener(
+            @NonNull TouchExplorationStateChangeListener listener) {
+        return true;
+    }
+
+    /**
+     * Registers a {@link HighTextContrastChangeListener} for changes in
+     * the global high text contrast state of the system.
+     *
+     * @param listener The listener.
+     * @return True if successfully registered.
+     *
+     */
+    public boolean addHighTextContrastStateChangeListener(
+            @NonNull HighTextContrastChangeListener listener) {
+        return true;
+    }
+
+    /**
+     * Unregisters a {@link HighTextContrastChangeListener}.
+     *
+     * @param listener The listener.
+     * @return True if successfully unregistered.
+     *
+     */
+    public boolean removeHighTextContrastStateChangeListener(
+            @NonNull HighTextContrastChangeListener listener) {
+        return true;
+    }
+
+    /**
+     * Sets the current state and notifies listeners, if necessary.
+     *
+     * @param stateFlags The state flags.
+     */
+    private void setStateLocked(int stateFlags) {
+    }
+
     public int addAccessibilityInteractionConnection(IWindow windowToken,
             IAccessibilityInteractionConnection connection) {
         return View.NO_ID;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
index cc69af2..3d0e1e8 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -290,7 +290,7 @@
             if (log != null) {
                 log.error(LayoutLog.TAG_BROKEN,
                         "Failed to load com.android.internal.R from the layout library jar",
-                        throwable);
+                        throwable, null);
             }
             return false;
         }
@@ -418,8 +418,7 @@
             locale = "";
         }
         ULocale uLocale = new ULocale(locale);
-        return uLocale.getCharacterOrientation().equals(ICU_LOCALE_DIRECTION_RTL) ?
-                true : false;
+        return uLocale.getCharacterOrientation().equals(ICU_LOCALE_DIRECTION_RTL);
     }
 
     /**
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/AndroidLocale.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/AndroidLocale.java
index 607e628..ea5f1ea 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/AndroidLocale.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/AndroidLocale.java
@@ -33,4 +33,27 @@
     public static String toLanguageTag(Locale locale)  {
         return ULocale.forLocale(locale).toLanguageTag();
     }
+
+    public static String adjustLanguageCode(String languageCode) {
+        String adjusted = languageCode.toLowerCase(Locale.US);
+        // Map new language codes to the obsolete language
+        // codes so the correct resource bundles will be used.
+        if (languageCode.equals("he")) {
+            adjusted = "iw";
+        } else if (languageCode.equals("id")) {
+            adjusted = "in";
+        } else if (languageCode.equals("yi")) {
+            adjusted = "ji";
+        }
+
+        return adjusted;
+    }
+
+    public static Locale forLanguageTag(String tag) {
+        return ULocale.forLanguageTag(tag).toLocale();
+    }
+
+    public static String getScript(Locale locale) {
+        return ULocale.forLocale(locale).getScript();
+    }
 }
diff --git a/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java b/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java
index 71947b0..8898856 100644
--- a/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java
+++ b/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java
@@ -177,12 +177,6 @@
         return Locale.getISOCountries();
     }
 
-
-    @LayoutlibDelegate
-    /*package*/ static String localeForLanguageTag(String languageTag, boolean strict) {
-        return "";
-    }
-
     @LayoutlibDelegate
     /*package*/ static boolean initLocaleDataNative(String locale, LocaleData result) {
 
diff --git a/tools/layoutlib/bridge/tests/Android.mk b/tools/layoutlib/bridge/tests/Android.mk
index 98cade9..7a9e067 100644
--- a/tools/layoutlib/bridge/tests/Android.mk
+++ b/tools/layoutlib/bridge/tests/Android.mk
@@ -24,7 +24,13 @@
 LOCAL_MODULE := layoutlib-tests
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_JAVA_LIBRARIES := layoutlib kxml2-2.3.0 junit
+LOCAL_JAVA_LIBRARIES := layoutlib \
+			kxml2-2.3.0 \
+			icu4j \
+			layoutlib_api-prebuilt \
+			tools-common-prebuilt \
+			sdk-common \
+			junit
 
 include $(BUILD_HOST_JAVA_LIBRARY)
 
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/.gitignore b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/.gitignore
new file mode 100644
index 0000000..a2ce0dc
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/.gitignore
@@ -0,0 +1,14 @@
+.gradle
+local.properties
+.idea
+.DS_Store
+*.iml
+# We need the built .class files to load custom views and R class.
+# The only way to negate an exclusion is by including every single parent
+# and excluding all children of those parents.
+
+/build/*
+!/build/intermediates/
+
+/build/intermediates/*
+!/build/intermediates/classes/
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build.gradle b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build.gradle
new file mode 100644
index 0000000..80be12d
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build.gradle
@@ -0,0 +1,43 @@
+buildscript {
+    repositories {
+        jcenter()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:0.12.+'
+
+        // NOTE: Do not place your application dependencies here; they belong
+        // in the individual module build.gradle files
+    }
+}
+
+allprojects {
+    repositories {
+        jcenter()
+    }
+}
+
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 20
+    buildToolsVersion '20'
+    defaultConfig {
+        applicationId 'com.android.layoutlib.test.myapplication'
+        minSdkVersion 19
+        targetSdkVersion 20
+        versionCode 1
+        versionName '1.0'
+    }
+    buildTypes {
+        release {
+            runProguard false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+    productFlavors {
+    }
+}
+
+dependencies {
+    compile fileTree(dir: 'libs', include: ['*.jar'])
+}
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/BuildConfig.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/BuildConfig.class
new file mode 100644
index 0000000..2b4f7bf
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/BuildConfig.class
Binary files differ
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/MyActivity.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/MyActivity.class
new file mode 100644
index 0000000..d252462
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/MyActivity.class
Binary files differ
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$attr.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$attr.class
new file mode 100644
index 0000000..9bab801
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$attr.class
Binary files differ
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$dimen.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$dimen.class
new file mode 100644
index 0000000..7ad8605
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$dimen.class
Binary files differ
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$drawable.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$drawable.class
new file mode 100644
index 0000000..e9e0a33
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$drawable.class
Binary files differ
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$id.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$id.class
new file mode 100644
index 0000000..d109302
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$id.class
Binary files differ
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$layout.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$layout.class
new file mode 100644
index 0000000..816ecc8
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$layout.class
Binary files differ
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$menu.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$menu.class
new file mode 100644
index 0000000..b034b75
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$menu.class
Binary files differ
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$string.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$string.class
new file mode 100644
index 0000000..f86b1d3
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$string.class
Binary files differ
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$style.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$style.class
new file mode 100644
index 0000000..8bbae90
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$style.class
Binary files differ
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R.class
new file mode 100644
index 0000000..8af745d
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R.class
Binary files differ
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradle.properties b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradle.properties
new file mode 100644
index 0000000..5d08ba7
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradle.properties
@@ -0,0 +1,18 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Settings specified in this file will override any Gradle settings
+# configured through the IDE.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
\ No newline at end of file
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradle/wrapper/gradle-wrapper.jar b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradle/wrapper/gradle-wrapper.properties b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..5de946b
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradlew b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradlew.bat b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off

+@rem ##########################################################################

+@rem

+@rem  Gradle startup script for Windows

+@rem

+@rem ##########################################################################

+

+@rem Set local scope for the variables with windows NT shell

+if "%OS%"=="Windows_NT" setlocal

+

+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.

+set DEFAULT_JVM_OPTS=

+

+set DIRNAME=%~dp0

+if "%DIRNAME%" == "" set DIRNAME=.

+set APP_BASE_NAME=%~n0

+set APP_HOME=%DIRNAME%

+

+@rem Find java.exe

+if defined JAVA_HOME goto findJavaFromJavaHome

+

+set JAVA_EXE=java.exe

+%JAVA_EXE% -version >NUL 2>&1

+if "%ERRORLEVEL%" == "0" goto init

+

+echo.

+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

+echo.

+echo Please set the JAVA_HOME variable in your environment to match the

+echo location of your Java installation.

+

+goto fail

+

+:findJavaFromJavaHome

+set JAVA_HOME=%JAVA_HOME:"=%

+set JAVA_EXE=%JAVA_HOME%/bin/java.exe

+

+if exist "%JAVA_EXE%" goto init

+

+echo.

+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%

+echo.

+echo Please set the JAVA_HOME variable in your environment to match the

+echo location of your Java installation.

+

+goto fail

+

+:init

+@rem Get command-line arguments, handling Windowz variants

+

+if not "%OS%" == "Windows_NT" goto win9xME_args

+if "%@eval[2+2]" == "4" goto 4NT_args

+

+:win9xME_args

+@rem Slurp the command line arguments.

+set CMD_LINE_ARGS=

+set _SKIP=2

+

+:win9xME_args_slurp

+if "x%~1" == "x" goto execute

+

+set CMD_LINE_ARGS=%*

+goto execute

+

+:4NT_args

+@rem Get arguments from the 4NT Shell from JP Software

+set CMD_LINE_ARGS=%$

+

+:execute

+@rem Setup the command line

+

+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

+

+@rem Execute Gradle

+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

+

+:end

+@rem End local scope for the variables with windows NT shell

+if "%ERRORLEVEL%"=="0" goto mainEnd

+

+:fail

+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of

+rem the _cmd.exe /c_ return code!

+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1

+exit /b 1

+

+:mainEnd

+if "%OS%"=="Windows_NT" endlocal

+

+:omega

diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/proguard-rules.pro b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/proguard-rules.pro
new file mode 100644
index 0000000..b0fcd2d
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /usr/local/google/home/deepanshu/ssd/sdk_out/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/androidTest/java/com/android/layoulib/test/myapplication/ApplicationTest.java b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/androidTest/java/com/android/layoulib/test/myapplication/ApplicationTest.java
new file mode 100644
index 0000000..7304af1
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/androidTest/java/com/android/layoulib/test/myapplication/ApplicationTest.java
@@ -0,0 +1,13 @@
+package com.android.layoulib.test.myapplication;
+
+import android.app.Application;
+import android.test.ApplicationTestCase;
+
+/**
+ * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
+ */
+public class ApplicationTest extends ApplicationTestCase<Application> {
+    public ApplicationTest() {
+        super(Application.class);
+    }
+}
\ No newline at end of file
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/AndroidManifest.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..2067474
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/AndroidManifest.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.layoutlib.test.myapplication" >
+<!-- If changing package here, update LayoutLibCallBack in tests. -->
+    <application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:name="com.android.layoutlib.test.myapplication.MyActivity"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/java/com/android/layoutlib/test/myapplication/MyActivity.java b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/java/com/android/layoutlib/test/myapplication/MyActivity.java
new file mode 100644
index 0000000..59de457
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/java/com/android/layoutlib/test/myapplication/MyActivity.java
@@ -0,0 +1,35 @@
+package com.android.layoutlib.test.myapplication;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+
+public class MyActivity extends Activity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity);
+    }
+
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        // Inflate the menu; this adds items to the action bar if it is present.
+        getMenuInflater().inflate(R.menu.my, menu);
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        // Handle action bar item clicks here. The action bar will
+        // automatically handle clicks on the Home/Up button, so long
+        // as you specify a parent activity in AndroidManifest.xml.
+        int id = item.getItemId();
+        if (id == R.id.action_settings) {
+            return true;
+        }
+        return super.onOptionsItemSelected(item);
+    }
+}
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/drawable/ic_launcher.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/drawable/ic_launcher.xml
new file mode 100644
index 0000000..67481d4
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/drawable/ic_launcher.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+    <solid android:color="#ff0000" />
+    <size
+        android:width="20dp"
+        android:height="20dp" />
+</shape>
\ No newline at end of file
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/activity.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/activity.xml
new file mode 100644
index 0000000..97d1983
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/activity.xml
@@ -0,0 +1,21 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    tools:context=".MyActivity">
+
+    <TextView
+        android:text="@string/hello_world"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:id="@+id/text1"/>
+
+    <include layout="@layout/layout"
+        android:layout_below="@+id/text1"
+        android:layout_height="wrap_content"
+        android:layout_width="wrap_content" />
+</RelativeLayout>
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/layout.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/layout.xml
new file mode 100644
index 0000000..2704c07
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/layout.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical" android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="Some text"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/menu/my.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/menu/my.xml
new file mode 100644
index 0000000..bea58cc
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/menu/my.xml
@@ -0,0 +1,8 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:context=".MyActivity" >
+    <item android:id="@+id/action_settings"
+        android:title="@string/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never" />
+</menu>
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/values/dimens.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..47c8224
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/values/dimens.xml
@@ -0,0 +1,5 @@
+<resources>
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="activity_horizontal_margin">16dp</dimen>
+    <dimen name="activity_vertical_margin">16dp</dimen>
+</resources>
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/values/strings.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/values/strings.xml
new file mode 100644
index 0000000..2b7083b
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/values/strings.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="app_name">My Application</string>
+    <string name="hello_world">Hello world!</string>
+    <string name="action_settings">Settings</string>
+
+</resources>
diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/values/styles.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/values/styles.xml
new file mode 100644
index 0000000..ff6c9d2
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/values/styles.xml
@@ -0,0 +1,8 @@
+<resources>
+
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+        <!-- Customize your theme here. -->
+    </style>
+
+</resources>
diff --git a/tools/layoutlib/bridge/tests/src/android/graphics/Matrix_DelegateTest.java b/tools/layoutlib/bridge/tests/src/android/graphics/Matrix_DelegateTest.java
index ec4edac..d20fb14 100644
--- a/tools/layoutlib/bridge/tests/src/android/graphics/Matrix_DelegateTest.java
+++ b/tools/layoutlib/bridge/tests/src/android/graphics/Matrix_DelegateTest.java
@@ -23,16 +23,6 @@
  */
 public class Matrix_DelegateTest extends TestCase {
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
     public void testIdentity() {
         Matrix m1 = new Matrix();
 
diff --git a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParserTest.java b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParserTest.java
index 865a008..92fcf90 100644
--- a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParserTest.java
+++ b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParserTest.java
@@ -24,17 +24,6 @@
 import junit.framework.TestCase;
 
 public class BridgeXmlBlockParserTest extends TestCase {
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
     public void testXmlBlockParser() throws Exception {
 
         XmlPullParser parser = ParserFactory.create(
diff --git a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java
new file mode 100644
index 0000000..4af07dd
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java
@@ -0,0 +1,325 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.layoutlib.bridge.intensive;
+
+import com.android.annotations.NonNull;
+import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.RenderSession;
+import com.android.ide.common.rendering.api.Result;
+import com.android.ide.common.rendering.api.SessionParams;
+import com.android.ide.common.rendering.api.SessionParams.RenderingMode;
+import com.android.ide.common.resources.FrameworkResources;
+import com.android.ide.common.resources.ResourceItem;
+import com.android.ide.common.resources.ResourceRepository;
+import com.android.ide.common.resources.ResourceResolver;
+import com.android.ide.common.resources.configuration.FolderConfiguration;
+import com.android.io.FolderWrapper;
+import com.android.layoutlib.bridge.Bridge;
+import com.android.layoutlib.bridge.intensive.setup.ConfigGenerator;
+import com.android.layoutlib.bridge.intensive.setup.LayoutLibTestCallback;
+import com.android.layoutlib.bridge.intensive.setup.LayoutPullParser;
+import com.android.utils.ILogger;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Comparator;
+
+import static org.junit.Assert.fail;
+
+/**
+ * This is a set of tests that loads all the framework resources and a project checked in this
+ * test's resources. The main dependencies
+ * are:
+ * 1. Fonts directory.
+ * 2. Framework Resources.
+ * 3. App resources.
+ * 4. build.prop file
+ *
+ * These are configured by two variables set in the system properties.
+ *
+ * 1. platform.dir: This is the directory for the current platform in the built SDK
+ *     (.../sdk/platforms/android-<version>).
+ *
+ *     The fonts are platform.dir/data/fonts.
+ *     The Framework resources are platform.dir/data/res.
+ *     build.prop is at platform.dir/build.prop.
+ *
+ * 2. test_res.dir: This is the directory for the resources of the test. If not specified, this
+ *     falls back to getClass().getProtectionDomain().getCodeSource().getLocation()
+ *
+ *     The app resources are at: test_res.dir/testApp/MyApplication/app/src/main/res
+ */
+public class Main {
+
+    private static final String PLATFORM_DIR_PROPERTY = "platform.dir";
+    private static final String RESOURCE_DIR_PROPERTY = "test_res.dir";
+
+    private static final String PLATFORM_DIR;
+    private static final String TEST_RES_DIR;
+    private static final String APP_TEST_RES = "/testApp/MyApplication/src/main/res";
+
+    private LayoutLog mLayoutLibLog;
+    private FrameworkResources mFrameworkRepo;
+    private ResourceRepository mProjectResources;
+    private ILogger mLogger;
+    private Bridge mBridge;
+
+    static {
+        // Test that System Properties are properly set.
+        PLATFORM_DIR = getPlatformDir();
+        if (PLATFORM_DIR == null) {
+            fail(String.format("System Property %1$s not properly set. The value is %2$s",
+                    PLATFORM_DIR_PROPERTY, System.getProperty(PLATFORM_DIR_PROPERTY)));
+        }
+
+        TEST_RES_DIR = getTestResDir();
+        if (TEST_RES_DIR == null) {
+            fail(String.format("System property %1$s.dir not properly set. The value is %2$s",
+                    RESOURCE_DIR_PROPERTY, System.getProperty(RESOURCE_DIR_PROPERTY)));
+        }
+    }
+
+    private static String getPlatformDir() {
+        String platformDir = System.getProperty(PLATFORM_DIR_PROPERTY);
+        if (platformDir != null && !platformDir.isEmpty() && new File(platformDir).isDirectory()) {
+            return platformDir;
+        }
+        // System Property not set. Try to find the directory in the build directory.
+        String out = System.getenv("ANDROID_HOST_OUT");
+        if (out == null || out.isEmpty() || !new File(out).isDirectory()) {
+            // Can't find the out directory.
+            return null;
+        }
+        File sdkDir = new File(out, "sdk" + File.separator + "sdk");
+        if (!sdkDir.isDirectory()) {
+            // The directory we thought that should contain the sdk is not a directory.
+            return null;
+        }
+        File[] possibleSdks = sdkDir.listFiles(new FileFilter() {
+            @Override
+            public boolean accept(File pathname) {
+                return pathname.isDirectory() && pathname.getAbsolutePath().contains("android-sdk");
+            }
+        });
+        for (File possibleSdk : possibleSdks) {
+            File platformsDir = new File(possibleSdk, "platforms");
+            File[] platforms = platformsDir.listFiles(new FileFilter() {
+                @Override
+                public boolean accept(File pathname) {
+                    return pathname.isDirectory()
+                            && pathname.toPath().getFileName().toString().startsWith("android-");
+                }
+            });
+            if (platforms == null || platforms.length == 0) {
+                continue;
+            }
+            Arrays.sort(platforms, new Comparator<File>() {
+                // Codenames before ints. Higher APIs precede lower.
+                @Override
+                public int compare(File o1, File o2) {
+                    final int MAX_VALUE = 1000;
+                    String suffix1 = o1.toPath().getFileName().toString()
+                            .substring("android-".length());
+                    String suffix2 = o2.toPath().getFileName().toString()
+                            .substring("android-".length());
+                    int suff1, suff2;
+                    try {
+                        suff1 = Integer.parseInt(suffix1);
+                    } catch (NumberFormatException e) {
+                        suff1 = MAX_VALUE;
+                    }
+                    try {
+                        suff2 = Integer.parseInt(suffix2);
+                    } catch (NumberFormatException e) {
+                        suff2 = MAX_VALUE;
+                    }
+                    if (suff1 != MAX_VALUE || suff2 != MAX_VALUE) {
+                        return suff2 - suff1;
+                    }
+                    return suffix2.compareTo(suffix1);
+                }
+            });
+            return platforms[0].getAbsolutePath();
+        }
+        return null;
+    }
+
+    private static String getTestResDir() {
+        String resourceDir = System.getProperty(RESOURCE_DIR_PROPERTY);
+        if (resourceDir != null && !resourceDir.isEmpty() && new File(resourceDir).isDirectory()) {
+            return resourceDir;
+        }
+        // TEST_RES_DIR not explicitly set. Fallback to the class's source location.
+        try {
+            URL location = Main.class.getProtectionDomain().getCodeSource().getLocation();
+            return new File(location.getPath()).exists() ? location.getPath() : null;
+        } catch (NullPointerException e) {
+            // Prevent a lot of null checks by just catching the exception.
+            return null;
+        }
+    }
+    /**
+     * Initialize the bridge and the resource maps.
+     */
+    @Before
+    public void setUp() {
+        File data_dir = new File(PLATFORM_DIR, "data");
+        File res = new File(data_dir, "res");
+        mFrameworkRepo = new FrameworkResources(new FolderWrapper(res));
+        mFrameworkRepo.loadResources();
+        mFrameworkRepo.loadPublicResources(getLogger());
+
+        mProjectResources =
+                new ResourceRepository(new FolderWrapper(TEST_RES_DIR + APP_TEST_RES), false) {
+            @NonNull
+            @Override
+            protected ResourceItem createResourceItem(String name) {
+                return new ResourceItem(name);
+            }
+        };
+        mProjectResources.loadResources();
+
+        File fontLocation = new File(data_dir, "fonts");
+        File buildProp = new File(PLATFORM_DIR, "build.prop");
+        File attrs = new File(res, "values" + File.separator + "attrs.xml");
+        mBridge = new Bridge();
+        mBridge.init(ConfigGenerator.loadProperties(buildProp), fontLocation,
+                ConfigGenerator.getEnumMap(attrs), getLayoutLog());
+    }
+
+    /**
+     * Create a new rendering session and test that rendering /layout/activity.xml on nexus 5
+     * doesn't throw any exceptions.
+     */
+    @Test
+    public void testRendering() throws ClassNotFoundException {
+        // Create the layout pull parser.
+        LayoutPullParser parser = new LayoutPullParser(APP_TEST_RES + "/layout/activity.xml");
+        // Create LayoutLibCallback.
+        LayoutLibTestCallback layoutLibCallback = new LayoutLibTestCallback(getLogger());
+        layoutLibCallback.initResources();
+        // TODO: Set up action bar handler properly to test menu rendering.
+        // Create session params.
+        SessionParams params = getSessionParams(parser, ConfigGenerator.NEXUS_5, layoutLibCallback);
+        RenderSession session = mBridge.createSession(params);
+        if (!session.getResult().isSuccess()) {
+            getLogger().error(session.getResult().getException(),
+                    session.getResult().getErrorMessage());
+        }
+        // Render the session with a timeout of 50s.
+        Result renderResult = session.render(50000);
+        if (!renderResult.isSuccess()) {
+            getLogger().error(session.getResult().getException(),
+                    session.getResult().getErrorMessage());
+        }
+    }
+
+    /**
+     * Uses Theme.Material and Target sdk version as 21.
+     */
+    private SessionParams getSessionParams(LayoutPullParser layoutParser,
+            ConfigGenerator configGenerator, LayoutLibTestCallback layoutLibCallback) {
+        FolderConfiguration config = configGenerator.getFolderConfig();
+        ResourceResolver resourceResolver =
+                ResourceResolver.create(mProjectResources.getConfiguredResources(config),
+                        mFrameworkRepo.getConfiguredResources(config), "Theme.Material", false);
+
+        return new SessionParams(
+                layoutParser,
+                RenderingMode.NORMAL,
+                null /*used for caching*/,
+                configGenerator.getHardwareConfig(),
+                resourceResolver,
+                layoutLibCallback,
+                0,
+                21, // TODO: Make it more configurable to run tests for various versions.
+                getLayoutLog());
+    }
+
+    private LayoutLog getLayoutLog() {
+        if (mLayoutLibLog == null) {
+            mLayoutLibLog = new LayoutLog() {
+                @Override
+                public void warning(String tag, String message, Object data) {
+                    System.out.println("Warning " + tag + ": " + message);
+                    fail(message);
+                }
+
+                @Override
+                public void fidelityWarning(String tag, String message, Throwable throwable,
+                        Object data) {
+                    System.out.println("FidelityWarning " + tag + ": " + message);
+                    if (throwable != null) {
+                        throwable.printStackTrace();
+                    }
+                    fail(message);
+                }
+
+                @Override
+                public void error(String tag, String message, Object data) {
+                    System.out.println("Error " + tag + ": " + message);
+                    fail(message);
+                }
+
+                @Override
+                public void error(String tag, String message, Throwable throwable, Object data) {
+                    System.out.println("Error " + tag + ": " + message);
+                    if (throwable != null) {
+                        throwable.printStackTrace();
+                    }
+                    fail(message);
+                }
+            };
+        }
+        return mLayoutLibLog;
+    }
+
+    private ILogger getLogger() {
+        if (mLogger == null) {
+            mLogger = new ILogger() {
+                @Override
+                public void error(Throwable t, String msgFormat, Object... args) {
+                    if (t != null) {
+                        t.printStackTrace();
+                    }
+                    fail(String.format(msgFormat, args));
+                }
+
+                @Override
+                public void warning(String msgFormat, Object... args) {
+                    fail(String.format(msgFormat, args));
+                }
+
+                @Override
+                public void info(String msgFormat, Object... args) {
+                    // pass.
+                }
+
+                @Override
+                public void verbose(String msgFormat, Object... args) {
+                    // pass.
+                }
+            };
+        }
+        return mLogger;
+    }
+}
diff --git a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/setup/ConfigGenerator.java b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/setup/ConfigGenerator.java
new file mode 100644
index 0000000..a5c3202
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/setup/ConfigGenerator.java
@@ -0,0 +1,294 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.layoutlib.bridge.intensive.setup;
+
+import com.android.ide.common.rendering.api.HardwareConfig;
+import com.android.ide.common.resources.configuration.CountryCodeQualifier;
+import com.android.ide.common.resources.configuration.DensityQualifier;
+import com.android.ide.common.resources.configuration.FolderConfiguration;
+import com.android.ide.common.resources.configuration.KeyboardStateQualifier;
+import com.android.ide.common.resources.configuration.LanguageQualifier;
+import com.android.ide.common.resources.configuration.LayoutDirectionQualifier;
+import com.android.ide.common.resources.configuration.NavigationMethodQualifier;
+import com.android.ide.common.resources.configuration.NetworkCodeQualifier;
+import com.android.ide.common.resources.configuration.NightModeQualifier;
+import com.android.ide.common.resources.configuration.RegionQualifier;
+import com.android.ide.common.resources.configuration.ScreenDimensionQualifier;
+import com.android.ide.common.resources.configuration.ScreenOrientationQualifier;
+import com.android.ide.common.resources.configuration.ScreenRatioQualifier;
+import com.android.ide.common.resources.configuration.ScreenSizeQualifier;
+import com.android.ide.common.resources.configuration.TextInputMethodQualifier;
+import com.android.ide.common.resources.configuration.TouchScreenQualifier;
+import com.android.ide.common.resources.configuration.UiModeQualifier;
+import com.android.ide.common.resources.configuration.VersionQualifier;
+import com.android.resources.Density;
+import com.android.resources.Keyboard;
+import com.android.resources.KeyboardState;
+import com.android.resources.Navigation;
+import com.android.resources.NightMode;
+import com.android.resources.ScreenOrientation;
+import com.android.resources.ScreenRatio;
+import com.android.resources.ScreenSize;
+import com.android.resources.TouchScreen;
+import com.android.resources.UiMode;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+
+import com.google.android.collect.Maps;
+
+/**
+ * Provides {@link FolderConfiguration} and {@link HardwareConfig} for various devices. Also
+ * provides utility methods to parse build.prop and attrs.xml to generate the appropriate maps.
+ */
+@SuppressWarnings("UnusedDeclaration") // For the pre-configured nexus generators.
+public class ConfigGenerator {
+
+    public static final ConfigGenerator NEXUS_4 = new ConfigGenerator();
+
+    public static final ConfigGenerator NEXUS_5 = new ConfigGenerator()
+                                                        .setScreenHeight(1920)
+                                                        .setScreenWidth(1080)
+                                                        .setXdpi(445)
+                                                        .setYdpi(445)
+                                                        .setOrientation(ScreenOrientation.PORTRAIT)
+                                                        .setDensity(Density.XXHIGH)
+                                                        .setRatio(ScreenRatio.NOTLONG)
+                                                        .setSize(ScreenSize.NORMAL)
+                                                        .setKeyboard(Keyboard.NOKEY)
+                                                        .setTouchScreen(TouchScreen.FINGER)
+                                                        .setKeyboardState(KeyboardState.SOFT)
+                                                        .setSoftButtons(true)
+                                                        .setNavigation(Navigation.NONAV);
+
+    public static final ConfigGenerator NEXUS_7 = new ConfigGenerator()
+                                                        .setScreenHeight(1920)
+                                                        .setScreenWidth(1200)
+                                                        .setXdpi(323)
+                                                        .setYdpi(323)
+                                                        .setOrientation(ScreenOrientation.PORTRAIT)
+                                                        .setDensity(Density.XHIGH)
+                                                        .setRatio(ScreenRatio.NOTLONG)
+                                                        .setSize(ScreenSize.LARGE)
+                                                        .setKeyboard(Keyboard.NOKEY)
+                                                        .setTouchScreen(TouchScreen.FINGER)
+                                                        .setKeyboardState(KeyboardState.SOFT)
+                                                        .setSoftButtons(true)
+                                                        .setNavigation(Navigation.NONAV);
+
+    public static final ConfigGenerator NEXUS_10 = new ConfigGenerator()
+                                                        .setScreenHeight(1600)
+                                                        .setScreenWidth(2560)
+                                                        .setXdpi(300)
+                                                        .setYdpi(300)
+                                                        .setOrientation(ScreenOrientation.LANDSCAPE)
+                                                        .setDensity(Density.XHIGH)
+                                                        .setRatio(ScreenRatio.NOTLONG)
+                                                        .setSize(ScreenSize.XLARGE)
+                                                        .setKeyboard(Keyboard.NOKEY)
+                                                        .setTouchScreen(TouchScreen.FINGER)
+                                                        .setKeyboardState(KeyboardState.SOFT)
+                                                        .setSoftButtons(true)
+                                                        .setNavigation(Navigation.NONAV);
+
+    private static final String TAG_ATTR = "attr";
+    private static final String TAG_ENUM = "enum";
+    private static final String TAG_FLAG = "flag";
+    private static final String ATTR_NAME = "name";
+    private static final String ATTR_VALUE = "value";
+
+    // Device Configuration. Defaults are for a Nexus 4 device.
+    private int mScreenHeight = 1280;
+    private int mScreenWidth = 768;
+    private int mXdpi = 320;
+    private int mYdpi = 320;
+    private ScreenOrientation mOrientation = ScreenOrientation.PORTRAIT;
+    private Density mDensity = Density.XHIGH;
+    private ScreenRatio mRatio = ScreenRatio.NOTLONG;
+    private ScreenSize mSize = ScreenSize.NORMAL;
+    private Keyboard mKeyboard = Keyboard.NOKEY;
+    private TouchScreen mTouchScreen = TouchScreen.FINGER;
+    private KeyboardState mKeyboardState = KeyboardState.SOFT;
+    private boolean mSoftButtons = true;
+    private Navigation mNavigation = Navigation.NONAV;
+
+    public FolderConfiguration getFolderConfig() {
+        FolderConfiguration config = new FolderConfiguration();
+        config.createDefault();
+        config.setDensityQualifier(new DensityQualifier(mDensity));
+        config.setNavigationMethodQualifier(new NavigationMethodQualifier(mNavigation));
+        if (mScreenWidth > mScreenHeight) {
+            config.setScreenDimensionQualifier(new ScreenDimensionQualifier(mScreenWidth,
+                    mScreenHeight));
+        } else {
+            config.setScreenDimensionQualifier(new ScreenDimensionQualifier(mScreenHeight,
+                    mScreenWidth));
+        }
+        config.setScreenRatioQualifier(new ScreenRatioQualifier(mRatio));
+        config.setScreenSizeQualifier(new ScreenSizeQualifier(mSize));
+        config.setTextInputMethodQualifier(new TextInputMethodQualifier(mKeyboard));
+        config.setTouchTypeQualifier(new TouchScreenQualifier(mTouchScreen));
+        config.setKeyboardStateQualifier(new KeyboardStateQualifier(mKeyboardState));
+        config.setScreenOrientationQualifier(new ScreenOrientationQualifier(mOrientation));
+
+        config.updateScreenWidthAndHeight();
+
+        // some default qualifiers.
+        config.setUiModeQualifier(new UiModeQualifier(UiMode.NORMAL));
+        config.setNightModeQualifier(new NightModeQualifier(NightMode.NOTNIGHT));
+        config.setCountryCodeQualifier(new CountryCodeQualifier());
+        config.setLanguageQualifier(new LanguageQualifier());
+        config.setLayoutDirectionQualifier(new LayoutDirectionQualifier());
+        config.setNetworkCodeQualifier(new NetworkCodeQualifier());
+        config.setRegionQualifier(new RegionQualifier());
+        config.setVersionQualifier(new VersionQualifier());
+        return config;
+    }
+
+    public HardwareConfig getHardwareConfig() {
+        return new HardwareConfig(mScreenWidth, mScreenHeight, mDensity, mXdpi, mYdpi, mSize,
+                mOrientation, mSoftButtons);
+    }
+
+    public static Map<String, String> loadProperties(File path) {
+        Properties p = new Properties();
+        Map<String, String> map = Maps.newHashMap();
+        try {
+            p.load(new FileInputStream(path));
+            for (String key : p.stringPropertyNames()) {
+                map.put(key, p.getProperty(key));
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return map;
+    }
+
+    public static Map<String, Map<String, Integer>> getEnumMap(File path) {
+        Map<String, Map<String, Integer>> map = Maps.newHashMap();
+        try {
+            XmlPullParser xmlPullParser = XmlPullParserFactory.newInstance().newPullParser();
+            xmlPullParser.setInput(new FileInputStream(path), null);
+            int eventType = xmlPullParser.getEventType();
+            String attr = null;
+            while (eventType != XmlPullParser.END_DOCUMENT) {
+                if (eventType == XmlPullParser.START_TAG) {
+                    if (TAG_ATTR.equals(xmlPullParser.getName())) {
+                        attr = xmlPullParser.getAttributeValue(null, ATTR_NAME);
+                    } else if (TAG_ENUM.equals(xmlPullParser.getName())
+                            || TAG_FLAG.equals(xmlPullParser.getName())) {
+                        String name = xmlPullParser.getAttributeValue(null, ATTR_NAME);
+                        String value = xmlPullParser.getAttributeValue(null, ATTR_VALUE);
+                        // Integer.decode cannot handle "ffffffff", see JDK issue 6624867
+                        int i = (int) (long) Long.decode(value);
+                        assert attr != null;
+                        Map<String, Integer> attributeMap = map.get(attr);
+                        if (attributeMap == null) {
+                            attributeMap = Maps.newHashMap();
+                            map.put(attr, attributeMap);
+                        }
+                        attributeMap.put(name, i);
+                    }
+                } else if (eventType == XmlPullParser.END_TAG) {
+                    if (TAG_ATTR.equals(xmlPullParser.getName())) {
+                        attr = null;
+                    }
+                }
+                eventType = xmlPullParser.next();
+            }
+        } catch (XmlPullParserException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return map;
+    }
+
+    // Methods to set the configuration values.
+
+    public ConfigGenerator setScreenHeight(int height) {
+        mScreenHeight = height;
+        return this;
+    }
+
+    public ConfigGenerator setScreenWidth(int width) {
+        mScreenWidth = width;
+        return this;
+    }
+
+    public ConfigGenerator setXdpi(int xdpi) {
+        mXdpi = xdpi;
+        return this;
+    }
+
+    public ConfigGenerator setYdpi(int ydpi) {
+        mYdpi = ydpi;
+        return this;
+    }
+
+    public ConfigGenerator setOrientation(ScreenOrientation orientation) {
+        mOrientation = orientation;
+        return this;
+    }
+
+    public ConfigGenerator setDensity(Density density) {
+        mDensity = density;
+        return this;
+    }
+
+    public ConfigGenerator setRatio(ScreenRatio ratio) {
+        mRatio = ratio;
+        return this;
+    }
+
+    public ConfigGenerator setSize(ScreenSize size) {
+        mSize = size;
+        return this;
+    }
+
+    public ConfigGenerator setKeyboard(Keyboard keyboard) {
+        mKeyboard = keyboard;
+        return this;
+    }
+
+    public ConfigGenerator setTouchScreen(TouchScreen touchScreen) {
+        mTouchScreen = touchScreen;
+        return this;
+    }
+
+    public ConfigGenerator setKeyboardState(KeyboardState state) {
+        mKeyboardState = state;
+        return this;
+    }
+
+    public ConfigGenerator setSoftButtons(boolean softButtons) {
+        mSoftButtons = softButtons;
+        return this;
+    }
+
+    public ConfigGenerator setNavigation(Navigation navigation) {
+        mNavigation = navigation;
+        return this;
+    }
+}
diff --git a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/setup/LayoutLibTestCallback.java b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/setup/LayoutLibTestCallback.java
new file mode 100644
index 0000000..565e881
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/setup/LayoutLibTestCallback.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.layoutlib.bridge.intensive.setup;
+
+import com.android.SdkConstants;
+import com.android.ide.common.rendering.api.ActionBarCallback;
+import com.android.ide.common.rendering.api.AdapterBinding;
+import com.android.ide.common.rendering.api.ILayoutPullParser;
+import com.android.ide.common.rendering.api.IProjectCallback;
+import com.android.ide.common.rendering.api.ResourceReference;
+import com.android.ide.common.rendering.api.ResourceValue;
+import com.android.resources.ResourceType;
+import com.android.ide.common.resources.IntArrayWrapper;
+import com.android.util.Pair;
+import com.android.utils.ILogger;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.Map;
+
+import com.google.android.collect.Maps;
+
+@SuppressWarnings("deprecation") // For Pair
+public class LayoutLibTestCallback extends ClassLoader implements IProjectCallback {
+
+    private static final String PROJECT_CLASSES_LOCATION = "/testApp/MyApplication/build/intermediates/classes/debug/";
+    private static final String PACKAGE_NAME = "com.android.layoutlib.test.myapplication";
+
+    private final Map<Integer, Pair<ResourceType, String>> mProjectResources = Maps.newHashMap();
+    private final Map<IntArrayWrapper, String> mStyleableValueToNameMap = Maps.newHashMap();
+    private final Map<ResourceType, Map<String, Integer>> mResources = Maps.newHashMap();
+    private final Map<String, Class<?>> mClasses = Maps.newHashMap();
+    private final ILogger mLog;
+    private final ActionBarCallback mActionBarCallback = new ActionBarCallback();
+
+    public LayoutLibTestCallback(ILogger logger) {
+        mLog = logger;
+    }
+
+    public void initResources() throws ClassNotFoundException {
+        Class<?> rClass = loadClass(PACKAGE_NAME + ".R");
+        Class<?>[] nestedClasses = rClass.getDeclaredClasses();
+        for (Class<?> resClass : nestedClasses) {
+            final ResourceType resType = ResourceType.getEnum(resClass.getSimpleName());
+
+            if (resType != null) {
+                final Map<String, Integer> resName2Id = Maps.newHashMap();
+                mResources.put(resType, resName2Id);
+
+                for (Field field : resClass.getDeclaredFields()) {
+                    final int modifiers = field.getModifiers();
+                    if (Modifier.isStatic(modifiers)) { // May not be final in library projects
+                        final Class<?> type = field.getType();
+                        try {
+                            if (type.isArray() && type.getComponentType() == int.class) {
+                                mStyleableValueToNameMap.put(
+                                        new IntArrayWrapper((int[]) field.get(null)),
+                                        field.getName());
+                            } else if (type == int.class) {
+                                final Integer value = (Integer) field.get(null);
+                                mProjectResources.put(value, Pair.of(resType, field.getName()));
+                                resName2Id.put(field.getName(), value);
+                            } else {
+                                mLog.error(null, "Unknown field type in R class: %1$s", type);
+                            }
+                        } catch (IllegalAccessException ignored) {
+                            mLog.error(ignored, "Malformed R class: %1$s", PACKAGE_NAME + ".R");
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    protected Class<?> findClass(String name) throws ClassNotFoundException {
+        Class<?> aClass = mClasses.get(name);
+        if (aClass != null) {
+            return aClass;
+        }
+        String pathName = PROJECT_CLASSES_LOCATION.concat(name.replace('.', '/')).concat(".class");
+        InputStream classInputStream = getClass().getResourceAsStream(pathName);
+        if (classInputStream == null) {
+            throw new ClassNotFoundException("Unable to find class " + name + " at " + pathName);
+        }
+        byte[] data;
+        try {
+            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+            int nRead;
+            data = new byte[16384];
+            while ((nRead = classInputStream.read(data, 0, data.length)) != -1) {
+                buffer.write(data, 0, nRead);
+            }
+            buffer.flush();
+            data = buffer.toByteArray();
+        } catch (IOException e) {
+            // Wrap the exception with ClassNotFoundException so that caller can deal with it.
+            throw new ClassNotFoundException("Unable to load class " + name, e);
+        }
+        aClass = defineClass(name, data, 0, data.length);
+        mClasses.put(name, aClass);
+        return aClass;
+    }
+
+    @Override
+    public Object loadView(String name, Class[] constructorSignature, Object[] constructorArgs)
+            throws Exception {
+        Class<?> viewClass = findClass(name);
+        Constructor<?> viewConstructor = viewClass.getConstructor(constructorSignature);
+        viewConstructor.setAccessible(true);
+        return viewConstructor.newInstance(constructorArgs);
+    }
+
+    @Override
+    public String getNamespace() {
+        return String.format(SdkConstants.NS_CUSTOM_RESOURCES_S,
+                PACKAGE_NAME);
+    }
+
+    @Override
+    public Pair<ResourceType, String> resolveResourceId(int id) {
+        return mProjectResources.get(id);
+    }
+
+    @Override
+    public String resolveResourceId(int[] id) {
+        return mStyleableValueToNameMap.get(new IntArrayWrapper(id));
+    }
+
+    @Override
+    public Integer getResourceId(ResourceType type, String name) {
+        return mResources.get(type).get(name);
+    }
+
+    @Override
+    public ILayoutPullParser getParser(String layoutName) {
+        org.junit.Assert.fail("This method shouldn't be called by this version of LayoutLib.");
+        return null;
+    }
+
+    @Override
+    public ILayoutPullParser getParser(ResourceValue layoutResource) {
+        return new LayoutPullParser(new File(layoutResource.getValue()));
+    }
+
+    @Override
+    public Object getAdapterItemValue(ResourceReference adapterView, Object adapterCookie,
+            ResourceReference itemRef, int fullPosition, int positionPerType,
+            int fullParentPosition, int parentPositionPerType, ResourceReference viewRef,
+            ViewAttribute viewAttribute, Object defaultValue) {
+        return null;
+    }
+
+    @Override
+    public AdapterBinding getAdapterBinding(ResourceReference adapterViewRef, Object adapterCookie,
+            Object viewObject) {
+        return null;
+    }
+
+    @Override
+    public ActionBarCallback getActionBarCallback() {
+        return mActionBarCallback;
+    }
+}
diff --git a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/setup/LayoutPullParser.java b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/setup/LayoutPullParser.java
new file mode 100644
index 0000000..c79b662
--- /dev/null
+++ b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/setup/LayoutPullParser.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.layoutlib.bridge.intensive.setup;
+
+import com.android.ide.common.rendering.api.ILayoutPullParser;
+
+import org.kxml2.io.KXmlParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOError;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import static com.android.SdkConstants.ATTR_IGNORE;
+import static com.android.SdkConstants.EXPANDABLE_LIST_VIEW;
+import static com.android.SdkConstants.GRID_VIEW;
+import static com.android.SdkConstants.LIST_VIEW;
+import static com.android.SdkConstants.SPINNER;
+import static com.android.SdkConstants.TOOLS_URI;
+
+public class LayoutPullParser extends KXmlParser implements ILayoutPullParser{
+
+    /**
+     * @param layoutPath Must start with '/' and be relative to test resources.
+     */
+    public LayoutPullParser(String layoutPath) {
+        assert layoutPath.startsWith("/");
+        try {
+            init(getClass().getResourceAsStream(layoutPath));
+        } catch (XmlPullParserException e) {
+            throw new IOError(e);
+        }
+    }
+
+    /**
+     * @param layoutFile Path of the layout xml file on disk.
+     */
+    public LayoutPullParser(File layoutFile) {
+        try {
+            init(new FileInputStream(layoutFile));
+        } catch (XmlPullParserException e) {
+            throw new IOError(e);
+        } catch (FileNotFoundException e) {
+            throw new IOError(e);
+        }
+    }
+
+    private void init(InputStream stream) throws XmlPullParserException {
+        setFeature(FEATURE_PROCESS_NAMESPACES, true);
+        setInput(stream, null);
+    }
+
+    @Override
+    public Object getViewCookie() {
+        // TODO: Implement this properly.
+        String name = super.getName();
+        if (name == null) {
+            return null;
+        }
+
+        // Store tools attributes if this looks like a layout we'll need adapter view
+        // bindings for in the LayoutlibCallback.
+        if (LIST_VIEW.equals(name) || EXPANDABLE_LIST_VIEW.equals(name) || GRID_VIEW.equals(name) || SPINNER.equals(name)) {
+            Map<String, String> map = null;
+            int count = getAttributeCount();
+            for (int i = 0; i < count; i++) {
+                String namespace = getAttributeNamespace(i);
+                if (namespace != null && namespace.equals(TOOLS_URI)) {
+                    String attribute = getAttributeName(i);
+                    if (attribute.equals(ATTR_IGNORE)) {
+                        continue;
+                    }
+                    if (map == null) {
+                        map = new HashMap<String, String>(4);
+                    }
+                    map.put(attribute, getAttributeValue(i));
+                }
+            }
+
+            return map;
+        }
+
+        return null;
+    }
+
+    @Override
+    @Deprecated
+    public ILayoutPullParser getParser(String layoutName) {
+        // Studio returns null.
+        return null;
+    }
+
+}
diff --git a/tools/layoutlib/create/create.iml b/tools/layoutlib/create/create.iml
new file mode 100644
index 0000000..b7e8eb3
--- /dev/null
+++ b/tools/layoutlib/create/create.iml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/tests/data" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/tests/mock_data" type="java-test-resource" />
+      <excludeFolder url="file://$MODULE_DIR$/.settings" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="asm-4.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="JUnit4" level="application" />
+  </component>
+</module>
+
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AbstractClassAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AbstractClassAdapter.java
index 323a791..a6902a4 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AbstractClassAdapter.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AbstractClassAdapter.java
@@ -97,7 +97,7 @@
         if (type.getSort() == Type.OBJECT) {
             String in = type.getInternalName();
             String newIn = renameInternalType(in);
-            if (newIn != in) {
+            if (!newIn.equals(in)) {
                 return Type.getType("L" + newIn + ";");
             }
         } else if (type.getSort() == Type.ARRAY) {
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java
index e043d4d..9a10f79 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java
@@ -341,6 +341,7 @@
                     inOutKeepClasses.size(), deps.size());
 
             for (ClassReader cr : temp.values()) {
+                visitor.setClassName(cr.getClassName());
                 cr.accept(visitor, 0 /* flags */);
             }
         }
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DependencyFinder.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DependencyFinder.java
index 2016c0e..7690fcd 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DependencyFinder.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DependencyFinder.java
@@ -316,9 +316,7 @@
 
             // Add it to the dependency set for the currently visited class, as needed.
             assert mCurrentDepSet != null;
-            if (mCurrentDepSet != null) {
-                mCurrentDepSet.add(className);
-            }
+            mCurrentDepSet.add(className);
         }
 
         /**
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
index ea9ce10..02f2c02 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
@@ -63,7 +63,7 @@
         String[] osDestJar = { null };
 
         if (!processArgs(log, args, osJarPath, osDestJar)) {
-            log.error("Usage: layoutlib_create [-v] [-p] output.jar input.jar ...");
+            log.error("Usage: layoutlib_create [-v] output.jar input.jar ...");
             log.error("Usage: layoutlib_create [-v] [--list-deps|--missing-deps] input.jar ...");
             System.exit(1);
         }
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/OverrideMethod.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/OverrideMethod.java
index a6aff99..4c87b3c 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/OverrideMethod.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/OverrideMethod.java
@@ -36,6 +36,7 @@
      * Sets the default listener for all methods not specifically handled.
      * Null means to do nothing.
      */
+    @SuppressWarnings("UnusedDeclaration") // Used by Bridge by reflection for debug purposes.
     public static void setDefaultListener(MethodListener listener) {
         sDefaultListener = listener;
     }
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/RenameClassAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/RenameClassAdapter.java
index 661074c..40bd126 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/RenameClassAdapter.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/RenameClassAdapter.java
@@ -73,7 +73,7 @@
             return mNewName;
         }
 
-        if (mOldBase != mOldName && type.equals(mOldBase)) {
+        if (!mOldBase.equals(mOldName) && type.equals(mOldBase)) {
             return mNewBase;
         }
 
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ReplaceMethodCallsAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ReplaceMethodCallsAdapter.java
index 94d5975..9c6fbac 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ReplaceMethodCallsAdapter.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ReplaceMethodCallsAdapter.java
@@ -19,11 +19,13 @@
 import org.objectweb.asm.ClassVisitor;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Locale;
 import java.util.Set;
 
 /**
@@ -42,45 +44,70 @@
 
     private static final List<MethodReplacer> METHOD_REPLACERS = new ArrayList<MethodReplacer>(2);
 
+    private static final String ANDROID_LOCALE_CLASS =
+            "com/android/layoutlib/bridge/android/AndroidLocale";
+
+    private static final String JAVA_LOCALE_CLASS = "java/util/Locale";
+    private static final Type STRING = Type.getType(String.class);
+
     // Static initialization block to initialize METHOD_REPLACERS.
     static {
         // Case 1: java.lang.System.arraycopy()
         METHOD_REPLACERS.add(new MethodReplacer() {
             @Override
             public boolean isNeeded(String owner, String name, String desc) {
-                return owner.equals("java/lang/System") && name.equals("arraycopy") &&
+                return "java/lang/System".equals(owner) && "arraycopy".equals(name) &&
                         ARRAYCOPY_DESCRIPTORS.contains(desc);
             }
 
             @Override
-            public void replace(int opcode, String owner, String name, String desc,
-                    int[] opcodeOut, String[] output) {
-                assert isNeeded(owner, name, desc) && output.length == 3
-                        && opcodeOut.length == 1;
-                opcodeOut[0] = opcode;
-                output[0] = owner;
-                output[1] = name;
-                output[2] = "(Ljava/lang/Object;ILjava/lang/Object;II)V";
+            public void replace(int[] opcode, String[] methodInformation) {
+                assert methodInformation.length == 3 && isNeeded(methodInformation[0], methodInformation[1], methodInformation[2])
+                        && opcode.length == 1;
+                methodInformation[2] = "(Ljava/lang/Object;ILjava/lang/Object;II)V";
             }
         });
 
-        // Case 2: java.util.Locale.toLanguageTag()
+        // Case 2: java.util.Locale.toLanguageTag() and java.util.Locale.getScript()
         METHOD_REPLACERS.add(new MethodReplacer() {
+
+            String LOCALE_TO_STRING = Type.getMethodDescriptor(STRING, Type.getType(Locale.class));
+
             @Override
             public boolean isNeeded(String owner, String name, String desc) {
-                return owner.equals("java/util/Locale") && name.equals("toLanguageTag") &&
-                        "()Ljava/lang/String;".equals(desc);
+                return JAVA_LOCALE_CLASS.equals(owner) && "()Ljava/lang/String;".equals(desc) &&
+                        ("toLanguageTag".equals(name) || "getScript".equals(name));
             }
 
             @Override
-            public void replace(int opcode, String owner, String name, String desc,
-                    int[] opcodeOut, String[] output) {
-                assert isNeeded(owner, name, desc) && output.length == 3
-                        && opcodeOut.length == 1;
-                opcodeOut[0] = Opcodes.INVOKESTATIC;
-                output[0] = "com/android/layoutlib/bridge/android/AndroidLocale";
-                output[1] = name;
-                output[2] = "(Ljava/util/Locale;)Ljava/lang/String;";
+            public void replace(int[] opcode, String[] methodInformation) {
+                assert methodInformation.length == 3 && isNeeded(methodInformation[0], methodInformation[1], methodInformation[2])
+                        && opcode.length == 1;
+                opcode[0] = Opcodes.INVOKESTATIC;
+                methodInformation[0] = ANDROID_LOCALE_CLASS;
+                methodInformation[2] = LOCALE_TO_STRING;
+            }
+        });
+
+        // Case 3: java.util.Locale.adjustLanguageCode() or java.util.Locale.forLanguageTag()
+        METHOD_REPLACERS.add(new MethodReplacer() {
+
+            private final String STRING_TO_STRING = Type.getMethodDescriptor(STRING, STRING);
+            private final String STRING_TO_LOCALE = Type.getMethodDescriptor(
+                    Type.getType(Locale.class), STRING);
+
+            @Override
+            public boolean isNeeded(String owner, String name, String desc) {
+                return JAVA_LOCALE_CLASS.equals(owner) &&
+                        ("adjustLanguageCode".equals(name) && desc.equals(STRING_TO_STRING) ||
+                        "forLanguageTag".equals(name) && desc.equals(STRING_TO_LOCALE));
+            }
+
+            @Override
+            public void replace(int[] opcode, String[] methodInformation) {
+                assert methodInformation.length == 3 && isNeeded(methodInformation[0], methodInformation[1], methodInformation[2])
+                        && opcode.length == 1;
+                methodInformation[0] = ANDROID_LOCALE_CLASS;
             }
         });
     }
@@ -112,16 +139,15 @@
 
         @Override
         public void visitMethodInsn(int opcode, String owner, String name, String desc) {
-            // Check if method is a specialized version of java.lang.System.arrayCopy
             for (MethodReplacer replacer : METHOD_REPLACERS) {
                 if (replacer.isNeeded(owner, name, desc)) {
-                    String[] output = new String[3];
-                    int[] opcodeOut = new int[1];
-                    replacer.replace(opcode, owner, name, desc, opcodeOut, output);
+                    String[] methodInformation = {owner, name, desc};
+                    int[] opcodeOut = {opcode};
+                    replacer.replace(opcodeOut, methodInformation);
                     opcode = opcodeOut[0];
-                    owner = output[0];
-                    name = output[1];
-                    desc = output[2];
+                    owner = methodInformation[0];
+                    name = methodInformation[1];
+                    desc = methodInformation[2];
                     break;
                 }
             }
@@ -133,14 +159,15 @@
         public boolean isNeeded(String owner, String name, String desc);
 
         /**
-         * This method must update the values of the output arrays with the new values of method
-         * attributes - opcode, owner, name and desc.
-         * @param opcodeOut An array that will contain the new value of the opcode. The size of
-         *                  the array must be 1.
-         * @param output An array that will contain the new values of the owner, name and desc in
-         *               that order. The size of the array must be 3.
+         * This method must update the arrays with the new values of the method attributes -
+         * opcode, owner, name and desc.
+         * @param opcode This array should contain the original value of the opcode. The value is
+         *               modified by the method if needed. The size of the array must be 1.
+         *
+         * @param methodInformation This array should contain the original values of the method
+         *                          attributes - owner, name and desc in that order. The values
+         *                          may be modified as needed. The size of the array must be 3.
          */
-        public void replace(int opcode, String owner, String name, String desc, int[] opcodeOut,
-                String[] output);
+        public void replace(int[] opcode, String[] methodInformation);
     }
 }
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/StubMethodAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/StubMethodAdapter.java
index 51e7535..416b73a 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/StubMethodAdapter.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/StubMethodAdapter.java
@@ -29,8 +29,8 @@
  */
 class StubMethodAdapter extends MethodVisitor {
 
-    private static String CONSTRUCTOR = "<init>";
-    private static String CLASS_INIT = "<clinit>";
+    private static final String CONSTRUCTOR = "<init>";
+    private static final String CLASS_INIT = "<clinit>";
 
     /** The parent method writer */
     private MethodVisitor mParentVisitor;
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/TransformClassAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/TransformClassAdapter.java
index 0b869a5..d9ecf98 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/TransformClassAdapter.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/TransformClassAdapter.java
@@ -17,7 +17,6 @@
 package com.android.tools.layoutlib.create;
 
 import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.FieldVisitor;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.Type;
@@ -136,13 +135,6 @@
         }
     }
 
-    /* Visits a field. Makes it public. */
-    @Override
-    public FieldVisitor visitField(int access, String name, String desc, String signature,
-            Object value) {
-        return super.visitField(access, name, desc, signature, value);
-    }
-
     /**
      * Extracts the return {@link Type} of this descriptor.
      */
diff --git a/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/DelegateClassAdapterTest.java b/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/DelegateClassAdapterTest.java
index 94aad1d..648cea43 100644
--- a/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/DelegateClassAdapterTest.java
+++ b/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/DelegateClassAdapterTest.java
@@ -116,9 +116,16 @@
 
                     // Check that the native method does NOT have the new annotation
                     Method[] m = clazz2.getDeclaredMethods();
-                    assertEquals("native_instance", m[2].getName());
-                    assertTrue(Modifier.isNative(m[2].getModifiers()));
-                    Annotation[] a = m[2].getAnnotations();
+                    Method nativeInstanceMethod = null;
+                    for (Method method : m) {
+                        if ("native_instance".equals(method.getName())) {
+                            nativeInstanceMethod = method;
+                            break;
+                        }
+                    }
+                    assertNotNull(nativeInstanceMethod);
+                    assertTrue(Modifier.isNative(nativeInstanceMethod.getModifiers()));
+                    Annotation[] a = nativeInstanceMethod.getAnnotations();
                     assertEquals(0, a.length);
                 }
             };
@@ -184,9 +191,16 @@
 
                      // Check that the native method now has the new annotation and is not native
                      Method[] m = clazz2.getDeclaredMethods();
-                     assertEquals("native_instance", m[2].getName());
-                     assertFalse(Modifier.isNative(m[2].getModifiers()));
-                     Annotation[] a = m[2].getAnnotations();
+                     Method nativeInstanceMethod = null;
+                     for (Method method : m) {
+                         if ("native_instance".equals(method.getName())) {
+                             nativeInstanceMethod = method;
+                             break;
+                         }
+                     }
+                     assertNotNull(nativeInstanceMethod);
+                     assertFalse(Modifier.isNative(nativeInstanceMethod.getModifiers()));
+                     Annotation[] a = nativeInstanceMethod.getAnnotations();
                      assertEquals("LayoutlibDelegate", a[0].annotationType().getSimpleName());
                 }
             };
@@ -237,13 +251,8 @@
                     assertEquals(4+10+20, callGet(o2, 10, 20));
                     assertEquals(1+10+20, callGet_Original(o2, 10, 20));
 
-                    // The original Outer has a private method that is
-                    // delegated. We should be able to call both the delegate
-                    // and the original (which is now public).
-                    assertEquals("outerPrivateMethod",
-                                 callMethod(o2, "privateMethod_Original", false /*makePublic*/));
-
-                    // The original method is private, so by default we can't access it
+                    // The original Outer has a private method,
+                    // so by default we can't access it.
                     boolean gotIllegalAccessException = false;
                     try {
                          callMethod(o2, "privateMethod", false /*makePublic*/);
@@ -251,9 +260,18 @@
                         gotIllegalAccessException = true;
                     }
                     assertTrue(gotIllegalAccessException);
-                    // Try again, but now making it accessible
-                    assertEquals("outerPrivate_Delegate",
-                            callMethod(o2, "privateMethod", true /*makePublic*/));
+
+                    // The private method from original Outer has been
+                    // delegated. The delegate generated should have the
+                    // same access.
+                    gotIllegalAccessException = false;
+                    try {
+                        assertEquals("outerPrivateMethod",
+                                callMethod(o2, "privateMethod_Original", false /*makePublic*/));
+                    } catch (IllegalAccessException e) {
+                        gotIllegalAccessException = true;
+                    }
+                    assertTrue(gotIllegalAccessException);
 
                     // Check the inner class. Since it's not a static inner class, we need
                     // to use the hidden constructor that takes the outer class as first parameter.