Merge "Make some methods/fields package private so that layoutlib can access them."
diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java
index 5df8bdc..edd0fa3 100755
--- a/core/java/android/animation/ValueAnimator.java
+++ b/core/java/android/animation/ValueAnimator.java
@@ -54,8 +54,8 @@
      * Messages sent to timing handler: START is sent when an animation first begins, FRAME is sent
      * by the handler to itself to process the next animation frame
      */
-    private static final int ANIMATION_START = 0;
-    private static final int ANIMATION_FRAME = 1;
+    static final int ANIMATION_START = 0;
+    static final int ANIMATION_FRAME = 1;
 
     /**
      * Values used with internal variable mPlayingState to indicate the current state of an
diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java
index 931cb18..ffefaa2 100644
--- a/core/java/android/content/res/AssetManager.java
+++ b/core/java/android/content/res/AssetManager.java
@@ -62,7 +62,7 @@
     private static final boolean DEBUG_REFS = false;
     
     private static final Object sSync = new Object();
-    private static AssetManager sSystem = null;
+    /*package*/ static AssetManager sSystem = null;
 
     private final TypedValue mValue = new TypedValue();
     private final long[] mOffsets = new long[2];
@@ -252,7 +252,7 @@
         }
     }
 
-    private final void makeStringBlocks(boolean copyFromSystem) {
+    /*package*/ final void makeStringBlocks(boolean copyFromSystem) {
         final int sysNum = copyFromSystem ? sSystem.mStringBlocks.length : 0;
         final int num = getStringBlockCount();
         mStringBlocks = new StringBlock[num];
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index 324c9fd..f526923 100755
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -77,7 +77,7 @@
     private static final int ID_OTHER = 0x01000004;
 
     private static final Object mSync = new Object();
-    private static Resources mSystem = null;
+    /*package*/ static Resources mSystem = null;
     
     // Information about preloaded resources.  Note that they are not
     // protected by a lock, because while preloading in zygote we are all
diff --git a/core/java/android/content/res/TypedArray.java b/core/java/android/content/res/TypedArray.java
index 37fdeb6..2df492e 100644
--- a/core/java/android/content/res/TypedArray.java
+++ b/core/java/android/content/res/TypedArray.java
@@ -42,7 +42,7 @@
     /*package*/ int[] mData;
     /*package*/ int[] mIndices;
     /*package*/ int mLength;
-    private TypedValue mValue = new TypedValue();
+    /*package*/ TypedValue mValue = new TypedValue();
    
     /**
      * Return the number of values in this array.
diff --git a/core/java/android/os/HandlerThread.java b/core/java/android/os/HandlerThread.java
index 911439a..d61b3b4 100644
--- a/core/java/android/os/HandlerThread.java
+++ b/core/java/android/os/HandlerThread.java
@@ -21,9 +21,9 @@
  * used to create handler classes. Note that start() must still be called.
  */
 public class HandlerThread extends Thread {
-    private int mPriority;
-    private int mTid = -1;
-    private Looper mLooper;
+    int mPriority;
+    int mTid = -1;
+    Looper mLooper;
 
     public HandlerThread(String name) {
         super(name);
diff --git a/core/java/android/os/Looper.java b/core/java/android/os/Looper.java
index c61f28a..5607f7f 100644
--- a/core/java/android/os/Looper.java
+++ b/core/java/android/os/Looper.java
@@ -54,7 +54,7 @@
     private static final String TAG = "Looper";
 
     // sThreadLocal.get() will return null unless you've called prepare().
-    private static final ThreadLocal<Looper> sThreadLocal = new ThreadLocal<Looper>();
+    static final ThreadLocal<Looper> sThreadLocal = new ThreadLocal<Looper>();
 
     final MessageQueue mQueue;
     final Thread mThread;
diff --git a/core/java/android/util/XmlPullAttributes.java b/core/java/android/util/XmlPullAttributes.java
index ecedbe1..6c8bb39 100644
--- a/core/java/android/util/XmlPullAttributes.java
+++ b/core/java/android/util/XmlPullAttributes.java
@@ -143,5 +143,5 @@
         return getAttributeResourceValue(null, "style", 0);
     }
 
-    private XmlPullParser mParser;
+    /*package*/ XmlPullParser mParser;
 }
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index d9efe0c..85e990aa 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -366,9 +366,9 @@
     // Following fields are initialized from native code
     private int         mPixelFormat;
     private float       mRefreshRate;
-    private float       mDensity;
-    private float       mDpiX;
-    private float       mDpiY;
+    /*package*/ float   mDensity;
+    /*package*/ float   mDpiX;
+    /*package*/ float   mDpiY;
     
     private final Point mTmpPoint = new Point();
     private final DisplayMetrics mTmpMetrics = new DisplayMetrics();
diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java
index 332a0fa..9628d6b 100644
--- a/core/java/android/view/LayoutInflater.java
+++ b/core/java/android/view/LayoutInflater.java
@@ -75,9 +75,9 @@
     private Factory2 mPrivateFactory;
     private Filter mFilter;
 
-    private final Object[] mConstructorArgs = new Object[2];
+    final Object[] mConstructorArgs = new Object[2];
 
-    private static final Class<?>[] mConstructorSignature = new Class[] {
+    static final Class<?>[] mConstructorSignature = new Class[] {
             Context.class, AttributeSet.class};
 
     private static final HashMap<String, Constructor<? extends View>> sConstructorMap =
@@ -705,7 +705,7 @@
      * Recursive method used to descend down the xml hierarchy and instantiate
      * views, instantiate their children, and then call onFinishInflate().
      */
-    private void rInflate(XmlPullParser parser, View parent, final AttributeSet attrs,
+    void rInflate(XmlPullParser parser, View parent, final AttributeSet attrs,
             boolean finishInflate) throws XmlPullParserException, IOException {
 
         final int depth = parser.getDepth();
diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java
index 9520958..5e104f9e 100644
--- a/core/java/android/view/ViewConfiguration.java
+++ b/core/java/android/view/ViewConfiguration.java
@@ -225,7 +225,7 @@
     private boolean sHasPermanentMenuKey;
     private boolean sHasPermanentMenuKeySet;
 
-    private static final SparseArray<ViewConfiguration> sConfigurations =
+    static final SparseArray<ViewConfiguration> sConfigurations =
             new SparseArray<ViewConfiguration>(2);
 
     /**
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 3fc6463..79acd55 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -93,7 +93,7 @@
 
         This can be called from JNI code.
     */
-    private Bitmap(int nativeBitmap, byte[] buffer, boolean isMutable, byte[] ninePatchChunk,
+    /*package*/ Bitmap(int nativeBitmap, byte[] buffer, boolean isMutable, byte[] ninePatchChunk,
             int density) {
         if (nativeBitmap == 0) {
             throw new RuntimeException("internal error: native bitmap is 0");
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index fe4b082..828bafd 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -70,16 +70,16 @@
      */
     public  int         mBidiFlags = BIDI_DEFAULT_LTR;
     
-    private static final Style[] sStyleArray = {
+    static final Style[] sStyleArray = {
         Style.FILL, Style.STROKE, Style.FILL_AND_STROKE
     };
-    private static final Cap[] sCapArray = {
+    static final Cap[] sCapArray = {
         Cap.BUTT, Cap.ROUND, Cap.SQUARE
     };
-    private static final Join[] sJoinArray = {
+    static final Join[] sJoinArray = {
         Join.MITER, Join.ROUND, Join.BEVEL
     };
-    private static final Align[] sAlignArray = {
+    static final Align[] sAlignArray = {
         Align.LEFT, Align.CENTER, Align.RIGHT
     };
 
@@ -103,7 +103,7 @@
     public static final int DEV_KERN_TEXT_FLAG  = 0x100;
 
     // we use this when we first create a paint
-    private static final int DEFAULT_PAINT_FLAGS = DEV_KERN_TEXT_FLAG;
+    static final int DEFAULT_PAINT_FLAGS = DEV_KERN_TEXT_FLAG;
 
     /**
      * Bidi flag to set LTR paragraph direction.
diff --git a/graphics/java/android/graphics/Path.java b/graphics/java/android/graphics/Path.java
index c5d7500..b4f1e84d 100644
--- a/graphics/java/android/graphics/Path.java
+++ b/graphics/java/android/graphics/Path.java
@@ -115,7 +115,7 @@
     }
     
     // these must be in the same order as their native values
-    private static final FillType[] sFillTypeArray = {
+    static final FillType[] sFillTypeArray = {
         FillType.WINDING,
         FillType.EVEN_ODD,
         FillType.INVERSE_WINDING,
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java
index bc92d3a..ed6fa08 100644
--- a/graphics/java/android/graphics/Typeface.java
+++ b/graphics/java/android/graphics/Typeface.java
@@ -43,7 +43,7 @@
     /** The NORMAL style of the default monospace typeface. */
     public static final Typeface MONOSPACE;
 
-    private static Typeface[] sDefaults;
+    /* package */ static Typeface[] sDefaults;
     
     /* package */ int native_instance;
 
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java b/tools/layoutlib/bridge/src/android/animation/AnimationThread.java
similarity index 98%
rename from tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java
rename to tools/layoutlib/bridge/src/android/animation/AnimationThread.java
index 4c18656..2b5e4fa 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java
+++ b/tools/layoutlib/bridge/src/android/animation/AnimationThread.java
@@ -14,13 +14,14 @@
  * limitations under the License.
  */
 
-package com.android.layoutlib.bridge.impl;
+package android.animation;
 
 import com.android.ide.common.rendering.api.IAnimationListener;
 import com.android.ide.common.rendering.api.RenderSession;
 import com.android.ide.common.rendering.api.Result;
 import com.android.ide.common.rendering.api.Result.Status;
 import com.android.layoutlib.bridge.Bridge;
+import com.android.layoutlib.bridge.impl.RenderSessionImpl;
 
 import android.animation.ValueAnimator;
 import android.os.Handler;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeAssetManager.java b/tools/layoutlib/bridge/src/android/content/res/BridgeAssetManager.java
similarity index 94%
rename from tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeAssetManager.java
rename to tools/layoutlib/bridge/src/android/content/res/BridgeAssetManager.java
index a825060..a953918 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeAssetManager.java
+++ b/tools/layoutlib/bridge/src/android/content/res/BridgeAssetManager.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.layoutlib.bridge.android;
+package android.content.res;
 
 import com.android.layoutlib.bridge.Bridge;
 
@@ -30,7 +30,7 @@
      * <p/>
      * {@link Bridge} calls this method after setting up a new bridge.
      */
-    /*package*/ public static AssetManager initSystem() {
+    public static AssetManager initSystem() {
         if (!(AssetManager.sSystem instanceof BridgeAssetManager)) {
             // Note that AssetManager() creates a system AssetManager and we override it
             // with our BridgeAssetManager.
diff --git a/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java b/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java
index 0928ec5..7b672da 100644
--- a/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java
+++ b/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java
@@ -214,7 +214,15 @@
         Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
 
         if (value != null) {
-            return value.getSecond().getValue();
+            ResourceValue resValue = value.getSecond();
+
+            assert resValue != null;
+            if (resValue != null) {
+                String v = resValue.getValue();
+                if (v != null) {
+                    return v;
+                }
+            }
         }
 
         // id was not found or not resolved. Throw a NotFoundException.
@@ -318,20 +326,24 @@
         Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
 
         if (value != null) {
-            String v = value.getSecond().getValue();
+            ResourceValue resValue = value.getSecond();
 
-            if (v != null) {
-                if (v.equals(BridgeConstants.MATCH_PARENT) ||
-                        v.equals(BridgeConstants.FILL_PARENT)) {
-                    return LayoutParams.MATCH_PARENT;
-                } else if (v.equals(BridgeConstants.WRAP_CONTENT)) {
-                    return LayoutParams.WRAP_CONTENT;
-                }
+            assert resValue != null;
+            if (resValue != null) {
+                String v = resValue.getValue();
+                if (v != null) {
+                    if (v.equals(BridgeConstants.MATCH_PARENT) ||
+                            v.equals(BridgeConstants.FILL_PARENT)) {
+                        return LayoutParams.MATCH_PARENT;
+                    } else if (v.equals(BridgeConstants.WRAP_CONTENT)) {
+                        return LayoutParams.WRAP_CONTENT;
+                    }
 
-                if (ResourceHelper.parseFloatAttribute(
-                        value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
-                        mTmpValue.type == TypedValue.TYPE_DIMENSION) {
-                    return mTmpValue.getDimension(getDisplayMetrics());
+                    if (ResourceHelper.parseFloatAttribute(
+                            value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
+                            mTmpValue.type == TypedValue.TYPE_DIMENSION) {
+                        return mTmpValue.getDimension(getDisplayMetrics());
+                    }
                 }
             }
         }
@@ -348,14 +360,18 @@
         Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
 
         if (value != null) {
-            String v = value.getSecond().getValue();
+            ResourceValue resValue = value.getSecond();
 
-            if (v != null) {
-                if (ResourceHelper.parseFloatAttribute(
-                        value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
-                        mTmpValue.type == TypedValue.TYPE_DIMENSION) {
-                    return TypedValue.complexToDimensionPixelOffset(mTmpValue.data,
-                            getDisplayMetrics());
+            assert resValue != null;
+            if (resValue != null) {
+                String v = resValue.getValue();
+                if (v != null) {
+                    if (ResourceHelper.parseFloatAttribute(
+                            value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
+                            mTmpValue.type == TypedValue.TYPE_DIMENSION) {
+                        return TypedValue.complexToDimensionPixelOffset(mTmpValue.data,
+                                getDisplayMetrics());
+                    }
                 }
             }
         }
@@ -372,14 +388,18 @@
         Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
 
         if (value != null) {
-            String v = value.getSecond().getValue();
+            ResourceValue resValue = value.getSecond();
 
-            if (v != null) {
-                if (ResourceHelper.parseFloatAttribute(
-                        value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
-                        mTmpValue.type == TypedValue.TYPE_DIMENSION) {
-                    return TypedValue.complexToDimensionPixelSize(mTmpValue.data,
-                            getDisplayMetrics());
+            assert resValue != null;
+            if (resValue != null) {
+                String v = resValue.getValue();
+                if (v != null) {
+                    if (ResourceHelper.parseFloatAttribute(
+                            value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
+                            mTmpValue.type == TypedValue.TYPE_DIMENSION) {
+                        return TypedValue.complexToDimensionPixelSize(mTmpValue.data,
+                                getDisplayMetrics());
+                    }
                 }
             }
         }
@@ -395,17 +415,24 @@
     public int getInteger(int id) throws NotFoundException {
         Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
 
-        if (value != null && value.getSecond().getValue() != null) {
-            String v = value.getSecond().getValue();
-            int radix = 10;
-            if (v.startsWith("0x")) {
-                v = v.substring(2);
-                radix = 16;
-            }
-            try {
-                return Integer.parseInt(v, radix);
-            } catch (NumberFormatException e) {
-                // return exception below
+        if (value != null) {
+            ResourceValue resValue = value.getSecond();
+
+            assert resValue != null;
+            if (resValue != null) {
+                String v = resValue.getValue();
+                if (v != null) {
+                    int radix = 10;
+                    if (v.startsWith("0x")) {
+                        v = v.substring(2);
+                        radix = 16;
+                    }
+                    try {
+                        return Integer.parseInt(v, radix);
+                    } catch (NumberFormatException e) {
+                        // return exception below
+                    }
+                }
             }
         }
 
@@ -420,9 +447,16 @@
     public boolean getBoolean(int id) throws NotFoundException {
         Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
 
-        if (value != null && value.getSecond().getValue() != null) {
-            String v = value.getSecond().getValue();
-            return Boolean.parseBoolean(v);
+        if (value != null) {
+            ResourceValue resValue = value.getSecond();
+
+            assert resValue != null;
+            if (resValue != null) {
+                String v = resValue.getValue();
+                if (v != null) {
+                    return Boolean.parseBoolean(v);
+                }
+            }
         }
 
         // id was not found or not resolved. Throw a NotFoundException.
diff --git a/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java
index 9deed32..8fdac02 100644
--- a/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java
+++ b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java
@@ -33,9 +33,6 @@
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
 
-import android.content.res.ColorStateList;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
 import android.graphics.drawable.Drawable;
 import android.util.DisplayMetrics;
 import android.util.TypedValue;
@@ -897,12 +894,6 @@
     }
 
     @Override
-    public boolean getValueAt(int index, TypedValue outValue) {
-        // pass
-        return false;
-    }
-
-    @Override
     public String toString() {
         return Arrays.toString(mResourceData);
     }
diff --git a/tools/layoutlib/bridge/src/android/content/res/TypedArray_Delegate.java b/tools/layoutlib/bridge/src/android/content/res/TypedArray_Delegate.java
new file mode 100644
index 0000000..0a7899a
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/content/res/TypedArray_Delegate.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 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 android.content.res;
+
+import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
+
+import android.util.TypedValue;
+
+public class TypedArray_Delegate {
+
+    @LayoutlibDelegate
+    public static boolean getValueAt(TypedArray theTypedArray, int index, TypedValue outValue) {
+        // pass
+        return false;
+    }
+}
diff --git a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
index 66e59d8..eadec02 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
@@ -22,7 +22,6 @@
 import com.android.resources.Density;
 import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
 
-import android.graphics.Bitmap;
 import android.graphics.Bitmap.Config;
 import android.os.Parcel;
 
@@ -149,7 +148,7 @@
     }
 
     public static int getBufferedImageType(int nativeBitmapConfig) {
-        switch (Config.sConfigs[nativeBitmapConfig]) {
+        switch (Config.nativeToConfig(nativeBitmapConfig)) {
             case ALPHA_8:
                 return BufferedImage.TYPE_INT_ARGB;
             case RGB_565:
@@ -210,7 +209,7 @@
         }
 
         // create a delegate with the content of the stream.
-        Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.sConfigs[nativeConfig]);
+        Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
 
         return createBitmap(delegate, mutable, Bitmap.getDefaultDensity());
     }
@@ -238,7 +237,7 @@
         image.setRGB(0, 0, width, height, argb, 0, width);
 
         // create a delegate with the content of the stream.
-        Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.sConfigs[nativeConfig]);
+        Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
 
         return createBitmap(delegate, isMutable, Bitmap.getDefaultDensity());
     }
diff --git a/tools/layoutlib/bridge/src/android/graphics/Typeface_Accessor.java b/tools/layoutlib/bridge/src/android/graphics/Typeface_Accessor.java
new file mode 100644
index 0000000..2745770
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/graphics/Typeface_Accessor.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2011 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 android.graphics;
+
+public class Typeface_Accessor {
+
+    public static void resetDefaults() {
+        Typeface.sDefaults = null;
+    }
+}
diff --git a/tools/layoutlib/bridge/src/android/os/Looper_Accessor.java b/tools/layoutlib/bridge/src/android/os/Looper_Accessor.java
new file mode 100644
index 0000000..ad95fcc
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/os/Looper_Accessor.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2011 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 android.os;
+
+public class Looper_Accessor {
+
+    public static void cleanupThread() {
+        // clean up the looper
+        Looper.sThreadLocal.remove();
+    }
+}
diff --git a/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java b/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java
index 63711a7..bd332a6 100644
--- a/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java
@@ -68,4 +68,28 @@
     /*package*/ static long currentThreadTimeMillis() {
         return System.currentTimeMillis();
     }
+
+    /**
+     * Returns microseconds running in the current thread.
+     *
+     * @return elapsed microseconds in the thread
+     *
+     * @hide
+     */
+    @LayoutlibDelegate
+    /*package*/ static long currentThreadTimeMicro() {
+        return System.currentTimeMillis() * 1000;
+    }
+
+    /**
+     * Returns current wall time in  microseconds.
+     *
+     * @return elapsed microseconds in wall time
+     *
+     * @hide
+     */
+    @LayoutlibDelegate
+    /*package*/ static long currentTimeMicro() {
+        return elapsedRealtime() * 1000;
+    }
 }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java b/tools/layoutlib/bridge/src/android/util/BridgeXmlPullAttributes.java
similarity index 97%
rename from tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java
rename to tools/layoutlib/bridge/src/android/util/BridgeXmlPullAttributes.java
index ba856e0..0a3cdc6 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java
+++ b/tools/layoutlib/bridge/src/android/util/BridgeXmlPullAttributes.java
@@ -14,12 +14,13 @@
  * limitations under the License.
  */
 
-package com.android.layoutlib.bridge.android;
+package android.util;
 
 import com.android.ide.common.rendering.api.RenderResources;
 import com.android.ide.common.rendering.api.ResourceValue;
 import com.android.layoutlib.bridge.Bridge;
 import com.android.layoutlib.bridge.BridgeConstants;
+import com.android.layoutlib.bridge.android.BridgeContext;
 import com.android.resources.ResourceType;
 
 import org.xmlpull.v1.XmlPullParser;
diff --git a/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java b/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java
new file mode 100644
index 0000000..e3778b1
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011 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 android.view;
+
+import com.android.layoutlib.bridge.android.BridgeWindow;
+import com.android.layoutlib.bridge.android.BridgeWindowSession;
+
+import android.os.Handler;
+import android.view.View.AttachInfo;
+
+public class AttachInfo_Accessor {
+
+    public static void setAttachInfo(View view) {
+        AttachInfo info = new AttachInfo(new BridgeWindowSession(), new BridgeWindow(),
+                new Handler(), null);
+        info.mHasWindowFocus = true;
+        info.mWindowVisibility = View.VISIBLE;
+        info.mInTouchMode = false; // this is so that we can display selections.
+        info.mHardwareAccelerated = false;
+        view.dispatchAttachedToWindow(info, 0);
+    }
+
+    public static void dispatchOnPreDraw(View view) {
+        view.mAttachInfo.mTreeObserver.dispatchOnPreDraw();
+    }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java b/tools/layoutlib/bridge/src/android/view/BridgeInflater.java
similarity index 98%
rename from tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
rename to tools/layoutlib/bridge/src/android/view/BridgeInflater.java
index 4a6393d..941f1ce6 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
+++ b/tools/layoutlib/bridge/src/android/view/BridgeInflater.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.layoutlib.bridge.android;
+package android.view;
 
 import com.android.ide.common.rendering.api.IProjectCallback;
 import com.android.ide.common.rendering.api.LayoutLog;
@@ -22,6 +22,8 @@
 import com.android.ide.common.rendering.api.ResourceReference;
 import com.android.ide.common.rendering.api.ResourceValue;
 import com.android.layoutlib.bridge.Bridge;
+import com.android.layoutlib.bridge.android.BridgeContext;
+import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
 import com.android.layoutlib.bridge.impl.ParserFactory;
 import com.android.resources.ResourceType;
 import com.android.util.Pair;
diff --git a/tools/layoutlib/bridge/src/android/view/Display_Delegate.java b/tools/layoutlib/bridge/src/android/view/Display_Delegate.java
index 83f9cc2..9732530 100644
--- a/tools/layoutlib/bridge/src/android/view/Display_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/view/Display_Delegate.java
@@ -46,31 +46,17 @@
     }
 
     @LayoutlibDelegate
-    /** @hide Returns the actual screen size, not including any decor. */
-    /*package*/ static int getRealWidth(Display theDisplay) {
-        // always dynamically query for the current window manager
-        return RenderAction.getCurrentContext().getIWindowManager().getMetrics().widthPixels;
-    }
-
-    @LayoutlibDelegate
-    /** @hide Returns the actual screen size, not including any decor. */
-    /*package*/ static int getRealHeight(Display theDisplay) {
-        // always dynamically query for the current window manager
-        return RenderAction.getCurrentContext().getIWindowManager().getMetrics().heightPixels;
-    }
-
-    @LayoutlibDelegate
     /** @hide special for when we are faking the screen size. */
     /*package*/ static int getRawWidth(Display theDisplay) {
         // same as real since we're not faking compatibility mode.
-        return getRealWidth(theDisplay);
+        return RenderAction.getCurrentContext().getIWindowManager().getMetrics().widthPixels;
     }
 
     @LayoutlibDelegate
     /** @hide special for when we are faking the screen size. */
     /*package*/ static int getRawHeight(Display theDisplay) {
         // same as real since we're not faking compatibility mode.
-        return getRealHeight(theDisplay);
+        return RenderAction.getCurrentContext().getIWindowManager().getMetrics().heightPixels;
     }
 
     @LayoutlibDelegate
diff --git a/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java b/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java
index 64efa7e..3db3a1b 100644
--- a/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java
@@ -16,7 +16,6 @@
 
 package android.view;
 
-import com.android.layoutlib.bridge.android.BridgeInflater;
 import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
 
 import org.xmlpull.v1.XmlPullParser;
diff --git a/tools/layoutlib/bridge/src/android/view/ViewConfiguration_Accessor.java b/tools/layoutlib/bridge/src/android/view/ViewConfiguration_Accessor.java
new file mode 100644
index 0000000..01db34e
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/view/ViewConfiguration_Accessor.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2011 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 android.view;
+
+public class ViewConfiguration_Accessor {
+
+    public static void clearConfigurations() {
+        // clear the stored ViewConfiguration since the map is per density and not per context.
+        ViewConfiguration.sConfigurations.clear();
+    }
+
+}
diff --git a/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Accessor.java b/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Accessor.java
new file mode 100644
index 0000000..875336a
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Accessor.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2011 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 android.view.inputmethod;
+
+public class InputMethodManager_Accessor {
+
+    public static void resetInstance() {
+        InputMethodManager.mInstance = null;
+    }
+}
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 3ba3257..33bf7bc 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -26,7 +26,6 @@
 import com.android.ide.common.rendering.api.Result;
 import com.android.ide.common.rendering.api.SessionParams;
 import com.android.ide.common.rendering.api.Result.Status;
-import com.android.layoutlib.bridge.android.BridgeAssetManager;
 import com.android.layoutlib.bridge.impl.FontLoader;
 import com.android.layoutlib.bridge.impl.RenderDrawable;
 import com.android.layoutlib.bridge.impl.RenderSessionImpl;
@@ -36,10 +35,12 @@
 import com.android.tools.layoutlib.create.OverrideMethod;
 import com.android.util.Pair;
 
+import android.content.res.BridgeAssetManager;
 import android.graphics.Bitmap;
-import android.graphics.Typeface;
+import android.graphics.Typeface_Accessor;
 import android.graphics.Typeface_Delegate;
 import android.os.Looper;
+import android.os.Looper_Accessor;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.ViewParent;
@@ -295,7 +296,7 @@
         BridgeAssetManager.clearSystem();
 
         // dispose of the default typeface.
-        Typeface.sDefaults = null;
+        Typeface_Accessor.resetDefaults();
 
         return true;
     }
@@ -429,7 +430,7 @@
      */
     public static void cleanupThread() {
         // clean up the looper
-        Looper.sThreadLocal.remove();
+        Looper_Accessor.cleanupThread();
     }
 
     public static LayoutLog getLog() {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index b38b3b8..0453a5e 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -33,8 +33,6 @@
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
 
-import android.app.Activity;
-import android.app.Fragment;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.ContentResolver;
@@ -65,7 +63,7 @@
 import android.util.AttributeSet;
 import android.util.DisplayMetrics;
 import android.util.TypedValue;
-import android.view.LayoutInflater;
+import android.view.BridgeInflater;
 import android.view.Surface;
 import android.view.View;
 import android.view.ViewGroup;
@@ -87,7 +85,7 @@
 /**
  * Custom implementation of Context/Activity to handle non compiled resources.
  */
-public final class BridgeContext extends Activity {
+public final class BridgeContext extends Context {
 
     private Resources mSystemResources;
     private final HashMap<View, Object> mViewKeyMap = new HashMap<View, Object>();
@@ -97,9 +95,10 @@
     private final Configuration mConfig;
     private final ApplicationInfo mApplicationInfo;
     private final IProjectCallback mProjectCallback;
-
     private final BridgeWindowManager mIWindowManager;
 
+    private Resources.Theme mTheme;
+
     private final Map<Object, Map<String, String>> mDefaultPropMaps =
         new IdentityHashMap<Object, Map<String,String>>();
 
@@ -139,9 +138,6 @@
 
         mIWindowManager = new BridgeWindowManager(mConfig, metrics, Surface.ROTATION_0);
 
-        mFragments.mCurState = Fragment.CREATED;
-        mFragments.mActivity = this;
-
         mApplicationInfo = new ApplicationInfo();
         mApplicationInfo.targetSdkVersion = targetSdkVersion;
     }
@@ -395,13 +391,6 @@
         return Pair.of(null, false);
     }
 
-    // ------------- Activity Methods
-
-    @Override
-    public LayoutInflater getLayoutInflater() {
-        return mBridgeInflater;
-    }
-
     // ------------ Context methods
 
     @Override
@@ -1275,7 +1264,7 @@
 
     @Override
     public Context getApplicationContext() {
-        throw new UnsupportedOperationException();
+        return this;
     }
 
     @Override
@@ -1288,4 +1277,10 @@
     public boolean isRestricted() {
         return false;
     }
+
+    @Override
+    public File getObbDir() {
+        Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "OBB not supported", null);
+        return null;
+    }
 }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java
index a8da377..8e673ad 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java
@@ -26,10 +26,9 @@
 import android.view.IWindow;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
-import android.view.View.AttachInfo;
 
 /**
- * Implementation of {@link IWindow} to pass to the {@link AttachInfo}.
+ * Implementation of {@link IWindow} to pass to the AttachInfo.
  */
 public final class BridgeWindow implements IWindow {
 
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java
index 5952c37..7d83a9f 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java
@@ -456,9 +456,7 @@
         return null;
     }
 
-    @Override
     public int getPreferredOptionsPanelGravity() throws RemoteException {
         return Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
     }
-
 }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
index 1016b32..f8ed4f7 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
@@ -25,7 +25,7 @@
 
 import android.content.res.XmlResourceParser;
 import android.util.AttributeSet;
-import android.util.XmlPullAttributes;
+import android.util.BridgeXmlPullAttributes;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -34,12 +34,12 @@
 /**
  * {@link BridgeXmlBlockParser} reimplements most of android.xml.XmlBlock.Parser.
  * It delegates to both an instance of {@link XmlPullParser} and an instance of
- * {@link XmlPullAttributes} (for the {@link AttributeSet} part).
+ * XmlPullAttributes (for the {@link AttributeSet} part).
  */
 public class BridgeXmlBlockParser implements XmlResourceParser {
 
     private final XmlPullParser mParser;
-    private final XmlPullAttributes mAttrib;
+    private final BridgeXmlPullAttributes mAttrib;
     private final BridgeContext mContext;
     private final boolean mPlatformFile;
 
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java
index 5569e06..7521011 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java
@@ -32,7 +32,8 @@
     public PhoneSystemBar(Context context, Density density) throws XmlPullParserException {
         super(context, density, "/bars/phone_system_bar.xml", "phone_system_bar.xml");
 
-        setGravity(mGravity | Gravity.RIGHT);
+        // FIXME: use FILL_H?
+        setGravity(Gravity.START | Gravity.TOP | Gravity.RIGHT);
         setBackgroundColor(0xFF000000);
 
         // Cannot access the inside items through id because no R.id values have been
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/PlayAnimationThread.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/PlayAnimationThread.java
index 35e5987..7b70180 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/PlayAnimationThread.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/PlayAnimationThread.java
@@ -20,6 +20,7 @@
 import com.android.ide.common.rendering.api.Result;
 import com.android.ide.common.rendering.api.Result.Status;
 
+import android.animation.AnimationThread;
 import android.animation.Animator;
 
 public class PlayAnimationThread extends AnimationThread {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
index d40222f..7323c6a 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
@@ -35,8 +35,9 @@
 import android.os.HandlerThread_Delegate;
 import android.os.Looper;
 import android.util.DisplayMetrics;
-import android.view.ViewConfiguration;
+import android.view.ViewConfiguration_Accessor;
 import android.view.inputmethod.InputMethodManager;
+import android.view.inputmethod.InputMethodManager_Accessor;
 
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.ReentrantLock;
@@ -248,10 +249,10 @@
         HandlerThread_Delegate.cleanUp(sCurrentContext);
 
         // clear the stored ViewConfiguration since the map is per density and not per context.
-        ViewConfiguration.sConfigurations.clear();
+        ViewConfiguration_Accessor.clearConfigurations();
 
         // remove the InputMethodManager
-        InputMethodManager.mInstance = null;
+        InputMethodManager_Accessor.resetInstance();
 
         sCurrentContext = null;
 
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderDrawable.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderDrawable.java
index 953d8cf..8133210 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderDrawable.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderDrawable.java
@@ -23,17 +23,13 @@
 import com.android.ide.common.rendering.api.Result;
 import com.android.ide.common.rendering.api.Result.Status;
 import com.android.layoutlib.bridge.android.BridgeContext;
-import com.android.layoutlib.bridge.android.BridgeWindow;
-import com.android.layoutlib.bridge.android.BridgeWindowSession;
 import com.android.resources.ResourceType;
 
 import android.graphics.Bitmap;
 import android.graphics.Bitmap_Delegate;
 import android.graphics.Canvas;
 import android.graphics.drawable.Drawable;
-import android.os.Handler;
-import android.view.View;
-import android.view.View.AttachInfo;
+import android.view.AttachInfo_Accessor;
 import android.view.View.MeasureSpec;
 import android.widget.FrameLayout;
 
@@ -82,13 +78,7 @@
             content.setBackgroundDrawable(d);
 
             // set the AttachInfo on the root view.
-            AttachInfo info = new AttachInfo(new BridgeWindowSession(), new BridgeWindow(),
-                    new Handler(), null);
-            info.mHasWindowFocus = true;
-            info.mWindowVisibility = View.VISIBLE;
-            info.mInTouchMode = false; // this is so that we can display selections.
-            info.mHardwareAccelerated = false;
-            content.dispatchAttachedToWindow(info, 0);
+            AttachInfo_Accessor.setAttachInfo(content);
 
 
             // measure
@@ -102,7 +92,7 @@
             content.layout(0, 0, w, h);
 
             // preDraw setup
-            content.mAttachInfo.mTreeObserver.dispatchOnPreDraw();
+            AttachInfo_Accessor.dispatchOnPreDraw(content);
 
             // draw into a new image
             BufferedImage image = getImage(w, h);
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
index aa30e29..d5400d7 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
@@ -40,10 +40,7 @@
 import com.android.internal.util.XmlUtils;
 import com.android.layoutlib.bridge.Bridge;
 import com.android.layoutlib.bridge.android.BridgeContext;
-import com.android.layoutlib.bridge.android.BridgeInflater;
 import com.android.layoutlib.bridge.android.BridgeLayoutParamsMapAttributes;
-import com.android.layoutlib.bridge.android.BridgeWindow;
-import com.android.layoutlib.bridge.android.BridgeWindowSession;
 import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
 import com.android.layoutlib.bridge.bars.FakeActionBar;
 import com.android.layoutlib.bridge.bars.PhoneSystemBar;
@@ -57,6 +54,7 @@
 
 import org.xmlpull.v1.XmlPullParserException;
 
+import android.animation.AnimationThread;
 import android.animation.Animator;
 import android.animation.AnimatorInflater;
 import android.animation.LayoutTransition;
@@ -66,12 +64,12 @@
 import android.graphics.Bitmap_Delegate;
 import android.graphics.Canvas;
 import android.graphics.drawable.Drawable;
-import android.os.Handler;
 import android.util.DisplayMetrics;
 import android.util.TypedValue;
+import android.view.AttachInfo_Accessor;
+import android.view.BridgeInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.View.AttachInfo;
 import android.view.View.MeasureSpec;
 import android.view.ViewGroup.LayoutParams;
 import android.view.ViewGroup.MarginLayoutParams;
@@ -190,7 +188,6 @@
         // build the inflater and parser.
         mInflater = new BridgeInflater(context, params.getProjectCallback());
         context.setBridgeInflater(mInflater);
-        mInflater.setFactory2(context);
 
         mBlockParser = new BridgeXmlBlockParser(
                 params.getLayoutDescription(), context, false /* platformResourceFlag */);
@@ -329,13 +326,7 @@
             Fragment_Delegate.setProjectCallback(null);
 
             // set the AttachInfo on the root view.
-            AttachInfo info = new AttachInfo(new BridgeWindowSession(), new BridgeWindow(),
-                    new Handler(), null);
-            info.mHasWindowFocus = true;
-            info.mWindowVisibility = View.VISIBLE;
-            info.mInTouchMode = false; // this is so that we can display selections.
-            info.mHardwareAccelerated = false;
-            mViewRoot.dispatchAttachedToWindow(info, 0);
+            AttachInfo_Accessor.setAttachInfo(mViewRoot);
 
             // post-inflate process. For now this supports TabHost/TabWidget
             postInflateProcess(view, params.getProjectCallback());
@@ -462,7 +453,7 @@
                 mImage = null;
                 mCanvas = null;
             } else {
-                mViewRoot.mAttachInfo.mTreeObserver.dispatchOnPreDraw();
+                AttachInfo_Accessor.dispatchOnPreDraw(mViewRoot);
 
                 // draw the views
                 // create the BufferedImage into which the layout will be rendered.
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
index 7c02f7e..0a15627 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
@@ -95,10 +95,11 @@
     /**
      * The list of methods to rewrite as delegates.
      */
-    private final static String[] DELEGATE_METHODS = new String[] {
+    public final static String[] DELEGATE_METHODS = new String[] {
         "android.app.Fragment#instantiate", //(Landroid/content/Context;Ljava/lang/String;Landroid/os/Bundle;)Landroid/app/Fragment;",
         "android.content.res.Resources$Theme#obtainStyledAttributes",
         "android.content.res.Resources$Theme#resolveAttribute",
+        "android.content.res.TypedArray#getValueAt",
         "android.graphics.BitmapFactory#finishDecode",
         "android.os.Handler#sendMessageAtTime",
         "android.os.HandlerThread#run",
@@ -116,7 +117,7 @@
     /**
      * The list of classes on which to delegate all native methods.
      */
-    private final static String[] DELEGATE_CLASS_NATIVES = new String[] {
+    public final static String[] DELEGATE_CLASS_NATIVES = new String[] {
         "android.animation.PropertyValuesHolder",
         "android.graphics.AvoidXfermode",
         "android.graphics.Bitmap",
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 b027b6a..4b7a348 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
@@ -165,6 +165,8 @@
             return false;
         }
 
+        sOptions.generatePublicAccess = false;
+
         return true;
     }
 }