Merge "Updated tether icons" into honeycomb
diff --git a/core/java/android/view/MenuInflater.java b/core/java/android/view/MenuInflater.java
index ab515c9..372ac15 100644
--- a/core/java/android/view/MenuInflater.java
+++ b/core/java/android/view/MenuInflater.java
@@ -228,8 +228,8 @@
         private boolean itemAdded;
         private int itemId;
         private int itemCategoryOrder;
-        private String itemTitle;
-        private String itemTitleCondensed;
+        private CharSequence itemTitle;
+        private CharSequence itemTitleCondensed;
         private int itemIconResId;
         private char itemAlphabeticShortcut;
         private char itemNumericShortcut;
@@ -311,8 +311,8 @@
             final int category = a.getInt(com.android.internal.R.styleable.MenuItem_menuCategory, groupCategory);
             final int order = a.getInt(com.android.internal.R.styleable.MenuItem_orderInCategory, groupOrder);
             itemCategoryOrder = (category & Menu.CATEGORY_MASK) | (order & Menu.USER_MASK);
-            itemTitle = a.getString(com.android.internal.R.styleable.MenuItem_title);
-            itemTitleCondensed = a.getString(com.android.internal.R.styleable.MenuItem_titleCondensed);
+            itemTitle = a.getText(com.android.internal.R.styleable.MenuItem_title);
+            itemTitleCondensed = a.getText(com.android.internal.R.styleable.MenuItem_titleCondensed);
             itemIconResId = a.getResourceId(com.android.internal.R.styleable.MenuItem_icon, 0);
             itemAlphabeticShortcut =
                     getShortcut(a.getString(com.android.internal.R.styleable.MenuItem_alphabeticShortcut));
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 5e8f31a..d0b150b 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -7539,10 +7539,6 @@
                 final int height = mBottom - mTop;
 
                 final ScrollBarDrawable scrollBar = cache.scrollBar;
-                int size = scrollBar.getSize(false);
-                if (size <= 0) {
-                    size = cache.scrollBarSize;
-                }
 
                 final int scrollX = mScrollX;
                 final int scrollY = mScrollY;
