Merge change 20937

* changes:
  libdrm: "==" should be an assignment.
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 066401f..f950c4b 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -177,36 +177,6 @@
         public static final String DISPLAY_NAME = "display_name";
 
         /**
-         * Reference to the row in the data table holding the primary phone number.
-         * <P>Type: INTEGER REFERENCES data(_id)</P>
-         */
-        @Deprecated
-        public static final String PRIMARY_PHONE_ID = "primary_phone_id";
-
-        /**
-         * Reference to the row in the data table holding the default phone number.
-         * If the contact has only one phone number, that number is the default one.
-         * Otherwise it is the one explicitly selected by the user as primary.
-         * <P>Type: INTEGER REFERENCES data(_id)</P>
-         */
-        public static final String DEFAULT_PHONE_ID = "default_phone_id";
-
-        /**
-         * Reference to the row in the data table holding the primary email address.
-         * <P>Type: INTEGER REFERENCES data(_id)</P>
-         */
-        @Deprecated
-        public static final String PRIMARY_EMAIL_ID = "primary_email_id";
-
-        /**
-         * Reference to the row in the data table holding the default email address.
-         * If the contact has only one email address, that address is the default one.
-         * Otherwise it is the one explicitly selected by the user as primary.
-         * <P>Type: INTEGER REFERENCES data(_id)</P>
-         */
-        public static final String DEFAULT_EMAIL_ID = "default_email_id";
-
-        /**
          * Reference to the row in the data table holding the photo.
          * <P>Type: INTEGER REFERENCES data(_id)</P>
          */
@@ -225,43 +195,11 @@
         public static final String PRESENCE_STATUS = Presence.PRESENCE_STATUS;
 
         /**
-         * The type of data, for example Home or Work.
+         * An indicator of whether this contact has at least one phone number. "1" if there is
+         * at least one phone number, "0" otherwise.
          * <P>Type: INTEGER</P>
          */
