Merge change Icfc893d2 into eclair

* changes:
  Fix for 2267410 : Battery use doesn't show CPU usage on non-wiped devices
diff --git a/api/current.xml b/api/current.xml
index 808e91c..81cb646 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -36143,7 +36143,7 @@
  value=""android.intent.extra.changed_component_name""
  static="true"
  final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </field>
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 0085f26..6ba79b4 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -2105,10 +2105,10 @@
             "android.intent.extra.remote_intent_token";
 
     /**
-     * @Deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
+     * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
      * will contain only the first name in the list.
      */
-    public static final String EXTRA_CHANGED_COMPONENT_NAME =
+    @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
             "android.intent.extra.changed_component_name";
 
     /**
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index 70af91f..809e230 100644
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -172,6 +172,10 @@
 
     public boolean isEnabled() {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
+        return isEnabledInternal();
+    }
+
+    private boolean isEnabledInternal() {
         return mBluetoothState == BluetoothAdapter.STATE_ON;
     }
 
@@ -328,7 +332,7 @@
         public void handleMessage(Message msg) {
             switch (msg.what) {
             case MESSAGE_REGISTER_SDP_RECORDS:
-                if (!isEnabled()) {
+                if (!isEnabledInternal()) {
                     return;
                 }
                 // SystemService.start() forks sdptool to register service
@@ -375,7 +379,7 @@
                 break;
             case MESSAGE_DISCOVERABLE_TIMEOUT:
                 int mode = msg.arg1;
-                if (isEnabled()) {
+                if (isEnabledInternal()) {
                     // TODO: Switch back to the previous scan mode
                     // This is ok for now, because we only use
                     // CONNECTABLE and CONNECTABLE_DISCOVERABLE
@@ -675,7 +679,9 @@
     }
 
     /*package*/synchronized void getAllProperties() {
+
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
+        if (!isEnabledInternal()) return;
         mAdapterProperties.clear();
 
         String properties[] = (String [])getAdapterPropertiesNative();
@@ -734,16 +740,19 @@
     // The following looks dirty.
     private boolean setPropertyString(String key, String value) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
+        if (!isEnabledInternal()) return false;
         return setAdapterPropertyStringNative(key, value);
     }
 
     private boolean setPropertyInteger(String key, int value) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
+        if (!isEnabledInternal()) return false;
         return setAdapterPropertyIntegerNative(key, value);
     }
 
     private boolean setPropertyBoolean(String key, boolean value) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
+        if (!isEnabledInternal()) return false;
         return setAdapterPropertyBooleanNative(key, value ? 1 : 0);
     }
 
@@ -852,7 +861,7 @@
 
     public synchronized int getScanMode() {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
-        if (!isEnabled())
+        if (!isEnabledInternal())
             return BluetoothAdapter.SCAN_MODE_NONE;
 
         boolean pairable = getProperty("Pairable").equals("true");
@@ -863,15 +872,16 @@
     public synchronized boolean startDiscovery() {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                                 "Need BLUETOOTH_ADMIN permission");
-        if (!isEnabled()) {
-            return false;
-        }
+        if (!isEnabledInternal()) return false;
+
         return startDiscoveryNative();
     }
 
     public synchronized boolean cancelDiscovery() {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                                 "Need BLUETOOTH_ADMIN permission");
+        if (!isEnabledInternal()) return false;
+
         return stopDiscoveryNative();
     }
 
@@ -887,6 +897,8 @@
     public synchronized boolean createBond(String address) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                                 "Need BLUETOOTH_ADMIN permission");
+        if (!isEnabledInternal()) return false;
+
         if (!BluetoothAdapter.checkBluetoothAddress(address)) {
             return false;
         }
@@ -919,6 +931,8 @@
     public synchronized boolean cancelBondProcess(String address) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                                 "Need BLUETOOTH_ADMIN permission");
+        if (!isEnabledInternal()) return false;
+
         if (!BluetoothAdapter.checkBluetoothAddress(address)) {
             return false;
         }
@@ -936,6 +950,8 @@
     public synchronized boolean removeBond(String address) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                                 "Need BLUETOOTH_ADMIN permission");