@@ -7551,6 +7547,11 @@
                 int left, top, right, bottom;
                 
                 if (drawHorizontalScrollBar) {
+                    int size = scrollBar.getSize(false);
+                    if (size <= 0) {
+                        size = cache.scrollBarSize;
+                    }
+
                     scrollBar.setParameters(computeHorizontalScrollRange(),
                                             computeHorizontalScrollOffset(),
                                             computeHorizontalScrollExtent(), false);
@@ -7567,6 +7568,11 @@
                 }
 
                 if (drawVerticalScrollBar) {
+                    int size = scrollBar.getSize(true);
+                    if (size <= 0) {
+                        size = cache.scrollBarSize;
+                    }
+
                     scrollBar.setParameters(computeVerticalScrollRange(),
                                             computeVerticalScrollOffset(),
                                             computeVerticalScrollExtent(), true);
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 41fc6c6..b21af41 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -1537,6 +1537,7 @@
                 int top = dirty.top;
                 int right = dirty.right;
                 int bottom = dirty.bottom;
+
                 canvas = surface.lockCanvas(dirty);
 
                 if (left != dirty.left || top != dirty.top || right != dirty.right ||
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index ec3c329..b7ffd14 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -88,6 +88,9 @@
     // Attached Javascript interfaces
     private Map<String, Object> mJSInterfaceMap;
 
+    // Key store handler when Chromium HTTP stack is used.
+    private KeyStoreHandler mKeyStoreHandler = null;
+
     // message ids
     // a message posted when a frame loading is completed
     static final int FRAME_COMPLETED = 1001;
@@ -1173,8 +1176,27 @@
         }
         mimeType = MimeTypeMap.getSingleton().remapGenericMimeType(
                 mimeType, url, contentDisposition);
-        mCallbackProxy.onDownloadStart(url, userAgent,
+
+        if (CertTool.getCertType(mimeType) != null) {
+            mKeyStoreHandler = new KeyStoreHandler(mimeType);
+        } else {
+            mCallbackProxy.onDownloadStart(url, userAgent,
                 contentDisposition, mimeType, contentLength);
+        }
+    }
+
+    /**
+     * Called by JNI for Chrome HTTP stack when the Java side needs to access the data.
+     */
+    private void didReceiveData(byte data[], int size) {
+        if (mKeyStoreHandler != null) mKeyStoreHandler.didReceiveData(data, size);
+    }
+
+    private void didFinishLoading() {
+      if (mKeyStoreHandler != null) {
+          mKeyStoreHandler.installCert(mContext);
+          mKeyStoreHandler = null;
+      }
     }
 
     /**
diff --git a/core/java/android/webkit/CertTool.java b/core/java/android/webkit/CertTool.java
index d25d970..4c534f9 100644
--- a/core/java/android/webkit/CertTool.java
+++ b/core/java/android/webkit/CertTool.java
@@ -29,6 +29,7 @@
 
 import java.security.KeyPair;
 import java.security.KeyPairGenerator;
+import java.util.HashMap;
 
 class CertTool {
     private static final String LOGTAG = "CertTool";
@@ -39,6 +40,14 @@
     static final String CERT = Credentials.CERTIFICATE;
     static final String PKCS12 = Credentials.PKCS12;
 
+    private static HashMap<String, String> sCertificateTypeMap;
+    static {
+        sCertificateTypeMap = new HashMap<String, String>();
+        sCertificateTypeMap.put("application/x-x509-ca-cert", CertTool.CERT);
+        sCertificateTypeMap.put("application/x-x509-user-cert", CertTool.CERT);
+        sCertificateTypeMap.put("application/x-pkcs12", CertTool.PKCS12);
+    }
+
     static String[] getKeyStrengthList() {
         return new String[] {"High Grade", "Medium Grade"};
     }
@@ -66,5 +75,9 @@
         Credentials.getInstance().install(context, type, value);
     }
 
+    static String getCertType(String mimeType) {
+        return sCertificateTypeMap.get(mimeType);
+  }
+
     private CertTool() {}
 }
diff --git a/core/java/android/webkit/KeyStoreHandler.java b/core/java/android/webkit/KeyStoreHandler.java
new file mode 100644
index 0000000..849007e
--- /dev/null
+++ b/core/java/android/webkit/KeyStoreHandler.java
@@ -0,0 +1,77 @@
+/*
+ * 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.webkit;
+
+import android.content.Context;
+import android.os.Handler;
+import android.util.Log;
+
+/**
+ * KeyStoreHandler: class responsible for certificate installation to
+ * the system key store. It reads the certificates file from network
+ * then pass the bytes to class CertTool.
+ * This class is only needed if the Chromium HTTP stack is used.
+ */
+class KeyStoreHandler extends Handler {
+    private static final String LOGTAG = "KeyStoreHandler";
+
+    private final ByteArrayBuilder mDataBuilder = new ByteArrayBuilder();
+
+    private String mMimeType;
+
+    public KeyStoreHandler(String mimeType) {
+      mMimeType = mimeType;
+    }
+
+    /**
+     * Add data to the internal collection of data.
+     * @param data A byte array containing the content.
+     * @param length The length of data.
+     */
+    public void didReceiveData(byte[] data, int length) {
+        synchronized (mDataBuilder) {
+            mDataBuilder.append(data, 0, length);
+        }
+    }
+
+    public void installCert(Context context) {
+        String type = CertTool.getCertType(mMimeType);
+        if (type == null) return;
+
+        // This must be synchronized so that no more data can be added
+        // after getByteSize returns.
+        synchronized (mDataBuilder) {
+            // In the case of downloading certificate, we will save it
+            // to the KeyStore and stop the current loading so that it
+            // will not generate a new history page
+            byte[] cert = new byte[mDataBuilder.getByteSize()];
+            int offset = 0;
+            while (true) {
+                ByteArrayBuilder.Chunk c = mDataBuilder.getFirstChunk();
+                if (c == null) break;
+
+                if (c.mLength != 0) {
+                    System.arraycopy(c.mArray, 0, cert, offset, c.mLength);
+                    offset += c.mLength;
+                }
+                c.release();
+            }
+            CertTool.addCertificate(context, type, cert);
+            return;
+        }
+    }
+}
diff --git a/core/java/android/webkit/LoadListener.java b/core/java/android/webkit/LoadListener.java
index 6d1d39a..04af738 100644
--- a/core/java/android/webkit/LoadListener.java
+++ b/core/java/android/webkit/LoadListener.java
@@ -75,14 +75,6 @@
     private static final int HTTP_NOT_FOUND = 404;
     private static final int HTTP_PROXY_AUTH = 407;
 
-    private static HashMap<String, String> sCertificateTypeMap;
-    static {
-        sCertificateTypeMap = new HashMap<String, String>();
-        sCertificateTypeMap.put("application/x-x509-ca-cert", CertTool.CERT);
-        sCertificateTypeMap.put("application/x-x509-user-cert", CertTool.CERT);
-        sCertificateTypeMap.put("application/x-pkcs12", CertTool.PKCS12);
-    }
-
     private static int sNativeLoaderCount;
 
     private final ByteArrayBuilder mDataBuilder = new ByteArrayBuilder();
@@ -1053,7 +1045,7 @@
 
     // This commits the headers without checking the response status code.
     private void commitHeaders() {
-        if (mIsMainPageLoader && sCertificateTypeMap.containsKey(mMimeType)) {
+        if (mIsMainPageLoader && CertTool.getCertType(mMimeType) != null) {
             // In the case of downloading certificate, we will save it to the
             // KeyStore in commitLoad. Do not call webcore.
             return;
@@ -1114,7 +1106,7 @@
         }
 
         if (mIsMainPageLoader) {
-            String type = sCertificateTypeMap.get(mMimeType);
+            String type = CertTool.getCertType(mMimeType);
             if (type != null) {
                 // This must be synchronized so that no more data can be added
                 // after getByteSize returns.
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 2a2b3af0..6363299 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -673,6 +673,7 @@
     static final int AUTOFILL_COMPLETE                  = 134;
 
     static final int SELECT_AT                          = 135;
+    static final int SCREEN_ON                          = 136;
 
     private static final int FIRST_PACKAGE_MSG_ID = SCROLL_TO_MSG_ID;
     private static final int LAST_PACKAGE_MSG_ID = SET_TOUCH_HIGHLIGHT_RECTS;
@@ -726,7 +727,8 @@
         "SAVE_WEBARCHIVE_FINISHED", //       = 132;
         "SET_AUTOFILLABLE", //               = 133;
         "AUTOFILL_COMPLETE", //              = 134;
-        "SELECT_AT" //                       = 135;
+        "SELECT_AT", //                      = 135;
+        "SCREEN_ON" //                       = 136;
     };
 
     // If the site doesn't use the viewport meta tag to specify the viewport,
@@ -7454,6 +7456,10 @@
                     doMotionUp(msg.arg1, msg.arg2);
                     break;
 
+                case SCREEN_ON:
+                    setKeepScreenOn(msg.arg1 == 1);
+                    break;
+
                 case SHOW_FULLSCREEN: {
                     View view = (View) msg.obj;
                     int npp = msg.arg1;
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 27bf51c..3bde000 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -2549,6 +2549,15 @@
     }
 
     // called by JNI
+    private void keepScreenOn(boolean screenOn) {
+        if (mWebView != null) {
+            Message message = mWebView.mPrivateHandler.obtainMessage(WebView.SCREEN_ON);
+            message.arg1 = screenOn ? 1 : 0;
+            message.sendToTarget();
+        }
+    }
+
+    // called by JNI
     private Class<?> getPluginClass(String libName, String clsName) {
         
         if (mWebView == null) {
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 7293572..4a34b45 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -30,6 +30,7 @@
 import android.util.Log;
 import android.util.SparseArray;
 import android.view.LayoutInflater;
+import android.view.accessibility.AccessibilityEvent;
 import android.widget.NumberPicker.OnValueChangeListener;
 
 import java.text.ParseException;
@@ -353,6 +354,16 @@
         return mIsEnabled;
     }
 
+    @Override
+    public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+        int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY
+                | DateUtils.FORMAT_SHOW_YEAR;
+        String selectedDateUtterance = DateUtils.formatDateTime(mContext,
+                mCurrentDate.getTimeInMillis(), flags);
+        event.getText().add(selectedDateUtterance);
+        return true;
+    }
+
     /**
      * Gets whether the {@link CalendarView} is shown.
      *
@@ -641,6 +652,7 @@
      * Notifies the listener, if such, for a change in the selected date.
      */
     private void notifyDateChanged() {
+        sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
         if (mOnDateChangedListener != null) {
             mOnDateChangedListener.onDateChanged(this, getYear(), getMonth(), getDayOfMonth());
         }
diff --git a/core/java/android/widget/ListPopupWindow.java b/core/java/android/widget/ListPopupWindow.java
index 5dc42e4..8116a12 100644
--- a/core/java/android/widget/ListPopupWindow.java
+++ b/core/java/android/widget/ListPopupWindow.java
@@ -190,6 +190,7 @@
     public ListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
         mContext = context;
         mPopup = new PopupWindow(context, attrs, defStyleAttr, defStyleRes);
+        mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
     }
 
     /**
@@ -576,7 +577,6 @@
             }
 
             mPopup.setWindowLayoutMode(widthSpec, heightSpec);
-            mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
             mPopup.setClipToScreenEnabled(true);
             
             // use outside touchable to dismiss drop down when touching outside of it, so
diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java
index 0baddcb..a92272c 100644
--- a/core/java/android/widget/Spinner.java
+++ b/core/java/android/widget/Spinner.java
@@ -665,6 +665,7 @@
         @Override
         public void show() {
             setWidth(Spinner.this.getWidth());
+            setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
             super.show();
             getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
             setSelection(Spinner.this.getSelectedItemPosition());
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index b024dcb..b217052 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -3320,7 +3320,7 @@
 
             } else if (actionCode == EditorInfo.IME_ACTION_DONE) {
                 InputMethodManager imm = InputMethodManager.peekInstance();
-                if (imm != null) {
+                if (imm != null && imm.isActive(this)) {
                     imm.hideSoftInputFromWindow(getWindowToken(), 0);
                 }
                 return;
@@ -4822,9 +4822,8 @@
                     if (mOnClickListener == null) {
                         if (mMovement != null && mText instanceof Editable
                                 && mLayout != null && onCheckIsTextEditor()) {
-                            InputMethodManager imm = (InputMethodManager)
-                                    getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
-                            imm.showSoftInput(this, 0);
+                            InputMethodManager imm = InputMethodManager.peekInstance();
+                            if (imm != null) imm.showSoftInput(this, 0);
                         }
                     }
                 }
@@ -4877,7 +4876,7 @@
                                 // No target for next focus, but make sure the IME
                                 // if this came from it.
                                 InputMethodManager imm = InputMethodManager.peekInstance();
-                                if (imm != null) {
+                                if (imm != null && imm.isActive(this)) {
                                     imm.hideSoftInputFromWindow(getWindowToken(), 0);
                                 }
                             }
@@ -7149,10 +7148,8 @@
         // the IME. Showing the IME while focus is moved using the D-Pad is a bad idea, however this
         // does not happen in that case (using the arrows on a bluetooth keyboard).
         if (focused && isTextEditable()) {
-            final InputMethodManager imm = (InputMethodManager)
-            getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
-
-            imm.showSoftInput(this, 0, null);
+            final InputMethodManager imm = InputMethodManager.peekInstance();
+            if (imm != null) imm.showSoftInput(this, 0, null);
         }
     }
 
@@ -7346,10 +7343,8 @@
 
                     // Show the IME, except when selecting in read-only text.
                     if (!mTextIsSelectable) {
-                        final InputMethodManager imm = (InputMethodManager)
-                                getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
-
-                        handled |= imm.showSoftInput(this, 0, csr) && (csr != null);
+                        final InputMethodManager imm = InputMethodManager.peekInstance();
+                        handled |= imm != null && imm.showSoftInput(this, 0, csr) && (csr != null);
                     }
 
                     stopSelectionActionMode();
@@ -8247,16 +8242,17 @@
             selectCurrentWord();
         }
 
-        if (!mTextIsSelectable) {
-            // Show the IME, except when selection non editable text.
-            final InputMethodManager imm = (InputMethodManager)
-                    getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
-            imm.showSoftInput(this, 0, null);
-        }
-
         ActionMode.Callback actionModeCallback = new SelectionActionModeCallback();
         mSelectionActionMode = startActionMode(actionModeCallback);
-        return mSelectionActionMode != null;
+        final boolean selectionStarted = mSelectionActionMode != null;
+
+        if (selectionStarted && !mTextIsSelectable) {
+            // Show the IME to be able to replace text, except when selecting non editable text.
+            final InputMethodManager imm = InputMethodManager.peekInstance();
+            if (imm != null) imm.showSoftInput(this, 0, null);
+        }
+
+        return selectionStarted;
     }
 
     /**
diff --git a/core/java/android/widget/TimePicker.java b/core/java/android/widget/TimePicker.java
index 2688b95..4b37beb 100644
--- a/core/java/android/widget/TimePicker.java
+++ b/core/java/android/widget/TimePicker.java
@@ -23,9 +23,11 @@
 import android.content.res.TypedArray;
 import android.os.Parcel;
 import android.os.Parcelable;
+import android.text.format.DateUtils;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.accessibility.AccessibilityEvent;
 import android.widget.NumberPicker.OnValueChangeListener;
 
 import java.text.DateFormatSymbols;
@@ -88,6 +90,8 @@
     // callbacks
     private OnTimeChangedListener mOnTimeChangedListener;
 
+    private Calendar mTempCalendar;
+
     /**
      * The callback interface used to indicate the time has been adjusted.
      */
@@ -214,12 +218,12 @@
         updateAmPmControl();
 
         // initialize to current time
-        Calendar calendar = Calendar.getInstance();
+        mTempCalendar = Calendar.getInstance();
         setOnTimeChangedListener(NO_OP_CHANGE_LISTENER);
 
         // set to current time
-        setCurrentHour(calendar.get(Calendar.HOUR_OF_DAY));
-        setCurrentMinute(calendar.get(Calendar.MINUTE));
+        setCurrentHour(mTempCalendar.get(Calendar.HOUR_OF_DAY));
+        setCurrentMinute(mTempCalendar.get(Calendar.MINUTE));
 
         if (!isEnabled()) {
             setEnabled(false);
@@ -406,6 +410,22 @@
         return mHourSpinner.getBaseline();
     }
 
+    @Override
+    public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+        int flags = DateUtils.FORMAT_SHOW_TIME;
+        if (mIs24HourView) {
+            flags |= DateUtils.FORMAT_24HOUR;
+        } else {
+            flags |= DateUtils.FORMAT_12HOUR;
+        }
+        mTempCalendar.set(Calendar.HOUR_OF_DAY, getCurrentHour());
+        mTempCalendar.set(Calendar.MINUTE, getCurrentMinute());
+        String selectedDateUtterance = DateUtils.formatDateTime(mContext,
+                mTempCalendar.getTimeInMillis(), flags);
+        event.getText().add(selectedDateUtterance);
+        return true;
+    }
+
     private void updateHourControl() {
         if (is24HourView()) {
             mHourSpinner.setMinValue(0);
@@ -435,9 +455,11 @@
                 mAmPmButton.setVisibility(View.VISIBLE);
             }
         }
+        sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
     }
 
     private void onTimeChanged() {
+        sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
         if (mOnTimeChangedListener != null) {
             mOnTimeChangedListener.onTimeChanged(this, getCurrentHour(), getCurrentMinute());
         }
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index e4af33f..aa9c107 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -296,8 +296,10 @@
 static jobject Surface_lockCanvas(JNIEnv* env, jobject clazz, jobject dirtyRect)
 {
     const sp<Surface>& surface(getSurface(env, clazz));
-    if (!Surface::isValid(surface))
+    if (!Surface::isValid(surface)) {
+        doThrow(env, "java/lang/IllegalArgumentException", NULL);
         return 0;
+    }
 
     // get dirty region
     Region dirtyRegion;
diff --git a/core/res/res/anim/lock_screen_behind_enter.xml b/core/res/res/anim/lock_screen_behind_enter.xml
index c01e265..6c7782e 100644
--- a/core/res/res/anim/lock_screen_behind_enter.xml
+++ b/core/res/res/anim/lock_screen_behind_enter.xml
@@ -3,21 +3,34 @@
 /*
 ** Copyright 2007, 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 
+** 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 
+**     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 
+** 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" android:interpolator="@interpolator/accelerate_cubic">
-    <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
-            android:duration="@android:integer/config_activityDefaultDur" />
-</set>
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+    android:detachWallpaper="true" android:shareInterpolator="false">
+    <scale
+        android:fromXScale="0.9" android:toXScale="1.0"
+        android:fromYScale="0.9" android:toYScale="1.0"
+        android:pivotX="50%p" android:pivotY="50%p"
+        android:fillEnabled="true" android:fillBefore="true"
+        android:interpolator="@interpolator/decelerate_cubic"
+        android:startOffset="@android:integer/config_mediumAnimTime"
+        android:duration="@android:integer/config_mediumAnimTime" />
+    <alpha
+        android:fromAlpha="0" android:toAlpha="1.0"
+        android:fillEnabled="true" android:fillBefore="true"
+        android:interpolator="@interpolator/decelerate_quad"
+        android:startOffset="@android:integer/config_mediumAnimTime"
+        android:duration="@android:integer/config_mediumAnimTime"/>
+</set>
\ No newline at end of file
diff --git a/core/res/res/anim/lock_screen_exit.xml b/core/res/res/anim/lock_screen_exit.xml
index 44ca736..d9c3a33 100644
--- a/core/res/res/anim/lock_screen_exit.xml
+++ b/core/res/res/anim/lock_screen_exit.xml
@@ -3,22 +3,33 @@
 /*
 ** Copyright 2007, 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 
+** 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 
+**     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 
+** 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"
-        android:interpolator="@interpolator/decelerate_cubic">
-	<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
-            android:duration="@android:integer/config_activityDefaultDur" />
-</set>
+    android:zAdjustment="top"
+    android:shareInterpolator="false">
+    <scale
+        android:fromXScale="1.0" android:toXScale="1.2"
+        android:fromYScale="1.0" android:toYScale="1.2"
+        android:pivotX="50%p" android:pivotY="50%p"
+        android:fillEnabled="true" android:fillAfter="true"
+        android:interpolator="@interpolator/accelerate_quint"
+        android:duration="@android:integer/config_mediumAnimTime" />
+    <alpha
+        android:fromAlpha="1.0" android:toAlpha="0"
+        android:fillEnabled="true" android:fillAfter="true"
+        android:interpolator="@interpolator/accelerate_quad"
+        android:duration="@android:integer/config_mediumAnimTime"/>
+</set>
\ No newline at end of file
diff --git a/core/res/res/drawable-hdpi/stat_sys_download_anim0.png b/core/res/res/drawable-hdpi/stat_sys_download_anim0.png
index 8858a75..943e620 100644
--- a/core/res/res/drawable-hdpi/stat_sys_download_anim0.png
+++ b/core/res/res/drawable-hdpi/stat_sys_download_anim0.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_download_anim1.png b/core/res/res/drawable-hdpi/stat_sys_download_anim1.png
index 5418785..28edae1 100644
--- a/core/res/res/drawable-hdpi/stat_sys_download_anim1.png
+++ b/core/res/res/drawable-hdpi/stat_sys_download_anim1.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_download_anim2.png b/core/res/res/drawable-hdpi/stat_sys_download_anim2.png
index f55887e..556a46f 100644
--- a/core/res/res/drawable-hdpi/stat_sys_download_anim2.png
+++ b/core/res/res/drawable-hdpi/stat_sys_download_anim2.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_download_anim3.png b/core/res/res/drawable-hdpi/stat_sys_download_anim3.png
index 50fcc36..422d72b 100644
--- a/core/res/res/drawable-hdpi/stat_sys_download_anim3.png
+++ b/core/res/res/drawable-hdpi/stat_sys_download_anim3.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_download_anim4.png b/core/res/res/drawable-hdpi/stat_sys_download_anim4.png
index 65ac698..24a0db5 100644
--- a/core/res/res/drawable-hdpi/stat_sys_download_anim4.png
+++ b/core/res/res/drawable-hdpi/stat_sys_download_anim4.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_download_anim5.png b/core/res/res/drawable-hdpi/stat_sys_download_anim5.png
index 7fb6032..97e5a6b 100644
--- a/core/res/res/drawable-hdpi/stat_sys_download_anim5.png
+++ b/core/res/res/drawable-hdpi/stat_sys_download_anim5.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_sys_download_anim0.png b/core/res/res/drawable-mdpi/stat_sys_download_anim0.png
index a326868..39e4ccb 100644
--- a/core/res/res/drawable-mdpi/stat_sys_download_anim0.png
+++ b/core/res/res/drawable-mdpi/stat_sys_download_anim0.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_sys_download_anim1.png b/core/res/res/drawable-mdpi/stat_sys_download_anim1.png
index 42e5c2a..429ebd7 100644
--- a/core/res/res/drawable-mdpi/stat_sys_download_anim1.png
+++ b/core/res/res/drawable-mdpi/stat_sys_download_anim1.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_sys_download_anim2.png b/core/res/res/drawable-mdpi/stat_sys_download_anim2.png
index 0c27622..b3de461 100644
--- a/core/res/res/drawable-mdpi/stat_sys_download_anim2.png
+++ b/core/res/res/drawable-mdpi/stat_sys_download_anim2.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_sys_download_anim3.png b/core/res/res/drawable-mdpi/stat_sys_download_anim3.png
index b1b84d4..195498e 100644
--- a/core/res/res/drawable-mdpi/stat_sys_download_anim3.png
+++ b/core/res/res/drawable-mdpi/stat_sys_download_anim3.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_sys_download_anim4.png b/core/res/res/drawable-mdpi/stat_sys_download_anim4.png
index 75cc99c..8fc3e86 100644
--- a/core/res/res/drawable-mdpi/stat_sys_download_anim4.png
+++ b/core/res/res/drawable-mdpi/stat_sys_download_anim4.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_sys_download_anim5.png b/core/res/res/drawable-mdpi/stat_sys_download_anim5.png
index c21b6ac..c6f2f4e 100644
--- a/core/res/res/drawable-mdpi/stat_sys_download_anim5.png
+++ b/core/res/res/drawable-mdpi/stat_sys_download_anim5.png
Binary files differ
diff --git a/core/res/res/layout/number_picker.xml b/core/res/res/layout/number_picker.xml
index f92c1bc..807daf2 100644
--- a/core/res/res/layout/number_picker.xml
+++ b/core/res/res/layout/number_picker.xml
@@ -22,7 +22,8 @@
     <ImageButton android:id="@+id/increment"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
-        style="?android:attr/numberPickerUpButtonStyle" />
+        style="?android:attr/numberPickerUpButtonStyle"
+        android:contentDescription="@string/number_picker_increment_button" />
 
     <EditText android:id="@+id/numberpicker_input"
         android:layout_width="fill_parent"
@@ -32,6 +33,7 @@
     <ImageButton android:id="@+id/decrement"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
-        style="?android:attr/numberPickerDownButtonStyle" />
+        style="?android:attr/numberPickerDownButtonStyle"
+        android:contentDescription="@string/number_picker_decrement_button" />
 
 </merge>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 529111e..d09210e 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2690,4 +2690,11 @@
 
     <!-- Choose Account Activity label -->
     <string name="choose_account_label">Select an account</string>
+
+    <!-- NumberPicker - accessibility support -->
+    <!-- Description of the button to increment the NumberPicker value. [CHAR LIMIT=NONE] -->
+    <string name="number_picker_increment_button">Increment</string>
+    <!-- Description of the button to decrement the NumberPicker value. [CHAR LIMIT=NONE] -->
+    <string name="number_picker_decrement_button">Decrement</string>
+
 </resources>
diff --git a/data/etc/android.hardware.touchscreen.multitouch.distinct.xml b/data/etc/android.hardware.touchscreen.multitouch.distinct.xml
index a3c116a..35eeefd 100644
--- a/data/etc/android.hardware.touchscreen.multitouch.distinct.xml
+++ b/data/etc/android.hardware.touchscreen.multitouch.distinct.xml
@@ -20,4 +20,5 @@
     <feature name="android.hardware.touchscreen" />
     <feature name="android.hardware.touchscreen.multitouch" />
     <feature name="android.hardware.touchscreen.multitouch.distinct" />
+    <feature name="android.hardware.faketouch" />
 </permissions>
diff --git a/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml b/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml
index 80bf859..ed6606d 100644
--- a/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml
+++ b/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml
@@ -21,4 +21,5 @@
     <feature name="android.hardware.touchscreen.multitouch" />
     <feature name="android.hardware.touchscreen.multitouch.distinct" />
     <feature name="android.hardware.touchscreen.multitouch.jazzhand" />
+    <feature name="android.hardware.faketouch" />
 </permissions>
diff --git a/data/etc/android.hardware.touchscreen.multitouch.xml b/data/etc/android.hardware.touchscreen.multitouch.xml
index 34b518a..1d59a27 100644
--- a/data/etc/android.hardware.touchscreen.multitouch.xml
+++ b/data/etc/android.hardware.touchscreen.multitouch.xml
@@ -20,4 +20,5 @@
 <permissions>
     <feature name="android.hardware.touchscreen" />
     <feature name="android.hardware.touchscreen.multitouch" />
+    <feature name="android.hardware.faketouch" />
 </permissions>
diff --git a/data/etc/android.hardware.touchscreen.xml b/data/etc/android.hardware.touchscreen.xml
index 10c91f1..5b5ddf9 100644
--- a/data/etc/android.hardware.touchscreen.xml
+++ b/data/etc/android.hardware.touchscreen.xml
@@ -18,4 +18,5 @@
      support multitouch. -->
 <permissions>
     <feature name="android.hardware.touchscreen" />
+    <feature name="android.hardware.faketouch" />
 </permissions>
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 7312d75..cbc7529 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -1450,7 +1450,7 @@
         if (AudioSystem.getForceUse(AudioSystem.FOR_COMMUNICATION) == AudioSystem.FORCE_BT_SCO) {
             // Log.v(TAG, "getActiveStreamType: Forcing STREAM_BLUETOOTH_SCO...");
             return AudioSystem.STREAM_BLUETOOTH_SCO;
-        } else if (isOffhook || AudioSystem.isStreamActive(AudioSystem.STREAM_VOICE_CALL)) {
+        } else if (isOffhook || getMode() == AudioManager.MODE_IN_COMMUNICATION) {
             // Log.v(TAG, "getActiveStreamType: Forcing STREAM_VOICE_CALL...");
             return AudioSystem.STREAM_VOICE_CALL;
         } else if (AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC)) {
diff --git a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
index 1244b8e..f438be8 100644
--- a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
+++ b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
@@ -2105,7 +2105,6 @@
                 //For image get the scaled height. Aspect ratio would remain the same
                 mediaItemHeight = ((MediaImageItem)overlay.getMediaItem()).getScaledHeight();
                 aspectRatio = overlay.getMediaItem().getAspectRatio();
-                effectSettings.framingResize = false; //since the image can be of odd size.
             }
         } else {
             aspectRatio = overlay.getMediaItem().getAspectRatio();
diff --git a/media/java/android/media/videoeditor/MediaImageItem.java b/media/java/android/media/videoeditor/MediaImageItem.java
index a977b8e..f1315c0 100755
--- a/media/java/android/media/videoeditor/MediaImageItem.java
+++ b/media/java/android/media/videoeditor/MediaImageItem.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 The Android Open Source Project
+ * 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.
@@ -71,6 +71,7 @@
     private String mDecodedFilename;
     private int mGeneratedClipHeight;
     private int mGeneratedClipWidth;
+    private String mFileName;
 
     private final MediaArtistNativeHelper mMANativeHelper;
 
@@ -116,7 +117,7 @@
         } catch (Exception e) {
             throw new IllegalArgumentException("Unsupported file or file not found: " + filename);
         }
-
+        mFileName = filename;
         /**
          *  Determine the dimensions of the image
          */
@@ -149,108 +150,53 @@
         /**
          *  Get the highest resolution
          */
-        final FileOutputStream fl = new FileOutputStream(mDecodedFilename);
-        final DataOutputStream dos = new DataOutputStream(fl);
         final Pair<Integer, Integer> maxResolution = resolutions[resolutions.length - 1];
+
+        final Bitmap imageBitmap;
+
         if (mHeight > maxResolution.second) {
             /**
              *  We need to scale the image
              */
-            final Bitmap scaledImage = scaleImage(filename, maxResolution.first,
-                                                          maxResolution.second);
+            imageBitmap = scaleImage(filename, maxResolution.first,
+                                                         maxResolution.second);
             mScaledFilename = String.format(mMANativeHelper.getProjectPath() +
                     "/" + "scaled" + getId()+ ".JPG");
             if (!((new File(mScaledFilename)).exists())) {
                 super.mRegenerateClip = true;
                 final FileOutputStream f1 = new FileOutputStream(mScaledFilename);
-                scaledImage.compress(Bitmap.CompressFormat.JPEG, 50,f1);
+                imageBitmap.compress(Bitmap.CompressFormat.JPEG, 50,f1);
                 f1.close();
             }
-            mScaledWidth = scaledImage.getWidth();
-            mScaledHeight = scaledImage.getHeight();
-
-            int mNewWidth = 0;
-            int mNewHeight = 0;
-            if ((mScaledWidth % 2 ) != 0) {
-                mNewWidth = mScaledWidth - 1;
-            } else {
-                mNewWidth = mScaledWidth;
-            }
-
-            if ((mScaledHeight % 2 ) != 0) {
-                mNewHeight = mScaledHeight - 1;
-            } else {
-                mNewHeight = mScaledHeight;
-            }
-
-            final int [] framingBuffer = new int[mNewWidth];
+            mScaledWidth =  (imageBitmap.getWidth() >> 1) << 1;
+            mScaledHeight = (imageBitmap.getHeight() >> 1) << 1;
+        } else {
+            mScaledFilename = filename;
+            mScaledWidth =  (mWidth >> 1) << 1;
+            mScaledHeight = (mHeight >> 1) << 1;
+            imageBitmap = BitmapFactory.decodeFile(mScaledFilename);
+        }
+        int newWidth = mScaledWidth;
+        int newHeight = mScaledHeight;
+        if (!((new File(mDecodedFilename)).exists())) {
+            final FileOutputStream fl = new FileOutputStream(mDecodedFilename);
+            final DataOutputStream dos = new DataOutputStream(fl);
+            final int [] framingBuffer = new int[newWidth];
             final ByteBuffer byteBuffer = ByteBuffer.allocate(framingBuffer.length * 4);
             IntBuffer intBuffer;
-
             final byte[] array = byteBuffer.array();
             int tmp = 0;
-            while (tmp < mNewHeight) {
-                scaledImage.getPixels(framingBuffer,0,mScaledWidth,0,
-                                                               tmp,mNewWidth,1);
+            while (tmp < newHeight) {
+                imageBitmap.getPixels(framingBuffer, 0, mScaledWidth, 0,
+                                                        tmp, newWidth, 1);
                 intBuffer = byteBuffer.asIntBuffer();
-                intBuffer.put(framingBuffer,0,mNewWidth);
+                intBuffer.put(framingBuffer, 0, newWidth);
                 dos.write(array);
                 tmp += 1;
             }
-
-            mScaledWidth = mNewWidth;
-            mScaledHeight = mNewHeight;
-            scaledImage.recycle();
-        } else {
-            final Bitmap scaledImage = BitmapFactory.decodeFile(filename);
-            mScaledFilename = String.format(mMANativeHelper.getProjectPath()
-                                + "/" + "scaled" + getId()+ ".JPG");
-            if (!((new File(mScaledFilename)).exists())) {
-                super.mRegenerateClip = true;
-                final FileOutputStream f1 = new FileOutputStream(mScaledFilename);
-                scaledImage.compress(Bitmap.CompressFormat.JPEG, 50,f1);
-                f1.close();
-            }
-
-            mScaledWidth = scaledImage.getWidth();
-            mScaledHeight = scaledImage.getHeight();
-
-            int mNewWidth = 0;
-            int mNewheight = 0;
-            if ((mScaledWidth % 2 ) != 0) {
-                mNewWidth = mScaledWidth - 1;
-            } else {
-                mNewWidth = mScaledWidth;
-            }
-
-            if ((mScaledHeight % 2 ) != 0) {
-                mNewheight = mScaledHeight - 1;
-            } else {
-                mNewheight = mScaledHeight;
-            }
-
-            final Bitmap imageBitmap = BitmapFactory.decodeFile(mScaledFilename);
-            final int [] framingBuffer = new int[mNewWidth];
-            ByteBuffer byteBuffer = ByteBuffer.allocate(framingBuffer.length * 4);
-            IntBuffer intBuffer;
-
-            byte[] array = byteBuffer.array();
-            int tmp = 0;
-            while (tmp < mNewheight) {
-                imageBitmap.getPixels(framingBuffer,0,mScaledWidth,0,
-                                                               tmp,mNewWidth,1);
-                intBuffer = byteBuffer.asIntBuffer();
-                intBuffer.put(framingBuffer,0,mNewWidth);
-                dos.write(array);
-                tmp += 1;
-            }
-
-            mScaledWidth = mNewWidth;
-            mScaledHeight = mNewheight;
-            imageBitmap.recycle();
+            fl.close();
         }
-
-        fl.close();
+        imageBitmap.recycle();
         System.gc();
     }
 
@@ -772,7 +718,9 @@
         }
 
         if (mScaledFilename != null) {
-            new File(mScaledFilename).delete();
+            if(mFileName != mScaledFilename) {
+                new File(mScaledFilename).delete();
+            }
             mScaledFilename = null;
         }
 
diff --git a/media/java/android/media/videoeditor/OverlayFrame.java b/media/java/android/media/videoeditor/OverlayFrame.java
index 834fc66..0a928fe 100755
--- a/media/java/android/media/videoeditor/OverlayFrame.java
+++ b/media/java/android/media/videoeditor/OverlayFrame.java
@@ -235,7 +235,7 @@
          mOFWidth = width;
      }
     /**
-     * Delete the overlay file
+     * Delete the overlay files
      */
     void invalidate() {
         if (mFilename != null) {
@@ -244,5 +244,9 @@
             mBitmap.recycle();
             mBitmap = null;
         }
+        if (mBitmapFileName != null) {
+            new File(mBitmapFileName).delete();
+            mBitmapFileName = null;
+        }
     }
 }
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_pocket.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_pocket.png
deleted file mode 100644
index 12b6cea..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_pocket.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_pocket_drag.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_pocket_drag.png
deleted file mode 100644
index 28590bc..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_pocket_drag.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_pocket_hidden.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_pocket_hidden.png
deleted file mode 100644
index c66ad77..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_pocket_hidden.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_pocket_holding.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_pocket_holding.png
deleted file mode 100644
index 6416969..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_pocket_holding.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/scrubber_control_disabled_holo.png b/packages/SystemUI/res/drawable-hdpi/scrubber_control_disabled_holo.png
new file mode 100644
index 0000000..18bd8b4
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/scrubber_control_disabled_holo.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/scrubber_control_holo.png b/packages/SystemUI/res/drawable-hdpi/scrubber_control_holo.png
new file mode 100644
index 0000000..993ccf4
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/scrubber_control_holo.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_pocket.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_pocket.png
deleted file mode 100644
index 90dffa9..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_pocket.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_pocket_drag.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_pocket_drag.png
deleted file mode 100644
index dcce495..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_pocket_drag.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_pocket_hidden.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_pocket_hidden.png
deleted file mode 100644
index 93b0d23..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_pocket_hidden.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_pocket_holding.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_pocket_holding.png
deleted file mode 100644
index 9eb9dc6..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_pocket_holding.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/scrubber_control_disabled_holo.png b/packages/SystemUI/res/drawable-mdpi/scrubber_control_disabled_holo.png
index b8adc97..7e679ed 100644
--- a/packages/SystemUI/res/drawable-mdpi/scrubber_control_disabled_holo.png
+++ b/packages/SystemUI/res/drawable-mdpi/scrubber_control_disabled_holo.png
Binary files differ
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java
index 5184462..a072aed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java
@@ -53,7 +53,7 @@
 
     private static final String TAG = "StatusBar.TabletTicker";
 
-    private static final boolean CLICKABLE_TICKER = false;
+    private static final boolean CLICKABLE_TICKER = true;
 
     // 3 is enough to let us see most cases, but not get so far behind that it's too annoying.
     private static final int QUEUE_LENGTH = 3;
@@ -300,8 +300,16 @@
         if (CLICKABLE_TICKER) {
             PendingIntent contentIntent = notification.notification.contentIntent;
             if (contentIntent != null) {
-                group.setOnClickListener(mBar.makeClicker(contentIntent,
-                            notification.pkg, notification.tag, notification.id));
+                // create the usual notification clicker, but chain it together with a halt() call
+                // to abort the ticker too
+                final View.OnClickListener clicker = mBar.makeClicker(contentIntent,
+                                            notification.pkg, notification.tag, notification.id);
+                group.setOnClickListener(new View.OnClickListener() {
+                    public void onClick(View v) {
+                        halt();
+                        clicker.onClick(v);
+                    }
+                });
             } else {
                 group.setOnClickListener(null);
             }
diff --git a/tools/layoutlib/bridge/.classpath b/tools/layoutlib/bridge/.classpath
index 2102eb1..64c1fb5 100644
--- a/tools/layoutlib/bridge/.classpath
+++ b/tools/layoutlib/bridge/.classpath
@@ -8,5 +8,6 @@
 	<classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/kxml2/kxml2-2.3.0.jar" sourcepath="/ANDROID_PLAT_SRC/dalvik/libcore/xml/src/main/java"/>
 	<classpathentry kind="var" path="ANDROID_PLAT_SRC/out/host/common/obj/JAVA_LIBRARIES/temp_layoutlib_intermediates/javalib.jar" sourcepath="/ANDROID_PLAT_SRC/frameworks/base"/>
 	<classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/ninepatch/ninepatch-prebuilt.jar"/>
+	<classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/resources/resources-prebuilt.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/tools/layoutlib/bridge/Android.mk b/tools/layoutlib/bridge/Android.mk
index a0a7307..57dd7ae 100644
--- a/tools/layoutlib/bridge/Android.mk
+++ b/tools/layoutlib/bridge/Android.mk
@@ -20,7 +20,8 @@
 
 LOCAL_JAVA_LIBRARIES := \
 	kxml2-2.3.0 \
-	layoutlib_api-prebuilt
+	layoutlib_api-prebuilt \
+	resources-prebuilt
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
 	temp_layoutlib \
diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java
index db3cf44..993c305 100644
--- a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java
+++ b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java
@@ -17,8 +17,8 @@
 package android.graphics;
 
 import com.android.ide.common.rendering.api.LayoutLog;
-import com.android.ide.common.rendering.api.ResourceDensity;
 import com.android.layoutlib.bridge.Bridge;
+import com.android.resources.Density;
 
 import android.content.res.AssetManager;
 import android.content.res.Resources;
@@ -462,9 +462,9 @@
             // into is.read(...) This number is not related to the value passed
             // to mark(...) above.
             try {
-                ResourceDensity density = ResourceDensity.MEDIUM;
+                Density density = Density.MEDIUM;
                 if (opts != null) {
-                    density = ResourceDensity.getEnum(opts.inDensity);
+                    density = Density.getEnum(opts.inDensity);
                 }
                 bm = Bitmap_Delegate.createBitmap(is, true, density);
             } catch (IOException e) {
diff --git a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
index 108d183..efe6955 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
@@ -17,9 +17,9 @@
 package android.graphics;
 
 import com.android.ide.common.rendering.api.LayoutLog;
-import com.android.ide.common.rendering.api.ResourceDensity;
 import com.android.layoutlib.bridge.Bridge;
 import com.android.layoutlib.bridge.impl.DelegateManager;
+import com.android.resources.Density;
 
 import android.graphics.Bitmap.Config;
 import android.os.Parcel;
@@ -89,12 +89,12 @@
      * @see Bitmap#isMutable()
      * @see Bitmap#getDensity()
      */
-    public static Bitmap createBitmap(File input, boolean isMutable, ResourceDensity density)
+    public static Bitmap createBitmap(File input, boolean isMutable, Density density)
             throws IOException {
         // create a delegate with the content of the file.
         Bitmap_Delegate delegate = new Bitmap_Delegate(ImageIO.read(input), Config.ARGB_8888);
 
-        return createBitmap(delegate, isMutable, density.getDpi());
+        return createBitmap(delegate, isMutable, density.getDpiValue());
     }
 
     /**
@@ -107,12 +107,12 @@
      * @see Bitmap#isMutable()
      * @see Bitmap#getDensity()
      */
-    public static Bitmap createBitmap(InputStream input, boolean isMutable, ResourceDensity density)
+    public static Bitmap createBitmap(InputStream input, boolean isMutable, Density density)
             throws IOException {
         // create a delegate with the content of the stream.
         Bitmap_Delegate delegate = new Bitmap_Delegate(ImageIO.read(input), Config.ARGB_8888);
 
-        return createBitmap(delegate, isMutable, density.getDpi());
+        return createBitmap(delegate, isMutable, density.getDpiValue());
     }
 
     /**
@@ -126,11 +126,11 @@
      * @see Bitmap#getDensity()
      */
     public static Bitmap createBitmap(BufferedImage image, boolean isMutable,
-            ResourceDensity density) throws IOException {
+            Density density) throws IOException {
         // create a delegate with the given image.
         Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.ARGB_8888);
 
-        return createBitmap(delegate, isMutable, density.getDpi());
+        return createBitmap(delegate, isMutable, density.getDpiValue());
     }
 
     /**
@@ -425,7 +425,7 @@
 
         // the density doesn't matter, it's set by the Java method.
         return createBitmap(delegate, false /*isMutable*/,
-                ResourceDensity.DEFAULT_DENSITY /*density*/);
+                Density.DEFAULT_DENSITY /*density*/);
     }
 
     /*package*/ static void nativePrepareToDraw(int nativeBitmap) {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
index 963dc4d..0c6fa20 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
@@ -56,6 +56,11 @@
     }
 
     @Override
