Merge change I6cacaa0d into eclair

* changes:
  Hack to fix issue #2125365: Sports Trivia compatability with Eclair
diff --git a/api/current.xml b/api/current.xml
index 5efaed1..62078a7 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -24317,6 +24317,17 @@
  visibility="public"
 >
 </field>
+<field name="SUGGEST_PARAMETER_LIMIT"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;limit&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="SUGGEST_URI_PATH_QUERY"
  type="java.lang.String"
  transient="false"
@@ -113927,6 +113938,17 @@
  visibility="public"
 >
 </field>
+<field name="OFFICE_LOCATION"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;data9&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="PHONETIC_NAME"
  type="java.lang.String"
  transient="false"
@@ -115097,6 +115119,27 @@
  visibility="public"
 >
 </field>
+<field name="CONTENT_VCARD_TYPE"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;text/x-vcard&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="CONTENT_VCARD_URI"
+ type="android.net.Uri"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 </class>
 <class name="ContactsContract.Contacts.AggregationSuggestions"
  extends="java.lang.Object"
@@ -123201,6 +123244,23 @@
 <parameter name="b" type="java.lang.String">
 </parameter>
 </method>
+<method name="compare"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="a" type="java.lang.String">
+</parameter>
+<parameter name="b" type="java.lang.String">
+</parameter>
+</method>
 <method name="convertKeypadLettersToDigits"
  return="java.lang.String"
  abstract="false"
@@ -156959,6 +157019,17 @@
  visibility="public"
 >
 </method>
+<method name="isScrollbarFadingEnabled"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="isSelected"
  return="boolean"
  abstract="false"
diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java
index 9851750..ae33fad 100644
--- a/core/java/android/app/SearchManager.java
+++ b/core/java/android/app/SearchManager.java
@@ -1592,8 +1592,7 @@
 
     /**
      * Query parameter added to suggestion queries to limit the number of suggestions returned.
-     *
-     * @hide Pending API council approval
+     * This limit is only advisory and suggestion providers may chose to ignore it.
      */
     public final static String SUGGEST_PARAMETER_LIMIT = "limit";
 
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 27c65f0..3e117d4 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -195,7 +195,15 @@
         if ((flags&PackageManager.GET_ACTIVITIES) != 0) {
             int N = p.activities.size();
             if (N > 0) {
-                pi.activities = new ActivityInfo[N];
+                if ((flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
+                    pi.activities = new ActivityInfo[N];
+                } else {
+                    int num = 0;
+                    for (int i=0; i<N; i++) {
+                        if (p.activities.get(i).info.enabled) num++;
+                    }
+                    pi.activities = new ActivityInfo[num];
+                }
                 for (int i=0; i<N; i++) {
                     final Activity activity = p.activities.get(i);
                     if (activity.info.enabled
@@ -208,7 +216,15 @@
         if ((flags&PackageManager.GET_RECEIVERS) != 0) {
             int N = p.receivers.size();
             if (N > 0) {
-                pi.receivers = new ActivityInfo[N];
+                if ((flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
+                    pi.receivers = new ActivityInfo[N];
+                } else {
+                    int num = 0;
+                    for (int i=0; i<N; i++) {
+                        if (p.receivers.get(i).info.enabled) num++;
+                    }
+                    pi.receivers = new ActivityInfo[num];
+                }
                 for (int i=0; i<N; i++) {
                     final Activity activity = p.receivers.get(i);
                     if (activity.info.enabled
@@ -221,7 +237,15 @@
         if ((flags&PackageManager.GET_SERVICES) != 0) {
             int N = p.services.size();
             if (N > 0) {
-                pi.services = new ServiceInfo[N];
+                if ((flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
+                    pi.services = new ServiceInfo[N];
+                } else {
+                    int num = 0;
+                    for (int i=0; i<N; i++) {
+                        if (p.services.get(i).info.enabled) num++;
+                    }
+                    pi.services = new ServiceInfo[num];
+                }
                 for (int i=0; i<N; i++) {
                     final Service service = p.services.get(i);
                     if (service.info.enabled
@@ -234,7 +258,15 @@
         if ((flags&PackageManager.GET_PROVIDERS) != 0) {
             int N = p.providers.size();
             if (N > 0) {
-                pi.providers = new ProviderInfo[N];
+                if ((flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
+                    pi.providers = new ProviderInfo[N];
+                } else {
+                    int num = 0;
+                    for (int i=0; i<N; i++) {
+                        if (p.providers.get(i).info.enabled) num++;
+                    }
+                    pi.providers = new ProviderInfo[num];
+                }
                 for (int i=0; i<N; i++) {
                     final Provider provider = p.providers.get(i);
                     if (provider.info.enabled
diff --git a/core/java/android/pim/vcard/VCardComposer.java b/core/java/android/pim/vcard/VCardComposer.java
index e01bd3c..40b4fc4 100644
--- a/core/java/android/pim/vcard/VCardComposer.java
+++ b/core/java/android/pim/vcard/VCardComposer.java
@@ -23,6 +23,7 @@
 import android.content.Entity.NamedContentValues;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteException;
+import android.net.Uri;
 import android.os.RemoteException;
 import android.provider.CallLog;
 import android.provider.CallLog.Calls;
@@ -81,7 +82,7 @@
 public class VCardComposer {
     private static final String LOG_TAG = "vcard.VCardComposer";
 
-    private final static String DEFAULT_EMAIL_TYPE = Constants.ATTR_TYPE_INTERNET;
+    private static final String DEFAULT_EMAIL_TYPE = Constants.ATTR_TYPE_INTERNET;
 
     public static final String FAILURE_REASON_FAILED_TO_GET_DATABASE_INFO =
         "Failed to get database information";
@@ -94,6 +95,14 @@
 
     public static final String NO_ERROR = "No error";
 
+    private static final Uri sDataRequestUri;
+
+    static {
+        Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon();
+        builder.appendQueryParameter(Data.FOR_EXPORT_ONLY, "1");
+        sDataRequestUri = builder.build();
+    }
+
     public static interface OneEntryHandler {
         public boolean onInit(Context context);
 
@@ -116,7 +125,7 @@
         @SuppressWarnings("hiding")
         private static final String LOG_TAG = "vcard.VCardComposer.HandlerForOutputStream";
 
-        private OutputStream mOutputStream; // mWriter will close this.
+        final private OutputStream mOutputStream; // mWriter will close this.
         private Writer mWriter;
 
         private boolean mOnTerminateIsCalled = false;
@@ -301,8 +310,8 @@
 
     private boolean mIsCallLogComposer = false;
 
-    private static final String[] sRawContactsProjection = new String[] {
-        RawContacts._ID,
+    private static final String[] sContactsProjection = new String[] {
+        Contacts._ID,
     };
 
     /** The projection to use when querying the call log table */
@@ -442,7 +451,7 @@
             mCursor = mContentResolver.query(CallLog.Calls.CONTENT_URI, sCallLogProjection,
                     selection, selectionArgs, null);
         } else {
-            mCursor = mContentResolver.query(RawContacts.CONTENT_URI, sRawContactsProjection,
+            mCursor = mContentResolver.query(Contacts.CONTENT_URI, sContactsProjection,
                     selection, selectionArgs, null);
         }
 
@@ -451,7 +460,7 @@
             return false;
         }
 
-        if (mCursor.getCount() == 0 || !mCursor.moveToFirst()) {
+        if (getCount() == 0 || !mCursor.moveToFirst()) {
             try {
                 mCursor.close();
             } catch (SQLiteException e) {
@@ -604,23 +613,19 @@
     }
 
     private String createOneEntryInternal(final String contactId) {
-        final StringBuilder builder = new StringBuilder();
-        appendVCardLine(builder, VCARD_PROPERTY_BEGIN, VCARD_DATA_VCARD);
-        if (mIsV30) {
-            appendVCardLine(builder, VCARD_PROPERTY_VERSION, Constants.VERSION_V30);
-        } else {
-            appendVCardLine(builder, VCARD_PROPERTY_VERSION, Constants.VERSION_V21);
-        }
-
         final Map<String, List<ContentValues>> contentValuesListMap =
-            new HashMap<String, List<ContentValues>>();
-
-        final String selection = Data.RAW_CONTACT_ID + "=?";
+                new HashMap<String, List<ContentValues>>();
+        final String selection = Data.CONTACT_ID + "=?";
         final String[] selectionArgs = new String[] {contactId};
+        // The resolver may return the entity iterator with no data. It is possiible.
+        // e.g. If all the data in the contact of the given contact id are not exportable ones,
+        //      they are hidden from the view of this method, though contact id itself exists.
+        boolean dataExists = false;
         EntityIterator entityIterator = null;
         try {
             entityIterator = mContentResolver.queryEntities(
-                    RawContacts.CONTENT_URI, selection, selectionArgs, null);
+                    sDataRequestUri, selection, selectionArgs, null);
+            dataExists = entityIterator.hasNext();
             while (entityIterator.hasNext()) {
                 Entity entity = entityIterator.next();
                 for (NamedContentValues namedContentValues : entity
@@ -648,7 +653,18 @@
             }
         }
 
-        // TODO: consolidate order? (low priority)
+        if (!dataExists) {
+            return "";
+        }
+
+        final StringBuilder builder = new StringBuilder();
+        appendVCardLine(builder, VCARD_PROPERTY_BEGIN, VCARD_DATA_VCARD);
+        if (mIsV30) {
+            appendVCardLine(builder, VCARD_PROPERTY_VERSION, Constants.VERSION_V30);
+        } else {
+            appendVCardLine(builder, VCARD_PROPERTY_VERSION, Constants.VERSION_V21);
+        }
+
         appendStructuredNames(builder, contentValuesListMap);
         appendNickNames(builder, contentValuesListMap);
         appendPhones(builder, contentValuesListMap);
@@ -660,7 +676,7 @@
         appendOrganizations(builder, contentValuesListMap);
         appendPhotos(builder, contentValuesListMap);
         appendNotes(builder, contentValuesListMap);
-        // TODO: GroupMembership... What?
+        // TODO: GroupMembership
 
         if (mIsDoCoMo) {
             appendVCardLine(builder, VCARD_PROPERTY_X_CLASS, VCARD_DATA_PUBLIC);
diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java
index b54ad5d..7854423 100644
--- a/core/java/android/provider/CallLog.java
+++ b/core/java/android/provider/CallLog.java
@@ -16,16 +16,14 @@
 
 package android.provider;
 
+import com.android.internal.telephony.CallerInfo;
+import com.android.internal.telephony.Connection;
+
 import android.content.ContentResolver;
 import android.content.ContentValues;
 import android.content.Context;
 import android.net.Uri;
-import android.provider.Contacts.People;
-import com.android.internal.telephony.CallerInfo;
-import com.android.internal.telephony.Connection;
-
 import android.text.TextUtils;
-import android.util.Log;
 
 /**
  * The CallLog provider contains information about placed and received calls.
@@ -179,7 +177,7 @@
             }
             
             if ((ci != null) && (ci.person_id > 0)) {
-                People.markAsContacted(resolver, ci.person_id);
+                ContactsContract.Contacts.markAsContacted(resolver, ci.person_id);
             }
             
             Uri result = resolver.insert(CONTENT_URI, values);
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index c7bce0f..1b13f52 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -318,6 +318,17 @@
                 "lookup");
 
         /**
+         * Base {@link Uri} for referencing a single {@link Contacts} entry,
+         * created by appending {@link #LOOKUP_KEY} using
+         * {@link Uri#withAppendedPath(Uri, String)}. Provides
+         * {@link OpenableColumns} columns when queried, or returns the
+         * referenced contact formatted as a vCard when opened through
+         * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
+         */
+        public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
+                "as_vcard");
+
+        /**
          * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
          * requested {@link Contacts} entry.
          *
@@ -435,6 +446,12 @@
         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
 
         /**
+         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
+         * person.
+         */
+        public static final String CONTENT_VCARD_TYPE = "text/x-vcard";
+
+        /**
          * A sub-directory of a single contact that contains all of the constituent raw contact
          * {@link Data} rows.
          */
@@ -805,6 +822,22 @@
         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
 
         /**
+         * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
+         * Data.CONTENT_URI contains only exportable data.
+         *
+         * This flag is useful (currently) only for vCard exporter in Contacts app, which
+         * needs to exclude "un-exportable" data from available data to export, while
+         * Contacts app itself has priviledge to access all data including "un-expotable"
+         * ones and providers return all of them regardless of the callers' intention.
+         * <P>Type: INTEGER</p>
+         *
+         * @hide Maybe available only in Eclair and not really ready for public use.
+         * TODO: remove, or implement this feature completely. As of now (Eclair),
+         * we only use this flag in queryEntities(), not query().
+         */
+        public static final String FOR_EXPORT_ONLY = "for_export_only";
+
+        /**
          * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
          * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
          * entry of the given {@link Data} entry.
@@ -1617,6 +1650,12 @@
             public static final String PHONETIC_NAME = DATA8;
 
             /**
+             * The office location of this organization.
+             * <P>Type: TEXT</P>
+             */
+            public static final String OFFICE_LOCATION = DATA9;
+
+            /**
              * Return the string resource that best describes the given
              * {@link #TYPE}. Will always return a valid resource.
              */
diff --git a/core/java/android/provider/Im.java b/core/java/android/provider/Im.java
index d3e2820..025d5c2 100644
--- a/core/java/android/provider/Im.java
+++ b/core/java/android/provider/Im.java
@@ -540,7 +540,7 @@
          * The content:// style URL for contacts who have an open chat session
          */
         public static final Uri CONTENT_URI_CHAT_CONTACTS =
-            Uri.parse("content://com.google.android.providers.talk/contacts/chatting");
+            Uri.parse("content://com.google.android.providers.talk/contacts_chatting");
 
         /**
          * The content:// style URL for contacts who have been blocked
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index a39faae..ed32af2 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -5321,12 +5321,24 @@
         initScrollCache();
         final ScrollabilityCache scrollabilityCache = mScrollCache;
         scrollabilityCache.fadeScrollBars = fadeScrollbars;
-        if (!fadeScrollbars) {
+        if (fadeScrollbars) {
+            scrollabilityCache.state = ScrollabilityCache.OFF;
+        } else {
             scrollabilityCache.state = ScrollabilityCache.ON;
         }
     }
     
     /**
+     * 
+     * Returns true if scrollbars will fade when this view is not scrolling
+     * 
+     * @return true if scrollbar fading is enabled
+     */
+    public boolean isScrollbarFadingEnabled() {
+        return mScrollCache != null && mScrollCache.fadeScrollBars; 
+    }
+    
+    /**
      * <p>Specify the style of the scrollbars. The scrollbars can be overlaid or
      * inset. When inset, they add to the padding of the view. And the scrollbars
      * can be drawn inside the padding area or on the edge of the view. For example,
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 398abf8..dba2e04 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -1841,7 +1841,7 @@
             }
         } break;
         case DIE:
-            dispatchDetachedFromWindow();
+            doDie();
             break;
         case DISPATCH_KEY_FROM_IME: {
             if (LOCAL_LOGV) Log.v(
@@ -2520,6 +2520,14 @@
     }
 
     public void die(boolean immediate) {
+        if (immediate) {
+            doDie();
+        } else {
+            sendEmptyMessage(DIE);
+        }
+    }
+
+    void doDie() {
         checkThread();
         if (Config.LOGV) Log.v("ViewRoot", "DIE in " + this + " of " + mSurface);
         synchronized (this) {
@@ -2543,11 +2551,7 @@
             }
             if (mAdded) {
                 mAdded = false;
-                if (immediate) {
-                    dispatchDetachedFromWindow();
-                } else if (mView != null) {
-                    sendEmptyMessage(DIE);
-                }
+                dispatchDetachedFromWindow();
             }
         }
     }
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java
index d24a5ab..65ce158 100644
--- a/core/java/android/webkit/WebTextView.java
+++ b/core/java/android/webkit/WebTextView.java
@@ -813,4 +813,14 @@
     /* package */ void updateCachedTextfield() {
         mWebView.updateCachedTextfield(getText().toString());
     }
+
+    @Override
+    public boolean requestRectangleOnScreen(Rect rectangle) {
+        // don't scroll while in zoom animation. When it is done, we will adjust
+        // the WebTextView if it is in editing mode.
+        if (!mWebView.inAnimateZoom()) {
+            return super.requestRectangleOnScreen(rectangle);
+        }
+        return false;
+    }
 }
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 603f67a..8858b81 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -2814,6 +2814,10 @@
         }
     }
 
+    boolean inAnimateZoom() {
+        return mZoomScale != 0;
+    }
+
     /**
      * Need to adjust the WebTextView after a change in zoom, since mActualScale
      * has changed.  This is especially important for password fields, which are
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 8ef65db..6771711 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -143,7 +143,7 @@
                                     Intent.FLAG_ACTIVITY_NEW_TASK,
                                     Intent.FLAG_ACTIVITY_NEW_TASK, 0);
                         } catch (IntentSender.SendIntentException e) {
-                            throw new ActionException(e.toString());
+                            android.util.Log.e(LOG_TAG, "Cannot send pending intent: ", e);
                         }
                     }
                 };
diff --git a/core/java/com/android/internal/widget/ContactHeaderWidget.java b/core/java/com/android/internal/widget/ContactHeaderWidget.java
index d7311c2..0d25728 100644
--- a/core/java/com/android/internal/widget/ContactHeaderWidget.java
+++ b/core/java/com/android/internal/widget/ContactHeaderWidget.java
@@ -24,22 +24,26 @@
 import android.content.ContentUris;
 import android.content.ContentValues;
 import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Resources;
+import android.content.res.Resources.NotFoundException;
 import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
-import android.graphics.Rect;
 import android.net.Uri;
 import android.os.SystemClock;
 import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.Data;
 import android.provider.ContactsContract.PhoneLookup;
-import android.provider.ContactsContract.Presence;
 import android.provider.ContactsContract.RawContacts;
+import android.provider.ContactsContract.StatusUpdates;
 import android.provider.ContactsContract.CommonDataKinds.Email;
 import android.provider.ContactsContract.CommonDataKinds.Photo;
 import android.text.TextUtils;
 import android.text.format.DateUtils;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.CheckBox;
@@ -67,7 +71,7 @@
     private FasttrackBadgeWidget mPhotoView;
     private ImageView mPresenceView;
     private TextView mStatusView;
-    private TextView mStatusDateView;
+    private TextView mStatusAttributionView;
     private int mNoPhotoResource;
     private QueryHandler mQueryHandler;
 
@@ -99,6 +103,8 @@
             Contacts.CONTACT_PRESENCE,
             Contacts.CONTACT_STATUS,
             Contacts.CONTACT_STATUS_TIMESTAMP,
+            Contacts.CONTACT_STATUS_RES_PACKAGE,
+            Contacts.CONTACT_STATUS_LABEL,
         };
         int _ID = 0;
         int LOOKUP_KEY = 1;
@@ -110,6 +116,8 @@
         int CONTACT_PRESENCE_STATUS = 5;
         int CONTACT_STATUS = 6;
         int CONTACT_STATUS_TIMESTAMP = 7;
+        int CONTACT_STATUS_RES_PACKAGE = 8;
+        int CONTACT_STATUS_LABEL = 9;
     }
 
     //Projection used for looking up contact id from phone number
@@ -168,7 +176,7 @@
         mPresenceView = (ImageView) findViewById(R.id.presence);
 
         mStatusView = (TextView)findViewById(R.id.status);
-        mStatusDateView = (TextView)findViewById(R.id.status_date);
+        mStatusAttributionView = (TextView)findViewById(R.id.status_date);
 
         // Set the photo with a random "no contact" image
         long now = SystemClock.elapsedRealtime();
@@ -287,7 +295,7 @@
      * Manually set the presence.
      */
     public void setPresence(int presence) {
-        mPresenceView.setImageResource(Presence.getPresenceIconResourceId(presence));
+        mPresenceView.setImageResource(StatusUpdates.getPresenceIconResourceId(presence));
     }
 
     /**
@@ -345,6 +353,7 @@
      */
     public void setExcludeMimes(String[] excludeMimes) {
         mExcludeMimes = excludeMimes;
+        mPhotoView.setExcludeMimes(excludeMimes);
     }
 
     /**
@@ -431,7 +440,7 @@
         //Set the presence status
         if (!c.isNull(ContactQuery.CONTACT_PRESENCE_STATUS)) {
             int presence = c.getInt(ContactQuery.CONTACT_PRESENCE_STATUS);
-            mPresenceView.setImageResource(Presence.getPresenceIconResourceId(presence));
+            mPresenceView.setImageResource(StatusUpdates.getPresenceIconResourceId(presence));
             mPresenceView.setVisibility(View.VISIBLE);
         } else {
             mPresenceView.setVisibility(View.GONE);
@@ -443,6 +452,8 @@
             mStatusView.setText(status);
             mStatusView.setVisibility(View.VISIBLE);
 
+            CharSequence timestamp = null;
+
             if (!c.isNull(ContactQuery.CONTACT_STATUS_TIMESTAMP)) {
                 long date = c.getLong(ContactQuery.CONTACT_STATUS_TIMESTAMP);
 
@@ -450,18 +461,63 @@
                 // times.
                 int flags = DateUtils.FORMAT_ABBREV_RELATIVE;
 
-                mStatusDateView.setText(DateUtils.getRelativeTimeSpanString(date, System
-                        .currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, flags));
-                mStatusDateView.setVisibility(View.VISIBLE);
+                timestamp = DateUtils.getRelativeTimeSpanString(date,
+                        System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, flags);
+            }
+
+            String label = null;
+
+            if (!c.isNull(ContactQuery.CONTACT_STATUS_LABEL)) {
+                String resPackage = c.getString(ContactQuery.CONTACT_STATUS_RES_PACKAGE);
+                int labelResource = c.getInt(ContactQuery.CONTACT_STATUS_LABEL);
+                Resources resources;
+                if (TextUtils.isEmpty(resPackage)) {
+                    resources = getResources();
+                } else {
+                    PackageManager pm = getContext().getPackageManager();
+                    try {
+                        resources = pm.getResourcesForApplication(resPackage);
+                    } catch (NameNotFoundException e) {
+                        Log.w(TAG, "Contact status update resource package not found: "
+                                + resPackage);
+                        resources = null;
+                    }
+                }
+
+                if (resources != null) {
+                    try {
+                        label = resources.getString(labelResource);
+                    } catch (NotFoundException e) {
+                        Log.w(TAG, "Contact status update resource not found: " + resPackage + "@"
+                                + labelResource);
+                    }
+                }
+            }
+
+            CharSequence attribution;
+            if (timestamp != null && label != null) {
+                attribution = getContext().getString(
+                        R.string.contact_status_update_attribution_with_date,
+                        timestamp, label);
+            } else if (timestamp == null && label != null) {
+                attribution = getContext().getString(
+                        R.string.contact_status_update_attribution,
+                        label);
+            } else if (timestamp != null) {
+                attribution = timestamp;
             } else {
-                mStatusDateView.setVisibility(View.GONE);
+                attribution = null;
+            }
+            if (attribution != null) {
+                mStatusAttributionView.setText(attribution);
+                mStatusAttributionView.setVisibility(View.VISIBLE);
+            } else {
+                mStatusAttributionView.setVisibility(View.GONE);
             }
         } else {
             mStatusView.setVisibility(View.GONE);
-            mStatusDateView.setVisibility(View.GONE);
+            mStatusAttributionView.setVisibility(View.GONE);
         }
-
-        // TODO add support for status update source, e.g. "via Google Talk"
     }
 
     public void onClick(View view) {
diff --git a/core/res/res/drawable-hdpi/tab_selected.9.png b/core/res/res/drawable-hdpi/tab_selected.9.png
index 29d45a17..f036b9a 100644
--- a/core/res/res/drawable-hdpi/tab_selected.9.png
+++ b/core/res/res/drawable-hdpi/tab_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/tab_selected_v4.9.png b/core/res/res/drawable-hdpi/tab_selected_v4.9.png
index 77d0f344..50fcb52 100644
--- a/core/res/res/drawable-hdpi/tab_selected_v4.9.png
+++ b/core/res/res/drawable-hdpi/tab_selected_v4.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/tab_unselected.9.png b/core/res/res/drawable-hdpi/tab_unselected.9.png
index f5781ab..c3a1f30 100644
--- a/core/res/res/drawable-hdpi/tab_unselected.9.png
+++ b/core/res/res/drawable-hdpi/tab_unselected.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/tab_unselected_v4.9.png b/core/res/res/drawable-hdpi/tab_unselected_v4.9.png
index 43b1ee5..c56254c 100644
--- a/core/res/res/drawable-hdpi/tab_unselected_v4.9.png
+++ b/core/res/res/drawable-hdpi/tab_unselected_v4.9.png
Binary files differ
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 2a55d85..7f97bd1 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1299,6 +1299,12 @@
     <string name="orgTypeOther">Other</string>
     <!-- Custom organization type -->
     <string name="orgTypeCustom">Custom</string>
+    
+    <!-- Attbution of a contact status update, when the time of update is unknown -->
+    <string name="contact_status_update_attribution">Via <xliff:g id="source" example="Google Talk">%1$s</xliff:g></string>
+
+    <!-- Attbution of a contact status update, when the time of update is known -->
+    <string name="contact_status_update_attribution_with_date"><xliff:g id="date" example="3 hours ago">%1$s</xliff:g> via <xliff:g id="source" example="Google Talk">%2$s</xliff:g></string>
 
     <!-- Instructions telling the user to enter their pin to unlock the keyguard.
          Displayed in one line in a large font.  -->
@@ -2082,5 +2088,4 @@
 
     <!-- Do Not Translate: Alternate eri.xml -->
     <string name="alternate_eri_file">/data/eri.xml</string>
-
 </resources>
diff --git a/docs/html/sdk/ndk/1.6_r1/index.jd b/docs/html/sdk/ndk/1.6_r1/index.jd
new file mode 100644
index 0000000..e066f95
--- /dev/null
+++ b/docs/html/sdk/ndk/1.6_r1/index.jd
@@ -0,0 +1,360 @@
+ndk=true
+ndk.version=1.6
+ndk.rel.id=1
+ndk.date=September 2009
+
+ndk.win_download=android-ndk-1.6_r1-windows.zip
+ndk.win_bytes=25896444
+ndk.win_checksum=a213c9592f24c61620755c6c43f85210
+
+ndk.mac_download=android-ndk-1.6_r1-darwin-x86.zip
+ndk.mac_bytes=20611080
+ndk.mac_checksum=93c5b8b92a1f7b1cdadf267cab8ec403
+
+ndk.linux_download=android-ndk-1.6_r1-linux-x86.zip
+ndk.linux_bytes=19421662
+ndk.linux_checksum=464d3dc02739b82917e6f0591e17edd1
+
+page.title=Android 1.6 NDK, Release 1
+@jd:body
+
+<h2 id="overview">What is the Android NDK?</h2>
+
+<p>The Android NDK provides tools that allow Android application developers
+to embed components that make use of native code in their Android applications.
+</p>
+
+<p>Android applications run in the Dalvik virtual machine. The NDK allows 
+developers to implement parts of their applications using native-code languages 
+such as C and C++. This can provide benefits to certain classes of applications, 
+in the form of reuse of existing code and in some cases increased speed.</p>
+
+<p>The NDK provides:</p>
+
+<ul>
+<li>A set of tools and build files used to generate native code libraries from C
+and C++ sources</li>
+<li>A way to embed the corresponding native libraries into application package
+files (.apks) that can be deployed on Android devices</li>
+<li>A set of native system headers and libraries that will be supported in all
+future versions of the Android platform, starting from Android 1.5 </li>
+<li>Documentation, samples, and tutorials</li>
+</ul>
+
+<p>This release of the NDK supports the ARMv5TE machine instruction set
+and provides stable headers for libc (the C library), libm (the Math library), 
+OpenGL ES 1.1 (3D graphics library), the JNI interface, and other libraries.</p>
+
+<p>The NDK will not benefit most applications. As a developer, you will need 
+to balance its benefits against its drawbacks; notably, using native code does 
+not result in an automatic performance increase, but does always increase 
+application complexity. Typical good candidates for the NDK are self-contained,
+CPU-intensive operations that don't allocate much memory, such as signal processing,
+physics simulation, and so on. Simply re-coding a method to run in C usually does 
+not result in a large performance increase. The NDK can, however, can be 
+an effective way to reuse a large corpus of existing C/C++ code.</p>
+
+<p>Please note that the NDK <em>does not</em> enable you to develop native-only
+applications. Android's primary runtime remains the Dalvik virtual machine.</p>
+
+<h2 id="contents">Contents of the NDK</h2>
+
+<h4>Development tools</h4>
+
+<p>The NDK includes a set of cross-toolchains (compilers, linkers, etc..) that
+can generate native ARM binaries on Linux, OS X, and Windows (with Cygwin)
+platforms.</p>
+
+<p>It provides a set of system headers for stable native APIs that are
+guaranteed to be supported in all later releases of the platform:</p>
+
+<ul>
+<li>libc (C library) headers</li>
+<li>libm (math library) headers</li>
+<li>JNI interface headers</li>
+<li>libz (Zlib compression) headers</li>
+<li>liblog (Android logging) header</li>
+<li>OpenGL ES 1.1 (3D graphics library) headers</li>
+<li>A Minimal set of headers for C++ support</li>
+</ul>
+
+<p>The NDK also provides a build system that lets you work efficiently with your
+sources, without having to handle the toolchain/platform/CPU/ABI details. You
+create very short build files to describe which sources to compile and which
+Android application will use them &mdash; the build system compiles the sources
+and places the shared libraries directly in your application project. </p>
+
+<p class="caution"><strong>Important:</strong> With the exception of the
+libraries listed above, native system libraries in the Android platform are
+<em>not</em> stable and may change in future platform versions.
+Your applications should <em>only</em> make use of the stable native system
+libraries provided in this NDK. </p>
+
+<h4>Documentation</h4>
+
+<p>The NDK package includes a set of documentation that describes the
+capabilities of the NDK and how to use it to create shared libraries for your
+Android applications. In this release, the documentation is provided only in the
+downloadable NDK package. You can find the documentation in the
+<code>&lt;ndk&gt;/docs/</code> directory. Included are these files:</p>
+
+<ul>
+<li>INSTALL.TXT &mdash; describes how to install the NDK and configure it for
+your host system</li>
+<li>OVERVIEW.TXT &mdash; provides an overview of the NDK capabilities and
+usage</li>
+<li>ANDROID-MK.TXT &mdash; describes the use of the Android.mk file, which
+defines the native sources you want to compile</li>
+<li>APPLICATION-MK.TXT &mdash; describes the use of the Application.mk file,
+which describes the native sources required by your Android application</li>
+<li>HOWTO.TXT &mdash; information about common tasks associated with NDK 
+development.</li>
+<li>SYSTEM-ISSUES.TXT &mdash; known issues in the Android system images 
+that you should be aware of, if you are developing using the NDK. </li>
+<li>STABLE-APIS.TXT &mdash; a complete list of the stable APIs exposed
+by headers in the NDK.</li>
+<li>CHANGES.TXT &mdash; a complete list of changes to the NDK across all 
+releases.</li>
+</ul>
+
+<p>Additionally, the package includes detailed information about the "bionic"
+C library provided with the Android platform that you should be aware of, if you
+are developing using the NDK. You can find the documentation in the 
+<code>&lt;ndk&gt;/docs/system/libc/</code> directory:</p>
+
+<ul>
+<li>OVERVIEW.TXT &mdash; provides an overview of the "bionic" C library and the 
+features it offers.</li>
+</ul>
+
+<h4>Sample applications</h4>
+
+<p>The NDK includes three sample Android applications that illustrate how to use
+native code in your Android applications:</p>
+
+<ul>
+<li><code>hello-jni</code> &mdash; A simple application that loads a string from
+a native method implemented in a shared library and then displays it in the
+application UI. </li>
+<li><code>two-libs</code> &mdash; A simple application that loads a shared
+library dynamically and calls a native method provided by the library. In this
+case, the method is implemented in a static library that is imported by the 
+shared library. </li>
+<li><code>san-angeles</code> &mdash; A simple application that renders 3D 
+graphics through the native OpenGL ES APIs, while managing activity lifecycle 
+with a {@link android.opengl.GLSurfaceView GLSurfaceView} object. </li>
+</ul>
+
+<p>For more information, see <a href="#samples">Using the Sample
+Applications</a>.</p>
+
+<h2 id="requirements">System and Software Requirements</h2>
+
+<p>The sections below describe the system and software requirements for using
+the Android NDK, as well as platform compatibility considerations that affect
+appplications using libraries produced with the NDK. </p>
+
+<h4>The Android SDK</h4>
+<ul>
+  <li>A complete Android SDK installation (including all dependencies) is
+required.</li>
+  <li>Android 1.5 SDK or later version is required.</li>
+</ul>
+
+<h4>Supported operating systems</h4>
+<ul>
+  <li>Windows XP (32-bit) or Vista (32- or 64-bit)</li>
+  <li>Mac OS X 10.4.8 or later (x86 only)</li>
+  <li>Linux (32- or 64-bit, tested on Linux Ubuntu Dapper Drake)</li>
+</ul>
+
+<h4>Required development tools</h4>
+<ul>
+  <li>For all development platforms, GNU Make 3.81 or later is required. Earlier
+versions of GNU Make might work but have not been tested.</li>
+  <li>For Windows, a recent release of <a
+href="http://www.cygwin.com">Cygwin</a> is required. </li>
+</ul>
+
+<h4>Android platform compatibility</h4>
+<ul>
+  <li>The native libraries created by the Android NDK can only be used on
+devices running the Android 1.5 platform version or later. This is due to 
+toolchain and ABI related changes that make the native libraries incompatible
+with 1.0 and 1.1 system images.</li>
+  <li>For this reason, you should use native libraries produced with the NDK in
+applications that are deployable to devices running the Android 1.5 platform
+version or later. 
+  <li>To ensure compatibility, an application using a native library
+produced with the NDK <em>must</em> declare a <code>&lt;uses-library&gt;</code> 
+element in its manifest file, with an <code>android:minSdkVersion</code> attribute 
+value of "3" or higher. For example:
+
+<pre>&lt;manifest&gt;
+  ...
+  &lt;uses-sdk android:minSdkVersion="3" /&gt;
+  ...
+&lt;/manifest&gt;</pre>
+
+<p>Additionally, if you use this NDK to create a native library that uses the
+OpenGL ES APIs, the application containing the library can be deployed only to
+devices running Android 1.6 or later. To ensure compatibility in this case, 
+the application <em>must</em> declare an <code>android:minSdkVersion</code>
+attribute value of "4" or higher. </p>
+
+<p>For more information about API Level and its relationship to Android 
+platform versions, see <a href="{@docRoot}guide/appendix/api-levels.html">
+Android API Levels</a>.</p></li>
+</ul>
+
+<h2 id="installing">Installing the NDK</h2>
+
+<p>Installing the NDK on your development computer is straightforward and
+involves extracting the NDK from its download package and running a host-setup
+script. </p>
+
+<p>Before you get started make sure that you have downloaded the latest <a
+href="{@docRoot}sdk/index.html">Android SDK</a> and upgraded your applications
+and environment as needed. The NDK will not work with older versions of the
+Android SDK. Also, take a moment to review the <a href="#requirements">System
+and Software Requirements</a> for the NDK, if you haven't already. </p>
+
+<p>To install the NDK, follow these steps:</p>
+
+<ol>
+<li>From the table at the top of this page, select the NDK package that is
+appropriate for your development computer and download the package.</li>
+<li>Uncompress the NDK download package using tools available on your computer.
+When uncompressed, the NDK files are contained in a directory called
+<code>android-ndk-&lt;version&gt;</code>. You can rename the NDK directory if
+necessary and you can move it to any location on your computer. This
+documentation refers to the NDK directory as <code>&lt;ndk&gt;</code>.  </li>
+<li>Open a terminal, change to the NDK directory, and run the host-setup script.
+The script sets up your environment and generates a host configuration file used
+later, when building your shared libraries. The path to the host-setup script
+is:
+
+<p><code>&lt;ndk&gt;/build/host-setup.sh</code></p>
+
+<p>If the script completes successfully, it prints a "Host setup complete."
+message. If it fails, it prints instructions that you can follow to correct any
+problems. </p>
+</li>
+</ol>
+
+<p>Once you have run the host-setup script, you are ready start working with the
+NDK. </p>
+
+<h2 id="gettingstarted">Getting Started with the NDK</h2>
+
+<p>Once you've installed the NDK successfully, take a few minutes to read the
+documentation included in the NDK. You can find the documentation in the
+<code>&lt;ndk&gt;/docs/</code> directory. In particular, please read the
+OVERVIEW.TXT document completely, so that you understand the intent of the NDK
+and how to use it.</p>
+
+<p>If you used a previous version of the NDK, take a moment to review the 
+list of NDK changes in the CHANGES.TXT document. </p>
+
+<p>Here's the general outline of how you work with the NDK tools:</p>
+
+<ol>
+<li>Place your native sources under
+<code>&lt;project&gt;/jni/...</code></li>
+<li>Create <code>&lt;project&gt;/jni/Android.mk</code> to
+describe your native sources to the NDK build system</li>
+<li>Create <code>&lt;ndk&gt;/apps/&lt;my_app&gt;/Application.mk</code> to
+describe your Android application and native sources it needs to the NDK build
+system. This file sets up the link between an Android SDK application project
+and any number of shared libraries defined in the
+<code>&lt;project&gt;/jni/</code> folder and it specifies the path to the
+application project that will receive the shared library built from the
+sources.</li>
+<li>Build your native code by running this make command from the top-level NDK
+directory:
+
+<p><code>$ make APP=&lt;my_app&gt;</code></p>
+
+<p>The build tools copy the stripped, shared libraries needed by your
+application to the proper location in the application's project directory.</p>
+</li>
+
+<li>Finally, compile your application using the SDK tools in the usual way. The
+SDK build tools will package the shared libraries in the application's
+deployable .apk file. </p></li>
+
+</ol>
+
+<p>For complete information on all of the steps listed above, please see the
+documentation included with the NDK package. </p>
+
+
+<h2 id="samples">Using the Sample Applications</h2>
+
+<p>The NDK includes three sample applications that illustrate how to use native
+code in your Android applications:</p>
+
+<ul>
+<li><code>hello-jni</code> &mdash; A simple application that loads a string from
+a native method implemented in a shared library and then displays it in the
+application UI. </li>
+<li><code>two-libs</code> &mdash; A simple application that loads a shared
+library dynamically and calls a native method provided by the library. In this
+case, the method is implemented in a static library imported by the shared
+library. </li>
+<li><code>san-angeles</code> &mdash; A simple application that renders 3D 
+graphics through the native OpenGL ES APIs, while managing activity lifecycle 
+with a {@link android.opengl.GLSurfaceView GLSurfaceView} object. </li>
+</ul>
+
+<p>For each sample, the NDK includes an Android application project, as well as
+the corresponding C source code and the necessary Android.mk and Application.mk
+files. The application projects are provided in
+<code>&lt;ndk&gt;/apps/&lt;app_name&gt;/project/</code> and the C source for
+each application is provided in
+<code>&lt;ndk&gt;/apps/&lt;app_name&gt;/project/jni/</code>.</p>
+
+<p>Once you have installed the NDK, you can build the shared libraries from the
+NDK by using these commands from the root of the NDK directory:</p>
+<ul>
+<li><code>$ make APP=hello-jni</code> &mdash; compiles
+<code>&lt;ndk&gt;/apps/hello-jni/project/jni/hello-jni.c</code> and outputs a
+shared library to
+<code>&lt;ndk&gt;/apps/hello-jni/project/libs/armeabi/libhello-jni.so</code>.
+</li>
+<li><code>$ make APP=two-libs</code> &mdash; compiles
+<code>&lt;ndk&gt;/apps/two-libs/project/jni/second.c</code> and
+<code>first.c</code> and outputs a shared library to
+<code>&lt;ndk&gt;/apps/two-libs/project/libs/armeabi/libtwolib-second.so</code>.
+</li>
+</ul>
+
+<p>Next, build the sample Android applications that use the shared
+libraries:</p>
+
+<ul>
+<li>If you are developing in Eclipse with ADT, use the New Project Wizard to
+create a new Android project for each sample, using the "Import from Existing
+Source" option and importing the source from 
+<code>&lt;ndk&gt;/apps/&lt;app_name&gt;/project/</code>. Then, set up an AVD, if
+necessary, and build/run the application in the emulator. For more information
+about creating a new Android project in Eclipse, see <a
+href="{@docRoot}guide/developing/eclipse-adt.html">Developing in
+Eclipse</a>.</li>
+<li>If you are developing with Ant, use the <code>android</code> tool to create
+the build file for each of the sample projects at
+<code>&lt;ndk&gt;/apps/&lt;app_name&gt;/project/</code>. Then set up an AVD, if
+necessary, build your project in the usual way, and run it in the emulator. 
+For more information, see <a
+href="{@docRoot}guide/developing/other-ide.html">Developing in Other
+IDEs</a>.</li>
+</ul>
+
+<h2>Discussion Forum and Mailing List</h2>
+
+<p>If you have questions about the NDK or would like to read or contribute to
+discussions about it, please visit the <a
+href="http://groups.google.com/group/android-ndk">android-ndk</a> group and 
+mailing list.</p>
+
+
diff --git a/docs/html/sdk/sdk_toc.cs b/docs/html/sdk/sdk_toc.cs
index b8116aa..143a38d 100644
--- a/docs/html/sdk/sdk_toc.cs
+++ b/docs/html/sdk/sdk_toc.cs
@@ -82,7 +82,7 @@
   <li>
     <h2>Native Development Tools</h2>
     <ul>
-      <li><a href="<?cs var:toroot ?>sdk/ndk/1.5_r1/index.html">Android 1.5 NDK, r1</a></li>
+      <li><a href="<?cs var:toroot ?>sdk/ndk/1.6_r1/index.html">Android 1.6 NDK, r1</a></li>
     </ul>
   </li>
   <li>
diff --git a/docs/html/sdk/terms.jd b/docs/html/sdk/terms.jd
index ffc574a..614a438 100644
--- a/docs/html/sdk/terms.jd
+++ b/docs/html/sdk/terms.jd
@@ -1,6 +1,4 @@
 page.title=Terms and Conditions
-sdk.version=1.6
-sdk.preview=true
 hide_license_footer=true
 @jd:body
 
diff --git a/graphics/java/android/renderscript/BaseObj.java b/graphics/java/android/renderscript/BaseObj.java
index c626d5d..e802ec5 100644
--- a/graphics/java/android/renderscript/BaseObj.java
+++ b/graphics/java/android/renderscript/BaseObj.java
@@ -66,8 +66,8 @@
             mRS = null;
             mID = 0;
             mDestroyed = true;
-            Log.v(RenderScript.LOG_TAG,
-                  getClass() + " auto finalizing object without having released the RS reference.");
+            //Log.v(RenderScript.LOG_TAG, getClass() +
+            // " auto finalizing object without having released the RS reference.");
         }
         super.finalize();
     }
diff --git a/keystore/tests/Android.mk b/keystore/tests/Android.mk
new file mode 100644
index 0000000..95604c6
--- /dev/null
+++ b/keystore/tests/Android.mk
@@ -0,0 +1,15 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+# We only want this apk build for tests.
+LOCAL_MODULE_TAGS := tests
+LOCAL_CERTIFICATE := platform
+
+LOCAL_JAVA_LIBRARIES := android.test.runner
+
+# Include all test java files.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := KeyStoreTests
+
+include $(BUILD_PACKAGE)
diff --git a/keystore/tests/AndroidManifest.xml b/keystore/tests/AndroidManifest.xml
new file mode 100644
index 0000000..1a5f065
--- /dev/null
+++ b/keystore/tests/AndroidManifest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="android.security.tests"
+          android:sharedUserId="android.uid.system">
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation android:name=".KeyStoreTestRunner"
+        android:targetPackage="android.security.tests"
+        android:label="KeyStore Tests">
+    </instrumentation>
+</manifest>
diff --git a/keystore/tests/src/android/security/KeyStoreTest.java b/keystore/tests/src/android/security/KeyStoreTest.java
new file mode 100755
index 0000000..569d8da
--- /dev/null
+++ b/keystore/tests/src/android/security/KeyStoreTest.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.tests;
+
+import android.app.Activity;
+import android.security.KeyStore;
+import android.test.ActivityUnitTestCase;
+import android.test.suitebuilder.annotation.MediumTest;
+
+/**
+ * Junit / Instrumentation test case for KeyStore class
+ *
+ * Running the test suite:
+ *
+ *  adb shell am instrument -w android.security.tests/.KeyStoreTestRunner
+ */
+@MediumTest
+public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
+    private static final String TEST_PASSWD = "12345678";
+    private static final String TEST_EMPTY_PASSWD = "";
+    private static final String TEST_SHORT_PASSWD = "short";
+    private static final String TEST_PASSWD2 = "87654321";
+    private static final String TEST_KEYNAME = "testkey";
+    private static final String TEST_KEYNAME1 = "testkey1";
+    private static final String TEST_KEYNAME2 = "testkey2";
+    private static final String TEST_KEYVALUE = "test value";
+
+    private KeyStore mKeyStore = null;
+
+    public KeyStoreTest() {
+        super(Activity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        mKeyStore = KeyStore.getInstance();
+        if (mKeyStore.test() != KeyStore.UNINITIALIZED) mKeyStore.reset();
+        assertEquals(KeyStore.UNINITIALIZED, mKeyStore.test());
+        super.setUp();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        mKeyStore.reset();
+        super.tearDown();
+    }
+
+    public void testTest() throws Exception {
+        assertEquals(KeyStore.UNINITIALIZED, mKeyStore.test());
+    }
+
+    public void testPassword() throws Exception {
+        //assertFalse(mKeyStore.password(TEST_EMPTY_PASSWD));
+        //assertFalse(mKeyStore.password(TEST_SHORT_PASSWD));
+
+        assertTrue(mKeyStore.password(TEST_PASSWD));
+        assertEquals(KeyStore.NO_ERROR, mKeyStore.test());
+
+        assertFalse(mKeyStore.password(TEST_PASSWD2, TEST_PASSWD2));
+        //assertFalse(mKeyStore.password(TEST_PASSWD, TEST_SHORT_PASSWD));
+
+        assertTrue(mKeyStore.password(TEST_PASSWD, TEST_PASSWD2));
+    }
+
+    public void testPut() throws Exception {
+        assertFalse(mKeyStore.put(TEST_KEYNAME, TEST_KEYVALUE));
+        assertFalse(mKeyStore.contains(TEST_KEYNAME));
+        mKeyStore.password(TEST_PASSWD);
+        assertTrue(mKeyStore.put(TEST_KEYNAME, TEST_KEYVALUE));
+    }
+
+    public void testDelete() throws Exception {
+        assertTrue(mKeyStore.delete(TEST_KEYNAME));
+        mKeyStore.password(TEST_PASSWD);
+        assertTrue(mKeyStore.delete(TEST_KEYNAME));
+
+        mKeyStore.put(TEST_KEYNAME, TEST_KEYVALUE);
+        assertTrue(mKeyStore.delete(TEST_KEYNAME));
+    }
+
+    public void testContains() throws Exception {
+        assertFalse(mKeyStore.contains(TEST_KEYNAME));
+
+        mKeyStore.password(TEST_PASSWD);
+        assertFalse(mKeyStore.contains(TEST_KEYNAME));
+
+        mKeyStore.put(TEST_KEYNAME, TEST_KEYVALUE);
+        assertTrue(mKeyStore.contains(TEST_KEYNAME));
+    }
+
+    public void testSaw() throws Exception {
+        String[] results = mKeyStore.saw(TEST_KEYNAME);
+        assertEquals(0, results.length);
+
+        mKeyStore.password(TEST_PASSWD);
+        mKeyStore.put(TEST_KEYNAME1, TEST_KEYVALUE);
+        mKeyStore.put(TEST_KEYNAME2, TEST_KEYVALUE);
+
+        results = mKeyStore.saw(TEST_KEYNAME);
+        assertEquals(2, results.length);
+    }
+
+    public void testLock() throws Exception {
+        assertFalse(mKeyStore.lock());
+
+        mKeyStore.password(TEST_PASSWD);
+        assertEquals(KeyStore.NO_ERROR, mKeyStore.test());
+
+        assertTrue(mKeyStore.lock());
+        assertEquals(KeyStore.LOCKED, mKeyStore.test());
+    }
+
+    public void testUnlock() throws Exception {
+        mKeyStore.password(TEST_PASSWD);
+        assertEquals(KeyStore.NO_ERROR, mKeyStore.test());
+        mKeyStore.lock();
+
+        assertFalse(mKeyStore.unlock(TEST_PASSWD2));
+        assertTrue(mKeyStore.unlock(TEST_PASSWD));
+    }
+}
diff --git a/keystore/tests/src/android/security/KeyStoreTestRunner.java b/keystore/tests/src/android/security/KeyStoreTestRunner.java
new file mode 100644
index 0000000..c85922d
--- /dev/null
+++ b/keystore/tests/src/android/security/KeyStoreTestRunner.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.tests;
+
+import junit.framework.TestSuite;
+
+import android.test.InstrumentationTestRunner;
+import android.test.InstrumentationTestSuite;
+
+/**
+ * Instrumentation Test Runner for all KeyStore unit tests.
+ *
+ * Running all tests:
+ *
+ *   runtest keystore-unit
+ * or
+ *   adb shell am instrument -w android.security.tests/.KeyStoreTestRunner
+ */
+
+public class KeyStoreTestRunner extends InstrumentationTestRunner {
+
+    @Override
+    public TestSuite getAllTests() {
+        TestSuite suite = new InstrumentationTestSuite(this);
+        suite.addTestSuite(android.security.tests.KeyStoreTest.class);
+        return suite;
+    }
+
+    @Override
+    public ClassLoader getLoader() {
+        return KeyStoreTestRunner.class.getClassLoader();
+    }
+}
diff --git a/libs/rs/java/Film/res/raw/filmimage.c b/libs/rs/java/Film/res/raw/filmimage.c
index 3bd9496..d154c68 100644
--- a/libs/rs/java/Film/res/raw/filmimage.c
+++ b/libs/rs/java/Film/res/raw/filmimage.c
@@ -4,7 +4,7 @@
 #pragma stateVertex(orthoWindow)
 #pragma stateRaster(flat)
 #pragma stateFragment(PgmFragBackground)
-#pragma stateFragmentStore(MyBlend)
+#pragma stateStore(MyBlend)
 
 
 int main(void* con, int ft, int launchID) {
diff --git a/libs/rs/java/Film/res/raw/filmstrip.c b/libs/rs/java/Film/res/raw/filmstrip.c
index 8fbfee1..bf75675 100644
--- a/libs/rs/java/Film/res/raw/filmstrip.c
+++ b/libs/rs/java/Film/res/raw/filmstrip.c
@@ -3,7 +3,7 @@
 #pragma version(1)
 #pragma stateVertex(PVBackground)
 #pragma stateFragment(PFBackground)
-#pragma stateFragmentStore(PSBackground)
+#pragma stateStore(PSBackground)
 
 #define STATE_TRIANGLE_OFFSET_COUNT 0
 #define STATE_LAST_FOCUS 1
@@ -33,7 +33,7 @@
     drawSimpleMesh(NAMED_mesh);
 
     // Start of images.
-    bindProgramFragmentStore(NAMED_PSImages);
+    bindProgramStore(NAMED_PSImages);
     bindProgramFragment(NAMED_PFImages);
     bindProgramVertex(NAMED_PVImages);
 
diff --git a/libs/rs/java/Fountain/res/raw/fountain.c b/libs/rs/java/Fountain/res/raw/fountain.c
index 86f0f99..f218f9b 100644
--- a/libs/rs/java/Fountain/res/raw/fountain.c
+++ b/libs/rs/java/Fountain/res/raw/fountain.c
@@ -1,8 +1,5 @@
 // Fountain test script
 #pragma version(1)
-#pragma stateVertex(default)
-#pragma stateFragment(default)
-#pragma stateFragmentStore(default)
 
 int newPart = 0;
 
diff --git a/libs/rs/java/Rollo/res/raw/rollo.c b/libs/rs/java/Rollo/res/raw/rollo.c
index 6376715..b31be81 100644
--- a/libs/rs/java/Rollo/res/raw/rollo.c
+++ b/libs/rs/java/Rollo/res/raw/rollo.c
@@ -1,7 +1,7 @@
 #pragma version(1)
 #pragma stateVertex(PV)
 #pragma stateFragment(PF)
-#pragma stateFragmentStore(PFS)
+#pragma stateStore(PFS)
 
 // Scratch buffer layout
 #define SCRATCH_FADE 0
@@ -105,7 +105,7 @@
     if ((zoom < 1.1f) && (zoom > 0.9f)) {
         bindProgramVertex(NAMED_PVOrtho);
         bindProgramFragment(NAMED_PFText);
-        bindProgramFragmentStore(NAMED_PFSText);
+        bindProgramStore(NAMED_PFSText);
 
         rot = drawRot * scale;
         index = 0;
@@ -144,7 +144,7 @@
 
         bindProgramVertex(NAMED_PV);
         bindProgramFragment(NAMED_PF);
-        bindProgramFragmentStore(NAMED_PFS);
+        bindProgramStore(NAMED_PFS);
     }
 
     // Draw the selected icon
diff --git a/libs/rs/java/Rollo/res/raw/rollo2.c b/libs/rs/java/Rollo/res/raw/rollo2.c
index 256fa3c..5b5cb2d 100644
--- a/libs/rs/java/Rollo/res/raw/rollo2.c
+++ b/libs/rs/java/Rollo/res/raw/rollo2.c
@@ -1,7 +1,7 @@
 #pragma version(1)
 #pragma stateVertex(PV)
 #pragma stateFragment(PF)
-#pragma stateFragmentStore(PFS)
+#pragma stateStore(PFS)
 
 // Scratch buffer layout
 #define SCRATCH_FADE 0
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 70add92..169d5d4 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -103,12 +103,14 @@
     ObjectBaseRef<ProgramFragment> frag(mFragment);
     ObjectBaseRef<ProgramVertex> vtx(mVertex);
     ObjectBaseRef<ProgramFragmentStore> store(mFragmentStore);
+    ObjectBaseRef<ProgramRaster> raster(mRaster);
 
     bool ret = s->run(this, launchID);
 
     mFragment.set(frag);
     mVertex.set(vtx);
     mFragmentStore.set(store);
+    mRaster.set(raster);
     return ret;
 }
 
@@ -124,7 +126,6 @@
     eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight);
     glViewport(0, 0, mEGL.mWidth, mEGL.mHeight);
     glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-    //glEnable(GL_POINT_SMOOTH);
 
     glClearColor(mRootScript->mEnviroment.mClearColor[0],
                  mRootScript->mEnviroment.mClearColor[1],
diff --git a/libs/rs/rsScript.h b/libs/rs/rsScript.h
index 0067fc8..8aa4542 100644
--- a/libs/rs/rsScript.h
+++ b/libs/rs/rsScript.h
@@ -51,7 +51,7 @@
 
         ObjectBaseRef<ProgramVertex> mVertex;
         ObjectBaseRef<ProgramFragment> mFragment;
-        //ObjectBaseRef<ProgramRaster> mRaster;
+        ObjectBaseRef<ProgramRaster> mRaster;
         ObjectBaseRef<ProgramFragmentStore> mFragmentStore;
         InvokeFunc_t mInvokables[MAX_SCRIPT_BANKS];
         const char * mScriptText;
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
index e63ed24..20088da 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -72,6 +72,9 @@
     if (mEnviroment.mVertex.get()) {
         rsc->setVertex(mEnviroment.mVertex.get());
     }
+    if (mEnviroment.mRaster.get()) {
+        rsc->setRaster(mEnviroment.mRaster.get());
+    }
 
     if (launchIndex == 0) {
         mEnviroment.mStartTimeMillis
@@ -175,6 +178,7 @@
     s->mEnviroment.mFragment.set(rsc->getDefaultProgramFragment());
     s->mEnviroment.mVertex.set(rsc->getDefaultProgramVertex());
     s->mEnviroment.mFragmentStore.set(rsc->getDefaultProgramFragmentStore());
+    s->mEnviroment.mRaster.set(rsc->getDefaultProgramRaster());
 
     if (s->mProgram.mScript) {
         const static int pragmaMax = 16;
@@ -204,6 +208,18 @@
             }
 
             if (!strcmp(str[ct], "stateRaster")) {
+                if (!strcmp(str[ct+1], "default")) {
+                    continue;
+                }
+                if (!strcmp(str[ct+1], "parent")) {
+                    s->mEnviroment.mRaster.clear();
+                    continue;
+                }
+                ProgramRaster * pr = (ProgramRaster *)rsc->lookupName(str[ct+1]);
+                if (pr != NULL) {
+                    s->mEnviroment.mRaster.set(pr);
+                    continue;
+                }
                 LOGE("Unreconized value %s passed to stateRaster", str[ct+1]);
             }
 
@@ -223,7 +239,7 @@
                 LOGE("Unreconized value %s passed to stateFragment", str[ct+1]);
             }
 
-            if (!strcmp(str[ct], "stateFragmentStore")) {
+            if (!strcmp(str[ct], "stateStore")) {
                 if (!strcmp(str[ct+1], "default")) {
                     continue;
                 }
@@ -237,7 +253,7 @@
                     s->mEnviroment.mFragmentStore.set(pfs);
                     continue;
                 }
-                LOGE("Unreconized value %s passed to stateFragmentStore", str[ct+1]);
+                LOGE("Unreconized value %s passed to stateStore", str[ct+1]);
             }
 
         }
diff --git a/libs/rs/rsScriptC_Lib.cpp b/libs/rs/rsScriptC_Lib.cpp
index f5f182f..2f195a5 100644
--- a/libs/rs/rsScriptC_Lib.cpp
+++ b/libs/rs/rsScriptC_Lib.cpp
@@ -672,6 +672,23 @@
     glDrawArrays(GL_LINES, 0, 2);
 }
 
+static void SC_drawPoint(float x, float y, float z)
+{
+    GET_TLS();
+    rsc->setupCheck();
+
+    float vtx[] = { x, y, z };
+
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
+    glEnableClientState(GL_VERTEX_ARRAY);
+    glVertexPointer(3, GL_FLOAT, 0, vtx);
+
+    glDisableClientState(GL_NORMAL_ARRAY);
+    glDisableClientState(GL_COLOR_ARRAY);
+
+    glDrawArrays(GL_POINTS, 0, 1);
+}
+
 static void SC_drawQuadTexCoords(float x1, float y1, float z1,
                                  float u1, float v1,
                                  float x2, float y2, float z2,
@@ -1131,6 +1148,8 @@
         "void", "(int)" },
     { "bindProgramFragmentStore", (void *)&SC_bindProgramFragmentStore,
         "void", "(int)" },
+    { "bindProgramStore", (void *)&SC_bindProgramFragmentStore,
+        "void", "(int)" },
     { "bindProgramVertex", (void *)&SC_bindProgramVertex,
         "void", "(int)" },
     { "bindSampler", (void *)&SC_bindSampler,
@@ -1155,6 +1174,8 @@
         "void", "(float x1, float y1, float z1, float u1, float v1, float x2, float y2, float z2, float u2, float v2, float x3, float y3, float z3, float u3, float v3, float x4, float y4, float z4, float u4, float v4)" },
     { "drawLine", (void *)&SC_drawLine,
         "void", "(float x1, float y1, float z1, float x2, float y2, float z2)" },
+    { "drawPoint", (void *)&SC_drawPoint,
+        "void", "(float x1, float y1, float z1)" },
     { "drawSimpleMesh", (void *)&SC_drawSimpleMesh,
         "void", "(int ism)" },
     { "drawSimpleMeshRange", (void *)&SC_drawSimpleMeshRange,
diff --git a/opengl/tests/gl2_basic/gl2_basic.cpp b/opengl/tests/gl2_basic/gl2_basic.cpp
index 9345de5..2361db5 100644
--- a/opengl/tests/gl2_basic/gl2_basic.cpp
+++ b/opengl/tests/gl2_basic/gl2_basic.cpp
@@ -175,23 +175,89 @@
     checkGlError("glDrawArrays");
 }
 
-#if 0
+void printEGLConfiguration(EGLDisplay dpy, EGLConfig config) {
 
-void PrintEGLConfig(EGLDisplay dpy, EGLConfig config) {
-	int attrib[] = {EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE, EGL_ALPHA_SIZE,
-			EGL_DEPTH_SIZE, EGL_SURFACE_TYPE, EGL_RENDERABLE_TYPE
-	};
-	for(size_t i = 0; i < sizeof(attrib)/sizeof(attrib[0]); i++) {
-        int value = 0;
-        int a = attrib[i];
-        if (eglGetConfigAttrib(dpy, config, a, &value)) {
-            printf(" 0x%04x: %d", a, value);
+#define X(VAL) {VAL, #VAL}
+    struct {EGLint attribute; const char* name;} names[] = {
+    X(EGL_BUFFER_SIZE),
+    X(EGL_ALPHA_SIZE),
+    X(EGL_BLUE_SIZE),
+    X(EGL_GREEN_SIZE),
+    X(EGL_RED_SIZE),
+    X(EGL_DEPTH_SIZE),
+    X(EGL_STENCIL_SIZE),
+    X(EGL_CONFIG_CAVEAT),
+    X(EGL_CONFIG_ID),
+    X(EGL_LEVEL),
+    X(EGL_MAX_PBUFFER_HEIGHT),
+    X(EGL_MAX_PBUFFER_PIXELS),
+    X(EGL_MAX_PBUFFER_WIDTH),
+    X(EGL_NATIVE_RENDERABLE),
+    X(EGL_NATIVE_VISUAL_ID),
+    X(EGL_NATIVE_VISUAL_TYPE),
+    X(EGL_PRESERVED_RESOURCES),
+    X(EGL_SAMPLES),
+    X(EGL_SAMPLE_BUFFERS),
+    X(EGL_SURFACE_TYPE),
+    X(EGL_TRANSPARENT_TYPE),
+    X(EGL_TRANSPARENT_RED_VALUE),
+    X(EGL_TRANSPARENT_GREEN_VALUE),
+    X(EGL_TRANSPARENT_BLUE_VALUE),
+    X(EGL_BIND_TO_TEXTURE_RGB),
+    X(EGL_BIND_TO_TEXTURE_RGBA),
+    X(EGL_MIN_SWAP_INTERVAL),
+    X(EGL_MAX_SWAP_INTERVAL),
+    X(EGL_LUMINANCE_SIZE),
+    X(EGL_ALPHA_MASK_SIZE),
+    X(EGL_COLOR_BUFFER_TYPE),
+    X(EGL_RENDERABLE_TYPE),
+    X(EGL_CONFORMANT),
+   };
+#undef X
+
+    for (size_t j = 0; j < sizeof(names) / sizeof(names[0]); j++) {
+        EGLint value = -1;
+        EGLint returnVal = eglGetConfigAttrib(dpy, config, names[j].attribute, &value);
+        EGLint error = eglGetError();
+        if (returnVal && error == EGL_SUCCESS) {
+            printf(" %s: ", names[j].name);
+            printf("%d (0x%x)", value, value);
         }
-	}
-	printf("\n");
+    }
+    printf("\n");
 }
 
-#endif
+int printEGLConfigurations(EGLDisplay dpy) {
+    EGLint numConfig = 0;
+    EGLint returnVal = eglGetConfigs(dpy, NULL, 0, &numConfig);
+    checkEglError("eglGetConfigs", returnVal);
+    if (!returnVal) {
+        return false;
+    }
+
+    printf("Number of EGL configuration: %d\n", numConfig);
+
+    EGLConfig* configs = (EGLConfig*) malloc(sizeof(EGLConfig) * numConfig);
+    if (! configs) {
+        printf("Could not allocate configs.\n");
+        return false;
+    }
+
+    returnVal = eglGetConfigs(dpy, configs, numConfig, &numConfig);
+    checkEglError("eglGetConfigs", returnVal);
+    if (!returnVal) {
+        free(configs);
+        return false;
+    }
+
+    for(int i = 0; i < numConfig; i++) {
+        printf("Configuration %d\n", i);
+        printEGLConfiguration(dpy, configs[i]);
+    }
+
+    free(configs);
+    return true;
+}
 
 int main(int argc, char** argv) {
     EGLBoolean returnValue;
@@ -199,7 +265,7 @@
 
     EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
     EGLint s_configAttribs[] = {
-            EGL_SURFACE_TYPE, EGL_PBUFFER_BIT|EGL_WINDOW_BIT,
+            EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
             EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
             EGL_NONE };
     EGLint majorVersion;
@@ -226,13 +292,25 @@
         return 0;
     }
 
+    if (!printEGLConfigurations(dpy)) {
+        printf("printEGLConfigurations failed\n");
+        return 0;
+    }
+
+    checkEglError("printEGLConfigurations");
+
     EGLNativeWindowType window = android_createDisplaySurface();

     returnValue = EGLUtils::selectConfigForNativeWindow(dpy, s_configAttribs, window, &myConfig);
     if (returnValue) {
-    	printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue);
-    	return 0;
+        printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue);
+        return 0;
     }
 
+    checkEglError("EGLUtils::selectConfigForNativeWindow");
+
+    printf("Chose this configuration:\n");
+    printEGLConfiguration(dpy, myConfig);
+
     surface = eglCreateWindowSurface(dpy, myConfig, window, NULL);
     checkEglError("eglCreateWindowSurface");
     if (surface == EGL_NO_SURFACE) {
diff --git a/opengl/tests/tritex/tritex.cpp b/opengl/tests/tritex/tritex.cpp
index 629b53c..3365ab4 100644
--- a/opengl/tests/tritex/tritex.cpp
+++ b/opengl/tests/tritex/tritex.cpp
@@ -123,7 +123,7 @@
     EGLConfig myConfig = {0};

     EGLint attrib[] =

     {

-            EGL_SURFACE_TYPE, EGL_PBUFFER_BIT|EGL_WINDOW_BIT,
+            EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
             EGL_DEPTH_SIZE,     16,

             EGL_NONE

     };

diff --git a/services/java/com/android/server/DockObserver.java b/services/java/com/android/server/DockObserver.java
index a70134d..aa9c243 100644
--- a/services/java/com/android/server/DockObserver.java
+++ b/services/java/com/android/server/DockObserver.java
@@ -17,6 +17,7 @@
 package com.android.server;
 
 import android.app.Activity;
+import android.app.KeyguardManager;
 import android.content.ActivityNotFoundException;
 import android.content.BroadcastReceiver;
 import android.content.Context;
@@ -27,6 +28,8 @@
 import android.os.UEventObserver;
 import android.util.Log;
 
+import com.android.internal.widget.LockPatternUtils;
+
 import java.io.FileReader;
 import java.io.FileNotFoundException;
 
@@ -46,7 +49,11 @@
     private final Context mContext;
 
     private PowerManagerService mPowerManager;
-    
+
+    private KeyguardManager.KeyguardLock mKeyguardLock;
+    private boolean mKeyguardDisabled;
+    private LockPatternUtils mLockPatternUtils;
+
     // The broadcast receiver which receives the result of the ordered broadcast sent when
     // the dock state changes. The original ordered broadcast is sent with an initial result
     // code of RESULT_OK. If any of the registered broadcast receivers changes this value, e.g.,
@@ -88,6 +95,7 @@
     public DockObserver(Context context, PowerManagerService pm) {
         mContext = context;
         mPowerManager = pm;
+        mLockPatternUtils = new LockPatternUtils(context.getContentResolver());
         init();  // set initial status
         startObserving(DOCK_UEVENT_MATCH);
     }
@@ -130,6 +138,10 @@
 
     void systemReady() {
         synchronized (this) {
+            KeyguardManager keyguardManager =
+                    (KeyguardManager)mContext.getSystemService(Context.KEYGUARD_SERVICE);
+            mKeyguardLock = keyguardManager.newKeyguardLock(TAG);
+
             // don't bother broadcasting undocked here
             if (mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
                 update();
@@ -142,10 +154,25 @@
         mHandler.sendEmptyMessage(0);
     }
 
+    private final void updateKeyguardLocked() {
+        if (!mLockPatternUtils.isLockPatternEnabled()) {
+            if (!mKeyguardDisabled && mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
+                Log.d(TAG, "calling mKeyguardLock.disableKeyguard");
+                mKeyguardLock.disableKeyguard();
+                mKeyguardDisabled = true;
+            } else if (mKeyguardDisabled && mDockState == Intent.EXTRA_DOCK_STATE_UNDOCKED) {
+                Log.d(TAG, "calling mKeyguardLock.reenableKeyguard");
+                mKeyguardLock.reenableKeyguard();
+                mKeyguardDisabled = false;
+            }
+        }
+    }
+
     private final Handler mHandler = new Handler() {
         @Override
         public void handleMessage(Message msg) {
             synchronized (this) {
+                updateKeyguardLocked();
                 Log.d(TAG, "Broadcasting dock state " + mDockState);
                 // Pack up the values and broadcast them to everyone
                 mPowerManager.userActivityWithForce(SystemClock.uptimeMillis(), false, true);
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 30855b1..84ed3ed 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -1396,12 +1396,15 @@
                 }
             }
             
-        } else {
+        } else if (mLowerWallpaperTarget != null) {
             // Is it time to stop animating?
-            if (mLowerWallpaperTarget == null
-                    || mLowerWallpaperTarget.mAppToken.animation == null
-                    || mUpperWallpaperTarget == null
-                    || mUpperWallpaperTarget.mAppToken.animation == null) {
+            boolean lowerAnimating = mLowerWallpaperTarget.mAnimation != null
+                    || (mLowerWallpaperTarget.mAppToken != null
+                            && mLowerWallpaperTarget.mAppToken.animation != null);
+            boolean upperAnimating = mUpperWallpaperTarget.mAnimation != null
+                    || (mUpperWallpaperTarget.mAppToken != null
+                            && mUpperWallpaperTarget.mAppToken.animation != null);
+            if (!lowerAnimating || !upperAnimating) {
                 if (DEBUG_WALLPAPER) {
                     Log.v(TAG, "No longer animating wallpaper targets!");
                 }
@@ -3965,7 +3968,7 @@
     // -------------------------------------------------------------
 
     public void disableKeyguard(IBinder token, String tag) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DISABLE_KEYGUARD)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
             != PackageManager.PERMISSION_GRANTED) {
             throw new SecurityException("Requires DISABLE_KEYGUARD permission");
         }
@@ -3973,7 +3976,7 @@
     }
 
     public void reenableKeyguard(IBinder token) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DISABLE_KEYGUARD)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
             != PackageManager.PERMISSION_GRANTED) {
             throw new SecurityException("Requires DISABLE_KEYGUARD permission");
         }
@@ -3999,7 +4002,7 @@
      * @see android.app.KeyguardManager#exitKeyguardSecurely
      */
     public void exitKeyguardSecurely(final IOnKeyguardExitResult callback) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DISABLE_KEYGUARD)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
             != PackageManager.PERMISSION_GRANTED) {
             throw new SecurityException("Requires DISABLE_KEYGUARD permission");
         }
diff --git a/services/java/com/android/server/status/StatusBarPolicy.java b/services/java/com/android/server/status/StatusBarPolicy.java
index 6570bcd..6d54cae 100644
--- a/services/java/com/android/server/status/StatusBarPolicy.java
+++ b/services/java/com/android/server/status/StatusBarPolicy.java
@@ -934,10 +934,10 @@
         else if (evdoDbm >= -105) levelEvdoDbm = 1;
         else levelEvdoDbm = 0;
 
-        if (evdoSnr > 7) levelEvdoSnr = 4;
-        else if (evdoSnr > 5) levelEvdoSnr = 3;
-        else if (evdoSnr > 3) levelEvdoSnr = 2;
-        else if (evdoSnr > 1) levelEvdoSnr = 1;
+        if (evdoSnr >= 7) levelEvdoSnr = 4;
+        else if (evdoSnr >= 5) levelEvdoSnr = 3;
+        else if (evdoSnr >= 3) levelEvdoSnr = 2;
+        else if (evdoSnr >= 1) levelEvdoSnr = 1;
         else levelEvdoSnr = 0;
 
         return (levelEvdoDbm < levelEvdoSnr) ? levelEvdoDbm : levelEvdoSnr;
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java
index 3265708..1aa1c76 100644
--- a/telephony/java/android/telephony/PhoneNumberUtils.java
+++ b/telephony/java/android/telephony/PhoneNumberUtils.java
@@ -302,10 +302,22 @@
      */
     public static boolean compare(String a, String b) {
         // We've used loose comparation at least Eclair, which may change in the future.
+
         return compare(a, b, false);
     }
 
     /**
+     * Compare phone numbers a and b, and return true if they're identical
+     * enough for caller ID purposes. Checks a resource to determine whether
+     * to use a strict or loose comparison algorithm.
+     */
+    public static boolean compare(Context context, String a, String b) {
+        boolean useStrict = context.getResources().getBoolean(
+               com.android.internal.R.bool.config_use_strict_phone_number_comparation);
+        return compare(a, b, useStrict);
+    }
+
+    /**
      * @hide only for testing.
      */
     public static boolean compare(String a, String b, boolean useStrictComparation) {
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
index 93b48a9..9407603 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
@@ -246,7 +246,7 @@
     @Override
     protected boolean isApnTypeActive(String type) {
         return (isApnTypeAvailable(type) &&
-                (state == State.CONNECTED || state == State.INITING));
+                (state != State.IDLE));
     }
 
     @Override
@@ -260,7 +260,7 @@
     }
 
     protected String[] getActiveApnTypes() {
-        if (state == State.CONNECTED || state == State.INITING) {
+        if (state != State.IDLE) {
             return mSupportedApnTypes.clone();
         }
         return new String[0];
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
index b063e0a..c85b9bd 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
@@ -351,7 +351,7 @@
      * @return false while no data connection if all above requirements are met.
      */
     public boolean isDataConnectionAsDesired() {
-        boolean roaming = getDataRoaming();
+        boolean roaming = phone.getServiceState().getRoaming();
 
         if (mGsmPhone.mSIMRecords.getRecordsLoaded() &&
                 mGsmPhone.mSST.getCurrentGprsState() == ServiceState.STATE_IN_SERVICE &&
@@ -363,10 +363,6 @@
         return true;
     }
 
-    private boolean getDataRoaming() {
-        return mGsmPhone.mSST.getDataRoaming();
-    }
-
     @Override
     protected boolean isApnTypeActive(String type) {
         // TODO: support simultaneous with List instead
@@ -394,7 +390,7 @@
     }
 
     private boolean isDataAllowed() {
-        boolean roaming = getDataRoaming();
+        boolean roaming = phone.getServiceState().getRoaming();
         return getAnyDataEnabled() && (!roaming || getDataOnRoamingEnabled());
     }
 
@@ -441,7 +437,6 @@
         }
 
         int gprsState = mGsmPhone.mSST.getCurrentGprsState();
-        boolean roaming = getDataRoaming();
         boolean desiredPowerState = mGsmPhone.mSST.getDesiredPowerState();
 
         if ((state == State.IDLE || state == State.SCANNING)
@@ -477,7 +472,7 @@
                     " phoneState=" + phone.getState() +
                     " isDataAllowed=" + isDataAllowed() +
                     " dataEnabled=" + getAnyDataEnabled() +
-                    " roaming=" + roaming +
+                    " roaming=" + phone.getServiceState().getRoaming() +
                     " dataOnRoamingEnable=" + getDataOnRoamingEnabled() +
                     " ps restricted=" + mIsPsRestricted +
                     " desiredPowerState=" + desiredPowerState);
@@ -1112,38 +1107,18 @@
         return trySetupData(reason);
     }
 
-    /**
-     * Check the data roaming consistency since this can be triggered by
-     * voice roaming flag of ServiceState in setDataOnRoamingEnabled()
-     *
-     * TODO make this triggered by data roaming state only
-     */
     @Override
     protected void onRoamingOff() {
-        if (!getDataRoaming()) { //data roaming is off
-            trySetupData(Phone.REASON_ROAMING_OFF);
-        } else { // Inconsistent! data roaming is on
-            sendMessage(obtainMessage(EVENT_ROAMING_ON));
-        }
+        trySetupData(Phone.REASON_ROAMING_OFF);
     }
 
-    /**
-     * Check the data roaming consistency since this can be triggered by
-     * voice roaming flag of ServiceState in setDataOnRoamingEnabled()
-     *
-     * TODO make this triggered by data roaming state only
-     */
     @Override
     protected void onRoamingOn() {
-        if (getDataRoaming()) { // data roaming is on
-            if (getDataOnRoamingEnabled()) {
-                trySetupData(Phone.REASON_ROAMING_ON);
-            } else {
-                if (DBG) log("Tear down data connection on roaming.");
-                cleanUpConnection(true, Phone.REASON_ROAMING_ON);
-            }
-        } else { // Inconsistent! data roaming is off
-            sendMessage(obtainMessage(EVENT_ROAMING_OFF));
+        if (getDataOnRoamingEnabled()) {
+            trySetupData(Phone.REASON_ROAMING_ON);
+        } else {
+            if (DBG) log("Tear down data connection on roaming.");
+            cleanUpConnection(true, Phone.REASON_ROAMING_ON);
         }
     }
 
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
index 003899b..8140654 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
@@ -83,12 +83,17 @@
     private int networkType = 0;
     private int newNetworkType = 0;
 
-    /** GSM roaming status solely based on TS 27.007 7.2 CREG. */
+    /**
+     * GSM roaming status solely based on TS 27.007 7.2 CREG. Only used by
+     * handlePollStateResult to store CREG roaming result.
+     */
     private boolean mGsmRoaming = false;
 
-    /** Data roaming status solely based on TS 27.007 10.1.19 CGREG. */
+    /**
+     * Data roaming status solely based on TS 27.007 10.1.19 CGREG. Only used by
+     * handlePollStateResult to store CGREG roaming result.
+     */
     private boolean mDataRoaming = false;
-    private boolean newDataRoaming = false;
 
     private RegistrantList gprsAttachedRegistrants = new RegistrantList();
     private RegistrantList gprsDetachedRegistrants = new RegistrantList();
@@ -310,10 +315,6 @@
         psRestrictDisabledRegistrants.remove(h);
     }
 
-    boolean getDataRoaming() {
-        return mDataRoaming;
-    }
-
     public void handleMessage (Message msg) {
         AsyncResult ar;
         int[] ints;
@@ -627,7 +628,6 @@
 
                     mGsmRoaming = regCodeIsRoaming(regState);
                     newSS.setState (regCodeToServiceState(regState));
-
                     // LAC and CID are -1 if not avail
                     newCellLoc.setLacAndCid(lac, cid);
                 break;
@@ -650,7 +650,7 @@
                         }
                     }
                     newGPRSState = regCodeToServiceState(regState);
-                    newDataRoaming = regCodeIsRoaming(regState);
+                    mDataRoaming = regCodeIsRoaming(regState);
                     newNetworkType = type;
                     newSS.setRadioTechnology(type);
                 break;
@@ -678,15 +678,22 @@
         pollingContext[0]--;
 
         if (pollingContext[0] == 0) {
-            newSS.setRoaming(isRoamingBetweenOperators(mGsmRoaming, newSS));
-            // when both roaming indicators are true but not roaming between
-            // operators, roaming should set to false.
-            if (newDataRoaming && mGsmRoaming && !newSS.getRoaming()) {
-                newDataRoaming = false;
+            /**
+             *  Since the roaming states of gsm service (from +CREG) and
+             *  data service (from +CGREG) could be different, the new SS
+             *  is set roaming while either one is roaming.
+             *
+             *  There is an exception for the above rule. The new SS is not set
+             *  as roaming while gsm service reports roaming but indeed it is
+             *  not roaming between operators.
+             */
+            boolean roaming = (mGsmRoaming || mDataRoaming);
+            if (mGsmRoaming && !isRoamingBetweenOperators(mGsmRoaming, newSS)) {
+                roaming = false;
             }
+            newSS.setRoaming(roaming);
             pollStateDone();
         }
-
     }
 
     private void setSignalStrengthDefaultValues() {
@@ -711,8 +718,6 @@
                 newCellLoc.setStateInvalid();
                 setSignalStrengthDefaultValues();
                 mGotCountryCode = false;
-                newDataRoaming = false;
-
                 pollStateDone();
             break;
 
@@ -721,8 +726,6 @@
                 newCellLoc.setStateInvalid();
                 setSignalStrengthDefaultValues();
                 mGotCountryCode = false;
-                newDataRoaming = false;
-
                 pollStateDone();
             break;
 
@@ -736,8 +739,6 @@
                 newCellLoc.setStateInvalid();
                 setSignalStrengthDefaultValues();
                 mGotCountryCode = false;
-                newDataRoaming = false;
-                mDataRoaming = false;
 
                 //NOTE: pollStateDone() is not needed in this case
                 break;
@@ -830,9 +831,9 @@
 
         boolean hasChanged = !newSS.equals(ss);
 
-        boolean hasRoamingOn = !mDataRoaming && newDataRoaming;
+        boolean hasRoamingOn = !ss.getRoaming() && newSS.getRoaming();
 
-        boolean hasRoamingOff = mDataRoaming && !newDataRoaming;
+        boolean hasRoamingOff = ss.getRoaming() && !newSS.getRoaming();
 
         boolean hasLocationChanged = !newCellLoc.equals(cellLoc);
 
@@ -849,7 +850,6 @@
 
         gprsState = newGPRSState;
         networkType = newNetworkType;
-        mDataRoaming = newDataRoaming;
 
         newSS.setStateOutOfService(); // clean slate for next time