+        if (!isEnabledInternal()) return false;
+
         if (!BluetoothAdapter.checkBluetoothAddress(address)) {
             return false;
         }
@@ -960,6 +976,8 @@
     }
 
     /*package*/ String[] getRemoteDeviceProperties(String address) {
+        if (!isEnabledInternal()) return null;
+
         String objectPath = getObjectPathFromAddress(address);
         return (String [])getDevicePropertiesNative(objectPath);
     }
@@ -1055,6 +1073,8 @@
             return false;
         }
 
+        if (!isEnabledInternal()) return false;
+
         return setDevicePropertyBooleanNative(getObjectPathFromAddress(address), "Trusted",
                 value ? 1 : 0);
     }
@@ -1144,6 +1164,8 @@
     public synchronized boolean fetchRemoteUuids(String address, ParcelUuid uuid,
             IBluetoothCallback callback) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
+        if (!isEnabledInternal()) return false;
+
         if (!BluetoothAdapter.checkBluetoothAddress(address)) {
             return false;
         }
@@ -1198,6 +1220,8 @@
      */
     public int getRemoteServiceChannel(String address, ParcelUuid uuid) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
+        if (!isEnabledInternal()) return -1;
+
         if (!BluetoothAdapter.checkBluetoothAddress(address)) {
             return BluetoothDevice.ERROR;
         }
@@ -1216,6 +1240,8 @@
     public synchronized boolean setPin(String address, byte[] pin) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                                 "Need BLUETOOTH_ADMIN permission");
+        if (!isEnabledInternal()) return false;
+
         if (pin == null || pin.length <= 0 || pin.length > 16 ||
             !BluetoothAdapter.checkBluetoothAddress(address)) {
             return false;
@@ -1242,6 +1268,8 @@
     public synchronized boolean setPasskey(String address, int passkey) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                                 "Need BLUETOOTH_ADMIN permission");
+        if (!isEnabledInternal()) return false;
+
         if (passkey < 0 || passkey > 999999 || !BluetoothAdapter.checkBluetoothAddress(address)) {
             return false;
         }
@@ -1259,6 +1287,8 @@
     public synchronized boolean setPairingConfirmation(String address, boolean confirm) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                                 "Need BLUETOOTH_ADMIN permission");
+        if (!isEnabledInternal()) return false;
+
         address = address.toUpperCase();
         Integer data = mEventLoop.getPasskeyAgentRequestData().remove(address);
         if (data == null) {
@@ -1273,6 +1303,8 @@
     public synchronized boolean cancelPairingUserInput(String address) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                                 "Need BLUETOOTH_ADMIN permission");
+        if (!isEnabledInternal()) return false;
+
         if (!BluetoothAdapter.checkBluetoothAddress(address)) {
             return false;
         }
@@ -1289,7 +1321,7 @@
         return cancelPairingUserInputNative(address, data.intValue());
     }
 