+    public boolean isAlphaChannelImage() {
+        return mSession.isAlphaChannelImage();
+    }
+
+    @Override
     public List<ViewInfo> getRootViews() {
         return mSession.getViewInfos();
     }
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 8d194925..79264d0 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
@@ -267,7 +267,7 @@
 
     @Override
     public final TypedArray obtainStyledAttributes(int[] attrs) {
-        return createStyleBasedTypedArray(mRenderResources.getTheme(), attrs);
+        return createStyleBasedTypedArray(mRenderResources.getCurrentTheme(), attrs);
     }
 
     @Override
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 8b06452..978832f 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
@@ -32,7 +32,6 @@
 import com.android.ide.common.rendering.api.Params;
 import com.android.ide.common.rendering.api.RenderResources;
 import com.android.ide.common.rendering.api.RenderSession;
-import com.android.ide.common.rendering.api.ResourceDensity;
 import com.android.ide.common.rendering.api.ResourceValue;
 import com.android.ide.common.rendering.api.Result;
 import com.android.ide.common.rendering.api.StyleResourceValue;
@@ -48,6 +47,8 @@
 import com.android.layoutlib.bridge.android.BridgeWindow;
 import com.android.layoutlib.bridge.android.BridgeWindowSession;
 import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
+import com.android.resources.Density;
+import com.android.resources.ScreenSize;
 
 import android.animation.Animator;
 import android.animation.AnimatorInflater;
