am a6708c6a: Merge "Add setting for configuring zoom level on double-tap." into ics-mr0

* commit 'a6708c6a462d2a30e51e7ded2559a4054cb651fc':
  Add setting for configuring zoom level on double-tap.
diff --git a/api/current.txt b/api/current.txt
index 92969f6..662ebcd 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -24082,6 +24082,8 @@
     method public int getCurrentItemIndex();
     method public int getFromIndex();
     method public int getItemCount();
+    method public int getMaxScrollX();
+    method public int getMaxScrollY();
     method public android.os.Parcelable getParcelableData();
     method public int getRemovedCount();
     method public int getScrollX();
@@ -24108,6 +24110,8 @@
     method public void setFromIndex(int);
     method public void setFullScreen(boolean);
     method public void setItemCount(int);
+    method public void setMaxScrollX(int);
+    method public void setMaxScrollY(int);
     method public void setParcelableData(android.os.Parcelable);
     method public void setPassword(boolean);
     method public void setRemovedCount(int);
diff --git a/core/java/android/accounts/ChooseAccountTypeActivity.java b/core/java/android/accounts/ChooseAccountTypeActivity.java
index 448b2c0..acc8549 100644
--- a/core/java/android/accounts/ChooseAccountTypeActivity.java
+++ b/core/java/android/accounts/ChooseAccountTypeActivity.java
@@ -43,7 +43,7 @@
  * @hide
  */
 public class ChooseAccountTypeActivity extends Activity {
-    private static final String TAG = "AccountManager";
+    private static final String TAG = "AccountChooser";
 
     private HashMap<String, AuthInfo> mTypeToAuthenticatorInfo = new HashMap<String, AuthInfo>();
     private ArrayList<AuthInfo> mAuthenticatorInfosToDisplay;
@@ -52,6 +52,11 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
+        if (Log.isLoggable(TAG, Log.VERBOSE)) {
+            Log.v(TAG, "ChooseAccountTypeActivity.onCreate(savedInstanceState="
+                    + savedInstanceState + ")");
+        }
+
         // Read the validAccountTypes, if present, and add them to the setOfAllowableAccountTypes
         Set<String> setOfAllowableAccountTypes = null;
         String[] validAccountTypes = getIntent().getStringArrayExtra(
@@ -111,8 +116,10 @@
         Bundle bundle = new Bundle();
         bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, type);
         setResult(Activity.RESULT_OK, new Intent().putExtras(bundle));
-        Log.d(TAG, "ChooseAccountTypeActivity.setResultAndFinish: "
-                + "selected account type " + type);
+        if (Log.isLoggable(TAG, Log.VERBOSE)) {
+            Log.v(TAG, "ChooseAccountTypeActivity.setResultAndFinish: "
+                    + "selected account type " + type);
+        }
         finish();
     }
 
diff --git a/core/java/android/accounts/ChooseTypeAndAccountActivity.java b/core/java/android/accounts/ChooseTypeAndAccountActivity.java
index 8cc2002..5f38eb4 100644
--- a/core/java/android/accounts/ChooseTypeAndAccountActivity.java
+++ b/core/java/android/accounts/ChooseTypeAndAccountActivity.java
@@ -47,7 +47,7 @@
  */
 public class ChooseTypeAndAccountActivity extends Activity
         implements AccountManagerCallback<Bundle> {
-    private static final String TAG = "AccountManager";
+    private static final String TAG = "AccountChooser";
 
     /**
      * A Parcelable ArrayList of Account objects that limits the choosable accounts to those
@@ -100,13 +100,39 @@
     public static final String EXTRA_DESCRIPTION_TEXT_OVERRIDE =
             "descriptionTextOverride";
 
+    public static final int REQUEST_NULL = 0;
+    public static final int REQUEST_CHOOSE_TYPE = 1;
+    public static final int REQUEST_ADD_ACCOUNT = 2;
+
+    private static final String KEY_INSTANCE_STATE_PENDING_REQUEST = "pendingRequest";
+    private static final String KEY_INSTANCE_STATE_EXISTING_ACCOUNTS = "existingAccounts";
+
     private ArrayList<AccountInfo> mAccountInfos;
+    private int mPendingRequest = REQUEST_NULL;
+    private Parcelable[] mExistingAccounts = null;
+    private Parcelable[] mSavedAccounts = null;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        if (Log.isLoggable(TAG, Log.VERBOSE)) {
+            Log.v(TAG, "ChooseTypeAndAccountActivity.onCreate(savedInstanceState="
+                    + savedInstanceState + ")");
+        }
+
         setContentView(R.layout.choose_type_and_account);
 
+        if (savedInstanceState != null) {
+            mPendingRequest = savedInstanceState.getInt(KEY_INSTANCE_STATE_PENDING_REQUEST);
+            mSavedAccounts =
+                    savedInstanceState.getParcelableArray(KEY_INSTANCE_STATE_EXISTING_ACCOUNTS);
+            mExistingAccounts = null;
+        } else {
+            mPendingRequest = REQUEST_NULL;
+            mSavedAccounts = null;
+            mExistingAccounts = null;
+        }
+
         // save some items we use frequently
         final AccountManager accountManager = AccountManager.get(this);
         final Intent intent = getIntent();
@@ -171,20 +197,6 @@
                     account.equals(selectedAccount)));
         }
 
-        // If there are no allowable accounts go directly to add account
-        if (mAccountInfos.isEmpty()) {
-            startChooseAccountTypeActivity();
-            return;
-        }
-
-        // if there is only one allowable account return it
-        if (!intent.getBooleanExtra(EXTRA_ALWAYS_PROMPT_FOR_ACCOUNT, false)
-                && mAccountInfos.size() == 1) {
-            Account account = mAccountInfos.get(0).account;
-            setResultAndFinish(account.name, account.type);
-            return;
-        }
-
         // there is more than one allowable account. initialize the list adapter to allow
         // the user to select an account.
         ListView list = (ListView) findViewById(android.R.id.list);
@@ -204,6 +216,37 @@
                 startChooseAccountTypeActivity();
             }
         });
+
+        if (mPendingRequest == REQUEST_NULL) {
+            // If there are no allowable accounts go directly to add account
+            if (mAccountInfos.isEmpty()) {
+                startChooseAccountTypeActivity();
+                return;
+            }
+
+            // if there is only one allowable account return it
+            if (!intent.getBooleanExtra(EXTRA_ALWAYS_PROMPT_FOR_ACCOUNT, false)
+                    && mAccountInfos.size() == 1) {
+                Account account = mAccountInfos.get(0).account;
+                setResultAndFinish(account.name, account.type);
+                return;
+            }
+        }
+    }
+
+    @Override
+    protected void onDestroy() {
+        if (Log.isLoggable(TAG, Log.VERBOSE)) {
+            Log.v(TAG, "ChooseTypeAndAccountActivity.onDestroy()");
+        }
+        super.onDestroy();
+    }
+
+    @Override
+    protected void onSaveInstanceState(final Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putInt(KEY_INSTANCE_STATE_PENDING_REQUEST, mPendingRequest);
+        outState.putParcelableArray(KEY_INSTANCE_STATE_EXISTING_ACCOUNTS, mExistingAccounts);
     }
 
     // Called when the choose account type activity (for adding an account) returns.
@@ -212,20 +255,75 @@
     @Override
     protected void onActivityResult(final int requestCode, final int resultCode,
             final Intent data) {
-        if (resultCode == RESULT_OK && data != null) {
-            String accountType = data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE);
-            if (accountType != null) {
-                runAddAccountForAuthenticator(accountType);
-                return;
-            }
+        if (Log.isLoggable(TAG, Log.VERBOSE)) {
+            if (data != null && data.getExtras() != null) data.getExtras().keySet();
+            Bundle extras = data != null ? data.getExtras() : null;
+            Log.v(TAG, "ChooseTypeAndAccountActivity.onActivityResult(reqCode=" + requestCode
+                    + ", resCode=" + resultCode + ", extras=" + extras + ")");
         }
-        Log.d(TAG, "ChooseTypeAndAccountActivity.onActivityResult: canceled");
+
+        // we got our result, so clear the fact that we had a pending request
+        mPendingRequest = REQUEST_NULL;
+        mExistingAccounts = null;
+
+        if (resultCode == RESULT_CANCELED) {
+            return;
+        }
+
+        if (resultCode == RESULT_OK) {
+            if (requestCode == REQUEST_CHOOSE_TYPE) {
+                if (data != null) {
+                    String accountType = data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE);
+                    if (accountType != null) {
+                        runAddAccountForAuthenticator(accountType);
+                        return;
+                    }
+                }
+                Log.d(TAG, "ChooseTypeAndAccountActivity.onActivityResult: unable to find account "
+                        + "type, pretending the request was canceled");
+            } else if (requestCode == REQUEST_ADD_ACCOUNT) {
+                String accountName = null;
+                String accountType = null;
+
+                if (data != null) {
+                    accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
+                    accountType = data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE);
+                }
+
+                if (accountName == null || accountType == null) {
+                    Account[] currentAccounts = AccountManager.get(this).getAccounts();
+                    Set<Account> preExistingAccounts = new HashSet<Account>();
+                    for (Parcelable accountParcel : mSavedAccounts) {
+                        preExistingAccounts.add((Account) accountParcel);
+                    }
+                    for (Account account : currentAccounts) {
+                        if (!preExistingAccounts.contains(account)) {
+                            accountName = account.name;
+                            accountType = account.type;
+                            break;
+                        }
+                    }
+                }
+
+                if (accountName != null || accountType != null) {
+                    setResultAndFinish(accountName, accountType);
+                    return;
+                }
+            }
+            Log.d(TAG, "ChooseTypeAndAccountActivity.onActivityResult: unable to find added "
+                    + "account, pretending the request was canceled");
+        }
+        if (Log.isLoggable(TAG, Log.VERBOSE)) {
+            Log.v(TAG, "ChooseTypeAndAccountActivity.onActivityResult: canceled");
+        }
         setResult(Activity.RESULT_CANCELED);
         finish();
     }
 
     protected void runAddAccountForAuthenticator(String type) {
-        Log.d(TAG, "selected account type " + type);
+        if (Log.isLoggable(TAG, Log.VERBOSE)) {
+            Log.v(TAG, "runAddAccountForAuthenticator: " + type);
+        }
         final Bundle options = getIntent().getBundleExtra(
                 ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE);
         final String[] requiredFeatures = getIntent().getStringArrayExtra(
@@ -233,20 +331,19 @@
         final String authTokenType = getIntent().getStringExtra(
                 ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING);
         AccountManager.get(this).addAccount(type, authTokenType, requiredFeatures,
-                options, this, this, null /* Handler */);
+                options, null /* activity */, this /* callback */, null /* Handler */);
     }
 
     public void run(final AccountManagerFuture<Bundle> accountManagerFuture) {
         try {
             final Bundle accountManagerResult = accountManagerFuture.getResult();
-            final String name = accountManagerResult.getString(AccountManager.KEY_ACCOUNT_NAME);
-            final String type = accountManagerResult.getString(AccountManager.KEY_ACCOUNT_TYPE);
-            if (name != null && type != null) {
-                final Bundle bundle = new Bundle();
-                bundle.putString(AccountManager.KEY_ACCOUNT_NAME, name);
-                bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, type);
-                setResult(Activity.RESULT_OK, new Intent().putExtras(bundle));
-                finish();
+            final Intent intent = (Intent)accountManagerResult.getParcelable(
+                    AccountManager.KEY_INTENT);
+            if (intent != null) {
+                mPendingRequest = REQUEST_ADD_ACCOUNT;
+                mExistingAccounts = AccountManager.get(this).getAccounts();
+                intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);
+                startActivityForResult(intent, REQUEST_ADD_ACCOUNT);
                 return;
             }
         } catch (OperationCanceledException e) {
@@ -297,12 +394,17 @@
         bundle.putString(AccountManager.KEY_ACCOUNT_NAME, accountName);
         bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, accountType);
         setResult(Activity.RESULT_OK, new Intent().putExtras(bundle));