-    public void updateDeviceServiceChannelCache(String address) {
+    /*package*/ void updateDeviceServiceChannelCache(String address) {
         ParcelUuid[] deviceUuids = getRemoteUuids(address);
         // We are storing the rfcomm channel numbers only for the uuids
         // we are interested in.
@@ -1364,8 +1396,9 @@
      */
     public synchronized int addRfcommServiceRecord(String serviceName, ParcelUuid uuid,
             int channel, IBinder b) {
-        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM,
-                                                "Need BLUETOOTH permission");
+        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
+        if (!isEnabledInternal()) return -1;
+
         if (serviceName == null || uuid == null || channel < 1 ||
                 channel > BluetoothSocket.MAX_RFCOMM_CHANNEL) {
             return -1;
diff --git a/core/java/android/text/method/QwertyKeyListener.java b/core/java/android/text/method/QwertyKeyListener.java
index 2e76470..b3926f2 100644
--- a/core/java/android/text/method/QwertyKeyListener.java
+++ b/core/java/android/text/method/QwertyKeyListener.java
@@ -432,7 +432,7 @@
         PICKER_SETS.put('y', "\u00FD\u00FF");
         PICKER_SETS.put('z', "\u017A\u017C\u017E");
         PICKER_SETS.put(KeyCharacterMap.PICKER_DIALOG_INPUT,
-                             "\u2026\u00A5\u2022\u00AE\u00A9\u00B1[]{}\\");
+                             "\u2026\u00A5\u2022\u00AE\u00A9\u00B1[]{}\\|");
         PICKER_SETS.put('/', "\\");
 
         // From packages/inputmethods/LatinIME/res/xml/kbd_symbols.xml
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index 23e7fb7..0ebe360 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -104,8 +104,12 @@
     int getSwitchStateForDevice(int devid, int sw);
     int getScancodeState(int sw);
     int getScancodeStateForDevice(int devid, int sw);
+    int getTrackballScancodeState(int sw);
+    int getDPadScancodeState(int sw);
     int getKeycodeState(int sw);
     int getKeycodeStateForDevice(int devid, int sw);
+    int getTrackballKeycodeState(int sw);
+    int getDPadKeycodeState(int sw);
     
     // Report whether the hardware supports the given keys; returns true if successful
     boolean hasKeys(in int[] keycodes, inout boolean[] keyExists);
diff --git a/core/java/com/android/internal/widget/ContactHeaderWidget.java b/core/java/com/android/internal/widget/ContactHeaderWidget.java
index d441155..19debec 100644
--- a/core/java/com/android/internal/widget/ContactHeaderWidget.java
+++ b/core/java/com/android/internal/widget/ContactHeaderWidget.java
@@ -119,6 +119,14 @@
         int CONTACT_STATUS_RES_PACKAGE = 8;
         int CONTACT_STATUS_LABEL = 9;
     }
+    
+    private interface PhotoQuery {
+        String[] COLUMNS = new String[] {
+            Photo.PHOTO
+        };
+        
+        int PHOTO = 0;
+    }
 
     //Projection used for looking up contact id from phone number
     protected static final String[] PHONE_LOOKUP_PROJECTION = new String[] {
@@ -144,6 +152,7 @@
     private static final int TOKEN_CONTACT_INFO = 0;
     private static final int TOKEN_PHONE_LOOKUP = 1;
     private static final int TOKEN_EMAIL_LOOKUP = 2;
+    private static final int TOKEN_PHOTO_QUERY = 3;
 
     public ContactHeaderWidget(Context context) {
         this(context, null);
@@ -229,11 +238,36 @@
         protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
             try{
                 switch (token) {
-                    case TOKEN_CONTACT_INFO: {
-                        bindContactInfo(cursor);
+                    case TOKEN_PHOTO_QUERY: {
+                        //Set the photo
+                        Bitmap photoBitmap = null;
+                        if (cursor != null && cursor.moveToFirst() 
+                                && !cursor.isNull(PhotoQuery.PHOTO)) {
+                            byte[] photoData = cursor.getBlob(PhotoQuery.PHOTO);
+                            photoBitmap = BitmapFactory.decodeByteArray(photoData, 0,
+                                    photoData.length, null);
+                        }
+                            
+                        if (photoBitmap == null) {
+                            photoBitmap = loadPlaceholderPhoto(null);
+                        }
+                        mPhotoView.setImageBitmap(photoBitmap);
+                        if (cookie != null && cookie instanceof Uri) {
+                            mPhotoView.assignContactUri((Uri) cookie);
+                        }
                         invalidate();
                         break;
                     }
+                    case TOKEN_CONTACT_INFO: {
+                        if (cursor != null && cursor.moveToFirst()) {
+                            bindContactInfo(cursor);
+                            Uri lookupUri = Contacts.getLookupUri(cursor.getLong(ContactQuery._ID), 
+                                    cursor.getString(ContactQuery.LOOKUP_KEY));
+                            startPhotoQuery(cursor.getLong(ContactQuery.PHOTO_ID), lookupUri);
+                            invalidate();
+                        }
+                        break;
+                    }
                     case TOKEN_PHONE_LOOKUP: {
                         if (cursor != null && cursor.moveToFirst()) {
                             long contactId = cursor.getLong(PHONE_LOOKUP_CONTACT_ID_COLUMN_INDEX);
@@ -375,8 +409,6 @@
      */
     public void bindFromContactUri(Uri contactUri) {
         mContactUri = contactUri;
-        long contactId = ContentUris.parseId(contactUri);
-
         startContactQuery(contactUri);
     }
 
@@ -424,30 +456,24 @@
                 null, null, null);
     }
 
+    protected void startPhotoQuery(long photoId, Uri lookupKey) {
+        mQueryHandler.startQuery(TOKEN_PHOTO_QUERY, lookupKey, 
+                ContentUris.withAppendedId(Data.CONTENT_URI, photoId), PhotoQuery.COLUMNS,
+                null, null, null);
+    }
+    
     /**
      * Bind the contact details provided by the given {@link Cursor}.
      */
     protected void bindContactInfo(Cursor c) {
-        if (c == null || !c.moveToFirst()) return;
-
         // TODO: Bring back phonetic name
         final String displayName = c.getString(ContactQuery.DISPLAY_NAME);
-        final long contactId = c.getLong(ContactQuery._ID);
-        final String lookupKey = c.getString(ContactQuery.LOOKUP_KEY);
         final String phoneticName = null;
         this.setDisplayName(displayName, null);
 
         final boolean starred = c.getInt(ContactQuery.STARRED) != 0;
         mStarredView.setChecked(starred);
 
-        //Set the photo
-        Bitmap photoBitmap = loadContactPhoto(c.getLong(ContactQuery.PHOTO_ID), null);
-        if (photoBitmap == null) {
-            photoBitmap = loadPlaceholderPhoto(null);
-        }
-        mPhotoView.setImageBitmap(photoBitmap);
-        mPhotoView.assignContactUri(Contacts.getLookupUri(contactId, lookupKey));
-
         //Set the presence status
         if (!c.isNull(ContactQuery.CONTACT_PRESENCE_STATUS)) {
             int presence = c.getInt(ContactQuery.CONTACT_PRESENCE_STATUS);
@@ -554,30 +580,6 @@
         }
     }
 
-    private Bitmap loadContactPhoto(long photoId, BitmapFactory.Options options) {
-        Cursor photoCursor = null;
-        Bitmap photoBm = null;
-
-        try {
-            photoCursor = mContentResolver.query(
-                    ContentUris.withAppendedId(Data.CONTENT_URI, photoId),
-                    new String[] { Photo.PHOTO },
-                    null, null, null);
-
-            if (photoCursor != null && photoCursor.moveToFirst() && !photoCursor.isNull(0)) {
-                byte[] photoData = photoCursor.getBlob(0);
-                photoBm = BitmapFactory.decodeByteArray(photoData, 0,
-                        photoData.length, options);
-            }
-        } finally {
-            if (photoCursor != null) {
-                photoCursor.close();
-            }
-        }
-
-        return photoBm;
-    }
-
     private Bitmap loadPlaceholderPhoto(BitmapFactory.Options options) {
         if (mNoPhotoResource == 0) {
             return null;
diff --git a/core/res/res/layout/keyguard_screen_unlock_portrait.xml b/core/res/res/layout/keyguard_screen_unlock_portrait.xml
index bc7f9a9..5916786 100644
--- a/core/res/res/layout/keyguard_screen_unlock_portrait.xml
+++ b/core/res/res/layout/keyguard_screen_unlock_portrait.xml
@@ -38,6 +38,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_alignParentTop="true"
+            android:layout_marginTop="6dip"
             android:layout_alignParentRight="true"
             android:layout_marginRight="8dip"
             android:textAppearance="?android:attr/textAppearanceMedium"
@@ -46,17 +47,18 @@
         <com.android.internal.widget.DigitalClock android:id="@+id/time"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_below="@id/carrier"
             android:layout_alignParentLeft="true"
-            android:layout_marginBottom="8dip"
-            android:layout_marginLeft="24dip"
+            android:layout_alignParentTop="true"
+            android:layout_marginTop="15dip"
+            android:layout_marginBottom="6dip"
+            android:layout_marginLeft="20dip"
             >
 
             <TextView android:id="@+id/timeDisplay"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:gravity="bottom"
-                android:textSize="72sp"
+                android:textSize="56sp"
                 android:textAppearance="?android:attr/textAppearanceMedium"
                 android:shadowColor="#C0000000"
                 android:shadowDx="0"
@@ -64,14 +66,13 @@
                 android:shadowRadius="3.0"
                 />
 
-
             <TextView android:id="@+id/am_pm"
                 android:layout_width="wrap_content"
                 android:layout_height="fill_parent"
                 android:gravity="bottom"
-                android:textSize="22sp"
+                android:textSize="18sp"
                 android:singleLine="true"
-                android:layout_marginLeft="8dip"
+                android:layout_marginLeft="4dip"
                 android:layout_marginBottom="-6dip"
                 android:textAppearance="?android:attr/textAppearanceMedium"
                 android:shadowColor="#C0000000"
@@ -87,7 +88,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_below="@id/time"
-            android:layout_marginLeft="16dip"
+            android:layout_marginLeft="24dip"
             android:textAppearance="?android:attr/textAppearanceMedium"
             />
     
@@ -95,7 +96,6 @@
 
     <View
         android:id="@+id/divider"
-        android:layout_below="@id/date"
         android:layout_width="fill_parent"
         android:layout_height="1dip"
         android:layout_marginTop="8dip"
@@ -109,8 +109,8 @@
         android:orientation="horizontal"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
-        android:layout_marginTop="3dip"
-        android:layout_marginLeft="16dip"
+        android:layout_marginTop="0dip"
+        android:layout_marginLeft="12dip"
         android:gravity="left"
         >
         <TextView
@@ -118,7 +118,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textAppearance="?android:attr/textAppearanceMedium"
-            android:textSize="17sp"
+            android:textSize="18sp"
             android:drawablePadding="4dip"
             />
         <TextView
@@ -128,7 +128,7 @@
             android:layout_marginLeft="5dip"
             android:layout_marginRight="5dip"
             android:textAppearance="?android:attr/textAppearanceMedium"
-            android:textSize="17sp"
+            android:textSize="18sp"
             />
         <TextView
             android:id="@+id/status2"
@@ -136,7 +136,7 @@
             android:layout_height="wrap_content"
             android:layout_alignParentTop="true"
             android:textAppearance="?android:attr/textAppearanceMedium"
-            android:textSize="17sp"
+            android:textSize="18sp"
             android:drawablePadding="4dip"
             />
     </LinearLayout>
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index a5bceb6..c42f647 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -68,6 +68,7 @@
     native void nContextDestroy(int con);
     native void nContextSetSurface(int w, int h, Surface sur);
     native void nContextSetPriority(int p);
+    native void nContextDump(int bits);
 
     native void nContextBindRootScript(int script);
     native void nContextBindSampler(int sampler, int slot);
@@ -304,6 +305,10 @@
         nContextSetSurface(w, h, mSurface);
     }
 
+    public void contextDump(int bits) {
+        nContextDump(bits);
+    }
+
     public void destroy() {
         nContextDeinitToClient();
         mMessageThread.mRun = false;
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index d311c33..af3bc74 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -189,9 +189,16 @@
 nContextDestroy(JNIEnv *_env, jobject _this, jint con)
 {
     LOG_API("nContextDestroy, con(%p)", (RsContext)con);
-    return rsContextDestroy((RsContext)con);
+    rsContextDestroy((RsContext)con);
 }
 
+static void
+nContextDump(JNIEnv *_env, jobject _this, jint bits)
+{
+    RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
+    LOG_API("nContextDump, con(%p)  bits(%i)", (RsContext)con, bits);
+    rsContextDump((RsContext)con, bits);
+}
 
 static void
 nContextPause(JNIEnv *_env, jobject _this)
@@ -1346,6 +1353,7 @@
 {"nContextSetPriority",            "(I)V",                                 (void*)nContextSetPriority },
 {"nContextSetSurface",             "(IILandroid/view/Surface;)V",          (void*)nContextSetSurface },
 {"nContextDestroy",                "(I)V",                                 (void*)nContextDestroy },
+{"nContextDump",                   "(I)V",                                 (void*)nContextDump },
 {"nContextPause",                  "()V",                                  (void*)nContextPause },
 {"nContextResume",                 "()V",                                  (void*)nContextResume },
 {"nAssignName",                    "(I[B)V",                               (void*)nAssignName },
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index be988e7..a4e72d9 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -42,6 +42,10 @@
 	param void *sur
 	}
 
+ContextDump {
+	param int32_t bits
+}
+
 ContextSetPriority {
 	param int32_t priority
 	}
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index 16029a6..408d83f 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -190,6 +190,24 @@
 {
 }
 
+void Allocation::dumpLOGV(const char *prefix) const
+{
+    ObjectBase::dumpLOGV(prefix);
+
+    String8 s(prefix);
+    s.append(" type ");
+    if (mType.get()) {
+        mType->dumpLOGV(s.string());
+    }
+
+    LOGV("%s allocation ptr=%p mCpuWrite=%i, mCpuRead=%i, mGpuWrite=%i, mGpuRead=%i",
+          prefix, mPtr, mCpuWrite, mCpuRead, mGpuWrite, mGpuRead);
+
+    LOGV("%s allocation mIsTexture=%i mIsTextureID=%i, mIsVertexBuffer=%i, mBufferID=%i",
+          prefix, mIsTexture, mTextureID, mIsVertexBuffer, mBufferID);
+
+
+}
 
 
 /////////////////
diff --git a/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h
index 1b83267..514b1c2 100644
--- a/libs/rs/rsAllocation.h
+++ b/libs/rs/rsAllocation.h
@@ -65,6 +65,8 @@
     void enableGLVertexBuffers() const;
     void setupGLIndexBuffers() const;
 
+    virtual void dumpLOGV(const char *prefix) const;
+
 
 protected:
     ObjectBaseRef<const Type> mType;
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index deb9592..08ed725 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -819,6 +819,11 @@
     rsc->setPriority(p);
 }
 
+void rsi_ContextDump(Context *rsc, int32_t bits)
+{
+    ObjectBase::dumpAll(rsc);
+}
+
 }
 }
 
diff --git a/libs/rs/rsObjectBase.cpp b/libs/rs/rsObjectBase.cpp
index b7d67cc..05791cb 100644
--- a/libs/rs/rsObjectBase.cpp
+++ b/libs/rs/rsObjectBase.cpp
@@ -190,3 +190,15 @@
     }
 }
 
+void ObjectBase::dumpAll(Context *rsc)
+{
+    if (rsc->props.mLogObjects) {
+        LOGV("Dumping all objects");
+        const ObjectBase * o = rsc->mObjHead;
+        while (o) {
+            o->dumpLOGV("  ");
+            o = o->mNext;
+        }
+    }
+}
+
diff --git a/libs/rs/rsObjectBase.h b/libs/rs/rsObjectBase.h
index dc85ac7..f247022 100644
--- a/libs/rs/rsObjectBase.h
+++ b/libs/rs/rsObjectBase.h
@@ -49,6 +49,7 @@
     void setContext(Context *);
 
     static void zeroAllUserRef(Context *rsc);
+    static void dumpAll(Context *rsc);
 
     virtual void dumpLOGV(const char *prefix) const;
 
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index afdc8f7..da25f97 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -640,10 +640,13 @@
                 map.put(Video.Media.ARTIST, (mArtist != null && mArtist.length() > 0 ? mArtist : MediaFile.UNKNOWN_STRING));
                 map.put(Video.Media.ALBUM, (mAlbum != null && mAlbum.length() > 0 ? mAlbum : MediaFile.UNKNOWN_STRING));
                 map.put(Video.Media.DURATION, mDuration);
+                map.put(Video.Media.DATE_TAKEN, mLastModified);
                 // FIXME - add RESOLUTION
             } else if (MediaFile.isImageFileType(mFileType)) {
                 // FIXME - add DESCRIPTION
-                // map.put(field, value);
+                // DATE_TAKEN will be overridden later if this is a JPEG image whose EXIF data
+                // contains date time information.
+                map.put(Images.Media.DATE_TAKEN, mLastModified);
             } else if (MediaFile.isAudioFileType(mFileType)) {
                 map.put(Audio.Media.ARTIST, (mArtist != null && mArtist.length() > 0 ? mArtist : MediaFile.UNKNOWN_STRING));
                 map.put(Audio.Media.ALBUM, (mAlbum != null && mAlbum.length() > 0 ? mAlbum : MediaFile.UNKNOWN_STRING));
diff --git a/services/java/com/android/server/KeyInputQueue.java b/services/java/com/android/server/KeyInputQueue.java
index a885df8..1bb897b 100644
--- a/services/java/com/android/server/KeyInputQueue.java
+++ b/services/java/com/android/server/KeyInputQueue.java
@@ -371,6 +371,40 @@
         }
     }
     