@@ -109,12 +110,19 @@
     private BridgeContext mContext;
     private BridgeXmlBlockParser mBlockParser;
     private BridgeInflater mInflater;
-    private int mScreenOffset;
     private ResourceValue mWindowBackground;
     private FrameLayout mViewRoot;
     private Canvas mCanvas;
     private int mMeasuredScreenWidth = -1;
     private int mMeasuredScreenHeight = -1;
+    private boolean mIsAlphaChannelImage = true;
+
+    private int mStatusBarSize;
+    private int mTopBarSize;
+    private int mSystemBarSize;
+    private int mTopOffset;
+    private int mTotalBarSize;
+
 
     // information being returned through the API
     private BufferedImage mImage;
@@ -176,19 +184,20 @@
         mContext = new BridgeContext(mParams.getProjectKey(), metrics, resources,
                 mParams.getProjectCallback(), mParams.getTargetSdkVersion());
 
+        // use default of true in case it's not found to use alpha by default
+        mIsAlphaChannelImage  = getBooleanThemeValue(resources,
+                "windowIsFloating", true /*defaultValue*/);
+
 
         setUp();
 
-        // get the screen offset and window-background resource
-        mWindowBackground = null;
-        mScreenOffset = 0;
-        StyleResourceValue theme = resources.getTheme();
-        if (theme != null && mParams.isBgColorOverridden() == false) {
-            mWindowBackground = resources.findItemInTheme("windowBackground");
-            mWindowBackground = resources.resolveResValue(mWindowBackground);
+        findBackground(resources);
+        findStatusBar(resources, metrics);
+        findTopBar(resources, metrics);
+        findSystemBar(resources, metrics);
 
-            mScreenOffset = getScreenOffset(resources, metrics);
-        }
+        mTopOffset = mStatusBarSize + mTopBarSize;
+        mTotalBarSize = mTopOffset + mSystemBarSize;
 
         // build the inflater and parser.
         mInflater = new BridgeInflater(mContext, mParams.getProjectCallback());
