Merge change I813fdb7a into eclair

* changes:
  Fixes for proximity sensor behavior:
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/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index b116bf8..467812e 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -178,15 +178,16 @@
      * null.
      */
     Resources getTopLevelResources(String resDir, CompatibilityInfo compInfo) {
+        ResourcesKey key = new ResourcesKey(resDir, compInfo.applicationScale);
+        Resources r;
         synchronized (mPackages) {
             // Resources is app scale dependent.
-            ResourcesKey key = new ResourcesKey(resDir, compInfo.applicationScale);
             if (false) {
                 Log.w(TAG, "getTopLevelResources: " + resDir + " / "
                         + compInfo.applicationScale);
             }
             WeakReference<Resources> wr = mActiveResources.get(key);
-            Resources r = wr != null ? wr.get() : null;
+            r = wr != null ? wr.get() : null;
             if (r != null && r.getAssets().isUpToDate()) {
                 if (false) {
                     Log.w(TAG, "Returning cached resources " + r + " " + resDir
@@ -194,25 +195,37 @@
                 }
                 return r;
             }
+        }
 
-            //if (r != null) {
-            //    Log.w(TAG, "Throwing away out-of-date resources!!!! "
-            //            + r + " " + resDir);
-            //}
+        //if (r != null) {
+        //    Log.w(TAG, "Throwing away out-of-date resources!!!! "
+        //            + r + " " + resDir);
+        //}
 
-            AssetManager assets = new AssetManager();
-            if (assets.addAssetPath(resDir) == 0) {
-                return null;
+        AssetManager assets = new AssetManager();
+        if (assets.addAssetPath(resDir) == 0) {
+            return null;
+        }
+
+        //Log.i(TAG, "Resource: key=" + key + ", display metrics=" + metrics);
+        DisplayMetrics metrics = getDisplayMetricsLocked(false);
+        r = new Resources(assets, metrics, getConfiguration(), compInfo);
+        if (false) {
+            Log.i(TAG, "Created app resources " + resDir + " " + r + ": "
+                    + r.getConfiguration() + " appScale="
+                    + r.getCompatibilityInfo().applicationScale);
+        }
+        
+        synchronized (mPackages) {
+            WeakReference<Resources> wr = mActiveResources.get(key);
+            Resources existing = wr != null ? wr.get() : null;
+            if (existing != null && existing.getAssets().isUpToDate()) {
+                // Someone else already created the resources while we were
+                // unlocked; go ahead and use theirs.
+                r.getAssets().close();
+                return existing;
             }
-
-            //Log.i(TAG, "Resource: key=" + key + ", display metrics=" + metrics);
-            DisplayMetrics metrics = getDisplayMetricsLocked(false);
-            r = new Resources(assets, metrics, getConfiguration(), compInfo);
-            if (false) {
-                Log.i(TAG, "Created app resources " + resDir + " " + r + ": "
-                        + r.getConfiguration() + " appScale="
-                        + r.getCompatibilityInfo().applicationScale);
-            }
+            
             // XXX need to remove entries when weak references go away
             mActiveResources.put(key, new WeakReference<Resources>(r));
             return r;
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/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/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 8698cb7..5199ada 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -57,7 +57,7 @@
     private static final int MAGIC = 0xBA757475; // 'BATSTATS' 
 
     // Current on-disk Parcel version
-    private static final int VERSION = 41;
+    private static final int VERSION = 42;
 
     private static int sNumSpeedSteps;
 
diff --git a/core/java/com/android/internal/widget/SlidingTab.java b/core/java/com/android/internal/widget/SlidingTab.java
index b7dd27d..cb67bfc 100644
--- a/core/java/com/android/internal/widget/SlidingTab.java
+++ b/core/java/com/android/internal/widget/SlidingTab.java
@@ -17,6 +17,7 @@
 package com.android.internal.widget;
 
 import android.content.Context;
+import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.graphics.Canvas;
@@ -150,6 +151,14 @@
     // TODO: For debugging; remove after glitches debugged.
     @Override
     protected void dispatchDraw(Canvas canvas) {
+        int orientation = getResources().getConfiguration().orientation;
+        if (mOrientation == HORIZONTAL && orientation != Configuration.ORIENTATION_PORTRAIT
+                || mOrientation == VERTICAL && orientation != Configuration.ORIENTATION_LANDSCAPE) {
+            // UBER HACK ALERT.  This is a workaround for a configuration race condition between
+            // orientation changed notification and the resize notification. This just prevents
+            // us from drawing under this circumstance, though the view will still be wrong.
+            return;
+        }
         super.dispatchDraw(canvas);
     }
 
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);
     }