+    public int getTrackballScancodeState(int code) {
+        synchronized (mFirst) {
+            final int N = mDevices.size();
+            for (int i=0; i<N; i++) {
+                InputDevice dev = mDevices.valueAt(i);
+                if ((dev.classes&RawInputEvent.CLASS_TRACKBALL) != 0) {
+                    int res = nativeGetScancodeState(dev.id, code);
+                    if (res > 0) {
+                        return res;
+                    }
+                }
+            }
+        }
+        
+        return 0;
+    }
+    
+    public int getDPadScancodeState(int code) {
+        synchronized (mFirst) {
+            final int N = mDevices.size();
+            for (int i=0; i<N; i++) {
+                InputDevice dev = mDevices.valueAt(i);
+                if ((dev.classes&RawInputEvent.CLASS_DPAD) != 0) {
+                    int res = nativeGetScancodeState(dev.id, code);
+                    if (res > 0) {
+                        return res;
+                    }
+                }
+            }
+        }
+        
+        return 0;
+    }
+    
     public int getKeycodeState(int code) {
         synchronized (mFirst) {
             VirtualKey vk = mPressedVirtualKey;
@@ -395,6 +429,40 @@
         }
     }
     
+    public int getTrackballKeycodeState(int code) {
+        synchronized (mFirst) {
+            final int N = mDevices.size();
+            for (int i=0; i<N; i++) {
+                InputDevice dev = mDevices.valueAt(i);
+                if ((dev.classes&RawInputEvent.CLASS_TRACKBALL) != 0) {
+                    int res = nativeGetKeycodeState(dev.id, code);
+                    if (res > 0) {
+                        return res;
+                    }
+                }
+            }
+        }
+        
+        return 0;
+    }
+    
+    public int getDPadKeycodeState(int code) {
+        synchronized (mFirst) {
+            final int N = mDevices.size();
+            for (int i=0; i<N; i++) {
+                InputDevice dev = mDevices.valueAt(i);
+                if ((dev.classes&RawInputEvent.CLASS_DPAD) != 0) {
+                    int res = nativeGetKeycodeState(dev.id, code);
+                    if (res > 0) {
+                        return res;
+                    }
+                }
+            }
+        }
+        
+        return 0;
+    }
+    
     public static native String getDeviceName(int deviceId);
     public static native int getDeviceClasses(int deviceId);
     public static native void addExcludedDevice(String deviceName);
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 327cd72..887c46d 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -4192,6 +4192,22 @@
         return mQueue.getScancodeState(devid, sw);
     }
 