@@ -414,7 +423,7 @@
             if (mMeasuredScreenWidth == -1) {
                 newRenderSize = true;
                 mMeasuredScreenWidth = mParams.getScreenWidth();
-                mMeasuredScreenHeight = mParams.getScreenHeight();
+                mMeasuredScreenHeight = mParams.getScreenHeight() - mTotalBarSize;
 
                 if (renderingMode != RenderingMode.NORMAL) {
                     // measure the full size needed by the layout.
@@ -422,7 +431,7 @@
                             renderingMode.isHorizExpand() ?
                                     MeasureSpec.UNSPECIFIED // this lets us know the actual needed size
                                     : MeasureSpec.EXACTLY);
-                    h_spec = MeasureSpec.makeMeasureSpec(mMeasuredScreenHeight - mScreenOffset,
+                    h_spec = MeasureSpec.makeMeasureSpec(mMeasuredScreenHeight,
                             renderingMode.isVertExpand() ?
                                     MeasureSpec.UNSPECIFIED // this lets us know the actual needed size
                                     : MeasureSpec.EXACTLY);
@@ -437,8 +446,8 @@
 
                     if (renderingMode.isVertExpand()) {
                         int neededHeight = mViewRoot.getChildAt(0).getMeasuredHeight();
-                        if (neededHeight > mMeasuredScreenHeight - mScreenOffset) {
-                            mMeasuredScreenHeight = neededHeight + mScreenOffset;
+                        if (neededHeight > mMeasuredScreenHeight) {
+                            mMeasuredScreenHeight = neededHeight;
                         }
                     }
                 }
@@ -447,23 +456,26 @@
             // remeasure with the size we need
             // This must always be done before the call to layout
             w_spec = MeasureSpec.makeMeasureSpec(mMeasuredScreenWidth, MeasureSpec.EXACTLY);
-            h_spec = MeasureSpec.makeMeasureSpec(mMeasuredScreenHeight - mScreenOffset,
+            h_spec = MeasureSpec.makeMeasureSpec(mMeasuredScreenHeight,
                     MeasureSpec.EXACTLY);
             mViewRoot.measure(w_spec, h_spec);
 
             // now do the layout.
-            mViewRoot.layout(0, mScreenOffset, mMeasuredScreenWidth, mMeasuredScreenHeight);
+            mViewRoot.layout(0, 0, mMeasuredScreenWidth, mMeasuredScreenHeight);
 
             // draw the views
             // create the BufferedImage into which the layout will be rendered.
             boolean newImage = false;
             if (newRenderSize || mCanvas == null) {
                 if (mParams.getImageFactory() != null) {
-                    mImage = mParams.getImageFactory().getImage(mMeasuredScreenWidth,
-                            mMeasuredScreenHeight - mScreenOffset);
+                    mImage = mParams.getImageFactory().getImage(
+                            mMeasuredScreenWidth,
+                            mMeasuredScreenHeight + mTotalBarSize);
                 } else {
-                    mImage = new BufferedImage(mMeasuredScreenWidth,
-                            mMeasuredScreenHeight - mScreenOffset, BufferedImage.TYPE_INT_ARGB);
+                    mImage = new BufferedImage(
+                            mMeasuredScreenWidth,
+                            mMeasuredScreenHeight + mTotalBarSize,
+                            BufferedImage.TYPE_INT_ARGB);
                     newImage = true;
                 }
 
@@ -473,31 +485,54 @@
                     Graphics2D gc = mImage.createGraphics();
                     gc.setColor(new Color(mParams.getOverrideBgColor(), true));
                     gc.setComposite(AlphaComposite.Src);
-                    gc.fillRect(0, 0, mMeasuredScreenWidth, mMeasuredScreenHeight - mScreenOffset);
+                    gc.fillRect(0, 0, mMeasuredScreenWidth,
+                            mMeasuredScreenHeight + mTotalBarSize);
                     gc.dispose();
                 }
 
                 // create an Android bitmap around the BufferedImage
                 Bitmap bitmap = Bitmap_Delegate.createBitmap(mImage,
                         true /*isMutable*/,
-                        ResourceDensity.getEnum(mParams.getDensity()));
+                        Density.getEnum(mParams.getDensity()));
 
                 // create a Canvas around the Android bitmap
                 mCanvas = new Canvas(bitmap);
                 mCanvas.setDensity(mParams.getDensity());
+                mCanvas.translate(0, mTopOffset);
             }
 
             if (freshRender && newImage == false) {
                 Graphics2D gc = mImage.createGraphics();
-                gc.setColor(new Color(0x00000000, true));
                 gc.setComposite(AlphaComposite.Src);
-                gc.fillRect(0, 0, mMeasuredScreenWidth, mMeasuredScreenHeight - mScreenOffset);
+
+                if (mStatusBarSize > 0) {
+                    gc.setColor(new Color(0xFF3C3C3C, true));
+                    gc.fillRect(0, 0, mMeasuredScreenWidth, mStatusBarSize);
+                }
+
+                if (mTopBarSize > 0) {
+                    gc.setColor(new Color(0xFF7F7F7F, true));
+                    gc.fillRect(0, mStatusBarSize, mMeasuredScreenWidth, mTopOffset);
+                }
+
+                // erase the rest
+                gc.setColor(new Color(0x00000000, true));
+                gc.fillRect(0, mTopOffset,
+                        mMeasuredScreenWidth, mMeasuredScreenHeight + mTopOffset);
+
+                if (mSystemBarSize > 0) {
+                    gc.setColor(new Color(0xFF3C3C3C, true));
+                    gc.fillRect(0, mMeasuredScreenHeight + mTopOffset,
+                            mMeasuredScreenWidth, mMeasuredScreenHeight + mTotalBarSize);
+                }
+
+                // done
                 gc.dispose();
             }
 
             mViewRoot.draw(mCanvas);
 
-            mViewInfoList = visitAllChildren((ViewGroup)mViewRoot, mContext);
+            mViewInfoList = visitAllChildren((ViewGroup)mViewRoot, mContext, mTopOffset);
 
             // success!
             return SUCCESS.createResult();
@@ -936,73 +971,173 @@
         }
     }
 