-        Log.d(TAG, "ChooseTypeAndAccountActivity.setResultAndFinish: "
-                + "selected account " + accountName + ", " + accountType);
+        if (Log.isLoggable(TAG, Log.VERBOSE)) {
+            Log.v(TAG, "ChooseTypeAndAccountActivity.setResultAndFinish: "
+                    + "selected account " + accountName + ", " + accountType);
+        }
         finish();
     }
 
     private void startChooseAccountTypeActivity() {
+        if (Log.isLoggable(TAG, Log.VERBOSE)) {
+            Log.v(TAG, "ChooseAccountTypeActivity.startChooseAccountTypeActivity()");
+        }
         final Intent intent = new Intent(this, ChooseAccountTypeActivity.class);
         intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
         intent.putExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY,
@@ -313,7 +415,8 @@
                 getIntent().getStringArrayExtra(EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY));
         intent.putExtra(EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING,
                 getIntent().getStringExtra(EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING));
-        startActivityForResult(intent, 0);
+        startActivityForResult(intent, REQUEST_CHOOSE_TYPE);
+        mPendingRequest = REQUEST_CHOOSE_TYPE;
     }
 
     private static class AccountInfo {
diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java
index fe0106d..33310df 100644
--- a/core/java/android/nfc/NfcAdapter.java
+++ b/core/java/android/nfc/NfcAdapter.java
@@ -768,61 +768,6 @@
     }
 
     /**
-     * TODO: Remove this once pre-built apk's (Maps, Youtube etc) are updated
-     * @deprecated use {@link CreateNdefMessageCallback} or {@link OnNdefPushCompleteCallback}
-     * @hide
-     */
-    @Deprecated
-    public interface NdefPushCallback {
-        /**
-         * @deprecated use {@link CreateNdefMessageCallback} instead
-         */
-        @Deprecated
-        NdefMessage createMessage();
-        /**
-         * @deprecated use{@link OnNdefPushCompleteCallback} instead
-         */
-        @Deprecated
-        void onMessagePushed();
-    }
-
-    /**
-     * TODO: Remove this
-     * Converts new callbacks to old callbacks.
-     */
-    static final class LegacyCallbackWrapper implements CreateNdefMessageCallback,
-            OnNdefPushCompleteCallback {
-        final NdefPushCallback mLegacyCallback;
-        LegacyCallbackWrapper(NdefPushCallback legacyCallback) {
-            mLegacyCallback = legacyCallback;
-        }
-        @Override
-        public void onNdefPushComplete(NfcEvent event) {
-            mLegacyCallback.onMessagePushed();
-        }
-        @Override
-        public NdefMessage createNdefMessage(NfcEvent event) {
-            return mLegacyCallback.createMessage();
-        }
-    }
-
-    /**
-     * TODO: Remove this once pre-built apk's (Maps, Youtube etc) are updated
-     * @deprecated use {@link #setNdefPushMessageCallback} instead
-     * @hide
-     */
-    @Deprecated
-    public void enableForegroundNdefPush(Activity activity, final NdefPushCallback callback) {
-        if (activity == null || callback == null) {
-            throw new NullPointerException();
-        }
-        enforceResumed(activity);
-        LegacyCallbackWrapper callbackWrapper = new LegacyCallbackWrapper(callback);
-        mNfcActivityManager.setNdefPushMessageCallback(activity, callbackWrapper);
-        mNfcActivityManager.setOnNdefPushCompleteCallback(activity, callbackWrapper);
-    }
-
-    /**
      * Enable NDEF Push feature.
      * <p>This API is for the Settings application.
      * @hide
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index 4d7a9bb..cc2fa85 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -35,7 +35,6 @@
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -902,15 +901,13 @@
             return false;
         }
 
+        // Thread policy controls BlockGuard.
         int threadPolicyMask = StrictMode.DETECT_DISK_WRITE |
                 StrictMode.DETECT_DISK_READ |
                 StrictMode.DETECT_NETWORK;
 
         if (!IS_USER_BUILD) {
             threadPolicyMask |= StrictMode.PENALTY_DROPBOX;
-            if (IS_ENG_BUILD) {
-                threadPolicyMask |= StrictMode.PENALTY_LOG;
-            }
         }
         if (doFlashes) {
             threadPolicyMask |= StrictMode.PENALTY_FLASH;
@@ -918,6 +915,8 @@
 
         StrictMode.setThreadPolicyMask(threadPolicyMask);
 
+        // VM Policy controls CloseGuard, detection of Activity leaks,
+        // and instance counting.
         if (IS_USER_BUILD) {
             setCloseGuardEnabled(false);
         } else {
diff --git a/core/java/android/provider/CalendarContract.java b/core/java/android/provider/CalendarContract.java
index 4b4d308..d7060c1 100644
--- a/core/java/android/provider/CalendarContract.java
+++ b/core/java/android/provider/CalendarContract.java
@@ -300,8 +300,25 @@
         public static final String CALENDAR_COLOR = "calendar_color";
 
         /**
+         * An index for looking up a color from the {@link Colors} table. NULL
+         * or an empty string are reserved for indicating that the calendar does
+         * not use an index for looking up the color. The provider will update
+         * {@link #CALENDAR_COLOR} automatically when a valid index is written
+         * to this column. @see Colors
+         * <P>
+         * Type: TEXT
+         * </P>
+         * TODO UNHIDE
+         *
+         * @hide
+         */
+        public static final String CALENDAR_COLOR_INDEX = "calendar_color_index";
+
+        /**
          * The display name of the calendar. Column name.
-         * <P>Type: TEXT</P>
+         * <P>
+         * Type: TEXT
+         * </P>
          */
         public static final String CALENDAR_DISPLAY_NAME = "calendar_displayName";
 
@@ -392,6 +409,34 @@
          * <P>Type: TEXT</P>
          */
         public static final String ALLOWED_REMINDERS = "allowedReminders";
+
+        /**
+         * A comma separated list of availability types supported for this
+         * calendar in the format "#,#,#". Valid types are
+         * {@link Events#AVAILABILITY_BUSY}, {@link Events#AVAILABILITY_FREE},
+         * {@link Events#AVAILABILITY_TENTATIVE}. Setting this field to only
+         * {@link Events#AVAILABILITY_BUSY} should be used to indicate that
+         * changing the availability is not supported.
+         *
+         * TODO UNHIDE, Update Calendars doc
+         *
+         * @hide
+         */
+        public static final String ALLOWED_AVAILABILITY = "allowedAvailability";
+
+        /**
+         * A comma separated list of attendee types supported for this calendar
+         * in the format "#,#,#". Valid types are {@link Attendees#TYPE_NONE},
+         * {@link Attendees#TYPE_OPTIONAL}, {@link Attendees#TYPE_REQUIRED},
+         * {@link Attendees#TYPE_RESOURCE}. Setting this field to only
+         * {@link Attendees#TYPE_NONE} should be used to indicate that changing
+         * the attendee type is not supported.
+         *
+         * TODO UNHIDE, Update Calendars doc
+         *
+         * @hide
+         */
+        public static final String ALLOWED_ATTENDEE_TYPES = "allowedAttendeeTypes";
     }
 
     /**
@@ -688,13 +733,22 @@
 
         /**
          * The type of attendee. Column name.
-         * <P>Type: Integer (one of {@link #TYPE_REQUIRED}, {@link #TYPE_OPTIONAL})</P>
+         * <P>
+         * Type: Integer (one of {@link #TYPE_REQUIRED}, {@link #TYPE_OPTIONAL}
+         * </P>
          */
         public static final String ATTENDEE_TYPE = "attendeeType";
 
         public static final int TYPE_NONE = 0;
         public static final int TYPE_REQUIRED = 1;
         public static final int TYPE_OPTIONAL = 2;
+        /**
+         * This specifies that an attendee is a resource, such as a room, and
+         * not an actual person. TODO UNHIDE and add to ATTENDEE_TYPE comment
+         * 
+         * @hide
+         */
+        public static final int TYPE_RESOURCE = 3;
 
         /**
          * The attendance status of the attendee. Column name.
@@ -787,13 +841,26 @@
         public static final String EVENT_LOCATION = "eventLocation";
 
         /**
-         * A secondary color for the individual event. Reserved for future use.
-         * Column name.
+         * A secondary color for the individual event. This should only be
+         * updated by the sync adapter for a given account.
          * <P>Type: INTEGER</P>
          */
         public static final String EVENT_COLOR = "eventColor";
 
         /**
+         * A secondary color index for the individual event. NULL or an empty
+         * string are reserved for indicating that the event does not use an
+         * index for looking up the color. The provider will update
+         * {@link #EVENT_COLOR} automatically when a valid index is written to
+         * this column. @see Colors
+         * <P>Type: TEXT</P>
+         * TODO UNHIDE
+         *
+         * @hide
+         */
+        public static final String EVENT_COLOR_INDEX = "eventColor_index";
+
+        /**
          * The event status. Column name.
          * <P>Type: INTEGER (one of {@link #STATUS_TENTATIVE}...)</P>
          */