-        @Deprecated
-        public static final String PRIMARY_PHONE_TYPE = CommonDataKinds.Phone.TYPE;
-
-        /**
-         * The type of data, for example Home or Work.
-         * <P>Type: INTEGER</P>
-         */
-        public static final String DEFAULT_PHONE_TYPE = "default_phone_type";
-
-        /**
-         * The user defined label for the primary phone.
-         * <P>Type: TEXT</P>
-         */
-        @Deprecated
-        public static final String PRIMARY_PHONE_LABEL = CommonDataKinds.Phone.LABEL;
-
-        /**
-         * The user defined label for the default phone.
-         * <P>Type: TEXT</P>
-         */
-        public static final String DEFAULT_PHONE_LABEL = "default_phone_label";
-
-        /**
-         * The primary phone number.
-         * <P>Type: TEXT</P>
-         */
-        @Deprecated
-        public static final String PRIMARY_PHONE_NUMBER = CommonDataKinds.Phone.NUMBER;
-
-        /**
-         * The default phone number.
-         * <P>Type: TEXT</P>
-         */
-        public static final String DEFAULT_PHONE_NUMBER = "default_phone_number";
+        public static final String HAS_PHONE_NUMBER = "has_phone_number";
     }
 
     /**
diff --git a/core/java/android/webkit/GeolocationService.java b/core/java/android/webkit/GeolocationService.java
new file mode 100755
index 0000000..78b25ba
--- /dev/null
+++ b/core/java/android/webkit/GeolocationService.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.webkit;
+
+import android.app.ActivityThread;
+import android.content.Context;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.LocationProvider;
+import android.os.Bundle;
+import android.util.Log;
+import android.webkit.WebView;
+import android.webkit.WebViewCore;
+
+
+/**
+ * Implements the Java side of GeolocationServiceAndroid.
+ * @hide Pending API council review.
+ */
+public final class GeolocationService implements LocationListener {
+
+    // Log tag
+    private static final String TAG = "geolocationService";
+
+    private long mNativeObject;
+    private LocationManager mLocationManager;
+    private boolean mIsGpsEnabled;
+    private boolean mIsRunning;
+    private boolean mIsNetworkProviderAvailable;
+    private boolean mIsGpsProviderAvailable;
+
+    /**
+     * Constructor
+     * @param nativeObject The native object to which this object will report position updates and
+     *     errors.
+     */
+    public GeolocationService(long nativeObject) {
+        mNativeObject = nativeObject;
+        // Register newLocationAvailable with platform service.
+        ActivityThread thread = ActivityThread.systemMain();
+        Context context = thread.getApplication();
+        mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
+        if (mLocationManager == null) {
+            Log.e(TAG, "Could not get location manager.");
+        }
+     }
+
+    /**
+     * Start listening for location updates.
+     */
+    public void start() {
+        registerForLocationUpdates();
+        mIsRunning = true;
+    }
+
+    /**
+     * Stop listening for location updates.
+     */
+    public void stop() {
+        unregisterFromLocationUpdates();
+        mIsRunning = false;
+    }
+
+    /**
+     * Sets whether to use the GPS.
+     * @param enable Whether to use the GPS.
+     */
+    public void setEnableGps(boolean enable) {
+        if (mIsGpsEnabled != enable) {
+            mIsGpsEnabled = enable;
+            if (mIsRunning) {
+                // There's no way to unregister from a single provider, so we can
+                // only unregister from all, then reregister with all but the GPS.
+                unregisterFromLocationUpdates();
+                registerForLocationUpdates();
+            }
+        }
+    }
+
+    /**
+     * LocationListener implementation.
+     * Called when the location has changed.
+     * @param location The new location, as a Location object.
+     */
+    public void onLocationChanged(Location location) {
+        // Callbacks from the system location sevice are queued to this thread, so it's possible
+        // that we receive callbacks after unregistering. At this point, the native object will no
+        // longer exist.
+        if (mIsRunning) {
+            nativeNewLocationAvailable(mNativeObject, location);
+        }
+    }
+
+    /**
+     * LocationListener implementation.
+     * Called when the provider status changes.
+     * @param provider The name of the provider.
+     * @param status The new status of the provider.
+     * @param extras an optional Bundle with provider specific data.
+     */
+    public void onStatusChanged(String providerName, int status, Bundle extras) {
+        boolean isAvailable = (status == LocationProvider.AVAILABLE);
+        if (LocationManager.NETWORK_PROVIDER.equals(providerName)) {
+            mIsNetworkProviderAvailable = isAvailable;
+        } else if (LocationManager.GPS_PROVIDER.equals(providerName)) {
+            mIsGpsProviderAvailable = isAvailable;
+        }
+        maybeReportError("The last location provider is no longer available");
+    }
+
+    /**
+     * LocationListener implementation.
+     * Called when the provider is enabled.
+     * @param provider The name of the location provider that is now enabled.
+     */
+    public void onProviderEnabled(String providerName) {
+        // No need to notify the native side. It's enough to start sending
+        // valid position fixes again.
+        if (LocationManager.NETWORK_PROVIDER.equals(providerName)) {
+            mIsNetworkProviderAvailable = true;
+        } else if (LocationManager.GPS_PROVIDER.equals(providerName)) {
+            mIsGpsProviderAvailable = true;
+        }
+    }
+
+    /**
+     * LocationListener implementation.
+     * Called when the provider is disabled.
+     * @param provider The name of the location provider that is now disabled.
+     */
+    public void onProviderDisabled(String providerName) {
+        if (LocationManager.NETWORK_PROVIDER.equals(providerName)) {
+            mIsNetworkProviderAvailable = false;
+        } else if (LocationManager.GPS_PROVIDER.equals(providerName)) {
+            mIsGpsProviderAvailable = false;
+        }
+        maybeReportError("The last location provider was disabled");
+    }
+
+    /**
+     * Registers this object with the location service.
+     */
+    private void registerForLocationUpdates() {
+        mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
+        mIsNetworkProviderAvailable = true;
+        if (mIsGpsEnabled) {
+            mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
+            mIsGpsProviderAvailable = true;
+        }
+    }
+
+    /**
+     * Unregisters this object from the location service.
+     */
+    private void unregisterFromLocationUpdates() {
+        mLocationManager.removeUpdates(this);
+    }
+
+    /**
+     * Reports an error if neither the network nor the GPS provider is available.
+     */
+    private void maybeReportError(String message) {
+        // Callbacks from the system location sevice are queued to this thread, so it's possible
+        // that we receive callbacks after unregistering. At this point, the native object will no
+        // longer exist.
+        if (mIsRunning && !mIsNetworkProviderAvailable && !mIsGpsProviderAvailable) {
+            nativeNewErrorAvailable(mNativeObject, message);
+        }
+    }
+
+    // Native functions
+    private static native void nativeNewLocationAvailable(long nativeObject, Location location);
+    private static native void nativeNewErrorAvailable(long nativeObject, String message);
+}
diff --git a/libs/audioflinger/A2dpAudioInterface.cpp b/libs/audioflinger/A2dpAudioInterface.cpp
index 20db8a5..57a29f2 100644
--- a/libs/audioflinger/A2dpAudioInterface.cpp
+++ b/libs/audioflinger/A2dpAudioInterface.cpp
@@ -204,7 +204,7 @@
     mFd(-1), mStandby(true), mStartCount(0), mRetryCount(0), mData(NULL),
     // assume BT enabled to start, this is safe because its only the
     // enabled->disabled transition we are worried about
-    mBluetoothEnabled(true), mDevice(0)
+    mBluetoothEnabled(true), mDevice(0), mClosing(false)
 {
     // use any address by default
     strcpy(mA2dpAddress, "00:00:00:00:00:00");
@@ -258,7 +258,7 @@
     size_t remaining = bytes;
     status_t status = -1;
 
-    if (!mBluetoothEnabled) {
+    if (!mBluetoothEnabled || mClosing) {
         LOGW("A2dpAudioStreamOut::write(), but bluetooth disabled");
         goto Error;
     }
@@ -307,6 +307,11 @@
 {
     int result = 0;
 
+    if (mClosing) {
+        LOGV("Ignore standby, closing");
+        return result;
+    }
+
     Mutex::Autolock lock(mLock);
 
     if (!mStandby) {
@@ -335,6 +340,11 @@
         }
         param.remove(key);
     }
+    key = String8("closing");
+    if (param.get(key, value) == NO_ERROR) {
+        mClosing = (value == "true");
+        param.remove(key);
+    }
     key = AudioParameter::keyRouting;
     if (param.getInt(key, device) == NO_ERROR) {
         if (AudioSystem::isA2dpDevice((AudioSystem::audio_devices)device)) {
diff --git a/libs/audioflinger/A2dpAudioInterface.h b/libs/audioflinger/A2dpAudioInterface.h
index d6709e2..35a6e11 100644
--- a/libs/audioflinger/A2dpAudioInterface.h
+++ b/libs/audioflinger/A2dpAudioInterface.h
@@ -112,6 +112,7 @@
                 Mutex       mLock;
                 bool        mBluetoothEnabled;
                 uint32_t    mDevice;
+                bool        mClosing;
     };
 
     friend class A2dpAudioStreamOut;