-    /**
-     * Returns the top screen offset. This depends on whether the current theme defines the user
-     * of the title and status bars.
-     * @param resolver The {@link RenderResources}
-     * @param metrics The display metrics
-     * @return the pixel height offset
-     */
-    private int getScreenOffset(RenderResources resolver, DisplayMetrics metrics) {
-        int offset = 0;
+    private void findBackground(RenderResources resources) {
+        if (mParams.isBgColorOverridden() == false) {
+            mWindowBackground = resources.findItemInTheme("windowBackground");
+            if (mWindowBackground != null) {
+                mWindowBackground = resources.resolveResValue(mWindowBackground);
+            }
+        }
+    }
 
-        // get the title bar flag from the current theme.
-        ResourceValue value = resolver.findItemInTheme("windowNoTitle");
+    private boolean isTabletUi() {
+        return mParams.getConfigScreenSize() == ScreenSize.XLARGE;
+    }
 
-        // because it may reference something else, we resolve it.
-        value = resolver.resolveResValue(value);
+    private boolean isHCApp() {
+        RenderResources resources = mContext.getRenderResources();
 
-        // if there's a value and it's true (default is false)
-        if (value == null || value.getValue() == null ||
-                XmlUtils.convertValueToBoolean(value.getValue(), false /* defValue */) == false) {
+        // the app must say it targets 11+ and the theme name must extend Theme.Holo or
+        // Theme.Holo.Light (which does not extend Theme.Holo, but Theme.Light)
+        if (mParams.getTargetSdkVersion() < 11) {
+            return false;
+        }
+
+        StyleResourceValue currentTheme = resources.getCurrentTheme();
+        StyleResourceValue holoTheme = resources.getTheme("Theme.Holo", true /*frameworkTheme*/);
+
+        if (currentTheme == holoTheme ||
+                resources.themeIsParentOf(holoTheme, currentTheme)) {
+            return true;
+        }
+
+        StyleResourceValue holoLightTheme = resources.getTheme("Theme.Holo.Light",
+                true /*frameworkTheme*/);
+
+        if (currentTheme == holoLightTheme ||
+                resources.themeIsParentOf(holoLightTheme, currentTheme)) {
+            return true;
+        }
+
+        return false;
+    }
+
+    private void findStatusBar(RenderResources resources, DisplayMetrics metrics) {
+        if (isTabletUi() == false) {
+            boolean windowFullscreen = getBooleanThemeValue(resources,
+                    "windowFullscreen", false /*defaultValue*/);
+
+            if (windowFullscreen == false) {
+                // default value
+                mStatusBarSize = DEFAULT_STATUS_BAR_HEIGHT;
+
+                // get the real value
+                ResourceValue value = resources.getFrameworkResource(RenderResources.RES_DIMEN,
+                        "status_bar_height");
+
+                if (value != null) {
+                    TypedValue typedValue = ResourceHelper.getValue(value.getValue());
+                    if (typedValue != null) {
+                        // compute the pixel value based on the display metrics
+                        mStatusBarSize = (int)typedValue.getDimension(metrics);
+                    }
+                }
+            }
+        }
+    }
+
+    private void findTopBar(RenderResources resources, DisplayMetrics metrics) {
+        boolean windowIsFloating = getBooleanThemeValue(resources,
+                "windowIsFloating", true /*defaultValue*/);
+
+        if (windowIsFloating == false) {
+            if (isHCApp()) {
+                findActionBar(resources, metrics);
+            } else {
+                findTitleBar(resources, metrics);
+            }
+        }
+    }
+
+    private void findActionBar(RenderResources resources, DisplayMetrics metrics) {
+        boolean windowActionBar = getBooleanThemeValue(resources,
+                "windowActionBar", true /*defaultValue*/);
+
+        // if there's a value and it's false (default is true)
+        if (windowActionBar) {
+
             // default size of the window title bar
-            int defaultOffset = DEFAULT_TITLE_BAR_HEIGHT;
+            mTopBarSize = DEFAULT_TITLE_BAR_HEIGHT;
 
             // get value from the theme.
-            value = resolver.findItemInTheme("windowTitleSize");
+            ResourceValue value = resources.findItemInTheme("actionBarSize");
 
             // resolve it
-            value = resolver.resolveResValue(value);
+            value = resources.resolveResValue(value);
 
             if (value != null) {
                 // get the numerical value, if available
                 TypedValue typedValue = ResourceHelper.getValue(value.getValue());
                 if (typedValue != null) {
                     // compute the pixel value based on the display metrics
-                    defaultOffset = (int)typedValue.getDimension(metrics);
+                    mTopBarSize = (int)typedValue.getDimension(metrics);
                 }
             }
-
-            offset += defaultOffset;
         }
+    }
 
-        // get the fullscreen flag from the current theme.
-        value = resolver.findItemInTheme("windowFullscreen");
+    private void findTitleBar(RenderResources resources, DisplayMetrics metrics) {
+        boolean windowNoTitle = getBooleanThemeValue(resources,
+                "windowNoTitle", false /*defaultValue*/);
 
-        // because it may reference something else, we resolve it.
-        value = resolver.resolveResValue(value);
+        if (windowNoTitle == false) {
 
-        if (value == null || value.getValue() == null ||
-                XmlUtils.convertValueToBoolean(value.getValue(), false /* defValue */) == false) {
+            // default size of the window title bar
+            mTopBarSize = DEFAULT_TITLE_BAR_HEIGHT;
+
+            // get value from the theme.
+            ResourceValue value = resources.findItemInTheme("windowTitleSize");
+
+            // resolve it
+            value = resources.resolveResValue(value);
+
+            if (value != null) {
+                // get the numerical value, if available
+                TypedValue typedValue = ResourceHelper.getValue(value.getValue());
+                if (typedValue != null) {
+                    // compute the pixel value based on the display metrics
+                    mTopBarSize = (int)typedValue.getDimension(metrics);
+                }
+            }
+        }
+    }
+
+    private void findSystemBar(RenderResources resources, DisplayMetrics metrics) {
+        if (isTabletUi() && getBooleanThemeValue(
+                resources, "windowIsFloating", true /*defaultValue*/) == false) {
 
             // default value
-            int defaultOffset = DEFAULT_STATUS_BAR_HEIGHT;
+            mSystemBarSize = 56; // ??
 
             // get the real value
-            value = resolver.getFrameworkResource(RenderResources.RES_DIMEN, "status_bar_height");
+            ResourceValue value = resources.getFrameworkResource(RenderResources.RES_DIMEN,
+                    "status_bar_height");
+
             if (value != null) {
                 TypedValue typedValue = ResourceHelper.getValue(value.getValue());
                 if (typedValue != null) {
                     // compute the pixel value based on the display metrics
-                    defaultOffset = (int)typedValue.getDimension(metrics);
+                    mSystemBarSize = (int)typedValue.getDimension(metrics);
                 }
             }
+        }
+    }
 
-            // add the computed offset.
-            offset += defaultOffset;
+    private boolean getBooleanThemeValue(RenderResources resources,
+            String name, boolean defaultValue) {
+
+        // get the title bar flag from the current theme.
+        ResourceValue value = resources.findItemInTheme(name);
+
+        // because it may reference something else, we resolve it.
+        value = resources.resolveResValue(value);
+
+        // if there's no value, return the default.
+        if (value == null || value.getValue() == null) {
+            return defaultValue;
         }
 
-        return offset;
+        return XmlUtils.convertValueToBoolean(value.getValue(), defaultValue);
     }
 
     /**
@@ -1111,32 +1246,33 @@
      * @param view the root View
      * @param context the context.
      */
-    private ViewInfo visit(View view, BridgeContext context) {
+    private ViewInfo visit(View view, BridgeContext context, int offset) {
         if (view == null) {
             return null;
         }
 
         ViewInfo result = new ViewInfo(view.getClass().getName(),
                 context.getViewKey(view),
-                view.getLeft(), view.getTop(), view.getRight(), view.getBottom(),
+                view.getLeft(), view.getTop() + offset, view.getRight(), view.getBottom() + offset,
                 view, view.getLayoutParams());
 
         if (view instanceof ViewGroup) {
             ViewGroup group = ((ViewGroup) view);
-            result.setChildren(visitAllChildren(group, context));
+            result.setChildren(visitAllChildren(group, context, 0 /*offset*/));
         }
 
         return result;
     }
 
-    private List<ViewInfo> visitAllChildren(ViewGroup viewGroup, BridgeContext context) {
+    private List<ViewInfo> visitAllChildren(ViewGroup viewGroup, BridgeContext context,
+            int offset) {
         if (viewGroup == null) {
             return null;
         }
 
         List<ViewInfo> children = new ArrayList<ViewInfo>();
         for (int i = 0; i < viewGroup.getChildCount(); i++) {
-            children.add(visit(viewGroup.getChildAt(i), context));
+            children.add(visit(viewGroup.getChildAt(i), context, offset));
         }
         return children;
     }
@@ -1150,6 +1286,10 @@
         return mImage;
     }
 
+    public boolean isAlphaChannelImage() {
+        return mIsAlphaChannelImage;
+    }
+
     public List<ViewInfo> getViewInfos() {
         return mViewInfoList;
     }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
index 475b4be2..119dfb1 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
@@ -18,13 +18,13 @@
 
 import com.android.ide.common.rendering.api.DensityBasedResourceValue;
 import com.android.ide.common.rendering.api.LayoutLog;
-import com.android.ide.common.rendering.api.ResourceDensity;
 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.ninepatch.NinePatch;
 import com.android.ninepatch.NinePatchChunk;
+import com.android.resources.Density;
 
 import org.kxml2.io.KXmlParser;
 import org.xmlpull.v1.XmlPullParser;
@@ -147,7 +147,7 @@
                             }
 
                             if (bitmap == null) {
-                                ResourceDensity density = ResourceDensity.MEDIUM;
+                                Density density = Density.MEDIUM;
                                 if (value instanceof DensityBasedResourceValue) {
                                     density =
                                         ((DensityBasedResourceValue)value).getResourceDensity();
@@ -214,7 +214,7 @@
                             isFramework ? null : context.getProjectKey());
 
                     if (bitmap == null) {
-                        ResourceDensity density = ResourceDensity.MEDIUM;
+                        Density density = Density.MEDIUM;
                         if (value instanceof DensityBasedResourceValue) {
                             density = ((DensityBasedResourceValue)value).getResourceDensity();
                         }