Merge change 1406 into donut

* changes:
  Internal APIs to get/set SMSC address.
diff --git a/api/current.xml b/api/current.xml
index f809c09..14faadc 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -5113,6 +5113,17 @@
  visibility="public"
 >
 </field>
+<field name="maxSdkVersion"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843377"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="maxWidth"
  type="int"
  transient="false"
@@ -7192,6 +7203,17 @@
  visibility="public"
 >
 </field>
+<field name="targetSdkVersion"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843376"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="taskAffinity"
  type="int"
  transient="false"
@@ -31852,6 +31874,28 @@
  visibility="public"
 >
 </field>
+<field name="FLAG_TARGETS_SDK"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="256"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="FLAG_UPDATED_SYSTEM_APP"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="128"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="className"
  type="java.lang.String"
  transient="false"
@@ -34085,6 +34129,17 @@
  visibility="public"
 >
 </field>
+<field name="INSTALL_FAILED_NEWER_SDK"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="-14"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="INSTALL_FAILED_NO_SHARED_USER"
  type="int"
  transient="false"
@@ -86088,6 +86143,16 @@
  visibility="public"
 >
 </constructor>
+<field name="CODENAME"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="INCREMENTAL"
  type="java.lang.String"
  transient="false"
@@ -86114,6 +86179,66 @@
  volatile="false"
  static="true"
  final="true"
+ deprecated="deprecated"
+ visibility="public"
+>
+</field>
+<field name="SDK_INT"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<class name="Build.VERSION_CODES"
+ extends="java.lang.Object"
+ abstract="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="Build.VERSION_CODES"
+ type="android.os.Build.VERSION_CODES"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+<field name="BASE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="BASE_1_1"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="CUPCAKE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="3"
+ static="true"
+ final="true"
  deprecated="not deprecated"
  visibility="public"
 >
diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp
index 96ee502..f85ea9f8 100644
--- a/camera/libcameraservice/CameraService.cpp
+++ b/camera/libcameraservice/CameraService.cpp
@@ -915,24 +915,24 @@
 void CameraService::Client::postAutoFocus(bool focused)
 {
     LOGV("postAutoFocus");
-    mCameraClient->autoFocusCallback(focused);
+    mCameraClient->notifyCallback(CAMERA_MSG_FOCUS, (int32_t)focused, 0);
 }
 
 void CameraService::Client::postShutter()
 {
-    mCameraClient->shutterCallback();
+    mCameraClient->notifyCallback(CAMERA_MSG_SHUTTER, 0, 0);
 }
 
 void CameraService::Client::postRaw(const sp<IMemory>& mem)
 {
     LOGD("postRaw");
-    mCameraClient->rawCallback(mem);
+    mCameraClient->dataCallback(CAMERA_MSG_RAW_IMAGE, mem);
 }
 
 void CameraService::Client::postJpeg(const sp<IMemory>& mem)
 {
     LOGD("postJpeg");
-    mCameraClient->jpegCallback(mem);
+    mCameraClient->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, mem);
 }
 
 void CameraService::Client::copyFrameAndPostCopiedFrame(sp<IMemoryHeap> heap, size_t offset, size_t size)
@@ -960,7 +960,7 @@
         LOGE("failed to allocate space for frame callback");
         return;
     }
-    mCameraClient->previewCallback(frame);
+    mCameraClient->dataCallback(CAMERA_MSG_PREVIEW_FRAME, frame);
 }
 
 void CameraService::Client::postRecordingFrame(const sp<IMemory>& frame)
@@ -970,7 +970,7 @@
         LOGW("frame is a null pointer");
         return;
     }
-    mCameraClient->recordingCallback(frame);
+    mCameraClient->dataCallback(CAMERA_MSG_VIDEO_FRAME, frame);
 }
 
 void CameraService::Client::postPreviewFrame(const sp<IMemory>& mem)
@@ -1004,7 +1004,7 @@
         copyFrameAndPostCopiedFrame(heap, offset, size);
     } else {
         LOGV("frame is directly sent out without copying");
-        mCameraClient->previewCallback(mem);
+        mCameraClient->dataCallback(CAMERA_MSG_PREVIEW_FRAME, mem);
     }
 
     // Is this is one-shot only?
@@ -1018,7 +1018,7 @@
 
 void CameraService::Client::postError(status_t error)
 {
-    mCameraClient->errorCallback(error);
+    mCameraClient->notifyCallback(CAMERA_MSG_ERROR, error, 0);
 }
 
 status_t CameraService::dump(int fd, const Vector<String16>& args)
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index 161bb46..04e69e3 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -537,6 +537,9 @@
         case PackageManager.INSTALL_FAILED_CONFLICTING_PROVIDER:
             s = "INSTALL_FAILED_CONFLICTING_PROVIDER";
             break;
+        case PackageManager.INSTALL_FAILED_NEWER_SDK:
+            s = "INSTALL_FAILED_NEWER_SDK";
+            break;
         case PackageManager.INSTALL_PARSE_FAILED_NOT_APK:
             s = "INSTALL_PARSE_FAILED_NOT_APK";
             break;
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index 0aa5975..a174843 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -325,6 +325,14 @@
         
         // show the dialog. this will call onStart().
         if (!isShowing()) {
+            // First make sure the keyboard is showing (if needed), so that we get the right height
+            // for the dropdown to respect the IME.
+            if (getContext().getResources().getConfiguration().hardKeyboardHidden ==
+                Configuration.HARDKEYBOARDHIDDEN_YES) {
+                InputMethodManager inputManager = (InputMethodManager)
+                getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+                        inputManager.showSoftInputUnchecked(0, null);
+            }
             show();
         }
 
@@ -528,13 +536,16 @@
         mSearchAutoComplete.setDropDownAnimationStyle(0); // no animation
         mSearchAutoComplete.setThreshold(mSearchable.getSuggestThreshold());
 
-        // TODO: Use different dropdown background resource for in-app search.
         if (mGlobalSearchMode) {
             mSearchAutoComplete.setDropDownAlwaysVisible(true);  // fill space until results come in
             mSearchAutoComplete.setDropDownDismissedOnCompletion(false);
+            mSearchAutoComplete.setDropDownBackgroundResource(
+                    com.android.internal.R.drawable.search_dropdown_background);
         } else {
             mSearchAutoComplete.setDropDownAlwaysVisible(false);
             mSearchAutoComplete.setDropDownDismissedOnCompletion(true);
+            mSearchAutoComplete.setDropDownBackgroundResource(
+                    com.android.internal.R.drawable.search_dropdown_background_apps);
         }
 
         // attach the suggestions adapter, if suggestions are available
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 3ebf816..81f72ac 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1940,7 +1940,7 @@
     /**
      * If set, this marks a point in the task's activity stack that should
      * be cleared when the task is reset.  That is, the next time the task
-     * is broad to the foreground with
+     * is brought to the foreground with
      * {@link #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED} (typically as a result of
      * the user re-launching it from home), this activity and all on top of
      * it will be finished so that the user does not return to them, but
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 173057c..fa9ec6e 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -113,19 +113,25 @@
      */
     public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
     
-    
     /**
-     * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
-     *  {@hide}
+     * Value for {@link #flags}: this is set if this application has been
+     * install as an update to a built-in system application.
      */
     public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
+    
+    /**
+     * Value for {@link #flags}: this is set of the application has set
+     * its android:targetSdkVersion to something >= the current SDK version.
+     */
+    public static final int FLAG_TARGETS_SDK = 1<<8;
 
     /**
      * Flags associated with the application.  Any combination of
      * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
      * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
      * {@link #FLAG_ALLOW_TASK_REPARENTING}
-     * {@link #FLAG_ALLOW_CLEAR_USER_DATA}.
+     * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
+     * {@link #FLAG_TARGETS_SDK}.
      */
     public int flags = 0;
     
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 9e06666..e2f0ce4 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -172,6 +172,14 @@
     public static final int GET_SUPPORTS_DENSITIES    = 0x00008000;
 
     /**
+     * Resolution and querying flag: if set, only filters that support the
+     * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
+     * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
+     * supplied Intent.
+     */
+    public static final int MATCH_DEFAULT_ONLY   = 0x00010000;
+
+    /**
      * Permission check result: this is returned by {@link #checkPermission}
      * if the permission has been granted to the given package.
      */
@@ -219,14 +227,6 @@
      */
     public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
 
-    /**
-     * Resolution and querying flag: if set, only filters that support the
-     * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
-     * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
-     * supplied Intent.
-     */
-    public static final int MATCH_DEFAULT_ONLY   = 0x00010000;
-
     public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
     public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
     public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
@@ -355,6 +355,14 @@
     public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
 
     /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
+     * the new package failed because the current SDK version is newer than
+     * that required by the package.
+     */
+    public static final int INSTALL_FAILED_NEWER_SDK = -14;
+
+    /**
      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
      * if the parser was given a path that is not a file, or does not end with the expected
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index f9c4984..12df5bd 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -59,6 +59,7 @@
     private String mArchiveSourcePath;
     private String[] mSeparateProcesses;
     private int mSdkVersion;
+    private String mSdkCodename;
 
     private int mParseError = PackageManager.INSTALL_SUCCEEDED;
 
@@ -123,8 +124,9 @@
         mSeparateProcesses = procs;
     }
 
-    public void setSdkVersion(int sdkVersion) {
+    public void setSdkVersion(int sdkVersion, String codename) {
         mSdkVersion = sdkVersion;
+        mSdkCodename = codename;
     }
 
     private static final boolean isPackageFilename(String name) {
@@ -613,9 +615,9 @@
         int type;
 
         final Package pkg = new Package(pkgName);
-        pkg.mSystem = (flags&PARSE_IS_SYSTEM) != 0;
         boolean foundApp = false;
-
+        boolean targetsSdk = false;
+        
         TypedArray sa = res.obtainAttributes(attrs,
                 com.android.internal.R.styleable.AndroidManifest);
         pkg.mVersionCode = sa.getInteger(
@@ -721,19 +723,74 @@
 
                 XmlUtils.skipCurrentTag(parser);
 
-            }  else if (tagName.equals("uses-sdk")) {
+            } else if (tagName.equals("uses-sdk")) {
                 if (mSdkVersion > 0) {
                     sa = res.obtainAttributes(attrs,
                             com.android.internal.R.styleable.AndroidManifestUsesSdk);
 
-                    int vers = sa.getInt(
-                            com.android.internal.R.styleable.AndroidManifestUsesSdk_minSdkVersion, 0);
+                    int minVers = 0;
+                    String minCode = null;
+                    int targetVers = 0;
+                    String targetCode = null;
+                    
+                    TypedValue val = sa.peekValue(
+                            com.android.internal.R.styleable.AndroidManifestUsesSdk_minSdkVersion);
+                    if (val != null) {
+                        if (val.type == TypedValue.TYPE_STRING && val.string != null) {
+                            targetCode = minCode = val.string.toString();
+                        } else {
+                            // If it's not a string, it's an integer.
+                            minVers = val.data;
+                        }
+                    }
+                    
+                    val = sa.peekValue(
+                            com.android.internal.R.styleable.AndroidManifestUsesSdk_targetSdkVersion);
+                    if (val != null) {
+                        if (val.type == TypedValue.TYPE_STRING && val.string != null) {
+                            targetCode = minCode = val.string.toString();
+                        } else {
+                            // If it's not a string, it's an integer.
+                            targetVers = val.data;
+                        }
+                    }
+                    
+                    int maxVers = sa.getInt(
+                            com.android.internal.R.styleable.AndroidManifestUsesSdk_maxSdkVersion,
+                            mSdkVersion);
 
                     sa.recycle();
 
-                    if (vers > mSdkVersion) {
-                        outError[0] = "Requires newer sdk version #" + vers
-                            + " (current version is #" + mSdkVersion + ")";
+                    if (targetCode != null) {
+                        if (!targetCode.equals(mSdkCodename)) {
+                            if (mSdkCodename != null) {
+                                outError[0] = "Requires development platform " + targetCode
+                                        + " (current platform is " + mSdkCodename + ")";
+                            } else {
+                                outError[0] = "Requires development platform " + targetCode
+                                        + " but this is a release platform.";
+                            }
+                            mParseError = PackageManager.INSTALL_FAILED_OLDER_SDK;
+                            return null;
+                        }
+                        // If the code matches, it definitely targets this SDK.
+                        targetsSdk = true;
+                    } else if (targetVers >= mSdkVersion) {
+                        // If they have explicitly targeted our current version
+                        // or something after it, then note this.
+                        targetsSdk = true;
+                    }
+                    
+                    if (minVers > mSdkVersion) {
+                        outError[0] = "Requires newer sdk version #" + minVers
+                                + " (current version is #" + mSdkVersion + ")";
+                        mParseError = PackageManager.INSTALL_FAILED_OLDER_SDK;
+                        return null;
+                    }
+                    
+                    if (maxVers < mSdkVersion) {
+                        outError[0] = "Requires older sdk version #" + maxVers
+                                + " (current version is #" + mSdkVersion + ")";
                         mParseError = PackageManager.INSTALL_FAILED_OLDER_SDK;
                         return null;
                     }
@@ -767,6 +824,10 @@
             mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_EMPTY;
         }
 
+        if (targetsSdk) {
+            pkg.applicationInfo.flags |= ApplicationInfo.FLAG_TARGETS_SDK;
+        }
+        
         if (pkg.usesLibraries.size() > 0) {
             pkg.usesLibraryFiles = new String[pkg.usesLibraries.size()];
             pkg.usesLibraries.toArray(pkg.usesLibraryFiles);
@@ -2133,9 +2194,6 @@
         // If this is a 3rd party app, this is the path of the zip file.
         public String mPath;
 
-        // True if this package is part of the system image.
-        public boolean mSystem;
-
         // The version code declared for this package.
         public int mVersionCode;
         
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 467c17f..5487c54 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -59,11 +59,47 @@
         public static final String RELEASE = getString("ro.build.version.release");
 
         /**
-         * The user-visible SDK version of the framework. It is an integer starting at 1.
+         * The user-visible SDK version of the framework in its raw String
+         * representation; use {@link #SDK_INT} instead.
+         * 
+         * @deprecated Use {@link #SDK_INT} to easily get this as an integer.
          */
         public static final String SDK = getString("ro.build.version.sdk");
+
+        /**
+         * The user-visible SDK version of the framework; its possible
+         * values are defined in {@link Build.VERSION_CODES}.
+         */
+        public static final int SDK_INT = SystemProperties.getInt(
+                "ro.build.version.sdk", 0);
+
+        /**
+         * The current development codename, or the string "REL" if this is
+         * a release build.
+         */
+        public static final String CODENAME = getString("ro.build.version.codename");
     }
 
+    /**
+     * Enumeration of the currently known SDK version codes.  These are the
+     * values that can be found in {@link VERSION#SDK}.  Version numbers
+     * increment monotonically with each official platform release.
+     */
+    public static class VERSION_CODES {
+        /**
+         * October 2008: The original, first, version of Android.  Yay!
+         */
+        public static final int BASE = 1;
+        /**
+         * February 2009: First Android update, officially called 1.1.
+         */
+        public static final int BASE_1_1 = 2;
+        /**
+         * May 2009: Android 1.5.
+         */
+        public static final int CUPCAKE = 3;
+    }
+    
     /** The type of build, like "user" or "eng". */
     public static final String TYPE = getString("ro.build.type");
 
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index d042f28d..410adb0 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -850,6 +850,28 @@
     public static final int HAPTIC_FEEDBACK_ENABLED = 0x10000000;
 
     /**
+     * View flag indicating whether this view was invalidated (fully or partially.)
+     *
+     * @hide
+     */
+    static final int DIRTY = 0x20000000;
+
+    /**
+     * View flag indicating whether this view was invalidated by an opaque
+     * invalidate request.
+     *
+     * @hide
+     */
+    static final int DIRTY_OPAQUE = 0x40000000;
+
+    /**
+     * Mask for {@link #DIRTY} and {@link #DIRTY_OPAQUE}.
+     *
+     * @hide
+     */
+    static final int DIRTY_MASK = 0x60000000;
+
+    /**
      * Use with {@link #focusSearch}. Move focus to the previous selectable
      * item.
      */
@@ -4522,6 +4544,23 @@
     }
 
     /**
+     * Indicates whether this View is opaque. An opaque View guarantees that it will
+     * draw all the pixels overlapping its bounds using a fully opaque color.
+     *
+     * Subclasses of View should override this method whenever possible to indicate
+     * whether an instance is opaque. Opaque Views are treated in a special way by
+     * the View hierarchy, possibly allowing it to perform optimizations during
+     * invalidate/draw passes.
+     * 
+     * @return True if this View is guaranteed to be fully opaque, false otherwise.
+     *
+     * @hide Pending API council approval
+     */
+    public boolean isOpaque() {
+        return mBGDrawable != null && mBGDrawable.getOpacity() == PixelFormat.OPAQUE;
+    }
+
+    /**
      * @return A handler associated with the thread running the View. This
      * handler can be used to pump events in the UI events queue.
      */
@@ -5687,7 +5726,7 @@
             final int restoreCount = canvas.save();
             canvas.translate(-mScrollX, -mScrollY);
 
-            mPrivateFlags |= DRAWN;
+            mPrivateFlags = (mPrivateFlags & ~DIRTY_MASK) | DRAWN; 
 
             // Fast path for layouts with no backgrounds
             if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
@@ -5875,7 +5914,8 @@
             ViewDebug.trace(this, ViewDebug.HierarchyTraceType.DRAW);
         }
 
-        mPrivateFlags |= DRAWN;                    
+        final boolean dirtyOpaque = (mPrivateFlags & DIRTY_MASK) == DIRTY_OPAQUE;
+        mPrivateFlags = (mPrivateFlags & ~DIRTY_MASK) | DRAWN;
 
         /*
          * Draw traversal performs several drawing steps which must be executed
@@ -5892,22 +5932,24 @@
         // Step 1, draw the background, if needed
         int saveCount;
 
-        final Drawable background = mBGDrawable;
-        if (background != null) {
-            final int scrollX = mScrollX;
-            final int scrollY = mScrollY;
+        if (!dirtyOpaque) {
+            final Drawable background = mBGDrawable;
+            if (background != null) {
+                final int scrollX = mScrollX;
+                final int scrollY = mScrollY;
 
-            if (mBackgroundSizeChanged) {
-                background.setBounds(0, 0,  mRight - mLeft, mBottom - mTop);
-                mBackgroundSizeChanged = false;
-            }
+                if (mBackgroundSizeChanged) {
+                    background.setBounds(0, 0,  mRight - mLeft, mBottom - mTop);
+                    mBackgroundSizeChanged = false;
+                }
 
-            if ((scrollX | scrollY) == 0) {
-                background.draw(canvas);
-            } else {
-                canvas.translate(scrollX, scrollY);
-                background.draw(canvas);
-                canvas.translate(-scrollX, -scrollY);
+                if ((scrollX | scrollY) == 0) {
+                    background.draw(canvas);
+                } else {
+                    canvas.translate(scrollX, scrollY);
+                    background.draw(canvas);
+                    canvas.translate(-scrollX, -scrollY);
+                }
             }
         }
 
@@ -5917,7 +5959,7 @@
         boolean verticalEdges = (viewFlags & FADING_EDGE_VERTICAL) != 0;
         if (!verticalEdges && !horizontalEdges) {
             // Step 3, draw the content
-            onDraw(canvas);
+            if (!dirtyOpaque) onDraw(canvas);
 
             // Step 4, draw the children
             dispatchDraw(canvas);
@@ -6020,7 +6062,7 @@
         }
 
         // Step 3, draw the content
-        onDraw(canvas);
+        if (!dirtyOpaque) onDraw(canvas);
 
         // Step 4, draw the children
         dispatchDraw(canvas);
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index e686d1c..31159d7 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -1796,7 +1796,7 @@
             boolean preventRequestLayout) {
         child.mParent = null;
         addViewInner(child, index, params, preventRequestLayout);
-        child.mPrivateFlags |= DRAWN;
+        child.mPrivateFlags = (child.mPrivateFlags & ~DIRTY_MASK) | DRAWN;
         return true;
     }
 
@@ -2210,7 +2210,7 @@
         addInArray(child, index);
 
         child.mParent = this;
-        child.mPrivateFlags |= DRAWN;
+        child.mPrivateFlags = (child.mPrivateFlags & ~DIRTY_MASK) | DRAWN;
 
         if (child.hasFocus()) {
             requestChildFocus(child, child.findFocus());
@@ -2320,15 +2320,33 @@
             // ourselves and the parent to make sure the invalidate request goes
             // through
             final boolean drawAnimation = (child.mPrivateFlags & DRAW_ANIMATION) == DRAW_ANIMATION;
-    
+
+            // Check whether the child that requests the invalidate is fully opaque
+            final boolean isOpaque = child.isOpaque();
+            // Mark the child as dirty, using the appropriate flag
+            // Make sure we do not set both flags at the same time
+            final int opaqueFlag = isOpaque ? DIRTY_OPAQUE : DIRTY;
+
             do {
+                View view = null;
+                if (parent instanceof View) {
+                    view = (View) parent;
+                }
+
                 if (drawAnimation) {
-                    if (parent instanceof View) {
-                        ((View) parent).mPrivateFlags |= DRAW_ANIMATION;
+                    if (view != null) {
+                        view.mPrivateFlags |= DRAW_ANIMATION;
                     } else if (parent instanceof ViewRoot) {
                         ((ViewRoot) parent).mIsAnimating = true;
                     }
                 }
+
+                // If the parent is dirty opaque or not dirty, mark it dirty with the opaque
+                // flag coming from the child that initiated the invalidate
+                if (view != null && (view.mPrivateFlags & DIRTY_MASK) != DIRTY) {
+                    view.mPrivateFlags = (view.mPrivateFlags & ~DIRTY_MASK) | opaqueFlag;
+                }
+
                 parent = parent.invalidateChildInParent(location, dirty);
             } while (parent != null);
         }
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 0b03626..819bc31 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -539,6 +539,7 @@
             }
             dirty = mTempRect;
         }
+        // TODO: When doing a union with mDirty != empty, we must cancel all the DIRTY_OPAQUE flags
         mDirty.union(dirty);
         if (!mWillDrawSoon) {
             scheduleTraversals();
diff --git a/core/java/android/webkit/CallbackProxy.java b/core/java/android/webkit/CallbackProxy.java
index 5f8acc8..17d3f94 100644
--- a/core/java/android/webkit/CallbackProxy.java
+++ b/core/java/android/webkit/CallbackProxy.java
@@ -98,6 +98,7 @@
     private static final int SCALE_CHANGED        = 123;
     private static final int RECEIVED_CERTIFICATE = 124;
     private static final int SWITCH_OUT_HISTORY   = 125;
+    private static final int JS_TIMEOUT           = 126;
 
     // Message triggered by the client to resume execution
     private static final int NOTIFY               = 200;
@@ -530,6 +531,18 @@
                 }
                 break;
 
+            case JS_TIMEOUT:
+                if(mWebChromeClient != null) {
+                    final JsResult res = (JsResult) msg.obj;
+                    if(mWebChromeClient.onJsTimeout()) {
+                        res.confirm();
+                    } else {
+                        res.cancel();
+                    }
+                    res.setReady();
+                }
+                break;
+
             case RECEIVED_CERTIFICATE:
                 mWebView.setCertificate((SslCertificate) msg.obj);
                 break;
@@ -1022,4 +1035,26 @@
         }
         return result.getResult();
     }
+
+    /**
+     * @hide pending API council approval
+     */
+    public boolean onJsTimeout() {
+        //always interrupt timedout JS by default
+        if (mWebChromeClient == null) {
+            return true;
+        }
+        JsResult result = new JsResult(this, true);
+        Message timeout = obtainMessage(JS_TIMEOUT, result);
+        synchronized (this) {
+            sendMessage(timeout);
+            try {
+                wait();
+            } catch (InterruptedException e) {
+                Log.e(LOGTAG, "Caught exception while waiting for jsUnload");
+                Log.e(LOGTAG, Log.getStackTraceString(e));
+            }
+        }
+        return result.getResult();
+    }
 }
diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java
index c0c6775..e8c2279 100644
--- a/core/java/android/webkit/CookieManager.java
+++ b/core/java/android/webkit/CookieManager.java
@@ -647,8 +647,6 @@
                     // another file in the local web server directory. Still
                     // "localhost" is the best pseudo domain name.
                     ret[0] = "localhost";
-                } else if (!ret[0].equals("localhost")) {
-                    return null;
                 }
             } else if (index == ret[0].lastIndexOf(PERIOD)) {
                 // cookie host must have at least two periods
diff --git a/core/java/android/webkit/WebChromeClient.java b/core/java/android/webkit/WebChromeClient.java
index f9400061..9d9763c 100644
--- a/core/java/android/webkit/WebChromeClient.java
+++ b/core/java/android/webkit/WebChromeClient.java
@@ -157,4 +157,19 @@
             JsResult result) {
         return false;
     }
+
+    /**
+     * Tell the client that a JavaScript execution timeout has occured. And the
+     * client may decide whether or not to interrupt the execution. If the
+     * client returns true, the JavaScript will be interrupted. If the client
+     * returns false, the execution will continue. Note that in the case of
+     * continuing execution, the timeout counter will be reset, and the callback
+     * will continue to occur if the script does not finish at the next check
+     * point.
+     * @return boolean Whether the JavaScript execution should be interrupted.
+     * @hide pending API Council approval
+     */
+    public boolean onJsTimeout() {
+        return true;
+    }
 }
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 58d8ae7..e9df453 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -263,6 +263,16 @@
         return mCallbackProxy.onJsBeforeUnload(url, message);
     }
 
+    /**
+     *
+     * Callback to notify that a JavaScript execution timeout has occured.
+     * @return True if the JavaScript execution should be interrupted. False
+     *         will continue the execution.
+     */
+    protected boolean jsInterrupt() {
+        return mCallbackProxy.onJsTimeout();
+    }
+
     //-------------------------------------------------------------------------
     // JNI methods
     //-------------------------------------------------------------------------
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 767c7e7..ffb6785 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -1947,7 +1947,7 @@
                 if (y != mLastY) {
                     deltaY -= mMotionCorrection;
                     int incrementalDeltaY = mLastY != Integer.MIN_VALUE ? y - mLastY : deltaY;
-                    trackMotionScroll(deltaY, incrementalDeltaY);
+                    trackMotionScroll(deltaY, incrementalDeltaY, true);
 
                     // Check to see if we have bumped into the scroll limit
                     View motionView = this.getChildAt(mMotionPosition - mFirstPosition);
@@ -2286,7 +2286,7 @@
                 delta = Math.max(-(getHeight() - mPaddingBottom - mPaddingTop - 1), delta);
             }
 
-            trackMotionScroll(delta, delta);
+            trackMotionScroll(delta, delta, false);
 
             // Check to see if we have bumped into the scroll limit
             View motionView = getChildAt(mMotionPosition - mFirstPosition);
@@ -2299,6 +2299,7 @@
             }
 
             if (more) {
+                invalidate();
                 mLastFlingY = y;
                 post(this);
             } else {
@@ -2323,6 +2324,7 @@
 
     private void clearScrollingCache() {
         if (mCachingStarted) {
+            mCachingStarted = false;
             setChildrenDrawnWithCacheEnabled(false);
             if ((mPersistentDrawingCache & PERSISTENT_SCROLLING_CACHE) == 0) {
                 setChildrenDrawingCacheEnabled(false);
@@ -2330,7 +2332,6 @@
             if (!isAlwaysDrawnWithCacheEnabled()) {
                 invalidate();
             }
-            mCachingStarted = false;
         }
     }
 
@@ -2340,8 +2341,9 @@
      * @param deltaY Amount to offset mMotionView. This is the accumulated delta since the motion
      *        began. Positive numbers mean the user's finger is moving down the screen.
      * @param incrementalDeltaY Change in deltaY from the previous event.
+     * @param invalidate True to make this method call invalidate(), false otherwise.
      */
-    void trackMotionScroll(int deltaY, int incrementalDeltaY) {
+    void trackMotionScroll(int deltaY, int incrementalDeltaY, boolean invalidate) {
         final int childCount = getChildCount();
         if (childCount == 0) {
             return;
@@ -2375,7 +2377,7 @@
         if (spaceAbove >= absIncrementalDeltaY && spaceBelow >= absIncrementalDeltaY) {
             hideSelector();
             offsetChildrenTopAndBottom(incrementalDeltaY);
-            invalidate();
+            if (invalidate) invalidate();
             mMotionViewNewTop = mMotionViewOriginalTop + deltaY;
         } else {
             final int firstPosition = mFirstPosition;
@@ -2453,7 +2455,7 @@
                 mFirstPosition += count;
             }
 
-            invalidate();
+            if (invalidate) invalidate();
             fillGap(down);
             mBlockLayoutRequests = false;
 
@@ -2788,7 +2790,7 @@
         int screenHeight = getResources().getDisplayMetrics().heightPixels;
         final int[] xy = new int[2];
         getLocationOnScreen(xy);
-        // TODO: The 20 below should come from the theme and be expressed in dip
+        // TODO: The 20 below should come from the theme
         // TODO: And the gravity should be defined in the theme as well
         final int bottomGap = screenHeight - xy[1] - getHeight() + (int) (mDensityScale * 20);
         if (!mPopup.isShowing()) {
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java
index 66c162e..5472d68 100644
--- a/core/java/android/widget/ListView.java
+++ b/core/java/android/widget/ListView.java
@@ -20,6 +20,7 @@
 import android.content.res.TypedArray;
 import android.graphics.Canvas;
 import android.graphics.Rect;
+import android.graphics.PixelFormat;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.ColorDrawable;
 import android.os.Parcel;
@@ -113,7 +114,11 @@
 
     Drawable mDivider;
     int mDividerHeight;
+
+    private boolean mIsCacheColorOpaque;
+    private boolean mDividerIsOpaque;
     private boolean mClipDivider;
+
     private boolean mHeaderDividersEnabled;
     private boolean mFooterDividersEnabled;
 
@@ -2776,6 +2781,20 @@
         return mItemsCanFocus;
     }
 
+    /**
+     * @hide Pending API council approval.
+     */
+    @Override
+    public boolean isOpaque() {
+        return (mCachingStarted && mIsCacheColorOpaque && mDividerIsOpaque) || super.isOpaque();
+    }
+
+    @Override
+    public void setCacheColorHint(int color) {
+        mIsCacheColorOpaque = (color >>> 24) == 0xFF;
+        super.setCacheColorHint(color);
+    }
+
     @Override
     protected void dispatchDraw(Canvas canvas) {
         // Draw the dividers
@@ -2897,6 +2916,7 @@
             mClipDivider = false;
         }
         mDivider = divider;
+        mDividerIsOpaque = divider == null || divider.getOpacity() == PixelFormat.OPAQUE;
         requestLayoutIfNecessary();
     }
 
diff --git a/core/jni/android_location_GpsLocationProvider.cpp b/core/jni/android_location_GpsLocationProvider.cpp
index 9c63fd2..004b0e3 100644
--- a/core/jni/android_location_GpsLocationProvider.cpp
+++ b/core/jni/android_location_GpsLocationProvider.cpp
@@ -31,31 +31,31 @@
 static jmethodID method_reportLocation;
 static jmethodID method_reportStatus;
 static jmethodID method_reportSvStatus;
-static jmethodID method_reportSuplStatus;
+static jmethodID method_reportAGpsStatus;
 static jmethodID method_xtraDownloadRequest;
 
 static const GpsInterface* sGpsInterface = NULL;
 static const GpsXtraInterface* sGpsXtraInterface = NULL;
-static const GpsSuplInterface* sGpsSuplInterface = NULL;
+static const AGpsInterface* sAGpsInterface = NULL;
 
 // data written to by GPS callbacks
 static GpsLocation  sGpsLocation;
 static GpsStatus    sGpsStatus;
 static GpsSvStatus  sGpsSvStatus;
-static GpsSuplStatus    sGpsSuplStatus;
+static AGpsStatus   sAGpsStatus;
 
 // a copy of the data shared by android_location_GpsLocationProvider_wait_for_event
 // and android_location_GpsLocationProvider_read_status
 static GpsLocation  sGpsLocationCopy;
 static GpsStatus    sGpsStatusCopy;
 static GpsSvStatus  sGpsSvStatusCopy;
-static GpsSuplStatus    sGpsSuplStatusCopy;
+static AGpsStatus   sAGpsStatusCopy;
 
 enum CallbackType {
     kLocation = 1,
     kStatus = 2,
     kSvStatus = 4,
-    kSuplStatus = 8,
+    kAGpsStatus = 8,
     kXtraDownloadRequest = 16,
     kDisableRequest = 32,
 }; 
@@ -96,12 +96,12 @@
     pthread_mutex_unlock(&sEventMutex);
 }
 
-static void supl_status_callback(GpsSuplStatus* supl_status)
+static void agps_status_callback(AGpsStatus* agps_status)
 {
     pthread_mutex_lock(&sEventMutex);
 
-    sPendingCallbacks |= kSuplStatus;
-    memcpy(&sGpsSuplStatus, supl_status, sizeof(GpsSuplStatus));
+    sPendingCallbacks |= kAGpsStatus;
+    memcpy(&sAGpsStatus, agps_status, sizeof(AGpsStatus));
 
     pthread_cond_signal(&sEventCond);
     pthread_mutex_unlock(&sEventMutex);
@@ -126,15 +126,15 @@
     download_request_callback,
 };
 
-GpsSuplCallbacks sGpsSuplCallbacks = {
-    supl_status_callback,
+AGpsCallbacks sAGpsCallbacks = {
+    agps_status_callback,
 };
 
 static void android_location_GpsLocationProvider_class_init_native(JNIEnv* env, jclass clazz) {
     method_reportLocation = env->GetMethodID(clazz, "reportLocation", "(IDDDFFFJ)V");
     method_reportStatus = env->GetMethodID(clazz, "reportStatus", "(I)V");
     method_reportSvStatus = env->GetMethodID(clazz, "reportSvStatus", "()V");
-    method_reportSuplStatus = env->GetMethodID(clazz, "reportSuplStatus", "(I)V");
+    method_reportAGpsStatus = env->GetMethodID(clazz, "reportAGpsStatus", "(II)V");
     method_xtraDownloadRequest = env->GetMethodID(clazz, "xtraDownloadRequest", "()V");
 }
 
@@ -151,10 +151,10 @@
     if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0)
         return false;
 
-    if (!sGpsSuplInterface)
-        sGpsSuplInterface = (const GpsSuplInterface*)sGpsInterface->get_extension(GPS_SUPL_INTERFACE);
-    if (sGpsSuplInterface)
-        sGpsSuplInterface->init(&sGpsSuplCallbacks);
+    if (!sAGpsInterface)
+        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
+    if (sAGpsInterface)
+        sAGpsInterface->init(&sAGpsCallbacks);
     return true;
 }
 
@@ -187,12 +187,6 @@
     return (sGpsInterface->stop() == 0);
 }
 
-static void android_location_GpsLocationProvider_set_fix_frequency(JNIEnv* env, jobject obj, jint fixFrequency)
-{
-    if (sGpsInterface->set_fix_frequency)
-        sGpsInterface->set_fix_frequency(fixFrequency);
-}
-
 static void android_location_GpsLocationProvider_delete_aiding_data(JNIEnv* env, jobject obj, jint flags)
 {
     sGpsInterface->delete_aiding_data(flags);
@@ -212,7 +206,7 @@
     memcpy(&sGpsLocationCopy, &sGpsLocation, sizeof(sGpsLocationCopy));
     memcpy(&sGpsStatusCopy, &sGpsStatus, sizeof(sGpsStatusCopy));
     memcpy(&sGpsSvStatusCopy, &sGpsSvStatus, sizeof(sGpsSvStatusCopy));
-    memcpy(&sGpsSuplStatusCopy, &sGpsSuplStatus, sizeof(sGpsSuplStatusCopy));
+    memcpy(&sAGpsStatusCopy, &sAGpsStatus, sizeof(sAGpsStatusCopy));
     pthread_mutex_unlock(&sEventMutex);   
 
     if (pendingCallbacks & kLocation) { 
@@ -228,8 +222,8 @@
     if (pendingCallbacks & kSvStatus) {
         env->CallVoidMethod(obj, method_reportSvStatus);
     }
-    if (pendingCallbacks & kSuplStatus) {
-        env->CallVoidMethod(obj, method_reportSuplStatus, sGpsSuplStatusCopy.status);
+    if (pendingCallbacks & kAGpsStatus) {
+        env->CallVoidMethod(obj, method_reportAGpsStatus, sAGpsStatusCopy.type, sAGpsStatusCopy.status);
     }  
     if (pendingCallbacks & kXtraDownloadRequest) {    
         env->CallVoidMethod(obj, method_xtraDownloadRequest);
@@ -299,73 +293,72 @@
     env->ReleaseByteArrayElements(data, bytes, 0);
 }
 
-static void android_location_GpsLocationProvider_supl_data_conn_open(JNIEnv* env, jobject obj, jstring apn)
+static void android_location_GpsLocationProvider_agps_data_conn_open(JNIEnv* env, jobject obj, jstring apn)
 {
-    if (!sGpsSuplInterface) {
-        sGpsSuplInterface = (const GpsSuplInterface*)sGpsInterface->get_extension(GPS_SUPL_INTERFACE);
+    if (!sAGpsInterface) {
+        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
     }
-    if (sGpsSuplInterface) {
+    if (sAGpsInterface) {
         if (apn == NULL) {
             jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
             return;
         }
         const char *apnStr = env->GetStringUTFChars(apn, NULL);
-        sGpsSuplInterface->data_conn_open(apnStr);
+        sAGpsInterface->data_conn_open(apnStr);
         env->ReleaseStringUTFChars(apn, apnStr);
     }
 }
 
-static void android_location_GpsLocationProvider_supl_data_conn_closed(JNIEnv* env, jobject obj)
+static void android_location_GpsLocationProvider_agps_data_conn_closed(JNIEnv* env, jobject obj)
 {
-    if (!sGpsSuplInterface) {
-        sGpsSuplInterface = (const GpsSuplInterface*)sGpsInterface->get_extension(GPS_SUPL_INTERFACE);
+    if (!sAGpsInterface) {
+        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
     }
-    if (sGpsSuplInterface) {
-        sGpsSuplInterface->data_conn_closed();
+    if (sAGpsInterface) {
+        sAGpsInterface->data_conn_closed();
     }
 }
 
-static void android_location_GpsLocationProvider_supl_data_conn_failed(JNIEnv* env, jobject obj)
+static void android_location_GpsLocationProvider_agps_data_conn_failed(JNIEnv* env, jobject obj)
 {
-    if (!sGpsSuplInterface) {
-        sGpsSuplInterface = (const GpsSuplInterface*)sGpsInterface->get_extension(GPS_SUPL_INTERFACE);
+    if (!sAGpsInterface) {
+        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
     }
-    if (sGpsSuplInterface) {
-        sGpsSuplInterface->data_conn_failed();
+    if (sAGpsInterface) {
+        sAGpsInterface->data_conn_failed();
     }
 }
 
-static void android_location_GpsLocationProvider_set_supl_server(JNIEnv* env, jobject obj,
-        jint addr, jint port)
+static void android_location_GpsLocationProvider_set_agps_server(JNIEnv* env, jobject obj,
+        jint type, jint addr, jint port)
 {
-    if (!sGpsSuplInterface) {
-        sGpsSuplInterface = (const GpsSuplInterface*)sGpsInterface->get_extension(GPS_SUPL_INTERFACE);
+    if (!sAGpsInterface) {
+        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
     }
-    if (sGpsSuplInterface) {
-        sGpsSuplInterface->set_server(addr, port);
+    if (sAGpsInterface) {
+        sAGpsInterface->set_server(type, addr, port);
     }
 }
 
 static JNINativeMethod sMethods[] = {
      /* name, signature, funcPtr */
     {"class_init_native", "()V", (void *)android_location_GpsLocationProvider_class_init_native},
-	{"native_is_supported", "()Z", (void*)android_location_GpsLocationProvider_is_supported},
-	{"native_init", "()Z", (void*)android_location_GpsLocationProvider_init},
-	{"native_disable", "()V", (void*)android_location_GpsLocationProvider_disable},
-	{"native_cleanup", "()V", (void*)android_location_GpsLocationProvider_cleanup},
-	{"native_start", "(IZI)Z", (void*)android_location_GpsLocationProvider_start},
-	{"native_stop", "()Z", (void*)android_location_GpsLocationProvider_stop},
-	{"native_set_fix_frequency", "(I)V", (void*)android_location_GpsLocationProvider_set_fix_frequency},
-	{"native_delete_aiding_data", "(I)V", (void*)android_location_GpsLocationProvider_delete_aiding_data},
-	{"native_wait_for_event", "()V", (void*)android_location_GpsLocationProvider_wait_for_event},
-	{"native_read_sv_status", "([I[F[F[F[I)I", (void*)android_location_GpsLocationProvider_read_sv_status},
-	{"native_inject_time", "(JJI)V", (void*)android_location_GpsLocationProvider_inject_time},
-	{"native_supports_xtra", "()Z", (void*)android_location_GpsLocationProvider_supports_xtra},
-	{"native_inject_xtra_data", "([BI)V", (void*)android_location_GpsLocationProvider_inject_xtra_data},
- 	{"native_supl_data_conn_open", "(Ljava/lang/String;)V", (void*)android_location_GpsLocationProvider_supl_data_conn_open},
- 	{"native_supl_data_conn_closed", "()V", (void*)android_location_GpsLocationProvider_supl_data_conn_closed},
- 	{"native_supl_data_conn_failed", "()V", (void*)android_location_GpsLocationProvider_supl_data_conn_failed},
- 	{"native_set_supl_server", "(II)V", (void*)android_location_GpsLocationProvider_set_supl_server},
+    {"native_is_supported", "()Z", (void*)android_location_GpsLocationProvider_is_supported},
+    {"native_init", "()Z", (void*)android_location_GpsLocationProvider_init},
+    {"native_disable", "()V", (void*)android_location_GpsLocationProvider_disable},
+    {"native_cleanup", "()V", (void*)android_location_GpsLocationProvider_cleanup},
+    {"native_start", "(IZI)Z", (void*)android_location_GpsLocationProvider_start},
+    {"native_stop", "()Z", (void*)android_location_GpsLocationProvider_stop},
+    {"native_delete_aiding_data", "(I)V", (void*)android_location_GpsLocationProvider_delete_aiding_data},
+    {"native_wait_for_event", "()V", (void*)android_location_GpsLocationProvider_wait_for_event},
+    {"native_read_sv_status", "([I[F[F[F[I)I", (void*)android_location_GpsLocationProvider_read_sv_status},
+    {"native_inject_time", "(JJI)V", (void*)android_location_GpsLocationProvider_inject_time},
+    {"native_supports_xtra", "()Z", (void*)android_location_GpsLocationProvider_supports_xtra},
+    {"native_inject_xtra_data", "([BI)V", (void*)android_location_GpsLocationProvider_inject_xtra_data},
+    {"native_agps_data_conn_open", "(Ljava/lang/String;)V", (void*)android_location_GpsLocationProvider_agps_data_conn_open},
+    {"native_agps_data_conn_closed", "()V", (void*)android_location_GpsLocationProvider_agps_data_conn_closed},
+    {"native_agps_data_conn_failed", "()V", (void*)android_location_GpsLocationProvider_agps_data_conn_failed},
+    {"native_set_agps_server", "(III)V", (void*)android_location_GpsLocationProvider_set_agps_server},
 };
 
 int register_android_location_GpsLocationProvider(JNIEnv* env)
diff --git a/core/jni/android_opengl_GLES10.cpp b/core/jni/android_opengl_GLES10.cpp
index 7e388ef..482d8eb 100644
--- a/core/jni/android_opengl_GLES10.cpp
+++ b/core/jni/android_opengl_GLES10.cpp
@@ -24,6 +24,19 @@
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
+/* special calls implemented in Android's GLES wrapper used to more
+ * efficiently bound-check passed arrays */
+extern "C" {
+GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
+        const GLvoid *ptr, GLsizei count);
+GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
+        const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+}
+
 static int initialized = 0;
 
 static jclass nioAccessClass;
diff --git a/core/jni/com_google_android_gles_jni_GLImpl.cpp b/core/jni/com_google_android_gles_jni_GLImpl.cpp
index 6f2a438..11822e0 100644
--- a/core/jni/com_google_android_gles_jni_GLImpl.cpp
+++ b/core/jni/com_google_android_gles_jni_GLImpl.cpp
@@ -24,6 +24,19 @@
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
+/* special calls implemented in Android's GLES wrapper used to more
+ * efficiently bound-check passed arrays */
+extern "C" {
+GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
+        const GLvoid *ptr, GLsizei count);
+GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
+        const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+}
+
 static int initialized = 0;
 
 static jclass nioAccessClass;
diff --git a/core/res/res/drawable/divider_horizontal_bright.9.png b/core/res/res/drawable/divider_horizontal_bright.9.png
index 144fc22..30c9b2b 100644
--- a/core/res/res/drawable/divider_horizontal_bright.9.png
+++ b/core/res/res/drawable/divider_horizontal_bright.9.png
Binary files differ
diff --git a/core/res/res/drawable/divider_horizontal_dark.9.png b/core/res/res/drawable/divider_horizontal_dark.9.png
index 08838ca..ce21acd 100644
--- a/core/res/res/drawable/divider_horizontal_dark.9.png
+++ b/core/res/res/drawable/divider_horizontal_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable/search_dropdown_background_apps.9.png b/core/res/res/drawable/search_dropdown_background_apps.9.png
new file mode 100644
index 0000000..56b697d
--- /dev/null
+++ b/core/res/res/drawable/search_dropdown_background_apps.9.png
Binary files differ
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index 54da326..1319c77 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -753,9 +753,28 @@
          {@link #AndroidManifest manifest} tag. -->
     <declare-styleable name="AndroidManifestUsesSdk" parent="AndroidManifest">
         <!-- This is the minimum SDK version number that the application
-             requires.  Currently there is only one SDK version, 1.  If
-             not supplied, the application will work on any SDK. -->
-        <attr name="minSdkVersion" format="integer" />
+             requires.  This number is an abstract integer, from the list
+             in {@link android.os.Build.VERSION_CODES}  If
+             not supplied, the application will work on any SDK.  This
+             may also be string (such as "Donut") if the application was built
+             against a development branch, in which case it will only work against
+             the development builds. -->
+        <attr name="minSdkVersion" format="integer|string" />
+        <!-- This is the SDK version number that the application is targeting.
+             It is able to run on older versions (down to minSdkVersion), but
+             was explicitly tested to work with the version specified here.
+             Specifying this version allows the platform to disable compatibility
+             code that are not required or enable newer features that are not
+             available to older applications.  This may also be a string
+             (such as "Donut") if this is built against a development
+             branch, in which case minSdkVersion is also forced to be that
+             string. -->
+        <attr name="targetSdkVersion" format="integer|string" />
+        <!-- This is the maximum SDK version number that an application works
+             on.  You can use this to ensure your application is filtered out
+             of later versions of the platform when you know you have
+             incompatibility with them. -->
+        <attr name="maxSdkVersion" format="integer" />
     </declare-styleable>
     
     <!-- The <code>uses-libraries</code> specifies a shared library that this
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 9e4c6a9..df5d879 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1087,7 +1087,7 @@
   <public type="integer" name="config_longAnimTime" id="0x010e0002" />
 
 <!-- ===============================================================
-     Resources added in version 4 of the platform.
+     Resources added in Donut.
      =============================================================== -->
   <eat-comment />
 
@@ -1097,6 +1097,8 @@
    <public type="attr" name="searchSuggestThreshold" id="0x0101026d" />
    <public type="attr" name="includeInGlobalSearch" id="0x0101026e" />
    <public type="attr" name="onClick" id="0x0101026f" />
+   <public type="attr" name="targetSdkVersion" id="0x01010270" />
+   <public type="attr" name="maxSdkVersion" id="0x01010271" />
 
    <public type="anim" name="anticipate_interpolator" id="0x010a0007" />
    <public type="anim" name="overshoot_interpolator" id="0x010a0008" />
diff --git a/include/ui/Camera.h b/include/ui/Camera.h
index 901c7a9..048bdd5 100644
--- a/include/ui/Camera.h
+++ b/include/ui/Camera.h
@@ -63,6 +63,23 @@
 #define FRAME_CALLBACK_FLAG_CAMERA                   0x05
 #define FRAME_CALLBACK_FLAG_BARCODE_SCANNER          0x07
 
+// msgType in notifyCallback function
+enum {
+    CAMERA_MSG_ERROR,
+    CAMERA_MSG_SHUTTER,
+    CAMERA_MSG_FOCUS,
+    CAMERA_MSG_ZOOM
+};
+
+// msgType in dataCallback function
+enum {
+    CAMERA_MSG_PREVIEW_FRAME,
+    CAMERA_MSG_VIDEO_FRAME,
+    CAMERA_MSG_POSTVIEW_FRAME,
+    CAMERA_MSG_RAW_IMAGE,
+    CAMERA_MSG_COMPRESSED_IMAGE
+};
+
 class ICameraService;
 class ICamera;
 class Surface;
@@ -136,15 +153,8 @@
             void        setAutoFocusCallback(autofocus_callback cb, void *cookie);
 
     // ICameraClient interface
-    virtual void        shutterCallback();
-    virtual void        rawCallback(const sp<IMemory>& picture);
-    virtual void        jpegCallback(const sp<IMemory>& picture);
-    virtual void        previewCallback(const sp<IMemory>& frame);
-    virtual void        errorCallback(status_t error);
-    virtual void        autoFocusCallback(bool focused);
-    virtual void        recordingCallback(const sp<IMemory>& frame);
     virtual void        notifyCallback(int32_t msgType, int32_t ext, int32_t ext2);
-    virtual void        dataCallback(int32_t msgType, const sp<IMemory>& frame);
+    virtual void        dataCallback(int32_t msgType, const sp<IMemory>& dataPtr);
 
     sp<ICamera>         remote();
 
diff --git a/include/ui/ICameraClient.h b/include/ui/ICameraClient.h
index 1645ef8..c4bdd07 100644
--- a/include/ui/ICameraClient.h
+++ b/include/ui/ICameraClient.h
@@ -29,30 +29,6 @@
 public:
     DECLARE_META_INTERFACE(CameraClient);
 
-    // msgType in notifyCallback function
-    enum {
-        ERROR,
-        SHUTTER,
-        FOCUSED,
-        ZOOM
-    } notify_callback_message_type;
-
-    // msgType in dataCallback function
-    enum {
-        PREVIEW,
-        RECORD,
-        POSTVIEW,
-        RAW,
-        COMPRESSED
-    } data_callback_message_type;
-
-    virtual void            shutterCallback() = 0;
-    virtual void            rawCallback(const sp<IMemory>& picture) = 0;
-    virtual void            jpegCallback(const sp<IMemory>& picture) = 0;
-    virtual void            previewCallback(const sp<IMemory>& frame) = 0;
-    virtual void            errorCallback(status_t error) = 0;
-    virtual void            autoFocusCallback(bool focused) = 0;
-    virtual void            recordingCallback(const sp<IMemory>& frame) = 0;
     virtual void            notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2) = 0;
     virtual void            dataCallback(int32_t msgType, const sp<IMemory>& data) = 0;
 
diff --git a/libs/ui/Camera.cpp b/libs/ui/Camera.cpp
index ed4f3b8..6613700 100644
--- a/libs/ui/Camera.cpp
+++ b/libs/ui/Camera.cpp
@@ -337,76 +337,66 @@
     mErrorCallbackCookie = cookie;
 }
 
-void Camera::autoFocusCallback(bool focused)
-{
-    LOGV("autoFocusCallback");
-    if (mAutoFocusCallback) {
-        mAutoFocusCallback(focused, mAutoFocusCallbackCookie);
-    }
-}
-
-void Camera::shutterCallback()
-{
-    LOGV("shutterCallback");
-    if (mShutterCallback) {
-        mShutterCallback(mShutterCallbackCookie);
-    }
-}
-
-void Camera::rawCallback(const sp<IMemory>& picture)
-{
-    LOGV("rawCallback");
-    if (mRawCallback) {
-        mRawCallback(picture, mRawCallbackCookie);
-    }
-}
-
-// callback from camera service when image is ready
-void Camera::jpegCallback(const sp<IMemory>& picture)
-{
-    LOGV("jpegCallback");
-    if (mJpegCallback) {
-        mJpegCallback(picture, mJpegCallbackCookie);
-    }
-}
-
-// callback from camera service when preview frame is ready
-void Camera::previewCallback(const sp<IMemory>& frame)
-{
-    LOGV("frameCallback");
-    if (mPreviewCallback) {
-        mPreviewCallback(frame, mPreviewCallbackCookie);
-    }
-}
-
-// callback from camera service when a recording frame is ready
-void Camera::recordingCallback(const sp<IMemory>& frame)
-{
-    LOGV("recordingCallback");
-    if (mRecordingCallback) {
-        mRecordingCallback(frame, mRecordingCallbackCookie);
-    }
-}
-
-// callback from camera service when an error occurs in preview or takePicture
-void Camera::errorCallback(status_t error)
-{
-    LOGV("errorCallback");
-    if (mErrorCallback) {
-        mErrorCallback(error, mErrorCallbackCookie);
-    }
-}
-
 // callback from camera service
 void Camera::notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)
 {
-    LOGV("notifyCallback");
+    switch(msgType) {
+    case CAMERA_MSG_ERROR:
+        LOGV("errorCallback");
+        if (mErrorCallback) {
+            mErrorCallback((status_t)ext1, mErrorCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_FOCUS:
+        LOGV("autoFocusCallback");
+        if (mAutoFocusCallback) {
+            mAutoFocusCallback((bool)ext1, mAutoFocusCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_SHUTTER:
+        LOGV("shutterCallback");
+        if (mShutterCallback) {
+            mShutterCallback(mShutterCallbackCookie);
+        }
+        break;
+    default:
+        LOGV("notifyCallback(%d, %d, %d)", msgType, ext1, ext2);
+        break;
+    }
 }
 
-// callback from camera service when image is ready
-void Camera::dataCallback(int32_t msgType, const sp<IMemory>& frame)
+// callback from camera service when frame or image is ready
+void Camera::dataCallback(int32_t msgType, const sp<IMemory>& dataPtr)
 {
-    LOGV("dataCallback");
+    switch(msgType) {
+    case CAMERA_MSG_PREVIEW_FRAME:
+        LOGV("previewCallback");
+        if (mPreviewCallback) {
+            mPreviewCallback(dataPtr, mPreviewCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_VIDEO_FRAME:
+        LOGV("recordingCallback");
+        if (mRecordingCallback) {
+            mRecordingCallback(dataPtr, mRecordingCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_RAW_IMAGE:
+        LOGV("rawCallback");
+        if (mRawCallback) {
+            mRawCallback(dataPtr, mRawCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_COMPRESSED_IMAGE:
+        LOGV("jpegCallback");
+        if (mJpegCallback) {
+            mJpegCallback(dataPtr, mJpegCallbackCookie);
+        }
+        break;
+    default:
+        LOGV("dataCallback(%d, %p)", msgType, dataPtr.get());
+        break;
+    }
 }
 
 void Camera::binderDied(const wp<IBinder>& who) {
diff --git a/libs/ui/ICameraClient.cpp b/libs/ui/ICameraClient.cpp
index ae07b67..c6cf75c 100644
--- a/libs/ui/ICameraClient.cpp
+++ b/libs/ui/ICameraClient.cpp
@@ -25,14 +25,7 @@
 namespace android {
 
 enum {
-    SHUTTER_CALLBACK = IBinder::FIRST_CALL_TRANSACTION,
-    RAW_CALLBACK,
-    JPEG_CALLBACK,
-    PREVIEW_CALLBACK,
-    ERROR_CALLBACK,
-    AUTOFOCUS_CALLBACK,
-    RECORDING_CALLBACK,
-    NOTIFY_CALLBACK,
+    NOTIFY_CALLBACK = IBinder::FIRST_CALL_TRANSACTION,
     DATA_CALLBACK,
 };
 
@@ -44,75 +37,6 @@
     {
     }
 
-    // callback to let the app know the shutter has closed, ideal for playing the shutter sound
-    void shutterCallback()
-    {
-        LOGV("shutterCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        remote()->transact(SHUTTER_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app with picture data
-    void rawCallback(const sp<IMemory>& picture)
-    {
-        LOGV("rawCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeStrongBinder(picture->asBinder());
-        remote()->transact(RAW_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app with picture data
-    void jpegCallback(const sp<IMemory>& picture)
-    {
-        LOGV("jpegCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeStrongBinder(picture->asBinder());
-        remote()->transact(JPEG_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app with preview frame data
-    void previewCallback(const sp<IMemory>& frame)
-    {
-        LOGV("previewCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeStrongBinder(frame->asBinder());
-        remote()->transact(PREVIEW_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app with recording frame data
-    void recordingCallback(const sp<IMemory>& frame)
-    {
-        LOGV("recordingCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeStrongBinder(frame->asBinder());
-        remote()->transact(RECORDING_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app to report error
-    void errorCallback(status_t error)
-    {
-        LOGV("errorCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeInt32(error);
-        remote()->transact(ERROR_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app to report autofocus completion
-    void autoFocusCallback(bool focused)
-    {
-        LOGV("autoFocusCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeInt32(focused);
-        remote()->transact(AUTOFOCUS_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
     // generic callback from camera service to app
     void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)
     {
@@ -152,54 +76,6 @@
     uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
 {
     switch(code) {
-        case SHUTTER_CALLBACK: {
-            LOGV("SHUTTER_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            shutterCallback();
-            return NO_ERROR;
-        } break;
-        case RAW_CALLBACK: {
-            LOGV("RAW_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            sp<IMemory> picture = interface_cast<IMemory>(data.readStrongBinder());
-            rawCallback(picture);
-            return NO_ERROR;
-        } break;
-        case JPEG_CALLBACK: {
-            LOGV("JPEG_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            sp<IMemory> picture = interface_cast<IMemory>(data.readStrongBinder());
-            jpegCallback(picture);
-            return NO_ERROR;
-        } break;
-        case PREVIEW_CALLBACK: {
-            LOGV("PREVIEW_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            sp<IMemory> frame = interface_cast<IMemory>(data.readStrongBinder());
-            previewCallback(frame);
-            return NO_ERROR;
-        } break;
-        case RECORDING_CALLBACK: {
-            LOGV("RECORDING_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            sp<IMemory> frame = interface_cast<IMemory>(data.readStrongBinder());
-            recordingCallback(frame);
-            return NO_ERROR;
-        } break;
-        case ERROR_CALLBACK: {
-            LOGV("ERROR_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            status_t error = data.readInt32();
-            errorCallback(error);
-            return NO_ERROR;
-        } break;
-        case AUTOFOCUS_CALLBACK: {
-            LOGV("AUTOFOCUS_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            bool focused = (bool)data.readInt32();
-            autoFocusCallback(focused);
-            return NO_ERROR;
-        } break;
         case NOTIFY_CALLBACK: {
             LOGV("NOTIFY_CALLBACK");
             CHECK_INTERFACE(ICameraClient, data, reply);
diff --git a/location/java/com/android/internal/location/GpsLocationProvider.java b/location/java/com/android/internal/location/GpsLocationProvider.java
index 21c7adb..943d56c 100644
--- a/location/java/com/android/internal/location/GpsLocationProvider.java
+++ b/location/java/com/android/internal/location/GpsLocationProvider.java
@@ -109,13 +109,13 @@
     private static final int GPS_STATUS_ENGINE_ON = 3;
     private static final int GPS_STATUS_ENGINE_OFF = 4;
 
-    // these need to match GpsSuplStatusValue defines in gps.h
-    /** SUPL status event values. */
-    private static final int GPS_REQUEST_SUPL_DATA_CONN = 1;
-    private static final int GPS_RELEASE_SUPL_DATA_CONN = 2;
-    private static final int GPS_SUPL_DATA_CONNECTED = 3;
-    private static final int GPS_SUPL_DATA_CONN_DONE = 4;
-    private static final int GPS_SUPL_DATA_CONN_FAILED = 5;
+    // these need to match GpsApgsStatusValue defines in gps.h
+    /** AGPS status event values. */
+    private static final int GPS_REQUEST_AGPS_DATA_CONN = 1;
+    private static final int GPS_RELEASE_AGPS_DATA_CONN = 2;
+    private static final int GPS_AGPS_DATA_CONNECTED = 3;
+    private static final int GPS_AGPS_DATA_CONN_DONE = 4;
+    private static final int GPS_AGPS_DATA_CONN_FAILED = 5;
 
     // these need to match GpsLocationFlags enum in gps.h
     private static final int LOCATION_INVALID = 0;
@@ -124,8 +124,8 @@
     private static final int LOCATION_HAS_SPEED = 4;
     private static final int LOCATION_HAS_BEARING = 8;
     private static final int LOCATION_HAS_ACCURACY = 16;
-    
-// IMPORTANT - the GPS_DELETE_* symbols here must match constants in GpsLocationProvider.java
+
+// IMPORTANT - the GPS_DELETE_* symbols here must match constants in gps.h
     private static final int GPS_DELETE_EPHEMERIS = 0x0001;
     private static final int GPS_DELETE_ALMANAC = 0x0002;
     private static final int GPS_DELETE_POSITION = 0x0004;
@@ -140,10 +140,14 @@
     private static final int GPS_DELETE_CELLDB_INFO = 0x8000;
     private static final int GPS_DELETE_ALL = 0xFFFF;
 
-    // for mSuplDataConnectionState
-    private static final int SUPL_DATA_CONNECTION_CLOSED = 0;
-    private static final int SUPL_DATA_CONNECTION_OPENING = 1;
-    private static final int SUPL_DATA_CONNECTION_OPEN = 2;
+    // these need to match AGpsType enum in gps.h
+    private static final int AGPS_TYPE_SUPL = 1;
+    private static final int AGPS_TYPE_C2K = 2;
+
+    // for mAGpsDataConnectionState
+    private static final int AGPS_DATA_CONNECTION_CLOSED = 0;
+    private static final int AGPS_DATA_CONNECTION_OPENING = 1;
+    private static final int AGPS_DATA_CONNECTION_OPEN = 2;
 
     private static final String PROPERTIES_FILE = "/etc/gps.conf";
 
@@ -203,9 +207,12 @@
 
     private String mSuplHost;
     private int mSuplPort;
+    private String mC2KHost;
+    private int mC2KPort;
     private boolean mSetSuplServer;
-    private String mSuplApn;
-    private int mSuplDataConnectionState;
+    private boolean mSetC2KServer;
+    private String mAGpsApn;
+    private int mAGpsDataConnectionState;
     private final ConnectivityManager mConnMgr;
 
     // Wakelocks
@@ -293,11 +300,12 @@
                 if (Config.LOGD) {
                     Log.d(TAG, "state: " + state +  " apnName: " + apnName + " reason: " + reason);
                 }
+                // FIXME - might not have an APN on CDMA
                 if ("CONNECTED".equals(state) && apnName != null && apnName.length() > 0) {
-                    mSuplApn = apnName;
-                    if (mSuplDataConnectionState == SUPL_DATA_CONNECTION_OPENING) {
-                        native_supl_data_conn_open(mSuplApn);
-                        mSuplDataConnectionState = SUPL_DATA_CONNECTION_OPEN;
+                    mAGpsApn = apnName;
+                    if (mAGpsDataConnectionState == AGPS_DATA_CONNECTION_OPENING) {
+                        native_agps_data_conn_open(mAGpsApn);
+                        mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPEN;
                     }
                 }
             }
@@ -336,14 +344,26 @@
             mProperties.load(stream);
             stream.close();
             mNtpServer = mProperties.getProperty("NTP_SERVER", null);
+
             mSuplHost = mProperties.getProperty("SUPL_HOST");
-            String suplPortString = mProperties.getProperty("SUPL_PORT");
-            if (mSuplHost != null && suplPortString != null) {
+            String portString = mProperties.getProperty("SUPL_PORT");
+            if (mSuplHost != null && portString != null) {
                 try {
-                    mSuplPort = Integer.parseInt(suplPortString);
+                    mSuplPort = Integer.parseInt(portString);
                     mSetSuplServer = true;
                 } catch (NumberFormatException e) {
-                    Log.e(TAG, "unable to parse SUPL_PORT: " + suplPortString);
+                    Log.e(TAG, "unable to parse SUPL_PORT: " + portString);
+                }
+            }
+
+            mC2KHost = mProperties.getProperty("C2K_HOST");
+            portString = mProperties.getProperty("C2K_PORT");
+            if (mC2KHost != null && portString != null) {
+                try {
+                    mC2KPort = Integer.parseInt(portString);
+                    mSetC2KServer = true;
+                } catch (NumberFormatException e) {
+                    Log.e(TAG, "unable to parse C2K_PORT: " + portString);
                 }
             }
         } catch (IOException e) {
@@ -358,7 +378,8 @@
     public boolean requiresNetwork() {
         // We want updateNetworkState() to get called when the network state changes
         // for XTRA and NTP time injection support.
-        return (mNtpServer != null || native_supports_xtra() || mSuplHost != null);
+        return (mNtpServer != null || native_supports_xtra() ||
+                mSuplHost != null || mC2KHost != null);
     }
 
     public void updateNetworkState(int state) {
@@ -561,7 +582,6 @@
                 interval = 1;
             }
             mFixInterval = interval;
-            native_set_fix_frequency(mFixInterval);
         }
     }
 
@@ -871,38 +891,38 @@
     }
 
     /**
-     * called from native code to update SUPL status
+     * called from native code to update AGPS status
      */
-    private void reportSuplStatus(int status) {
+    private void reportAGpsStatus(int type, int status) {
         switch (status) {
-            case GPS_REQUEST_SUPL_DATA_CONN:
+            case GPS_REQUEST_AGPS_DATA_CONN:
                  int result = mConnMgr.startUsingNetworkFeature(
                         ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_SUPL);
                 if (result == Phone.APN_ALREADY_ACTIVE) {
-                    native_supl_data_conn_open(mSuplApn);
-                    mSuplDataConnectionState = SUPL_DATA_CONNECTION_OPEN;
+                    native_agps_data_conn_open(mAGpsApn);
+                    mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPEN;
                 } else if (result == Phone.APN_REQUEST_STARTED) {
-                    mSuplDataConnectionState = SUPL_DATA_CONNECTION_OPENING;
+                    mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPENING;
                 } else {
-                    native_supl_data_conn_failed();
+                    native_agps_data_conn_failed();
                 }
                 break;
-            case GPS_RELEASE_SUPL_DATA_CONN:
-                if (mSuplDataConnectionState != SUPL_DATA_CONNECTION_CLOSED) {
+            case GPS_RELEASE_AGPS_DATA_CONN:
+                if (mAGpsDataConnectionState != AGPS_DATA_CONNECTION_CLOSED) {
                     mConnMgr.stopUsingNetworkFeature(
                             ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_SUPL);
-                    native_supl_data_conn_closed();
-                    mSuplDataConnectionState = SUPL_DATA_CONNECTION_CLOSED;
+                    native_agps_data_conn_closed();
+                    mAGpsDataConnectionState = AGPS_DATA_CONNECTION_CLOSED;
                 }
                 break;
-            case GPS_SUPL_DATA_CONNECTED:
-                // Log.d(TAG, "GPS_SUPL_DATA_CONNECTED");
+            case GPS_AGPS_DATA_CONNECTED:
+                // Log.d(TAG, "GPS_AGPS_DATA_CONNECTED");
                 break;
-            case GPS_SUPL_DATA_CONN_DONE:
-                // Log.d(TAG, "GPS_SUPL_DATA_CONN_DONE");
+            case GPS_AGPS_DATA_CONN_DONE:
+                // Log.d(TAG, "GPS_AGPS_DATA_CONN_DONE");
                 break;
-            case GPS_SUPL_DATA_CONN_FAILED:
-                // Log.d(TAG, "GPS_SUPL_DATA_CONN_FAILED");
+            case GPS_AGPS_DATA_CONN_FAILED:
+                // Log.d(TAG, "GPS_AGPS_DATA_CONN_FAILED");
                 break;
         }
     }
@@ -914,6 +934,29 @@
         }
     }
 
+    private boolean setAGpsServer(int type, String host, int port) {
+        try {
+            InetAddress inetAddress = InetAddress.getByName(host);
+            if (inetAddress != null) {
+                byte[] addrBytes = inetAddress.getAddress();
+                long addr = 0;
+                for (int i = 0; i < addrBytes.length; i++) {
+                    int temp = addrBytes[i];
+                    // signed -> unsigned
+                    if (temp < 0) temp = 256 + temp;
+                    addr = addr * 256 + temp;
+                }
+                // use MS-Based position mode if SUPL support is enabled
+                mPositionMode = GPS_POSITION_MODE_MS_BASED;
+                native_set_agps_server(type, (int)addr, port);
+            }
+        } catch (UnknownHostException e) {
+            Log.e(TAG, "unknown host for server " + host);
+            return false;
+        }
+        return true;
+    }
+
     private class GpsEventThread extends Thread {
 
         public GpsEventThread() {
@@ -985,7 +1028,8 @@
                         }
                     }
                     waitTime = getWaitTime();
-                } while (!mDone && ((!mXtraDownloadRequested && !mSetSuplServer && waitTime > 0)
+                } while (!mDone && ((!mXtraDownloadRequested &&
+                        !mSetSuplServer && !mSetC2KServer && waitTime > 0)
                         || !mNetworkAvailable));
                 if (Config.LOGD) Log.d(TAG, "NetworkThread out of wake loop");
                 
@@ -1012,26 +1056,15 @@
                         }
                     }
 
-                    // Set the SUPL server address if we have not yet
+                    // Set the AGPS server addresses if we have not yet
                     if (mSetSuplServer) {
-                        try {
-                            InetAddress inetAddress = InetAddress.getByName(mSuplHost);
-                            if (inetAddress != null) {
-                                byte[] addrBytes = inetAddress.getAddress();
-                                long addr = 0;
-                                for (int i = 0; i < addrBytes.length; i++) {
-                                    int temp = addrBytes[i];
-                                    // signed -> unsigned
-                                    if (temp < 0) temp = 256 + temp;
-                                    addr = addr * 256 + temp;
-                                }
-                                // use MS-Based position mode if SUPL support is enabled
-                                mPositionMode = GPS_POSITION_MODE_MS_BASED;
-                                native_set_supl_server((int)addr, mSuplPort);
-                                mSetSuplServer = false; 
-                            }
-                        } catch (UnknownHostException e) {
-                            Log.e(TAG, "unknown host for SUPL server " + mSuplHost);
+                        if (setAGpsServer(AGPS_TYPE_SUPL, mSuplHost, mSuplPort)) {
+                            mSetSuplServer = false;
+                        }
+                    }
+                    if (mSetC2KServer) {
+                        if (setAGpsServer(AGPS_TYPE_C2K, mC2KHost, mC2KPort)) {
+                            mSetC2KServer = false;
                         }
                     }
 
@@ -1125,9 +1158,9 @@
     private native boolean native_supports_xtra();
     private native void native_inject_xtra_data(byte[] data, int length);
 
-    // SUPL Support    
-    private native void native_supl_data_conn_open(String apn);
-    private native void native_supl_data_conn_closed();
-    private native void native_supl_data_conn_failed();
-    private native void native_set_supl_server(int addr, int port);
+    // AGPS Support    
+    private native void native_agps_data_conn_open(String apn);
+    private native void native_agps_data_conn_closed();
+    private native void native_agps_data_conn_failed();
+    private native void native_set_agps_server(int type, int addr, int port);
 }
diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp
index 209b09f..cac65d6 100644
--- a/media/jni/android_media_MediaRecorder.cpp
+++ b/media/jni/android_media_MediaRecorder.cpp
@@ -150,6 +150,11 @@
 
 static void android_media_MediaRecorder_setCamera(JNIEnv* env, jobject thiz, jobject camera)
 {
+    // we should not pass a null camera to get_native_camera() call.
+    if (camera == NULL) {
+        jniThrowException(env, "java/lang/NullPointerException", "camera object is a NULL pointer");
+        return;
+    }
     sp<Camera> c = get_native_camera(env, camera, NULL);
     sp<MediaRecorder> mr = getMediaRecorder(env, thiz);
     process_media_recorder_call(env, mr->setCamera(c->remote()),
diff --git a/opengl/include/GLES/glext.h b/opengl/include/GLES/glext.h
index 4c01871a..a8fe2e9 100644
--- a/opengl/include/GLES/glext.h
+++ b/opengl/include/GLES/glext.h
@@ -599,21 +599,6 @@
 #define GL_EXT_texture_filter_anisotropic 1
 #endif
 
-/*------------------------------------------------------------------------*
- * dalvik extension functions
- *------------------------------------------------------------------------*/
-#ifdef ANDROID
-void glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
-        const GLvoid *ptr, GLsizei count);
-void glNormalPointerBounds(GLenum type, GLsizei stride,
-        const GLvoid *pointer, GLsizei count);
-void glTexCoordPointerBounds(GLint size, GLenum type,
-        GLsizei stride, const GLvoid *pointer, GLsizei count);
-void glVertexPointerBounds(GLint size, GLenum type,
-        GLsizei stride, const GLvoid *pointer, GLsizei count);
-#endif
-
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/opengl/include/KHR/khrplatform.h b/opengl/include/KHR/khrplatform.h
index 4cc27c5..1660bd7 100644
--- a/opengl/include/KHR/khrplatform.h
+++ b/opengl/include/KHR/khrplatform.h
@@ -91,6 +91,8 @@
 #   define KHRONOS_APICALL __declspec(dllimport)
 #elif defined (__SYMBIAN32__)
 #   define KHRONOS_APICALL IMPORT_C
+#elif defined(ANDROID)
+#   define KHRONOS_APICALL __attribute__((visibility("default")))
 #else
 #   define KHRONOS_APICALL
 #endif
diff --git a/opengl/libagl/Android.mk b/opengl/libagl/Android.mk
index 99efe4c..3ce0414 100644
--- a/opengl/libagl/Android.mk
+++ b/opengl/libagl/Android.mk
@@ -33,6 +33,8 @@
 endif
 
 LOCAL_SHARED_LIBRARIES := libcutils libutils libpixelflinger
+LOCAL_CFLAGS += -fvisibility=hidden
+
 LOCAL_LDLIBS := -lpthread -ldl
 LOCAL_MODULE:= libagl
 
diff --git a/opengl/libs/Android.mk b/opengl/libs/Android.mk
index d636d73..5ba6b76 100644
--- a/opengl/libs/Android.mk
+++ b/opengl/libs/Android.mk
@@ -23,6 +23,8 @@
     LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../bionic/libc/private
 endif
 
+LOCAL_CFLAGS += -fvisibility=hidden
+
 include $(BUILD_SHARED_LIBRARY)
 
 
@@ -49,4 +51,6 @@
     LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../bionic/libc/private
 endif
 
+LOCAL_CFLAGS += -fvisibility=hidden
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/opengl/libs/EGL/gpu.cpp b/opengl/libs/EGL/gpu.cpp
index 3f9fd63..f9dc5f1 100644
--- a/opengl/libs/EGL/gpu.cpp
+++ b/opengl/libs/EGL/gpu.cpp
@@ -53,7 +53,7 @@
 static Mutex                            gRegionsLock;
 static request_gpu_t                    gRegions;
 static sp<ISurfaceComposer>             gSurfaceManager;
-ISurfaceComposer*                       GLES_localSurfaceManager = 0;
+GL_API ISurfaceComposer*                GLES_localSurfaceManager = 0;
 
 extern egl_connection_t gEGLImpl[2];
 
diff --git a/opengl/libs/GLES_CM/gl.cpp b/opengl/libs/GLES_CM/gl.cpp
index 0057168..384b59a 100644
--- a/opengl/libs/GLES_CM/gl.cpp
+++ b/opengl/libs/GLES_CM/gl.cpp
@@ -37,6 +37,17 @@
 // extensions for the framework
 // ----------------------------------------------------------------------------
 
+extern "C" {
+GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
+        const GLvoid *ptr, GLsizei count);
+GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
+        const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+}
+
 void glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
         const GLvoid *ptr, GLsizei count) {
     glColorPointer(size, type, stride, ptr);
diff --git a/opengl/libs/egl_impl.h b/opengl/libs/egl_impl.h
index 62ce3fc..312b176 100644
--- a/opengl/libs/egl_impl.h
+++ b/opengl/libs/egl_impl.h
@@ -20,6 +20,8 @@
 #include <ctype.h>
 
 #include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <EGL/eglplatform.h>
 
 // ----------------------------------------------------------------------------
 namespace android {
diff --git a/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp
index 7aa18b6..3948fd3 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp
+++ b/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp
@@ -23,6 +23,19 @@
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
+/* special calls implemented in Android's GLES wrapper used to more
+ * efficiently bound-check passed arrays */
+extern "C" {
+GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
+        const GLvoid *ptr, GLsizei count);
+GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
+        const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+}
+
 static int initialized = 0;
 
 static jclass nioAccessClass;
diff --git a/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp b/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp
index 8f174c7..11c6087 100644
--- a/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp
+++ b/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp
@@ -23,6 +23,19 @@
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
+/* special calls implemented in Android's GLES wrapper used to more
+ * efficiently bound-check passed arrays */
+extern "C" {
+GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
+        const GLvoid *ptr, GLsizei count);
+GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
+        const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+}
+
 static int initialized = 0;
 
 static jclass nioAccessClass;
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index a60f059..237b70d 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -59,6 +59,7 @@
 import android.content.pm.Signature;
 import android.net.Uri;
 import android.os.Binder;
+import android.os.Build;
 import android.os.Bundle;
 import android.os.HandlerThread;
 import android.os.Parcel;
@@ -140,8 +141,9 @@
             Process.THREAD_PRIORITY_BACKGROUND);
     final Handler mHandler;
 
-    final int mSdkVersion = SystemProperties.getInt(
-            "ro.build.version.sdk", 0);
+    final int mSdkVersion = Build.VERSION.SDK_INT;
+    final String mSdkCodename = "REL".equals(Build.VERSION.CODENAME)
+            ? null : Build.VERSION.CODENAME;
     
     final Context mContext;
     final boolean mFactoryTest;
@@ -1751,7 +1753,7 @@
         parseFlags |= mDefParseFlags;
         PackageParser pp = new PackageParser(scanFile.getPath());
         pp.setSeparateProcesses(mSeparateProcesses);
-        pp.setSdkVersion(mSdkVersion);
+        pp.setSdkVersion(mSdkVersion, mSdkCodename);
         final PackageParser.Package pkg = pp.parsePackage(scanFile,
                 destCodeFile.getAbsolutePath(), mMetrics, parseFlags);
         if (pkg == null) {
@@ -3693,7 +3695,7 @@
             parseFlags |= mDefParseFlags;
             PackageParser pp = new PackageParser(tmpPackageFile.getPath());
             pp.setSeparateProcesses(mSeparateProcesses);
-            pp.setSdkVersion(mSdkVersion);
+            pp.setSdkVersion(mSdkVersion, mSdkCodename);
             final PackageParser.Package pkg = pp.parsePackage(tmpPackageFile,
                     destPackageFile.getAbsolutePath(), mMetrics, parseFlags);
             if (pkg == null) {
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 2be4975..9471eff 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -169,6 +169,10 @@
     static final int LOG_BOOT_PROGRESS_AMS_READY = 3040;
     static final int LOG_BOOT_PROGRESS_ENABLE_SCREEN = 3050;
 
+    // The flags that are set for all calls we make to the package manager.
+    static final int STOCK_PM_FLAGS = PackageManager.GET_SHARED_LIBRARY_FILES
+            | PackageManager.GET_SUPPORTS_DENSITIES;
+    
     private static final String SYSTEM_SECURE = "ro.secure";
 
     // This is the maximum number of application processes we would like
@@ -1058,7 +1062,7 @@
 
             ApplicationInfo info =
                 mSelf.mContext.getPackageManager().getApplicationInfo(
-                        "android", PackageManager.GET_SHARED_LIBRARY_FILES);
+                        "android", STOCK_PM_FLAGS);
             synchronized (mSelf) {
                 ProcessRecord app = mSelf.newProcessRecordLocked(
                         mSystemThread.getApplicationThread(), info,
@@ -2224,7 +2228,7 @@
             }
             ActivityInfo aInfo =
                 intent.resolveActivityInfo(mContext.getPackageManager(),
-                        PackageManager.GET_SHARED_LIBRARY_FILES);
+                        STOCK_PM_FLAGS);
             if (aInfo != null) {
                 intent.setComponent(new ComponentName(
                         aInfo.applicationInfo.packageName, aInfo.name));
@@ -3181,7 +3185,7 @@
                 ActivityThread.getPackageManager().resolveIntent(
                         intent, resolvedType,
                         PackageManager.MATCH_DEFAULT_ONLY
-                        | PackageManager.GET_SHARED_LIBRARY_FILES);
+                        | STOCK_PM_FLAGS);
             aInfo = rInfo != null ? rInfo.activityInfo : null;
         } catch (RemoteException e) {
             aInfo = null;
@@ -3242,8 +3246,7 @@
                 List<ResolveInfo> resolves =
                     ActivityThread.getPackageManager().queryIntentActivities(
                             intent, r.resolvedType,
-                            PackageManager.MATCH_DEFAULT_ONLY
-                            | PackageManager.GET_SHARED_LIBRARY_FILES);
+                            PackageManager.MATCH_DEFAULT_ONLY | STOCK_PM_FLAGS);
 
                 // Look for the original activity in the list...
                 final int N = resolves != null ? resolves.size() : 0;
@@ -3325,8 +3328,7 @@
             ResolveInfo rInfo =
                 ActivityThread.getPackageManager().resolveIntent(
                         intent, resolvedType,
-                        PackageManager.MATCH_DEFAULT_ONLY
-                        | PackageManager.GET_SHARED_LIBRARY_FILES);
+                        PackageManager.MATCH_DEFAULT_ONLY | STOCK_PM_FLAGS);
             aInfo = rInfo != null ? rInfo.activityInfo : null;
         } catch (RemoteException e) {
             aInfo = null;
@@ -4608,7 +4610,8 @@
                     mWaitForDebugger = mOrigWaitForDebugger;
                 }
             }
-            thread.bindApplication(processName, app.info, providers,
+            thread.bindApplication(processName, app.instrumentationInfo != null
+                    ? app.instrumentationInfo : app.info, providers,
                     app.instrumentationClass, app.instrumentationProfileFile,
                     app.instrumentationArguments, app.instrumentationWatcher, testMode, 
                     mConfiguration, getCommonServicesLocked());
@@ -6651,8 +6654,7 @@
         try {
             providers = ActivityThread.getPackageManager().
                 queryContentProviders(app.processName, app.info.uid,
-                        PackageManager.GET_SHARED_LIBRARY_FILES
-                        | PackageManager.GET_URI_PERMISSION_PATTERNS);
+                        STOCK_PM_FLAGS | PackageManager.GET_URI_PERMISSION_PATTERNS);
         } catch (RemoteException ex) {
         }
         if (providers != null) {
@@ -6756,7 +6758,8 @@
             } else {
                 try {
                     cpi = ActivityThread.getPackageManager().
-                        resolveContentProvider(name, PackageManager.GET_URI_PERMISSION_PATTERNS);
+                        resolveContentProvider(name,
+                                STOCK_PM_FLAGS | PackageManager.GET_URI_PERMISSION_PATTERNS);
                 } catch (RemoteException ex) {
                 }
                 if (cpi == null) {
@@ -6777,7 +6780,7 @@
                             ActivityThread.getPackageManager().
                                 getApplicationInfo(
                                         cpi.applicationInfo.packageName,
-                                        PackageManager.GET_SHARED_LIBRARY_FILES);
+                                        STOCK_PM_FLAGS);
                         if (ai == null) {
                             Log.w(TAG, "No package info for content provider "
                                     + cpi.name);
@@ -7513,7 +7516,7 @@
             if (mFactoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL) {
                 ResolveInfo ri = mContext.getPackageManager()
                         .resolveActivity(new Intent(Intent.ACTION_FACTORY_TEST),
-                                0);
+                                STOCK_PM_FLAGS);
                 CharSequence errorMsg = null;
                 if (ri != null) {
                     ActivityInfo ai = ri.activityInfo;
@@ -7549,7 +7552,7 @@
             if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
                 try {
                     List apps = ActivityThread.getPackageManager().
-                        getPersistentApplications(PackageManager.GET_SHARED_LIBRARY_FILES);
+                        getPersistentApplications(STOCK_PM_FLAGS);
                     if (apps != null) {
                         int N = apps.size();
                         int i;
@@ -8964,7 +8967,7 @@
             try {
                 ResolveInfo rInfo =
                     ActivityThread.getPackageManager().resolveService(
-                            service, resolvedType, PackageManager.GET_SHARED_LIBRARY_FILES);
+                            service, resolvedType, STOCK_PM_FLAGS);
                 ServiceInfo sInfo =
                     rInfo != null ? rInfo.serviceInfo : null;
                 if (sInfo == null) {
@@ -10182,7 +10185,7 @@
             if (intent.getComponent() != null) {
                 // Broadcast is going to one specific receiver class...
                 ActivityInfo ai = ActivityThread.getPackageManager().
-                    getReceiverInfo(intent.getComponent(), 0);
+                    getReceiverInfo(intent.getComponent(), STOCK_PM_FLAGS);
                 if (ai != null) {
                     receivers = new ArrayList();
                     ResolveInfo ri = new ResolveInfo();
@@ -10195,7 +10198,7 @@
                          == 0) {
                     receivers =
                         ActivityThread.getPackageManager().queryIntentReceivers(
-                                intent, resolvedType, PackageManager.GET_SHARED_LIBRARY_FILES);
+                                intent, resolvedType, STOCK_PM_FLAGS);
                 }
                 registeredReceivers = mReceiverResolver.queryIntent(resolver,
                         intent, resolvedType, false);
@@ -10932,9 +10935,9 @@
             ApplicationInfo ai = null;
             try {
                 ii = mContext.getPackageManager().getInstrumentationInfo(
-                    className, 0);
+                    className, STOCK_PM_FLAGS);
                 ai = mContext.getPackageManager().getApplicationInfo(
-                    ii.targetPackage, PackageManager.GET_SHARED_LIBRARY_FILES);
+                    ii.targetPackage, STOCK_PM_FLAGS);
             } catch (PackageManager.NameNotFoundException e) {
             }
             if (ii == null) {
@@ -10966,6 +10969,7 @@
             uninstallPackageLocked(ii.targetPackage, -1, true);
             ProcessRecord app = addAppLocked(ai);
             app.instrumentationClass = className;
+            app.instrumentationInfo = ai;
             app.instrumentationProfileFile = profileFile;
             app.instrumentationArguments = arguments;
             app.instrumentationWatcher = watcher;
@@ -11013,6 +11017,7 @@
         }
         app.instrumentationWatcher = null;
         app.instrumentationClass = null;
+        app.instrumentationInfo = null;
         app.instrumentationProfileFile = null;
         app.instrumentationArguments = null;
 
diff --git a/services/java/com/android/server/am/ProcessRecord.java b/services/java/com/android/server/am/ProcessRecord.java
index b76547a..68aebc3 100644
--- a/services/java/com/android/server/am/ProcessRecord.java
+++ b/services/java/com/android/server/am/ProcessRecord.java
@@ -28,6 +28,7 @@
 import android.os.Bundle;
 import android.os.IBinder;
 import android.os.RemoteException;
+import android.util.PrintWriterPrinter;
 
 import java.io.PrintWriter;
 import java.util.ArrayList;
@@ -62,6 +63,7 @@
     IBinder forcingToForeground;// Token that is forcing this process to be foreground
     int adjSeq;                 // Sequence id for identifying repeated trav
     ComponentName instrumentationClass;// class installed to instrument app
+    ApplicationInfo instrumentationInfo; // the application being instrumented
     String instrumentationProfileFile; // where to save profiling
     IInstrumentationWatcher instrumentationWatcher; // who is waiting
     Bundle instrumentationArguments;// as given to us
@@ -125,6 +127,11 @@
                     pw.println(instrumentationProfileFile);
             pw.print(prefix); pw.print("instrumentationArguments=");
                     pw.println(instrumentationArguments);
+            pw.print(prefix); pw.print("instrumentationInfo=");
+                    pw.println(instrumentationInfo);
+            if (instrumentationInfo != null) {
+                instrumentationInfo.dump(new PrintWriterPrinter(pw), prefix + "  ");
+            }
         }
         pw.print(prefix); pw.print("thread="); pw.print(thread);
                 pw.print(" curReceiver="); pw.println(curReceiver);
diff --git a/tests/CoreTests/android/core/SocketTest.java b/tests/CoreTests/android/core/SocketTest.java
index b64c156..9db6077 100644
--- a/tests/CoreTests/android/core/SocketTest.java
+++ b/tests/CoreTests/android/core/SocketTest.java
@@ -178,29 +178,35 @@
         SocketChannel.open();
     }
 
-    // Regression test for issue 1018016, connecting ignored a set timeout.
-    @LargeTest
-    public void testSocketSetSOTimeout() throws IOException {
-        Socket sock = new Socket();
-        int timeout = 5000;
-        long start = System.currentTimeMillis();
-        try {
-            sock.connect(new InetSocketAddress(NON_EXISTING_ADDRESS, 80), timeout);
-        } catch (SocketTimeoutException e) {
-            // expected
-            long delay = System.currentTimeMillis() - start;
-            if (Math.abs(delay - timeout) > 1000) {
-                fail("timeout was not accurate. expected: " + timeout
-                        + " actual: " + delay + " miliseconds.");
-            }
-        } finally {
-            try {
-                sock.close();
-            } catch (IOException ioe) {
-                // ignore
-            }
-        }
-    }
+// Regression test for issue 1018016, connecting ignored a set timeout.
+//
+// Disabled because test behaves differently depending on networking
+// environment. It works fine in the emulator and one the device with
+// WLAN, but when 3G comes into play, the possible existence of a
+// proxy makes it fail.
+//
+//    @LargeTest
+//    public void testSocketSetSOTimeout() throws IOException {
+//        Socket sock = new Socket();
+//        int timeout = 5000;
+//        long start = System.currentTimeMillis();
+//        try {
+//            sock.connect(new InetSocketAddress(NON_EXISTING_ADDRESS, 80), timeout);
+//        } catch (SocketTimeoutException e) {
+//            // expected
+//            long delay = System.currentTimeMillis() - start;
+//            if (Math.abs(delay - timeout) > 1000) {
+//                fail("timeout was not accurate. expected: " + timeout
+//                        + " actual: " + delay + " miliseconds.");
+//            }
+//        } finally {
+//            try {
+//                sock.close();
+//            } catch (IOException ioe) {
+//                // ignore
+//            }
+//        }
+//    }
     
     /**
      * Regression test for 1062928: Dotted IP addresses (e.g., 192.168.100.1)
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index a09b1a6..ef11a83 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -1225,7 +1225,7 @@
                         // pseudolocalize here
                         block.setPosition(parserPosition);
                         err = parseAndAddEntry(bundle, in, &block, pseudoParams, myPackage, curType,
-                                ident, *curTag, curIsStyled, curFormat, true, false, outTable);
+                                ident, *curTag, curIsStyled, curFormat, true, overwrite, outTable);
                         if (err != NO_ERROR) {
                             hasErrors = localHasErrors = true;
                         }