@@ -964,6 +1031,15 @@
          * other events.
          */
         public static final int AVAILABILITY_FREE = 1;
+        /**
+         * Indicates that the owner's availability may change, but should be
+         * considered busy time that will conflict.
+         *
+         * TODO UNHIDE
+         *
+         * @hide
+         */
+        public static final int AVAILABILITY_TENTATIVE = 2;
 
         /**
          * Whether the event has an alarm or not. Column name.
@@ -2224,6 +2300,91 @@
         }
     }
 
+    /**
+     * @hide
+     * TODO UNHIDE
+     */
+    protected interface ColorsColumns extends SyncStateContract.Columns {
+
+        /**
+         * The type of color, which describes how it should be used. Valid types
+         * are {@link #TYPE_CALENDAR} and {@link #TYPE_EVENT}. Column name.
+         * <P>
+         * Type: INTEGER (NOT NULL)
+         * </P>
+         */
+        public static final String COLOR_TYPE = "color_type";
+
+        /**
+         * This indicateds a color that can be used for calendars.
+         */
+        public static final int TYPE_CALENDAR = 0;
+        /**
+         * This indicates a color that can be used for events.
+         */
+        public static final int TYPE_EVENT = 1;
+
+        /**
+         * The index used to reference this color. This can be any non-empty
+         * string, but must be unique for a given {@link #ACCOUNT_TYPE} and
+         * {@link #ACCOUNT_NAME} . Column name.
+         * <P>
+         * Type: TEXT
+         * </P>
+         */
+        public static final String COLOR_INDEX = "color_index";
+
+        /**
+         * The version of this color that will work with dark text as an 8-bit
+         * ARGB integer value. Colors should specify alpha as fully opaque (eg
+         * 0xFF993322) as the alpha may be ignored or modified for display.
+         * Column name.
+         * <P>
+         * Type: INTEGER (NOT NULL)
+         * </P>
+         */
+        public static final String COLOR_LIGHT = "color_light";
+
+        /**
+         * The version of this color that will work with light text as an 8-bit
+         * ARGB integer value. Colors should specify alpha as fully opaque (eg
+         * 0xFF993322) as the alpha may be ignored or modified for display.
+         * Column name.
+         * <P>
+         * Type: INTEGER (NOT NULL)
+         * </P>
+         */
+        public static final String COLOR_DARK = "color_dark";
+
+    }
+
+    /**
+     * Fields for accessing colors available for a given account. Colors are
+     * referenced by {@link #COLOR_INDEX} which must be unique for a given
+     * account name/type. These values should only be updated by the sync
+     * adapter.
+     * TODO UNHIDE
+     *
+     * @hide
+     */
+    public static final class Colors implements ColorsColumns {
+        /**
+         * @hide
+         */
+        public static final String TABLE_NAME = "Colors";
+        /**
+         * The Uri for querying color information
+         */
+        @SuppressWarnings("hiding")
+        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/colors");
+
+        /**
+         * This utility class cannot be instantiated
+         */
+        private Colors() {
+        }
+    }
+
     protected interface ExtendedPropertiesColumns {
         /**
          * The event the extended property belongs to. Column name.
diff --git a/core/java/android/view/accessibility/AccessibilityRecord.java b/core/java/android/view/accessibility/AccessibilityRecord.java
index fe06d98..a4e0688 100644
--- a/core/java/android/view/accessibility/AccessibilityRecord.java
+++ b/core/java/android/view/accessibility/AccessibilityRecord.java
@@ -391,8 +391,6 @@
      * Gets the max scroll offset of the source left edge in pixels.
      *
      * @return The max scroll.
-     *
-     * @hide
      */
     public int getMaxScrollX() {
         return mMaxScrollX;
@@ -401,8 +399,6 @@
      * Sets the max scroll offset of the source left edge in pixels.
      *
      * @param maxScrollX The max scroll.
-     *
-     * @hide
      */
     public void setMaxScrollX(int maxScrollX) {
         enforceNotSealed();
@@ -413,8 +409,6 @@
      * Gets the max scroll offset of the source top edge in pixels.
      *
      * @return The max scroll.
-     *
-     * @hide
      */
     public int getMaxScrollY() {
         return mMaxScrollY;
@@ -424,8 +418,6 @@
      * Sets the max scroll offset of the source top edge in pixels.
      *
      * @param maxScrollY The max scroll.
-     *
-     * @hide
      */
     public void setMaxScrollY(int maxScrollY) {
         enforceNotSealed();
diff --git a/core/java/android/widget/SpellChecker.java b/core/java/android/widget/SpellChecker.java
index 510e2d4..1da18aa 100644
--- a/core/java/android/widget/SpellChecker.java
+++ b/core/java/android/widget/SpellChecker.java
@@ -239,6 +239,7 @@
             SuggestionsInfo suggestionsInfo, SpellCheckSpan spellCheckSpan) {
         final int start = editable.getSpanStart(spellCheckSpan);
         final int end = editable.getSpanEnd(spellCheckSpan);
+        if (start < 0 || end < 0) return; // span was removed in the meantime
 
         // Other suggestion spans may exist on that region, with identical suggestions, filter
         // them out to avoid duplicates. First, filter suggestion spans on that exact region.
@@ -249,7 +250,6 @@
             final int spanEnd = editable.getSpanEnd(suggestionSpans[i]);
             if (spanStart != start || spanEnd != end) {
                 suggestionSpans[i] = null;
-                break;
             }
         }
 
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 041e8a4..324198f 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -9608,15 +9608,6 @@
             SpannableStringBuilder text = new SpannableStringBuilder();
             TextAppearanceSpan highlightSpan = new TextAppearanceSpan(mContext,
                     android.R.style.TextAppearance_SuggestionHighlight);
-
-            void removeMisspelledFlag() {
-                int suggestionSpanFlags = suggestionSpan.getFlags();
-                if ((suggestionSpanFlags & SuggestionSpan.FLAG_MISSPELLED) > 0) {
-                    suggestionSpanFlags &= ~SuggestionSpan.FLAG_MISSPELLED;
-                    suggestionSpanFlags &= ~SuggestionSpan.FLAG_EASY_CORRECT;
-                    suggestionSpan.setFlags(suggestionSpanFlags);
-                }
-            }
         }
 
         private class SuggestionAdapter extends BaseAdapter {
@@ -9932,6 +9923,14 @@
                     suggestionSpansStarts[i] = editable.getSpanStart(suggestionSpan);
                     suggestionSpansEnds[i] = editable.getSpanEnd(suggestionSpan);
                     suggestionSpansFlags[i] = editable.getSpanFlags(suggestionSpan);
+
+                    // Remove potential misspelled flags
+                    int suggestionSpanFlags = suggestionSpan.getFlags();
+                    if ((suggestionSpanFlags & SuggestionSpan.FLAG_MISSPELLED) > 0) {
+                        suggestionSpanFlags &= ~SuggestionSpan.FLAG_MISSPELLED;
+                        suggestionSpanFlags &= ~SuggestionSpan.FLAG_EASY_CORRECT;
+                        suggestionSpan.setFlags(suggestionSpanFlags);
+                    }
                 }
 
                 final int suggestionStart = suggestionInfo.suggestionStart;
@@ -9940,8 +9939,6 @@
                         suggestionStart, suggestionEnd).toString();
                 editable.replace(spanStart, spanEnd, suggestion);
 
-                suggestionInfo.removeMisspelledFlag();
-
                 // Notify source IME of the suggestion pick. Do this before swaping texts.
                 if (!TextUtils.isEmpty(
                         suggestionInfo.suggestionSpan.getNotificationTargetClassName())) {
diff --git a/core/java/com/android/internal/view/menu/ExpandedMenuView.java b/core/java/com/android/internal/view/menu/ExpandedMenuView.java
index 723ece4..47058ad 100644
--- a/core/java/com/android/internal/view/menu/ExpandedMenuView.java
+++ b/core/java/com/android/internal/view/menu/ExpandedMenuView.java
@@ -63,11 +63,6 @@
         setChildrenDrawingCacheEnabled(false);
     }
 
-    @Override
-    protected boolean recycleOnMeasure() {
-        return false;
-    }
-
     public boolean invokeItem(MenuItemImpl item) {
         return mMenu.performItemAction(item, 0);
     }
diff --git a/core/java/com/android/internal/view/menu/ListMenuItemView.java b/core/java/com/android/internal/view/menu/ListMenuItemView.java
index a1e16d4..df579c6 100644
--- a/core/java/com/android/internal/view/menu/ListMenuItemView.java
+++ b/core/java/com/android/internal/view/menu/ListMenuItemView.java
@@ -34,6 +34,7 @@
  * The item view for each item in the ListView-based MenuViews.
  */
 public class ListMenuItemView extends LinearLayout implements MenuView.ItemView {
+    private static final String TAG = "ListMenuItemView";
     private MenuItemImpl mItemData; 
     
     private ImageView mIconView;
@@ -121,27 +122,25 @@
     }
 
     public void setCheckable(boolean checkable) {
-        
         if (!checkable && mRadioButton == null && mCheckBox == null) {
             return;
         }
         
-        if (mRadioButton == null) {
-            insertRadioButton();
-        }
-        if (mCheckBox == null) {
-            insertCheckBox();
-        }
-        
         // Depending on whether its exclusive check or not, the checkbox or
         // radio button will be the one in use (and the other will be otherCompoundButton)
         final CompoundButton compoundButton;
         final CompoundButton otherCompoundButton; 
 
         if (mItemData.isExclusiveCheckable()) {
+            if (mRadioButton == null) {
+                insertRadioButton();
+            }
             compoundButton = mRadioButton;
             otherCompoundButton = mCheckBox;
         } else {
+            if (mCheckBox == null) {
+                insertCheckBox();
+            }
             compoundButton = mCheckBox;
             otherCompoundButton = mRadioButton;
         }
@@ -155,12 +154,12 @@
             }
             
             // Make sure the other compound button isn't visible
-            if (otherCompoundButton.getVisibility() != GONE) {
+            if (otherCompoundButton != null && otherCompoundButton.getVisibility() != GONE) {
                 otherCompoundButton.setVisibility(GONE);
             }
         } else {
-            mCheckBox.setVisibility(GONE);
-            mRadioButton.setVisibility(GONE);
+            if (mCheckBox != null) mCheckBox.setVisibility(GONE);
+            if (mRadioButton != null) mRadioButton.setVisibility(GONE);
         }
     }
     
diff --git a/data/keyboards/keyboards.mk b/data/keyboards/keyboards.mk
index 564f41c..c964961 100644
--- a/data/keyboards/keyboards.mk
+++ b/data/keyboards/keyboards.mk
@@ -24,6 +24,3 @@
 
 PRODUCT_COPY_FILES += $(foreach file,$(keyconfigs),\
     frameworks/base/data/keyboards/$(file):system/usr/idc/$(file))
-
-PRODUCT_PACKAGES := $(keylayouts) $(keycharmaps) $(keyconfigs)
-
diff --git a/include/utils/Singleton.h b/include/utils/Singleton.h
index e1ee8eb..a42ce21 100644
--- a/include/utils/Singleton.h
+++ b/include/utils/Singleton.h
@@ -20,12 +20,13 @@
 #include <stdint.h>
 #include <sys/types.h>
 #include <utils/threads.h>
+#include <cutils/compiler.h>
 
 namespace android {
 // ---------------------------------------------------------------------------
 
 template <typename TYPE>
-class Singleton
+class ANDROID_API Singleton
 {
 public:
     static TYPE& getInstance() {
diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk
index a98e4cd..9bfc94c 100644
--- a/libs/hwui/Android.mk
+++ b/libs/hwui/Android.mk
@@ -39,6 +39,7 @@
 		external/skia/include/utils
 
 	LOCAL_CFLAGS += -DUSE_OPENGL_RENDERER
+	LOCAL_CFLAGS += -fvisibility=hidden
 	LOCAL_MODULE_CLASS := SHARED_LIBRARIES
 	LOCAL_SHARED_LIBRARIES := libcutils libutils libGLESv2 libskia libui
 	LOCAL_MODULE := libhwui
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index cdcbf21..9b0d7c6 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -23,6 +23,8 @@
 
 #include <utils/Singleton.h>
 
+#include <cutils/compiler.h>
+
 #include "Extensions.h"
 #include "FontRenderer.h"
 #include "GammaFontRenderer.h"
@@ -82,7 +84,7 @@
 // Caches
 ///////////////////////////////////////////////////////////////////////////////
 
-class Caches: public Singleton<Caches> {
+class ANDROID_API Caches: public Singleton<Caches> {
     Caches();
     ~Caches();
 
diff --git a/libs/hwui/DisplayListLogBuffer.h b/libs/hwui/DisplayListLogBuffer.h
index bf16f29..5d689bb 100644
--- a/libs/hwui/DisplayListLogBuffer.h
+++ b/libs/hwui/DisplayListLogBuffer.h
@@ -18,6 +18,7 @@
 #define ANDROID_HWUI_DISPLAY_LIST_LOG_BUFFER_H
 
 #include <utils/Singleton.h>
+
 #include <stdio.h>
 
 namespace android {
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index 8cd7fea..ab475bf 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -26,6 +26,8 @@
 #include <SkTDArray.h>
 #include <SkTSearch.h>
 
+#include <cutils/compiler.h>
+
 #include "DisplayListLogBuffer.h"
 #include "OpenGLRenderer.h"
 #include "utils/Functor.h"
@@ -58,7 +60,7 @@
 class DisplayList {
 public:
     DisplayList(const DisplayListRenderer& recorder);
-    ~DisplayList();
+    ANDROID_API ~DisplayList();
 
     // IMPORTANT: Update the intialization of OP_NAMES in the .cpp file
     //            when modifying this file
@@ -107,13 +109,13 @@
 
     void initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing = false);
 
-    size_t getSize();
+    ANDROID_API size_t getSize();
 
     bool replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level = 0);
 
     void output(OpenGLRenderer& renderer, uint32_t level = 0);
 
-    static void outputLogBuffer(int fd);
+    ANDROID_API static void outputLogBuffer(int fd);
 
     void setRenderable(bool renderable) {
         mIsRenderable = renderable;
@@ -230,75 +232,76 @@
  */
 class DisplayListRenderer: public OpenGLRenderer {
 public:
-    DisplayListRenderer();
-    ~DisplayListRenderer();
+    ANDROID_API DisplayListRenderer();
+    virtual ~DisplayListRenderer();
 
-    DisplayList* getDisplayList(DisplayList* displayList);
+    ANDROID_API DisplayList* getDisplayList(DisplayList* displayList);
 
-    void setViewport(int width, int height);
-    void prepareDirty(float left, float top, float right, float bottom, bool opaque);
-    void finish();
+    virtual void setViewport(int width, int height);
+    virtual void prepareDirty(float left, float top, float right, float bottom, bool opaque);
+    virtual void finish();
 
-    bool callDrawGLFunction(Functor *functor, Rect& dirty);
+    virtual bool callDrawGLFunction(Functor *functor, Rect& dirty);
 
-    void interrupt();
-    void resume();
+    virtual void interrupt();
+    virtual void resume();
 
-    int save(int flags);
-    void restore();
-    void restoreToCount(int saveCount);
+    virtual int save(int flags);
+    virtual void restore();
+    virtual void restoreToCount(int saveCount);
 
-    int saveLayer(float left, float top, float right, float bottom,
+    virtual int saveLayer(float left, float top, float right, float bottom,
             SkPaint* p, int flags);
-    int saveLayerAlpha(float left, float top, float right, float bottom,
+    virtual int saveLayerAlpha(float left, float top, float right, float bottom,
                 int alpha, int flags);
 
-    void translate(float dx, float dy);
-    void rotate(float degrees);
-    void scale(float sx, float sy);
-    void skew(float sx, float sy);
+    virtual void translate(float dx, float dy);
+    virtual void rotate(float degrees);
+    virtual void scale(float sx, float sy);
+    virtual void skew(float sx, float sy);
 
-    void setMatrix(SkMatrix* matrix);
-    void concatMatrix(SkMatrix* matrix);
+    virtual void setMatrix(SkMatrix* matrix);
+    virtual void concatMatrix(SkMatrix* matrix);
 
-    bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op);
+    virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op);
 
-    bool drawDisplayList(DisplayList* displayList, uint32_t width, uint32_t height,
+    virtual bool drawDisplayList(DisplayList* displayList, uint32_t width, uint32_t height,
             Rect& dirty, uint32_t level = 0);
-    void drawLayer(Layer* layer, float x, float y, SkPaint* paint);
-    void drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint);
-    void drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint);
-    void drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
+    virtual void drawLayer(Layer* layer, float x, float y, SkPaint* paint);
+    virtual void drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint);
+    virtual void drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint);
+    virtual void drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
             float srcRight, float srcBottom, float dstLeft, float dstTop,
             float dstRight, float dstBottom, SkPaint* paint);
-    void drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
+    virtual void drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
             float* vertices, int* colors, SkPaint* paint);
-    void drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int32_t* yDivs,
+    virtual void drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int32_t* yDivs,
             const uint32_t* colors, uint32_t width, uint32_t height, int8_t numColors,
             float left, float top, float right, float bottom, SkPaint* paint);
-    void drawColor(int color, SkXfermode::Mode mode);
-    void drawRect(float left, float top, float right, float bottom, SkPaint* paint);
-    void drawRoundRect(float left, float top, float right, float bottom,
+    virtual void drawColor(int color, SkXfermode::Mode mode);
+    virtual void drawRect(float left, float top, float right, float bottom, SkPaint* paint);
+    virtual void drawRoundRect(float left, float top, float right, float bottom,
             float rx, float ry, SkPaint* paint);
-    void drawCircle(float x, float y, float radius, SkPaint* paint);
-    void drawOval(float left, float top, float right, float bottom, SkPaint* paint);
-    void drawArc(float left, float top, float right, float bottom,
+    virtual void drawCircle(float x, float y, float radius, SkPaint* paint);
+    virtual void drawOval(float left, float top, float right, float bottom, SkPaint* paint);
+    virtual void drawArc(float left, float top, float right, float bottom,
             float startAngle, float sweepAngle, bool useCenter, SkPaint* paint);
-    void drawPath(SkPath* path, SkPaint* paint);
-    void drawLines(float* points, int count, SkPaint* paint);
-    void drawPoints(float* points, int count, SkPaint* paint);
-    void drawText(const char* text, int bytesCount, int count, float x, float y, SkPaint* paint);
+    virtual void drawPath(SkPath* path, SkPaint* paint);
+    virtual void drawLines(float* points, int count, SkPaint* paint);
+    virtual void drawPoints(float* points, int count, SkPaint* paint);
+    virtual void drawText(const char* text, int bytesCount, int count, float x, float y,
+            SkPaint* paint);
 
-    void resetShader();
-    void setupShader(SkiaShader* shader);
+    virtual void resetShader();
+    virtual void setupShader(SkiaShader* shader);
 
-    void resetColorFilter();
-    void setupColorFilter(SkiaColorFilter* filter);
+    virtual void resetColorFilter();
+    virtual void setupColorFilter(SkiaColorFilter* filter);
 
-    void resetShadow();
-    void setupShadow(float radius, float dx, float dy, int color);
+    virtual void resetShadow();
+    virtual void setupShadow(float radius, float dx, float dy, int color);
 
-    void reset();
+    ANDROID_API void reset();
 
     const SkWriter32& writeStream() const {
         return mWriter;
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp
index 349b9e3..dfcc5ea 100644
--- a/libs/hwui/LayerRenderer.cpp
+++ b/libs/hwui/LayerRenderer.cpp
@@ -31,6 +31,12 @@
 // Rendering
 ///////////////////////////////////////////////////////////////////////////////
 
+LayerRenderer::LayerRenderer(Layer* layer): mLayer(layer) {
+}
+
+LayerRenderer::~LayerRenderer() {
+}
+
 void LayerRenderer::prepareDirty(float left, float top, float right, float bottom, bool opaque) {
     LAYER_RENDERER_LOGD("Rendering into layer, fbo = %d", mLayer->getFbo());
 
@@ -264,7 +270,7 @@
     layer->setFbo(0);
     layer->setAlpha(255, SkXfermode::kSrcOver_Mode);
     layer->layer.set(0.0f, 0.0f, 0.0f, 0.0f);
-    layer->texCoords.set(0.0f, 1.0f, 0.0f, 1.0f);
+    layer->texCoords.set(0.0f, 1.0f, 1.0f, 0.0f);
     layer->region.clear();
     layer->setRenderTarget(GL_NONE); // see ::updateTextureLayer()
 
@@ -400,6 +406,18 @@
             renderer.setViewport(bitmap->width(), bitmap->height());
             renderer.OpenGLRenderer::prepareDirty(0.0f, 0.0f,
                     bitmap->width(), bitmap->height(), !layer->isBlend());
+
+            glDisable(GL_SCISSOR_TEST);
+            renderer.translate(0.0f, bitmap->height());
+            renderer.scale(1.0f, -1.0f);
+
+            mat4 texTransform(layer->getTexTransform());
+
+            mat4 invert;
+            invert.translate(0.0f, 1.0f, 0.0f);
+            invert.scale(1.0f, -1.0f, 1.0f);
+            layer->getTexTransform().multiply(invert);
+
             if ((error = glGetError()) != GL_NO_ERROR) goto error;
 
             {
@@ -413,6 +431,7 @@
                 if ((error = glGetError()) != GL_NO_ERROR) goto error;
             }
 
+            layer->getTexTransform().load(texTransform);
             status = true;
         }
 
diff --git a/libs/hwui/LayerRenderer.h b/libs/hwui/LayerRenderer.h
index 2246573..6104301 100644
--- a/libs/hwui/LayerRenderer.h
+++ b/libs/hwui/LayerRenderer.h
@@ -17,6 +17,8 @@
 #ifndef ANDROID_HWUI_LAYER_RENDERER_H
 #define ANDROID_HWUI_LAYER_RENDERER_H
 
+#include <cutils/compiler.h>
+
 #include "OpenGLRenderer.h"
 #include "Layer.h"
 
@@ -42,27 +44,24 @@
 
 class LayerRenderer: public OpenGLRenderer {
 public:
-    LayerRenderer(Layer* layer): mLayer(layer) {
-    }
+    ANDROID_API LayerRenderer(Layer* layer);
+    virtual ~LayerRenderer();
 
-    ~LayerRenderer() {
-    }
+    virtual void prepareDirty(float left, float top, float right, float bottom, bool opaque);
+    virtual void finish();
 
-    void prepareDirty(float left, float top, float right, float bottom, bool opaque);
-    void finish();
+    virtual bool hasLayer();
+    virtual Region* getRegion();
+    virtual GLint getTargetFbo();
 
-    bool hasLayer();
-    Region* getRegion();
-    GLint getTargetFbo();
-
-    static Layer* createTextureLayer(bool isOpaque);
-    static Layer* createLayer(uint32_t width, uint32_t height, bool isOpaque = false);
-    static bool resizeLayer(Layer* layer, uint32_t width, uint32_t height);
-    static void updateTextureLayer(Layer* layer, uint32_t width, uint32_t height,
+    ANDROID_API static Layer* createTextureLayer(bool isOpaque);
+    ANDROID_API static Layer* createLayer(uint32_t width, uint32_t height, bool isOpaque = false);
+    ANDROID_API static bool resizeLayer(Layer* layer, uint32_t width, uint32_t height);
+    ANDROID_API static void updateTextureLayer(Layer* layer, uint32_t width, uint32_t height,
             bool isOpaque, GLenum renderTarget, float* transform);
-    static void destroyLayer(Layer* layer);
-    static void destroyLayerDeferred(Layer* layer);
-    static bool copyLayer(Layer* layer, SkBitmap* bitmap);
+    ANDROID_API static void destroyLayer(Layer* layer);
+    ANDROID_API static void destroyLayerDeferred(Layer* layer);
+    ANDROID_API static bool copyLayer(Layer* layer, SkBitmap* bitmap);
 
 private:
     void generateMesh();
diff --git a/libs/hwui/Matrix.h b/libs/hwui/Matrix.h
index 56fd37d..22220a9 100644
--- a/libs/hwui/Matrix.h
+++ b/libs/hwui/Matrix.h
@@ -19,6 +19,8 @@
 
 #include <SkMatrix.h>
 
+#include <cutils/compiler.h>
+
 #include "Rect.h"
 
 namespace android {
@@ -28,7 +30,7 @@
 // Classes
 ///////////////////////////////////////////////////////////////////////////////
 
-class Matrix4 {
+class ANDROID_API Matrix4 {
 public:
     float data[16];
 
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 14b22b3..2fc88e1 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -31,6 +31,8 @@
 #include <utils/RefBase.h>
 #include <utils/Vector.h>
 
+#include <cutils/compiler.h>
+
 #include "Debug.h"
 #include "Extensions.h"
 #include "Matrix.h"
@@ -57,12 +59,12 @@
  */
 class OpenGLRenderer {
 public:
-    OpenGLRenderer();
+    ANDROID_API OpenGLRenderer();
     virtual ~OpenGLRenderer();
 
     virtual void setViewport(int width, int height);
 
-    void prepare(bool opaque);
+    ANDROID_API void prepare(bool opaque);
     virtual void prepareDirty(float left, float top, float right, float bottom, bool opaque);
     virtual void finish();
 
@@ -72,7 +74,7 @@
 
     virtual bool callDrawGLFunction(Functor *functor, Rect& dirty);
 
-    int getSaveCount() const;
+    ANDROID_API int getSaveCount() const;
     virtual int save(int flags);
     virtual void restore();
     virtual void restoreToCount(int saveCount);
@@ -87,12 +89,12 @@
     virtual void scale(float sx, float sy);
     virtual void skew(float sx, float sy);
 
-    void getMatrix(SkMatrix* matrix);
+    ANDROID_API void getMatrix(SkMatrix* matrix);
     virtual void setMatrix(SkMatrix* matrix);
     virtual void concatMatrix(SkMatrix* matrix);
 
-    const Rect& getClipBounds();
-    bool quickReject(float left, float top, float right, float bottom);
+    ANDROID_API const Rect& getClipBounds();
+    ANDROID_API bool quickReject(float left, float top, float right, float bottom);
     virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op);
 
     virtual bool drawDisplayList(DisplayList* displayList, uint32_t width, uint32_t height,
diff --git a/libs/hwui/ResourceCache.h b/libs/hwui/ResourceCache.h
index 2a38910..8cf466b 100644
--- a/libs/hwui/ResourceCache.h
+++ b/libs/hwui/ResourceCache.h
@@ -17,6 +17,8 @@
 #ifndef ANDROID_HWUI_RESOURCE_CACHE_H
 #define ANDROID_HWUI_RESOURCE_CACHE_H
 
+#include <cutils/compiler.h>
+
 #include <SkBitmap.h>
 #include <SkiaColorFilter.h>
 #include <SkiaShader.h>
@@ -49,7 +51,7 @@
     ResourceType resourceType;
 };
 
-class ResourceCache {
+class ANDROID_API ResourceCache {
     KeyedVector<void *, ResourceReference *>* mCache;
 public:
     ResourceCache();
diff --git a/libs/hwui/SkiaColorFilter.h b/libs/hwui/SkiaColorFilter.h
index 1bf475c..2feb834 100644
--- a/libs/hwui/SkiaColorFilter.h
+++ b/libs/hwui/SkiaColorFilter.h
@@ -20,6 +20,8 @@
 #include <GLES2/gl2.h>
 #include <SkColorFilter.h>
 
+#include <cutils/compiler.h>
+
 #include "ProgramCache.h"
 #include "Extensions.h"
 
@@ -45,7 +47,7 @@
         kBlend,
     };
 
-    SkiaColorFilter(SkColorFilter *skFilter, Type type, bool blend);
+    ANDROID_API SkiaColorFilter(SkColorFilter *skFilter, Type type, bool blend);
     virtual ~SkiaColorFilter();
 
     virtual void describe(ProgramDescription& description, const Extensions& extensions) = 0;
@@ -79,7 +81,7 @@
  * A color filter that multiplies the source color with a matrix and adds a vector.
  */
 struct SkiaColorMatrixFilter: public SkiaColorFilter {
-    SkiaColorMatrixFilter(SkColorFilter *skFilter, float* matrix, float* vector);
+    ANDROID_API SkiaColorMatrixFilter(SkColorFilter *skFilter, float* matrix, float* vector);
     ~SkiaColorMatrixFilter();
 
     void describe(ProgramDescription& description, const Extensions& extensions);
@@ -95,7 +97,7 @@
  * another fixed value. Ignores the alpha channel of both arguments.
  */
 struct SkiaLightingFilter: public SkiaColorFilter {
-    SkiaLightingFilter(SkColorFilter *skFilter, int multiply, int add);
+    ANDROID_API SkiaLightingFilter(SkColorFilter *skFilter, int multiply, int add);
 
     void describe(ProgramDescription& description, const Extensions& extensions);
     void setupProgram(Program* program);
@@ -110,7 +112,7 @@
  * and PorterDuff blending mode.
  */
 struct SkiaBlendFilter: public SkiaColorFilter {
-    SkiaBlendFilter(SkColorFilter *skFilter, int color, SkXfermode::Mode mode);
+    ANDROID_API SkiaBlendFilter(SkColorFilter *skFilter, int color, SkXfermode::Mode mode);
 
     void describe(ProgramDescription& description, const Extensions& extensions);
     void setupProgram(Program* program);
diff --git a/libs/hwui/SkiaShader.h b/libs/hwui/SkiaShader.h
index 89dd131..2de9a93 100644
--- a/libs/hwui/SkiaShader.h
+++ b/libs/hwui/SkiaShader.h
@@ -22,6 +22,8 @@
 
 #include <GLES2/gl2.h>
 
+#include <cutils/compiler.h>
+
 #include "Extensions.h"
 #include "ProgramCache.h"
 #include "TextureCache.h"
@@ -52,8 +54,8 @@
         kCompose
     };
 
-    SkiaShader(Type type, SkShader* key, SkShader::TileMode tileX, SkShader::TileMode tileY,
-            SkMatrix* matrix, bool blend);
+    ANDROID_API SkiaShader(Type type, SkShader* key, SkShader::TileMode tileX,
+            SkShader::TileMode tileY, SkMatrix* matrix, bool blend);
     virtual ~SkiaShader();
 
     virtual SkiaShader* copy() = 0;
@@ -139,7 +141,7 @@
  * A shader that draws a bitmap.
  */
 struct SkiaBitmapShader: public SkiaShader {
-    SkiaBitmapShader(SkBitmap* bitmap, SkShader* key, SkShader::TileMode tileX,
+    ANDROID_API SkiaBitmapShader(SkBitmap* bitmap, SkShader* key, SkShader::TileMode tileX,
             SkShader::TileMode tileY, SkMatrix* matrix, bool blend);
     SkiaShader* copy();
 
@@ -169,8 +171,8 @@
  * A shader that draws a linear gradient.
  */
 struct SkiaLinearGradientShader: public SkiaShader {
-    SkiaLinearGradientShader(float* bounds, uint32_t* colors, float* positions, int count,
-            SkShader* key, SkShader::TileMode tileMode, SkMatrix* matrix, bool blend);
+    ANDROID_API SkiaLinearGradientShader(float* bounds, uint32_t* colors, float* positions,
+            int count, SkShader* key, SkShader::TileMode tileMode, SkMatrix* matrix, bool blend);
     ~SkiaLinearGradientShader();
     SkiaShader* copy();
 
@@ -193,8 +195,8 @@
  * A shader that draws a sweep gradient.
  */
 struct SkiaSweepGradientShader: public SkiaShader {
-    SkiaSweepGradientShader(float x, float y, uint32_t* colors, float* positions, int count,
-            SkShader* key, SkMatrix* matrix, bool blend);
+    ANDROID_API SkiaSweepGradientShader(float x, float y, uint32_t* colors, float* positions,
+            int count, SkShader* key, SkMatrix* matrix, bool blend);
     ~SkiaSweepGradientShader();
     SkiaShader* copy();
 
@@ -218,8 +220,9 @@
  * A shader that draws a circular gradient.
  */
 struct SkiaCircularGradientShader: public SkiaSweepGradientShader {
-    SkiaCircularGradientShader(float x, float y, float radius, uint32_t* colors, float* positions,
-            int count, SkShader* key,SkShader::TileMode tileMode, SkMatrix* matrix, bool blend);
+    ANDROID_API SkiaCircularGradientShader(float x, float y, float radius, uint32_t* colors,
+            float* positions, int count, SkShader* key,SkShader::TileMode tileMode,
+            SkMatrix* matrix, bool blend);
     SkiaShader* copy();
 
     void describe(ProgramDescription& description, const Extensions& extensions);
@@ -233,7 +236,8 @@
  * A shader that draws two shaders, composited with an xfermode.
  */
 struct SkiaComposeShader: public SkiaShader {
-    SkiaComposeShader(SkiaShader* first, SkiaShader* second, SkXfermode::Mode mode, SkShader* key);
+    ANDROID_API SkiaComposeShader(SkiaShader* first, SkiaShader* second, SkXfermode::Mode mode,
+            SkShader* key);
     ~SkiaComposeShader();
     SkiaShader* copy();
 
diff --git a/libs/rs/driver/rsdBcc.cpp b/libs/rs/driver/rsdBcc.cpp
index 5fd5c35..4ecf8e8 100644
--- a/libs/rs/driver/rsdBcc.cpp
+++ b/libs/rs/driver/rsdBcc.cpp
@@ -226,6 +226,7 @@
     RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv;
     uint32_t sig = mtls->sig;
 
+    outer_foreach_t fn = dc->mForEachLaunch[sig];
     while (1) {
         uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum);
         uint32_t yStart = mtls->yStart + slice * mtls->mSliceSize;
@@ -239,16 +240,10 @@
         //LOGE("usr ptr in %p,  out %p", mtls->ptrIn, mtls->ptrOut);
         for (p.y = yStart; p.y < yEnd; p.y++) {
             uint32_t offset = mtls->dimX * p.y;
-            uint8_t *xPtrOut = mtls->ptrOut + (mtls->eStrideOut * offset);
-            const uint8_t *xPtrIn = mtls->ptrIn + (mtls->eStrideIn * offset);
-
-            for (p.x = mtls->xStart; p.x < mtls->xEnd; p.x++) {
-                p.in = xPtrIn;
-                p.out = xPtrOut;
-                dc->mForEachLaunch[sig](&mtls->script->mHal.info.root, &p);
-                xPtrIn += mtls->eStrideIn;
-                xPtrOut += mtls->eStrideOut;
-            }
+            p.out = mtls->ptrOut + (mtls->eStrideOut * offset);
+            p.in = mtls->ptrIn + (mtls->eStrideIn * offset);
+            fn(&mtls->script->mHal.info.root, &p, mtls->xStart, mtls->xEnd,
+               mtls->eStrideIn, mtls->eStrideOut);
         }
     }
 }
@@ -262,6 +257,7 @@
     RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv;
     uint32_t sig = mtls->sig;
 
+    outer_foreach_t fn = dc->mForEachLaunch[sig];
     while (1) {
         uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum);
         uint32_t xStart = mtls->xStart + slice * mtls->mSliceSize;
@@ -271,17 +267,12 @@
             return;
         }
 
-        //LOGE("usr idx %i, x %i,%i  y %i,%i", idx, mtls->xStart, mtls->xEnd, yStart, yEnd);
+        //LOGE("usr slice %i idx %i, x %i,%i", slice, idx, xStart, xEnd);
         //LOGE("usr ptr in %p,  out %p", mtls->ptrIn, mtls->ptrOut);
-        uint8_t *xPtrOut = mtls->ptrOut + (mtls->eStrideOut * xStart);
-        const uint8_t *xPtrIn = mtls->ptrIn + (mtls->eStrideIn * xStart);
-        for (p.x = xStart; p.x < xEnd; p.x++) {
-            p.in = xPtrIn;
-            p.out = xPtrOut;
-            dc->mForEachLaunch[sig](&mtls->script->mHal.info.root, &p);
-            xPtrIn += mtls->eStrideIn;
-            xPtrOut += mtls->eStrideOut;
-        }
+
+        p.out = mtls->ptrOut + (mtls->eStrideOut * xStart);
+        p.in = mtls->ptrIn + (mtls->eStrideIn * xStart);
+        fn(&mtls->script->mHal.info.root, &p, xStart, xEnd, mtls->eStrideIn, mtls->eStrideOut);
     }
 }
 
@@ -392,22 +383,17 @@
         uint32_t sig = mtls.sig;
 
         //LOGE("launch 3");
+        outer_foreach_t fn = dc->mForEachLaunch[sig];
         for (p.ar[0] = mtls.arrayStart; p.ar[0] < mtls.arrayEnd; p.ar[0]++) {
             for (p.z = mtls.zStart; p.z < mtls.zEnd; p.z++) {
                 for (p.y = mtls.yStart; p.y < mtls.yEnd; p.y++) {
                     uint32_t offset = mtls.dimX * mtls.dimY * mtls.dimZ * p.ar[0] +
                                       mtls.dimX * mtls.dimY * p.z +
                                       mtls.dimX * p.y;
-                    uint8_t *xPtrOut = mtls.ptrOut + (mtls.eStrideOut * offset);
-                    const uint8_t *xPtrIn = mtls.ptrIn + (mtls.eStrideIn * offset);
-
-                    for (p.x = mtls.xStart; p.x < mtls.xEnd; p.x++) {
-                        p.in = xPtrIn;
-                        p.out = xPtrOut;
-                        dc->mForEachLaunch[sig](&s->mHal.info.root, &p);
-                        xPtrIn += mtls.eStrideIn;
-                        xPtrOut += mtls.eStrideOut;
-                    }
+                    p.out = mtls.ptrOut + (mtls.eStrideOut * offset);
+                    p.in = mtls.ptrIn + (mtls.eStrideIn * offset);
+                    fn(&mtls.script->mHal.info.root, &p, mtls.xStart, mtls.xEnd,
+                       mtls.eStrideIn, mtls.eStrideOut);
                 }
             }
         }
diff --git a/libs/rs/driver/rsdCore.cpp b/libs/rs/driver/rsdCore.cpp
index f8107d9..247f4dc 100644
--- a/libs/rs/driver/rsdCore.cpp
+++ b/libs/rs/driver/rsdCore.cpp
@@ -292,75 +292,136 @@
 }
 
 static void rsdForEach17(const void *vRoot,
-        const android::renderscript::RsForEachStubParamStruct *p) {
+        const android::renderscript::RsForEachStubParamStruct *p,
+                                uint32_t x1, uint32_t x2,
+                                uint32_t instep, uint32_t outstep) {
     typedef void (*fe)(const void *, uint32_t);
     (*(fe*)vRoot)(p->in, p->y);
 }
 
 static void rsdForEach18(const void *vRoot,
-        const android::renderscript::RsForEachStubParamStruct *p) {
+        const android::renderscript::RsForEachStubParamStruct *p,
+                                uint32_t x1, uint32_t x2,
+                                uint32_t instep, uint32_t outstep) {
     typedef void (*fe)(void *, uint32_t);
     (*(fe*)vRoot)(p->out, p->y);
 }
 
 static void rsdForEach19(const void *vRoot,
-        const android::renderscript::RsForEachStubParamStruct *p) {
+        const android::renderscript::RsForEachStubParamStruct *p,
+                                uint32_t x1, uint32_t x2,
+                                uint32_t instep, uint32_t outstep) {
     typedef void (*fe)(const void *, void *, uint32_t);
     (*(fe*)vRoot)(p->in, p->out, p->y);
 }
 
 static void rsdForEach21(const void *vRoot,
-        const android::renderscript::RsForEachStubParamStruct *p) {
+        const android::renderscript::RsForEachStubParamStruct *p,
+                                uint32_t x1, uint32_t x2,
+                                uint32_t instep, uint32_t outstep) {
     typedef void (*fe)(const void *, const void *, uint32_t);
     (*(fe*)vRoot)(p->in, p->usr, p->y);
 }
 
 static void rsdForEach22(const void *vRoot,
-        const android::renderscript::RsForEachStubParamStruct *p) {
+        const android::renderscript::RsForEachStubParamStruct *p,
+                                uint32_t x1, uint32_t x2,
+                                uint32_t instep, uint32_t outstep) {
     typedef void (*fe)(void *, const void *, uint32_t);
     (*(fe*)vRoot)(p->out, p->usr, p->y);
 }
 
 static void rsdForEach23(const void *vRoot,
-        const android::renderscript::RsForEachStubParamStruct *p) {
+        const android::renderscript::RsForEachStubParamStruct *p,
+                                uint32_t x1, uint32_t x2,
+                                uint32_t instep, uint32_t outstep) {
     typedef void (*fe)(const void *, void *, const void *, uint32_t);
     (*(fe*)vRoot)(p->in, p->out, p->usr, p->y);
 }
 
 static void rsdForEach25(const void *vRoot,
-        const android::renderscript::RsForEachStubParamStruct *p) {
+        const android::renderscript::RsForEachStubParamStruct *p,
+                                uint32_t x1, uint32_t x2,
+                                uint32_t instep, uint32_t outstep) {
     typedef void (*fe)(const void *, uint32_t, uint32_t);
-    (*(fe*)vRoot)(p->in, p->x, p->y);
+    const uint8_t *pin = (const uint8_t *)p->in;
+    uint32_t y = p->y;
+    for (uint32_t x = x1; x < x2; x++) {
+        (*(fe*)vRoot)(pin, x, y);
+        pin += instep;
+    }
 }
 
 static void rsdForEach26(const void *vRoot,
-        const android::renderscript::RsForEachStubParamStruct *p) {
+        const android::renderscript::RsForEachStubParamStruct *p,
+                                uint32_t x1, uint32_t x2,
+                                uint32_t instep, uint32_t outstep) {
     typedef void (*fe)(void *, uint32_t, uint32_t);
-    (*(fe*)vRoot)(p->out, p->x, p->y);
+    uint8_t *pout = (uint8_t *)p->out;
+    uint32_t y = p->y;
+    for (uint32_t x = x1; x < x2; x++) {
+        (*(fe*)vRoot)(pout, x, y);
+        pout += outstep;
+    }
 }
 
 static void rsdForEach27(const void *vRoot,
-        const android::renderscript::RsForEachStubParamStruct *p) {
+        const android::renderscript::RsForEachStubParamStruct *p,
+                                uint32_t x1, uint32_t x2,
+                                uint32_t instep, uint32_t outstep) {
     typedef void (*fe)(const void *, void *, uint32_t, uint32_t);
-    (*(fe*)vRoot)(p->in, p->out, p->x, p->y);
+    uint8_t *pout = (uint8_t *)p->out;
+    const uint8_t *pin = (const uint8_t *)p->in;
+    uint32_t y = p->y;
+    for (uint32_t x = x1; x < x2; x++) {
+        (*(fe*)vRoot)(pin, pout, x, y);
+        pin += instep;
+        pout += outstep;
+    }
 }
 
 static void rsdForEach29(const void *vRoot,
-        const android::renderscript::RsForEachStubParamStruct *p) {
+        const android::renderscript::RsForEachStubParamStruct *p,
+                                uint32_t x1, uint32_t x2,
+                                uint32_t instep, uint32_t outstep) {
     typedef void (*fe)(const void *, const void *, uint32_t, uint32_t);
-    (*(fe*)vRoot)(p->in, p->usr, p->x, p->y);
+    const uint8_t *pin = (const uint8_t *)p->in;
+    const void *usr = p->usr;
+    const uint32_t y = p->y;
+    for (uint32_t x = x1; x < x2; x++) {
+        (*(fe*)vRoot)(pin, usr, x, y);
+        pin += instep;
+    }
 }
 
 static void rsdForEach30(const void *vRoot,
-        const android::renderscript::RsForEachStubParamStruct *p) {
+        const android::renderscript::RsForEachStubParamStruct *p,
+                                uint32_t x1, uint32_t x2,
+                                uint32_t instep, uint32_t outstep) {
     typedef void (*fe)(void *, const void *, uint32_t, uint32_t);
-    (*(fe*)vRoot)(p->out, p->usr, p->x, p->y);
+    uint8_t *pout = (uint8_t *)p->out;
+    const void *usr = p->usr;
+    const uint32_t y = p->y;
+    for (uint32_t x = x1; x < x2; x++) {
+        (*(fe*)vRoot)(pout, usr, x, y);
+        pout += outstep;
+    }
 }
 
 static void rsdForEach31(const void *vRoot,
-        const android::renderscript::RsForEachStubParamStruct *p) {
+        const android::renderscript::RsForEachStubParamStruct *p,
+                                uint32_t x1, uint32_t x2,
+                                uint32_t instep, uint32_t outstep) {
     typedef void (*fe)(const void *, void *, const void *, uint32_t, uint32_t);
-    (*(fe*)vRoot)(p->in, p->out, p->usr, p->x, p->y);
+    uint8_t *pout = (uint8_t *)p->out;
+    const uint8_t *pin = (const uint8_t *)p->in;
+    const void *usr = p->usr;
+    const uint32_t y = p->y;
+    for (uint32_t x = x1; x < x2; x++) {
+        (*(fe*)vRoot)(pin, pout, usr, x, y);
+        pin += instep;
+        pout += outstep;
+    }
 }
 
 
diff --git a/libs/rs/driver/rsdCore.h b/libs/rs/driver/rsdCore.h
index 159b72a..ce86d11 100644
--- a/libs/rs/driver/rsdCore.h
+++ b/libs/rs/driver/rsdCore.h
@@ -28,7 +28,9 @@
 typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
 
 typedef void (*outer_foreach_t)(const void *,
-    const android::renderscript::RsForEachStubParamStruct *);
+    const android::renderscript::RsForEachStubParamStruct *,
+                                uint32_t x1, uint32_t x2,
+                                uint32_t instep, uint32_t outstep);
 
 typedef struct RsdSymbolTableRec {
     const char * mName;
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back.png
index 3adcbec..4a1d37e 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_highlight.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_highlight.png
index d7a591c..9378fac 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_highlight.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_highlight.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_in.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_in.png
index 277dcb8..6e84546 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_in.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_inout.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_inout.png
index edc1760..c56905e 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_inout.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_out.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_out.png
index fbc6b99..11ffbde 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_out.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_in.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_in.png
index fb938e8..2bb923e 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_in.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_inout.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_inout.png
index 2d35517..783ad175 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_inout.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_out.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_out.png
index fe68c3c..e499f9d 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_out.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back.png
index 49411bd..39e3df0 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_highlight.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_highlight.png
index 77924f0..b4920c3 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_highlight.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_highlight.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_in.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_in.png
index 000e98b..31c0936 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_in.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_inout.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_inout.png
index 62b940a..7e9b752 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_inout.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_out.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_out.png
index 5beb543..3209234d 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_out.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_in.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_in.png
index f70d315..95c56ed 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_in.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_inout.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_inout.png
index be9953f..11b9a93 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_inout.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_out.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_out.png
index de20bdd..0f85ca0 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_out.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_in.png b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_in.png
index 8a3d90c..3d67766 100644
--- a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_in.png
+++ b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_inout.png b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_inout.png
index 45dda51c..b74e070 100644
--- a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_inout.png
+++ b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_out.png b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_out.png
index 18e019c..24485e1 100644
--- a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_out.png
+++ b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_wifi_in.png b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_wifi_in.png
index cb8ed3a..390d500 100644
--- a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_wifi_in.png
+++ b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_wifi_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_wifi_inout.png b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_wifi_inout.png
index ab4ad05..78998f9 100644
--- a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_wifi_inout.png
+++ b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_wifi_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_wifi_out.png b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_wifi_out.png
index 956b6c1..c539615 100644
--- a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_wifi_out.png
+++ b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_wifi_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_in.png b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_in.png
index 9d95f17..5c38d45 100644
--- a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_in.png
+++ b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_inout.png b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_inout.png
index e68d57d..6a79695 100644
--- a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_inout.png
+++ b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_out.png b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_out.png
index 4ac361d9..99dbe1b 100644
--- a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_out.png
+++ b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_wifi_in.png b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_wifi_in.png
index 5e7ecdc..6a73a89 100644
--- a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_wifi_in.png
+++ b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_wifi_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_wifi_inout.png b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_wifi_inout.png
index 462fad4..7042f2b 100644
--- a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_wifi_inout.png
+++ b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_wifi_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_wifi_out.png b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_wifi_out.png
index d284c02..3da781e 100644
--- a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_wifi_out.png
+++ b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_wifi_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_in.png b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_in.png
index 4a5e701..cf63e24 100644
--- a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_in.png
+++ b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_inout.png b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_inout.png
index 9a08949..8f68e1f 100644
--- a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_inout.png
+++ b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_out.png b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_out.png
index 314f422..894c63b 100644
--- a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_out.png
+++ b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_wifi_in.png b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_wifi_in.png
index 4e0a48a..1ec5b49 100644
--- a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_wifi_in.png
+++ b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_wifi_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_wifi_inout.png b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_wifi_inout.png
index 4eeae1d..9ca3ca8 100644
--- a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_wifi_inout.png
+++ b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_wifi_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_wifi_out.png b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_wifi_out.png
index 1a6f1ef..74241e0 100644
--- a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_wifi_out.png
+++ b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_wifi_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back.png
index d853993..faeee29 100644
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back.png
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_highlight.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_highlight.png
index 2e6e3ac..f7e7102 100644
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_highlight.png
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_highlight.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_in.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_in.png
index 2864ec3..cc9c49f 100644
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_in.png
+++ b/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_inout.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_inout.png
index 0bb0c72..5a313c5 100644
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_inout.png
+++ b/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_out.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_out.png
index f23dd60..373a4a4 100644
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_out.png
+++ b/packages/SystemUI/res/drawable-xhdpi/stat_sys_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_wifi_in.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_wifi_in.png
index b1c3168..d299daf 100644
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_wifi_in.png
+++ b/packages/SystemUI/res/drawable-xhdpi/stat_sys_wifi_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_wifi_inout.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_wifi_inout.png
index 5e41470..dcfdb7b 100644
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_wifi_inout.png
+++ b/packages/SystemUI/res/drawable-xhdpi/stat_sys_wifi_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_wifi_out.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_wifi_out.png
index 639842b..fb8125a 100644
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_wifi_out.png
+++ b/packages/SystemUI/res/drawable-xhdpi/stat_sys_wifi_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable/notification_row_bg.xml b/packages/SystemUI/res/drawable/notification_row_bg.xml
index dc626d1..1bb2172 100644
--- a/packages/SystemUI/res/drawable/notification_row_bg.xml
+++ b/packages/SystemUI/res/drawable/notification_row_bg.xml
@@ -17,6 +17,6 @@
 <selector xmlns:android="http://schemas.android.com/apk/res/android"
         android:exitFadeDuration="@android:integer/config_mediumAnimTime">
 
-    <item android:state_pressed="true"  android:drawable="@android:color/holo_blue_light" />
+    <item android:state_pressed="true"  android:drawable="@drawable/notification_item_background_color_pressed" />
     <item android:state_pressed="false" android:drawable="@drawable/notification_item_background_color" />
 </selector>
diff --git a/packages/SystemUI/res/layout/status_bar_notification_row.xml b/packages/SystemUI/res/layout/status_bar_notification_row.xml
index 3220e62..abbc89a 100644
--- a/packages/SystemUI/res/layout/status_bar_notification_row.xml
+++ b/packages/SystemUI/res/layout/status_bar_notification_row.xml
@@ -41,7 +41,7 @@
         android:layout_width="match_parent"
         android:layout_height="@dimen/notification_divider_height"
         android:layout_alignParentBottom="true"
-        android:background="@drawable/notification_item_background_color"
+        android:background="@drawable/status_bar_notification_row_background_color"
         />
 
 </RelativeLayout>
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index 5ba1908..c88d651 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -19,6 +19,7 @@
 <resources>
     <drawable name="notification_number_text_color">#ffffffff</drawable>
     <drawable name="notification_item_background_color">#ff111111</drawable>
+    <drawable name="notification_item_background_color_pressed">#ff257390</drawable>
     <drawable name="ticker_background_color">#ff1d1d1d</drawable>
     <drawable name="status_bar_background">#ff000000</drawable>
     <drawable name="status_bar_recents_background">#b3000000</drawable>
diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java
index 8569143..11b6c15 100644
--- a/policy/src/com/android/internal/policy/impl/GlobalActions.java
+++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java
@@ -18,7 +18,6 @@
 
 import android.app.Activity;
 import android.app.AlertDialog;
-import android.app.StatusBarManager;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -57,8 +56,6 @@
 
     private static final String TAG = "GlobalActions";
 
-    private StatusBarManager mStatusBar;
-
     private final Context mContext;
     private final AudioManager mAudioManager;
 
@@ -103,13 +100,12 @@
         mKeyguardShowing = keyguardShowing;
         mDeviceProvisioned = isDeviceProvisioned;
         if (mDialog == null) {
-            mStatusBar = (StatusBarManager)mContext.getSystemService(Context.STATUS_BAR_SERVICE);
             mDialog = createDialog();
         }
         prepareDialog();
 
-        mStatusBar.disable(StatusBarManager.DISABLE_EXPAND);
         mDialog.show();
+        mDialog.getWindow().getDecorView().setSystemUiVisibility(View.STATUS_BAR_DISABLE_EXPAND);
     }
 
     /**
@@ -249,7 +245,6 @@
 
     /** {@inheritDoc} */
     public void onDismiss(DialogInterface dialog) {
-        mStatusBar.disable(StatusBarManager.DISABLE_NONE);
     }
 
     /** {@inheritDoc} */
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index b05705e..bcb1aa2 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -238,6 +238,11 @@
      * Notify our observers of an interface removal.
      */
     private void notifyInterfaceRemoved(String iface) {
+        // netd already clears out quota and alerts for removed ifaces; update
+        // our sanity-checking state.
+        mActiveAlertIfaces.remove(iface);
+        mActiveQuotaIfaces.remove(iface);
+
         for (INetworkManagementEventObserver obs : mObservers) {
             try {
                 obs.interfaceRemoved(iface);
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
index 3232eedc..414ae0d 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
@@ -22,9 +22,11 @@
 import android.content.res.Resources;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
+import android.graphics.Matrix;
 import android.graphics.SurfaceTexture;
 import android.opengl.GLUtils;
 import android.os.Bundle;
+import android.os.Environment;
 import android.util.Log;
 import android.view.Gravity;
 import android.view.TextureView;
@@ -39,6 +41,7 @@
 import javax.microedition.khronos.egl.EGLSurface;
 import javax.microedition.khronos.opengles.GL;
 import java.io.BufferedOutputStream;
+import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -65,7 +68,8 @@
                 Bitmap b = mTextureView.getBitmap(800, 800);
                 BufferedOutputStream out = null;
                 try {
-                    out = new BufferedOutputStream(new FileOutputStream("/sdcard/out.png"));
+                    File dump = new File(Environment.getExternalStorageDirectory(), "out.png");
+                    out = new BufferedOutputStream(new FileOutputStream(dump));
                     b.compress(Bitmap.CompressFormat.PNG, 100, out);
                 } catch (FileNotFoundException e) {
                     e.printStackTrace();
@@ -168,10 +172,10 @@
         private static final int TRIANGLE_VERTICES_DATA_UV_OFFSET = 3;
         private final float[] mTriangleVerticesData = {
                 // X, Y, Z, U, V
-                -1.0f, -1.0f, 0, 0.f, 0.f,
-                1.0f, -1.0f, 0, 1.f, 0.f,
-                -1.0f,  1.0f, 0, 0.f, 1.f,
-                1.0f,   1.0f, 0, 1.f, 1.f,
+                -1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
+                 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
+                -1.0f,  1.0f, 0.0f, 0.0f, 1.0f,
+                 1.0f,  1.0f, 0.0f, 1.0f, 1.0f,
         };
 
         @Override
@@ -212,8 +216,6 @@
             while (!mFinished) {
                 checkCurrent();
 
-                Log.d(LOG_TAG, "Rendering frame");
-
                 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
                 checkGlError();
 
@@ -237,7 +239,7 @@
                 checkEglError();
 
                 try {
-                    Thread.sleep(20);
+                    Thread.sleep(2000);
                 } catch (InterruptedException e) {
                     // Ignore
                 }
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
index fcb57d9..0f4c668 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
@@ -17,16 +17,23 @@
 package com.android.test.hwui;
 
 import android.app.Activity;
+import android.graphics.Bitmap;
 import android.graphics.Matrix;
 import android.graphics.SurfaceTexture;
 import android.hardware.Camera;
 import android.os.Bundle;
+import android.os.Environment;
 import android.view.Gravity;
+import android.view.Surface;
 import android.view.TextureView;
 import android.view.View;
 import android.widget.Button;
 import android.widget.FrameLayout;
 
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
 
 @SuppressWarnings({"UnusedDeclaration"})
@@ -44,6 +51,26 @@
 
         mTextureView = new TextureView(this);
         mTextureView.setSurfaceTextureListener(this);
+        mTextureView.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                Bitmap b = mTextureView.getBitmap(800, 800);
+                BufferedOutputStream out = null;
+                try {
+                    File dump = new File(Environment.getExternalStorageDirectory(), "out.png");
+                    out = new BufferedOutputStream(new FileOutputStream(dump));
+                    b.compress(Bitmap.CompressFormat.PNG, 100, out);
+                } catch (FileNotFoundException e) {
+                    e.printStackTrace();
+                } finally {
+                    if (out != null) try {
+                        out.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        });
 
         Button button = new Button(this);
         button.setText("Remove/Add");
@@ -73,6 +100,8 @@
     @Override
     public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
         mCamera = Camera.open();
+        mCamera.setDisplayOrientation(getCameraOrientation());
+
         Camera.Size previewSize = mCamera.getParameters().getPreviewSize();
         mTextureView.setLayoutParams(new FrameLayout.LayoutParams(
                 previewSize.width, previewSize.height, Gravity.CENTER));
@@ -86,6 +115,34 @@
         mCamera.startPreview();
     }
 
+    private int getCameraOrientation() {
+        Camera.CameraInfo info = new Camera.CameraInfo();
+        for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
+            Camera.getCameraInfo(i, info);
+            if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) break;
+        }
+        
+        int rotation = getWindowManager().getDefaultDisplay().getRotation();
+        int degrees = 0;
+
+        switch (rotation) {
+            case Surface.ROTATION_0:
+                degrees = 0;
+                break;
+            case Surface.ROTATION_90:
+                degrees = 90;
+                break;
+            case Surface.ROTATION_180:
+                degrees = 180;
+                break;
+            case Surface.ROTATION_270:
+                degrees = 270;
+                break;
+        }
+
+        return (info.orientation - degrees + 360) % 360;
+    }
+
     @Override
     public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
         // Ignored, the Camera does all the work for us
diff --git a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbosync.rs b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbosync.rs
index b77ccb4..42b1cf1 100644
--- a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbosync.rs
+++ b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbosync.rs
@@ -105,8 +105,8 @@
         rsgMeshComputeBoundingBox(info->mMesh,
                                   &minX, &minY, &minZ,
                                   &maxX, &maxY, &maxZ);
-        info->bBoxMin = (minX, minY, minZ);
-        info->bBoxMax = (maxX, maxY, maxZ);
+        info->bBoxMin = (float3){minX, minY, minZ};
+        info->bBoxMax = (float3){maxX, maxY, maxZ};
         gLookAt += (info->bBoxMin + info->bBoxMax)*0.5f;
     }
     gLookAt = gLookAt / (float)size;
diff --git a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbotest.rs b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbotest.rs
index d44fd2b..05ef3ac 100644
--- a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbotest.rs
+++ b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbotest.rs
@@ -104,8 +104,8 @@
         rsgMeshComputeBoundingBox(info->mMesh,
                                   &minX, &minY, &minZ,
                                   &maxX, &maxY, &maxZ);
-        info->bBoxMin = (minX, minY, minZ);
-        info->bBoxMax = (maxX, maxY, maxZ);
+        info->bBoxMin = (float3){minX, minY, minZ};
+        info->bBoxMax = (float3){maxX, maxY, maxZ};
         gLookAt += (info->bBoxMin + info->bBoxMax)*0.5f;
     }
     gLookAt = gLookAt / (float)size;