+    public int getTrackballScancodeState(int sw) {
+        if (!checkCallingPermission(android.Manifest.permission.READ_INPUT_STATE,
+                "getTrackballScancodeState()")) {
+            throw new SecurityException("Requires READ_INPUT_STATE permission");
+        }
+        return mQueue.getTrackballScancodeState(sw);
+    }
+
+    public int getDPadScancodeState(int sw) {
+        if (!checkCallingPermission(android.Manifest.permission.READ_INPUT_STATE,
+                "getDPadScancodeState()")) {
+            throw new SecurityException("Requires READ_INPUT_STATE permission");
+        }
+        return mQueue.getDPadScancodeState(sw);
+    }
+
     public int getKeycodeState(int sw) {
         if (!checkCallingPermission(android.Manifest.permission.READ_INPUT_STATE,
                 "getKeycodeState()")) {
@@ -4208,6 +4224,22 @@
         return mQueue.getKeycodeState(devid, sw);
     }
 
+    public int getTrackballKeycodeState(int sw) {
+        if (!checkCallingPermission(android.Manifest.permission.READ_INPUT_STATE,
+                "getTrackballKeycodeState()")) {
+            throw new SecurityException("Requires READ_INPUT_STATE permission");
+        }
+        return mQueue.getTrackballKeycodeState(sw);
+    }
+
+    public int getDPadKeycodeState(int sw) {
+        if (!checkCallingPermission(android.Manifest.permission.READ_INPUT_STATE,
+                "getDPadKeycodeState()")) {
+            throw new SecurityException("Requires READ_INPUT_STATE permission");
+        }
+        return mQueue.getDPadKeycodeState(sw);
+    }
+
     public boolean hasKeys(int[] keycodes, boolean[] keyExists) {
         return KeyInputQueue.hasKeys(keycodes, keyExists);
     }
diff --git a/services/java/com/android/server/status/StatusBarService.java b/services/java/com/android/server/status/StatusBarService.java
index 8d73904..1db20df 100644
--- a/services/java/com/android/server/status/StatusBarService.java
+++ b/services/java/com/android/server/status/StatusBarService.java
@@ -85,10 +85,8 @@
 public class StatusBarService extends IStatusBar.Stub
 {
     static final String TAG = "StatusBar";
-    static final boolean DEBUG = false;
     static final boolean SPEW = false;
-    static final boolean DBG = false;
-        
+
     static final int EXPANDED_LEAVE_ALONE = -10000;
     static final int EXPANDED_FULL_OPEN = -10001;
 
@@ -656,7 +654,7 @@
 
     /* private */ void performAddUpdateIcon(IBinder key, IconData data, NotificationData n)
                         throws StatusBarException {
-        if (DBG) {
+        if (SPEW) {
             Log.d(TAG, "performAddUpdateIcon icon=" + data + " notification=" + n + " key=" + key);
         }
         // notification
@@ -748,7 +746,7 @@
 
     /* private */ void performSetIconVisibility(IBinder key, boolean visible) {
         synchronized (mIconMap) {
-            if (DBG) {
+            if (SPEW) {
                 Log.d(TAG, "performSetIconVisibility key=" + key + " visible=" + visible);
             }
             StatusBarIcon icon = mIconMap.get(key);
@@ -758,7 +756,7 @@
     
     /* private */ void performRemoveIcon(IBinder key) {
         synchronized (this) {
-            if (DBG) {
+            if (SPEW) {
                 Log.d(TAG, "performRemoveIcon key=" + key);
             }
             StatusBarIcon icon = mIconMap.remove(key);
@@ -997,7 +995,7 @@
     }
     
     void performExpand() {
-        if (SPEW) Log.d(TAG, "Perform expand: expanded=" + mExpanded);
+        if (SPEW) Log.d(TAG, "performExpand: mExpanded=" + mExpanded);
         if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) {
             return ;
         }
@@ -1022,8 +1020,8 @@
     }
 
     void performCollapse() {
-        if (SPEW) Log.d(TAG, "Perform collapse: expanded=" + mExpanded
-                + " expanded visible=" + mExpandedVisible);
+        if (SPEW) Log.d(TAG, "performCollapse: mExpanded=" + mExpanded
+                + " mExpandedVisible=" + mExpandedVisible);
         
         if (!mExpandedVisible) {
             return;
@@ -1668,7 +1666,7 @@
         // act accordingly
         if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) {
             if ((net & StatusBarManager.DISABLE_EXPAND) != 0) {
-                performCollapse();
+                animateCollapse();
             }
         }
         if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {